Skip to content

Commit bc72d11

Browse files
committed
refactor!: Renamed auth to conn
BREAKING CHANGE: Renamed auth to conn
1 parent 1dd64a2 commit bc72d11

19 files changed

+16
-34
lines changed

src/auth/eventEmitter.ts renamed to src/conn/eventEmitter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import Emittery from 'emittery';
1919

2020
import { AuthCode } from '.';
2121

22-
const debug = Debug('WA-JS:event:auth');
22+
const debug = Debug('WA-JS:event:conn');
2323

2424
export type UnsubscribeFn = () => void;
2525

@@ -31,7 +31,7 @@ export interface EventTypes {
3131

3232
export const eventEmitter = new Emittery<EventTypes, EventTypes>({
3333
debug: {
34-
name: 'AuthEvent',
34+
name: 'ConnEvent',
3535
enabled: debug.enabled,
3636
logger: (type, debugName, eventName, eventData) => {
3737
debug(eventName, eventData);
File renamed without changes.

src/auth/events/registerChangeEvent.ts renamed to src/conn/events/registerChangeEvent.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { Conn } from '../../whatsapp';
2121
import { getAuthCode } from '..';
2222
import { eventEmitter } from '../eventEmitter';
2323

24-
const debug = Debug('WA-JS:auth');
24+
const debug = Debug('WA-JS:conn');
2525

2626
webpack.onInjected(() => registerChangeEvent());
2727

src/auth/events/registerIdleEvent.ts renamed to src/conn/events/registerIdleEvent.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { State } from '../../whatsapp';
2121
import { isIdle } from '..';
2222
import { eventEmitter } from '../eventEmitter';
2323

24-
const debug = Debug('WA-JS:auth');
24+
const debug = Debug('WA-JS:conn');
2525

2626
webpack.onInjected(() => registerIdleEvent());
2727

src/auth/events/registerLogoutEvent.ts renamed to src/conn/events/registerLogoutEvent.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import * as webpack from '../../webpack';
2020
import { Cmd } from '../../whatsapp';
2121
import { eventEmitter } from '../eventEmitter';
2222

23-
const debug = Debug('WA-JS:auth');
23+
const debug = Debug('WA-JS:conn');
2424

2525
webpack.onInjected(() => registerLogoutEvent());
2626

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/auth/functions/setMultiDevice.ts renamed to src/conn/functions/setMultiDevice.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { Cmd } from '../../whatsapp';
2020
* @param md If it's true, WhatsApp WEB will switch to MD. If it's false, WhatsApp WEB will switch to Legacy.
2121
* @example
2222
* ```javascript
23-
* WPP.auth.setMultiDevice(true)
23+
* WPP.conn.setMultiDevice(true)
2424
* ```
2525
*/
2626
export function setMultiDevice(md = true): boolean {
File renamed without changes.
File renamed without changes.

src/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,13 @@ export { isInjected, isReady } from './webpack';
2828

2929
export * as config from './config';
3030

31-
export * as auth from './auth';
3231
export * as blocklist from './blocklist';
3332
export * as chat from './chat';
33+
export * as conn from './conn';
34+
/**
35+
* @deprecated
36+
*/
37+
export * as auth from './conn';
3438
export * as contact from './contact';
3539
export * as group from './group';
3640
export * as labels from './labels';

src/internal.ts

Lines changed: 0 additions & 22 deletions
This file was deleted.

tests/check-auth.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ test('chech is not logged test', async ({ page }) => {
2121

2222
await expect(title).toHaveText('WhatsApp');
2323

24-
const isAuthenticated = await page.evaluate(() => WPP.auth.isAuthenticated());
24+
const isAuthenticated = await page.evaluate(() => WPP.conn.isAuthenticated());
2525

2626
expect(isAuthenticated).toBe(false);
2727
});
@@ -32,7 +32,7 @@ test('chech is logged test', async ({ loggedPage: cleanPage }) => {
3232
await expect(title).toHaveText('WhatsApp');
3333

3434
const isAuthenticated = await cleanPage.evaluate(() =>
35-
WPP.auth.isAuthenticated()
35+
WPP.conn.isAuthenticated()
3636
);
3737

3838
expect(isAuthenticated).toBe(true);

tests/prepare.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ test('basic setup', async ({ loggedPage }) => {
2222
await expect(title).toHaveText('WhatsApp');
2323

2424
let isAuthenticated = await loggedPage.evaluate(() =>
25-
WPP.auth.isAuthenticated()
25+
WPP.conn.isAuthenticated()
2626
);
2727

2828
if (isAuthenticated) {
@@ -32,9 +32,9 @@ test('basic setup', async ({ loggedPage }) => {
3232

3333
expect(isAuthenticated).toBe(false);
3434

35-
await loggedPage.waitForFunction(() => WPP.auth.isAuthenticated());
35+
await loggedPage.waitForFunction(() => WPP.conn.isAuthenticated());
3636

37-
isAuthenticated = await loggedPage.evaluate(() => WPP.auth.isAuthenticated());
37+
isAuthenticated = await loggedPage.evaluate(() => WPP.conn.isAuthenticated());
3838

3939
expect(isAuthenticated).toBe(true);
4040
});

0 commit comments

Comments
 (0)