zapo-js 1.3.0 → 1.4.0
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/dist/auth/WaAuthClient.d.ts +15 -0
- package/dist/auth/WaAuthClient.js +47 -0
- package/dist/auth/pairing/WaShortcakeFlow.d.ts +93 -0
- package/dist/auth/pairing/WaShortcakeFlow.js +210 -0
- package/dist/auth/pairing/pairing-code-crypto.d.ts +1 -0
- package/dist/auth/pairing/pairing-code-crypto.js +3 -2
- package/dist/auth/pairing/shortcake-crypto.d.ts +59 -0
- package/dist/auth/pairing/shortcake-crypto.js +106 -0
- package/dist/client/WaClientFactory.js +3 -1
- package/dist/client/coordinators/WaRetryCoordinator.js +1 -0
- package/dist/client/types.d.ts +19 -0
- package/dist/esm/auth/WaAuthClient.js +48 -1
- package/dist/esm/auth/pairing/WaShortcakeFlow.js +206 -0
- package/dist/esm/auth/pairing/pairing-code-crypto.js +2 -2
- package/dist/esm/auth/pairing/shortcake-crypto.js +99 -0
- package/dist/esm/client/WaClientFactory.js +3 -1
- package/dist/esm/client/coordinators/WaRetryCoordinator.js +1 -0
- package/dist/esm/protocol/nodes.js +2 -0
- package/dist/esm/protocol/notification.js +3 -1
- package/dist/esm/retry/replay.js +4 -12
- package/dist/esm/transport/node/builders/shortcake.js +50 -0
- package/dist/esm/transport/noise/WaClientPayload.js +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/protocol/nodes.d.ts +2 -0
- package/dist/protocol/nodes.js +2 -0
- package/dist/protocol/notification.d.ts +2 -0
- package/dist/protocol/notification.js +3 -1
- package/dist/retry/replay.d.ts +1 -0
- package/dist/retry/replay.js +4 -12
- package/dist/transport/node/builders/shortcake.d.ts +19 -0
- package/dist/transport/node/builders/shortcake.js +57 -0
- package/dist/transport/noise/WaClientPayload.d.ts +2 -0
- package/dist/transport/noise/WaClientPayload.js +1 -0
- package/package.json +1 -1
package/dist/retry/replay.js
CHANGED
|
@@ -88,9 +88,9 @@ class WaRetryReplayService {
|
|
|
88
88
|
resolveSignedDeviceIdentity(context) {
|
|
89
89
|
const signedIdentity = this.options.getCurrentCredentials()?.signedIdentity;
|
|
90
90
|
if (!signedIdentity) {
|
|
91
|
-
this.options.
|
|
92
|
-
context
|
|
93
|
-
}
|
|
91
|
+
if (!this.options.isMobilePrimary?.()) {
|
|
92
|
+
this.options.logger.warn('retry request missing signed identity for pkmsg envelope', { context });
|
|
93
|
+
}
|
|
94
94
|
return undefined;
|
|
95
95
|
}
|
|
96
96
|
return _proto_1.proto.ADVSignedDeviceIdentity.encode(signedIdentity).finish();
|
|
@@ -182,15 +182,7 @@ class WaRetryReplayService {
|
|
|
182
182
|
logContext: 'group'
|
|
183
183
|
})) ?? payload.plaintext;
|
|
184
184
|
const encrypted = await this.options.signalProtocol.encryptMessage(requesterAddress, plaintext);
|
|
185
|
-
|
|
186
|
-
if (encrypted.type === 'pkmsg') {
|
|
187
|
-
const signedIdentity = this.options.getCurrentCredentials()?.signedIdentity;
|
|
188
|
-
if (!signedIdentity) {
|
|
189
|
-
this.options.logger.warn('retry request rejected: missing signed identity for pkmsg group retry');
|
|
190
|
-
return 'ineligible';
|
|
191
|
-
}
|
|
192
|
-
deviceIdentity = _proto_1.proto.ADVSignedDeviceIdentity.encode(signedIdentity).finish();
|
|
193
|
-
}
|
|
185
|
+
const deviceIdentity = encrypted.type === 'pkmsg' ? this.resolveSignedDeviceIdentity('group') : undefined;
|
|
194
186
|
const isStatus = (0, jid_1.isStatusBroadcastJid)(payload.to);
|
|
195
187
|
const metaAttrs = {};
|
|
196
188
|
if (isStatus) {
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { BinaryNode } from '../../types';
|
|
2
|
+
/** `<iq type="get" xmlns="md"><passkey_request_options/></iq>` */
|
|
3
|
+
export declare function buildGetPasskeyRequestOptionsRequestNode(): BinaryNode;
|
|
4
|
+
/** `<iq type="get" xmlns="md"><ref/></iq>` */
|
|
5
|
+
export declare function buildShortcakeGetRefRequestNode(): BinaryNode;
|
|
6
|
+
/**
|
|
7
|
+
* `<iq type="set" xmlns="md"><passkey_prologue><credential_id/><webauthn_assertion/>`
|
|
8
|
+
* `<prologue_payload/>[<pairing_handoff_proof/>]</passkey_prologue></iq>`
|
|
9
|
+
*/
|
|
10
|
+
export declare function buildSetPasskeyPrologueRequestNode(args: {
|
|
11
|
+
readonly credentialId: Uint8Array;
|
|
12
|
+
readonly webauthnAssertion: Uint8Array;
|
|
13
|
+
readonly prologuePayload: Uint8Array;
|
|
14
|
+
readonly pairingHandoffProof?: Uint8Array;
|
|
15
|
+
}): BinaryNode;
|
|
16
|
+
/** `<iq type="set" xmlns="md"><companion_nonce/></iq>` */
|
|
17
|
+
export declare function buildSetCompanionNonceRequestNode(companionNonce: Uint8Array): BinaryNode;
|
|
18
|
+
/** `<iq type="set" xmlns="md"><encrypted_pairing_request/></iq>` */
|
|
19
|
+
export declare function buildSetEncryptedPairingRequestRequestNode(encryptedPairingRequest: Uint8Array): BinaryNode;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildGetPasskeyRequestOptionsRequestNode = buildGetPasskeyRequestOptionsRequestNode;
|
|
4
|
+
exports.buildShortcakeGetRefRequestNode = buildShortcakeGetRefRequestNode;
|
|
5
|
+
exports.buildSetPasskeyPrologueRequestNode = buildSetPasskeyPrologueRequestNode;
|
|
6
|
+
exports.buildSetCompanionNonceRequestNode = buildSetCompanionNonceRequestNode;
|
|
7
|
+
exports.buildSetEncryptedPairingRequestRequestNode = buildSetEncryptedPairingRequestRequestNode;
|
|
8
|
+
const constants_1 = require("../../../protocol/constants");
|
|
9
|
+
const query_1 = require("../../node/query");
|
|
10
|
+
/**
|
|
11
|
+
* IQ builders for the WhatsApp "Shortcake" companion-linking protocol
|
|
12
|
+
* (`xmlns="md"`). Wire shapes mirror the official client's
|
|
13
|
+
* `WASmaxOutMd…Request` builders. The stanza `id` is assigned by the socket
|
|
14
|
+
* query layer, matching the other pairing builders.
|
|
15
|
+
*/
|
|
16
|
+
function mdIq(type, content) {
|
|
17
|
+
return (0, query_1.buildIqNode)(type, constants_1.WA_DEFAULTS.HOST_DOMAIN, constants_1.WA_XMLNS.MD, content);
|
|
18
|
+
}
|
|
19
|
+
/** `<iq type="get" xmlns="md"><passkey_request_options/></iq>` */
|
|
20
|
+
function buildGetPasskeyRequestOptionsRequestNode() {
|
|
21
|
+
return mdIq(constants_1.WA_IQ_TYPES.GET, [
|
|
22
|
+
{ tag: constants_1.WA_NODE_TAGS.PASSKEY_REQUEST_OPTIONS, attrs: {}, content: undefined }
|
|
23
|
+
]);
|
|
24
|
+
}
|
|
25
|
+
/** `<iq type="get" xmlns="md"><ref/></iq>` */
|
|
26
|
+
function buildShortcakeGetRefRequestNode() {
|
|
27
|
+
return mdIq(constants_1.WA_IQ_TYPES.GET, [{ tag: constants_1.WA_NODE_TAGS.REF, attrs: {}, content: undefined }]);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* `<iq type="set" xmlns="md"><passkey_prologue><credential_id/><webauthn_assertion/>`
|
|
31
|
+
* `<prologue_payload/>[<pairing_handoff_proof/>]</passkey_prologue></iq>`
|
|
32
|
+
*/
|
|
33
|
+
function buildSetPasskeyPrologueRequestNode(args) {
|
|
34
|
+
const children = [
|
|
35
|
+
{ tag: 'credential_id', attrs: {}, content: args.credentialId },
|
|
36
|
+
{ tag: 'webauthn_assertion', attrs: {}, content: args.webauthnAssertion },
|
|
37
|
+
{ tag: 'prologue_payload', attrs: {}, content: args.prologuePayload }
|
|
38
|
+
];
|
|
39
|
+
if (args.pairingHandoffProof) {
|
|
40
|
+
children.push({
|
|
41
|
+
tag: 'pairing_handoff_proof',
|
|
42
|
+
attrs: {},
|
|
43
|
+
content: args.pairingHandoffProof
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
return mdIq(constants_1.WA_IQ_TYPES.SET, [{ tag: 'passkey_prologue', attrs: {}, content: children }]);
|
|
47
|
+
}
|
|
48
|
+
/** `<iq type="set" xmlns="md"><companion_nonce/></iq>` */
|
|
49
|
+
function buildSetCompanionNonceRequestNode(companionNonce) {
|
|
50
|
+
return mdIq(constants_1.WA_IQ_TYPES.SET, [{ tag: 'companion_nonce', attrs: {}, content: companionNonce }]);
|
|
51
|
+
}
|
|
52
|
+
/** `<iq type="set" xmlns="md"><encrypted_pairing_request/></iq>` */
|
|
53
|
+
function buildSetEncryptedPairingRequestRequestNode(encryptedPairingRequest) {
|
|
54
|
+
return mdIq(constants_1.WA_IQ_TYPES.SET, [
|
|
55
|
+
{ tag: 'encrypted_pairing_request', attrs: {}, content: encryptedPairingRequest }
|
|
56
|
+
]);
|
|
57
|
+
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { proto } from '../../proto';
|
|
1
2
|
import type { WaLoginPayloadConfig, WaRegistrationPayloadConfig } from '../noise/types';
|
|
3
|
+
export declare function resolveDevicePropsPlatformType(deviceBrowser?: string): proto.DeviceProps.PlatformType;
|
|
2
4
|
export declare function buildLoginPayload(config: WaLoginPayloadConfig): Uint8Array;
|
|
3
5
|
export declare function buildRegistrationPayload(config: WaRegistrationPayloadConfig): Uint8Array;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveDevicePropsPlatformType = resolveDevicePropsPlatformType;
|
|
3
4
|
exports.buildLoginPayload = buildLoginPayload;
|
|
4
5
|
exports.buildRegistrationPayload = buildRegistrationPayload;
|
|
5
6
|
const node_crypto_1 = require("node:crypto");
|