@zapo-js/fake-server 0.3.0 → 1.1.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/README.md +96 -8
- package/dist/api/AppStateSyncManager.d.ts +0 -1
- package/dist/api/AppStateSyncManager.js +0 -1
- package/dist/api/FakePairingDriver.d.ts +0 -1
- package/dist/api/FakePairingDriver.js +0 -1
- package/dist/api/FakePeer.d.ts +77 -4
- package/dist/api/FakePeer.js +208 -2
- package/dist/api/FakeServerSession.d.ts +67 -0
- package/dist/api/FakeServerSession.js +293 -0
- package/dist/api/FakeWaServer.d.ts +77 -31
- package/dist/api/FakeWaServer.js +140 -259
- package/dist/api/PreKeyDispenser.d.ts +0 -1
- package/dist/api/PreKeyDispenser.js +0 -1
- package/dist/api/Scenario.d.ts +0 -1
- package/dist/api/Scenario.js +0 -1
- package/dist/api/ServerRegistries.d.ts +0 -1
- package/dist/api/ServerRegistries.js +0 -1
- package/dist/api/iq-handlers.d.ts +1 -1
- package/dist/api/iq-handlers.js +23 -1
- package/dist/{cli.d.ts → bin.d.ts} +0 -1
- package/dist/bin.js +296 -0
- package/dist/esm/api/AppStateSyncManager.js +146 -0
- package/dist/esm/api/FakePairingDriver.js +31 -0
- package/dist/esm/api/FakePeer.js +610 -0
- package/dist/esm/api/FakeServerSession.js +287 -0
- package/dist/esm/api/FakeWaServer.js +528 -0
- package/dist/esm/api/PreKeyDispenser.js +93 -0
- package/dist/esm/api/Scenario.js +32 -0
- package/dist/esm/api/ServerRegistries.js +261 -0
- package/dist/esm/api/iq-handlers.js +515 -0
- package/dist/{cli.js → esm/bin.js} +70 -25
- package/dist/esm/index.js +26 -0
- package/dist/esm/infra/WaFakeConnection.js +49 -0
- package/dist/esm/infra/WaFakeConnectionPipeline.js +235 -0
- package/dist/esm/infra/WaFakeFrameSocket.js +117 -0
- package/dist/esm/infra/WaFakeMediaHttpsServer.js +126 -0
- package/dist/esm/infra/WaFakeNoiseHandshake.js +67 -0
- package/dist/esm/infra/WaFakeTransport.js +31 -0
- package/dist/esm/infra/WaFakeWsServer.js +96 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/protocol/auth/cert-chain.js +50 -0
- package/dist/esm/protocol/auth/client-payload-validate.js +55 -0
- package/dist/esm/protocol/auth/fake-primary-device.js +47 -0
- package/dist/esm/protocol/auth/pair-device.js +87 -0
- package/dist/esm/protocol/auth/success-node.js +26 -0
- package/dist/esm/protocol/iq/abprops.js +30 -0
- package/dist/esm/protocol/iq/appstate-sync.js +146 -0
- package/dist/esm/protocol/iq/business.js +59 -0
- package/dist/esm/protocol/iq/dirty-bits.js +19 -0
- package/dist/esm/protocol/iq/group-ops.js +154 -0
- package/dist/esm/protocol/iq/newsletter.js +14 -0
- package/dist/esm/protocol/iq/prekey-fetch.js +88 -0
- package/dist/esm/protocol/iq/privacy-token.js +26 -0
- package/dist/esm/protocol/iq/privacy.js +123 -0
- package/dist/esm/protocol/iq/profile.js +72 -0
- package/dist/esm/protocol/iq/router.js +117 -0
- package/dist/esm/protocol/iq/usync.js +64 -0
- package/dist/esm/protocol/push/app-state-key-share.js +26 -0
- package/dist/esm/protocol/push/call-failure.js +27 -0
- package/dist/esm/protocol/push/chatstate.js +23 -0
- package/dist/esm/protocol/push/error-stanza.js +13 -0
- package/dist/esm/protocol/push/history-sync.js +111 -0
- package/dist/esm/protocol/push/message.js +38 -0
- package/dist/esm/protocol/push/notification.js +29 -0
- package/dist/esm/protocol/push/presence.js +14 -0
- package/dist/esm/protocol/push/receipt.js +21 -0
- package/dist/esm/protocol/signal/fake-app-state-crypto.js +196 -0
- package/dist/esm/protocol/signal/fake-peer-double-ratchet.js +398 -0
- package/dist/esm/protocol/signal/fake-peer-group-recv-session.js +120 -0
- package/dist/esm/protocol/signal/fake-peer-identity.js +8 -0
- package/dist/esm/protocol/signal/fake-peer-key-bundle.js +25 -0
- package/dist/esm/protocol/signal/fake-sender-key.js +83 -0
- package/dist/esm/protocol/signal/prekey-upload.js +107 -0
- package/dist/esm/protocol/stream/stream-error.js +56 -0
- package/dist/esm/state/fake-app-state-collection.js +134 -0
- package/dist/esm/state/fake-media-store.js +53 -0
- package/dist/esm/transport/codec.js +8 -0
- package/dist/esm/transport/crypto.js +8 -0
- package/dist/esm/transport/protos.js +7 -0
- package/dist/esm/transport/util.js +8 -0
- package/dist/index.d.ts +2 -3
- package/dist/index.js +2 -2
- package/dist/infra/WaFakeConnection.d.ts +0 -1
- package/dist/infra/WaFakeConnection.js +0 -1
- package/dist/infra/WaFakeConnectionPipeline.d.ts +10 -3
- package/dist/infra/WaFakeConnectionPipeline.js +47 -32
- package/dist/infra/WaFakeFrameSocket.d.ts +0 -1
- package/dist/infra/WaFakeFrameSocket.js +0 -1
- package/dist/infra/WaFakeMediaHttpsServer.d.ts +0 -1
- package/dist/infra/WaFakeMediaHttpsServer.js +0 -1
- package/dist/infra/WaFakeNoiseHandshake.d.ts +8 -10
- package/dist/infra/WaFakeNoiseHandshake.js +19 -24
- package/dist/infra/WaFakeTransport.d.ts +2 -4
- package/dist/infra/WaFakeTransport.js +2 -1
- package/dist/infra/WaFakeWsServer.d.ts +0 -1
- package/dist/infra/WaFakeWsServer.js +0 -1
- package/dist/protocol/auth/cert-chain.d.ts +4 -1
- package/dist/protocol/auth/cert-chain.js +13 -3
- package/dist/protocol/auth/client-payload-validate.d.ts +0 -1
- package/dist/protocol/auth/client-payload-validate.js +0 -1
- package/dist/protocol/auth/fake-primary-device.d.ts +0 -1
- package/dist/protocol/auth/fake-primary-device.js +1 -3
- package/dist/protocol/auth/pair-device.d.ts +0 -1
- package/dist/protocol/auth/pair-device.js +4 -16
- package/dist/protocol/auth/success-node.d.ts +0 -1
- package/dist/protocol/auth/success-node.js +0 -1
- package/dist/protocol/iq/abprops.d.ts +0 -1
- package/dist/protocol/iq/abprops.js +0 -1
- package/dist/protocol/iq/appstate-sync.d.ts +0 -1
- package/dist/protocol/iq/appstate-sync.js +0 -1
- package/dist/protocol/iq/business.d.ts +0 -1
- package/dist/protocol/iq/business.js +0 -1
- package/dist/protocol/iq/dirty-bits.d.ts +0 -1
- package/dist/protocol/iq/dirty-bits.js +0 -1
- package/dist/protocol/iq/group-ops.d.ts +0 -1
- package/dist/protocol/iq/group-ops.js +0 -1
- package/dist/protocol/iq/newsletter.d.ts +0 -1
- package/dist/protocol/iq/newsletter.js +0 -1
- package/dist/protocol/iq/prekey-fetch.d.ts +0 -1
- package/dist/protocol/iq/prekey-fetch.js +0 -1
- package/dist/protocol/iq/privacy-token.d.ts +0 -1
- package/dist/protocol/iq/privacy-token.js +0 -1
- package/dist/protocol/iq/privacy.d.ts +0 -1
- package/dist/protocol/iq/privacy.js +15 -16
- package/dist/protocol/iq/profile.d.ts +0 -1
- package/dist/protocol/iq/profile.js +0 -1
- package/dist/protocol/iq/router.d.ts +7 -2
- package/dist/protocol/iq/router.js +8 -3
- package/dist/protocol/iq/usync.d.ts +0 -1
- package/dist/protocol/iq/usync.js +0 -1
- package/dist/protocol/push/app-state-key-share.d.ts +0 -1
- package/dist/protocol/push/app-state-key-share.js +0 -1
- package/dist/protocol/push/call-failure.d.ts +0 -1
- package/dist/protocol/push/call-failure.js +0 -1
- package/dist/protocol/push/chatstate.d.ts +0 -1
- package/dist/protocol/push/chatstate.js +0 -1
- package/dist/protocol/push/error-stanza.d.ts +0 -1
- package/dist/protocol/push/error-stanza.js +0 -1
- package/dist/protocol/push/history-sync.d.ts +0 -1
- package/dist/protocol/push/history-sync.js +0 -1
- package/dist/protocol/push/message.d.ts +0 -1
- package/dist/protocol/push/message.js +0 -1
- package/dist/protocol/push/notification.d.ts +0 -1
- package/dist/protocol/push/notification.js +0 -1
- package/dist/protocol/push/presence.d.ts +0 -1
- package/dist/protocol/push/presence.js +0 -1
- package/dist/protocol/push/receipt.d.ts +0 -1
- package/dist/protocol/push/receipt.js +0 -1
- package/dist/protocol/signal/fake-app-state-crypto.d.ts +7 -9
- package/dist/protocol/signal/fake-app-state-crypto.js +31 -33
- package/dist/protocol/signal/fake-peer-double-ratchet.d.ts +0 -1
- package/dist/protocol/signal/fake-peer-double-ratchet.js +23 -28
- package/dist/protocol/signal/fake-peer-group-recv-session.d.ts +0 -1
- package/dist/protocol/signal/fake-peer-group-recv-session.js +6 -10
- package/dist/protocol/signal/fake-peer-identity.d.ts +0 -1
- package/dist/protocol/signal/fake-peer-identity.js +0 -1
- package/dist/protocol/signal/fake-peer-key-bundle.d.ts +0 -1
- package/dist/protocol/signal/fake-peer-key-bundle.js +0 -1
- package/dist/protocol/signal/fake-sender-key.d.ts +0 -1
- package/dist/protocol/signal/fake-sender-key.js +5 -9
- package/dist/protocol/signal/prekey-upload.d.ts +0 -1
- package/dist/protocol/signal/prekey-upload.js +0 -1
- package/dist/protocol/stream/stream-error.d.ts +0 -1
- package/dist/protocol/stream/stream-error.js +0 -1
- package/dist/state/fake-app-state-collection.d.ts +0 -1
- package/dist/state/fake-app-state-collection.js +0 -1
- package/dist/state/fake-media-store.d.ts +0 -1
- package/dist/state/fake-media-store.js +2 -2
- package/dist/transport/codec.d.ts +2 -3
- package/dist/transport/codec.js +2 -3
- package/dist/transport/crypto.d.ts +5 -7
- package/dist/transport/crypto.js +6 -11
- package/dist/transport/protos.d.ts +2 -4
- package/dist/transport/protos.js +2 -4
- package/dist/transport/util.d.ts +8 -0
- package/dist/transport/util.js +16 -0
- package/package.json +26 -6
- package/dist/api/AppStateSyncManager.d.ts.map +0 -1
- package/dist/api/AppStateSyncManager.js.map +0 -1
- package/dist/api/FakePairingDriver.d.ts.map +0 -1
- package/dist/api/FakePairingDriver.js.map +0 -1
- package/dist/api/FakePeer.d.ts.map +0 -1
- package/dist/api/FakePeer.js.map +0 -1
- package/dist/api/FakeWaServer.d.ts.map +0 -1
- package/dist/api/FakeWaServer.js.map +0 -1
- package/dist/api/PreKeyDispenser.d.ts.map +0 -1
- package/dist/api/PreKeyDispenser.js.map +0 -1
- package/dist/api/Scenario.d.ts.map +0 -1
- package/dist/api/Scenario.js.map +0 -1
- package/dist/api/ServerRegistries.d.ts.map +0 -1
- package/dist/api/ServerRegistries.js.map +0 -1
- package/dist/api/iq-handlers.d.ts.map +0 -1
- package/dist/api/iq-handlers.js.map +0 -1
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/infra/WaFakeConnection.d.ts.map +0 -1
- package/dist/infra/WaFakeConnection.js.map +0 -1
- package/dist/infra/WaFakeConnectionPipeline.d.ts.map +0 -1
- package/dist/infra/WaFakeConnectionPipeline.js.map +0 -1
- package/dist/infra/WaFakeFrameSocket.d.ts.map +0 -1
- package/dist/infra/WaFakeFrameSocket.js.map +0 -1
- package/dist/infra/WaFakeMediaHttpsServer.d.ts.map +0 -1
- package/dist/infra/WaFakeMediaHttpsServer.js.map +0 -1
- package/dist/infra/WaFakeNoiseHandshake.d.ts.map +0 -1
- package/dist/infra/WaFakeNoiseHandshake.js.map +0 -1
- package/dist/infra/WaFakeTransport.d.ts.map +0 -1
- package/dist/infra/WaFakeTransport.js.map +0 -1
- package/dist/infra/WaFakeWsServer.d.ts.map +0 -1
- package/dist/infra/WaFakeWsServer.js.map +0 -1
- package/dist/protocol/auth/cert-chain.d.ts.map +0 -1
- package/dist/protocol/auth/cert-chain.js.map +0 -1
- package/dist/protocol/auth/client-payload-validate.d.ts.map +0 -1
- package/dist/protocol/auth/client-payload-validate.js.map +0 -1
- package/dist/protocol/auth/fake-primary-device.d.ts.map +0 -1
- package/dist/protocol/auth/fake-primary-device.js.map +0 -1
- package/dist/protocol/auth/pair-device.d.ts.map +0 -1
- package/dist/protocol/auth/pair-device.js.map +0 -1
- package/dist/protocol/auth/success-node.d.ts.map +0 -1
- package/dist/protocol/auth/success-node.js.map +0 -1
- package/dist/protocol/iq/abprops.d.ts.map +0 -1
- package/dist/protocol/iq/abprops.js.map +0 -1
- package/dist/protocol/iq/appstate-sync.d.ts.map +0 -1
- package/dist/protocol/iq/appstate-sync.js.map +0 -1
- package/dist/protocol/iq/business.d.ts.map +0 -1
- package/dist/protocol/iq/business.js.map +0 -1
- package/dist/protocol/iq/dirty-bits.d.ts.map +0 -1
- package/dist/protocol/iq/dirty-bits.js.map +0 -1
- package/dist/protocol/iq/group-ops.d.ts.map +0 -1
- package/dist/protocol/iq/group-ops.js.map +0 -1
- package/dist/protocol/iq/newsletter.d.ts.map +0 -1
- package/dist/protocol/iq/newsletter.js.map +0 -1
- package/dist/protocol/iq/prekey-fetch.d.ts.map +0 -1
- package/dist/protocol/iq/prekey-fetch.js.map +0 -1
- package/dist/protocol/iq/privacy-token.d.ts.map +0 -1
- package/dist/protocol/iq/privacy-token.js.map +0 -1
- package/dist/protocol/iq/privacy.d.ts.map +0 -1
- package/dist/protocol/iq/privacy.js.map +0 -1
- package/dist/protocol/iq/profile.d.ts.map +0 -1
- package/dist/protocol/iq/profile.js.map +0 -1
- package/dist/protocol/iq/router.d.ts.map +0 -1
- package/dist/protocol/iq/router.js.map +0 -1
- package/dist/protocol/iq/usync.d.ts.map +0 -1
- package/dist/protocol/iq/usync.js.map +0 -1
- package/dist/protocol/push/app-state-key-share.d.ts.map +0 -1
- package/dist/protocol/push/app-state-key-share.js.map +0 -1
- package/dist/protocol/push/call-failure.d.ts.map +0 -1
- package/dist/protocol/push/call-failure.js.map +0 -1
- package/dist/protocol/push/chatstate.d.ts.map +0 -1
- package/dist/protocol/push/chatstate.js.map +0 -1
- package/dist/protocol/push/error-stanza.d.ts.map +0 -1
- package/dist/protocol/push/error-stanza.js.map +0 -1
- package/dist/protocol/push/history-sync.d.ts.map +0 -1
- package/dist/protocol/push/history-sync.js.map +0 -1
- package/dist/protocol/push/message.d.ts.map +0 -1
- package/dist/protocol/push/message.js.map +0 -1
- package/dist/protocol/push/notification.d.ts.map +0 -1
- package/dist/protocol/push/notification.js.map +0 -1
- package/dist/protocol/push/presence.d.ts.map +0 -1
- package/dist/protocol/push/presence.js.map +0 -1
- package/dist/protocol/push/receipt.d.ts.map +0 -1
- package/dist/protocol/push/receipt.js.map +0 -1
- package/dist/protocol/signal/fake-app-state-crypto.d.ts.map +0 -1
- package/dist/protocol/signal/fake-app-state-crypto.js.map +0 -1
- package/dist/protocol/signal/fake-peer-double-ratchet.d.ts.map +0 -1
- package/dist/protocol/signal/fake-peer-double-ratchet.js.map +0 -1
- package/dist/protocol/signal/fake-peer-group-recv-session.d.ts.map +0 -1
- package/dist/protocol/signal/fake-peer-group-recv-session.js.map +0 -1
- package/dist/protocol/signal/fake-peer-identity.d.ts.map +0 -1
- package/dist/protocol/signal/fake-peer-identity.js.map +0 -1
- package/dist/protocol/signal/fake-peer-key-bundle.d.ts.map +0 -1
- package/dist/protocol/signal/fake-peer-key-bundle.js.map +0 -1
- package/dist/protocol/signal/fake-peer-recv-session.d.ts +0 -60
- package/dist/protocol/signal/fake-peer-recv-session.d.ts.map +0 -1
- package/dist/protocol/signal/fake-peer-recv-session.js +0 -284
- package/dist/protocol/signal/fake-peer-recv-session.js.map +0 -1
- package/dist/protocol/signal/fake-peer-session.d.ts +0 -87
- package/dist/protocol/signal/fake-peer-session.d.ts.map +0 -1
- package/dist/protocol/signal/fake-peer-session.js +0 -207
- package/dist/protocol/signal/fake-peer-session.js.map +0 -1
- package/dist/protocol/signal/fake-sender-key.d.ts.map +0 -1
- package/dist/protocol/signal/fake-sender-key.js.map +0 -1
- package/dist/protocol/signal/prekey-upload.d.ts.map +0 -1
- package/dist/protocol/signal/prekey-upload.js.map +0 -1
- package/dist/protocol/stream/stream-error.d.ts.map +0 -1
- package/dist/protocol/stream/stream-error.js.map +0 -1
- package/dist/state/fake-app-state-collection.d.ts.map +0 -1
- package/dist/state/fake-app-state-collection.js.map +0 -1
- package/dist/state/fake-media-store.d.ts.map +0 -1
- package/dist/state/fake-media-store.js.map +0 -1
- package/dist/transport/codec.d.ts.map +0 -1
- package/dist/transport/codec.js.map +0 -1
- package/dist/transport/crypto.d.ts.map +0 -1
- package/dist/transport/crypto.js.map +0 -1
- package/dist/transport/index.d.ts +0 -4
- package/dist/transport/index.d.ts.map +0 -1
- package/dist/transport/index.js +0 -20
- package/dist/transport/index.js.map +0 -1
- package/dist/transport/protos.d.ts.map +0 -1
- package/dist/transport/protos.js.map +0 -1
package/dist/api/FakeWaServer.js
CHANGED
|
@@ -1,126 +1,98 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FakeWaServer = void 0;
|
|
3
|
+
exports.FakeWaServer = exports.FakeServerSession = void 0;
|
|
4
4
|
const node_https_1 = require("node:https");
|
|
5
5
|
const WaFakeConnectionPipeline_1 = require("../infra/WaFakeConnectionPipeline");
|
|
6
6
|
const WaFakeMediaHttpsServer_1 = require("../infra/WaFakeMediaHttpsServer");
|
|
7
7
|
const WaFakeWsServer_1 = require("../infra/WaFakeWsServer");
|
|
8
8
|
const cert_chain_1 = require("../protocol/auth/cert-chain");
|
|
9
|
-
const router_1 = require("../protocol/iq/router");
|
|
10
9
|
const fake_media_store_1 = require("../state/fake-media-store");
|
|
11
10
|
const crypto_1 = require("../transport/crypto");
|
|
12
|
-
const AppStateSyncManager_1 = require("./AppStateSyncManager");
|
|
13
11
|
const FakePairingDriver_1 = require("./FakePairingDriver");
|
|
14
12
|
const FakePeer_1 = require("./FakePeer");
|
|
15
|
-
const
|
|
16
|
-
const PreKeyDispenser_1 = require("./PreKeyDispenser");
|
|
13
|
+
const FakeServerSession_1 = require("./FakeServerSession");
|
|
17
14
|
const Scenario_1 = require("./Scenario");
|
|
18
|
-
|
|
15
|
+
var FakeServerSession_2 = require("./FakeServerSession");
|
|
16
|
+
Object.defineProperty(exports, "FakeServerSession", { enumerable: true, get: function () { return FakeServerSession_2.FakeServerSession; } });
|
|
19
17
|
class FakeWaServer {
|
|
20
18
|
constructor(options = {}) {
|
|
21
|
-
this.registries = new ServerRegistries_1.ServerRegistries();
|
|
22
|
-
this.preKeyDispenser = new PreKeyDispenser_1.PreKeyDispenser();
|
|
23
|
-
this.appStateSync = new AppStateSyncManager_1.AppStateSyncManager();
|
|
24
19
|
this.pipelines = new Set();
|
|
25
|
-
this.
|
|
26
|
-
this.capturedStanzas = [];
|
|
27
|
-
this.pendingIqExpectations = new Set();
|
|
28
|
-
this.pendingStanzaExpectations = new Set();
|
|
20
|
+
this.pipelineSessions = new WeakMap();
|
|
29
21
|
this.authenticatedListeners = new Set();
|
|
30
|
-
this.
|
|
22
|
+
this.sessions = new Map();
|
|
23
|
+
this.globalIqHandlers = new Set();
|
|
31
24
|
this.rootCa = null;
|
|
32
25
|
this.serverStaticKeyPair = null;
|
|
33
26
|
this.listenInfo = null;
|
|
34
|
-
this.
|
|
27
|
+
this.pipelineListeners = new Set();
|
|
35
28
|
this.rejectMode = null;
|
|
36
29
|
this.mediaStore = new fake_media_store_1.FakeMediaStore();
|
|
37
30
|
this.mediaHttpsServer = new WaFakeMediaHttpsServer_1.WaFakeMediaHttpsServer();
|
|
38
31
|
this.capturedMediaUploads = [];
|
|
39
32
|
this.nextUploadCounter = 0;
|
|
40
33
|
this.cachedMediaProxyAgent = null;
|
|
34
|
+
this.options = options;
|
|
41
35
|
this.wsServer = new WaFakeWsServer_1.WaFakeWsServer(options);
|
|
42
36
|
this.wsServer.onConnection((connection) => this.handleConnection(connection));
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
lookupDeviceIdsForUser: (userJid) => reg.lookupDeviceIdsForUser(userJid),
|
|
81
|
-
notifyGroupOp: (op) => reg.notifyGroupOp(op),
|
|
82
|
-
mutatePrivacySettings: (category, value) => reg.mutatePrivacySettings(category, value),
|
|
83
|
-
mutateBlocklist: (action, jid) => reg.mutateBlocklist(action, jid),
|
|
84
|
-
notifyProfilePictureSet: (op) => reg.notifyProfilePictureSet(op),
|
|
85
|
-
handleProfilePictureSet: (targetJid, newId) => reg.handleProfilePictureSet(targetJid, newId),
|
|
86
|
-
notifyStatusSet: (text) => reg.notifyStatusSet(text),
|
|
87
|
-
notifyLogout: () => reg.notifyLogout(),
|
|
88
|
-
notifyPrivacyTokenIssue: (token) => reg.notifyPrivacyTokenIssue(token),
|
|
89
|
-
notifyDirtyBitsClear: (op) => reg.notifyDirtyBitsClear(op),
|
|
90
|
-
notifyPrivacySet: (change) => {
|
|
91
|
-
for (const listener of reg.privacySetListeners) {
|
|
92
|
-
try {
|
|
93
|
-
listener(change);
|
|
94
|
-
}
|
|
95
|
-
catch (error) {
|
|
96
|
-
void error;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
},
|
|
100
|
-
notifyBlocklistChange: (change) => {
|
|
101
|
-
for (const listener of reg.blocklistChangeListeners) {
|
|
102
|
-
try {
|
|
103
|
-
listener(change);
|
|
104
|
-
}
|
|
105
|
-
catch (error) {
|
|
106
|
-
void error;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
},
|
|
110
|
-
capturePreKeyBundle: (bundle) => preKey.captureBundle(bundle),
|
|
111
|
-
consumeOutboundAppStatePatches: (iq) => appState.consumeOutboundAppStatePatches(iq),
|
|
112
|
-
get appStateCollectionProviders() {
|
|
113
|
-
return appState.appStateCollectionProviders;
|
|
114
|
-
},
|
|
115
|
-
requireMediaHttpsInfo: () => this.requireMediaHttpsInfo()
|
|
116
|
-
};
|
|
37
|
+
this.defaultSession = this.createSession('__default__');
|
|
38
|
+
}
|
|
39
|
+
/** State of the single default session (the only session for one client). */
|
|
40
|
+
get registries() {
|
|
41
|
+
return this.defaultSession.registries;
|
|
42
|
+
}
|
|
43
|
+
get preKeyDispenser() {
|
|
44
|
+
return this.defaultSession.preKeyDispenser;
|
|
45
|
+
}
|
|
46
|
+
get appStateSync() {
|
|
47
|
+
return this.defaultSession.appStateSync;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Returns the isolated session for `id`, creating it on first use. Every
|
|
51
|
+
* session gets its own registries, prekey dispenser, app-state, IQ router,
|
|
52
|
+
* and stanza capture. Use with the `sessionKey` option to run several
|
|
53
|
+
* `WaClient`s against one server without them sharing any state.
|
|
54
|
+
*/
|
|
55
|
+
session(id) {
|
|
56
|
+
const existing = this.sessions.get(id);
|
|
57
|
+
if (existing) {
|
|
58
|
+
return existing;
|
|
59
|
+
}
|
|
60
|
+
return this.createSession(id);
|
|
61
|
+
}
|
|
62
|
+
/** The session a connection is bound to (default before authentication). */
|
|
63
|
+
sessionFor(pipeline) {
|
|
64
|
+
return this.pipelineSessions.get(pipeline) ?? this.defaultSession;
|
|
65
|
+
}
|
|
66
|
+
createSession(id) {
|
|
67
|
+
const session = new FakeServerSession_1.FakeServerSession(id, { requireMediaHttpsInfo: () => this.requireMediaHttpsInfo() }, { defaultIqHandlers: this.options.defaultIqHandlers !== false });
|
|
68
|
+
this.sessions.set(id, session);
|
|
69
|
+
// Server-level custom handlers apply to every session, present and future.
|
|
70
|
+
for (const handler of this.globalIqHandlers) {
|
|
71
|
+
handler.unregisterBySession.set(session, session.registerIqHandler(handler.matcher, handler.respond, handler.label));
|
|
72
|
+
}
|
|
73
|
+
return session;
|
|
117
74
|
}
|
|
118
75
|
registerIqHandler(matcher, respond, label) {
|
|
119
|
-
const
|
|
120
|
-
|
|
76
|
+
const entry = {
|
|
77
|
+
matcher,
|
|
78
|
+
respond,
|
|
79
|
+
label,
|
|
80
|
+
unregisterBySession: new Map()
|
|
81
|
+
};
|
|
82
|
+
for (const session of this.sessions.values()) {
|
|
83
|
+
entry.unregisterBySession.set(session, session.registerIqHandler(matcher, respond, label));
|
|
84
|
+
}
|
|
85
|
+
this.globalIqHandlers.add(entry);
|
|
86
|
+
return () => {
|
|
87
|
+
for (const unregister of entry.unregisterBySession.values()) {
|
|
88
|
+
unregister();
|
|
89
|
+
}
|
|
90
|
+
entry.unregisterBySession.clear();
|
|
91
|
+
this.globalIqHandlers.delete(entry);
|
|
92
|
+
};
|
|
121
93
|
}
|
|
122
94
|
async routeIqForTest(iq) {
|
|
123
|
-
return this.
|
|
95
|
+
return this.defaultSession.routeIq(iq);
|
|
124
96
|
}
|
|
125
97
|
onOutboundGroupOp(listener) {
|
|
126
98
|
return this.registries.onOutboundGroupOp(listener);
|
|
@@ -177,7 +149,7 @@ class FakeWaServer {
|
|
|
177
149
|
return this.registries.createFakeGroup(input);
|
|
178
150
|
}
|
|
179
151
|
async triggerPreKeyUpload(pipeline, options = {}) {
|
|
180
|
-
return this.preKeyDispenser.triggerPreKeyUpload(pipeline, options);
|
|
152
|
+
return this.sessionFor(pipeline).preKeyDispenser.triggerPreKeyUpload(pipeline, options);
|
|
181
153
|
}
|
|
182
154
|
awaitPreKeyBundle(timeoutMs = 15000) {
|
|
183
155
|
return this.preKeyDispenser.awaitPreKeyBundle(timeoutMs);
|
|
@@ -207,7 +179,7 @@ class FakeWaServer {
|
|
|
207
179
|
return this.appStateSync.provideAppStateCollection(name, provider);
|
|
208
180
|
}
|
|
209
181
|
async pushServerSyncNotification(pipeline, input) {
|
|
210
|
-
return this.appStateSync.pushServerSyncNotification(pipeline, input);
|
|
182
|
+
return this.sessionFor(pipeline).appStateSync.pushServerSyncNotification(pipeline, input);
|
|
211
183
|
}
|
|
212
184
|
onAuthenticatedPipeline(listener) {
|
|
213
185
|
this.authenticatedListeners.add(listener);
|
|
@@ -217,63 +189,24 @@ class FakeWaServer {
|
|
|
217
189
|
configure(new Scenario_1.Scenario(this));
|
|
218
190
|
}
|
|
219
191
|
expectIq(matcher, options = {}) {
|
|
220
|
-
|
|
221
|
-
for (const captured of this.capturedStanzas) {
|
|
222
|
-
if (matchesIq(captured, matcher)) {
|
|
223
|
-
return Promise.resolve(captured);
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
return new Promise((resolve, reject) => {
|
|
227
|
-
const expectation = {
|
|
228
|
-
matcher,
|
|
229
|
-
resolve: (iq) => {
|
|
230
|
-
this.pendingIqExpectations.delete(expectation);
|
|
231
|
-
clearTimeout(expectation.timer);
|
|
232
|
-
resolve(iq);
|
|
233
|
-
},
|
|
234
|
-
reject: (error) => {
|
|
235
|
-
this.pendingIqExpectations.delete(expectation);
|
|
236
|
-
clearTimeout(expectation.timer);
|
|
237
|
-
reject(error);
|
|
238
|
-
},
|
|
239
|
-
timer: setTimeout(() => {
|
|
240
|
-
this.pendingIqExpectations.delete(expectation);
|
|
241
|
-
reject(new Error(`expectIq timed out after ${timeoutMs}ms (${describeMatcher(matcher)})`));
|
|
242
|
-
}, timeoutMs)
|
|
243
|
-
};
|
|
244
|
-
this.pendingIqExpectations.add(expectation);
|
|
245
|
-
});
|
|
192
|
+
return this.defaultSession.expectIq(matcher, options);
|
|
246
193
|
}
|
|
247
194
|
capturedStanzaSnapshot() {
|
|
248
|
-
return this.
|
|
195
|
+
return this.defaultSession.capturedStanzaSnapshot();
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Subscribes to every stanza captured from the client side (the lib) of
|
|
199
|
+
* the default session. The listener is called synchronously for each new
|
|
200
|
+
* stanza as it arrives. Returns an unsubscribe function. Useful for
|
|
201
|
+
* benches that need to count or react to a stream of receipts/messages
|
|
202
|
+
* without paying the O(N²) cost of polling `capturedStanzaSnapshot()` or
|
|
203
|
+
* queuing one `expectStanza(...)` per iteration.
|
|
204
|
+
*/
|
|
205
|
+
onCapturedStanza(listener) {
|
|
206
|
+
return this.defaultSession.onCapturedStanza(listener);
|
|
249
207
|
}
|
|
250
208
|
expectStanza(matcher, options = {}) {
|
|
251
|
-
|
|
252
|
-
for (const captured of this.capturedStanzas) {
|
|
253
|
-
if (matchesStanza(captured, matcher)) {
|
|
254
|
-
return Promise.resolve(captured);
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
return new Promise((resolve, reject) => {
|
|
258
|
-
const expectation = {
|
|
259
|
-
matcher,
|
|
260
|
-
resolve: (node) => {
|
|
261
|
-
this.pendingStanzaExpectations.delete(expectation);
|
|
262
|
-
clearTimeout(expectation.timer);
|
|
263
|
-
resolve(node);
|
|
264
|
-
},
|
|
265
|
-
reject: (error) => {
|
|
266
|
-
this.pendingStanzaExpectations.delete(expectation);
|
|
267
|
-
clearTimeout(expectation.timer);
|
|
268
|
-
reject(error);
|
|
269
|
-
},
|
|
270
|
-
timer: setTimeout(() => {
|
|
271
|
-
this.pendingStanzaExpectations.delete(expectation);
|
|
272
|
-
reject(new Error(`expectStanza timed out after ${timeoutMs}ms (${describeStanzaMatcher(matcher)})`));
|
|
273
|
-
}, timeoutMs)
|
|
274
|
-
};
|
|
275
|
-
this.pendingStanzaExpectations.add(expectation);
|
|
276
|
-
});
|
|
209
|
+
return this.defaultSession.expectStanza(matcher, options);
|
|
277
210
|
}
|
|
278
211
|
async broadcastStanza(node) {
|
|
279
212
|
const tasks = [];
|
|
@@ -318,7 +251,16 @@ class FakeWaServer {
|
|
|
318
251
|
}
|
|
319
252
|
get mediaProxyAgent() {
|
|
320
253
|
if (!this.cachedMediaProxyAgent) {
|
|
321
|
-
|
|
254
|
+
// keepAlive is required for representative perf measurements
|
|
255
|
+
// and matches what real-world WhatsApp clients do – every
|
|
256
|
+
// media upload/download would otherwise pay a full TLS
|
|
257
|
+
// handshake. The `src/media/__tests__/media.test.ts` fixtures
|
|
258
|
+
// and a production-quality `proxy.mediaUpload` configuration
|
|
259
|
+
// all set this; mirroring it here keeps benches in line.
|
|
260
|
+
this.cachedMediaProxyAgent = new node_https_1.Agent({
|
|
261
|
+
rejectUnauthorized: false,
|
|
262
|
+
keepAlive: true
|
|
263
|
+
});
|
|
322
264
|
}
|
|
323
265
|
return this.cachedMediaProxyAgent;
|
|
324
266
|
}
|
|
@@ -326,8 +268,9 @@ class FakeWaServer {
|
|
|
326
268
|
return this.capturedMediaUploads.slice();
|
|
327
269
|
}
|
|
328
270
|
async createFakePeer(options, pipeline) {
|
|
329
|
-
const
|
|
330
|
-
|
|
271
|
+
const session = this.sessionFor(pipeline);
|
|
272
|
+
const peer = await FakePeer_1.FakePeer.create(options, this.buildFakePeerDeps(pipeline, session));
|
|
273
|
+
session.registries.registerPeer(peer);
|
|
331
274
|
return peer;
|
|
332
275
|
}
|
|
333
276
|
async createFakePeerWithDevices(input, pipeline) {
|
|
@@ -340,6 +283,7 @@ class FakeWaServer {
|
|
|
340
283
|
}
|
|
341
284
|
const userPart = input.userJid.slice(0, atIdx);
|
|
342
285
|
const server = input.userJid.slice(atIdx + 1);
|
|
286
|
+
const session = this.sessionFor(pipeline);
|
|
343
287
|
const peers = [];
|
|
344
288
|
for (const deviceId of input.deviceIds) {
|
|
345
289
|
const deviceJid = deviceId === 0 ? input.userJid : `${userPart}:${deviceId}@${server}`;
|
|
@@ -347,36 +291,27 @@ class FakeWaServer {
|
|
|
347
291
|
jid: deviceJid,
|
|
348
292
|
displayName: input.displayName,
|
|
349
293
|
skipOneTimePreKey: input.skipOneTimePreKey
|
|
350
|
-
}, this.buildFakePeerDeps(pipeline));
|
|
351
|
-
|
|
294
|
+
}, this.buildFakePeerDeps(pipeline, session));
|
|
295
|
+
session.registries.registerPeer(peer);
|
|
352
296
|
peers.push(peer);
|
|
353
297
|
}
|
|
354
298
|
return peers;
|
|
355
299
|
}
|
|
356
|
-
buildFakePeerDeps(pipeline) {
|
|
300
|
+
buildFakePeerDeps(pipeline, session) {
|
|
357
301
|
return {
|
|
358
|
-
bundleResolver: () =>
|
|
359
|
-
reserveOneTimePreKey: () =>
|
|
302
|
+
bundleResolver: () => session.preKeyDispenser.awaitPreKeyBundle(),
|
|
303
|
+
reserveOneTimePreKey: () => session.preKeyDispenser.dispenseOneTimePreKey(),
|
|
360
304
|
pushStanza: (stanza) => pipeline.sendStanza(stanza),
|
|
361
|
-
subscribeInboundMessages: (listener) =>
|
|
362
|
-
const wrapped = (node) => {
|
|
363
|
-
if (node.tag !== 'message')
|
|
364
|
-
return;
|
|
365
|
-
listener(node);
|
|
366
|
-
};
|
|
367
|
-
this.inboundStanzaListeners.add(wrapped);
|
|
368
|
-
return () => {
|
|
369
|
-
this.inboundStanzaListeners.delete(wrapped);
|
|
370
|
-
};
|
|
371
|
-
}
|
|
305
|
+
subscribeInboundMessages: (listener) => session.subscribeInboundMessages(listener)
|
|
372
306
|
};
|
|
373
307
|
}
|
|
374
308
|
async runPairing(pipeline, options, companionMaterialResolver) {
|
|
309
|
+
const session = this.sessionFor(pipeline);
|
|
375
310
|
const driver = new FakePairingDriver_1.FakePairingDriver(options, {
|
|
376
311
|
pipeline,
|
|
377
312
|
companionMaterialResolver,
|
|
378
313
|
waitForPairDeviceAck: async (pairDeviceIqId) => {
|
|
379
|
-
await
|
|
314
|
+
await session.expectIq({
|
|
380
315
|
id: pairDeviceIqId
|
|
381
316
|
}, {
|
|
382
317
|
timeoutMs: 15000
|
|
@@ -413,8 +348,15 @@ class FakeWaServer {
|
|
|
413
348
|
const root = this.requireRootCa();
|
|
414
349
|
return { publicKey: root.publicKey, serial: root.serial };
|
|
415
350
|
}
|
|
351
|
+
/**
|
|
352
|
+
* Subscribes to every new connection pipeline (pre-auth). Listeners
|
|
353
|
+
* fan out; returns an unsubscribe function.
|
|
354
|
+
*/
|
|
416
355
|
onPipeline(listener) {
|
|
417
|
-
this.
|
|
356
|
+
this.pipelineListeners.add(listener);
|
|
357
|
+
return () => {
|
|
358
|
+
this.pipelineListeners.delete(listener);
|
|
359
|
+
};
|
|
418
360
|
}
|
|
419
361
|
async listen() {
|
|
420
362
|
if (this.listenInfo) {
|
|
@@ -456,45 +398,51 @@ class FakeWaServer {
|
|
|
456
398
|
connection,
|
|
457
399
|
rootCa: this.rootCa,
|
|
458
400
|
serverStaticKeyPair: this.serverStaticKeyPair,
|
|
459
|
-
|
|
401
|
+
routeIq: (node) => this.sessionFor(pipeline).routeIq(node),
|
|
402
|
+
...(this.options.successNodeAttributes !== undefined
|
|
403
|
+
? { successNodeAttributes: this.options.successNodeAttributes }
|
|
404
|
+
: {})
|
|
460
405
|
});
|
|
461
406
|
this.pipelines.add(pipeline);
|
|
407
|
+
this.pipelineSessions.set(pipeline, this.defaultSession);
|
|
462
408
|
pipeline.setEvents({
|
|
463
409
|
onAuthenticated: () => {
|
|
410
|
+
this.bindPipelineSession(pipeline);
|
|
464
411
|
for (const listener of this.authenticatedListeners) {
|
|
465
|
-
|
|
412
|
+
try {
|
|
413
|
+
void Promise.resolve(listener(pipeline)).catch(() => undefined);
|
|
414
|
+
}
|
|
415
|
+
catch {
|
|
416
|
+
/* ignore */
|
|
417
|
+
}
|
|
466
418
|
}
|
|
467
419
|
},
|
|
468
|
-
onStanza: (node) => this.handleCapturedStanza(node),
|
|
420
|
+
onStanza: (node) => this.sessionFor(pipeline).handleCapturedStanza(node),
|
|
469
421
|
onClose: () => this.pipelines.delete(pipeline)
|
|
470
422
|
});
|
|
471
|
-
this.
|
|
472
|
-
}
|
|
473
|
-
handleCapturedStanza(node) {
|
|
474
|
-
this.capturedStanzas.push(node);
|
|
475
|
-
for (const listener of this.inboundStanzaListeners) {
|
|
423
|
+
for (const listener of this.pipelineListeners) {
|
|
476
424
|
try {
|
|
477
|
-
listener(
|
|
425
|
+
void Promise.resolve(listener(pipeline)).catch(() => undefined);
|
|
478
426
|
}
|
|
479
|
-
catch
|
|
480
|
-
|
|
427
|
+
catch {
|
|
428
|
+
/* ignore */
|
|
481
429
|
}
|
|
482
430
|
}
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
431
|
+
}
|
|
432
|
+
/**
|
|
433
|
+
* Rebinds a connection to its keyed session once authenticated. Runs
|
|
434
|
+
* before user `onAuthenticated` listeners and before any client stanza, so
|
|
435
|
+
* captures and IQ routing land in the right session from the first frame.
|
|
436
|
+
* No-op without a `sessionKey` resolver (single default session).
|
|
437
|
+
*/
|
|
438
|
+
bindPipelineSession(pipeline) {
|
|
439
|
+
const resolveKey = this.options.sessionKey;
|
|
440
|
+
const clientPayload = pipeline.clientPayload;
|
|
441
|
+
if (!resolveKey || !clientPayload) {
|
|
490
442
|
return;
|
|
491
443
|
}
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
expectation.resolve(node);
|
|
495
|
-
return;
|
|
496
|
-
}
|
|
497
|
-
}
|
|
444
|
+
const id = resolveKey({ clientPayload, pipeline });
|
|
445
|
+
this.pipelineSessions.set(pipeline, this.session(id));
|
|
498
446
|
}
|
|
499
447
|
buildMediaRequestHandler() {
|
|
500
448
|
return (req, res) => {
|
|
@@ -583,70 +531,3 @@ function parseQueryParam(query, name) {
|
|
|
583
531
|
}
|
|
584
532
|
return undefined;
|
|
585
533
|
}
|
|
586
|
-
function matchesIq(iq, matcher) {
|
|
587
|
-
if (iq.tag !== 'iq')
|
|
588
|
-
return false;
|
|
589
|
-
if (matcher.id !== undefined && iq.attrs.id !== matcher.id)
|
|
590
|
-
return false;
|
|
591
|
-
if (matcher.type !== undefined && iq.attrs.type !== matcher.type)
|
|
592
|
-
return false;
|
|
593
|
-
if (matcher.xmlns !== undefined && iq.attrs.xmlns !== matcher.xmlns)
|
|
594
|
-
return false;
|
|
595
|
-
if (matcher.childTag !== undefined) {
|
|
596
|
-
const children = Array.isArray(iq.content) ? iq.content : null;
|
|
597
|
-
if (!children || children.length === 0)
|
|
598
|
-
return false;
|
|
599
|
-
if (children[0].tag !== matcher.childTag)
|
|
600
|
-
return false;
|
|
601
|
-
}
|
|
602
|
-
return true;
|
|
603
|
-
}
|
|
604
|
-
function describeMatcher(matcher) {
|
|
605
|
-
const parts = [];
|
|
606
|
-
if (matcher.id !== undefined)
|
|
607
|
-
parts.push(`id=${matcher.id}`);
|
|
608
|
-
if (matcher.type !== undefined)
|
|
609
|
-
parts.push(`type=${matcher.type}`);
|
|
610
|
-
if (matcher.xmlns !== undefined)
|
|
611
|
-
parts.push(`xmlns=${matcher.xmlns}`);
|
|
612
|
-
if (matcher.childTag !== undefined)
|
|
613
|
-
parts.push(`childTag=${matcher.childTag}`);
|
|
614
|
-
return parts.length > 0 ? parts.join(', ') : 'any iq';
|
|
615
|
-
}
|
|
616
|
-
function matchesStanza(node, matcher) {
|
|
617
|
-
if (matcher.tag !== undefined && node.tag !== matcher.tag)
|
|
618
|
-
return false;
|
|
619
|
-
if (matcher.type !== undefined && node.attrs.type !== matcher.type)
|
|
620
|
-
return false;
|
|
621
|
-
if (matcher.xmlns !== undefined && node.attrs.xmlns !== matcher.xmlns)
|
|
622
|
-
return false;
|
|
623
|
-
if (matcher.from !== undefined && node.attrs.from !== matcher.from)
|
|
624
|
-
return false;
|
|
625
|
-
if (matcher.to !== undefined && node.attrs.to !== matcher.to)
|
|
626
|
-
return false;
|
|
627
|
-
if (matcher.childTag !== undefined) {
|
|
628
|
-
const children = Array.isArray(node.content) ? node.content : null;
|
|
629
|
-
if (!children || children.length === 0)
|
|
630
|
-
return false;
|
|
631
|
-
if (children[0].tag !== matcher.childTag)
|
|
632
|
-
return false;
|
|
633
|
-
}
|
|
634
|
-
return true;
|
|
635
|
-
}
|
|
636
|
-
function describeStanzaMatcher(matcher) {
|
|
637
|
-
const parts = [];
|
|
638
|
-
if (matcher.tag !== undefined)
|
|
639
|
-
parts.push(`tag=${matcher.tag}`);
|
|
640
|
-
if (matcher.type !== undefined)
|
|
641
|
-
parts.push(`type=${matcher.type}`);
|
|
642
|
-
if (matcher.xmlns !== undefined)
|
|
643
|
-
parts.push(`xmlns=${matcher.xmlns}`);
|
|
644
|
-
if (matcher.from !== undefined)
|
|
645
|
-
parts.push(`from=${matcher.from}`);
|
|
646
|
-
if (matcher.to !== undefined)
|
|
647
|
-
parts.push(`to=${matcher.to}`);
|
|
648
|
-
if (matcher.childTag !== undefined)
|
|
649
|
-
parts.push(`childTag=${matcher.childTag}`);
|
|
650
|
-
return parts.length > 0 ? parts.join(', ') : 'any stanza';
|
|
651
|
-
}
|
|
652
|
-
//# sourceMappingURL=FakeWaServer.js.map
|
package/dist/api/Scenario.d.ts
CHANGED
package/dist/api/Scenario.js
CHANGED
|
@@ -34,6 +34,7 @@ export interface IqHandlerDeps {
|
|
|
34
34
|
notifyPrivacySet(change: CapturedPrivacySet): void;
|
|
35
35
|
notifyBlocklistChange(change: CapturedBlocklistChange): void;
|
|
36
36
|
capturePreKeyBundle(bundle: ClientPreKeyBundle): void;
|
|
37
|
+
countServerPreKeys(): number;
|
|
37
38
|
consumeOutboundAppStatePatches(iq: BinaryNode): Promise<void>;
|
|
38
39
|
readonly appStateCollectionProviders: ReadonlyMap<string, () => Promise<FakeAppStateCollectionPayload | null> | FakeAppStateCollectionPayload | null>;
|
|
39
40
|
requireMediaHttpsInfo(): {
|
|
@@ -44,4 +45,3 @@ export interface IqHandlerDeps {
|
|
|
44
45
|
export declare function parseUsyncRequestedUserJids(iq: BinaryNode): readonly string[];
|
|
45
46
|
export declare function parseRequestedKeyJids(iq: BinaryNode): readonly string[];
|
|
46
47
|
export declare function registerDefaultIqHandlers(router: WaFakeIqRouter, deps: IqHandlerDeps): void;
|
|
47
|
-
//# sourceMappingURL=iq-handlers.d.ts.map
|
package/dist/api/iq-handlers.js
CHANGED
|
@@ -98,6 +98,29 @@ function registerDefaultIqHandlers(router, deps) {
|
|
|
98
98
|
matcher: { xmlns: 'encrypt', type: 'get', childTag: 'digest' },
|
|
99
99
|
respond: (iq) => (0, router_1.buildIqError)(iq, { code: 404, text: 'item-not-found' })
|
|
100
100
|
});
|
|
101
|
+
// Baileys-family and whatsmeow clients block on this query before
|
|
102
|
+
// reporting the connection as open; zapo-js uses <digest> instead.
|
|
103
|
+
router.register({
|
|
104
|
+
label: 'prekey-count',
|
|
105
|
+
matcher: { xmlns: 'encrypt', type: 'get', childTag: 'count' },
|
|
106
|
+
respond: (iq) => {
|
|
107
|
+
const result = (0, router_1.buildIqResult)(iq);
|
|
108
|
+
return {
|
|
109
|
+
...result,
|
|
110
|
+
content: [
|
|
111
|
+
{
|
|
112
|
+
tag: 'count',
|
|
113
|
+
attrs: { value: String(deps.countServerPreKeys()) }
|
|
114
|
+
}
|
|
115
|
+
]
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
router.register({
|
|
120
|
+
label: 'passive-mode',
|
|
121
|
+
matcher: { xmlns: 'passive', type: 'set' },
|
|
122
|
+
respond: (iq) => (0, router_1.buildIqResult)(iq)
|
|
123
|
+
});
|
|
101
124
|
router.register({
|
|
102
125
|
label: 'media-conn',
|
|
103
126
|
matcher: { xmlns: 'w:m', type: 'set', childTag: 'media_conn' },
|
|
@@ -495,4 +518,3 @@ function registerDefaultIqHandlers(router, deps) {
|
|
|
495
518
|
respond: (iq) => (0, router_1.buildIqResult)(iq)
|
|
496
519
|
});
|
|
497
520
|
}
|
|
498
|
-
//# sourceMappingURL=iq-handlers.js.map
|