zapo-js 0.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 +235 -0
- package/dist/appstate/WaAppStateCrypto.js +202 -0
- package/dist/appstate/WaAppStateSyncClient.js +808 -0
- package/dist/appstate/WaAppStateSyncResponseParser.js +71 -0
- package/dist/appstate/constants.js +23 -0
- package/dist/appstate/index.js +28 -0
- package/dist/appstate/store/sqlite.js +55 -0
- package/dist/appstate/types.js +2 -0
- package/dist/appstate/utils.js +84 -0
- package/dist/auth/WaAuthClient.js +266 -0
- package/dist/auth/flow/WaAuthCredentialsFlow.js +123 -0
- package/dist/auth/index.js +27 -0
- package/dist/auth/pairing/WaPairingCodeCrypto.js +75 -0
- package/dist/auth/pairing/WaPairingFlow.js +328 -0
- package/dist/auth/pairing/WaQrFlow.js +86 -0
- package/dist/auth/pairing/constants.js +5 -0
- package/dist/auth/types.js +2 -0
- package/dist/client/WaClient.js +749 -0
- package/dist/client/WaClientFactory.js +381 -0
- package/dist/client/coordinators/WaGroupCoordinator.js +191 -0
- package/dist/client/coordinators/WaIncomingNodeCoordinator.js +315 -0
- package/dist/client/coordinators/WaMessageDispatchCoordinator.js +1061 -0
- package/dist/client/coordinators/WaPassiveTasksCoordinator.js +200 -0
- package/dist/client/coordinators/WaRetryCoordinator.js +494 -0
- package/dist/client/coordinators/WaStreamControlCoordinator.js +123 -0
- package/dist/client/dirty.js +254 -0
- package/dist/client/events/chat.js +226 -0
- package/dist/client/events/group.js +410 -0
- package/dist/client/history-sync.js +122 -0
- package/dist/client/incoming.js +236 -0
- package/dist/client/index.js +5 -0
- package/dist/client/mailbox.js +49 -0
- package/dist/client/messages.js +152 -0
- package/dist/client/types.js +2 -0
- package/dist/crypto/core/constants.js +4 -0
- package/dist/crypto/core/encoding.js +29 -0
- package/dist/crypto/core/hkdf.js +26 -0
- package/dist/crypto/core/index.js +43 -0
- package/dist/crypto/core/keys.js +73 -0
- package/dist/crypto/core/nonce.js +18 -0
- package/dist/crypto/core/primitives.js +121 -0
- package/dist/crypto/core/random.js +32 -0
- package/dist/crypto/curves/Ed25519.js +42 -0
- package/dist/crypto/curves/X25519.js +64 -0
- package/dist/crypto/curves/constants.js +6 -0
- package/dist/crypto/curves/types.js +9 -0
- package/dist/crypto/index.js +22 -0
- package/dist/crypto/math/constants.js +44 -0
- package/dist/crypto/math/edwards.js +64 -0
- package/dist/crypto/math/le.js +20 -0
- package/dist/crypto/math/mod.js +38 -0
- package/dist/crypto/math/types.js +2 -0
- package/dist/esm/appstate/WaAppStateCrypto.js +198 -0
- package/dist/esm/appstate/WaAppStateSyncClient.js +803 -0
- package/dist/esm/appstate/WaAppStateSyncResponseParser.js +67 -0
- package/dist/esm/appstate/constants.js +20 -0
- package/dist/esm/appstate/index.js +6 -0
- package/dist/esm/appstate/store/sqlite.js +49 -0
- package/dist/esm/appstate/types.js +1 -0
- package/dist/esm/appstate/utils.js +75 -0
- package/dist/esm/auth/WaAuthClient.js +262 -0
- package/dist/esm/auth/flow/WaAuthCredentialsFlow.js +118 -0
- package/dist/esm/auth/index.js +5 -0
- package/dist/esm/auth/pairing/WaPairingCodeCrypto.js +71 -0
- package/dist/esm/auth/pairing/WaPairingFlow.js +324 -0
- package/dist/esm/auth/pairing/WaQrFlow.js +82 -0
- package/dist/esm/auth/pairing/constants.js +2 -0
- package/dist/esm/auth/types.js +1 -0
- package/dist/esm/client/WaClient.js +745 -0
- package/dist/esm/client/WaClientFactory.js +377 -0
- package/dist/esm/client/coordinators/WaGroupCoordinator.js +188 -0
- package/dist/esm/client/coordinators/WaIncomingNodeCoordinator.js +311 -0
- package/dist/esm/client/coordinators/WaMessageDispatchCoordinator.js +1057 -0
- package/dist/esm/client/coordinators/WaPassiveTasksCoordinator.js +196 -0
- package/dist/esm/client/coordinators/WaRetryCoordinator.js +490 -0
- package/dist/esm/client/coordinators/WaStreamControlCoordinator.js +120 -0
- package/dist/esm/client/dirty.js +250 -0
- package/dist/esm/client/events/chat.js +223 -0
- package/dist/esm/client/events/group.js +407 -0
- package/dist/esm/client/history-sync.js +119 -0
- package/dist/esm/client/incoming.js +227 -0
- package/dist/esm/client/index.js +1 -0
- package/dist/esm/client/mailbox.js +46 -0
- package/dist/esm/client/messages.js +148 -0
- package/dist/esm/client/types.js +1 -0
- package/dist/esm/crypto/core/constants.js +1 -0
- package/dist/esm/crypto/core/encoding.js +25 -0
- package/dist/esm/crypto/core/hkdf.js +22 -0
- package/dist/esm/crypto/core/index.js +11 -0
- package/dist/esm/crypto/core/keys.js +66 -0
- package/dist/esm/crypto/core/nonce.js +15 -0
- package/dist/esm/crypto/core/primitives.js +102 -0
- package/dist/esm/crypto/core/random.js +28 -0
- package/dist/esm/crypto/curves/Ed25519.js +38 -0
- package/dist/esm/crypto/curves/X25519.js +58 -0
- package/dist/esm/crypto/curves/constants.js +3 -0
- package/dist/esm/crypto/curves/types.js +6 -0
- package/dist/esm/crypto/index.js +3 -0
- package/dist/esm/crypto/math/constants.js +41 -0
- package/dist/esm/crypto/math/edwards.js +60 -0
- package/dist/esm/crypto/math/le.js +16 -0
- package/dist/esm/crypto/math/mod.js +31 -0
- package/dist/esm/crypto/math/types.js +1 -0
- package/dist/esm/index.js +6 -0
- package/dist/esm/infra/log/ConsoleLogger.js +40 -0
- package/dist/esm/infra/log/PinoLogger.js +73 -0
- package/dist/esm/infra/log/types.js +1 -0
- package/dist/esm/infra/perf/BoundedTaskQueue.js +62 -0
- package/dist/esm/media/WaMediaCrypto.js +224 -0
- package/dist/esm/media/WaMediaTransferClient.js +361 -0
- package/dist/esm/media/conn.js +33 -0
- package/dist/esm/media/constants.js +18 -0
- package/dist/esm/media/index.js +3 -0
- package/dist/esm/media/types.js +1 -0
- package/dist/esm/message/WaMessageClient.js +210 -0
- package/dist/esm/message/ack.js +46 -0
- package/dist/esm/message/content.js +20 -0
- package/dist/esm/message/device-sent.js +49 -0
- package/dist/esm/message/incoming.js +318 -0
- package/dist/esm/message/index.js +2 -0
- package/dist/esm/message/padding.js +20 -0
- package/dist/esm/message/phash.js +25 -0
- package/dist/esm/message/types.js +1 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/proto.js +3 -0
- package/dist/esm/protocol/appstate.js +34 -0
- package/dist/esm/protocol/auth.js +12 -0
- package/dist/esm/protocol/browser.js +41 -0
- package/dist/esm/protocol/constants.js +11 -0
- package/dist/esm/protocol/defaults.js +27 -0
- package/dist/esm/protocol/dirty.js +26 -0
- package/dist/esm/protocol/group.js +5 -0
- package/dist/esm/protocol/index.js +11 -0
- package/dist/esm/protocol/jid.js +94 -0
- package/dist/esm/protocol/media.js +20 -0
- package/dist/esm/protocol/message.js +16 -0
- package/dist/esm/protocol/nodes.js +83 -0
- package/dist/esm/protocol/notification.js +50 -0
- package/dist/esm/protocol/stream.js +60 -0
- package/dist/esm/retry/constants.js +20 -0
- package/dist/esm/retry/index.js +5 -0
- package/dist/esm/retry/outbound.js +83 -0
- package/dist/esm/retry/parse.js +130 -0
- package/dist/esm/retry/reason.js +50 -0
- package/dist/esm/retry/replay.js +177 -0
- package/dist/esm/retry/types.js +1 -0
- package/dist/esm/signal/api/SignalDeviceSyncApi.js +185 -0
- package/dist/esm/signal/api/SignalDigestSyncApi.js +179 -0
- package/dist/esm/signal/api/SignalIdentitySyncApi.js +111 -0
- package/dist/esm/signal/api/SignalMissingPreKeysSyncApi.js +141 -0
- package/dist/esm/signal/api/SignalRotateKeyApi.js +59 -0
- package/dist/esm/signal/api/SignalSessionSyncApi.js +187 -0
- package/dist/esm/signal/api/codec.js +23 -0
- package/dist/esm/signal/api/constants.js +9 -0
- package/dist/esm/signal/api/prekeys.js +9 -0
- package/dist/esm/signal/constants.js +16 -0
- package/dist/esm/signal/crypto/WaAdvSignature.js +60 -0
- package/dist/esm/signal/crypto/constants.js +8 -0
- package/dist/esm/signal/group/SenderKeyChain.js +97 -0
- package/dist/esm/signal/group/SenderKeyCodec.js +46 -0
- package/dist/esm/signal/group/SenderKeyManager.js +176 -0
- package/dist/esm/signal/index.js +11 -0
- package/dist/esm/signal/registration/keygen.js +31 -0
- package/dist/esm/signal/registration/utils.js +16 -0
- package/dist/esm/signal/session/SignalProtocol.js +122 -0
- package/dist/esm/signal/session/SignalRatchet.js +260 -0
- package/dist/esm/signal/session/SignalSerializer.js +63 -0
- package/dist/esm/signal/session/SignalSession.js +153 -0
- package/dist/esm/signal/store/sqlite.js +310 -0
- package/dist/esm/signal/types.js +1 -0
- package/dist/esm/store/contracts/appstate.store.js +1 -0
- package/dist/esm/store/contracts/auth.store.js +1 -0
- package/dist/esm/store/contracts/contact.store.js +1 -0
- package/dist/esm/store/contracts/device-list.store.js +1 -0
- package/dist/esm/store/contracts/message.store.js +1 -0
- package/dist/esm/store/contracts/participants.store.js +1 -0
- package/dist/esm/store/contracts/retry.store.js +1 -0
- package/dist/esm/store/contracts/sender-key.store.js +1 -0
- package/dist/esm/store/contracts/signal.store.js +1 -0
- package/dist/esm/store/contracts/thread.store.js +1 -0
- package/dist/esm/store/createStore.js +278 -0
- package/dist/esm/store/index.js +20 -0
- package/dist/esm/store/noop.store.js +43 -0
- package/dist/esm/store/providers/memory/appstate.store.js +101 -0
- package/dist/esm/store/providers/memory/contact.store.js +23 -0
- package/dist/esm/store/providers/memory/device-list.store.js +86 -0
- package/dist/esm/store/providers/memory/message.store.js +40 -0
- package/dist/esm/store/providers/memory/participants.store.js +61 -0
- package/dist/esm/store/providers/memory/retry.store.js +71 -0
- package/dist/esm/store/providers/memory/sender-key.store.js +88 -0
- package/dist/esm/store/providers/memory/signal.store.js +170 -0
- package/dist/esm/store/providers/memory/thread.store.js +34 -0
- package/dist/esm/store/providers/sqlite/BaseSqliteStore.js +37 -0
- package/dist/esm/store/providers/sqlite/appstate.store.js +169 -0
- package/dist/esm/store/providers/sqlite/auth.store.js +176 -0
- package/dist/esm/store/providers/sqlite/connection.js +240 -0
- package/dist/esm/store/providers/sqlite/contact.store.js +61 -0
- package/dist/esm/store/providers/sqlite/device-list.store.js +155 -0
- package/dist/esm/store/providers/sqlite/message.store.js +119 -0
- package/dist/esm/store/providers/sqlite/migrations.js +347 -0
- package/dist/esm/store/providers/sqlite/participants.store.js +85 -0
- package/dist/esm/store/providers/sqlite/retry.store.js +144 -0
- package/dist/esm/store/providers/sqlite/sender-key.store.js +203 -0
- package/dist/esm/store/providers/sqlite/signal.store.js +353 -0
- package/dist/esm/store/providers/sqlite/thread.store.js +72 -0
- package/dist/esm/store/types.js +1 -0
- package/dist/esm/transport/WaComms.js +527 -0
- package/dist/esm/transport/WaWebSocket.js +361 -0
- package/dist/esm/transport/binary/constants.js +96 -0
- package/dist/esm/transport/binary/decoder.js +275 -0
- package/dist/esm/transport/binary/encoder.js +210 -0
- package/dist/esm/transport/binary/index.js +4 -0
- package/dist/esm/transport/binary/tokens.js +1280 -0
- package/dist/esm/transport/index.js +6 -0
- package/dist/esm/transport/keepalive/WaKeepAlive.js +141 -0
- package/dist/esm/transport/node/WaNodeOrchestrator.js +143 -0
- package/dist/esm/transport/node/WaNodeTransport.js +64 -0
- package/dist/esm/transport/node/builders/accountSync.js +101 -0
- package/dist/esm/transport/node/builders/group.js +47 -0
- package/dist/esm/transport/node/builders/index.js +7 -0
- package/dist/esm/transport/node/builders/media.js +10 -0
- package/dist/esm/transport/node/builders/message.js +317 -0
- package/dist/esm/transport/node/builders/pairing.js +130 -0
- package/dist/esm/transport/node/builders/prekeys.js +102 -0
- package/dist/esm/transport/node/builders/retry.js +116 -0
- package/dist/esm/transport/node/helpers.js +37 -0
- package/dist/esm/transport/node/query.js +53 -0
- package/dist/esm/transport/node/xml.js +39 -0
- package/dist/esm/transport/noise/WaClientPayload.js +162 -0
- package/dist/esm/transport/noise/WaFrameCodec.js +121 -0
- package/dist/esm/transport/noise/WaNoiseCert.js +74 -0
- package/dist/esm/transport/noise/WaNoiseHandshake.js +57 -0
- package/dist/esm/transport/noise/WaNoiseSession.js +322 -0
- package/dist/esm/transport/noise/WaNoiseSocket.js +17 -0
- package/dist/esm/transport/noise/constants.js +8 -0
- package/dist/esm/transport/noise/types.js +1 -0
- package/dist/esm/transport/stream/parse.js +91 -0
- package/dist/esm/transport/types.js +1 -0
- package/dist/esm/util/async.js +5 -0
- package/dist/esm/util/base64.js +18 -0
- package/dist/esm/util/bytes.js +275 -0
- package/dist/esm/util/coercion.js +56 -0
- package/dist/esm/util/collections.js +27 -0
- package/dist/esm/util/primitives.js +32 -0
- package/dist/esm/util/runtime.js +15 -0
- package/dist/esm/util/signal-address.js +5 -0
- package/dist/index.js +52 -0
- package/dist/infra/log/ConsoleLogger.js +44 -0
- package/dist/infra/log/PinoLogger.js +111 -0
- package/dist/infra/log/types.js +2 -0
- package/dist/infra/perf/BoundedTaskQueue.js +67 -0
- package/dist/media/WaMediaCrypto.js +228 -0
- package/dist/media/WaMediaTransferClient.js +365 -0
- package/dist/media/conn.js +36 -0
- package/dist/media/constants.js +21 -0
- package/dist/media/index.js +9 -0
- package/dist/media/types.js +2 -0
- package/dist/message/WaMessageClient.js +214 -0
- package/dist/message/ack.js +52 -0
- package/dist/message/content.js +24 -0
- package/dist/message/device-sent.js +53 -0
- package/dist/message/incoming.js +321 -0
- package/dist/message/index.js +20 -0
- package/dist/message/padding.js +24 -0
- package/dist/message/phash.js +28 -0
- package/dist/message/types.js +2 -0
- package/dist/proto.js +5 -0
- package/dist/protocol/appstate.js +37 -0
- package/dist/protocol/auth.js +15 -0
- package/dist/protocol/browser.js +45 -0
- package/dist/protocol/constants.js +46 -0
- package/dist/protocol/defaults.js +30 -0
- package/dist/protocol/dirty.js +29 -0
- package/dist/protocol/group.js +8 -0
- package/dist/protocol/index.js +53 -0
- package/dist/protocol/jid.js +107 -0
- package/dist/protocol/media.js +24 -0
- package/dist/protocol/message.js +19 -0
- package/dist/protocol/nodes.js +86 -0
- package/dist/protocol/notification.js +53 -0
- package/dist/protocol/stream.js +63 -0
- package/dist/retry/constants.js +23 -0
- package/dist/retry/index.js +19 -0
- package/dist/retry/outbound.js +88 -0
- package/dist/retry/parse.js +133 -0
- package/dist/retry/reason.js +53 -0
- package/dist/retry/replay.js +181 -0
- package/dist/retry/types.js +2 -0
- package/dist/signal/api/SignalDeviceSyncApi.js +189 -0
- package/dist/signal/api/SignalDigestSyncApi.js +183 -0
- package/dist/signal/api/SignalIdentitySyncApi.js +115 -0
- package/dist/signal/api/SignalMissingPreKeysSyncApi.js +145 -0
- package/dist/signal/api/SignalRotateKeyApi.js +63 -0
- package/dist/signal/api/SignalSessionSyncApi.js +191 -0
- package/dist/signal/api/codec.js +27 -0
- package/dist/signal/api/constants.js +12 -0
- package/dist/signal/api/prekeys.js +16 -0
- package/dist/signal/constants.js +19 -0
- package/dist/signal/crypto/WaAdvSignature.js +72 -0
- package/dist/signal/crypto/constants.js +11 -0
- package/dist/signal/group/SenderKeyChain.js +101 -0
- package/dist/signal/group/SenderKeyCodec.js +50 -0
- package/dist/signal/group/SenderKeyManager.js +180 -0
- package/dist/signal/index.js +29 -0
- package/dist/signal/registration/keygen.js +37 -0
- package/dist/signal/registration/utils.js +19 -0
- package/dist/signal/session/SignalProtocol.js +126 -0
- package/dist/signal/session/SignalRatchet.js +268 -0
- package/dist/signal/session/SignalSerializer.js +69 -0
- package/dist/signal/session/SignalSession.js +165 -0
- package/dist/signal/store/sqlite.js +324 -0
- package/dist/signal/types.js +2 -0
- package/dist/store/contracts/appstate.store.js +2 -0
- package/dist/store/contracts/auth.store.js +2 -0
- package/dist/store/contracts/contact.store.js +2 -0
- package/dist/store/contracts/device-list.store.js +2 -0
- package/dist/store/contracts/message.store.js +2 -0
- package/dist/store/contracts/participants.store.js +2 -0
- package/dist/store/contracts/retry.store.js +2 -0
- package/dist/store/contracts/sender-key.store.js +2 -0
- package/dist/store/contracts/signal.store.js +2 -0
- package/dist/store/contracts/thread.store.js +2 -0
- package/dist/store/createStore.js +281 -0
- package/dist/store/index.js +43 -0
- package/dist/store/noop.store.js +46 -0
- package/dist/store/providers/memory/appstate.store.js +105 -0
- package/dist/store/providers/memory/contact.store.js +27 -0
- package/dist/store/providers/memory/device-list.store.js +90 -0
- package/dist/store/providers/memory/message.store.js +44 -0
- package/dist/store/providers/memory/participants.store.js +65 -0
- package/dist/store/providers/memory/retry.store.js +75 -0
- package/dist/store/providers/memory/sender-key.store.js +92 -0
- package/dist/store/providers/memory/signal.store.js +174 -0
- package/dist/store/providers/memory/thread.store.js +38 -0
- package/dist/store/providers/sqlite/BaseSqliteStore.js +41 -0
- package/dist/store/providers/sqlite/appstate.store.js +173 -0
- package/dist/store/providers/sqlite/auth.store.js +180 -0
- package/dist/store/providers/sqlite/connection.js +276 -0
- package/dist/store/providers/sqlite/contact.store.js +65 -0
- package/dist/store/providers/sqlite/device-list.store.js +159 -0
- package/dist/store/providers/sqlite/message.store.js +123 -0
- package/dist/store/providers/sqlite/migrations.js +350 -0
- package/dist/store/providers/sqlite/participants.store.js +89 -0
- package/dist/store/providers/sqlite/retry.store.js +148 -0
- package/dist/store/providers/sqlite/sender-key.store.js +207 -0
- package/dist/store/providers/sqlite/signal.store.js +357 -0
- package/dist/store/providers/sqlite/thread.store.js +76 -0
- package/dist/store/types.js +2 -0
- package/dist/transport/WaComms.js +531 -0
- package/dist/transport/WaWebSocket.js +365 -0
- package/dist/transport/binary/constants.js +99 -0
- package/dist/transport/binary/decoder.js +279 -0
- package/dist/transport/binary/encoder.js +214 -0
- package/dist/transport/binary/index.js +23 -0
- package/dist/transport/binary/tokens.js +1283 -0
- package/dist/transport/index.js +18 -0
- package/dist/transport/keepalive/WaKeepAlive.js +145 -0
- package/dist/transport/node/WaNodeOrchestrator.js +147 -0
- package/dist/transport/node/WaNodeTransport.js +68 -0
- package/dist/transport/node/builders/accountSync.js +110 -0
- package/dist/transport/node/builders/group.js +52 -0
- package/dist/transport/node/builders/index.js +39 -0
- package/dist/transport/node/builders/media.js +13 -0
- package/dist/transport/node/builders/message.js +328 -0
- package/dist/transport/node/builders/pairing.js +137 -0
- package/dist/transport/node/builders/prekeys.js +107 -0
- package/dist/transport/node/builders/retry.js +119 -0
- package/dist/transport/node/helpers.js +46 -0
- package/dist/transport/node/query.js +59 -0
- package/dist/transport/node/xml.js +42 -0
- package/dist/transport/noise/WaClientPayload.js +166 -0
- package/dist/transport/noise/WaFrameCodec.js +125 -0
- package/dist/transport/noise/WaNoiseCert.js +77 -0
- package/dist/transport/noise/WaNoiseHandshake.js +61 -0
- package/dist/transport/noise/WaNoiseSession.js +326 -0
- package/dist/transport/noise/WaNoiseSocket.js +21 -0
- package/dist/transport/noise/constants.js +11 -0
- package/dist/transport/noise/types.js +2 -0
- package/dist/transport/stream/parse.js +97 -0
- package/dist/transport/types.js +2 -0
- package/dist/types/appstate/WaAppStateCrypto.d.ts +59 -0
- package/dist/types/appstate/WaAppStateSyncClient.d.ts +63 -0
- package/dist/types/appstate/WaAppStateSyncResponseParser.d.ts +12 -0
- package/dist/types/appstate/constants.d.ts +14 -0
- package/dist/types/appstate/index.d.ts +7 -0
- package/dist/types/appstate/store/sqlite.d.ts +21 -0
- package/dist/types/appstate/types.d.ts +66 -0
- package/dist/types/appstate/utils.d.ts +10 -0
- package/dist/types/auth/WaAuthClient.d.ts +61 -0
- package/dist/types/auth/flow/WaAuthCredentialsFlow.d.ts +14 -0
- package/dist/types/auth/index.d.ts +6 -0
- package/dist/types/auth/pairing/WaPairingCodeCrypto.d.ts +17 -0
- package/dist/types/auth/pairing/WaPairingFlow.d.ts +48 -0
- package/dist/types/auth/pairing/WaQrFlow.d.ts +23 -0
- package/dist/types/auth/pairing/constants.d.ts +2 -0
- package/dist/types/auth/types.d.ts +48 -0
- package/dist/types/client/WaClient.d.ts +97 -0
- package/dist/types/client/WaClientFactory.d.ts +83 -0
- package/dist/types/client/coordinators/WaGroupCoordinator.d.ts +48 -0
- package/dist/types/client/coordinators/WaIncomingNodeCoordinator.d.ts +60 -0
- package/dist/types/client/coordinators/WaMessageDispatchCoordinator.d.ts +90 -0
- package/dist/types/client/coordinators/WaPassiveTasksCoordinator.d.ts +43 -0
- package/dist/types/client/coordinators/WaRetryCoordinator.d.ts +61 -0
- package/dist/types/client/coordinators/WaStreamControlCoordinator.d.ts +17 -0
- package/dist/types/client/dirty.d.ts +17 -0
- package/dist/types/client/events/chat.d.ts +3 -0
- package/dist/types/client/events/group.d.ts +7 -0
- package/dist/types/client/history-sync.d.ts +17 -0
- package/dist/types/client/incoming.d.ts +35 -0
- package/dist/types/client/index.d.ts +2 -0
- package/dist/types/client/mailbox.d.ts +12 -0
- package/dist/types/client/messages.d.ts +17 -0
- package/dist/types/client/types.d.ts +235 -0
- package/dist/types/crypto/core/constants.d.ts +1 -0
- package/dist/types/crypto/core/encoding.d.ts +11 -0
- package/dist/types/crypto/core/hkdf.d.ts +8 -0
- package/dist/types/crypto/core/index.d.ts +11 -0
- package/dist/types/crypto/core/keys.d.ts +20 -0
- package/dist/types/crypto/core/nonce.d.ts +5 -0
- package/dist/types/crypto/core/primitives.d.ts +25 -0
- package/dist/types/crypto/core/random.d.ts +8 -0
- package/dist/types/crypto/curves/Ed25519.d.ts +7 -0
- package/dist/types/crypto/curves/X25519.d.ts +8 -0
- package/dist/types/crypto/curves/constants.d.ts +2 -0
- package/dist/types/crypto/curves/types.d.ts +10 -0
- package/dist/types/crypto/index.d.ts +3 -0
- package/dist/types/crypto/math/constants.d.ts +7 -0
- package/dist/types/crypto/math/edwards.d.ts +3 -0
- package/dist/types/crypto/math/le.d.ts +2 -0
- package/dist/types/crypto/math/mod.d.ts +5 -0
- package/dist/types/crypto/math/types.d.ts +6 -0
- package/dist/types/index.d.ts +10 -0
- package/dist/types/infra/log/ConsoleLogger.d.ts +11 -0
- package/dist/types/infra/log/PinoLogger.d.ts +30 -0
- package/dist/types/infra/log/types.d.ts +9 -0
- package/dist/types/infra/perf/BoundedTaskQueue.d.ts +19 -0
- package/dist/types/media/WaMediaCrypto.d.ts +12 -0
- package/dist/types/media/WaMediaTransferClient.d.ts +81 -0
- package/dist/types/media/conn.d.ts +3 -0
- package/dist/types/media/constants.d.ts +10 -0
- package/dist/types/media/index.d.ts +4 -0
- package/dist/types/media/types.d.ts +56 -0
- package/dist/types/message/WaMessageClient.d.ts +29 -0
- package/dist/types/message/ack.d.ts +5 -0
- package/dist/types/message/content.d.ts +4 -0
- package/dist/types/message/device-sent.d.ts +3 -0
- package/dist/types/message/incoming.d.ts +18 -0
- package/dist/types/message/index.d.ts +2 -0
- package/dist/types/message/padding.d.ts +2 -0
- package/dist/types/message/phash.d.ts +1 -0
- package/dist/types/message/types.d.ts +58 -0
- package/dist/types/proto.d.ts +2 -0
- package/dist/types/protocol/appstate.d.ts +34 -0
- package/dist/types/protocol/auth.d.ts +12 -0
- package/dist/types/protocol/browser.d.ts +22 -0
- package/dist/types/protocol/constants.d.ts +11 -0
- package/dist/types/protocol/defaults.d.ts +26 -0
- package/dist/types/protocol/dirty.d.ts +15 -0
- package/dist/types/protocol/group.d.ts +6 -0
- package/dist/types/protocol/index.d.ts +11 -0
- package/dist/types/protocol/jid.d.ts +19 -0
- package/dist/types/protocol/media.d.ts +15 -0
- package/dist/types/protocol/message.d.ts +16 -0
- package/dist/types/protocol/nodes.d.ts +83 -0
- package/dist/types/protocol/notification.d.ts +50 -0
- package/dist/types/protocol/stream.d.ts +60 -0
- package/dist/types/retry/constants.d.ts +21 -0
- package/dist/types/retry/index.d.ts +7 -0
- package/dist/types/retry/outbound.d.ts +4 -0
- package/dist/types/retry/parse.d.ts +3 -0
- package/dist/types/retry/reason.d.ts +2 -0
- package/dist/types/retry/replay.d.ts +30 -0
- package/dist/types/retry/types.d.ts +70 -0
- package/dist/types/signal/api/SignalDeviceSyncApi.d.ts +31 -0
- package/dist/types/signal/api/SignalDigestSyncApi.d.ts +27 -0
- package/dist/types/signal/api/SignalIdentitySyncApi.d.ts +26 -0
- package/dist/types/signal/api/SignalMissingPreKeysSyncApi.d.ts +39 -0
- package/dist/types/signal/api/SignalRotateKeyApi.d.ts +22 -0
- package/dist/types/signal/api/SignalSessionSyncApi.d.ts +38 -0
- package/dist/types/signal/api/codec.d.ts +3 -0
- package/dist/types/signal/api/constants.d.ts +9 -0
- package/dist/types/signal/api/prekeys.d.ts +6 -0
- package/dist/types/signal/constants.d.ts +14 -0
- package/dist/types/signal/crypto/WaAdvSignature.d.ts +7 -0
- package/dist/types/signal/crypto/constants.d.ts +5 -0
- package/dist/types/signal/group/SenderKeyChain.d.ts +11 -0
- package/dist/types/signal/group/SenderKeyCodec.d.ts +14 -0
- package/dist/types/signal/group/SenderKeyManager.d.ts +22 -0
- package/dist/types/signal/index.d.ts +12 -0
- package/dist/types/signal/registration/keygen.d.ts +5 -0
- package/dist/types/signal/registration/utils.d.ts +9 -0
- package/dist/types/signal/session/SignalProtocol.d.ts +22 -0
- package/dist/types/signal/session/SignalRatchet.d.ts +25 -0
- package/dist/types/signal/session/SignalSerializer.d.ts +6 -0
- package/dist/types/signal/session/SignalSession.d.ts +43 -0
- package/dist/types/signal/store/sqlite.d.ts +72 -0
- package/dist/types/signal/types.d.ts +110 -0
- package/dist/types/store/contracts/appstate.store.d.ts +22 -0
- package/dist/types/store/contracts/auth.store.d.ts +6 -0
- package/dist/types/store/contracts/contact.store.d.ts +14 -0
- package/dist/types/store/contracts/device-list.store.d.ts +16 -0
- package/dist/types/store/contracts/message.store.d.ts +18 -0
- package/dist/types/store/contracts/participants.store.d.ts +14 -0
- package/dist/types/store/contracts/retry.store.d.ts +11 -0
- package/dist/types/store/contracts/sender-key.store.d.ts +16 -0
- package/dist/types/store/contracts/signal.store.d.ts +31 -0
- package/dist/types/store/contracts/thread.store.d.ts +17 -0
- package/dist/types/store/createStore.d.ts +2 -0
- package/dist/types/store/index.d.ts +31 -0
- package/dist/types/store/noop.store.d.ts +10 -0
- package/dist/types/store/providers/memory/appstate.store.d.ts +21 -0
- package/dist/types/store/providers/memory/contact.store.d.ts +13 -0
- package/dist/types/store/providers/memory/device-list.store.d.ts +20 -0
- package/dist/types/store/providers/memory/message.store.d.ts +14 -0
- package/dist/types/store/providers/memory/participants.store.d.ts +18 -0
- package/dist/types/store/providers/memory/retry.store.d.ts +18 -0
- package/dist/types/store/providers/memory/sender-key.store.d.ts +28 -0
- package/dist/types/store/providers/memory/signal.store.d.ts +51 -0
- package/dist/types/store/providers/memory/thread.store.d.ts +14 -0
- package/dist/types/store/providers/sqlite/BaseSqliteStore.d.ts +12 -0
- package/dist/types/store/providers/sqlite/appstate.store.d.ts +15 -0
- package/dist/types/store/providers/sqlite/auth.store.d.ts +10 -0
- package/dist/types/store/providers/sqlite/connection.d.ts +10 -0
- package/dist/types/store/providers/sqlite/contact.store.d.ts +10 -0
- package/dist/types/store/providers/sqlite/device-list.store.d.ts +18 -0
- package/dist/types/store/providers/sqlite/message.store.d.ts +11 -0
- package/dist/types/store/providers/sqlite/migrations.d.ts +3 -0
- package/dist/types/store/providers/sqlite/participants.store.d.ts +13 -0
- package/dist/types/store/providers/sqlite/retry.store.d.ts +16 -0
- package/dist/types/store/providers/sqlite/sender-key.store.d.ts +25 -0
- package/dist/types/store/providers/sqlite/signal.store.d.ts +46 -0
- package/dist/types/store/providers/sqlite/thread.store.d.ts +11 -0
- package/dist/types/store/types.d.ts +103 -0
- package/dist/types/transport/WaComms.d.ts +61 -0
- package/dist/types/transport/WaWebSocket.d.ts +36 -0
- package/dist/types/transport/binary/constants.d.ts +49 -0
- package/dist/types/transport/binary/decoder.d.ts +3 -0
- package/dist/types/transport/binary/encoder.d.ts +3 -0
- package/dist/types/transport/binary/index.d.ts +4 -0
- package/dist/types/transport/binary/tokens.d.ts +11 -0
- package/dist/types/transport/index.d.ts +7 -0
- package/dist/types/transport/keepalive/WaKeepAlive.d.ts +39 -0
- package/dist/types/transport/node/WaNodeOrchestrator.d.ts +28 -0
- package/dist/types/transport/node/WaNodeTransport.d.ts +22 -0
- package/dist/types/transport/node/builders/accountSync.d.ts +11 -0
- package/dist/types/transport/node/builders/group.d.ts +16 -0
- package/dist/types/transport/node/builders/index.d.ts +7 -0
- package/dist/types/transport/node/builders/media.d.ts +2 -0
- package/dist/types/transport/node/builders/message.d.ts +52 -0
- package/dist/types/transport/node/builders/pairing.d.ts +18 -0
- package/dist/types/transport/node/builders/prekeys.d.ts +5 -0
- package/dist/types/transport/node/builders/retry.d.ts +18 -0
- package/dist/types/transport/node/helpers.d.ts +8 -0
- package/dist/types/transport/node/query.d.ts +10 -0
- package/dist/types/transport/node/xml.d.ts +2 -0
- package/dist/types/transport/noise/WaClientPayload.d.ts +3 -0
- package/dist/types/transport/noise/WaFrameCodec.d.ts +9 -0
- package/dist/types/transport/noise/WaNoiseCert.d.ts +1 -0
- package/dist/types/transport/noise/WaNoiseHandshake.d.ts +14 -0
- package/dist/types/transport/noise/WaNoiseSession.d.ts +33 -0
- package/dist/types/transport/noise/WaNoiseSocket.d.ts +10 -0
- package/dist/types/transport/noise/constants.d.ts +7 -0
- package/dist/types/transport/noise/types.d.ts +23 -0
- package/dist/types/transport/stream/parse.d.ts +23 -0
- package/dist/types/transport/types.d.ts +71 -0
- package/dist/types/util/async.d.ts +1 -0
- package/dist/types/util/base64.d.ts +4 -0
- package/dist/types/util/bytes.d.ts +28 -0
- package/dist/types/util/coercion.d.ts +8 -0
- package/dist/types/util/collections.d.ts +3 -0
- package/dist/types/util/primitives.d.ts +7 -0
- package/dist/types/util/runtime.d.ts +2 -0
- package/dist/types/util/signal-address.d.ts +2 -0
- package/dist/util/async.js +8 -0
- package/dist/util/base64.js +24 -0
- package/dist/util/bytes.js +291 -0
- package/dist/util/coercion.js +66 -0
- package/dist/util/collections.js +32 -0
- package/dist/util/primitives.js +37 -0
- package/dist/util/runtime.js +19 -0
- package/dist/util/signal-address.js +8 -0
- package/package.json +150 -0
- package/proto/index.d.ts +10861 -0
- package/proto/index.js +1 -0
- package/scripts/check-node-version.cjs +55 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { parseCollectionName } from './utils.js';
|
|
2
|
+
import { proto } from '../proto.js';
|
|
3
|
+
import { WA_APP_STATE_COLLECTION_STATES, WA_APP_STATE_ERROR_CODES, WA_IQ_TYPES, WA_NODE_TAGS } from '../protocol/constants.js';
|
|
4
|
+
import { decodeNodeContentBase64OrBytes, findNodeChild, getNodeChildrenByTag } from '../transport/node/helpers.js';
|
|
5
|
+
export function parseSyncResponse(iqNode) {
|
|
6
|
+
if (iqNode.tag !== WA_NODE_TAGS.IQ) {
|
|
7
|
+
throw new Error(`invalid sync response tag ${iqNode.tag}`);
|
|
8
|
+
}
|
|
9
|
+
const syncNode = findNodeChild(iqNode, WA_NODE_TAGS.SYNC);
|
|
10
|
+
if (!syncNode) {
|
|
11
|
+
throw new Error('sync response is missing <sync> node');
|
|
12
|
+
}
|
|
13
|
+
const payloads = [];
|
|
14
|
+
for (const collectionNode of getNodeChildrenByTag(syncNode, WA_NODE_TAGS.COLLECTION)) {
|
|
15
|
+
const collection = parseCollectionName(collectionNode.attrs.name);
|
|
16
|
+
if (!collection) {
|
|
17
|
+
throw new Error(`invalid app-state collection name: ${collectionNode.attrs.name}`);
|
|
18
|
+
}
|
|
19
|
+
const state = parseCollectionState(collectionNode);
|
|
20
|
+
const versionAttr = collectionNode.attrs.version;
|
|
21
|
+
let version;
|
|
22
|
+
if (versionAttr) {
|
|
23
|
+
const parsedVersion = Number.parseInt(versionAttr, 10);
|
|
24
|
+
if (!Number.isSafeInteger(parsedVersion) || parsedVersion < 0) {
|
|
25
|
+
throw new Error(`invalid app-state collection version "${versionAttr}"`);
|
|
26
|
+
}
|
|
27
|
+
version = parsedVersion;
|
|
28
|
+
}
|
|
29
|
+
const patchesNode = findNodeChild(collectionNode, WA_NODE_TAGS.PATCHES);
|
|
30
|
+
const patches = patchesNode
|
|
31
|
+
? getNodeChildrenByTag(patchesNode, WA_NODE_TAGS.PATCH).map((node) => proto.SyncdPatch.decode(decodeNodeContentBase64OrBytes(node.content, 'collection.patches.patch')))
|
|
32
|
+
: [];
|
|
33
|
+
const snapshotNode = findNodeChild(collectionNode, WA_NODE_TAGS.SNAPSHOT);
|
|
34
|
+
const snapshotReference = snapshotNode
|
|
35
|
+
? proto.ExternalBlobReference.decode(decodeNodeContentBase64OrBytes(snapshotNode.content, 'collection.snapshot'))
|
|
36
|
+
: undefined;
|
|
37
|
+
payloads.push({
|
|
38
|
+
collection,
|
|
39
|
+
state,
|
|
40
|
+
version,
|
|
41
|
+
patches,
|
|
42
|
+
snapshotReference
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
return payloads;
|
|
46
|
+
}
|
|
47
|
+
export function parseCollectionState(node) {
|
|
48
|
+
const type = node.attrs.type;
|
|
49
|
+
const hasMorePatches = node.attrs.has_more_patches === 'true';
|
|
50
|
+
if (type !== WA_IQ_TYPES.ERROR) {
|
|
51
|
+
return hasMorePatches
|
|
52
|
+
? WA_APP_STATE_COLLECTION_STATES.SUCCESS_HAS_MORE
|
|
53
|
+
: WA_APP_STATE_COLLECTION_STATES.SUCCESS;
|
|
54
|
+
}
|
|
55
|
+
const errorNode = findNodeChild(node, WA_NODE_TAGS.ERROR);
|
|
56
|
+
const code = errorNode?.attrs.code;
|
|
57
|
+
if (code === WA_APP_STATE_ERROR_CODES.CONFLICT) {
|
|
58
|
+
return hasMorePatches
|
|
59
|
+
? WA_APP_STATE_COLLECTION_STATES.CONFLICT_HAS_MORE
|
|
60
|
+
: WA_APP_STATE_COLLECTION_STATES.CONFLICT;
|
|
61
|
+
}
|
|
62
|
+
if (code === WA_APP_STATE_ERROR_CODES.BAD_REQUEST ||
|
|
63
|
+
code === WA_APP_STATE_ERROR_CODES.NOT_FOUND) {
|
|
64
|
+
return WA_APP_STATE_COLLECTION_STATES.ERROR_FATAL;
|
|
65
|
+
}
|
|
66
|
+
return WA_APP_STATE_COLLECTION_STATES.ERROR_RETRY;
|
|
67
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { WA_APP_STATE_COLLECTIONS } from '../protocol/constants.js';
|
|
2
|
+
export const APP_STATE_DERIVED_KEY_LENGTH = 160;
|
|
3
|
+
export const APP_STATE_DERIVED_INDEX_KEY_END = 32;
|
|
4
|
+
export const APP_STATE_DERIVED_VALUE_ENCRYPTION_KEY_END = 64;
|
|
5
|
+
export const APP_STATE_DERIVED_VALUE_MAC_KEY_END = 96;
|
|
6
|
+
export const APP_STATE_DERIVED_SNAPSHOT_MAC_KEY_END = 128;
|
|
7
|
+
export const APP_STATE_DERIVED_PATCH_MAC_KEY_END = 160;
|
|
8
|
+
export const APP_STATE_VALUE_MAC_LENGTH = 32;
|
|
9
|
+
export const APP_STATE_MAC_OCTET_LENGTH = 8;
|
|
10
|
+
export const APP_STATE_IV_LENGTH = 16;
|
|
11
|
+
export const APP_STATE_LT_HASH_SIZE = 128;
|
|
12
|
+
export const APP_STATE_POINT_SIZE = 2;
|
|
13
|
+
export const APP_STATE_EMPTY_LT_HASH = new Uint8Array(APP_STATE_LT_HASH_SIZE);
|
|
14
|
+
export const APP_STATE_DEFAULT_COLLECTIONS = [
|
|
15
|
+
WA_APP_STATE_COLLECTIONS.CRITICAL_UNBLOCK_LOW,
|
|
16
|
+
WA_APP_STATE_COLLECTIONS.CRITICAL_BLOCK,
|
|
17
|
+
WA_APP_STATE_COLLECTIONS.REGULAR_LOW,
|
|
18
|
+
WA_APP_STATE_COLLECTIONS.REGULAR,
|
|
19
|
+
WA_APP_STATE_COLLECTIONS.REGULAR_HIGH
|
|
20
|
+
];
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export * from './constants.js';
|
|
2
|
+
export * from './utils.js';
|
|
3
|
+
export { WaAppStateCrypto } from './WaAppStateCrypto.js';
|
|
4
|
+
export { WaAppStateMissingKeyError } from './WaAppStateSyncClient.js';
|
|
5
|
+
export { parseCollectionState, parseSyncResponse } from './WaAppStateSyncResponseParser.js';
|
|
6
|
+
export { WaAppStateSyncClient } from './WaAppStateSyncClient.js';
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { proto } from '../../proto.js';
|
|
2
|
+
import { asBytes, asNumber, asOptionalBytes, asString } from '../../util/coercion.js';
|
|
3
|
+
export function encodeAppStateFingerprint(fingerprint) {
|
|
4
|
+
if (!fingerprint) {
|
|
5
|
+
return null;
|
|
6
|
+
}
|
|
7
|
+
return proto.Message.AppStateSyncKeyFingerprint.encode(fingerprint).finish();
|
|
8
|
+
}
|
|
9
|
+
export function decodeAppStateFingerprint(raw) {
|
|
10
|
+
const bytes = asOptionalBytes(raw, 'appstate_sync_keys.fingerprint');
|
|
11
|
+
if (!bytes) {
|
|
12
|
+
return undefined;
|
|
13
|
+
}
|
|
14
|
+
try {
|
|
15
|
+
return proto.Message.AppStateSyncKeyFingerprint.decode(bytes);
|
|
16
|
+
}
|
|
17
|
+
catch (error) {
|
|
18
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
19
|
+
throw new Error(`invalid appstate_sync_keys.fingerprint protobuf payload: ${reason}`);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export function decodeAppStateSyncKeys(rows) {
|
|
23
|
+
return rows.map((row) => ({
|
|
24
|
+
keyId: asBytes(row.key_id, 'appstate_sync_keys.key_id'),
|
|
25
|
+
keyData: asBytes(row.key_data, 'appstate_sync_keys.key_data'),
|
|
26
|
+
timestamp: asNumber(row.timestamp, 'appstate_sync_keys.timestamp'),
|
|
27
|
+
fingerprint: decodeAppStateFingerprint(row.fingerprint)
|
|
28
|
+
}));
|
|
29
|
+
}
|
|
30
|
+
export function decodeAppStateCollections(versionRows, valueRows) {
|
|
31
|
+
const valueMapByCollection = new Map();
|
|
32
|
+
for (const row of valueRows) {
|
|
33
|
+
const collection = asString(row.collection, 'appstate_collection_index_values.collection');
|
|
34
|
+
const byIndex = valueMapByCollection.get(collection) ?? {};
|
|
35
|
+
byIndex[asString(row.index_mac_hex, 'appstate_collection_index_values.index_mac_hex')] =
|
|
36
|
+
asBytes(row.value_mac, 'appstate_collection_index_values.value_mac');
|
|
37
|
+
valueMapByCollection.set(collection, byIndex);
|
|
38
|
+
}
|
|
39
|
+
const collections = {};
|
|
40
|
+
for (const row of versionRows) {
|
|
41
|
+
const collection = asString(row.collection, 'appstate_collection_versions.collection');
|
|
42
|
+
collections[collection] = {
|
|
43
|
+
version: asNumber(row.version, 'appstate_collection_versions.version'),
|
|
44
|
+
hash: asBytes(row.hash, 'appstate_collection_versions.hash'),
|
|
45
|
+
indexValueMap: valueMapByCollection.get(collection) ?? {}
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
return collections;
|
|
49
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { WA_APP_STATE_COLLECTIONS, WA_APP_STATE_KEY_TYPES } from '../protocol/constants.js';
|
|
2
|
+
import { decodeProtoBytes } from '../util/base64.js';
|
|
3
|
+
import { bytesToHex } from '../util/bytes.js';
|
|
4
|
+
export function keyIdToHex(keyId) {
|
|
5
|
+
return bytesToHex(keyId);
|
|
6
|
+
}
|
|
7
|
+
export function parseCollectionName(value) {
|
|
8
|
+
if (!value) {
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
for (const collection of Object.values(WA_APP_STATE_COLLECTIONS)) {
|
|
12
|
+
if (collection === value) {
|
|
13
|
+
return collection;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
export function keyDeviceId(keyId) {
|
|
19
|
+
if (keyId.byteLength < 6) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
return (keyId[0] << 8) | keyId[1];
|
|
23
|
+
}
|
|
24
|
+
export function keyEpoch(keyId) {
|
|
25
|
+
if (keyId.byteLength < 6) {
|
|
26
|
+
return -1;
|
|
27
|
+
}
|
|
28
|
+
return new DataView(keyId.buffer, keyId.byteOffset, keyId.byteLength).getUint32(2, false);
|
|
29
|
+
}
|
|
30
|
+
export function pickActiveSyncKey(keys) {
|
|
31
|
+
let active = null;
|
|
32
|
+
for (const key of keys) {
|
|
33
|
+
if (!active) {
|
|
34
|
+
active = key;
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
const currentEpoch = keyEpoch(active.keyId);
|
|
38
|
+
const nextEpoch = keyEpoch(key.keyId);
|
|
39
|
+
if (nextEpoch > currentEpoch) {
|
|
40
|
+
active = key;
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
if (nextEpoch < currentEpoch) {
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
const nextDeviceId = keyDeviceId(key.keyId);
|
|
47
|
+
const currentDeviceId = keyDeviceId(active.keyId);
|
|
48
|
+
if (nextDeviceId !== null && currentDeviceId !== null && nextDeviceId < currentDeviceId) {
|
|
49
|
+
active = key;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return active;
|
|
53
|
+
}
|
|
54
|
+
export function toNetworkOrder64(value) {
|
|
55
|
+
const out = new Uint8Array(8);
|
|
56
|
+
const view = new DataView(out.buffer);
|
|
57
|
+
view.setUint32(0, Math.floor(value / 4294967296), false);
|
|
58
|
+
view.setUint32(4, value >>> 0, false);
|
|
59
|
+
return out;
|
|
60
|
+
}
|
|
61
|
+
export async function downloadExternalBlobReference(mediaTransfer, reference) {
|
|
62
|
+
if (!reference.directPath) {
|
|
63
|
+
throw new Error('external blob reference is missing directPath');
|
|
64
|
+
}
|
|
65
|
+
const mediaKey = decodeProtoBytes(reference.mediaKey, 'external blob mediaKey');
|
|
66
|
+
const fileSha256 = decodeProtoBytes(reference.fileSha256, 'external blob fileSha256');
|
|
67
|
+
const fileEncSha256 = decodeProtoBytes(reference.fileEncSha256, 'external blob fileEncSha256');
|
|
68
|
+
return mediaTransfer.downloadAndDecrypt({
|
|
69
|
+
directPath: reference.directPath,
|
|
70
|
+
mediaType: WA_APP_STATE_KEY_TYPES.MD_APP_STATE,
|
|
71
|
+
mediaKey,
|
|
72
|
+
fileSha256,
|
|
73
|
+
fileEncSha256
|
|
74
|
+
});
|
|
75
|
+
}
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
import { buildCommsConfig, loadOrCreateCredentials, persistCredentials } from './flow/WaAuthCredentialsFlow.js';
|
|
2
|
+
import { WaPairingFlow } from './pairing/WaPairingFlow.js';
|
|
3
|
+
import { WaQrFlow } from './pairing/WaQrFlow.js';
|
|
4
|
+
import { getWaCompanionPlatformId, WA_DEFAULTS } from '../protocol/constants.js';
|
|
5
|
+
import { uint8Equal } from '../util/bytes.js';
|
|
6
|
+
import { toError } from '../util/primitives.js';
|
|
7
|
+
import { getRuntimeOsDisplayName } from '../util/runtime.js';
|
|
8
|
+
export class WaAuthClient {
|
|
9
|
+
constructor(options, deps) {
|
|
10
|
+
const deviceBrowser = options.deviceBrowser ?? WA_DEFAULTS.DEVICE_BROWSER;
|
|
11
|
+
const device = Object.freeze({
|
|
12
|
+
browser: deviceBrowser,
|
|
13
|
+
osDisplayName: options.deviceOsDisplayName ?? getRuntimeOsDisplayName(),
|
|
14
|
+
platform: options.devicePlatform ?? getWaCompanionPlatformId(deviceBrowser)
|
|
15
|
+
});
|
|
16
|
+
this.options = Object.freeze({
|
|
17
|
+
...options,
|
|
18
|
+
deviceBrowser: device.browser,
|
|
19
|
+
deviceOsDisplayName: device.osDisplayName,
|
|
20
|
+
devicePlatform: device.platform,
|
|
21
|
+
requireFullSync: options.requireFullSync
|
|
22
|
+
});
|
|
23
|
+
this.logger = deps.logger;
|
|
24
|
+
this.callbacks = deps.callbacks ?? {};
|
|
25
|
+
this.authStore = deps.authStore;
|
|
26
|
+
this.signalStore = deps.signalStore;
|
|
27
|
+
this.credentials = null;
|
|
28
|
+
this.qrFlow = new WaQrFlow({
|
|
29
|
+
logger: this.logger,
|
|
30
|
+
getCredentials: () => this.credentials,
|
|
31
|
+
getDevicePlatform: () => device.platform,
|
|
32
|
+
emitQr: (qr, ttlMs) => this.callbacks.onQr?.(qr, ttlMs)
|
|
33
|
+
});
|
|
34
|
+
this.pairingFlow = new WaPairingFlow({
|
|
35
|
+
logger: this.logger,
|
|
36
|
+
auth: {
|
|
37
|
+
getCredentials: () => this.credentials,
|
|
38
|
+
updateCredentials: this.updateCredentials.bind(this)
|
|
39
|
+
},
|
|
40
|
+
socket: deps.socket,
|
|
41
|
+
qrFlow: this.qrFlow,
|
|
42
|
+
device,
|
|
43
|
+
callbacks: {
|
|
44
|
+
emitPairingCode: (code) => this.callbacks.onPairingCode?.(code),
|
|
45
|
+
emitPairingRefresh: (forceManual) => this.callbacks.onPairingRefresh?.(forceManual),
|
|
46
|
+
emitPaired: (credentials) => this.callbacks.onPaired?.(credentials)
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
getState(connected = false) {
|
|
51
|
+
return {
|
|
52
|
+
connected,
|
|
53
|
+
registered: this.credentials?.meJid !== null && this.credentials?.meJid !== undefined,
|
|
54
|
+
hasQr: this.qrFlow.hasQr(),
|
|
55
|
+
hasPairingCode: this.pairingFlow.hasPairingSession()
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
getCurrentCredentials() {
|
|
59
|
+
return this.credentials;
|
|
60
|
+
}
|
|
61
|
+
async loadOrCreateCredentials() {
|
|
62
|
+
return this.runHandled(async () => {
|
|
63
|
+
this.logger.debug('auth client loadOrCreateCredentials start');
|
|
64
|
+
this.credentials = await loadOrCreateCredentials({
|
|
65
|
+
logger: this.logger,
|
|
66
|
+
authStore: this.authStore,
|
|
67
|
+
signalStore: this.signalStore
|
|
68
|
+
});
|
|
69
|
+
this.logger.info('auth client credentials ready', {
|
|
70
|
+
registered: this.credentials.meJid !== null && this.credentials.meJid !== undefined
|
|
71
|
+
});
|
|
72
|
+
return this.credentials;
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
buildCommsConfig(socketOptions) {
|
|
76
|
+
this.logger.trace('auth client building comms config');
|
|
77
|
+
return buildCommsConfig(this.logger, this.requireCredentials(), socketOptions, {
|
|
78
|
+
deviceBrowser: this.options.deviceBrowser,
|
|
79
|
+
deviceOsDisplayName: this.options.deviceOsDisplayName,
|
|
80
|
+
requireFullSync: this.options.requireFullSync
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
async clearTransientState() {
|
|
84
|
+
this.logger.trace('auth client clear transient state');
|
|
85
|
+
this.qrFlow.clear();
|
|
86
|
+
this.pairingFlow.clearSession();
|
|
87
|
+
}
|
|
88
|
+
async clearStoredCredentials() {
|
|
89
|
+
this.logger.warn('auth client clearing stored credentials');
|
|
90
|
+
await this.authStore.clear();
|
|
91
|
+
this.credentials = null;
|
|
92
|
+
await this.clearTransientState();
|
|
93
|
+
}
|
|
94
|
+
async persistServerStaticKey(serverStaticKey) {
|
|
95
|
+
this.logger.debug('persisting server static key', {
|
|
96
|
+
keyLength: serverStaticKey.byteLength
|
|
97
|
+
});
|
|
98
|
+
await this.patchCredentials((credentials) => ({
|
|
99
|
+
...credentials,
|
|
100
|
+
serverStaticKey
|
|
101
|
+
}));
|
|
102
|
+
}
|
|
103
|
+
async persistServerHasPreKeys(serverHasPreKeys) {
|
|
104
|
+
await this.patchCredentials((credentials) => ({
|
|
105
|
+
...credentials,
|
|
106
|
+
serverHasPreKeys
|
|
107
|
+
}), {
|
|
108
|
+
shouldPersist: (current) => current.serverHasPreKeys !== serverHasPreKeys,
|
|
109
|
+
onPersist: () => {
|
|
110
|
+
this.logger.debug('persisting serverHasPreKeys', {
|
|
111
|
+
serverHasPreKeys
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
async persistRoutingInfo(routingInfo) {
|
|
117
|
+
this.logger.trace('persisting routing info', {
|
|
118
|
+
byteLength: routingInfo.byteLength
|
|
119
|
+
});
|
|
120
|
+
await this.patchCredentials((credentials) => ({
|
|
121
|
+
...credentials,
|
|
122
|
+
routingInfo
|
|
123
|
+
}), {
|
|
124
|
+
shouldPersist: (current) => {
|
|
125
|
+
if (current.routingInfo && uint8Equal(current.routingInfo, routingInfo)) {
|
|
126
|
+
this.logger.trace('routing info unchanged, skipping persistence');
|
|
127
|
+
return false;
|
|
128
|
+
}
|
|
129
|
+
return true;
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
async clearRoutingInfo() {
|
|
134
|
+
return this.patchCredentials((credentials) => ({
|
|
135
|
+
...credentials,
|
|
136
|
+
routingInfo: undefined
|
|
137
|
+
}), {
|
|
138
|
+
shouldPersist: (current) => current.routingInfo !== undefined,
|
|
139
|
+
onPersist: () => {
|
|
140
|
+
this.logger.warn('clearing persisted routing info');
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
async persistMeLid(meLid) {
|
|
145
|
+
await this.persistSuccessAttributes({
|
|
146
|
+
meLid
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
async persistSuccessAttributes(attributes) {
|
|
150
|
+
let changes = {};
|
|
151
|
+
await this.patchCredentials((credentials) => {
|
|
152
|
+
const nextMeLid = attributes.meLid ?? credentials.meLid;
|
|
153
|
+
const nextMeDisplayName = attributes.meDisplayName ?? credentials.meDisplayName;
|
|
154
|
+
const nextCompanionEncStatic = attributes.companionEncStatic ?? credentials.companionEncStatic;
|
|
155
|
+
const nextLastSuccessTs = attributes.lastSuccessTs ?? credentials.lastSuccessTs;
|
|
156
|
+
const nextPropsVersion = attributes.propsVersion ?? credentials.propsVersion;
|
|
157
|
+
const nextAbPropsVersion = attributes.abPropsVersion ?? credentials.abPropsVersion;
|
|
158
|
+
const nextConnectionLocation = attributes.connectionLocation ?? credentials.connectionLocation;
|
|
159
|
+
const nextAccountCreationTs = attributes.accountCreationTs ?? credentials.accountCreationTs;
|
|
160
|
+
changes = {
|
|
161
|
+
lidChanged: nextMeLid !== credentials.meLid,
|
|
162
|
+
displayNameChanged: nextMeDisplayName !== credentials.meDisplayName,
|
|
163
|
+
companionChanged: (credentials.companionEncStatic === undefined) !==
|
|
164
|
+
(nextCompanionEncStatic === undefined) ||
|
|
165
|
+
(credentials.companionEncStatic !== undefined &&
|
|
166
|
+
nextCompanionEncStatic !== undefined &&
|
|
167
|
+
!uint8Equal(credentials.companionEncStatic, nextCompanionEncStatic)),
|
|
168
|
+
lastSuccessTsChanged: nextLastSuccessTs !== credentials.lastSuccessTs,
|
|
169
|
+
propsVersionChanged: nextPropsVersion !== credentials.propsVersion,
|
|
170
|
+
abPropsVersionChanged: nextAbPropsVersion !== credentials.abPropsVersion,
|
|
171
|
+
connectionLocationChanged: nextConnectionLocation !== credentials.connectionLocation,
|
|
172
|
+
accountCreationTsChanged: nextAccountCreationTs !== credentials.accountCreationTs
|
|
173
|
+
};
|
|
174
|
+
return {
|
|
175
|
+
...credentials,
|
|
176
|
+
meLid: nextMeLid,
|
|
177
|
+
meDisplayName: nextMeDisplayName,
|
|
178
|
+
companionEncStatic: nextCompanionEncStatic,
|
|
179
|
+
lastSuccessTs: nextLastSuccessTs,
|
|
180
|
+
propsVersion: nextPropsVersion,
|
|
181
|
+
abPropsVersion: nextAbPropsVersion,
|
|
182
|
+
connectionLocation: nextConnectionLocation,
|
|
183
|
+
accountCreationTs: nextAccountCreationTs
|
|
184
|
+
};
|
|
185
|
+
}, {
|
|
186
|
+
shouldPersist: () => Object.values(changes).some(Boolean),
|
|
187
|
+
onPersist: () => {
|
|
188
|
+
this.logger.debug('persisting success attributes', changes);
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
async requestPairingCode(phoneNumber, shouldShowPushNotification = false) {
|
|
193
|
+
this.requireCredentials();
|
|
194
|
+
this.logger.info('auth client requesting pairing code');
|
|
195
|
+
return this.runHandled(() => this.pairingFlow.requestPairingCode(phoneNumber, shouldShowPushNotification));
|
|
196
|
+
}
|
|
197
|
+
async fetchPairingCountryCodeIso() {
|
|
198
|
+
this.requireCredentials();
|
|
199
|
+
this.logger.trace('auth client fetching pairing country code ISO');
|
|
200
|
+
return this.runHandled(() => this.pairingFlow.fetchPairingCountryCodeIso());
|
|
201
|
+
}
|
|
202
|
+
async handleIncomingIqSet(node) {
|
|
203
|
+
return this.runHandled(async () => {
|
|
204
|
+
this.logger.trace('auth client handleIncomingIqSet', { id: node.attrs.id });
|
|
205
|
+
return this.pairingFlow.handleIncomingIqSet(node);
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
async handleLinkCodeNotification(node) {
|
|
209
|
+
return this.runHandled(async () => {
|
|
210
|
+
this.logger.trace('auth client handleLinkCodeNotification', { id: node.attrs.id });
|
|
211
|
+
return this.pairingFlow.handleLinkCodeNotification(node);
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
async handleCompanionRegRefreshNotification(node) {
|
|
215
|
+
return this.runHandled(async () => {
|
|
216
|
+
this.logger.trace('auth client handleCompanionRegRefreshNotification', {
|
|
217
|
+
id: node.attrs.id
|
|
218
|
+
});
|
|
219
|
+
return this.pairingFlow.handleCompanionRegRefreshNotification(node);
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
async patchCredentials(buildNext, options = {}) {
|
|
223
|
+
const current = this.requireCredentials();
|
|
224
|
+
const next = buildNext(current);
|
|
225
|
+
if (options.shouldPersist && !options.shouldPersist(current, next)) {
|
|
226
|
+
return current;
|
|
227
|
+
}
|
|
228
|
+
options.onPersist?.(current, next);
|
|
229
|
+
await this.updateCredentials(next);
|
|
230
|
+
return next;
|
|
231
|
+
}
|
|
232
|
+
async runHandled(action) {
|
|
233
|
+
try {
|
|
234
|
+
return await action();
|
|
235
|
+
}
|
|
236
|
+
catch (error) {
|
|
237
|
+
this.handleError(toError(error));
|
|
238
|
+
throw error;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
async updateCredentials(credentials) {
|
|
242
|
+
this.logger.trace('auth client update credentials', {
|
|
243
|
+
registered: credentials.meJid !== null && credentials.meJid !== undefined
|
|
244
|
+
});
|
|
245
|
+
this.credentials = credentials;
|
|
246
|
+
await persistCredentials({
|
|
247
|
+
logger: this.logger,
|
|
248
|
+
authStore: this.authStore,
|
|
249
|
+
signalStore: this.signalStore
|
|
250
|
+
}, credentials);
|
|
251
|
+
}
|
|
252
|
+
requireCredentials() {
|
|
253
|
+
if (!this.credentials) {
|
|
254
|
+
throw new Error('credentials are not initialized');
|
|
255
|
+
}
|
|
256
|
+
return this.credentials;
|
|
257
|
+
}
|
|
258
|
+
handleError(error) {
|
|
259
|
+
this.logger.error('wa auth client error', { message: error.message });
|
|
260
|
+
this.callbacks.onError?.(error);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { randomBytesAsync } from '../../crypto/index.js';
|
|
2
|
+
import { toSerializedPubKey } from '../../crypto/core/keys.js';
|
|
3
|
+
import { X25519 } from '../../crypto/curves/X25519.js';
|
|
4
|
+
import { getLoginIdentity } from '../../protocol/jid.js';
|
|
5
|
+
import { verifySignalSignature } from '../../signal/crypto/WaAdvSignature.js';
|
|
6
|
+
import { createAndStoreInitialKeys } from '../../signal/registration/utils.js';
|
|
7
|
+
import { toError } from '../../util/primitives.js';
|
|
8
|
+
export async function loadOrCreateCredentials(args) {
|
|
9
|
+
args.logger.trace('auth credentials loadOrCreate start');
|
|
10
|
+
const existing = await args.authStore.load();
|
|
11
|
+
if (!existing) {
|
|
12
|
+
const credentials = await createAndPersistFreshCredentials(args);
|
|
13
|
+
args.logger.info('created fresh auth credentials');
|
|
14
|
+
return credentials;
|
|
15
|
+
}
|
|
16
|
+
args.logger.debug('auth credentials loaded from store', {
|
|
17
|
+
registered: existing.meJid !== null && existing.meJid !== undefined,
|
|
18
|
+
hasServerStaticKey: existing.serverStaticKey !== null && existing.serverStaticKey !== undefined
|
|
19
|
+
});
|
|
20
|
+
if (!existing.meJid && !(await hasValidSignedPreKey(args.logger, existing))) {
|
|
21
|
+
args.logger.warn('signed pre-key is invalid, regenerating credentials');
|
|
22
|
+
const fresh = await createAndPersistFreshCredentials(args);
|
|
23
|
+
args.logger.info('regenerated credentials due to invalid signed pre-key');
|
|
24
|
+
return fresh;
|
|
25
|
+
}
|
|
26
|
+
await restoreSignalStore(args.signalStore, existing);
|
|
27
|
+
args.logger.trace('auth credentials restored into signal store');
|
|
28
|
+
return existing;
|
|
29
|
+
}
|
|
30
|
+
export async function persistCredentials(args, credentials) {
|
|
31
|
+
args.logger.trace('persisting auth credentials', {
|
|
32
|
+
registered: credentials.meJid !== null && credentials.meJid !== undefined
|
|
33
|
+
});
|
|
34
|
+
await args.authStore.save(credentials);
|
|
35
|
+
}
|
|
36
|
+
export function buildCommsConfig(logger, credentials, socketOptions, clientOptions) {
|
|
37
|
+
const registered = credentials.meJid !== null && credentials.meJid !== undefined;
|
|
38
|
+
const loginIdentity = registered ? getLoginIdentity(credentials.meJid) : null;
|
|
39
|
+
logger.debug('building comms config from credentials', {
|
|
40
|
+
registered,
|
|
41
|
+
hasServerStaticKey: credentials.serverStaticKey !== null && credentials.serverStaticKey !== undefined
|
|
42
|
+
});
|
|
43
|
+
return {
|
|
44
|
+
url: socketOptions.url,
|
|
45
|
+
urls: socketOptions.urls,
|
|
46
|
+
protocols: socketOptions.protocols,
|
|
47
|
+
connectTimeoutMs: socketOptions.connectTimeoutMs,
|
|
48
|
+
reconnectIntervalMs: socketOptions.reconnectIntervalMs,
|
|
49
|
+
timeoutIntervalMs: socketOptions.timeoutIntervalMs,
|
|
50
|
+
maxReconnectAttempts: socketOptions.maxReconnectAttempts,
|
|
51
|
+
noise: {
|
|
52
|
+
clientStaticKeyPair: credentials.noiseKeyPair,
|
|
53
|
+
isRegistered: registered,
|
|
54
|
+
serverStaticKey: credentials.serverStaticKey,
|
|
55
|
+
routingInfo: credentials.routingInfo,
|
|
56
|
+
loginPayloadConfig: loginIdentity
|
|
57
|
+
? {
|
|
58
|
+
username: loginIdentity.username,
|
|
59
|
+
device: loginIdentity.device,
|
|
60
|
+
deviceBrowser: clientOptions.deviceBrowser,
|
|
61
|
+
deviceOsDisplayName: clientOptions.deviceOsDisplayName
|
|
62
|
+
}
|
|
63
|
+
: undefined,
|
|
64
|
+
registrationPayloadConfig: !loginIdentity
|
|
65
|
+
? {
|
|
66
|
+
registrationInfo: credentials.registrationInfo,
|
|
67
|
+
signedPreKey: credentials.signedPreKey,
|
|
68
|
+
deviceBrowser: clientOptions.deviceBrowser,
|
|
69
|
+
deviceOsDisplayName: clientOptions.deviceOsDisplayName,
|
|
70
|
+
requireFullSync: clientOptions.requireFullSync
|
|
71
|
+
}
|
|
72
|
+
: undefined
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
async function createFreshCredentials(signalStore, logger) {
|
|
77
|
+
logger.trace('creating fresh credentials');
|
|
78
|
+
const [noiseKeyPair, registrationBundle, advSecretKey] = await Promise.all([
|
|
79
|
+
X25519.generateKeyPair(),
|
|
80
|
+
createAndStoreInitialKeys(signalStore),
|
|
81
|
+
randomBytesAsync(32)
|
|
82
|
+
]);
|
|
83
|
+
return {
|
|
84
|
+
noiseKeyPair,
|
|
85
|
+
registrationInfo: registrationBundle.registrationInfo,
|
|
86
|
+
signedPreKey: registrationBundle.signedPreKey,
|
|
87
|
+
serverHasPreKeys: false,
|
|
88
|
+
advSecretKey
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
async function createAndPersistFreshCredentials(args) {
|
|
92
|
+
const credentials = await createFreshCredentials(args.signalStore, args.logger);
|
|
93
|
+
await persistFreshCredentials(args, credentials);
|
|
94
|
+
return credentials;
|
|
95
|
+
}
|
|
96
|
+
async function hasValidSignedPreKey(logger, credentials) {
|
|
97
|
+
try {
|
|
98
|
+
const serializedPubKey = toSerializedPubKey(credentials.signedPreKey.keyPair.pubKey);
|
|
99
|
+
const valid = await verifySignalSignature(credentials.registrationInfo.identityKeyPair.pubKey, serializedPubKey, credentials.signedPreKey.signature);
|
|
100
|
+
logger.trace('signed pre-key validation completed', { valid });
|
|
101
|
+
return valid;
|
|
102
|
+
}
|
|
103
|
+
catch (error) {
|
|
104
|
+
logger.warn('signed pre-key validation failed with exception', {
|
|
105
|
+
message: toError(error).message
|
|
106
|
+
});
|
|
107
|
+
return false;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
async function restoreSignalStore(signalStore, credentials) {
|
|
111
|
+
await signalStore.setRegistrationInfo(credentials.registrationInfo);
|
|
112
|
+
await signalStore.setSignedPreKey(credentials.signedPreKey);
|
|
113
|
+
await signalStore.setServerHasPreKeys(credentials.serverHasPreKeys === true);
|
|
114
|
+
}
|
|
115
|
+
async function persistFreshCredentials(args, credentials) {
|
|
116
|
+
await args.authStore.save(credentials);
|
|
117
|
+
await restoreSignalStore(args.signalStore, credentials);
|
|
118
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export * from './types.js';
|
|
2
|
+
export { getLoginIdentity } from '../protocol/jid.js';
|
|
3
|
+
export { WaAuthClient } from './WaAuthClient.js';
|
|
4
|
+
export { completeCompanionFinish, createCompanionHello } from './pairing/WaPairingCodeCrypto.js';
|
|
5
|
+
export { WaAuthSqliteStore } from '../store/providers/sqlite/auth.store.js';
|