zapo-js 0.1.0 → 0.1.2
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 +12 -7
- package/dist/appstate/WaAppStateCrypto.js +18 -25
- package/dist/appstate/WaAppStateSyncClient.js +181 -114
- package/dist/appstate/WaAppStateSyncResponseParser.js +16 -5
- package/dist/appstate/constants.js +4 -3
- package/dist/appstate/utils.js +10 -30
- package/dist/auth/WaAuthClient.js +48 -55
- package/dist/auth/flow/WaAuthCredentialsFlow.js +21 -14
- package/dist/auth/index.js +1 -3
- package/dist/auth/pairing/WaPairingFlow.js +21 -23
- package/dist/auth/pairing/WaQrFlow.js +37 -24
- package/dist/client/WaClient.js +103 -276
- package/dist/client/WaClientFactory.js +227 -110
- package/dist/client/connection/WaConnectionManager.js +292 -0
- package/dist/client/connection/WaKeyShareCoordinator.js +63 -0
- package/dist/client/connection/WaReceiptQueue.js +51 -0
- package/dist/client/coordinators/WaAppStateMutationCoordinator.js +471 -0
- package/dist/client/coordinators/WaGroupCoordinator.js +27 -17
- package/dist/client/coordinators/WaIncomingNodeCoordinator.js +20 -27
- package/dist/client/coordinators/WaMessageDispatchCoordinator.js +231 -686
- package/dist/client/coordinators/WaRetryCoordinator.js +70 -37
- package/dist/client/dirty.js +35 -29
- package/dist/client/events/chat.js +4 -3
- package/dist/client/events/group.js +59 -36
- package/dist/client/history-sync.js +53 -63
- package/dist/client/incoming.js +23 -20
- package/dist/client/mailbox.js +8 -8
- package/dist/client/messages.js +4 -4
- package/dist/client/messaging/fanout.js +189 -0
- package/dist/client/messaging/key-protocol.js +130 -0
- package/dist/client/messaging/participants.js +191 -0
- package/dist/crypto/core/hkdf.js +3 -8
- package/dist/crypto/core/index.js +1 -4
- package/dist/crypto/core/keys.js +2 -3
- package/dist/crypto/core/primitives.js +12 -15
- package/dist/crypto/core/random.js +7 -26
- package/dist/crypto/curves/Ed25519.js +7 -8
- package/dist/crypto/curves/X25519.js +13 -16
- package/dist/crypto/index.js +0 -5
- package/dist/esm/appstate/WaAppStateCrypto.js +6 -13
- package/dist/esm/appstate/WaAppStateSyncClient.js +174 -107
- package/dist/esm/appstate/WaAppStateSyncResponseParser.js +17 -6
- package/dist/esm/appstate/constants.js +3 -2
- package/dist/esm/appstate/utils.js +8 -27
- package/dist/esm/auth/WaAuthClient.js +48 -55
- package/dist/esm/auth/flow/WaAuthCredentialsFlow.js +21 -14
- package/dist/esm/auth/index.js +0 -1
- package/dist/esm/auth/pairing/WaPairingFlow.js +14 -16
- package/dist/esm/auth/pairing/WaQrFlow.js +37 -24
- package/dist/esm/client/WaClient.js +103 -276
- package/dist/esm/client/WaClientFactory.js +227 -110
- package/dist/esm/client/connection/WaConnectionManager.js +288 -0
- package/dist/esm/client/connection/WaKeyShareCoordinator.js +59 -0
- package/dist/esm/client/connection/WaReceiptQueue.js +47 -0
- package/dist/esm/client/coordinators/WaAppStateMutationCoordinator.js +467 -0
- package/dist/esm/client/coordinators/WaGroupCoordinator.js +20 -10
- package/dist/esm/client/coordinators/WaIncomingNodeCoordinator.js +20 -27
- package/dist/esm/client/coordinators/WaMessageDispatchCoordinator.js +232 -687
- package/dist/esm/client/coordinators/WaRetryCoordinator.js +71 -38
- package/dist/esm/client/dirty.js +30 -24
- package/dist/esm/client/events/chat.js +4 -3
- package/dist/esm/client/events/group.js +50 -28
- package/dist/esm/client/history-sync.js +50 -60
- package/dist/esm/client/incoming.js +23 -20
- package/dist/esm/client/mailbox.js +8 -8
- package/dist/esm/client/messages.js +1 -1
- package/dist/esm/client/messaging/fanout.js +186 -0
- package/dist/esm/client/messaging/key-protocol.js +127 -0
- package/dist/esm/client/messaging/participants.js +188 -0
- package/dist/esm/crypto/core/hkdf.js +3 -8
- package/dist/esm/crypto/core/index.js +0 -1
- package/dist/esm/crypto/core/keys.js +2 -3
- package/dist/esm/crypto/core/primitives.js +12 -15
- package/dist/esm/crypto/core/random.js +6 -25
- package/dist/esm/crypto/curves/Ed25519.js +4 -5
- package/dist/esm/crypto/curves/X25519.js +10 -13
- package/dist/esm/crypto/index.js +0 -2
- package/dist/esm/infra/log/ConsoleLogger.js +18 -17
- package/dist/esm/infra/log/PinoLogger.js +15 -9
- package/dist/esm/infra/log/types.js +11 -1
- package/dist/esm/infra/perf/BoundedTaskQueue.js +13 -17
- package/dist/esm/media/WaMediaCrypto.js +2 -4
- package/dist/esm/media/WaMediaTransferClient.js +226 -58
- package/dist/esm/media/conn.js +10 -6
- package/dist/esm/media/constants.js +4 -1
- package/dist/esm/message/WaMessageClient.js +4 -13
- package/dist/esm/message/ack.js +6 -6
- package/dist/esm/message/addon-crypto.js +59 -0
- package/dist/esm/message/incoming.js +106 -111
- package/dist/esm/message/index.js +2 -0
- package/dist/esm/message/reporting-token.js +438 -0
- package/dist/esm/message/use-case-secret.js +49 -0
- package/dist/esm/protocol/appstate.js +58 -0
- package/dist/esm/protocol/constants.js +2 -1
- package/dist/esm/protocol/index.js +2 -10
- package/dist/esm/protocol/jid.js +63 -51
- package/dist/esm/protocol/media.js +3 -3
- package/dist/esm/protocol/nodes.js +2 -0
- package/dist/esm/protocol/usync.js +11 -0
- package/dist/esm/retry/index.js +1 -0
- package/dist/esm/retry/outbound.js +4 -5
- package/dist/esm/retry/parse.js +58 -76
- package/dist/esm/retry/replay.js +48 -49
- package/dist/esm/retry/tracker.js +56 -0
- package/dist/esm/signal/api/SignalDeviceSyncApi.js +249 -82
- package/dist/esm/signal/api/SignalDigestSyncApi.js +6 -1
- package/dist/esm/signal/api/SignalIdentitySyncApi.js +49 -34
- package/dist/esm/signal/api/SignalMissingPreKeysSyncApi.js +70 -62
- package/dist/esm/signal/api/SignalSessionSyncApi.js +23 -30
- package/dist/esm/signal/crypto/WaAdvSignature.js +3 -5
- package/dist/esm/signal/group/SenderKeyChain.js +28 -23
- package/dist/esm/signal/group/SenderKeyCodec.js +2 -4
- package/dist/esm/signal/group/SenderKeyManager.js +26 -16
- package/dist/esm/signal/index.js +1 -0
- package/dist/esm/signal/session/SignalProtocol.js +49 -14
- package/dist/esm/signal/session/SignalRatchet.js +24 -15
- package/dist/esm/signal/session/SignalSession.js +14 -9
- package/dist/esm/signal/session/resolver.js +186 -0
- package/dist/esm/signal/store/sqlite.js +16 -37
- package/dist/esm/store/createStore.js +16 -18
- package/dist/esm/store/noop.store.js +3 -6
- package/dist/esm/store/providers/memory/appstate.store.js +30 -6
- package/dist/esm/store/providers/memory/contact.store.js +5 -0
- package/dist/esm/store/providers/memory/device-list.store.js +3 -30
- package/dist/esm/store/providers/memory/message.store.js +11 -5
- package/dist/esm/store/providers/memory/participants.store.js +1 -8
- package/dist/esm/store/providers/memory/sender-key.store.js +5 -7
- package/dist/esm/store/providers/memory/signal.store.js +13 -1
- package/dist/esm/store/providers/memory/thread.store.js +5 -0
- package/dist/esm/store/providers/sqlite/appstate.store.js +82 -1
- package/dist/esm/store/providers/sqlite/connection.js +18 -13
- package/dist/esm/store/providers/sqlite/contact.store.js +31 -18
- package/dist/esm/store/providers/sqlite/device-list.store.js +7 -35
- package/dist/esm/store/providers/sqlite/message.store.js +45 -32
- package/dist/esm/store/providers/sqlite/migrations.js +1 -1
- package/dist/esm/store/providers/sqlite/participants.store.js +1 -9
- package/dist/esm/store/providers/sqlite/retry.store.js +8 -11
- package/dist/esm/store/providers/sqlite/sender-key.store.js +25 -30
- package/dist/esm/store/providers/sqlite/signal.store.js +104 -22
- package/dist/esm/store/providers/sqlite/table-names.js +107 -0
- package/dist/esm/store/providers/sqlite/thread.store.js +35 -22
- package/dist/esm/transport/WaComms.js +25 -23
- package/dist/esm/transport/WaWebSocket.js +115 -12
- package/dist/esm/transport/binary/decoder.js +4 -4
- package/dist/esm/transport/binary/encoder.js +12 -4
- package/dist/esm/transport/index.js +1 -0
- package/dist/esm/transport/keepalive/WaKeepAlive.js +2 -8
- package/dist/esm/transport/node/WaNodeOrchestrator.js +2 -4
- package/dist/esm/transport/node/WaNodeTransport.js +0 -3
- package/dist/esm/transport/node/builders/{accountSync.js → account-sync.js} +16 -36
- package/dist/esm/transport/node/builders/index.js +2 -1
- package/dist/esm/transport/node/builders/message.js +9 -0
- package/dist/esm/transport/node/builders/pairing.js +4 -5
- package/dist/esm/transport/node/builders/usync.js +41 -0
- package/dist/esm/transport/node/helpers.js +107 -5
- package/dist/esm/transport/node/usync.js +35 -0
- package/dist/esm/transport/noise/WaFrameCodec.js +48 -33
- package/dist/esm/transport/noise/WaNoiseCert.js +3 -6
- package/dist/esm/transport/noise/WaNoiseSession.js +17 -10
- package/dist/esm/transport/proxy.js +27 -0
- package/dist/esm/transport/stream/parse.js +13 -48
- package/dist/esm/util/bytes.js +50 -32
- package/dist/esm/util/coercion.js +6 -14
- package/dist/esm/util/primitives.js +39 -14
- package/dist/infra/log/ConsoleLogger.js +18 -17
- package/dist/infra/log/PinoLogger.js +15 -9
- package/dist/infra/log/types.js +12 -0
- package/dist/infra/perf/BoundedTaskQueue.js +13 -17
- package/dist/media/WaMediaCrypto.js +1 -3
- package/dist/media/WaMediaTransferClient.js +259 -58
- package/dist/media/conn.js +10 -6
- package/dist/media/constants.js +4 -1
- package/dist/message/WaMessageClient.js +5 -14
- package/dist/message/ack.js +6 -6
- package/dist/message/addon-crypto.js +65 -0
- package/dist/message/incoming.js +104 -109
- package/dist/message/index.js +2 -0
- package/dist/message/reporting-token.js +443 -0
- package/dist/message/use-case-secret.js +55 -0
- package/dist/protocol/appstate.js +59 -1
- package/dist/protocol/constants.js +7 -1
- package/dist/protocol/index.js +20 -42
- package/dist/protocol/jid.js +64 -51
- package/dist/protocol/media.js +3 -3
- package/dist/protocol/nodes.js +2 -0
- package/dist/protocol/usync.js +14 -0
- package/dist/retry/index.js +3 -1
- package/dist/retry/outbound.js +6 -7
- package/dist/retry/parse.js +57 -75
- package/dist/retry/replay.js +46 -47
- package/dist/retry/tracker.js +59 -0
- package/dist/signal/api/SignalDeviceSyncApi.js +247 -80
- package/dist/signal/api/SignalDigestSyncApi.js +6 -1
- package/dist/signal/api/SignalIdentitySyncApi.js +49 -34
- package/dist/signal/api/SignalMissingPreKeysSyncApi.js +67 -59
- package/dist/signal/api/SignalSessionSyncApi.js +23 -30
- package/dist/signal/crypto/WaAdvSignature.js +2 -4
- package/dist/signal/group/SenderKeyChain.js +27 -22
- package/dist/signal/group/SenderKeyCodec.js +1 -3
- package/dist/signal/group/SenderKeyManager.js +26 -16
- package/dist/signal/index.js +3 -1
- package/dist/signal/session/SignalProtocol.js +49 -14
- package/dist/signal/session/SignalRatchet.js +24 -15
- package/dist/signal/session/SignalSession.js +14 -9
- package/dist/signal/session/resolver.js +189 -0
- package/dist/signal/store/sqlite.js +16 -37
- package/dist/store/createStore.js +16 -18
- package/dist/store/noop.store.js +3 -6
- package/dist/store/providers/memory/appstate.store.js +28 -4
- package/dist/store/providers/memory/contact.store.js +5 -0
- package/dist/store/providers/memory/device-list.store.js +3 -30
- package/dist/store/providers/memory/message.store.js +11 -5
- package/dist/store/providers/memory/participants.store.js +1 -8
- package/dist/store/providers/memory/sender-key.store.js +8 -10
- package/dist/store/providers/memory/signal.store.js +21 -9
- package/dist/store/providers/memory/thread.store.js +5 -0
- package/dist/store/providers/sqlite/appstate.store.js +81 -0
- package/dist/store/providers/sqlite/connection.js +18 -13
- package/dist/store/providers/sqlite/contact.store.js +31 -18
- package/dist/store/providers/sqlite/device-list.store.js +7 -35
- package/dist/store/providers/sqlite/message.store.js +45 -32
- package/dist/store/providers/sqlite/migrations.js +1 -1
- package/dist/store/providers/sqlite/participants.store.js +1 -9
- package/dist/store/providers/sqlite/retry.store.js +8 -11
- package/dist/store/providers/sqlite/sender-key.store.js +24 -29
- package/dist/store/providers/sqlite/signal.store.js +105 -23
- package/dist/store/providers/sqlite/table-names.js +113 -0
- package/dist/store/providers/sqlite/thread.store.js +35 -22
- package/dist/transport/WaComms.js +27 -25
- package/dist/transport/WaWebSocket.js +148 -12
- package/dist/transport/binary/decoder.js +4 -4
- package/dist/transport/binary/encoder.js +12 -4
- package/dist/transport/index.js +7 -1
- package/dist/transport/keepalive/WaKeepAlive.js +1 -7
- package/dist/transport/node/WaNodeOrchestrator.js +2 -4
- package/dist/transport/node/WaNodeTransport.js +0 -3
- package/dist/transport/node/builders/{accountSync.js → account-sync.js} +15 -35
- package/dist/transport/node/builders/index.js +12 -9
- package/dist/transport/node/builders/message.js +9 -0
- package/dist/transport/node/builders/pairing.js +4 -5
- package/dist/transport/node/builders/usync.js +45 -0
- package/dist/transport/node/helpers.js +112 -4
- package/dist/transport/node/usync.js +38 -0
- package/dist/transport/noise/WaFrameCodec.js +47 -32
- package/dist/transport/noise/WaNoiseCert.js +5 -8
- package/dist/transport/noise/WaNoiseSession.js +17 -10
- package/dist/transport/proxy.js +34 -0
- package/dist/transport/stream/parse.js +17 -53
- package/dist/types/appstate/WaAppStateCrypto.d.ts +0 -1
- package/dist/types/appstate/WaAppStateSyncClient.d.ts +5 -2
- package/dist/types/appstate/constants.d.ts +1 -0
- package/dist/types/appstate/store/sqlite.d.ts +4 -18
- package/dist/types/appstate/utils.d.ts +0 -1
- package/dist/types/auth/WaAuthClient.d.ts +10 -12
- package/dist/types/auth/index.d.ts +0 -2
- package/dist/types/auth/pairing/WaQrFlow.d.ts +1 -1
- package/dist/types/auth/types.d.ts +6 -9
- package/dist/types/client/WaClient.d.ts +27 -25
- package/dist/types/client/WaClientFactory.d.ts +22 -23
- package/dist/types/client/connection/WaConnectionManager.d.ts +64 -0
- package/dist/types/client/connection/WaKeyShareCoordinator.d.ts +14 -0
- package/dist/types/client/connection/WaReceiptQueue.d.ts +13 -0
- package/dist/types/client/coordinators/WaAppStateMutationCoordinator.d.ts +46 -0
- package/dist/types/client/coordinators/WaIncomingNodeCoordinator.d.ts +0 -1
- package/dist/types/client/coordinators/WaMessageDispatchCoordinator.d.ts +18 -41
- package/dist/types/client/coordinators/WaRetryCoordinator.d.ts +2 -0
- package/dist/types/client/dirty.d.ts +1 -0
- package/dist/types/client/events/group.d.ts +2 -1
- package/dist/types/client/index.d.ts +1 -1
- package/dist/types/client/messaging/fanout.d.ts +14 -0
- package/dist/types/client/messaging/key-protocol.d.ts +18 -0
- package/dist/types/client/messaging/participants.d.ts +13 -0
- package/dist/types/client/types.d.ts +24 -1
- package/dist/types/crypto/core/hkdf.d.ts +0 -6
- package/dist/types/crypto/core/index.d.ts +0 -1
- package/dist/types/crypto/core/random.d.ts +1 -7
- package/dist/types/crypto/index.d.ts +0 -2
- package/dist/types/index.d.ts +1 -1
- package/dist/types/infra/log/ConsoleLogger.d.ts +2 -1
- package/dist/types/infra/log/PinoLogger.d.ts +1 -1
- package/dist/types/infra/log/types.d.ts +1 -0
- package/dist/types/infra/perf/BoundedTaskQueue.d.ts +1 -1
- package/dist/types/media/WaMediaTransferClient.d.ts +13 -3
- package/dist/types/media/types.d.ts +5 -0
- package/dist/types/message/addon-crypto.d.ts +25 -0
- package/dist/types/message/index.d.ts +2 -0
- package/dist/types/message/reporting-token.d.ts +19 -0
- package/dist/types/message/use-case-secret.d.ts +20 -0
- package/dist/types/protocol/appstate.d.ts +58 -0
- package/dist/types/protocol/constants.d.ts +2 -1
- package/dist/types/protocol/index.d.ts +2 -10
- package/dist/types/protocol/jid.d.ts +3 -3
- package/dist/types/protocol/nodes.d.ts +2 -0
- package/dist/types/protocol/usync.d.ts +11 -0
- package/dist/types/retry/index.d.ts +1 -0
- package/dist/types/retry/replay.d.ts +0 -4
- package/dist/types/retry/tracker.d.ts +19 -0
- package/dist/types/retry/types.d.ts +4 -3
- package/dist/types/signal/api/SignalDeviceSyncApi.d.ts +13 -1
- package/dist/types/signal/group/SenderKeyCodec.d.ts +4 -6
- package/dist/types/signal/index.d.ts +1 -0
- package/dist/types/signal/session/SignalProtocol.d.ts +9 -0
- package/dist/types/signal/session/resolver.d.ts +17 -0
- package/dist/types/store/contracts/appstate.store.d.ts +3 -0
- package/dist/types/store/contracts/contact.store.d.ts +1 -0
- package/dist/types/store/contracts/device-list.store.d.ts +0 -3
- package/dist/types/store/contracts/message.store.d.ts +1 -0
- package/dist/types/store/contracts/participants.store.d.ts +0 -1
- package/dist/types/store/contracts/sender-key.store.d.ts +0 -1
- package/dist/types/store/contracts/signal.store.d.ts +6 -0
- package/dist/types/store/contracts/thread.store.d.ts +1 -0
- package/dist/types/store/index.d.ts +1 -1
- package/dist/types/store/providers/memory/appstate.store.d.ts +2 -0
- package/dist/types/store/providers/memory/contact.store.d.ts +1 -0
- package/dist/types/store/providers/memory/device-list.store.d.ts +0 -3
- package/dist/types/store/providers/memory/message.store.d.ts +1 -0
- package/dist/types/store/providers/memory/participants.store.d.ts +0 -1
- package/dist/types/store/providers/memory/sender-key.store.d.ts +0 -1
- package/dist/types/store/providers/memory/signal.store.d.ts +6 -0
- package/dist/types/store/providers/memory/thread.store.d.ts +1 -0
- package/dist/types/store/providers/sqlite/appstate.store.d.ts +2 -0
- package/dist/types/store/providers/sqlite/contact.store.d.ts +2 -0
- package/dist/types/store/providers/sqlite/device-list.store.d.ts +0 -3
- package/dist/types/store/providers/sqlite/message.store.d.ts +2 -0
- package/dist/types/store/providers/sqlite/participants.store.d.ts +0 -1
- package/dist/types/store/providers/sqlite/retry.store.d.ts +0 -1
- package/dist/types/store/providers/sqlite/sender-key.store.d.ts +0 -1
- package/dist/types/store/providers/sqlite/signal.store.d.ts +7 -0
- package/dist/types/store/providers/sqlite/table-names.d.ts +5 -0
- package/dist/types/store/providers/sqlite/thread.store.d.ts +2 -0
- package/dist/types/store/types.d.ts +3 -0
- package/dist/types/transport/WaWebSocket.d.ts +3 -0
- package/dist/types/transport/index.d.ts +2 -1
- package/dist/types/transport/keepalive/WaKeepAlive.d.ts +0 -1
- package/dist/types/transport/node/WaNodeTransport.d.ts +0 -9
- package/dist/types/transport/node/builders/group.d.ts +4 -6
- package/dist/types/transport/node/builders/index.d.ts +2 -1
- package/dist/types/transport/node/builders/message.d.ts +14 -25
- package/dist/types/transport/node/builders/retry.d.ts +2 -4
- package/dist/types/transport/node/builders/usync.d.ts +21 -0
- package/dist/types/transport/node/helpers.d.ts +8 -0
- package/dist/types/transport/node/usync.d.ts +2 -0
- package/dist/types/transport/noise/WaFrameCodec.d.ts +3 -0
- package/dist/types/transport/noise/WaNoiseSession.d.ts +1 -0
- package/dist/types/transport/proxy.d.ts +6 -0
- package/dist/types/transport/stream/parse.d.ts +0 -1
- package/dist/types/transport/types.d.ts +18 -1
- package/dist/types/util/bytes.d.ts +5 -0
- package/dist/types/util/primitives.d.ts +3 -0
- package/dist/util/bytes.js +55 -33
- package/dist/util/coercion.js +6 -14
- package/dist/util/primitives.js +42 -14
- package/package.json +27 -9
- package/proto/index.d.ts +1090 -1048
- package/proto/index.js +1 -1
- package/scripts/check-node-version.cjs +0 -1
- package/dist/crypto/core/encoding.js +0 -29
- package/dist/esm/crypto/core/encoding.js +0 -25
- package/dist/esm/util/base64.js +0 -18
- package/dist/esm/util/signal-address.js +0 -5
- package/dist/types/crypto/core/encoding.d.ts +0 -11
- package/dist/types/util/base64.d.ts +0 -4
- package/dist/types/util/signal-address.d.ts +0 -2
- package/dist/util/base64.js +0 -24
- package/dist/util/signal-address.js +0 -8
- /package/dist/types/transport/node/builders/{accountSync.d.ts → account-sync.d.ts} +0 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export function isProxyDispatcher(value) {
|
|
2
|
+
return (typeof value === 'object' &&
|
|
3
|
+
value !== null &&
|
|
4
|
+
'dispatch' in value &&
|
|
5
|
+
typeof value.dispatch === 'function');
|
|
6
|
+
}
|
|
7
|
+
export function isProxyAgent(value) {
|
|
8
|
+
return (typeof value === 'object' &&
|
|
9
|
+
value !== null &&
|
|
10
|
+
'addRequest' in value &&
|
|
11
|
+
typeof value.addRequest === 'function');
|
|
12
|
+
}
|
|
13
|
+
export function isProxyTransport(value) {
|
|
14
|
+
return isProxyDispatcher(value) || isProxyAgent(value);
|
|
15
|
+
}
|
|
16
|
+
export function toProxyDispatcher(proxy) {
|
|
17
|
+
if (!proxy || !isProxyDispatcher(proxy)) {
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
20
|
+
return proxy;
|
|
21
|
+
}
|
|
22
|
+
export function toProxyAgent(proxy) {
|
|
23
|
+
if (!proxy || !isProxyAgent(proxy)) {
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
return proxy;
|
|
27
|
+
}
|
|
@@ -1,74 +1,39 @@
|
|
|
1
1
|
import { WA_STREAM_SIGNALING } from '../../protocol/constants.js';
|
|
2
2
|
import { findNodeChild, hasNodeChild } from '../node/helpers.js';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
if (!/^\d+$/.test(value)) {
|
|
6
|
-
return undefined;
|
|
7
|
-
}
|
|
8
|
-
const parsed = Number(value);
|
|
9
|
-
if (!Number.isSafeInteger(parsed)) {
|
|
10
|
-
return undefined;
|
|
11
|
-
}
|
|
12
|
-
return parsed;
|
|
13
|
-
}
|
|
3
|
+
import { base64ToBytesChecked } from '../../util/bytes.js';
|
|
4
|
+
import { parseOptionalInt, parseStrictUnsignedInt } from '../../util/primitives.js';
|
|
14
5
|
export function parseStreamControlNode(node) {
|
|
15
6
|
if (node.tag === WA_STREAM_SIGNALING.XML_STREAM_END_TAG) {
|
|
16
|
-
return {
|
|
17
|
-
kind: 'xmlstreamend'
|
|
18
|
-
};
|
|
7
|
+
return { kind: 'xmlstreamend' };
|
|
19
8
|
}
|
|
20
9
|
if (node.tag !== WA_STREAM_SIGNALING.STREAM_ERROR_TAG) {
|
|
21
10
|
return null;
|
|
22
11
|
}
|
|
23
12
|
const conflictNode = findNodeChild(node, WA_STREAM_SIGNALING.CONFLICT_TAG);
|
|
24
13
|
if (conflictNode) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
return {
|
|
31
|
-
kind: 'stream_error_device_removed'
|
|
32
|
-
};
|
|
14
|
+
return conflictNode.attrs.type === WA_STREAM_SIGNALING.REPLACED_TYPE
|
|
15
|
+
? { kind: 'stream_error_replaced' }
|
|
16
|
+
: { kind: 'stream_error_device_removed' };
|
|
33
17
|
}
|
|
34
|
-
const
|
|
35
|
-
if (
|
|
36
|
-
|
|
37
|
-
if (code !== undefined) {
|
|
38
|
-
return {
|
|
39
|
-
kind: 'stream_error_code',
|
|
40
|
-
code
|
|
41
|
-
};
|
|
42
|
-
}
|
|
18
|
+
const code = node.attrs.code ? parseStrictUnsignedInt(node.attrs.code) : undefined;
|
|
19
|
+
if (code !== undefined) {
|
|
20
|
+
return { kind: 'stream_error_code', code };
|
|
43
21
|
}
|
|
44
22
|
const ackNode = findNodeChild(node, WA_STREAM_SIGNALING.ACK_TAG);
|
|
45
23
|
if (ackNode) {
|
|
46
|
-
return {
|
|
47
|
-
kind: 'stream_error_ack',
|
|
48
|
-
id: ackNode.attrs.id
|
|
49
|
-
};
|
|
24
|
+
return { kind: 'stream_error_ack', id: ackNode.attrs.id };
|
|
50
25
|
}
|
|
51
26
|
if (hasNodeChild(node, WA_STREAM_SIGNALING.XML_NOT_WELL_FORMED_TAG)) {
|
|
52
|
-
return {
|
|
53
|
-
kind: 'stream_error_xml_not_well_formed'
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
return {
|
|
57
|
-
kind: 'stream_error_other'
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
export function parseOptionalInt(value) {
|
|
61
|
-
if (!value) {
|
|
62
|
-
return undefined;
|
|
27
|
+
return { kind: 'stream_error_xml_not_well_formed' };
|
|
63
28
|
}
|
|
64
|
-
return
|
|
29
|
+
return { kind: 'stream_error_other' };
|
|
65
30
|
}
|
|
66
31
|
export function parseCompanionEncStatic(value, onError) {
|
|
67
32
|
if (!value) {
|
|
68
33
|
return undefined;
|
|
69
34
|
}
|
|
70
35
|
try {
|
|
71
|
-
return
|
|
36
|
+
return base64ToBytesChecked(value, 'success.companion_enc_static');
|
|
72
37
|
}
|
|
73
38
|
catch (error) {
|
|
74
39
|
if (error instanceof Error) {
|
package/dist/esm/util/bytes.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { timingSafeEqual } from 'node:crypto';
|
|
2
2
|
export const TEXT_ENCODER = new TextEncoder();
|
|
3
3
|
export const TEXT_DECODER = new TextDecoder();
|
|
4
|
+
export const ZERO_BYTES = new Uint8Array([0]);
|
|
4
5
|
export const EMPTY_BYTES = Object.freeze(new Uint8Array(0));
|
|
5
6
|
const HEX_CHARS = '0123456789abcdef';
|
|
6
7
|
const HEX_TABLE = /* @__PURE__ */ (() => {
|
|
@@ -90,28 +91,52 @@ export function base64ToBytes(value) {
|
|
|
90
91
|
out[j++] = ((b & 0x0f) << 4) | (c >> 2);
|
|
91
92
|
out[j++] = ((c & 0x03) << 6) | d;
|
|
92
93
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
94
|
+
const a = lookupBase64(value.charCodeAt(i));
|
|
95
|
+
const b = lookupBase64(value.charCodeAt(i + 1));
|
|
96
|
+
out[j++] = (a << 2) | (b >> 4);
|
|
97
|
+
if (j < outLen) {
|
|
96
98
|
const c = lookupBase64(value.charCodeAt(i + 2));
|
|
97
|
-
const d = lookupBase64(value.charCodeAt(i + 3));
|
|
98
|
-
out[j++] = (a << 2) | (b >> 4);
|
|
99
99
|
out[j++] = ((b & 0x0f) << 4) | (c >> 2);
|
|
100
|
-
|
|
100
|
+
if (j < outLen) {
|
|
101
|
+
const d = lookupBase64(value.charCodeAt(i + 3));
|
|
102
|
+
out[j++] = ((c & 0x03) << 6) | d;
|
|
103
|
+
}
|
|
101
104
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
out[j++] = ((b & 0x0f) << 4) | (c >> 2);
|
|
105
|
+
return out;
|
|
106
|
+
}
|
|
107
|
+
export function base64ToBytesChecked(value, field, requireNonEmpty = true) {
|
|
108
|
+
if (requireNonEmpty && value.length === 0) {
|
|
109
|
+
throw new Error(`invalid base64 payload for ${field}`);
|
|
108
110
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
111
|
+
return base64ToBytes(value);
|
|
112
|
+
}
|
|
113
|
+
export function decodeBase64Url(value, field) {
|
|
114
|
+
if (!value) {
|
|
115
|
+
throw new Error(`missing ${field}`);
|
|
116
|
+
}
|
|
117
|
+
const padded = value
|
|
118
|
+
.replace(/-/g, '+')
|
|
119
|
+
.replace(/_/g, '/')
|
|
120
|
+
.padEnd(Math.ceil(value.length / 4) * 4, '=');
|
|
121
|
+
return base64ToBytesChecked(padded, field);
|
|
122
|
+
}
|
|
123
|
+
export function assertByteLength(value, expectedLength, errorMessage, throwOnMismatch = true) {
|
|
124
|
+
if (value.length !== expectedLength) {
|
|
125
|
+
if (!throwOnMismatch) {
|
|
126
|
+
return false;
|
|
127
|
+
}
|
|
128
|
+
throw new Error(errorMessage);
|
|
113
129
|
}
|
|
114
|
-
return
|
|
130
|
+
return true;
|
|
131
|
+
}
|
|
132
|
+
export function decodeProtoBytes(value, field) {
|
|
133
|
+
if (value === null || value === undefined) {
|
|
134
|
+
throw new Error(`missing protobuf bytes field ${field}`);
|
|
135
|
+
}
|
|
136
|
+
if (value instanceof Uint8Array) {
|
|
137
|
+
return value;
|
|
138
|
+
}
|
|
139
|
+
return base64ToBytes(value);
|
|
115
140
|
}
|
|
116
141
|
function lookupBase64(code) {
|
|
117
142
|
if (code > 127) {
|
|
@@ -180,28 +205,21 @@ export function concatBytes(parts) {
|
|
|
180
205
|
}
|
|
181
206
|
export function toBytesView(value) {
|
|
182
207
|
if (value instanceof Uint8Array) {
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
return new Uint8Array(value.buffer, value.byteOffset, value.byteLength);
|
|
208
|
+
return value.constructor === Uint8Array
|
|
209
|
+
? value
|
|
210
|
+
: new Uint8Array(value.buffer, value.byteOffset, value.byteLength);
|
|
187
211
|
}
|
|
188
|
-
if (ArrayBuffer
|
|
189
|
-
return new Uint8Array(value
|
|
212
|
+
if (value instanceof ArrayBuffer) {
|
|
213
|
+
return new Uint8Array(value);
|
|
190
214
|
}
|
|
191
|
-
return new Uint8Array(value);
|
|
215
|
+
return new Uint8Array(value.buffer, value.byteOffset, value.byteLength);
|
|
192
216
|
}
|
|
193
217
|
export function toChunkBytes(chunk) {
|
|
194
|
-
if (chunk instanceof Uint8Array) {
|
|
195
|
-
return chunk;
|
|
196
|
-
}
|
|
197
|
-
if (chunk instanceof ArrayBuffer) {
|
|
198
|
-
return new Uint8Array(chunk);
|
|
199
|
-
}
|
|
200
218
|
if (typeof chunk === 'string') {
|
|
201
219
|
return TEXT_ENCODER.encode(chunk);
|
|
202
220
|
}
|
|
203
|
-
if (ArrayBuffer.isView(chunk)) {
|
|
204
|
-
return
|
|
221
|
+
if (chunk instanceof Uint8Array || chunk instanceof ArrayBuffer || ArrayBuffer.isView(chunk)) {
|
|
222
|
+
return toBytesView(chunk);
|
|
205
223
|
}
|
|
206
224
|
throw new Error(`unsupported stream chunk type: ${typeof chunk}`);
|
|
207
225
|
}
|
|
@@ -10,9 +10,8 @@ export function asNumber(value, field) {
|
|
|
10
10
|
throw new Error(`invalid number value for ${field}`);
|
|
11
11
|
}
|
|
12
12
|
export function asOptionalNumber(value, field = 'optional number') {
|
|
13
|
-
if (value === null || value === undefined)
|
|
13
|
+
if (value === null || value === undefined)
|
|
14
14
|
return undefined;
|
|
15
|
-
}
|
|
16
15
|
return asNumber(value, field);
|
|
17
16
|
}
|
|
18
17
|
export function asString(value, field) {
|
|
@@ -22,9 +21,8 @@ export function asString(value, field) {
|
|
|
22
21
|
throw new Error(`invalid string value for ${field}`);
|
|
23
22
|
}
|
|
24
23
|
export function asOptionalString(value, field = 'optional string') {
|
|
25
|
-
if (value === null || value === undefined)
|
|
24
|
+
if (value === null || value === undefined)
|
|
26
25
|
return undefined;
|
|
27
|
-
}
|
|
28
26
|
return asString(value, field);
|
|
29
27
|
}
|
|
30
28
|
export function asBytes(value, field) {
|
|
@@ -34,23 +32,17 @@ export function asBytes(value, field) {
|
|
|
34
32
|
throw new Error(`invalid bytes value for ${field}`);
|
|
35
33
|
}
|
|
36
34
|
export function asOptionalBytes(value, field = 'optional bytes') {
|
|
37
|
-
if (value === null || value === undefined)
|
|
35
|
+
if (value === null || value === undefined)
|
|
38
36
|
return undefined;
|
|
39
|
-
}
|
|
40
37
|
return asBytes(value, field);
|
|
41
38
|
}
|
|
42
39
|
export function toBoolOrUndef(value) {
|
|
43
|
-
|
|
44
|
-
return undefined;
|
|
45
|
-
}
|
|
46
|
-
return Boolean(value);
|
|
40
|
+
return value === null || value === undefined ? undefined : Boolean(value);
|
|
47
41
|
}
|
|
48
42
|
export function resolvePositive(value, fallback, name) {
|
|
49
|
-
if (value === undefined)
|
|
43
|
+
if (value === undefined)
|
|
50
44
|
return fallback;
|
|
51
|
-
|
|
52
|
-
if (Number.isSafeInteger(value) && value > 0) {
|
|
45
|
+
if (Number.isSafeInteger(value) && value > 0)
|
|
53
46
|
return value;
|
|
54
|
-
}
|
|
55
47
|
throw new Error(`${name} must be a positive safe integer`);
|
|
56
48
|
}
|
|
@@ -1,32 +1,57 @@
|
|
|
1
1
|
export function toError(value) {
|
|
2
|
-
if (value instanceof Error)
|
|
2
|
+
if (value instanceof Error)
|
|
3
3
|
return value;
|
|
4
|
-
|
|
5
|
-
if (typeof value === 'string') {
|
|
4
|
+
if (typeof value === 'string')
|
|
6
5
|
return new Error(value);
|
|
6
|
+
if (typeof value === 'number' || typeof value === 'boolean' || typeof value === 'bigint') {
|
|
7
|
+
return new Error(String(value));
|
|
8
|
+
}
|
|
9
|
+
if (value && typeof value === 'object') {
|
|
10
|
+
const message = value.message;
|
|
11
|
+
if (typeof message === 'string' && message.length > 0) {
|
|
12
|
+
return new Error(message);
|
|
13
|
+
}
|
|
14
|
+
const code = value.code;
|
|
15
|
+
if (typeof code === 'string' || typeof code === 'number') {
|
|
16
|
+
return new Error(`unknown error (${code})`);
|
|
17
|
+
}
|
|
7
18
|
}
|
|
8
19
|
return new Error('unknown error');
|
|
9
20
|
}
|
|
10
21
|
function assertSafeInteger(value, field, nullishBehavior) {
|
|
11
|
-
if (
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
return value;
|
|
22
|
+
if (Number.isFinite(value) && Number.isSafeInteger(value))
|
|
23
|
+
return value;
|
|
24
|
+
const prefix = nullishBehavior === 'throw' ? `invalid ${field}` : 'invalid long numeric value';
|
|
25
|
+
throw new Error(`${prefix}: ${value}`);
|
|
16
26
|
}
|
|
17
27
|
export function toSafeNumber(value, field) {
|
|
18
|
-
if (value === null || value === undefined)
|
|
28
|
+
if (value === null || value === undefined)
|
|
19
29
|
throw new Error(`missing ${field}`);
|
|
20
|
-
}
|
|
21
30
|
const numeric = typeof value === 'number' ? value : value.toNumber?.();
|
|
22
|
-
if (typeof numeric !== 'number')
|
|
31
|
+
if (typeof numeric !== 'number')
|
|
23
32
|
throw new Error(`invalid ${field}`);
|
|
24
|
-
}
|
|
25
33
|
return assertSafeInteger(numeric, field, 'throw');
|
|
26
34
|
}
|
|
27
35
|
export function longToNumber(value) {
|
|
28
|
-
if (value === null || value === undefined)
|
|
36
|
+
if (value === null || value === undefined)
|
|
29
37
|
return 0;
|
|
30
|
-
}
|
|
31
38
|
return assertSafeInteger(typeof value === 'number' ? value : value.toNumber(), '', 'zero');
|
|
32
39
|
}
|
|
40
|
+
export function normalizeNonNegativeInteger(value, fallback) {
|
|
41
|
+
if (typeof value !== 'number' || !Number.isFinite(value))
|
|
42
|
+
return fallback;
|
|
43
|
+
return Math.max(0, Math.trunc(value));
|
|
44
|
+
}
|
|
45
|
+
export function parseStrictUnsignedInt(value) {
|
|
46
|
+
if (!/^\d+$/.test(value))
|
|
47
|
+
return undefined;
|
|
48
|
+
const parsed = Number(value);
|
|
49
|
+
if (!Number.isSafeInteger(parsed))
|
|
50
|
+
return undefined;
|
|
51
|
+
return parsed;
|
|
52
|
+
}
|
|
53
|
+
export function parseOptionalInt(value) {
|
|
54
|
+
if (!value)
|
|
55
|
+
return undefined;
|
|
56
|
+
return parseStrictUnsignedInt(value);
|
|
57
|
+
}
|
|
@@ -8,37 +8,38 @@ const LOG_LEVEL_PRIORITY = {
|
|
|
8
8
|
warn: 40,
|
|
9
9
|
error: 50
|
|
10
10
|
};
|
|
11
|
+
const CONSOLE_WRITERS = {
|
|
12
|
+
trace: console.debug,
|
|
13
|
+
debug: console.debug,
|
|
14
|
+
info: console.info,
|
|
15
|
+
warn: console.warn,
|
|
16
|
+
error: console.error
|
|
17
|
+
};
|
|
11
18
|
class ConsoleLogger {
|
|
12
19
|
constructor(level = 'info') {
|
|
13
20
|
this.level = level;
|
|
21
|
+
this.minLevelPriority = LOG_LEVEL_PRIORITY[level];
|
|
14
22
|
}
|
|
15
23
|
trace(message, context) {
|
|
16
|
-
|
|
17
|
-
console.debug(message, context);
|
|
18
|
-
}
|
|
24
|
+
this.write('trace', message, context);
|
|
19
25
|
}
|
|
20
26
|
debug(message, context) {
|
|
21
|
-
|
|
22
|
-
console.debug(message, context);
|
|
23
|
-
}
|
|
27
|
+
this.write('debug', message, context);
|
|
24
28
|
}
|
|
25
29
|
info(message, context) {
|
|
26
|
-
|
|
27
|
-
console.info(message, context);
|
|
28
|
-
}
|
|
30
|
+
this.write('info', message, context);
|
|
29
31
|
}
|
|
30
32
|
warn(message, context) {
|
|
31
|
-
|
|
32
|
-
console.warn(message, context);
|
|
33
|
-
}
|
|
33
|
+
this.write('warn', message, context);
|
|
34
34
|
}
|
|
35
35
|
error(message, context) {
|
|
36
|
-
|
|
37
|
-
console.error(message, context);
|
|
38
|
-
}
|
|
36
|
+
this.write('error', message, context);
|
|
39
37
|
}
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
write(level, message, context) {
|
|
39
|
+
if (LOG_LEVEL_PRIORITY[level] < this.minLevelPriority) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
CONSOLE_WRITERS[level](message, context);
|
|
42
43
|
}
|
|
43
44
|
}
|
|
44
45
|
exports.ConsoleLogger = ConsoleLogger;
|
|
@@ -60,26 +60,32 @@ class PinoLogger {
|
|
|
60
60
|
this.logger.level = level;
|
|
61
61
|
}
|
|
62
62
|
trace(message, context) {
|
|
63
|
-
this.
|
|
63
|
+
this.write('trace', message, context);
|
|
64
64
|
}
|
|
65
65
|
debug(message, context) {
|
|
66
|
-
this.
|
|
66
|
+
this.write('debug', message, context);
|
|
67
67
|
}
|
|
68
68
|
info(message, context) {
|
|
69
|
-
this.
|
|
69
|
+
this.write('info', message, context);
|
|
70
70
|
}
|
|
71
71
|
warn(message, context) {
|
|
72
|
-
this.
|
|
72
|
+
this.write('warn', message, context);
|
|
73
73
|
}
|
|
74
74
|
error(message, context) {
|
|
75
|
-
this.
|
|
75
|
+
this.write('error', message, context);
|
|
76
76
|
}
|
|
77
|
-
|
|
78
|
-
if (
|
|
79
|
-
this.logger[
|
|
77
|
+
write(level, message, context) {
|
|
78
|
+
if (context === null || context === undefined) {
|
|
79
|
+
this.logger[level](message);
|
|
80
80
|
return;
|
|
81
81
|
}
|
|
82
|
-
|
|
82
|
+
for (const key in context) {
|
|
83
|
+
if (Object.prototype.hasOwnProperty.call(context, key)) {
|
|
84
|
+
this.logger[level](context, message);
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
this.logger[level](message);
|
|
83
89
|
}
|
|
84
90
|
}
|
|
85
91
|
exports.PinoLogger = PinoLogger;
|
package/dist/infra/log/types.js
CHANGED
|
@@ -1,2 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createNoopLogger = createNoopLogger;
|
|
4
|
+
function noop() { }
|
|
5
|
+
function createNoopLogger(level = 'trace') {
|
|
6
|
+
return {
|
|
7
|
+
level,
|
|
8
|
+
trace: noop,
|
|
9
|
+
debug: noop,
|
|
10
|
+
info: noop,
|
|
11
|
+
warn: noop,
|
|
12
|
+
error: noop
|
|
13
|
+
};
|
|
14
|
+
}
|
|
@@ -11,6 +11,16 @@ class BoundedTaskQueueFullError extends Error {
|
|
|
11
11
|
exports.BoundedTaskQueueFullError = BoundedTaskQueueFullError;
|
|
12
12
|
class BoundedTaskQueue {
|
|
13
13
|
constructor(maxQueueSize = 256, maxConcurrency = 1) {
|
|
14
|
+
this.settleTask = () => {
|
|
15
|
+
this.running--;
|
|
16
|
+
if (this.head >= 1024 && this.head * 2 >= this.queue.length) {
|
|
17
|
+
const remaining = this.queue.length - this.head;
|
|
18
|
+
this.queue.copyWithin(0, this.head);
|
|
19
|
+
this.queue.length = remaining;
|
|
20
|
+
this.head = 0;
|
|
21
|
+
}
|
|
22
|
+
this.drain();
|
|
23
|
+
};
|
|
14
24
|
if (maxQueueSize <= 0) {
|
|
15
25
|
throw new Error('maxQueueSize must be > 0');
|
|
16
26
|
}
|
|
@@ -29,8 +39,8 @@ class BoundedTaskQueue {
|
|
|
29
39
|
}
|
|
30
40
|
return new Promise((resolve, reject) => {
|
|
31
41
|
this.queue.push({
|
|
32
|
-
task,
|
|
33
|
-
resolve:
|
|
42
|
+
task: task,
|
|
43
|
+
resolve: resolve,
|
|
34
44
|
reject
|
|
35
45
|
});
|
|
36
46
|
this.drain();
|
|
@@ -46,22 +56,8 @@ class BoundedTaskQueue {
|
|
|
46
56
|
while (this.running < this.maxConcurrency && this.head < this.queue.length) {
|
|
47
57
|
const item = this.queue[this.head++];
|
|
48
58
|
this.running++;
|
|
49
|
-
item.task()
|
|
50
|
-
.then(item.resolve)
|
|
51
|
-
.catch(item.reject)
|
|
52
|
-
.finally(() => {
|
|
53
|
-
this.running--;
|
|
54
|
-
this.compactIfNeeded();
|
|
55
|
-
this.drain();
|
|
56
|
-
});
|
|
59
|
+
void item.task().then(item.resolve, item.reject).finally(this.settleTask);
|
|
57
60
|
}
|
|
58
61
|
}
|
|
59
|
-
compactIfNeeded() {
|
|
60
|
-
if (this.head < 1024 || this.head * 2 < this.queue.length) {
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
this.queue.splice(0, this.head);
|
|
64
|
-
this.head = 0;
|
|
65
|
-
}
|
|
66
62
|
}
|
|
67
63
|
exports.BoundedTaskQueue = BoundedTaskQueue;
|
|
@@ -16,9 +16,7 @@ class WaMediaCrypto {
|
|
|
16
16
|
return (0, random_1.randomBytesAsync)(32);
|
|
17
17
|
}
|
|
18
18
|
static async deriveKeys(mediaType, mediaKey) {
|
|
19
|
-
|
|
20
|
-
throw new Error(`invalid media key length ${mediaKey.byteLength}, expected 32`);
|
|
21
|
-
}
|
|
19
|
+
(0, bytes_1.assertByteLength)(mediaKey, 32, `invalid media key length ${mediaKey.byteLength}, expected 32`);
|
|
22
20
|
const info = mediaTypeToHkdfInfo(mediaType);
|
|
23
21
|
const expanded = await (0, hkdf_1.hkdf)(mediaKey, null, info, constants_1.MEDIA_HKDF_SIZE);
|
|
24
22
|
return {
|