libzapitu 1.0.0-alpha.13 → 1.0.0-alpha.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/Socket/messages-recv.js +26 -0
- package/lib/Socket/socket.js +24 -0
- package/lib/Types/Events.d.ts +19 -0
- package/package.json +1 -1
|
@@ -444,6 +444,32 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
444
444
|
});
|
|
445
445
|
authState.creds.registered = true;
|
|
446
446
|
ev.emit('creds.update', authState.creds);
|
|
447
|
+
break;
|
|
448
|
+
case 'passkey_prologue_request': {
|
|
449
|
+
const optsNode = (0, WABinary_1.getBinaryNodeChild)(node, 'passkey_request_options');
|
|
450
|
+
let publicKey;
|
|
451
|
+
const content = optsNode === null || optsNode === void 0 ? void 0 : optsNode.content;
|
|
452
|
+
if (content instanceof Buffer || content instanceof Uint8Array) {
|
|
453
|
+
publicKey = content;
|
|
454
|
+
}
|
|
455
|
+
else if (typeof content === 'string') {
|
|
456
|
+
try {
|
|
457
|
+
publicKey = JSON.parse(content);
|
|
458
|
+
}
|
|
459
|
+
catch (_d) {
|
|
460
|
+
publicKey = Buffer.from(content, 'utf-8');
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
ev.emit('pair.passkey.request', { publicKey, raw: node });
|
|
464
|
+
logger.info('passkey_prologue_request — use WhatsApp Web + extensão');
|
|
465
|
+
break;
|
|
466
|
+
}
|
|
467
|
+
case 'crsc_continuation': {
|
|
468
|
+
const primaryNode = (0, WABinary_1.getBinaryNodeChild)(node, 'primary_ephemeral_identity');
|
|
469
|
+
ev.emit('pair.passkey.confirmation', { raw: node });
|
|
470
|
+
logger.info({ hasPrimary: !!primaryNode }, 'passkey continuation (crsc_continuation)');
|
|
471
|
+
break;
|
|
472
|
+
}
|
|
447
473
|
}
|
|
448
474
|
if (Object.keys(result).length) {
|
|
449
475
|
return result;
|
package/lib/Socket/socket.js
CHANGED
|
@@ -467,6 +467,30 @@ const makeSocket = (config) => {
|
|
|
467
467
|
await sendNode(iq);
|
|
468
468
|
const pairDeviceNode = (0, WABinary_1.getBinaryNodeChild)(stanza, 'pair-device');
|
|
469
469
|
const refNodes = (0, WABinary_1.getBinaryNodeChildren)(pairDeviceNode, 'ref');
|
|
470
|
+
const passkeyOpts = (0, WABinary_1.getBinaryNodeChild)(pairDeviceNode, 'passkey_request_options');
|
|
471
|
+
const passkeyNode = passkeyOpts || (0, WABinary_1.getBinaryNodeChild)(pairDeviceNode, 'passkey');
|
|
472
|
+
if (passkeyNode && !refNodes.length) {
|
|
473
|
+
if (qrTimer) {
|
|
474
|
+
clearTimeout(qrTimer);
|
|
475
|
+
qrTimer = undefined;
|
|
476
|
+
}
|
|
477
|
+
let publicKey;
|
|
478
|
+
const content = passkeyNode.content;
|
|
479
|
+
if (content instanceof Buffer || content instanceof Uint8Array) {
|
|
480
|
+
publicKey = content;
|
|
481
|
+
}
|
|
482
|
+
else if (typeof content === 'string') {
|
|
483
|
+
try {
|
|
484
|
+
publicKey = JSON.parse(content);
|
|
485
|
+
}
|
|
486
|
+
catch (_a) {
|
|
487
|
+
publicKey = Buffer.from(content, 'utf-8');
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
ev.emit('pair.passkey.request', { publicKey, raw: passkeyNode });
|
|
491
|
+
logger.info('pair-device passkey request — use WhatsApp Web + extensão');
|
|
492
|
+
return;
|
|
493
|
+
}
|
|
470
494
|
const noiseKeyB64 = Buffer.from(creds.noiseKey.public).toString('base64');
|
|
471
495
|
const identityKeyB64 = Buffer.from(creds.signedIdentityKey.public).toString('base64');
|
|
472
496
|
const advB64 = creds.advSecretKey;
|
package/lib/Types/Events.d.ts
CHANGED
|
@@ -9,6 +9,21 @@ import { Label } from './Label';
|
|
|
9
9
|
import { LabelAssociation } from './LabelAssociation';
|
|
10
10
|
import { MessageUpsertType, MessageUserReceiptUpdate, WAMessage, WAMessageKey, WAMessageUpdate } from './Message';
|
|
11
11
|
import { ConnectionState } from './State';
|
|
12
|
+
import type { BinaryNode } from '../WABinary';
|
|
13
|
+
export type PairPasskeyRequestEvent = {
|
|
14
|
+
publicKey?: Uint8Array | Record<string, unknown>;
|
|
15
|
+
raw?: BinaryNode;
|
|
16
|
+
};
|
|
17
|
+
export type PairPasskeyConfirmationEvent = {
|
|
18
|
+
code?: string;
|
|
19
|
+
skipHandoffUX?: boolean;
|
|
20
|
+
raw?: BinaryNode;
|
|
21
|
+
};
|
|
22
|
+
export type PairPasskeyErrorEvent = {
|
|
23
|
+
error: Error;
|
|
24
|
+
continuation?: boolean;
|
|
25
|
+
raw?: BinaryNode;
|
|
26
|
+
};
|
|
12
27
|
export type BaileysEventMap = {
|
|
13
28
|
/** connection state has been updated -- WS closed, opened, connecting etc. */
|
|
14
29
|
'connection.update': Partial<ConnectionState>;
|
|
@@ -130,6 +145,10 @@ export type BaileysEventMap = {
|
|
|
130
145
|
id: string;
|
|
131
146
|
update: any;
|
|
132
147
|
};
|
|
148
|
+
/** Passkey pairing (shortcake) — account requires WebAuthn in browser, not QR */
|
|
149
|
+
'pair.passkey.request': PairPasskeyRequestEvent;
|
|
150
|
+
'pair.passkey.confirmation': PairPasskeyConfirmationEvent;
|
|
151
|
+
'pair.passkey.error': PairPasskeyErrorEvent;
|
|
133
152
|
};
|
|
134
153
|
export type BufferedEventData = {
|
|
135
154
|
historySets: {
|