@open-e2ee/signal-protocol-sdk 0.1.0-alpha.1
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/ADAPTERS.md +195 -0
- package/ARCHITECTURE.md +206 -0
- package/CHANGELOG.md +13 -0
- package/LICENSE +661 -0
- package/NOTICE +27 -0
- package/README.md +152 -0
- package/SECURITY.md +125 -0
- package/THIRD_PARTY_NOTICES.md +31 -0
- package/TROUBLESHOOTING.md +203 -0
- package/blocking/README.md +42 -0
- package/client/README.md +169 -0
- package/device/README.md +166 -0
- package/dist/blocking/index.d.ts +4 -0
- package/dist/blocking/index.d.ts.map +1 -0
- package/dist/blocking/index.js +2 -0
- package/dist/blocking/index.js.map +1 -0
- package/dist/blocking/manager.d.ts +27 -0
- package/dist/blocking/manager.d.ts.map +1 -0
- package/dist/blocking/manager.js +61 -0
- package/dist/blocking/manager.js.map +1 -0
- package/dist/blocking/types.d.ts +43 -0
- package/dist/blocking/types.d.ts.map +1 -0
- package/dist/blocking/types.js +9 -0
- package/dist/blocking/types.js.map +1 -0
- package/dist/client/client.d.ts +1281 -0
- package/dist/client/client.d.ts.map +1 -0
- package/dist/client/client.js +2296 -0
- package/dist/client/client.js.map +1 -0
- package/dist/client/compose.d.ts +105 -0
- package/dist/client/compose.d.ts.map +1 -0
- package/dist/client/compose.js +41 -0
- package/dist/client/compose.js.map +1 -0
- package/dist/client/config.d.ts +707 -0
- package/dist/client/config.d.ts.map +1 -0
- package/dist/client/config.js +19 -0
- package/dist/client/config.js.map +1 -0
- package/dist/client/constants.d.ts +48 -0
- package/dist/client/constants.d.ts.map +1 -0
- package/dist/client/constants.js +40 -0
- package/dist/client/constants.js.map +1 -0
- package/dist/client/content-adapter.d.ts +106 -0
- package/dist/client/content-adapter.d.ts.map +1 -0
- package/dist/client/content-adapter.js +423 -0
- package/dist/client/content-adapter.js.map +1 -0
- package/dist/client/dual-store.d.ts +70 -0
- package/dist/client/dual-store.d.ts.map +1 -0
- package/dist/client/dual-store.js +123 -0
- package/dist/client/dual-store.js.map +1 -0
- package/dist/client/endorsement-manager.d.ts +143 -0
- package/dist/client/endorsement-manager.d.ts.map +1 -0
- package/dist/client/endorsement-manager.js +259 -0
- package/dist/client/endorsement-manager.js.map +1 -0
- package/dist/client/event-hooks.d.ts +330 -0
- package/dist/client/event-hooks.d.ts.map +1 -0
- package/dist/client/event-hooks.js +59 -0
- package/dist/client/event-hooks.js.map +1 -0
- package/dist/client/files.d.ts +73 -0
- package/dist/client/files.d.ts.map +1 -0
- package/dist/client/files.js +192 -0
- package/dist/client/files.js.map +1 -0
- package/dist/client/groups.d.ts +204 -0
- package/dist/client/groups.d.ts.map +1 -0
- package/dist/client/groups.js +340 -0
- package/dist/client/groups.js.map +1 -0
- package/dist/client/headless.d.ts +99 -0
- package/dist/client/headless.d.ts.map +1 -0
- package/dist/client/headless.js +163 -0
- package/dist/client/headless.js.map +1 -0
- package/dist/client/index.d.ts +33 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +7 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/key-rotation-core.d.ts +167 -0
- package/dist/client/key-rotation-core.d.ts.map +1 -0
- package/dist/client/key-rotation-core.js +459 -0
- package/dist/client/key-rotation-core.js.map +1 -0
- package/dist/client/key-rotation.d.ts +45 -0
- package/dist/client/key-rotation.d.ts.map +1 -0
- package/dist/client/key-rotation.js +174 -0
- package/dist/client/key-rotation.js.map +1 -0
- package/dist/client/media.d.ts +173 -0
- package/dist/client/media.d.ts.map +1 -0
- package/dist/client/media.js +476 -0
- package/dist/client/media.js.map +1 -0
- package/dist/client/messages.d.ts +131 -0
- package/dist/client/messages.d.ts.map +1 -0
- package/dist/client/messages.js +546 -0
- package/dist/client/messages.js.map +1 -0
- package/dist/client/multi-device.d.ts +73 -0
- package/dist/client/multi-device.d.ts.map +1 -0
- package/dist/client/multi-device.js +104 -0
- package/dist/client/multi-device.js.map +1 -0
- package/dist/client/prekeys.d.ts +133 -0
- package/dist/client/prekeys.d.ts.map +1 -0
- package/dist/client/prekeys.js +608 -0
- package/dist/client/prekeys.js.map +1 -0
- package/dist/client/relay-subscription.d.ts +83 -0
- package/dist/client/relay-subscription.d.ts.map +1 -0
- package/dist/client/relay-subscription.js +353 -0
- package/dist/client/relay-subscription.js.map +1 -0
- package/dist/client/retry-utils.d.ts +42 -0
- package/dist/client/retry-utils.d.ts.map +1 -0
- package/dist/client/retry-utils.js +107 -0
- package/dist/client/retry-utils.js.map +1 -0
- package/dist/client/retry.d.ts +121 -0
- package/dist/client/retry.d.ts.map +1 -0
- package/dist/client/retry.js +499 -0
- package/dist/client/retry.js.map +1 -0
- package/dist/client/sealed-sender-ops.d.ts +61 -0
- package/dist/client/sealed-sender-ops.d.ts.map +1 -0
- package/dist/client/sealed-sender-ops.js +173 -0
- package/dist/client/sealed-sender-ops.js.map +1 -0
- package/dist/client/sessions.d.ts +108 -0
- package/dist/client/sessions.d.ts.map +1 -0
- package/dist/client/sessions.js +367 -0
- package/dist/client/sessions.js.map +1 -0
- package/dist/client/signal-service-cipher.d.ts +331 -0
- package/dist/client/signal-service-cipher.d.ts.map +1 -0
- package/dist/client/signal-service-cipher.js +1506 -0
- package/dist/client/signal-service-cipher.js.map +1 -0
- package/dist/client/state.d.ts +147 -0
- package/dist/client/state.d.ts.map +1 -0
- package/dist/client/state.js +226 -0
- package/dist/client/state.js.map +1 -0
- package/dist/client/types.d.ts +423 -0
- package/dist/client/types.d.ts.map +1 -0
- package/dist/client/types.js +42 -0
- package/dist/client/types.js.map +1 -0
- package/dist/device/connection.d.ts +46 -0
- package/dist/device/connection.d.ts.map +1 -0
- package/dist/device/connection.js +239 -0
- package/dist/device/connection.js.map +1 -0
- package/dist/device/constants.d.ts +69 -0
- package/dist/device/constants.d.ts.map +1 -0
- package/dist/device/constants.js +64 -0
- package/dist/device/constants.js.map +1 -0
- package/dist/device/device-id.d.ts +45 -0
- package/dist/device/device-id.d.ts.map +1 -0
- package/dist/device/device-id.js +87 -0
- package/dist/device/device-id.js.map +1 -0
- package/dist/device/device-name-crypto.d.ts +39 -0
- package/dist/device/device-name-crypto.d.ts.map +1 -0
- package/dist/device/device-name-crypto.js +165 -0
- package/dist/device/device-name-crypto.js.map +1 -0
- package/dist/device/index.d.ts +31 -0
- package/dist/device/index.d.ts.map +1 -0
- package/dist/device/index.js +35 -0
- package/dist/device/index.js.map +1 -0
- package/dist/device/lifecycle/index.d.ts +25 -0
- package/dist/device/lifecycle/index.d.ts.map +1 -0
- package/dist/device/lifecycle/index.js +3 -0
- package/dist/device/lifecycle/index.js.map +1 -0
- package/dist/device/lifecycle/manager.d.ts +273 -0
- package/dist/device/lifecycle/manager.d.ts.map +1 -0
- package/dist/device/lifecycle/manager.js +1229 -0
- package/dist/device/lifecycle/manager.js.map +1 -0
- package/dist/device/lifecycle/types.d.ts +372 -0
- package/dist/device/lifecycle/types.d.ts.map +1 -0
- package/dist/device/lifecycle/types.js +10 -0
- package/dist/device/lifecycle/types.js.map +1 -0
- package/dist/device/lifecycle/utils.d.ts +37 -0
- package/dist/device/lifecycle/utils.d.ts.map +1 -0
- package/dist/device/lifecycle/utils.js +79 -0
- package/dist/device/lifecycle/utils.js.map +1 -0
- package/dist/device/provisioning.d.ts +249 -0
- package/dist/device/provisioning.d.ts.map +1 -0
- package/dist/device/provisioning.js +439 -0
- package/dist/device/provisioning.js.map +1 -0
- package/dist/device/transfer.d.ts +231 -0
- package/dist/device/transfer.d.ts.map +1 -0
- package/dist/device/transfer.js +628 -0
- package/dist/device/transfer.js.map +1 -0
- package/dist/device/types.d.ts +275 -0
- package/dist/device/types.d.ts.map +1 -0
- package/dist/device/types.js +42 -0
- package/dist/device/types.js.map +1 -0
- package/dist/encoding/base64.d.ts +14 -0
- package/dist/encoding/base64.d.ts.map +1 -0
- package/dist/encoding/base64.js +2 -0
- package/dist/encoding/base64.js.map +1 -0
- package/dist/encoding/hex.d.ts +14 -0
- package/dist/encoding/hex.d.ts.map +1 -0
- package/dist/encoding/hex.js +2 -0
- package/dist/encoding/hex.js.map +1 -0
- package/dist/encoding/index.d.ts +17 -0
- package/dist/encoding/index.d.ts.map +1 -0
- package/dist/encoding/index.js +3 -0
- package/dist/encoding/index.js.map +1 -0
- package/dist/files/index.d.ts +16 -0
- package/dist/files/index.d.ts.map +1 -0
- package/dist/files/index.js +15 -0
- package/dist/files/index.js.map +1 -0
- package/dist/groups/index.d.ts +12 -0
- package/dist/groups/index.d.ts.map +1 -0
- package/dist/groups/index.js +9 -0
- package/dist/groups/index.js.map +1 -0
- package/dist/hooks/index.d.ts +20 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +6 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/use-connection-presence.d.ts +68 -0
- package/dist/hooks/use-connection-presence.d.ts.map +1 -0
- package/dist/hooks/use-connection-presence.js +300 -0
- package/dist/hooks/use-connection-presence.js.map +1 -0
- package/dist/hooks/use-group-membership.d.ts +66 -0
- package/dist/hooks/use-group-membership.d.ts.map +1 -0
- package/dist/hooks/use-group-membership.js +156 -0
- package/dist/hooks/use-group-membership.js.map +1 -0
- package/dist/hooks/use-key-rotation.d.ts +119 -0
- package/dist/hooks/use-key-rotation.d.ts.map +1 -0
- package/dist/hooks/use-key-rotation.js +198 -0
- package/dist/hooks/use-key-rotation.js.map +1 -0
- package/dist/hooks/use-session-health.d.ts +51 -0
- package/dist/hooks/use-session-health.d.ts.map +1 -0
- package/dist/hooks/use-session-health.js +59 -0
- package/dist/hooks/use-session-health.js.map +1 -0
- package/dist/hooks/use-single-flight.d.ts +29 -0
- package/dist/hooks/use-single-flight.d.ts.map +1 -0
- package/dist/hooks/use-single-flight.js +59 -0
- package/dist/hooks/use-single-flight.js.map +1 -0
- package/dist/index.d.ts +203 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +169 -0
- package/dist/index.js.map +1 -0
- package/dist/internal/crypto/ec/ed25519.d.ts +78 -0
- package/dist/internal/crypto/ec/ed25519.d.ts.map +1 -0
- package/dist/internal/crypto/ec/ed25519.js +108 -0
- package/dist/internal/crypto/ec/ed25519.js.map +1 -0
- package/dist/internal/crypto/ec/index.d.ts +5 -0
- package/dist/internal/crypto/ec/index.d.ts.map +1 -0
- package/dist/internal/crypto/ec/index.js +4 -0
- package/dist/internal/crypto/ec/index.js.map +1 -0
- package/dist/internal/crypto/ec/x25519-validation.d.ts +70 -0
- package/dist/internal/crypto/ec/x25519-validation.d.ts.map +1 -0
- package/dist/internal/crypto/ec/x25519-validation.js +137 -0
- package/dist/internal/crypto/ec/x25519-validation.js.map +1 -0
- package/dist/internal/crypto/ec/x25519.d.ts +91 -0
- package/dist/internal/crypto/ec/x25519.d.ts.map +1 -0
- package/dist/internal/crypto/ec/x25519.js +124 -0
- package/dist/internal/crypto/ec/x25519.js.map +1 -0
- package/dist/internal/crypto/hash/index.d.ts +4 -0
- package/dist/internal/crypto/hash/index.d.ts.map +1 -0
- package/dist/internal/crypto/hash/index.js +3 -0
- package/dist/internal/crypto/hash/index.js.map +1 -0
- package/dist/internal/crypto/hash/sha256.d.ts +24 -0
- package/dist/internal/crypto/hash/sha256.d.ts.map +1 -0
- package/dist/internal/crypto/hash/sha256.js +23 -0
- package/dist/internal/crypto/hash/sha256.js.map +1 -0
- package/dist/internal/crypto/hash/sha512.d.ts +16 -0
- package/dist/internal/crypto/hash/sha512.d.ts.map +1 -0
- package/dist/internal/crypto/hash/sha512.js +27 -0
- package/dist/internal/crypto/hash/sha512.js.map +1 -0
- package/dist/internal/crypto/index.d.ts +60 -0
- package/dist/internal/crypto/index.d.ts.map +1 -0
- package/dist/internal/crypto/index.js +107 -0
- package/dist/internal/crypto/index.js.map +1 -0
- package/dist/internal/crypto/kdf/hkdf.d.ts +300 -0
- package/dist/internal/crypto/kdf/hkdf.d.ts.map +1 -0
- package/dist/internal/crypto/kdf/hkdf.js +452 -0
- package/dist/internal/crypto/kdf/hkdf.js.map +1 -0
- package/dist/internal/crypto/kdf/index.d.ts +4 -0
- package/dist/internal/crypto/kdf/index.d.ts.map +1 -0
- package/dist/internal/crypto/kdf/index.js +3 -0
- package/dist/internal/crypto/kdf/index.js.map +1 -0
- package/dist/internal/crypto/kdf/pbkdf2.d.ts +42 -0
- package/dist/internal/crypto/kdf/pbkdf2.d.ts.map +1 -0
- package/dist/internal/crypto/kdf/pbkdf2.js +44 -0
- package/dist/internal/crypto/kdf/pbkdf2.js.map +1 -0
- package/dist/internal/crypto/key-prefix.d.ts +82 -0
- package/dist/internal/crypto/key-prefix.d.ts.map +1 -0
- package/dist/internal/crypto/key-prefix.js +116 -0
- package/dist/internal/crypto/key-prefix.js.map +1 -0
- package/dist/internal/crypto/pq/index.d.ts +3 -0
- package/dist/internal/crypto/pq/index.d.ts.map +1 -0
- package/dist/internal/crypto/pq/index.js +2 -0
- package/dist/internal/crypto/pq/index.js.map +1 -0
- package/dist/internal/crypto/pq/kyber.d.ts +232 -0
- package/dist/internal/crypto/pq/kyber.d.ts.map +1 -0
- package/dist/internal/crypto/pq/kyber.js +317 -0
- package/dist/internal/crypto/pq/kyber.js.map +1 -0
- package/dist/internal/crypto/random.d.ts +22 -0
- package/dist/internal/crypto/random.d.ts.map +1 -0
- package/dist/internal/crypto/random.js +45 -0
- package/dist/internal/crypto/random.js.map +1 -0
- package/dist/internal/crypto/symmetric/aes-ctr.d.ts +73 -0
- package/dist/internal/crypto/symmetric/aes-ctr.d.ts.map +1 -0
- package/dist/internal/crypto/symmetric/aes-ctr.js +98 -0
- package/dist/internal/crypto/symmetric/aes-ctr.js.map +1 -0
- package/dist/internal/crypto/symmetric/aes-gcm-siv.d.ts +77 -0
- package/dist/internal/crypto/symmetric/aes-gcm-siv.d.ts.map +1 -0
- package/dist/internal/crypto/symmetric/aes-gcm-siv.js +111 -0
- package/dist/internal/crypto/symmetric/aes-gcm-siv.js.map +1 -0
- package/dist/internal/crypto/symmetric/aes.d.ts +211 -0
- package/dist/internal/crypto/symmetric/aes.d.ts.map +1 -0
- package/dist/internal/crypto/symmetric/aes.js +386 -0
- package/dist/internal/crypto/symmetric/aes.js.map +1 -0
- package/dist/internal/crypto/symmetric/hmac.d.ts +32 -0
- package/dist/internal/crypto/symmetric/hmac.d.ts.map +1 -0
- package/dist/internal/crypto/symmetric/hmac.js +20 -0
- package/dist/internal/crypto/symmetric/hmac.js.map +1 -0
- package/dist/internal/crypto/symmetric/index.d.ts +9 -0
- package/dist/internal/crypto/symmetric/index.d.ts.map +1 -0
- package/dist/internal/crypto/symmetric/index.js +8 -0
- package/dist/internal/crypto/symmetric/index.js.map +1 -0
- package/dist/internal/crypto/symmetric/mac.d.ts +154 -0
- package/dist/internal/crypto/symmetric/mac.d.ts.map +1 -0
- package/dist/internal/crypto/symmetric/mac.js +292 -0
- package/dist/internal/crypto/symmetric/mac.js.map +1 -0
- package/dist/internal/crypto/symmetric/padding.d.ts +55 -0
- package/dist/internal/crypto/symmetric/padding.d.ts.map +1 -0
- package/dist/internal/crypto/symmetric/padding.js +90 -0
- package/dist/internal/crypto/symmetric/padding.js.map +1 -0
- package/dist/internal/crypto/symmetric/streaming-aead.d.ts +89 -0
- package/dist/internal/crypto/symmetric/streaming-aead.d.ts.map +1 -0
- package/dist/internal/crypto/symmetric/streaming-aead.js +253 -0
- package/dist/internal/crypto/symmetric/streaming-aead.js.map +1 -0
- package/dist/internal/crypto/utils.d.ts +119 -0
- package/dist/internal/crypto/utils.d.ts.map +1 -0
- package/dist/internal/crypto/utils.js +366 -0
- package/dist/internal/crypto/utils.js.map +1 -0
- package/dist/internal/crypto/validation.d.ts +45 -0
- package/dist/internal/crypto/validation.d.ts.map +1 -0
- package/dist/internal/crypto/validation.js +37 -0
- package/dist/internal/crypto/validation.js.map +1 -0
- package/dist/internal/encoding/index.d.ts +2 -0
- package/dist/internal/encoding/index.d.ts.map +1 -0
- package/dist/internal/encoding/index.js +2 -0
- package/dist/internal/encoding/index.js.map +1 -0
- package/dist/internal/encoding/proto/envelope.d.ts +120 -0
- package/dist/internal/encoding/proto/envelope.d.ts.map +1 -0
- package/dist/internal/encoding/proto/envelope.js +160 -0
- package/dist/internal/encoding/proto/envelope.js.map +1 -0
- package/dist/internal/encoding/proto/index.d.ts +25 -0
- package/dist/internal/encoding/proto/index.d.ts.map +1 -0
- package/dist/internal/encoding/proto/index.js +30 -0
- package/dist/internal/encoding/proto/index.js.map +1 -0
- package/dist/internal/encoding/proto/pq-ratchet-serialize.d.ts +118 -0
- package/dist/internal/encoding/proto/pq-ratchet-serialize.d.ts.map +1 -0
- package/dist/internal/encoding/proto/pq-ratchet-serialize.js +383 -0
- package/dist/internal/encoding/proto/pq-ratchet-serialize.js.map +1 -0
- package/dist/internal/encoding/proto/primitives.d.ts +98 -0
- package/dist/internal/encoding/proto/primitives.d.ts.map +1 -0
- package/dist/internal/encoding/proto/primitives.js +179 -0
- package/dist/internal/encoding/proto/primitives.js.map +1 -0
- package/dist/internal/encoding/proto/sender-key-message.d.ts +147 -0
- package/dist/internal/encoding/proto/sender-key-message.d.ts.map +1 -0
- package/dist/internal/encoding/proto/sender-key-message.js +220 -0
- package/dist/internal/encoding/proto/sender-key-message.js.map +1 -0
- package/dist/internal/encoding/proto/signal-message.d.ts +174 -0
- package/dist/internal/encoding/proto/signal-message.d.ts.map +1 -0
- package/dist/internal/encoding/proto/signal-message.js +372 -0
- package/dist/internal/encoding/proto/signal-message.js.map +1 -0
- package/dist/internal/groups/group-id.d.ts +74 -0
- package/dist/internal/groups/group-id.d.ts.map +1 -0
- package/dist/internal/groups/group-id.js +63 -0
- package/dist/internal/groups/group-id.js.map +1 -0
- package/dist/internal/groups/index.d.ts +15 -0
- package/dist/internal/groups/index.d.ts.map +1 -0
- package/dist/internal/groups/index.js +2 -0
- package/dist/internal/groups/index.js.map +1 -0
- package/dist/internal/groups-v2/access-control.d.ts +101 -0
- package/dist/internal/groups-v2/access-control.d.ts.map +1 -0
- package/dist/internal/groups-v2/access-control.js +184 -0
- package/dist/internal/groups-v2/access-control.js.map +1 -0
- package/dist/internal/groups-v2/change-actions.d.ts +35 -0
- package/dist/internal/groups-v2/change-actions.d.ts.map +1 -0
- package/dist/internal/groups-v2/change-actions.js +358 -0
- package/dist/internal/groups-v2/change-actions.js.map +1 -0
- package/dist/internal/groups-v2/encrypted-state.d.ts +121 -0
- package/dist/internal/groups-v2/encrypted-state.d.ts.map +1 -0
- package/dist/internal/groups-v2/encrypted-state.js +455 -0
- package/dist/internal/groups-v2/encrypted-state.js.map +1 -0
- package/dist/internal/groups-v2/index.d.ts +14 -0
- package/dist/internal/groups-v2/index.d.ts.map +1 -0
- package/dist/internal/groups-v2/index.js +11 -0
- package/dist/internal/groups-v2/index.js.map +1 -0
- package/dist/internal/groups-v2/invite-link.d.ts +55 -0
- package/dist/internal/groups-v2/invite-link.d.ts.map +1 -0
- package/dist/internal/groups-v2/invite-link.js +111 -0
- package/dist/internal/groups-v2/invite-link.js.map +1 -0
- package/dist/internal/groups-v2/manager.d.ts +351 -0
- package/dist/internal/groups-v2/manager.d.ts.map +1 -0
- package/dist/internal/groups-v2/manager.js +1093 -0
- package/dist/internal/groups-v2/manager.js.map +1 -0
- package/dist/internal/groups-v2/types.d.ts +371 -0
- package/dist/internal/groups-v2/types.d.ts.map +1 -0
- package/dist/internal/groups-v2/types.js +61 -0
- package/dist/internal/groups-v2/types.js.map +1 -0
- package/dist/internal/manager/index.d.ts +16 -0
- package/dist/internal/manager/index.d.ts.map +1 -0
- package/dist/internal/manager/index.js +2 -0
- package/dist/internal/manager/index.js.map +1 -0
- package/dist/internal/manager/manager.d.ts +378 -0
- package/dist/internal/manager/manager.d.ts.map +1 -0
- package/dist/internal/manager/manager.js +1079 -0
- package/dist/internal/manager/manager.js.map +1 -0
- package/dist/internal/protocol/double-ratchet/chains.d.ts +135 -0
- package/dist/internal/protocol/double-ratchet/chains.d.ts.map +1 -0
- package/dist/internal/protocol/double-ratchet/chains.js +417 -0
- package/dist/internal/protocol/double-ratchet/chains.js.map +1 -0
- package/dist/internal/protocol/double-ratchet/index.d.ts +20 -0
- package/dist/internal/protocol/double-ratchet/index.d.ts.map +1 -0
- package/dist/internal/protocol/double-ratchet/index.js +21 -0
- package/dist/internal/protocol/double-ratchet/index.js.map +1 -0
- package/dist/internal/protocol/double-ratchet/ratchet.d.ts +231 -0
- package/dist/internal/protocol/double-ratchet/ratchet.d.ts.map +1 -0
- package/dist/internal/protocol/double-ratchet/ratchet.js +198 -0
- package/dist/internal/protocol/double-ratchet/ratchet.js.map +1 -0
- package/dist/internal/protocol/index.d.ts +24 -0
- package/dist/internal/protocol/index.d.ts.map +1 -0
- package/dist/internal/protocol/index.js +9 -0
- package/dist/internal/protocol/index.js.map +1 -0
- package/dist/internal/protocol/pqxdh/index.d.ts +19 -0
- package/dist/internal/protocol/pqxdh/index.d.ts.map +1 -0
- package/dist/internal/protocol/pqxdh/index.js +16 -0
- package/dist/internal/protocol/pqxdh/index.js.map +1 -0
- package/dist/internal/protocol/pqxdh/pqxdh.d.ts +141 -0
- package/dist/internal/protocol/pqxdh/pqxdh.d.ts.map +1 -0
- package/dist/internal/protocol/pqxdh/pqxdh.js +399 -0
- package/dist/internal/protocol/pqxdh/pqxdh.js.map +1 -0
- package/dist/internal/protocol/sealed-sender/certificate.d.ts +94 -0
- package/dist/internal/protocol/sealed-sender/certificate.d.ts.map +1 -0
- package/dist/internal/protocol/sealed-sender/certificate.js +254 -0
- package/dist/internal/protocol/sealed-sender/certificate.js.map +1 -0
- package/dist/internal/protocol/sealed-sender/decryption-v2.d.ts +46 -0
- package/dist/internal/protocol/sealed-sender/decryption-v2.d.ts.map +1 -0
- package/dist/internal/protocol/sealed-sender/decryption-v2.js +184 -0
- package/dist/internal/protocol/sealed-sender/decryption-v2.js.map +1 -0
- package/dist/internal/protocol/sealed-sender/decryption.d.ts +59 -0
- package/dist/internal/protocol/sealed-sender/decryption.d.ts.map +1 -0
- package/dist/internal/protocol/sealed-sender/decryption.js +268 -0
- package/dist/internal/protocol/sealed-sender/decryption.js.map +1 -0
- package/dist/internal/protocol/sealed-sender/delivery-token.d.ts +48 -0
- package/dist/internal/protocol/sealed-sender/delivery-token.d.ts.map +1 -0
- package/dist/internal/protocol/sealed-sender/delivery-token.js +71 -0
- package/dist/internal/protocol/sealed-sender/delivery-token.js.map +1 -0
- package/dist/internal/protocol/sealed-sender/encryption-v2.d.ts +56 -0
- package/dist/internal/protocol/sealed-sender/encryption-v2.d.ts.map +1 -0
- package/dist/internal/protocol/sealed-sender/encryption-v2.js +169 -0
- package/dist/internal/protocol/sealed-sender/encryption-v2.js.map +1 -0
- package/dist/internal/protocol/sealed-sender/encryption.d.ts +66 -0
- package/dist/internal/protocol/sealed-sender/encryption.d.ts.map +1 -0
- package/dist/internal/protocol/sealed-sender/encryption.js +174 -0
- package/dist/internal/protocol/sealed-sender/encryption.js.map +1 -0
- package/dist/internal/protocol/sealed-sender/index.d.ts +23 -0
- package/dist/internal/protocol/sealed-sender/index.d.ts.map +1 -0
- package/dist/internal/protocol/sealed-sender/index.js +61 -0
- package/dist/internal/protocol/sealed-sender/index.js.map +1 -0
- package/dist/internal/protocol/sealed-sender/proto/index.d.ts +129 -0
- package/dist/internal/protocol/sealed-sender/proto/index.d.ts.map +1 -0
- package/dist/internal/protocol/sealed-sender/proto/index.js +267 -0
- package/dist/internal/protocol/sealed-sender/proto/index.js.map +1 -0
- package/dist/internal/protocol/sealed-sender/types.d.ts +461 -0
- package/dist/internal/protocol/sealed-sender/types.d.ts.map +1 -0
- package/dist/internal/protocol/sealed-sender/types.js +99 -0
- package/dist/internal/protocol/sealed-sender/types.js.map +1 -0
- package/dist/internal/protocol/sealed-sender/v2-binary.d.ts +124 -0
- package/dist/internal/protocol/sealed-sender/v2-binary.d.ts.map +1 -0
- package/dist/internal/protocol/sealed-sender/v2-binary.js +295 -0
- package/dist/internal/protocol/sealed-sender/v2-binary.js.map +1 -0
- package/dist/internal/protocol/sealed-sender/v2-helpers.d.ts +107 -0
- package/dist/internal/protocol/sealed-sender/v2-helpers.d.ts.map +1 -0
- package/dist/internal/protocol/sealed-sender/v2-helpers.js +185 -0
- package/dist/internal/protocol/sealed-sender/v2-helpers.js.map +1 -0
- package/dist/internal/protocol/sender-keys/index.d.ts +11 -0
- package/dist/internal/protocol/sender-keys/index.d.ts.map +1 -0
- package/dist/internal/protocol/sender-keys/index.js +2 -0
- package/dist/internal/protocol/sender-keys/index.js.map +1 -0
- package/dist/internal/protocol/sender-keys/manager.d.ts +298 -0
- package/dist/internal/protocol/sender-keys/manager.d.ts.map +1 -0
- package/dist/internal/protocol/sender-keys/manager.js +839 -0
- package/dist/internal/protocol/sender-keys/manager.js.map +1 -0
- package/dist/internal/protocol/spqr/braid-serialize.d.ts +128 -0
- package/dist/internal/protocol/spqr/braid-serialize.d.ts.map +1 -0
- package/dist/internal/protocol/spqr/braid-serialize.js +373 -0
- package/dist/internal/protocol/spqr/braid-serialize.js.map +1 -0
- package/dist/internal/protocol/spqr/braid.d.ts +164 -0
- package/dist/internal/protocol/spqr/braid.d.ts.map +1 -0
- package/dist/internal/protocol/spqr/braid.js +305 -0
- package/dist/internal/protocol/spqr/braid.js.map +1 -0
- package/dist/internal/protocol/spqr/index.d.ts +161 -0
- package/dist/internal/protocol/spqr/index.d.ts.map +1 -0
- package/dist/internal/protocol/spqr/index.js +115 -0
- package/dist/internal/protocol/spqr/index.js.map +1 -0
- package/dist/internal/protocol/spqr/message.d.ts +237 -0
- package/dist/internal/protocol/spqr/message.d.ts.map +1 -0
- package/dist/internal/protocol/spqr/message.js +298 -0
- package/dist/internal/protocol/spqr/message.js.map +1 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/authenticator.d.ts +174 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/authenticator.d.ts.map +1 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/authenticator.js +248 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/authenticator.js.map +1 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/chunk-domain.d.ts +29 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/chunk-domain.d.ts.map +1 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/chunk-domain.js +43 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/chunk-domain.js.map +1 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/errors.d.ts +170 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/errors.d.ts.map +1 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/errors.js +249 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/errors.js.map +1 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/incremental-kem.d.ts +84 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/incremental-kem.d.ts.map +1 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/incremental-kem.js +138 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/incremental-kem.js.map +1 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/index.d.ts +45 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/index.d.ts.map +1 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/index.js +94 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/index.js.map +1 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/kdf.d.ts +52 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/kdf.d.ts.map +1 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/kdf.js +121 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/kdf.js.map +1 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/noble-pq/arithmetic.d.ts +12 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/noble-pq/arithmetic.d.ts.map +1 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/noble-pq/arithmetic.js +15 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/noble-pq/arithmetic.js.map +1 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/noble-pq/index.d.ts +136 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/noble-pq/index.d.ts.map +1 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/noble-pq/index.js +796 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/noble-pq/index.js.map +1 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/rs/codec.d.ts +454 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/rs/codec.d.ts.map +1 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/rs/codec.js +790 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/rs/codec.js.map +1 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/rs/galois/field.d.ts +108 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/rs/galois/field.d.ts.map +1 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/rs/galois/field.js +125 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/rs/galois/field.js.map +1 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/rs/galois/index.d.ts +12 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/rs/galois/index.d.ts.map +1 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/rs/galois/index.js +5 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/rs/galois/index.js.map +1 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/rs/galois/tables-16.d.ts +28 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/rs/galois/tables-16.d.ts.map +1 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/rs/galois/tables-16.js +13953 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/rs/galois/tables-16.js.map +1 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/rs/index.d.ts +40 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/rs/index.d.ts.map +1 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/rs/index.js +52 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/rs/index.js.map +1 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/rs/lagrange.d.ts +151 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/rs/lagrange.d.ts.map +1 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/rs/lagrange.js +297 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/rs/lagrange.js.map +1 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/rs/polynomial.d.ts +97 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/rs/polynomial.d.ts.map +1 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/rs/polynomial.js +201 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/rs/polynomial.js.map +1 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/serialize.d.ts +249 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/serialize.d.ts.map +1 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/serialize.js +731 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/serialize.js.map +1 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/state-machine.d.ts +127 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/state-machine.d.ts.map +1 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/state-machine.js +894 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/state-machine.js.map +1 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/types.d.ts +387 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/types.d.ts.map +1 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/types.js +121 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/types.js.map +1 -0
- package/dist/internal/protocol/spqr/serialize.d.ts +149 -0
- package/dist/internal/protocol/spqr/serialize.d.ts.map +1 -0
- package/dist/internal/protocol/spqr/serialize.js +370 -0
- package/dist/internal/protocol/spqr/serialize.js.map +1 -0
- package/dist/internal/protocol/spqr/spqr.d.ts +486 -0
- package/dist/internal/protocol/spqr/spqr.d.ts.map +1 -0
- package/dist/internal/protocol/spqr/spqr.js +1031 -0
- package/dist/internal/protocol/spqr/spqr.js.map +1 -0
- package/dist/internal/protocol/spqr/validate.d.ts +35 -0
- package/dist/internal/protocol/spqr/validate.d.ts.map +1 -0
- package/dist/internal/protocol/spqr/validate.js +62 -0
- package/dist/internal/protocol/spqr/validate.js.map +1 -0
- package/dist/internal/protocol/triple-ratchet/index.d.ts +21 -0
- package/dist/internal/protocol/triple-ratchet/index.d.ts.map +1 -0
- package/dist/internal/protocol/triple-ratchet/index.js +19 -0
- package/dist/internal/protocol/triple-ratchet/index.js.map +1 -0
- package/dist/internal/protocol/triple-ratchet/ratchet.d.ts +233 -0
- package/dist/internal/protocol/triple-ratchet/ratchet.d.ts.map +1 -0
- package/dist/internal/protocol/triple-ratchet/ratchet.js +254 -0
- package/dist/internal/protocol/triple-ratchet/ratchet.js.map +1 -0
- package/dist/internal/protocol/username/generate.d.ts +9 -0
- package/dist/internal/protocol/username/generate.d.ts.map +1 -0
- package/dist/internal/protocol/username/generate.js +16 -0
- package/dist/internal/protocol/username/generate.js.map +1 -0
- package/dist/internal/protocol/username/hash.d.ts +74 -0
- package/dist/internal/protocol/username/hash.d.ts.map +1 -0
- package/dist/internal/protocol/username/hash.js +228 -0
- package/dist/internal/protocol/username/hash.js.map +1 -0
- package/dist/internal/protocol/username/link.d.ts +50 -0
- package/dist/internal/protocol/username/link.d.ts.map +1 -0
- package/dist/internal/protocol/username/link.js +187 -0
- package/dist/internal/protocol/username/link.js.map +1 -0
- package/dist/internal/protocol/username/proof.d.ts +34 -0
- package/dist/internal/protocol/username/proof.d.ts.map +1 -0
- package/dist/internal/protocol/username/proof.js +83 -0
- package/dist/internal/protocol/username/proof.js.map +1 -0
- package/dist/internal/protocol/version.d.ts +184 -0
- package/dist/internal/protocol/version.d.ts.map +1 -0
- package/dist/internal/protocol/version.js +163 -0
- package/dist/internal/protocol/version.js.map +1 -0
- package/dist/internal/protocol/x3dh/index.d.ts +15 -0
- package/dist/internal/protocol/x3dh/index.d.ts.map +1 -0
- package/dist/internal/protocol/x3dh/index.js +13 -0
- package/dist/internal/protocol/x3dh/index.js.map +1 -0
- package/dist/internal/protocol/x3dh/x3dh.d.ts +131 -0
- package/dist/internal/protocol/x3dh/x3dh.d.ts.map +1 -0
- package/dist/internal/protocol/x3dh/x3dh.js +261 -0
- package/dist/internal/protocol/x3dh/x3dh.js.map +1 -0
- package/dist/internal/protocol/zk/credentials/attributes.d.ts +157 -0
- package/dist/internal/protocol/zk/credentials/attributes.d.ts.map +1 -0
- package/dist/internal/protocol/zk/credentials/attributes.js +177 -0
- package/dist/internal/protocol/zk/credentials/attributes.js.map +1 -0
- package/dist/internal/protocol/zk/credentials/credentials.d.ts +129 -0
- package/dist/internal/protocol/zk/credentials/credentials.d.ts.map +1 -0
- package/dist/internal/protocol/zk/credentials/credentials.js +204 -0
- package/dist/internal/protocol/zk/credentials/credentials.js.map +1 -0
- package/dist/internal/protocol/zk/credentials/endorsements.d.ts +235 -0
- package/dist/internal/protocol/zk/credentials/endorsements.d.ts.map +1 -0
- package/dist/internal/protocol/zk/credentials/endorsements.js +520 -0
- package/dist/internal/protocol/zk/credentials/endorsements.js.map +1 -0
- package/dist/internal/protocol/zk/credentials/index.d.ts +14 -0
- package/dist/internal/protocol/zk/credentials/index.d.ts.map +1 -0
- package/dist/internal/protocol/zk/credentials/index.js +6 -0
- package/dist/internal/protocol/zk/credentials/index.js.map +1 -0
- package/dist/internal/protocol/zk/credentials/issuance.d.ts +135 -0
- package/dist/internal/protocol/zk/credentials/issuance.d.ts.map +1 -0
- package/dist/internal/protocol/zk/credentials/issuance.js +338 -0
- package/dist/internal/protocol/zk/credentials/issuance.js.map +1 -0
- package/dist/internal/protocol/zk/credentials/presentation.d.ts +160 -0
- package/dist/internal/protocol/zk/credentials/presentation.d.ts.map +1 -0
- package/dist/internal/protocol/zk/credentials/presentation.js +447 -0
- package/dist/internal/protocol/zk/credentials/presentation.js.map +1 -0
- package/dist/internal/protocol/zk/groups/auth-credential.d.ts +191 -0
- package/dist/internal/protocol/zk/groups/auth-credential.d.ts.map +1 -0
- package/dist/internal/protocol/zk/groups/auth-credential.js +377 -0
- package/dist/internal/protocol/zk/groups/auth-credential.js.map +1 -0
- package/dist/internal/protocol/zk/groups/client-zk-group-cipher.d.ts +73 -0
- package/dist/internal/protocol/zk/groups/client-zk-group-cipher.d.ts.map +1 -0
- package/dist/internal/protocol/zk/groups/client-zk-group-cipher.js +140 -0
- package/dist/internal/protocol/zk/groups/client-zk-group-cipher.js.map +1 -0
- package/dist/internal/protocol/zk/groups/group-params.d.ts +93 -0
- package/dist/internal/protocol/zk/groups/group-params.d.ts.map +1 -0
- package/dist/internal/protocol/zk/groups/group-params.js +184 -0
- package/dist/internal/protocol/zk/groups/group-params.js.map +1 -0
- package/dist/internal/protocol/zk/groups/group-send-endorsement.d.ts +245 -0
- package/dist/internal/protocol/zk/groups/group-send-endorsement.d.ts.map +1 -0
- package/dist/internal/protocol/zk/groups/group-send-endorsement.js +404 -0
- package/dist/internal/protocol/zk/groups/group-send-endorsement.js.map +1 -0
- package/dist/internal/protocol/zk/groups/index.d.ts +19 -0
- package/dist/internal/protocol/zk/groups/index.d.ts.map +1 -0
- package/dist/internal/protocol/zk/groups/index.js +12 -0
- package/dist/internal/protocol/zk/groups/index.js.map +1 -0
- package/dist/internal/protocol/zk/groups/lizard.d.ts +51 -0
- package/dist/internal/protocol/zk/groups/lizard.d.ts.map +1 -0
- package/dist/internal/protocol/zk/groups/lizard.js +478 -0
- package/dist/internal/protocol/zk/groups/lizard.js.map +1 -0
- package/dist/internal/protocol/zk/groups/profile-key-commitment.d.ts +35 -0
- package/dist/internal/protocol/zk/groups/profile-key-commitment.d.ts.map +1 -0
- package/dist/internal/protocol/zk/groups/profile-key-commitment.js +99 -0
- package/dist/internal/protocol/zk/groups/profile-key-commitment.js.map +1 -0
- package/dist/internal/protocol/zk/groups/profile-key-credential.d.ts +195 -0
- package/dist/internal/protocol/zk/groups/profile-key-credential.d.ts.map +1 -0
- package/dist/internal/protocol/zk/groups/profile-key-credential.js +370 -0
- package/dist/internal/protocol/zk/groups/profile-key-credential.js.map +1 -0
- package/dist/internal/protocol/zk/groups/profile-key-encryption.d.ts +45 -0
- package/dist/internal/protocol/zk/groups/profile-key-encryption.d.ts.map +1 -0
- package/dist/internal/protocol/zk/groups/profile-key-encryption.js +125 -0
- package/dist/internal/protocol/zk/groups/profile-key-encryption.js.map +1 -0
- package/dist/internal/protocol/zk/groups/profile-key-struct.d.ts +33 -0
- package/dist/internal/protocol/zk/groups/profile-key-struct.d.ts.map +1 -0
- package/dist/internal/protocol/zk/groups/profile-key-struct.js +62 -0
- package/dist/internal/protocol/zk/groups/profile-key-struct.js.map +1 -0
- package/dist/internal/protocol/zk/groups/profile-key-version.d.ts +17 -0
- package/dist/internal/protocol/zk/groups/profile-key-version.d.ts.map +1 -0
- package/dist/internal/protocol/zk/groups/profile-key-version.js +33 -0
- package/dist/internal/protocol/zk/groups/profile-key-version.js.map +1 -0
- package/dist/internal/protocol/zk/groups/server-params.d.ts +114 -0
- package/dist/internal/protocol/zk/groups/server-params.d.ts.map +1 -0
- package/dist/internal/protocol/zk/groups/server-params.js +146 -0
- package/dist/internal/protocol/zk/groups/server-params.js.map +1 -0
- package/dist/internal/protocol/zk/groups/uid-encryption.d.ts +41 -0
- package/dist/internal/protocol/zk/groups/uid-encryption.d.ts.map +1 -0
- package/dist/internal/protocol/zk/groups/uid-encryption.js +113 -0
- package/dist/internal/protocol/zk/groups/uid-encryption.js.map +1 -0
- package/dist/internal/protocol/zk/groups/uid-struct.d.ts +48 -0
- package/dist/internal/protocol/zk/groups/uid-struct.d.ts.map +1 -0
- package/dist/internal/protocol/zk/groups/uid-struct.js +77 -0
- package/dist/internal/protocol/zk/groups/uid-struct.js.map +1 -0
- package/dist/internal/protocol/zk/proofs/args.d.ts +33 -0
- package/dist/internal/protocol/zk/proofs/args.d.ts.map +1 -0
- package/dist/internal/protocol/zk/proofs/args.js +43 -0
- package/dist/internal/protocol/zk/proofs/args.js.map +1 -0
- package/dist/internal/protocol/zk/proofs/index.d.ts +13 -0
- package/dist/internal/protocol/zk/proofs/index.d.ts.map +1 -0
- package/dist/internal/protocol/zk/proofs/index.js +7 -0
- package/dist/internal/protocol/zk/proofs/index.js.map +1 -0
- package/dist/internal/protocol/zk/proofs/proof.d.ts +30 -0
- package/dist/internal/protocol/zk/proofs/proof.d.ts.map +1 -0
- package/dist/internal/protocol/zk/proofs/proof.js +48 -0
- package/dist/internal/protocol/zk/proofs/proof.js.map +1 -0
- package/dist/internal/protocol/zk/proofs/sho-sha256.d.ts +34 -0
- package/dist/internal/protocol/zk/proofs/sho-sha256.d.ts.map +1 -0
- package/dist/internal/protocol/zk/proofs/sho-sha256.js +138 -0
- package/dist/internal/protocol/zk/proofs/sho-sha256.js.map +1 -0
- package/dist/internal/protocol/zk/proofs/sho.d.ts +120 -0
- package/dist/internal/protocol/zk/proofs/sho.d.ts.map +1 -0
- package/dist/internal/protocol/zk/proofs/sho.js +221 -0
- package/dist/internal/protocol/zk/proofs/sho.js.map +1 -0
- package/dist/internal/protocol/zk/proofs/sign.d.ts +29 -0
- package/dist/internal/protocol/zk/proofs/sign.d.ts.map +1 -0
- package/dist/internal/protocol/zk/proofs/sign.js +34 -0
- package/dist/internal/protocol/zk/proofs/sign.js.map +1 -0
- package/dist/internal/protocol/zk/proofs/statement.d.ts +103 -0
- package/dist/internal/protocol/zk/proofs/statement.d.ts.map +1 -0
- package/dist/internal/protocol/zk/proofs/statement.js +282 -0
- package/dist/internal/protocol/zk/proofs/statement.js.map +1 -0
- package/dist/internal/sesame/device-registry.d.ts +208 -0
- package/dist/internal/sesame/device-registry.d.ts.map +1 -0
- package/dist/internal/sesame/device-registry.js +431 -0
- package/dist/internal/sesame/device-registry.js.map +1 -0
- package/dist/internal/sesame/index.d.ts +31 -0
- package/dist/internal/sesame/index.d.ts.map +1 -0
- package/dist/internal/sesame/index.js +40 -0
- package/dist/internal/sesame/index.js.map +1 -0
- package/dist/internal/sesame/manager.d.ts +351 -0
- package/dist/internal/sesame/manager.d.ts.map +1 -0
- package/dist/internal/sesame/manager.js +1760 -0
- package/dist/internal/sesame/manager.js.map +1 -0
- package/dist/internal/sesame/types.d.ts +840 -0
- package/dist/internal/sesame/types.d.ts.map +1 -0
- package/dist/internal/sesame/types.js +290 -0
- package/dist/internal/sesame/types.js.map +1 -0
- package/dist/internal/sesame/validation.d.ts +72 -0
- package/dist/internal/sesame/validation.d.ts.map +1 -0
- package/dist/internal/sesame/validation.js +136 -0
- package/dist/internal/sesame/validation.js.map +1 -0
- package/dist/internal/session/builder.d.ts +94 -0
- package/dist/internal/session/builder.d.ts.map +1 -0
- package/dist/internal/session/builder.js +266 -0
- package/dist/internal/session/builder.js.map +1 -0
- package/dist/internal/session/cipher.d.ts +256 -0
- package/dist/internal/session/cipher.d.ts.map +1 -0
- package/dist/internal/session/cipher.js +1222 -0
- package/dist/internal/session/cipher.js.map +1 -0
- package/dist/internal/session/decryption.d.ts +37 -0
- package/dist/internal/session/decryption.d.ts.map +1 -0
- package/dist/internal/session/decryption.js +256 -0
- package/dist/internal/session/decryption.js.map +1 -0
- package/dist/internal/session/factory.d.ts +161 -0
- package/dist/internal/session/factory.d.ts.map +1 -0
- package/dist/internal/session/factory.js +211 -0
- package/dist/internal/session/factory.js.map +1 -0
- package/dist/internal/session/handshake.d.ts +72 -0
- package/dist/internal/session/handshake.d.ts.map +1 -0
- package/dist/internal/session/handshake.js +343 -0
- package/dist/internal/session/handshake.js.map +1 -0
- package/dist/internal/session/identity-binding.d.ts +5 -0
- package/dist/internal/session/identity-binding.d.ts.map +1 -0
- package/dist/internal/session/identity-binding.js +15 -0
- package/dist/internal/session/identity-binding.js.map +1 -0
- package/dist/internal/session/index.d.ts +73 -0
- package/dist/internal/session/index.d.ts.map +1 -0
- package/dist/internal/session/index.js +75 -0
- package/dist/internal/session/index.js.map +1 -0
- package/dist/internal/session/keys.d.ts +220 -0
- package/dist/internal/session/keys.d.ts.map +1 -0
- package/dist/internal/session/keys.js +78 -0
- package/dist/internal/session/keys.js.map +1 -0
- package/dist/internal/session/ratchet.d.ts +97 -0
- package/dist/internal/session/ratchet.d.ts.map +1 -0
- package/dist/internal/session/ratchet.js +187 -0
- package/dist/internal/session/ratchet.js.map +1 -0
- package/dist/internal/session/session-resolver.d.ts +138 -0
- package/dist/internal/session/session-resolver.d.ts.map +1 -0
- package/dist/internal/session/session-resolver.js +190 -0
- package/dist/internal/session/session-resolver.js.map +1 -0
- package/dist/internal/session/state.d.ts +278 -0
- package/dist/internal/session/state.d.ts.map +1 -0
- package/dist/internal/session/state.js +167 -0
- package/dist/internal/session/state.js.map +1 -0
- package/dist/internal/session/types.d.ts +192 -0
- package/dist/internal/session/types.d.ts.map +1 -0
- package/dist/internal/session/types.js +16 -0
- package/dist/internal/session/types.js.map +1 -0
- package/dist/internal/session/validation.d.ts +145 -0
- package/dist/internal/session/validation.d.ts.map +1 -0
- package/dist/internal/session/validation.js +340 -0
- package/dist/internal/session/validation.js.map +1 -0
- package/dist/keys/branded.d.ts +85 -0
- package/dist/keys/branded.d.ts.map +1 -0
- package/dist/keys/branded.js +26 -0
- package/dist/keys/branded.js.map +1 -0
- package/dist/keys/generation.d.ts +101 -0
- package/dist/keys/generation.d.ts.map +1 -0
- package/dist/keys/generation.js +181 -0
- package/dist/keys/generation.js.map +1 -0
- package/dist/keys/identity.d.ts +27 -0
- package/dist/keys/identity.d.ts.map +1 -0
- package/dist/keys/identity.js +200 -0
- package/dist/keys/identity.js.map +1 -0
- package/dist/keys/index.d.ts +24 -0
- package/dist/keys/index.d.ts.map +1 -0
- package/dist/keys/index.js +22 -0
- package/dist/keys/index.js.map +1 -0
- package/dist/keys/prekey-signature.d.ts +13 -0
- package/dist/keys/prekey-signature.d.ts.map +1 -0
- package/dist/keys/prekey-signature.js +46 -0
- package/dist/keys/prekey-signature.js.map +1 -0
- package/dist/keys/types.d.ts +255 -0
- package/dist/keys/types.d.ts.map +1 -0
- package/dist/keys/types.js +11 -0
- package/dist/keys/types.js.map +1 -0
- package/dist/layers.d.ts +228 -0
- package/dist/layers.d.ts.map +1 -0
- package/dist/layers.js +328 -0
- package/dist/layers.js.map +1 -0
- package/dist/local/store/expo/adapter.d.ts +243 -0
- package/dist/local/store/expo/adapter.d.ts.map +1 -0
- package/dist/local/store/expo/adapter.js +619 -0
- package/dist/local/store/expo/adapter.js.map +1 -0
- package/dist/local/store/expo/database-key.d.ts +142 -0
- package/dist/local/store/expo/database-key.d.ts.map +1 -0
- package/dist/local/store/expo/database-key.js +312 -0
- package/dist/local/store/expo/database-key.js.map +1 -0
- package/dist/local/store/expo/db.d.ts +92 -0
- package/dist/local/store/expo/db.d.ts.map +1 -0
- package/dist/local/store/expo/db.js +142 -0
- package/dist/local/store/expo/db.js.map +1 -0
- package/dist/local/store/expo/index.d.ts +22 -0
- package/dist/local/store/expo/index.d.ts.map +1 -0
- package/dist/local/store/expo/index.js +10 -0
- package/dist/local/store/expo/index.js.map +1 -0
- package/dist/local/store/expo/key-storage.d.ts +422 -0
- package/dist/local/store/expo/key-storage.d.ts.map +1 -0
- package/dist/local/store/expo/key-storage.js +1292 -0
- package/dist/local/store/expo/key-storage.js.map +1 -0
- package/dist/local/store/expo/maintenance.d.ts +4 -0
- package/dist/local/store/expo/maintenance.d.ts.map +1 -0
- package/dist/local/store/expo/maintenance.js +36 -0
- package/dist/local/store/expo/maintenance.js.map +1 -0
- package/dist/local/store/expo/models/ec-one-time-prekey.d.ts +155 -0
- package/dist/local/store/expo/models/ec-one-time-prekey.d.ts.map +1 -0
- package/dist/local/store/expo/models/ec-one-time-prekey.js +309 -0
- package/dist/local/store/expo/models/ec-one-time-prekey.js.map +1 -0
- package/dist/local/store/expo/models/ec-signed-prekey.d.ts +189 -0
- package/dist/local/store/expo/models/ec-signed-prekey.d.ts.map +1 -0
- package/dist/local/store/expo/models/ec-signed-prekey.js +359 -0
- package/dist/local/store/expo/models/ec-signed-prekey.js.map +1 -0
- package/dist/local/store/expo/models/identity-key-id.d.ts +9 -0
- package/dist/local/store/expo/models/identity-key-id.d.ts.map +1 -0
- package/dist/local/store/expo/models/identity-key-id.js +10 -0
- package/dist/local/store/expo/models/identity-key-id.js.map +1 -0
- package/dist/local/store/expo/models/index.d.ts +20 -0
- package/dist/local/store/expo/models/index.d.ts.map +1 -0
- package/dist/local/store/expo/models/index.js +80 -0
- package/dist/local/store/expo/models/index.js.map +1 -0
- package/dist/local/store/expo/models/kyber-one-time-prekey.d.ts +183 -0
- package/dist/local/store/expo/models/kyber-one-time-prekey.d.ts.map +1 -0
- package/dist/local/store/expo/models/kyber-one-time-prekey.js +353 -0
- package/dist/local/store/expo/models/kyber-one-time-prekey.js.map +1 -0
- package/dist/local/store/expo/models/kyber-prekey-used.d.ts +37 -0
- package/dist/local/store/expo/models/kyber-prekey-used.d.ts.map +1 -0
- package/dist/local/store/expo/models/kyber-prekey-used.js +59 -0
- package/dist/local/store/expo/models/kyber-prekey-used.js.map +1 -0
- package/dist/local/store/expo/models/kyber-prekey.d.ts +172 -0
- package/dist/local/store/expo/models/kyber-prekey.d.ts.map +1 -0
- package/dist/local/store/expo/models/kyber-prekey.js +314 -0
- package/dist/local/store/expo/models/kyber-prekey.js.map +1 -0
- package/dist/local/store/expo/models/local-identity.d.ts +52 -0
- package/dist/local/store/expo/models/local-identity.d.ts.map +1 -0
- package/dist/local/store/expo/models/local-identity.js +166 -0
- package/dist/local/store/expo/models/local-identity.js.map +1 -0
- package/dist/local/store/expo/models/message-record.d.ts +198 -0
- package/dist/local/store/expo/models/message-record.d.ts.map +1 -0
- package/dist/local/store/expo/models/message-record.js +298 -0
- package/dist/local/store/expo/models/message-record.js.map +1 -0
- package/dist/local/store/expo/models/recipient-identity.d.ts +21 -0
- package/dist/local/store/expo/models/recipient-identity.d.ts.map +1 -0
- package/dist/local/store/expo/models/recipient-identity.js +66 -0
- package/dist/local/store/expo/models/recipient-identity.js.map +1 -0
- package/dist/local/store/expo/models/replaced-prekey-utils.d.ts +33 -0
- package/dist/local/store/expo/models/replaced-prekey-utils.d.ts.map +1 -0
- package/dist/local/store/expo/models/replaced-prekey-utils.js +54 -0
- package/dist/local/store/expo/models/replaced-prekey-utils.js.map +1 -0
- package/dist/local/store/expo/models/sender-key.d.ts +210 -0
- package/dist/local/store/expo/models/sender-key.d.ts.map +1 -0
- package/dist/local/store/expo/models/sender-key.js +379 -0
- package/dist/local/store/expo/models/sender-key.js.map +1 -0
- package/dist/local/store/expo/models/session.d.ts +175 -0
- package/dist/local/store/expo/models/session.d.ts.map +1 -0
- package/dist/local/store/expo/models/session.js +496 -0
- package/dist/local/store/expo/models/session.js.map +1 -0
- package/dist/local/store/expo/schema.d.ts +1734 -0
- package/dist/local/store/expo/schema.d.ts.map +1 -0
- package/dist/local/store/expo/schema.js +155 -0
- package/dist/local/store/expo/schema.js.map +1 -0
- package/dist/local/store/expo/secure-store-options.d.ts +10 -0
- package/dist/local/store/expo/secure-store-options.d.ts.map +1 -0
- package/dist/local/store/expo/secure-store-options.js +5 -0
- package/dist/local/store/expo/secure-store-options.js.map +1 -0
- package/dist/local/store/index.d.ts +41 -0
- package/dist/local/store/index.d.ts.map +1 -0
- package/dist/local/store/index.js +34 -0
- package/dist/local/store/index.js.map +1 -0
- package/dist/local/store/mock/adapter.d.ts +185 -0
- package/dist/local/store/mock/adapter.d.ts.map +1 -0
- package/dist/local/store/mock/adapter.js +875 -0
- package/dist/local/store/mock/adapter.js.map +1 -0
- package/dist/local/store/mock/index.d.ts +10 -0
- package/dist/local/store/mock/index.d.ts.map +1 -0
- package/dist/local/store/mock/index.js +6 -0
- package/dist/local/store/mock/index.js.map +1 -0
- package/dist/local/store/node/adapter.d.ts +85 -0
- package/dist/local/store/node/adapter.d.ts.map +1 -0
- package/dist/local/store/node/adapter.js +274 -0
- package/dist/local/store/node/adapter.js.map +1 -0
- package/dist/local/store/node/database-encryption.d.ts +109 -0
- package/dist/local/store/node/database-encryption.d.ts.map +1 -0
- package/dist/local/store/node/database-encryption.js +202 -0
- package/dist/local/store/node/database-encryption.js.map +1 -0
- package/dist/local/store/node/database-key.d.ts +124 -0
- package/dist/local/store/node/database-key.d.ts.map +1 -0
- package/dist/local/store/node/database-key.js +264 -0
- package/dist/local/store/node/database-key.js.map +1 -0
- package/dist/local/store/node/database.d.ts +156 -0
- package/dist/local/store/node/database.d.ts.map +1 -0
- package/dist/local/store/node/database.js +630 -0
- package/dist/local/store/node/database.js.map +1 -0
- package/dist/local/store/node/index.d.ts +11 -0
- package/dist/local/store/node/index.d.ts.map +1 -0
- package/dist/local/store/node/index.js +8 -0
- package/dist/local/store/node/index.js.map +1 -0
- package/dist/local/store/react-native/adapter.d.ts +240 -0
- package/dist/local/store/react-native/adapter.d.ts.map +1 -0
- package/dist/local/store/react-native/adapter.js +1108 -0
- package/dist/local/store/react-native/adapter.js.map +1 -0
- package/dist/local/store/react-native/index.d.ts +19 -0
- package/dist/local/store/react-native/index.d.ts.map +1 -0
- package/dist/local/store/react-native/index.js +6 -0
- package/dist/local/store/react-native/index.js.map +1 -0
- package/dist/local/store/react-native/storage.d.ts +39 -0
- package/dist/local/store/react-native/storage.d.ts.map +1 -0
- package/dist/local/store/react-native/storage.js +2 -0
- package/dist/local/store/react-native/storage.js.map +1 -0
- package/dist/local/store/session-codec.d.ts +5 -0
- package/dist/local/store/session-codec.d.ts.map +1 -0
- package/dist/local/store/session-codec.js +42 -0
- package/dist/local/store/session-codec.js.map +1 -0
- package/dist/local/store/web/adapter.d.ts +190 -0
- package/dist/local/store/web/adapter.d.ts.map +1 -0
- package/dist/local/store/web/adapter.js +1188 -0
- package/dist/local/store/web/adapter.js.map +1 -0
- package/dist/local/store/web/index.d.ts +11 -0
- package/dist/local/store/web/index.d.ts.map +1 -0
- package/dist/local/store/web/index.js +8 -0
- package/dist/local/store/web/index.js.map +1 -0
- package/dist/local/vault/expo-secure-store.d.ts +10 -0
- package/dist/local/vault/expo-secure-store.d.ts.map +1 -0
- package/dist/local/vault/expo-secure-store.js +23 -0
- package/dist/local/vault/expo-secure-store.js.map +1 -0
- package/dist/local/vault/index.d.ts +7 -0
- package/dist/local/vault/index.d.ts.map +1 -0
- package/dist/local/vault/index.js +2 -0
- package/dist/local/vault/index.js.map +1 -0
- package/dist/logger.d.ts +18 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +71 -0
- package/dist/logger.js.map +1 -0
- package/dist/media/index.d.ts +524 -0
- package/dist/media/index.d.ts.map +1 -0
- package/dist/media/index.js +2053 -0
- package/dist/media/index.js.map +1 -0
- package/dist/profile/cipher.d.ts +125 -0
- package/dist/profile/cipher.d.ts.map +1 -0
- package/dist/profile/cipher.js +197 -0
- package/dist/profile/cipher.js.map +1 -0
- package/dist/profile/contact-state.d.ts +33 -0
- package/dist/profile/contact-state.d.ts.map +1 -0
- package/dist/profile/contact-state.js +77 -0
- package/dist/profile/contact-state.js.map +1 -0
- package/dist/profile/crypto.d.ts +65 -0
- package/dist/profile/crypto.d.ts.map +1 -0
- package/dist/profile/crypto.js +93 -0
- package/dist/profile/crypto.js.map +1 -0
- package/dist/profile/index.d.ts +26 -0
- package/dist/profile/index.d.ts.map +1 -0
- package/dist/profile/index.js +30 -0
- package/dist/profile/index.js.map +1 -0
- package/dist/profile/profile-key.d.ts +102 -0
- package/dist/profile/profile-key.d.ts.map +1 -0
- package/dist/profile/profile-key.js +229 -0
- package/dist/profile/profile-key.js.map +1 -0
- package/dist/profile/storage.d.ts +61 -0
- package/dist/profile/storage.d.ts.map +1 -0
- package/dist/profile/storage.js +145 -0
- package/dist/profile/storage.js.map +1 -0
- package/dist/profile/update-service.d.ts +53 -0
- package/dist/profile/update-service.d.ts.map +1 -0
- package/dist/profile/update-service.js +67 -0
- package/dist/profile/update-service.js.map +1 -0
- package/dist/remote/object-store/convex-r2/index.d.ts +11 -0
- package/dist/remote/object-store/convex-r2/index.d.ts.map +1 -0
- package/dist/remote/object-store/convex-r2/index.js +13 -0
- package/dist/remote/object-store/convex-r2/index.js.map +1 -0
- package/dist/remote/object-store/convex-r2/server/index.d.ts +2 -0
- package/dist/remote/object-store/convex-r2/server/index.d.ts.map +1 -0
- package/dist/remote/object-store/convex-r2/server/index.js +2 -0
- package/dist/remote/object-store/convex-r2/server/index.js.map +1 -0
- package/dist/remote/object-store/convex-r2/server.d.ts +126 -0
- package/dist/remote/object-store/convex-r2/server.d.ts.map +1 -0
- package/dist/remote/object-store/convex-r2/server.js +232 -0
- package/dist/remote/object-store/convex-r2/server.js.map +1 -0
- package/dist/remote/object-store/convex-r2/storage.d.ts +47 -0
- package/dist/remote/object-store/convex-r2/storage.d.ts.map +1 -0
- package/dist/remote/object-store/convex-r2/storage.js +55 -0
- package/dist/remote/object-store/convex-r2/storage.js.map +1 -0
- package/dist/remote/object-store/index.d.ts +8 -0
- package/dist/remote/object-store/index.d.ts.map +1 -0
- package/dist/remote/object-store/index.js +2 -0
- package/dist/remote/object-store/index.js.map +1 -0
- package/dist/remote/object-store/s3/index.d.ts +8 -0
- package/dist/remote/object-store/s3/index.d.ts.map +1 -0
- package/dist/remote/object-store/s3/index.js +10 -0
- package/dist/remote/object-store/s3/index.js.map +1 -0
- package/dist/remote/object-store/s3/storage.d.ts +44 -0
- package/dist/remote/object-store/s3/storage.d.ts.map +1 -0
- package/dist/remote/object-store/s3/storage.js +41 -0
- package/dist/remote/object-store/s3/storage.js.map +1 -0
- package/dist/remote/object-store/types.d.ts +80 -0
- package/dist/remote/object-store/types.d.ts.map +1 -0
- package/dist/remote/object-store/types.js +2 -0
- package/dist/remote/object-store/types.js.map +1 -0
- package/dist/remote/object-store/validation.d.ts +6 -0
- package/dist/remote/object-store/validation.d.ts.map +1 -0
- package/dist/remote/object-store/validation.js +93 -0
- package/dist/remote/object-store/validation.js.map +1 -0
- package/dist/remote/relay/convex/group-server.d.ts +118 -0
- package/dist/remote/relay/convex/group-server.d.ts.map +1 -0
- package/dist/remote/relay/convex/group-server.js +150 -0
- package/dist/remote/relay/convex/group-server.js.map +1 -0
- package/dist/remote/relay/convex/index.d.ts +39 -0
- package/dist/remote/relay/convex/index.d.ts.map +1 -0
- package/dist/remote/relay/convex/index.js +36 -0
- package/dist/remote/relay/convex/index.js.map +1 -0
- package/dist/remote/relay/convex/relay.d.ts +339 -0
- package/dist/remote/relay/convex/relay.d.ts.map +1 -0
- package/dist/remote/relay/convex/relay.js +1086 -0
- package/dist/remote/relay/convex/relay.js.map +1 -0
- package/dist/remote/relay/convex/types.d.ts +111 -0
- package/dist/remote/relay/convex/types.d.ts.map +1 -0
- package/dist/remote/relay/convex/types.js +19 -0
- package/dist/remote/relay/convex/types.js.map +1 -0
- package/dist/remote/relay/index.d.ts +34 -0
- package/dist/remote/relay/index.d.ts.map +1 -0
- package/dist/remote/relay/index.js +28 -0
- package/dist/remote/relay/index.js.map +1 -0
- package/dist/remote/relay/mock/adapter.d.ts +237 -0
- package/dist/remote/relay/mock/adapter.d.ts.map +1 -0
- package/dist/remote/relay/mock/adapter.js +939 -0
- package/dist/remote/relay/mock/adapter.js.map +1 -0
- package/dist/remote/relay/mock/index.d.ts +10 -0
- package/dist/remote/relay/mock/index.d.ts.map +1 -0
- package/dist/remote/relay/mock/index.js +6 -0
- package/dist/remote/relay/mock/index.js.map +1 -0
- package/dist/remote/relay/types.d.ts +756 -0
- package/dist/remote/relay/types.d.ts.map +1 -0
- package/dist/remote/relay/types.js +11 -0
- package/dist/remote/relay/types.js.map +1 -0
- package/dist/safety/core.d.ts +108 -0
- package/dist/safety/core.d.ts.map +1 -0
- package/dist/safety/core.js +299 -0
- package/dist/safety/core.js.map +1 -0
- package/dist/safety/fingerprint.d.ts +277 -0
- package/dist/safety/fingerprint.d.ts.map +1 -0
- package/dist/safety/fingerprint.js +339 -0
- package/dist/safety/fingerprint.js.map +1 -0
- package/dist/safety/index.d.ts +141 -0
- package/dist/safety/index.d.ts.map +1 -0
- package/dist/safety/index.js +230 -0
- package/dist/safety/index.js.map +1 -0
- package/dist/safety/protobuf.d.ts +34 -0
- package/dist/safety/protobuf.d.ts.map +1 -0
- package/dist/safety/protobuf.js +142 -0
- package/dist/safety/protobuf.js.map +1 -0
- package/dist/safety/url.d.ts +133 -0
- package/dist/safety/url.d.ts.map +1 -0
- package/dist/safety/url.js +242 -0
- package/dist/safety/url.js.map +1 -0
- package/dist/sealed-sender/index.d.ts +7 -0
- package/dist/sealed-sender/index.d.ts.map +1 -0
- package/dist/sealed-sender/index.js +6 -0
- package/dist/sealed-sender/index.js.map +1 -0
- package/dist/server-clock.d.ts +10 -0
- package/dist/server-clock.d.ts.map +1 -0
- package/dist/server-clock.js +27 -0
- package/dist/server-clock.js.map +1 -0
- package/dist/types/address.d.ts +171 -0
- package/dist/types/address.d.ts.map +1 -0
- package/dist/types/address.js +241 -0
- package/dist/types/address.js.map +1 -0
- package/dist/types/api.d.ts +1222 -0
- package/dist/types/api.d.ts.map +1 -0
- package/dist/types/api.js +5 -0
- package/dist/types/api.js.map +1 -0
- package/dist/types/errors.d.ts +772 -0
- package/dist/types/errors.d.ts.map +1 -0
- package/dist/types/errors.js +937 -0
- package/dist/types/errors.js.map +1 -0
- package/dist/types/index.d.ts +20 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +33 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/messages.d.ts +257 -0
- package/dist/types/messages.d.ts.map +1 -0
- package/dist/types/messages.js +96 -0
- package/dist/types/messages.js.map +1 -0
- package/dist/types/protocol-config.d.ts +337 -0
- package/dist/types/protocol-config.d.ts.map +1 -0
- package/dist/types/protocol-config.js +178 -0
- package/dist/types/protocol-config.js.map +1 -0
- package/dist/types/protocol-constants.d.ts +122 -0
- package/dist/types/protocol-constants.d.ts.map +1 -0
- package/dist/types/protocol-constants.js +115 -0
- package/dist/types/protocol-constants.js.map +1 -0
- package/dist/types/session.d.ts +721 -0
- package/dist/types/session.d.ts.map +1 -0
- package/dist/types/session.js +340 -0
- package/dist/types/session.js.map +1 -0
- package/dist/types/trust.d.ts +168 -0
- package/dist/types/trust.d.ts.map +1 -0
- package/dist/types/trust.js +84 -0
- package/dist/types/trust.js.map +1 -0
- package/dist/types/utils.d.ts +93 -0
- package/dist/types/utils.d.ts.map +1 -0
- package/dist/types/utils.js +89 -0
- package/dist/types/utils.js.map +1 -0
- package/dist/username/index.d.ts +12 -0
- package/dist/username/index.d.ts.map +1 -0
- package/dist/username/index.js +11 -0
- package/dist/username/index.js.map +1 -0
- package/dist/username/link.d.ts +52 -0
- package/dist/username/link.d.ts.map +1 -0
- package/dist/username/link.js +87 -0
- package/dist/username/link.js.map +1 -0
- package/dist/utils/binary-transfer.d.ts +18 -0
- package/dist/utils/binary-transfer.d.ts.map +1 -0
- package/dist/utils/binary-transfer.js +27 -0
- package/dist/utils/binary-transfer.js.map +1 -0
- package/dist/utils/errors.d.ts +9 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +15 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/retry.d.ts +59 -0
- package/dist/utils/retry.d.ts.map +1 -0
- package/dist/utils/retry.js +136 -0
- package/dist/utils/retry.js.map +1 -0
- package/dist/versions.d.ts +62 -0
- package/dist/versions.d.ts.map +1 -0
- package/dist/versions.js +78 -0
- package/dist/versions.js.map +1 -0
- package/dist/zk/credentials.d.ts +10 -0
- package/dist/zk/credentials.d.ts.map +1 -0
- package/dist/zk/credentials.js +9 -0
- package/dist/zk/credentials.js.map +1 -0
- package/dist/zk/groups.d.ts +12 -0
- package/dist/zk/groups.d.ts.map +1 -0
- package/dist/zk/groups.js +11 -0
- package/dist/zk/groups.js.map +1 -0
- package/docs/ASSURANCE.md +102 -0
- package/docs/CLIENT_COMPOSITION.md +189 -0
- package/docs/DOCUMENTATION_STANDARDS.md +107 -0
- package/docs/E2EE.md +35 -0
- package/docs/ERROR_HANDLING.md +396 -0
- package/docs/GETTING_STARTED.md +714 -0
- package/docs/INTERFACES.md +187 -0
- package/docs/PACKAGE_SURFACE.md +235 -0
- package/docs/PROTOCOL_POLICY.md +109 -0
- package/docs/RECIPES.md +389 -0
- package/docs/SECURITY.md +199 -0
- package/docs/api/README.md +471 -0
- package/docs/api/classes/EncryptionError.md +112 -0
- package/docs/api/classes/EndorsementManager.md +307 -0
- package/docs/api/classes/SealedSenderAuthError.md +127 -0
- package/docs/api/classes/ServerDerivedKeyPair.md +68 -0
- package/docs/api/classes/ServerDerivedPublicKey.md +33 -0
- package/docs/api/classes/ServerRootKeyPair.md +94 -0
- package/docs/api/classes/ServerRootPublicKey.md +72 -0
- package/docs/api/classes/SignalBlockingManager.md +106 -0
- package/docs/api/classes/SignalProtocolClient.md +2651 -0
- package/docs/api/classes/VerificationFailure.md +25 -0
- package/docs/api/enumerations/ContentHint.md +63 -0
- package/docs/api/enumerations/EncryptionErrorCode.md +488 -0
- package/docs/api/enumerations/IdentityKeyChange.md +65 -0
- package/docs/api/enumerations/MessageType.md +29 -0
- package/docs/api/enumerations/TrustDirection.md +33 -0
- package/docs/api/enumerations/TypingAction.md +31 -0
- package/docs/api/functions/createDefaultSignalContentAdapter.md +13 -0
- package/docs/api/functions/createDefaultSignalLogger.md +36 -0
- package/docs/api/functions/createGroupId.md +32 -0
- package/docs/api/functions/createSignalProtocolClient.md +36 -0
- package/docs/api/functions/createSignalProtocolClientConfig.md +24 -0
- package/docs/api/functions/extractGroupId.md +32 -0
- package/docs/api/functions/formatVersion.md +25 -0
- package/docs/api/functions/isCompatible.md +31 -0
- package/docs/api/functions/isGroupId.md +37 -0
- package/docs/api/functions/isSealedSenderAuthError.md +25 -0
- package/docs/api/functions/parseVersion.md +29 -0
- package/docs/api/functions/resolveSPQRLimits.md +21 -0
- package/docs/api/functions/resolveSignalLogger.md +42 -0
- package/docs/api/interfaces/AccountIdentityProvisioning.md +43 -0
- package/docs/api/interfaces/AccountIdentityRotation.md +69 -0
- package/docs/api/interfaces/AttachmentTransferOptions.md +49 -0
- package/docs/api/interfaces/BlockedRecipientEntry.md +25 -0
- package/docs/api/interfaces/BlockedRecipientsSyncInput.md +27 -0
- package/docs/api/interfaces/ConfigurationSyncInput.md +19 -0
- package/docs/api/interfaces/CredentialPublicKey.md +25 -0
- package/docs/api/interfaces/DataMessageInput.md +21 -0
- package/docs/api/interfaces/DecryptedEnvelope.md +95 -0
- package/docs/api/interfaces/DecryptedGroup.md +86 -0
- package/docs/api/interfaces/DeviceInfo.md +79 -0
- package/docs/api/interfaces/DeviceRecord.md +87 -0
- package/docs/api/interfaces/DeviceRegistration.md +27 -0
- package/docs/api/interfaces/DoubleRatchetConfig.md +36 -0
- package/docs/api/interfaces/EcOneTimePreKey.md +27 -0
- package/docs/api/interfaces/EcSignedPreKey.md +39 -0
- package/docs/api/interfaces/EcSignedPreKeyUpload.md +50 -0
- package/docs/api/interfaces/EncryptionErrorContext.md +51 -0
- package/docs/api/interfaces/Envelope.md +154 -0
- package/docs/api/interfaces/ForceKeyResetResult.md +37 -0
- package/docs/api/interfaces/GroupAuthorization.md +23 -0
- package/docs/api/interfaces/GroupChangeEntry.md +42 -0
- package/docs/api/interfaces/GroupMemberDevice.md +26 -0
- package/docs/api/interfaces/IEcOneTimePreKeyStore.md +86 -0
- package/docs/api/interfaces/IEcSignedPreKeyStore.md +132 -0
- package/docs/api/interfaces/IGroupServer.md +120 -0
- package/docs/api/interfaces/IGroupStateStore.md +128 -0
- package/docs/api/interfaces/IIdentityKeyStore.md +312 -0
- package/docs/api/interfaces/IKemPreKeyStore.md +144 -0
- package/docs/api/interfaces/IKyberLastResortPreKeyStore.md +111 -0
- package/docs/api/interfaces/ILogger.md +117 -0
- package/docs/api/interfaces/IProtocolStore.md +1033 -0
- package/docs/api/interfaces/ISenderKeyStore.md +417 -0
- package/docs/api/interfaces/ISesameStore.md +249 -0
- package/docs/api/interfaces/ISessionStore.md +178 -0
- package/docs/api/interfaces/ISignalLocalSecretVault.md +71 -0
- package/docs/api/interfaces/ISignalLocalStore.md +2053 -0
- package/docs/api/interfaces/ISignalProtocolClient.md +1183 -0
- package/docs/api/interfaces/ISignalProtocolManager.md +272 -0
- package/docs/api/interfaces/ISignalRelayServer.md +1329 -0
- package/docs/api/interfaces/IdentityKeyPair.md +49 -0
- package/docs/api/interfaces/IncomingEnvelope.md +91 -0
- package/docs/api/interfaces/InspectedSignalContent.md +43 -0
- package/docs/api/interfaces/KDFChain.md +31 -0
- package/docs/api/interfaces/KemLastResortPreKeyUpload.md +50 -0
- package/docs/api/interfaces/KeyPair.md +23 -0
- package/docs/api/interfaces/KyberPreKey.md +42 -0
- package/docs/api/interfaces/MLKEMBraidAgentState.md +191 -0
- package/docs/api/interfaces/MLKEMBraidMessage.md +49 -0
- package/docs/api/interfaces/MediaAttachmentDeleteSyncInput.md +31 -0
- package/docs/api/interfaces/MessageHeader.md +49 -0
- package/docs/api/interfaces/MessageRecord.md +86 -0
- package/docs/api/interfaces/ParsedReceiptContent.md +19 -0
- package/docs/api/interfaces/ParsedTypingContent.md +19 -0
- package/docs/api/interfaces/PreKeyMaintenanceStore.md +87 -0
- package/docs/api/interfaces/PreKeyMessage.md +159 -0
- package/docs/api/interfaces/PreKeyStatusResult.md +21 -0
- package/docs/api/interfaces/PreKeyUpload.md +42 -0
- package/docs/api/interfaces/ProcessEnvelopeOptions.md +72 -0
- package/docs/api/interfaces/ProtocolAddress.md +38 -0
- package/docs/api/interfaces/ProtocolStrategyConfig.md +91 -0
- package/docs/api/interfaces/RatchetMessage.md +96 -0
- package/docs/api/interfaces/ReadSyncEntryInput.md +19 -0
- package/docs/api/interfaces/ReceiverChain.md +43 -0
- package/docs/api/interfaces/RecipientUsernameSyncInput.md +31 -0
- package/docs/api/interfaces/RelayPreKeyBundle.md +254 -0
- package/docs/api/interfaces/RemoteObjectDownload.md +33 -0
- package/docs/api/interfaces/RemoteObjectUpload.md +49 -0
- package/docs/api/interfaces/ResolvedSPQRInfoStrings.md +27 -0
- package/docs/api/interfaces/ResolvedSPQRLimits.md +37 -0
- package/docs/api/interfaces/RetryRequest.md +80 -0
- package/docs/api/interfaces/SCKAState.md +65 -0
- package/docs/api/interfaces/SPQRLimits.md +40 -0
- package/docs/api/interfaces/SPQRState.md +191 -0
- package/docs/api/interfaces/SafetyNumber.md +60 -0
- package/docs/api/interfaces/SafetyNumberConfirmation.md +46 -0
- package/docs/api/interfaces/SealedSenderConfig.md +70 -0
- package/docs/api/interfaces/SendOptions.md +191 -0
- package/docs/api/interfaces/SendResult.md +93 -0
- package/docs/api/interfaces/SenderKeyDistributionMessage.md +43 -0
- package/docs/api/interfaces/SenderKeyState.md +76 -0
- package/docs/api/interfaces/SenderKeysConfig.md +65 -0
- package/docs/api/interfaces/SentSyncTranscriptInput.md +31 -0
- package/docs/api/interfaces/ServiceId.md +19 -0
- package/docs/api/interfaces/SesameMessage.md +84 -0
- package/docs/api/interfaces/SesameStats.md +57 -0
- package/docs/api/interfaces/SessionHealthResult.md +120 -0
- package/docs/api/interfaces/SessionRecord.md +80 -0
- package/docs/api/interfaces/SessionRecordMetadata.md +109 -0
- package/docs/api/interfaces/SessionState.md +368 -0
- package/docs/api/interfaces/SessionTrustCommit.md +58 -0
- package/docs/api/interfaces/SignalBlockingHooks.md +44 -0
- package/docs/api/interfaces/SignalBlockingManagerOptions.md +31 -0
- package/docs/api/interfaces/SignalBlockingMirror.md +30 -0
- package/docs/api/interfaces/SignalBlockingStore.md +83 -0
- package/docs/api/interfaces/SignalContentAdapter.md +325 -0
- package/docs/api/interfaces/SignalProtocolClientAdapterConfig.md +44 -0
- package/docs/api/interfaces/SignalProtocolClientCompositionOptions.md +693 -0
- package/docs/api/interfaces/SignalProtocolClientConfig.md +839 -0
- package/docs/api/interfaces/SignalProtocolClientDeleteLocalAttachmentInput.md +25 -0
- package/docs/api/interfaces/SignalProtocolClientHooks.md +506 -0
- package/docs/api/interfaces/SignalProtocolClientIdentityConfig.md +35 -0
- package/docs/api/interfaces/SignalProtocolClientLoadLocalAttachmentInput.md +187 -0
- package/docs/api/interfaces/SignalProtocolClientLoadedLocalAttachment.md +19 -0
- package/docs/api/interfaces/SignalProtocolClientMedia.md +83 -0
- package/docs/api/interfaces/SignalProtocolClientMediaCompletedResult.md +25 -0
- package/docs/api/interfaces/SignalProtocolClientMediaConfig.md +157 -0
- package/docs/api/interfaces/SignalProtocolClientMediaDownloadCompletedResult.md +37 -0
- package/docs/api/interfaces/SignalProtocolClientMediaDownloadNotNeededResult.md +25 -0
- package/docs/api/interfaces/SignalProtocolClientMediaFailedResult.md +19 -0
- package/docs/api/interfaces/SignalProtocolClientMediaOperationOptions.md +53 -0
- package/docs/api/interfaces/SignalProtocolClientMediaPendingResult.md +19 -0
- package/docs/api/interfaces/SignalProtocolClientMediaProcessResult.md +43 -0
- package/docs/api/interfaces/SignalProtocolClientMediaSkippedResult.md +25 -0
- package/docs/api/interfaces/SignalProtocolClientMediaUploadCompletedResult.md +31 -0
- package/docs/api/interfaces/SignalProtocolClientProcessPendingMediaOptions.md +87 -0
- package/docs/api/interfaces/SignalProtocolClientSaveDownloadedAttachmentInput.md +25 -0
- package/docs/api/interfaces/SignalProtocolClientSaveUploadedAttachmentInput.md +25 -0
- package/docs/api/interfaces/SignalProtocolClientSyncDeleteInput.md +19 -0
- package/docs/api/interfaces/SignalProtocolConfig.md +50 -0
- package/docs/api/interfaces/SignalRemoteObjectStore.md +88 -0
- package/docs/api/interfaces/SkippedSenderMessageKey.md +26 -0
- package/docs/api/interfaces/TaskNotificationAckSyncInput.md +31 -0
- package/docs/api/interfaces/TripleRatchetState.md +64 -0
- package/docs/api/interfaces/UserRecord.md +71 -0
- package/docs/api/interfaces/UsernameStateSyncInput.md +19 -0
- package/docs/api/interfaces/VerificationStateSyncInput.md +31 -0
- package/docs/api/interfaces/VersionNegotiationState.md +84 -0
- package/docs/api/interfaces/ViewOnceOpenSyncInput.md +19 -0
- package/docs/api/namespaces/ProtocolAddress/README.md +33 -0
- package/docs/api/namespaces/ProtocolAddress/functions/create.md +41 -0
- package/docs/api/namespaces/ProtocolAddress/functions/equals.md +39 -0
- package/docs/api/namespaces/ProtocolAddress/functions/fromStorageKey.md +36 -0
- package/docs/api/namespaces/ProtocolAddress/functions/isUser.md +39 -0
- package/docs/api/namespaces/ProtocolAddress/functions/isValid.md +34 -0
- package/docs/api/namespaces/ProtocolAddress/functions/parse.md +41 -0
- package/docs/api/namespaces/ProtocolAddress/functions/toStorageKey.md +38 -0
- package/docs/api/namespaces/ProtocolAddress/functions/toString.md +34 -0
- package/docs/api/namespaces/SessionRecord/README.md +30 -0
- package/docs/api/namespaces/SessionRecord/functions/archiveCurrent.md +40 -0
- package/docs/api/namespaces/SessionRecord/functions/archiveCurrentState.md +34 -0
- package/docs/api/namespaces/SessionRecord/functions/create.md +25 -0
- package/docs/api/namespaces/SessionRecord/functions/deserialize.md +29 -0
- package/docs/api/namespaces/SessionRecord/functions/findSession.md +34 -0
- package/docs/api/namespaces/SessionRecord/functions/getAllSessions.md +25 -0
- package/docs/api/namespaces/SessionRecord/functions/getArchivedCount.md +25 -0
- package/docs/api/namespaces/SessionRecord/functions/hasCurrentSession.md +25 -0
- package/docs/api/namespaces/SessionRecord/functions/hasUsableSenderChain.md +36 -0
- package/docs/api/namespaces/SessionRecord/functions/promoteSession.md +34 -0
- package/docs/api/namespaces/SessionRecord/functions/serialize.md +28 -0
- package/docs/api/namespaces/SessionRecord/variables/MAX_ARCHIVED_SESSIONS.md +14 -0
- package/docs/api/namespaces/SessionState/README.md +15 -0
- package/docs/api/namespaces/SessionState/functions/getSessionId.md +32 -0
- package/docs/api/namespaces/blocking/README.md +43 -0
- package/docs/api/namespaces/encoding/README.md +33 -0
- package/docs/api/namespaces/encoding/functions/base64ToUrlSafe.md +28 -0
- package/docs/api/namespaces/encoding/functions/bytesToBase64.md +21 -0
- package/docs/api/namespaces/encoding/functions/bytesToString.md +21 -0
- package/docs/api/namespaces/encoding/functions/bytesToUrlSafeBase64.md +33 -0
- package/docs/api/namespaces/encoding/functions/concatBytes.md +21 -0
- package/docs/api/namespaces/encoding/functions/stringToBytes.md +21 -0
- package/docs/api/namespaces/encoding/functions/urlSafeToBase64.md +27 -0
- package/docs/api/namespaces/keys/README.md +126 -0
- package/docs/api/namespaces/keys/functions/acceptContactIdentityRotation.md +33 -0
- package/docs/api/namespaces/keys/functions/assertIdentityCommitment.md +25 -0
- package/docs/api/namespaces/keys/functions/compositeIdentitiesEqual.md +23 -0
- package/docs/api/namespaces/keys/functions/createCompositeIdentityV1.md +19 -0
- package/docs/api/namespaces/keys/functions/createPreKeySignatureContext.md +31 -0
- package/docs/api/namespaces/keys/functions/createUnverifiedContactIdentityRecord.md +23 -0
- package/docs/api/namespaces/keys/functions/decodeCompositeIdentityV1.md +19 -0
- package/docs/api/namespaces/keys/functions/deriveIdentityCommitment.md +19 -0
- package/docs/api/namespaces/keys/functions/encodeCompositeIdentityV1.md +19 -0
- package/docs/api/namespaces/keys/functions/evaluateContactIdentityCandidate.md +27 -0
- package/docs/api/namespaces/keys/functions/generateEcOneTimePreKeys.md +37 -0
- package/docs/api/namespaces/keys/functions/generateEcSignedPreKey.md +39 -0
- package/docs/api/namespaces/keys/functions/generateEcSignedPreKeyId.md +21 -0
- package/docs/api/namespaces/keys/functions/generateIdentityKeyPair.md +24 -0
- package/docs/api/namespaces/keys/functions/generateKemOneTimePreKeys.md +47 -0
- package/docs/api/namespaces/keys/functions/generateKyberLastResortPreKey.md +37 -0
- package/docs/api/namespaces/keys/functions/generateRegistrationId.md +13 -0
- package/docs/api/namespaces/keys/functions/signMlKem1024PreKey.md +29 -0
- package/docs/api/namespaces/keys/functions/signPreKey.md +31 -0
- package/docs/api/namespaces/keys/functions/validateContactIdentityRecord.md +19 -0
- package/docs/api/namespaces/keys/functions/verifyContactIdentityRecord.md +31 -0
- package/docs/api/namespaces/keys/functions/verifyMlKem1024PreKey.md +33 -0
- package/docs/api/namespaces/keys/functions/verifyPreKeySignature.md +35 -0
- package/docs/api/namespaces/keys/interfaces/CompositeIdentityV1.md +33 -0
- package/docs/api/namespaces/keys/interfaces/ContactIdentityRecord.md +53 -0
- package/docs/api/namespaces/keys/interfaces/KemOneTimePreKey.md +43 -0
- package/docs/api/namespaces/keys/type-aliases/IdentityCandidateStatus.md +9 -0
- package/docs/api/namespaces/keys/type-aliases/IdentityTrustState.md +9 -0
- package/docs/api/namespaces/keys/type-aliases/IdentityType.md +9 -0
- package/docs/api/namespaces/keys/variables/COMPOSITE_IDENTITY_V1_ED25519_TAG.md +9 -0
- package/docs/api/namespaces/keys/variables/COMPOSITE_IDENTITY_V1_LENGTH.md +9 -0
- package/docs/api/namespaces/keys/variables/COMPOSITE_IDENTITY_V1_VERSION.md +9 -0
- package/docs/api/namespaces/keys/variables/COMPOSITE_IDENTITY_V1_X25519_TAG.md +9 -0
- package/docs/api/namespaces/keys/variables/IDENTITY_COMMITMENT_V1_DOMAIN.md +9 -0
- package/docs/api/namespaces/keys/variables/PREKEY_ALGORITHM_ML_KEM_1024.md +9 -0
- package/docs/api/namespaces/keys/variables/PREKEY_ALGORITHM_X25519.md +9 -0
- package/docs/api/namespaces/keys/variables/PREKEY_SIGNATURE_V1_DOMAIN.md +9 -0
- package/docs/api/namespaces/media/README.md +105 -0
- package/docs/api/namespaces/media/classes/MediaAttachmentError.md +57 -0
- package/docs/api/namespaces/media/functions/createByteRangeMediaAttachmentTransfer.md +19 -0
- package/docs/api/namespaces/media/functions/createMediaAttachmentDeliveryId.md +29 -0
- package/docs/api/namespaces/media/functions/createMediaAttachmentId.md +19 -0
- package/docs/api/namespaces/media/functions/createMediaAttachmentMessage.md +25 -0
- package/docs/api/namespaces/media/functions/createMediaAttachmentPointer.md +19 -0
- package/docs/api/namespaces/media/functions/createTusMediaAttachmentTransfer.md +19 -0
- package/docs/api/namespaces/media/functions/deleteMediaAttachment.md +23 -0
- package/docs/api/namespaces/media/functions/executeMediaAttachmentJob.md +23 -0
- package/docs/api/namespaces/media/functions/isMediaAttachmentFlagSet.md +19 -0
- package/docs/api/namespaces/media/functions/parseMediaAttachmentMessage.md +19 -0
- package/docs/api/namespaces/media/functions/planMediaAttachmentCleanup.md +23 -0
- package/docs/api/namespaces/media/functions/planMediaAttachmentCleanupJobs.md +19 -0
- package/docs/api/namespaces/media/functions/planMediaAttachmentDeleteSync.md +19 -0
- package/docs/api/namespaces/media/functions/planMediaAttachmentDownloadJob.md +19 -0
- package/docs/api/namespaces/media/functions/planMediaAttachmentOpen.md +19 -0
- package/docs/api/namespaces/media/functions/planMediaAttachmentProcessing.md +19 -0
- package/docs/api/namespaces/media/functions/planMediaAttachmentUploadJob.md +19 -0
- package/docs/api/namespaces/media/functions/prepareMediaAttachmentUpload.md +30 -0
- package/docs/api/namespaces/media/functions/resolveMediaAttachment.md +30 -0
- package/docs/api/namespaces/media/functions/serializeMediaAttachmentMessage.md +25 -0
- package/docs/api/namespaces/media/functions/validateMediaAttachmentPolicy.md +23 -0
- package/docs/api/namespaces/media/interfaces/ByteRangeMediaAttachmentPartialStore.md +68 -0
- package/docs/api/namespaces/media/interfaces/ByteRangeMediaAttachmentTransferOptions.md +91 -0
- package/docs/api/namespaces/media/interfaces/DeleteMediaAttachmentOptions.md +25 -0
- package/docs/api/namespaces/media/interfaces/DeleteMediaAttachmentResult.md +19 -0
- package/docs/api/namespaces/media/interfaces/ExecuteMediaAttachmentJobOptions.md +157 -0
- package/docs/api/namespaces/media/interfaces/MediaAttachmentBackgroundJob.md +85 -0
- package/docs/api/namespaces/media/interfaces/MediaAttachmentCleanupPlan.md +37 -0
- package/docs/api/namespaces/media/interfaces/MediaAttachmentJobExecutionResult.md +55 -0
- package/docs/api/namespaces/media/interfaces/MediaAttachmentMessage.md +31 -0
- package/docs/api/namespaces/media/interfaces/MediaAttachmentOpenDecision.md +31 -0
- package/docs/api/namespaces/media/interfaces/MediaAttachmentPointer.md +133 -0
- package/docs/api/namespaces/media/interfaces/MediaAttachmentPolicy.md +67 -0
- package/docs/api/namespaces/media/interfaces/MediaAttachmentProcessingPlan.md +73 -0
- package/docs/api/namespaces/media/interfaces/MediaAttachmentProgress.md +69 -0
- package/docs/api/namespaces/media/interfaces/MediaAttachmentResumeState.md +37 -0
- package/docs/api/namespaces/media/interfaces/MediaAttachmentRetryOptions.md +31 -0
- package/docs/api/namespaces/media/interfaces/MediaAttachmentTransfer.md +51 -0
- package/docs/api/namespaces/media/interfaces/MediaAttachmentTransferCheckpoint.md +69 -0
- package/docs/api/namespaces/media/interfaces/MediaAttachmentTransferOptions.md +67 -0
- package/docs/api/namespaces/media/interfaces/MediaAttachmentUploadJobData.md +19 -0
- package/docs/api/namespaces/media/interfaces/MediaAttachmentUploadResponse.md +25 -0
- package/docs/api/namespaces/media/interfaces/PlanMediaAttachmentCleanupJobsInput.md +61 -0
- package/docs/api/namespaces/media/interfaces/PlanMediaAttachmentDeleteSyncInput.md +25 -0
- package/docs/api/namespaces/media/interfaces/PlanMediaAttachmentDownloadJobInput.md +161 -0
- package/docs/api/namespaces/media/interfaces/PlanMediaAttachmentOpenInput.md +25 -0
- package/docs/api/namespaces/media/interfaces/PlanMediaAttachmentProcessingInput.md +83 -0
- package/docs/api/namespaces/media/interfaces/PlanMediaAttachmentUploadJobInput.md +147 -0
- package/docs/api/namespaces/media/interfaces/PrepareMediaAttachmentUploadOptions.md +144 -0
- package/docs/api/namespaces/media/interfaces/ResolveMediaAttachmentOptions.md +55 -0
- package/docs/api/namespaces/media/interfaces/ResolvedMediaAttachment.md +109 -0
- package/docs/api/namespaces/media/interfaces/TusMediaAttachmentTransferOptions.md +85 -0
- package/docs/api/namespaces/media/type-aliases/CreateMediaAttachmentPointerInput.md +15 -0
- package/docs/api/namespaces/media/type-aliases/MediaAttachmentCheckpointCallback.md +19 -0
- package/docs/api/namespaces/media/type-aliases/MediaAttachmentCleanupReason.md +9 -0
- package/docs/api/namespaces/media/type-aliases/MediaAttachmentErrorCode.md +9 -0
- package/docs/api/namespaces/media/type-aliases/MediaAttachmentFlag.md +9 -0
- package/docs/api/namespaces/media/type-aliases/MediaAttachmentJobExecutionStatus.md +9 -0
- package/docs/api/namespaces/media/type-aliases/MediaAttachmentJobOperation.md +9 -0
- package/docs/api/namespaces/media/type-aliases/MediaAttachmentJobPriority.md +9 -0
- package/docs/api/namespaces/media/type-aliases/MediaAttachmentJobSkipReason.md +9 -0
- package/docs/api/namespaces/media/type-aliases/MediaAttachmentJobSource.md +9 -0
- package/docs/api/namespaces/media/type-aliases/MediaAttachmentKnownIds.md +9 -0
- package/docs/api/namespaces/media/type-aliases/MediaAttachmentMessageType.md +9 -0
- package/docs/api/namespaces/media/type-aliases/MediaAttachmentProgressCallback.md +19 -0
- package/docs/api/namespaces/media/variables/MEDIA_ATTACHMENT_POLICY_DEFAULTS.md +47 -0
- package/docs/api/namespaces/media/variables/MEDIA_ATTACHMENT_POLICY_PRESETS.md +95 -0
- package/docs/api/namespaces/media/variables/MediaAttachmentCleanupReason.md +27 -0
- package/docs/api/namespaces/media/variables/MediaAttachmentErrorCode.md +75 -0
- package/docs/api/namespaces/media/variables/MediaAttachmentFlag.md +23 -0
- package/docs/api/namespaces/media/variables/MediaAttachmentJobExecutionStatus.md +19 -0
- package/docs/api/namespaces/media/variables/MediaAttachmentJobOperation.md +31 -0
- package/docs/api/namespaces/media/variables/MediaAttachmentJobPriority.md +23 -0
- package/docs/api/namespaces/media/variables/MediaAttachmentJobSource.md +51 -0
- package/docs/api/namespaces/media/variables/MediaAttachmentMessageType.md +15 -0
- package/docs/api/namespaces/media/variables/downloadMediaAttachment.md +30 -0
- package/docs/api/namespaces/safety/README.md +61 -0
- package/docs/api/namespaces/safety/classes/DisplayableFingerprint.md +108 -0
- package/docs/api/namespaces/safety/classes/Fingerprint.md +104 -0
- package/docs/api/namespaces/safety/classes/ScannableFingerprint.md +209 -0
- package/docs/api/namespaces/safety/functions/base64ToBytes.md +21 -0
- package/docs/api/namespaces/safety/functions/clearFingerprintCache.md +15 -0
- package/docs/api/namespaces/safety/functions/compareSafetyNumbers.md +25 -0
- package/docs/api/namespaces/safety/functions/createFingerprintData.md +60 -0
- package/docs/api/namespaces/safety/functions/extractQrData.md +34 -0
- package/docs/api/namespaces/safety/functions/generateCompositeSafetyNumber.md +39 -0
- package/docs/api/namespaces/safety/functions/generateEmojiFingerprint.md +24 -0
- package/docs/api/namespaces/safety/functions/generateSingleKeyReferenceSafetyNumber.md +51 -0
- package/docs/api/namespaces/safety/functions/generateVerifySchemeUrl.md +32 -0
- package/docs/api/namespaces/safety/functions/generateVerifyUrl.md +49 -0
- package/docs/api/namespaces/safety/functions/isValidSafetyNumber.md +21 -0
- package/docs/api/namespaces/safety/functions/isVerifyUrl.md +45 -0
- package/docs/api/namespaces/safety/functions/parseVerifyUrl.md +31 -0
- package/docs/api/namespaces/safety/interfaces/FingerprintData.md +52 -0
- package/docs/api/namespaces/safety/interfaces/SafetyNumber.md +49 -0
- package/docs/api/namespaces/safety/interfaces/VerifyLinkConfig.md +28 -0
- package/docs/api/namespaces/safety/interfaces/VerifyUrlParams.md +49 -0
- package/docs/api/namespaces/safety/type-aliases/CompareResult.md +21 -0
- package/docs/api/namespaces/safety/variables/DEFAULT_VERIFY_LINK_CONFIG.md +12 -0
- package/docs/api/namespaces/safety/variables/FINGERPRINT_ITERATIONS.md +12 -0
- package/docs/api/namespaces/safety/variables/FINGERPRINT_VERSION.md +12 -0
- package/docs/api/namespaces/safety/variables/VERIFY_BASE_URL.md +11 -0
- package/docs/api/namespaces/safety/variables/VERIFY_SCHEME_URL.md +11 -0
- package/docs/api/type-aliases/Base64.md +20 -0
- package/docs/api/type-aliases/BraidPolicy.md +11 -0
- package/docs/api/type-aliases/Bytes.md +20 -0
- package/docs/api/type-aliases/Ciphertext.md +21 -0
- package/docs/api/type-aliases/DeviceType.md +11 -0
- package/docs/api/type-aliases/DownloadedAttachment.md +11 -0
- package/docs/api/type-aliases/GroupId.md +27 -0
- package/docs/api/type-aliases/Hex.md +20 -0
- package/docs/api/type-aliases/HookName.md +11 -0
- package/docs/api/type-aliases/PostQuantumPolicy.md +11 -0
- package/docs/api/type-aliases/PreparedAttachmentUpload.md +14 -0
- package/docs/api/type-aliases/PrivateKey.md +22 -0
- package/docs/api/type-aliases/ProgressCallback.md +45 -0
- package/docs/api/type-aliases/PublicKey.md +22 -0
- package/docs/api/type-aliases/RemoteObjectCompleteUploadRequest.md +19 -0
- package/docs/api/type-aliases/RemoteObjectDeleteRequest.md +19 -0
- package/docs/api/type-aliases/RemoteObjectDownloadRequest.md +19 -0
- package/docs/api/type-aliases/RemoteObjectUploadRequest.md +42 -0
- package/docs/api/type-aliases/SCKAMode.md +11 -0
- package/docs/api/type-aliases/SealedSenderAuth.md +15 -0
- package/docs/api/type-aliases/SignalProtocolClientMediaCleanupInput.md +9 -0
- package/docs/api/type-aliases/SignalProtocolClientMediaCleanupResult.md +9 -0
- package/docs/api/type-aliases/SignalProtocolClientMediaDownloadInput.md +9 -0
- package/docs/api/type-aliases/SignalProtocolClientMediaDownloadResult.md +9 -0
- package/docs/api/type-aliases/SignalProtocolClientMediaOperationResult.md +9 -0
- package/docs/api/type-aliases/SignalProtocolClientMediaUploadInput.md +9 -0
- package/docs/api/type-aliases/SignalProtocolClientMediaUploadResult.md +9 -0
- package/docs/api/type-aliases/Signature.md +21 -0
- package/docs/api/type-aliases/Unsubscribe.md +15 -0
- package/docs/api/variables/BraidPolicy.md +21 -0
- package/docs/api/variables/DEFAULT_DEVICE_ID.md +12 -0
- package/docs/api/variables/DOUBLE_RATCHET_SPEC.md +11 -0
- package/docs/api/variables/GROUP_V2_PREFIX.md +11 -0
- package/docs/api/variables/KEY_REFRESH_INTERVAL_MS_DEFAULT.md +11 -0
- package/docs/api/variables/MAX_MESSAGE_KEYS.md +14 -0
- package/docs/api/variables/MAX_PREKEY_AGE_MS_DEFAULT.md +11 -0
- package/docs/api/variables/MAX_RECEIVER_CHAINS.md +14 -0
- package/docs/api/variables/MAX_REGISTRATION_ID.md +16 -0
- package/docs/api/variables/MAX_SKIP.md +11 -0
- package/docs/api/variables/MESSAGE_FORMAT.md +11 -0
- package/docs/api/variables/MIN_REGISTRATION_ID.md +16 -0
- package/docs/api/variables/ML_KEM_BRAID_SPEC.md +11 -0
- package/docs/api/variables/ONE_TIME_PREKEY_BATCH_SIZE.md +21 -0
- package/docs/api/variables/PQXDH_SPEC.md +11 -0
- package/docs/api/variables/PostQuantumPolicy.md +21 -0
- package/docs/api/variables/SENDER_KEY_FORMAT.md +11 -0
- package/docs/api/variables/SENDER_KEY_SPEC.md +11 -0
- package/docs/api/variables/SESAME_SPEC.md +11 -0
- package/docs/api/variables/SESSION_FORMAT.md +11 -0
- package/docs/api/variables/SPQR_LIMITS_DEFAULTS.md +11 -0
- package/docs/api/variables/X3DH_SPEC.md +9 -0
- package/docs/api/variables/defaultSignalLogger.md +32 -0
- package/encoding/README.md +32 -0
- package/files/README.md +37 -0
- package/groups/README.md +42 -0
- package/hooks/README.md +40 -0
- package/keys/README.md +121 -0
- package/local/store/README.md +120 -0
- package/local/store/expo/README.md +73 -0
- package/local/store/mock/README.md +27 -0
- package/local/store/node/README.md +35 -0
- package/local/store/react-native/README.md +39 -0
- package/local/store/web/README.md +65 -0
- package/local/vault/README.md +32 -0
- package/media/README.md +73 -0
- package/package.json +436 -0
- package/profile/README.md +44 -0
- package/remote/README.md +219 -0
- package/remote/object-store/README.md +45 -0
- package/remote/object-store/convex-r2/README.md +85 -0
- package/remote/object-store/s3/README.md +35 -0
- package/remote/relay/README.md +38 -0
- package/remote/relay/convex/README.md +54 -0
- package/remote/relay/mock/README.md +32 -0
- package/safety/README.md +42 -0
- package/sealed-sender/README.md +32 -0
- package/types/README.md +36 -0
- package/username/README.md +37 -0
- package/utils/README.md +37 -0
- package/zk/README.md +36 -0
|
@@ -0,0 +1,1760 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SESAME (Secure Encrypted Stored Authenticated Messaging Extension)
|
|
3
|
+
*
|
|
4
|
+
* Signal Protocol Section 7 - SESAME
|
|
5
|
+
* Multi-device session management for encrypted asynchronous messaging.
|
|
6
|
+
*
|
|
7
|
+
* Key Features:
|
|
8
|
+
* - Generic support for SESAME's per-user and per-device identity-key models;
|
|
9
|
+
* the client provisions one composite tuple per user and identity type
|
|
10
|
+
* - Session convergence through receive-activated switching
|
|
11
|
+
* - 3-phase message sending process
|
|
12
|
+
* - Automatic session expiration and cleanup
|
|
13
|
+
* - Retry request mechanism for failed decryption
|
|
14
|
+
* - Stale record cleanup to prevent storage growth
|
|
15
|
+
*
|
|
16
|
+
* @see https://signal.org/docs/specifications/sesame/
|
|
17
|
+
*/
|
|
18
|
+
import { defaultSignalLogger } from '../../logger.js';
|
|
19
|
+
import { getErrorMessage } from '../../utils/errors.js';
|
|
20
|
+
import { RetryReason, DEFAULT_SESAME_CONFIG, SesameError, SesameDeviceNotFoundError, NoActiveSessionError, DecryptionFailedError, StaleDeviceListError, MIN_DEVICE_ID, MAX_DEVICE_ID,
|
|
21
|
+
// Session record helpers
|
|
22
|
+
updateSessionRecordAfterSend, updateSessionRecordAfterReceive, } from './types.js';
|
|
23
|
+
import { validateSesameConfig } from './validation.js';
|
|
24
|
+
import { ProtocolAddress } from '../../types/address.js';
|
|
25
|
+
import { constantTimeEqual, base64ToBytes, bytesToBase64 } from '../crypto/utils.js';
|
|
26
|
+
import { deserializePublicKey } from '../crypto/key-prefix.js';
|
|
27
|
+
import { parsePreKeySignalMessageEnvelope, decodePreKeySignalMessage, parseSignalMessageEnvelope, decodeSignalMessage, } from '../encoding/proto/index.js';
|
|
28
|
+
import { SessionResolver } from '../session/session-resolver.js';
|
|
29
|
+
import { EncryptionError } from '../../types/errors.js';
|
|
30
|
+
import { decodeCompositeIdentityV1, encodeCompositeIdentityV1 } from '../../keys/identity.js';
|
|
31
|
+
export const MAX_SEND_RETRIES = 3;
|
|
32
|
+
/**
|
|
33
|
+
* Detect if a ciphertext is a PreKeyMessage (initiating message)
|
|
34
|
+
*
|
|
35
|
+
* PreKeyMessages are sent to establish new sessions and contain
|
|
36
|
+
* the sender's identity key and prekey information.
|
|
37
|
+
*
|
|
38
|
+
* @param ciphertext - The encrypted message content
|
|
39
|
+
* @returns true if this is a PreKeyMessage (initiating), false otherwise
|
|
40
|
+
*/
|
|
41
|
+
function isPreKeyMessage(ciphertext) {
|
|
42
|
+
// Binary protobuf format: base64 decode, check version byte + first protobuf tag
|
|
43
|
+
try {
|
|
44
|
+
const bytes = base64ToBytes(ciphertext);
|
|
45
|
+
if (bytes.length < 2)
|
|
46
|
+
return false;
|
|
47
|
+
// Check for valid version byte (high nibble should be protocol version)
|
|
48
|
+
const version = bytes[0] >> 4;
|
|
49
|
+
if (version < 2 || version > 15)
|
|
50
|
+
return false;
|
|
51
|
+
// Detect message type from first protobuf tag:
|
|
52
|
+
// PreKeySignalMessage wire field 1 (uint32, oneTimePreKeyId/ecOneTimePreKeyId) → wire type 0 → tag 0x08
|
|
53
|
+
// PreKeySignalMessage wire field 2 (bytes, baseKey) → wire type 2 → tag 0x12
|
|
54
|
+
// SignalMessage wire field 1 (bytes, ratchetKey) → wire type 2 → tag 0x0A
|
|
55
|
+
const firstTag = bytes[1];
|
|
56
|
+
return firstTag === 0x08 || firstTag === 0x12;
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* SESAME Manager implementation
|
|
64
|
+
*
|
|
65
|
+
* Manages multi-device sessions following the Signal Protocol SESAME specification.
|
|
66
|
+
*
|
|
67
|
+
* Supports event callbacks for observability via the SesameEvents interface.
|
|
68
|
+
*/
|
|
69
|
+
export class SesameManager {
|
|
70
|
+
storage;
|
|
71
|
+
config;
|
|
72
|
+
localUserId = null;
|
|
73
|
+
localDeviceId = null;
|
|
74
|
+
protocol = null;
|
|
75
|
+
logger;
|
|
76
|
+
/**
|
|
77
|
+
* Optional MessageRecord store for SESAME retry request support.
|
|
78
|
+
* When set, sent messages are stored so they can be resent on retry request.
|
|
79
|
+
* Per SESAME Specification Section 6.2.
|
|
80
|
+
*/
|
|
81
|
+
messageRecordStore = null;
|
|
82
|
+
/**
|
|
83
|
+
* O(1) session lookup index: sessionId -> { userId, deviceId }
|
|
84
|
+
*
|
|
85
|
+
* Maps sessionId (from ProtocolAddress.toString() of the session's remoteAddress)
|
|
86
|
+
* to the userId and deviceId of the DeviceRecord containing that session.
|
|
87
|
+
* Maintained during registerSession(), setSession(), removeDevice(),
|
|
88
|
+
* and related methods to avoid O(n*m) scans in findSession().
|
|
89
|
+
*/
|
|
90
|
+
sessionIndex = new Map();
|
|
91
|
+
/**
|
|
92
|
+
* Event callbacks for session lifecycle events.
|
|
93
|
+
* Set via setEvents() or constructor options.
|
|
94
|
+
*/
|
|
95
|
+
events = {};
|
|
96
|
+
constructor(storage, config, protocol, events, logger = defaultSignalLogger) {
|
|
97
|
+
this.logger = logger;
|
|
98
|
+
// Validate configuration per SESAME specification
|
|
99
|
+
const validation = validateSesameConfig(config);
|
|
100
|
+
if (!validation.valid) {
|
|
101
|
+
const errorMsg = `Invalid SESAME configuration: ${validation.errors.join('; ')}`;
|
|
102
|
+
this.logger.error(errorMsg, {
|
|
103
|
+
category: 'SESAME',
|
|
104
|
+
data: { errors: validation.errors },
|
|
105
|
+
});
|
|
106
|
+
throw new SesameError(errorMsg, 'INVALID_CONFIG');
|
|
107
|
+
}
|
|
108
|
+
// Log warnings but allow configuration
|
|
109
|
+
if (validation.warnings.length > 0) {
|
|
110
|
+
this.logger.warn('SESAME configuration warnings', {
|
|
111
|
+
category: 'SESAME',
|
|
112
|
+
data: { warnings: validation.warnings },
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
this.storage = storage;
|
|
116
|
+
this.config = { ...DEFAULT_SESAME_CONFIG, ...config };
|
|
117
|
+
this.protocol = protocol || null;
|
|
118
|
+
this.events = events || {};
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Set the Signal Protocol manager for encryption/decryption
|
|
122
|
+
* This must be called before using send/receive
|
|
123
|
+
*/
|
|
124
|
+
setProtocolManager(protocol) {
|
|
125
|
+
this.protocol = protocol;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Set the MessageRecord store for retry request support.
|
|
129
|
+
* Per SESAME Specification Section 6.2 - "Each MessageRecord stores
|
|
130
|
+
* the plaintext of the encrypted message."
|
|
131
|
+
*
|
|
132
|
+
* When set, sent messages are stored so they can be resent on retry request.
|
|
133
|
+
*/
|
|
134
|
+
setMessageRecordStore(store) {
|
|
135
|
+
this.messageRecordStore = store;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Set event callbacks for session lifecycle events.
|
|
139
|
+
*
|
|
140
|
+
* @param events - Event callbacks to set
|
|
141
|
+
*/
|
|
142
|
+
setEvents(events) {
|
|
143
|
+
this.events = events;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Get current event callbacks
|
|
147
|
+
*/
|
|
148
|
+
getEvents() {
|
|
149
|
+
return this.events;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Initialize SESAME manager with local device information
|
|
153
|
+
*/
|
|
154
|
+
async initialize(localUserId, localDeviceId) {
|
|
155
|
+
this.localUserId = localUserId;
|
|
156
|
+
this.localDeviceId = localDeviceId;
|
|
157
|
+
this.logger.debug('SESAME: Initialized', {
|
|
158
|
+
category: 'E2EE',
|
|
159
|
+
data: {
|
|
160
|
+
operation: 'sesame-init',
|
|
161
|
+
userId: localUserId,
|
|
162
|
+
deviceId: localDeviceId,
|
|
163
|
+
},
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Add a device for a user with its identity key
|
|
168
|
+
*
|
|
169
|
+
* @throws {SesameError} if deviceId is outside valid range (1-5)
|
|
170
|
+
*/
|
|
171
|
+
async addDevice(userId, deviceId, identityKey, _prekeyBundle) {
|
|
172
|
+
// Validate device ID range (Signal Protocol limits to 1-5 devices per user)
|
|
173
|
+
if (deviceId < MIN_DEVICE_ID || deviceId > MAX_DEVICE_ID) {
|
|
174
|
+
throw new SesameError(`Device ID must be between ${MIN_DEVICE_ID} and ${MAX_DEVICE_ID}, got ${deviceId}`, 'INVALID_DEVICE_ID');
|
|
175
|
+
}
|
|
176
|
+
this.logger.debug('SESAME: Adding device', {
|
|
177
|
+
category: 'E2EE',
|
|
178
|
+
data: {
|
|
179
|
+
operation: 'sesame-add-device',
|
|
180
|
+
userId,
|
|
181
|
+
deviceId,
|
|
182
|
+
},
|
|
183
|
+
});
|
|
184
|
+
// Get or create user record
|
|
185
|
+
let userRecord = await this.storage.getUserRecord(userId);
|
|
186
|
+
if (!userRecord) {
|
|
187
|
+
userRecord = {
|
|
188
|
+
userId,
|
|
189
|
+
devices: new Map(),
|
|
190
|
+
createdAt: Date.now(),
|
|
191
|
+
updatedAt: Date.now(),
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
// Create device record
|
|
195
|
+
const deviceRecord = {
|
|
196
|
+
userId,
|
|
197
|
+
deviceId,
|
|
198
|
+
identityKey,
|
|
199
|
+
session: null, // SessionRecord, not SesameSessionRecord
|
|
200
|
+
createdAt: Date.now(),
|
|
201
|
+
updatedAt: Date.now(),
|
|
202
|
+
};
|
|
203
|
+
// Add device to user record
|
|
204
|
+
userRecord.devices.set(deviceId, deviceRecord);
|
|
205
|
+
userRecord.updatedAt = Date.now();
|
|
206
|
+
// Save device record
|
|
207
|
+
await this.storage.setDeviceRecord(userId, deviceId, deviceRecord);
|
|
208
|
+
// Save user record
|
|
209
|
+
await this.storage.setUserRecord(userId, userRecord);
|
|
210
|
+
// Emit device added event
|
|
211
|
+
this.events.onDeviceAdded?.(userId, deviceId);
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Remove a device from a user
|
|
215
|
+
*/
|
|
216
|
+
async removeDevice(userId, deviceId) {
|
|
217
|
+
this.logger.debug('SESAME: Removing device', {
|
|
218
|
+
category: 'E2EE',
|
|
219
|
+
data: {
|
|
220
|
+
operation: 'sesame-remove-device',
|
|
221
|
+
userId,
|
|
222
|
+
deviceId,
|
|
223
|
+
},
|
|
224
|
+
});
|
|
225
|
+
const userRecord = await this.storage.getUserRecord(userId);
|
|
226
|
+
if (!userRecord)
|
|
227
|
+
return;
|
|
228
|
+
// Remove session index entries for this device
|
|
229
|
+
this.removeDeviceFromSessionIndex(userId, deviceId);
|
|
230
|
+
// Remove device
|
|
231
|
+
userRecord.devices.delete(deviceId);
|
|
232
|
+
userRecord.updatedAt = Date.now();
|
|
233
|
+
// Delete device record from storage
|
|
234
|
+
await this.storage.deleteDeviceRecord(userId, deviceId);
|
|
235
|
+
// Update user record (or clean up if empty)
|
|
236
|
+
if (userRecord.devices.size > 0) {
|
|
237
|
+
await this.storage.setUserRecord(userId, userRecord);
|
|
238
|
+
}
|
|
239
|
+
// Emit device removed event
|
|
240
|
+
this.events.onDeviceRemoved?.(userId, deviceId);
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Clear pending verification flag for a device after user verifies safety numbers.
|
|
244
|
+
* This unblocks messaging to the device.
|
|
245
|
+
*/
|
|
246
|
+
async clearPendingVerification(userId, deviceId) {
|
|
247
|
+
const record = await this.storage.getDeviceRecord(userId, deviceId);
|
|
248
|
+
if (record && record.pendingVerification) {
|
|
249
|
+
record.pendingVerification = false;
|
|
250
|
+
await this.storage.setDeviceRecord(userId, deviceId, record);
|
|
251
|
+
this.logger.info('SESAME: Cleared pending verification', {
|
|
252
|
+
category: 'E2EE',
|
|
253
|
+
data: {
|
|
254
|
+
operation: 'sesame-clear-verification',
|
|
255
|
+
userId,
|
|
256
|
+
deviceId,
|
|
257
|
+
},
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Get device record for a specific user and device
|
|
263
|
+
*/
|
|
264
|
+
async getDeviceRecord(userId, deviceId) {
|
|
265
|
+
return await this.storage.getDeviceRecord(userId, deviceId);
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Get user record with all devices
|
|
269
|
+
*/
|
|
270
|
+
async getUserRecord(userId) {
|
|
271
|
+
return await this.storage.getUserRecord(userId);
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Get the full session record for a device.
|
|
275
|
+
* Returns the SessionRecord which includes currentSession and archivedSessions.
|
|
276
|
+
*/
|
|
277
|
+
async getSession(userId, deviceId) {
|
|
278
|
+
const deviceRecord = await this.storage.getDeviceRecord(userId, deviceId);
|
|
279
|
+
return deviceRecord?.session ?? null;
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Get the active session state for a device.
|
|
283
|
+
* Returns SessionRecord.currentSession.
|
|
284
|
+
*/
|
|
285
|
+
async getActiveSession(userId, deviceId) {
|
|
286
|
+
const sessionRecord = await this.getSession(userId, deviceId);
|
|
287
|
+
return sessionRecord?.currentSession ?? null;
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Set the session record for a device (internal helper).
|
|
291
|
+
* Uses SessionRecord.archiveCurrent() to move the previous active session to archived.
|
|
292
|
+
*/
|
|
293
|
+
async setSession(userId, deviceId, sessionRecord) {
|
|
294
|
+
const deviceRecord = await this.storage.getDeviceRecord(userId, deviceId);
|
|
295
|
+
if (!deviceRecord) {
|
|
296
|
+
throw new SesameDeviceNotFoundError(`Device not found: ${userId}/${deviceId}`);
|
|
297
|
+
}
|
|
298
|
+
// Clear old index entries and add new ones
|
|
299
|
+
this.removeDeviceFromSessionIndex(userId, deviceId);
|
|
300
|
+
this.indexSessionRecord(userId, deviceId, sessionRecord);
|
|
301
|
+
// Update device record with new session
|
|
302
|
+
deviceRecord.session = sessionRecord;
|
|
303
|
+
deviceRecord.updatedAt = Date.now();
|
|
304
|
+
await this.storage.setDeviceRecord(userId, deviceId, deviceRecord);
|
|
305
|
+
const sessionId = sessionRecord.currentSession?.remoteAddress
|
|
306
|
+
? ProtocolAddress.toString(sessionRecord.currentSession.remoteAddress)
|
|
307
|
+
: 'none';
|
|
308
|
+
this.logger.debug('SESAME: Session updated', {
|
|
309
|
+
category: 'E2EE',
|
|
310
|
+
data: {
|
|
311
|
+
operation: 'sesame-set-session',
|
|
312
|
+
userId,
|
|
313
|
+
deviceId,
|
|
314
|
+
sessionId,
|
|
315
|
+
archivedCount: Object.keys(sessionRecord.archivedSessions).length,
|
|
316
|
+
},
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* Register a newly established Double Ratchet session with SESAME.
|
|
321
|
+
*
|
|
322
|
+
* Creates a SessionRecord with SESAME metadata and sets it as the device's session.
|
|
323
|
+
* Any existing session is archived in SessionRecord.archivedSessions.
|
|
324
|
+
*
|
|
325
|
+
* This bridges the Double Ratchet layer with the SESAME multi-device layer,
|
|
326
|
+
* ensuring sessions established via SignalProtocolClient.establishSession() are
|
|
327
|
+
* automatically tracked for multi-device messaging.
|
|
328
|
+
*
|
|
329
|
+
* @param userId - Remote user's ID
|
|
330
|
+
* @param deviceId - Remote device's ID
|
|
331
|
+
* @param sessionState - The Double Ratchet session state
|
|
332
|
+
* @param isInitiator - Whether we initiated the session (true) or responded (false)
|
|
333
|
+
*/
|
|
334
|
+
async registerSession(userId, deviceId, sessionState, isInitiator) {
|
|
335
|
+
const address = ProtocolAddress.create(userId, deviceId);
|
|
336
|
+
const sessionId = ProtocolAddress.toString(address);
|
|
337
|
+
// Ensure device record exists
|
|
338
|
+
let deviceRecord = await this.storage.getDeviceRecord(userId, deviceId);
|
|
339
|
+
if (!deviceRecord) {
|
|
340
|
+
// Auto-create device record if it doesn't exist
|
|
341
|
+
// Use empty identity key - will be updated when we have the actual key
|
|
342
|
+
await this.addDevice(userId, deviceId, new Uint8Array(32));
|
|
343
|
+
deviceRecord = await this.storage.getDeviceRecord(userId, deviceId);
|
|
344
|
+
}
|
|
345
|
+
// Create or update session record using SessionResolver
|
|
346
|
+
const sessionRecord = SessionResolver.insertSession(deviceRecord?.session ?? null, sessionState, isInitiator, this.config.maxInactiveSessions);
|
|
347
|
+
// Set the session record
|
|
348
|
+
await this.setSession(userId, deviceId, sessionRecord);
|
|
349
|
+
this.logger.debug('SESAME: Session registered', {
|
|
350
|
+
category: 'E2EE',
|
|
351
|
+
data: {
|
|
352
|
+
operation: 'sesame-register-session',
|
|
353
|
+
userId,
|
|
354
|
+
deviceId,
|
|
355
|
+
sessionId,
|
|
356
|
+
isInitiator,
|
|
357
|
+
},
|
|
358
|
+
});
|
|
359
|
+
// Emit session established event (reuse address from above)
|
|
360
|
+
this.events.onSessionEstablished?.(address);
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* Send a message to a specific device
|
|
364
|
+
* Implements SESAME 3-phase sending process
|
|
365
|
+
*
|
|
366
|
+
* SESAME 3-Phase Sending (from specification):
|
|
367
|
+
* Phase 1: Identify devices with non-stale active sessions
|
|
368
|
+
* Phase 2: Encrypt message for each device using Double Ratchet
|
|
369
|
+
* Phase 3: Validate device list is current before sending
|
|
370
|
+
*/
|
|
371
|
+
async sendMessage(recipientUserId, recipientDeviceId, plaintext, options) {
|
|
372
|
+
if (!this.localUserId || !this.localDeviceId) {
|
|
373
|
+
throw new SesameError('SesameManager not initialized', 'NOT_INITIALIZED');
|
|
374
|
+
}
|
|
375
|
+
if (!this.protocol) {
|
|
376
|
+
throw new SesameError('Signal Protocol manager not set. Call setProtocolManager() first.', 'PROTOCOL_NOT_SET');
|
|
377
|
+
}
|
|
378
|
+
// Check if device requires identity verification before messaging
|
|
379
|
+
const deviceRecord = await this.getDeviceRecord(recipientUserId, recipientDeviceId);
|
|
380
|
+
if (deviceRecord?.pendingVerification) {
|
|
381
|
+
throw new SesameError(`Cannot send to ${recipientUserId}:${recipientDeviceId} - identity key changed, verification required`, 'IDENTITY_KEY_PENDING_VERIFICATION');
|
|
382
|
+
}
|
|
383
|
+
this.logger.debug('SESAME: Sending message', {
|
|
384
|
+
category: 'E2EE',
|
|
385
|
+
data: {
|
|
386
|
+
operation: 'sesame-send',
|
|
387
|
+
recipientUserId,
|
|
388
|
+
recipientDeviceId,
|
|
389
|
+
},
|
|
390
|
+
});
|
|
391
|
+
// Phase 1: Check session state and get/create session
|
|
392
|
+
const activeSession = await this.getActiveSession(recipientUserId, recipientDeviceId);
|
|
393
|
+
// If no active session exists, we need to establish one
|
|
394
|
+
if (!activeSession) {
|
|
395
|
+
throw new NoActiveSessionError(recipientUserId, recipientDeviceId);
|
|
396
|
+
}
|
|
397
|
+
// Check if session is too old to send on
|
|
398
|
+
const sessionId = ProtocolAddress.toString(activeSession.remoteAddress);
|
|
399
|
+
const canSend = await this.canSendOnSession(sessionId);
|
|
400
|
+
if (!canSend) {
|
|
401
|
+
throw new SesameError(`Session ${sessionId} is too old to send (age > MAXSEND)`, 'SESSION_TOO_OLD');
|
|
402
|
+
}
|
|
403
|
+
// Phase 2: Encrypt message using Double Ratchet
|
|
404
|
+
const recipientAddress = ProtocolAddress.create(recipientUserId, recipientDeviceId);
|
|
405
|
+
try {
|
|
406
|
+
// Encrypt the plaintext using the Signal Protocol
|
|
407
|
+
const plaintextString = new TextDecoder().decode(plaintext);
|
|
408
|
+
const ciphertext = await this.protocol.encrypt(recipientAddress, plaintextString);
|
|
409
|
+
// Phase 3: Validate device list version (SESAME spec §3.3)
|
|
410
|
+
// MUST happen BEFORE persisting session metadata.
|
|
411
|
+
// Per §3.3: "If any error occurs in encrypting to a particular user,
|
|
412
|
+
// then the sending device shall discard any changes to the relevant UserRecord."
|
|
413
|
+
const localDeviceListVersion = options?.localDeviceListVersion;
|
|
414
|
+
if (localDeviceListVersion !== undefined) {
|
|
415
|
+
const userRecord = await this.getUserRecord(recipientUserId);
|
|
416
|
+
const serverVersion = userRecord?.deviceListVersion ?? 0;
|
|
417
|
+
if (localDeviceListVersion < serverVersion) {
|
|
418
|
+
throw new StaleDeviceListError(recipientUserId, localDeviceListVersion, serverVersion);
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
// Update session lastSentAt timestamp via SessionRecord
|
|
422
|
+
// Placed AFTER Phase 3 validation so metadata is not persisted if validation fails
|
|
423
|
+
const deviceRecord = await this.getDeviceRecord(recipientUserId, recipientDeviceId);
|
|
424
|
+
if (deviceRecord?.session) {
|
|
425
|
+
const updatedSession = updateSessionRecordAfterSend(deviceRecord.session);
|
|
426
|
+
deviceRecord.session = updatedSession;
|
|
427
|
+
deviceRecord.updatedAt = Date.now();
|
|
428
|
+
await this.storage.setDeviceRecord(recipientUserId, recipientDeviceId, deviceRecord);
|
|
429
|
+
}
|
|
430
|
+
// Convert Ciphertext to Uint8Array for SesameMessage
|
|
431
|
+
const ciphertextBytes = this.serializeCiphertext(ciphertext);
|
|
432
|
+
// Client timestamp for envelope alignment (application send-pipeline ordering)
|
|
433
|
+
// Threaded explicitly via SesameSendOptions — no plaintext parsing needed
|
|
434
|
+
const clientTimestamp = options?.clientTimestamp ?? Date.now();
|
|
435
|
+
// Store MessageRecord for retry request support (SESAME spec §6.2)
|
|
436
|
+
// "Each MessageRecord stores the plaintext of the encrypted message"
|
|
437
|
+
if (this.messageRecordStore) {
|
|
438
|
+
try {
|
|
439
|
+
await this.messageRecordStore.storeMessageRecord({
|
|
440
|
+
sessionId,
|
|
441
|
+
timestamp: clientTimestamp,
|
|
442
|
+
recipientUserId,
|
|
443
|
+
recipientDeviceId,
|
|
444
|
+
plaintext: plaintextString,
|
|
445
|
+
createdAt: clientTimestamp,
|
|
446
|
+
// store sender's
|
|
447
|
+
// current ratchet key (DHs) for retry session matching. Detects intra-session
|
|
448
|
+
// ratchet advancement, not just cross-session changes.
|
|
449
|
+
sessionStateId: activeSession.DHs?.publicKey ?? '',
|
|
450
|
+
});
|
|
451
|
+
}
|
|
452
|
+
catch (storeError) {
|
|
453
|
+
// CRITICAL: If this fails, retry requests won't work after reinstall
|
|
454
|
+
// Upgraded from warn to error to track failures in Sentry
|
|
455
|
+
this.logger.error('SESAME: Failed to store MessageRecord - retry flow may fail', {
|
|
456
|
+
category: 'E2EE',
|
|
457
|
+
data: {
|
|
458
|
+
sessionId,
|
|
459
|
+
timestamp: clientTimestamp,
|
|
460
|
+
recipientUserId,
|
|
461
|
+
recipientDeviceId,
|
|
462
|
+
error: getErrorMessage(storeError),
|
|
463
|
+
errorStack: storeError instanceof Error ? storeError.stack?.substring(0, 500) : undefined,
|
|
464
|
+
},
|
|
465
|
+
});
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
this.logger.debug('SESAME: Message encrypted', {
|
|
469
|
+
category: 'E2EE',
|
|
470
|
+
data: {
|
|
471
|
+
operation: 'sesame-send',
|
|
472
|
+
recipientUserId,
|
|
473
|
+
recipientDeviceId,
|
|
474
|
+
sessionId,
|
|
475
|
+
timestamp: clientTimestamp,
|
|
476
|
+
},
|
|
477
|
+
});
|
|
478
|
+
// Return SESAME message
|
|
479
|
+
// Note: Message ordering is handled by Double Ratchet's N/PN counters (spec Section 2.6)
|
|
480
|
+
return {
|
|
481
|
+
senderUserId: this.localUserId,
|
|
482
|
+
senderDeviceId: this.localDeviceId,
|
|
483
|
+
recipientUserId,
|
|
484
|
+
recipientDeviceId,
|
|
485
|
+
sessionId,
|
|
486
|
+
ciphertext: ciphertextBytes,
|
|
487
|
+
isInitiating: isPreKeyMessage(ciphertext),
|
|
488
|
+
initHeader: null,
|
|
489
|
+
// Client timestamp for message identification
|
|
490
|
+
// Same value stored in MessageRecord for retry request matching
|
|
491
|
+
timestamp: clientTimestamp,
|
|
492
|
+
};
|
|
493
|
+
}
|
|
494
|
+
catch (error) {
|
|
495
|
+
// Re-throw SesameError subclasses (StaleDeviceListError, etc.) without wrapping
|
|
496
|
+
// so callers can distinguish Phase 3 validation failures from encryption errors
|
|
497
|
+
if (error instanceof SesameError) {
|
|
498
|
+
throw error;
|
|
499
|
+
}
|
|
500
|
+
throw new SesameError(`Failed to encrypt message: ${getErrorMessage(error)}`, 'ENCRYPTION_FAILED');
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
/**
|
|
504
|
+
* Serialize a Ciphertext object to Uint8Array
|
|
505
|
+
*/
|
|
506
|
+
serializeCiphertext(ciphertext) {
|
|
507
|
+
// Ciphertext is a branded base64 string, encode it directly
|
|
508
|
+
return new TextEncoder().encode(ciphertext);
|
|
509
|
+
}
|
|
510
|
+
/**
|
|
511
|
+
* Deserialize Uint8Array back to Ciphertext object
|
|
512
|
+
*/
|
|
513
|
+
deserializeCiphertext(bytes) {
|
|
514
|
+
const text = new TextDecoder().decode(bytes);
|
|
515
|
+
return text;
|
|
516
|
+
}
|
|
517
|
+
/**
|
|
518
|
+
* Send an encrypted message to all devices of a user
|
|
519
|
+
* Implements the 3-phase sending process from SESAME spec:
|
|
520
|
+
* Phase 1: Identify devices with non-stale active sessions
|
|
521
|
+
* Phase 2: Encrypt message for each device using Double Ratchet
|
|
522
|
+
* Phase 3: Validate device list is current before sending
|
|
523
|
+
*
|
|
524
|
+
* Returns an OutgoingMessageBatch that separates:
|
|
525
|
+
* - deviceMessages: Messages for recipient's devices
|
|
526
|
+
* - syncMessages: Messages for our own other devices (multi-device sync)
|
|
527
|
+
*
|
|
528
|
+
* Per SESAME spec §3.3: If Phase 3 device list validation fails with
|
|
529
|
+
* StaleDeviceListError, the device list is refetched and the send is retried
|
|
530
|
+
* (up to MAX_SEND_RETRIES attempts). The UserRecord is marked stale per §3.3
|
|
531
|
+
* to trigger a fresh fetch on next access.
|
|
532
|
+
*
|
|
533
|
+
* @param recipientUserId - Target user ID
|
|
534
|
+
* @param plaintext - Message to encrypt
|
|
535
|
+
* @param options - Optional SESAME send controls, including stale-device-list retry hooks
|
|
536
|
+
* @returns OutgoingMessageBatch with separated device and sync messages
|
|
537
|
+
*
|
|
538
|
+
* @see https://signal.org/docs/specifications/sesame/
|
|
539
|
+
*/
|
|
540
|
+
async send(recipientUserId, plaintext, options) {
|
|
541
|
+
if (!this.localUserId || !this.localDeviceId) {
|
|
542
|
+
throw new SesameError('SesameManager not initialized', 'NOT_INITIALIZED');
|
|
543
|
+
}
|
|
544
|
+
if (!this.protocol) {
|
|
545
|
+
throw new SesameError('Signal Protocol manager not set. Call setProtocolManager() first.', 'PROTOCOL_NOT_SET');
|
|
546
|
+
}
|
|
547
|
+
// M14: Retry loop for stale device list (SESAME spec §3.3 step 8 + §6.5)
|
|
548
|
+
// "To avoid excessive looping in case of a malicious or buggy server,
|
|
549
|
+
// devices should impose some limit on the number of times they're willing
|
|
550
|
+
// to repeat the message sending loop for a recipient user."
|
|
551
|
+
let currentDeviceListVersion = options?.localDeviceListVersion;
|
|
552
|
+
const fetchDeviceList = options?.fetchDeviceList;
|
|
553
|
+
for (let attempt = 0; attempt < MAX_SEND_RETRIES; attempt++) {
|
|
554
|
+
try {
|
|
555
|
+
return await this.sendAttempt(recipientUserId, plaintext, {
|
|
556
|
+
...options,
|
|
557
|
+
localDeviceListVersion: currentDeviceListVersion,
|
|
558
|
+
});
|
|
559
|
+
}
|
|
560
|
+
catch (error) {
|
|
561
|
+
// M18: Re-throw StaleDeviceListError specifically for retry logic
|
|
562
|
+
// M15: Mark the UserRecord as stale when StaleDeviceListError occurs
|
|
563
|
+
if (error instanceof StaleDeviceListError) {
|
|
564
|
+
// Mark the UserRecord as stale per SESAME spec §3.3
|
|
565
|
+
await this.markUserRecordStale(recipientUserId);
|
|
566
|
+
// If this is the last attempt, throw the error
|
|
567
|
+
if (attempt >= MAX_SEND_RETRIES - 1) {
|
|
568
|
+
this.logger.error('SESAME: Max send retries exceeded for stale device list', {
|
|
569
|
+
category: 'E2EE',
|
|
570
|
+
data: {
|
|
571
|
+
operation: 'sesame-send-retry',
|
|
572
|
+
recipientUserId,
|
|
573
|
+
attempts: attempt + 1,
|
|
574
|
+
maxRetries: MAX_SEND_RETRIES,
|
|
575
|
+
},
|
|
576
|
+
});
|
|
577
|
+
throw error;
|
|
578
|
+
}
|
|
579
|
+
// M14: Refetch device list and retry
|
|
580
|
+
if (fetchDeviceList) {
|
|
581
|
+
try {
|
|
582
|
+
const freshDeviceList = await fetchDeviceList(recipientUserId);
|
|
583
|
+
await this.syncDeviceList(freshDeviceList);
|
|
584
|
+
currentDeviceListVersion = freshDeviceList.version;
|
|
585
|
+
this.logger.info('SESAME: Retrying send after device list refresh', {
|
|
586
|
+
category: 'E2EE',
|
|
587
|
+
data: {
|
|
588
|
+
operation: 'sesame-send-retry',
|
|
589
|
+
recipientUserId,
|
|
590
|
+
attempt: attempt + 1,
|
|
591
|
+
newVersion: freshDeviceList.version,
|
|
592
|
+
},
|
|
593
|
+
});
|
|
594
|
+
continue; // Retry with fresh device list
|
|
595
|
+
}
|
|
596
|
+
catch (fetchError) {
|
|
597
|
+
this.logger.error('SESAME: Failed to refetch device list during retry', {
|
|
598
|
+
category: 'E2EE',
|
|
599
|
+
data: {
|
|
600
|
+
operation: 'sesame-send-retry',
|
|
601
|
+
recipientUserId,
|
|
602
|
+
error: getErrorMessage(fetchError),
|
|
603
|
+
},
|
|
604
|
+
});
|
|
605
|
+
throw error; // Re-throw the original StaleDeviceListError
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
else {
|
|
609
|
+
// No fetchDeviceList callback provided - throw immediately
|
|
610
|
+
// Caller is responsible for handling the stale device list
|
|
611
|
+
throw error;
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
// Non-StaleDeviceListError: throw immediately without retry
|
|
615
|
+
throw error;
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
// This should be unreachable due to the loop structure, but TypeScript requires it
|
|
619
|
+
throw new SesameError('Send retry loop exhausted', 'SEND_RETRY_EXHAUSTED');
|
|
620
|
+
}
|
|
621
|
+
async sendToLocalOtherDevices(plaintext, options) {
|
|
622
|
+
if (!this.localUserId || !this.localDeviceId) {
|
|
623
|
+
throw new SesameError('SesameManager not initialized', 'NOT_INITIALIZED');
|
|
624
|
+
}
|
|
625
|
+
const localUserRecord = await this.getUserRecord(this.localUserId);
|
|
626
|
+
if (!localUserRecord) {
|
|
627
|
+
return [];
|
|
628
|
+
}
|
|
629
|
+
const syncMessages = [];
|
|
630
|
+
for (const [deviceId, deviceRecord] of localUserRecord.devices.entries()) {
|
|
631
|
+
if (deviceId === this.localDeviceId)
|
|
632
|
+
continue;
|
|
633
|
+
try {
|
|
634
|
+
const activeSession = deviceRecord.session?.currentSession;
|
|
635
|
+
if (!activeSession)
|
|
636
|
+
continue;
|
|
637
|
+
const sessionId = ProtocolAddress.toString(activeSession.remoteAddress);
|
|
638
|
+
const canSend = await this.canSendOnSession(sessionId);
|
|
639
|
+
if (!canSend)
|
|
640
|
+
continue;
|
|
641
|
+
const syncMessage = await this.sendMessage(this.localUserId, deviceId, plaintext, options);
|
|
642
|
+
syncMessages.push(syncMessage);
|
|
643
|
+
}
|
|
644
|
+
catch {
|
|
645
|
+
this.logger.debug('SESAME: Sync message failed for device', {
|
|
646
|
+
category: 'E2EE',
|
|
647
|
+
data: {
|
|
648
|
+
operation: 'sesame-send-sync',
|
|
649
|
+
deviceId,
|
|
650
|
+
},
|
|
651
|
+
});
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
return syncMessages;
|
|
655
|
+
}
|
|
656
|
+
/**
|
|
657
|
+
* Single attempt to send an encrypted message to all devices of a user.
|
|
658
|
+
* Extracted from send() to support the retry loop for stale device lists.
|
|
659
|
+
*
|
|
660
|
+
* @param recipientUserId - Target user ID
|
|
661
|
+
* @param plaintext - Message to encrypt
|
|
662
|
+
* @param options - Optional SESAME send controls for a single send attempt
|
|
663
|
+
* @returns OutgoingMessageBatch with separated device and sync messages
|
|
664
|
+
*/
|
|
665
|
+
async sendAttempt(recipientUserId, plaintext, options) {
|
|
666
|
+
const includeSyncMessages = options?.includeSyncMessages ?? true;
|
|
667
|
+
// M15: Check if UserRecord is marked stale and clear it for this attempt
|
|
668
|
+
// Per SESAME spec §3.3: stale records trigger a fresh device list fetch
|
|
669
|
+
const userRecord = await this.getUserRecord(recipientUserId);
|
|
670
|
+
if (!userRecord) {
|
|
671
|
+
throw new SesameError(`No user record found for ${recipientUserId}`, 'USER_NOT_FOUND');
|
|
672
|
+
}
|
|
673
|
+
if (userRecord.stale) {
|
|
674
|
+
// Clear stale flag since we're about to use this record
|
|
675
|
+
// (caller should have refreshed the device list before retrying)
|
|
676
|
+
userRecord.stale = false;
|
|
677
|
+
userRecord.updatedAt = Date.now();
|
|
678
|
+
await this.storage.setUserRecord(recipientUserId, userRecord);
|
|
679
|
+
}
|
|
680
|
+
if (userRecord.devices.size === 0) {
|
|
681
|
+
throw new SesameError(`User ${recipientUserId} has no devices`, 'NO_DEVICES');
|
|
682
|
+
}
|
|
683
|
+
const timestamp = Date.now();
|
|
684
|
+
const deviceMessages = [];
|
|
685
|
+
const syncMessages = [];
|
|
686
|
+
const failures = [];
|
|
687
|
+
let attemptedDevices = 0;
|
|
688
|
+
this.logger.debug('SESAME: Sending to all devices', {
|
|
689
|
+
category: 'E2EE',
|
|
690
|
+
data: {
|
|
691
|
+
operation: 'sesame-send-user',
|
|
692
|
+
recipientUserId,
|
|
693
|
+
deviceCount: userRecord.devices.size,
|
|
694
|
+
includeSyncMessages,
|
|
695
|
+
},
|
|
696
|
+
});
|
|
697
|
+
// Phase 1 & 2: Encrypt message for each recipient device
|
|
698
|
+
for (const [deviceId, deviceRecord] of userRecord.devices.entries()) {
|
|
699
|
+
attemptedDevices++;
|
|
700
|
+
try {
|
|
701
|
+
// Check if device has an active session
|
|
702
|
+
const activeSession = deviceRecord.session?.currentSession;
|
|
703
|
+
if (!activeSession) {
|
|
704
|
+
failures.push({
|
|
705
|
+
deviceId,
|
|
706
|
+
error: new NoActiveSessionError(recipientUserId, deviceId),
|
|
707
|
+
});
|
|
708
|
+
continue;
|
|
709
|
+
}
|
|
710
|
+
// Check if session is too old
|
|
711
|
+
const sessionId = ProtocolAddress.toString(activeSession.remoteAddress);
|
|
712
|
+
const canSend = await this.canSendOnSession(sessionId);
|
|
713
|
+
if (!canSend) {
|
|
714
|
+
failures.push({
|
|
715
|
+
deviceId,
|
|
716
|
+
error: new SesameError(`Session for device ${deviceId} is too old (age > MAXSEND)`, 'SESSION_TOO_OLD'),
|
|
717
|
+
});
|
|
718
|
+
continue;
|
|
719
|
+
}
|
|
720
|
+
// Encrypt message for this device (Phase 3 validation happens inside)
|
|
721
|
+
const message = await this.sendMessage(recipientUserId, deviceId, plaintext, options);
|
|
722
|
+
deviceMessages.push(message);
|
|
723
|
+
}
|
|
724
|
+
catch (error) {
|
|
725
|
+
// M18: Re-throw StaleDeviceListError without wrapping so the retry
|
|
726
|
+
// loop in send() can catch it and refetch the device list.
|
|
727
|
+
// Per SESAME spec §3.3: "If any error occurs in encrypting to a
|
|
728
|
+
// particular user, then the sending device shall discard any changes
|
|
729
|
+
// to the relevant UserRecord."
|
|
730
|
+
if (error instanceof StaleDeviceListError) {
|
|
731
|
+
throw error;
|
|
732
|
+
}
|
|
733
|
+
failures.push({
|
|
734
|
+
deviceId,
|
|
735
|
+
error: error instanceof Error ? error : new Error('Unknown error'),
|
|
736
|
+
});
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
// If all recipient devices failed, throw error
|
|
740
|
+
if (deviceMessages.length === 0 && failures.length > 0) {
|
|
741
|
+
throw new SesameError(`Failed to send message to all ${failures.length} devices: ${failures.map((f) => `${f.deviceId}: ${f.error.message}`).join(', ')}`, 'ALL_DEVICES_FAILED');
|
|
742
|
+
}
|
|
743
|
+
// Encrypt sync messages for our own other devices (multi-device sync)
|
|
744
|
+
if (includeSyncMessages) {
|
|
745
|
+
if (this.localUserId) {
|
|
746
|
+
const localUserRecord = await this.getUserRecord(this.localUserId);
|
|
747
|
+
if (localUserRecord) {
|
|
748
|
+
attemptedDevices += Array.from(localUserRecord.devices.keys()).filter((deviceId) => deviceId !== this.localDeviceId).length;
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
const syncPayload = options?.syncPlaintext ?? plaintext;
|
|
752
|
+
const localSyncMessages = await this.sendToLocalOtherDevices(syncPayload, options);
|
|
753
|
+
syncMessages.push(...localSyncMessages);
|
|
754
|
+
}
|
|
755
|
+
// Log partial failures
|
|
756
|
+
if (failures.length > 0) {
|
|
757
|
+
this.logger.warn('SESAME: Partial send failure', {
|
|
758
|
+
category: 'E2EE',
|
|
759
|
+
data: {
|
|
760
|
+
operation: 'sesame-send-user',
|
|
761
|
+
recipientUserId,
|
|
762
|
+
successCount: deviceMessages.length,
|
|
763
|
+
failureCount: failures.length,
|
|
764
|
+
failedDevices: failures.map((f) => f.deviceId),
|
|
765
|
+
},
|
|
766
|
+
});
|
|
767
|
+
}
|
|
768
|
+
return {
|
|
769
|
+
deviceMessages,
|
|
770
|
+
syncMessages,
|
|
771
|
+
recipientUserId,
|
|
772
|
+
timestamp,
|
|
773
|
+
attemptedDevices,
|
|
774
|
+
failedDevices: failures.length,
|
|
775
|
+
};
|
|
776
|
+
}
|
|
777
|
+
/**
|
|
778
|
+
* Receive and decrypt a message
|
|
779
|
+
* Implements session convergence through receive-activated switching
|
|
780
|
+
*
|
|
781
|
+
* SESAME Session Convergence (from specification):
|
|
782
|
+
* - Try to decrypt with active session first
|
|
783
|
+
* - If that fails, try inactive sessions
|
|
784
|
+
* - If decryption succeeds on inactive session, activate it
|
|
785
|
+
* - This allows devices to automatically converge on matching session pairs
|
|
786
|
+
*
|
|
787
|
+
* @see https://signal.org/docs/specifications/sesame/
|
|
788
|
+
*/
|
|
789
|
+
async receive(message) {
|
|
790
|
+
if (!this.localUserId || !this.localDeviceId) {
|
|
791
|
+
throw new SesameError('SesameManager not initialized', 'NOT_INITIALIZED');
|
|
792
|
+
}
|
|
793
|
+
if (!this.protocol) {
|
|
794
|
+
throw new SesameError('Signal Protocol manager not set. Call setProtocolManager() first.', 'PROTOCOL_NOT_SET');
|
|
795
|
+
}
|
|
796
|
+
// 1. Validate message is addressed to this device
|
|
797
|
+
if (message.recipientUserId !== this.localUserId) {
|
|
798
|
+
throw new SesameError(`Message not addressed to this user (expected ${this.localUserId}, got ${message.recipientUserId})`, 'WRONG_RECIPIENT_USER');
|
|
799
|
+
}
|
|
800
|
+
if (message.recipientDeviceId !== this.localDeviceId) {
|
|
801
|
+
throw new SesameError(`Message not addressed to this device (expected ${this.localDeviceId}, got ${message.recipientDeviceId})`, 'WRONG_RECIPIENT_DEVICE');
|
|
802
|
+
}
|
|
803
|
+
this.logger.debug('SESAME: Receiving message', {
|
|
804
|
+
category: 'E2EE',
|
|
805
|
+
data: {
|
|
806
|
+
operation: 'sesame-receive',
|
|
807
|
+
senderUserId: message.senderUserId,
|
|
808
|
+
senderDeviceId: message.senderDeviceId,
|
|
809
|
+
},
|
|
810
|
+
});
|
|
811
|
+
// Deserialize ciphertext
|
|
812
|
+
const ciphertext = this.deserializeCiphertext(message.ciphertext);
|
|
813
|
+
const senderAddress = ProtocolAddress.create(message.senderUserId, message.senderDeviceId);
|
|
814
|
+
// 3. Get session record and all decryption candidates
|
|
815
|
+
const sessionRecord = await this.getSession(message.senderUserId, message.senderDeviceId);
|
|
816
|
+
const candidates = SessionResolver.findDecryptingSessions(sessionRecord);
|
|
817
|
+
// If no existing sessions, try protocol.decrypt() anyway - it handles PreKeyMessage
|
|
818
|
+
// session establishment for first messages from new senders
|
|
819
|
+
if (candidates.length === 0) {
|
|
820
|
+
try {
|
|
821
|
+
const result = await this.handlePreKeyMessage(message, senderAddress, ciphertext);
|
|
822
|
+
// TRANSACTIONAL: Only persist after successful decrypt
|
|
823
|
+
// This prevents session state corruption if decryption fails
|
|
824
|
+
if (result.pendingUserRecord) {
|
|
825
|
+
await this.storage.setUserRecord(message.senderUserId, result.pendingUserRecord);
|
|
826
|
+
}
|
|
827
|
+
// Update session index for the newly established session
|
|
828
|
+
this.removeDeviceFromSessionIndex(message.senderUserId, message.senderDeviceId);
|
|
829
|
+
this.indexSessionRecord(message.senderUserId, message.senderDeviceId, result.pendingDeviceRecord.session);
|
|
830
|
+
await this.storage.setDeviceRecord(message.senderUserId, message.senderDeviceId, result.pendingDeviceRecord);
|
|
831
|
+
this.logger.debug('SESAME: Session established from PreKeyMessage (persisted)', {
|
|
832
|
+
category: 'E2EE',
|
|
833
|
+
data: {
|
|
834
|
+
operation: 'sesame-receive',
|
|
835
|
+
senderUserId: message.senderUserId,
|
|
836
|
+
senderDeviceId: message.senderDeviceId,
|
|
837
|
+
},
|
|
838
|
+
});
|
|
839
|
+
return result.plaintext;
|
|
840
|
+
}
|
|
841
|
+
catch (error) {
|
|
842
|
+
// TRANSACTIONAL: No session state was persisted, so no cleanup needed
|
|
843
|
+
this.logger.debug('SESAME: PreKeyMessage handling failed, no sessions available', {
|
|
844
|
+
category: 'E2EE',
|
|
845
|
+
data: {
|
|
846
|
+
operation: 'sesame-receive',
|
|
847
|
+
senderUserId: message.senderUserId,
|
|
848
|
+
senderDeviceId: message.senderDeviceId,
|
|
849
|
+
error: error.message,
|
|
850
|
+
},
|
|
851
|
+
});
|
|
852
|
+
// Preserve EncryptionError for client-layer handling (e.g., PREKEY_NOT_FOUND triggers key rotation)
|
|
853
|
+
if (error instanceof EncryptionError) {
|
|
854
|
+
throw error;
|
|
855
|
+
}
|
|
856
|
+
throw new DecryptionFailedError(message.sessionId, 0);
|
|
857
|
+
}
|
|
858
|
+
}
|
|
859
|
+
// 4. Try each session in order (active first, then archived)
|
|
860
|
+
let decryptedPlaintext = null;
|
|
861
|
+
let successfulCandidate = null;
|
|
862
|
+
for (const candidate of candidates) {
|
|
863
|
+
try {
|
|
864
|
+
const plaintextString = await this.protocol.decrypt(senderAddress, ciphertext);
|
|
865
|
+
decryptedPlaintext = new TextEncoder().encode(plaintextString);
|
|
866
|
+
successfulCandidate = candidate;
|
|
867
|
+
break;
|
|
868
|
+
}
|
|
869
|
+
catch {
|
|
870
|
+
// This session failed - try next one
|
|
871
|
+
continue;
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
// 5. Handle successful decryption
|
|
875
|
+
if (decryptedPlaintext && successfulCandidate && sessionRecord) {
|
|
876
|
+
// CRITICAL: Sync session from protocol layer to get updated state (Nr, chain keys, etc.)
|
|
877
|
+
// The protocol.decrypt() call above mutates and saves the session to KeyStorage.
|
|
878
|
+
// We MUST read it back to avoid overwriting with stale data from sessionRecord.
|
|
879
|
+
// The protocol layer also handles archived session promotion internally.
|
|
880
|
+
const sessionFromProtocol = await this.protocol.getSession(senderAddress);
|
|
881
|
+
// Use the protocol's updated session (includes updated Nr, chain keys, and any promotion)
|
|
882
|
+
// Fall back to original sessionRecord only if sync fails (should not happen)
|
|
883
|
+
const updatedSession = sessionFromProtocol || sessionRecord;
|
|
884
|
+
// If we decrypted on an archived session, emit convergence event for observability
|
|
885
|
+
// Note: The actual promotion is already handled by the protocol layer (cipher.ts)
|
|
886
|
+
if (!successfulCandidate.isActive && successfulCandidate.baseKey) {
|
|
887
|
+
this.logger.debug('SESAME: Session convergence - archived session used', {
|
|
888
|
+
category: 'E2EE',
|
|
889
|
+
data: {
|
|
890
|
+
operation: 'sesame-receive',
|
|
891
|
+
senderUserId: message.senderUserId,
|
|
892
|
+
senderDeviceId: message.senderDeviceId,
|
|
893
|
+
baseKey: successfulCandidate.baseKey,
|
|
894
|
+
},
|
|
895
|
+
});
|
|
896
|
+
// Emit session convergence event
|
|
897
|
+
this.events.onSessionConverged?.(senderAddress, successfulCandidate.baseKey);
|
|
898
|
+
}
|
|
899
|
+
else {
|
|
900
|
+
this.logger.debug('SESAME: Message decrypted with active session', {
|
|
901
|
+
category: 'E2EE',
|
|
902
|
+
data: {
|
|
903
|
+
operation: 'sesame-receive',
|
|
904
|
+
senderUserId: message.senderUserId,
|
|
905
|
+
senderDeviceId: message.senderDeviceId,
|
|
906
|
+
},
|
|
907
|
+
});
|
|
908
|
+
}
|
|
909
|
+
// Update session metadata and persist
|
|
910
|
+
await this.persistSessionAfterReceive(message.senderUserId, message.senderDeviceId, updatedSession);
|
|
911
|
+
return decryptedPlaintext;
|
|
912
|
+
}
|
|
913
|
+
// 6. All sessions failed - try PreKeyMessage handling as fallback
|
|
914
|
+
// This handles the device reset scenario where the sender has a new identity key
|
|
915
|
+
// and is sending a PreKeyMessage, but we have an old session that can't decrypt it.
|
|
916
|
+
this.logger.debug('SESAME: All existing sessions failed, trying PreKeyMessage fallback', {
|
|
917
|
+
category: 'E2EE',
|
|
918
|
+
data: {
|
|
919
|
+
operation: 'sesame-receive',
|
|
920
|
+
senderUserId: message.senderUserId,
|
|
921
|
+
senderDeviceId: message.senderDeviceId,
|
|
922
|
+
candidatesTried: candidates.length,
|
|
923
|
+
},
|
|
924
|
+
});
|
|
925
|
+
try {
|
|
926
|
+
const result = await this.handlePreKeyMessage(message, senderAddress, ciphertext);
|
|
927
|
+
// TRANSACTIONAL: Only persist after successful decrypt
|
|
928
|
+
// This prevents session state corruption if decryption fails
|
|
929
|
+
if (result.pendingUserRecord) {
|
|
930
|
+
await this.storage.setUserRecord(message.senderUserId, result.pendingUserRecord);
|
|
931
|
+
}
|
|
932
|
+
// Update session index for the newly established session
|
|
933
|
+
this.removeDeviceFromSessionIndex(message.senderUserId, message.senderDeviceId);
|
|
934
|
+
this.indexSessionRecord(message.senderUserId, message.senderDeviceId, result.pendingDeviceRecord.session);
|
|
935
|
+
await this.storage.setDeviceRecord(message.senderUserId, message.senderDeviceId, result.pendingDeviceRecord);
|
|
936
|
+
this.logger.debug('SESAME: Session established from PreKeyMessage fallback (persisted)', {
|
|
937
|
+
category: 'E2EE',
|
|
938
|
+
data: {
|
|
939
|
+
operation: 'sesame-receive',
|
|
940
|
+
senderUserId: message.senderUserId,
|
|
941
|
+
senderDeviceId: message.senderDeviceId,
|
|
942
|
+
},
|
|
943
|
+
});
|
|
944
|
+
return result.plaintext;
|
|
945
|
+
}
|
|
946
|
+
catch (error) {
|
|
947
|
+
// TRANSACTIONAL: No session state was persisted, so no cleanup needed
|
|
948
|
+
this.logger.debug('SESAME: PreKeyMessage fallback failed', {
|
|
949
|
+
category: 'E2EE',
|
|
950
|
+
data: {
|
|
951
|
+
operation: 'sesame-receive',
|
|
952
|
+
senderUserId: message.senderUserId,
|
|
953
|
+
senderDeviceId: message.senderDeviceId,
|
|
954
|
+
error: error.message,
|
|
955
|
+
},
|
|
956
|
+
});
|
|
957
|
+
// Preserve EncryptionError for client-layer handling (e.g., PREKEY_NOT_FOUND triggers key rotation)
|
|
958
|
+
if (error instanceof EncryptionError) {
|
|
959
|
+
throw error;
|
|
960
|
+
}
|
|
961
|
+
throw new DecryptionFailedError(message.sessionId, candidates.length);
|
|
962
|
+
}
|
|
963
|
+
}
|
|
964
|
+
/**
|
|
965
|
+
* Create a retry request for a failed message
|
|
966
|
+
*/
|
|
967
|
+
async createRetryRequest(failedMessage, reason) {
|
|
968
|
+
if (!this.config.enableRetryRequests) {
|
|
969
|
+
throw new SesameError('Retry requests are disabled in configuration', 'RETRY_DISABLED');
|
|
970
|
+
}
|
|
971
|
+
if (!this.localUserId || !this.localDeviceId) {
|
|
972
|
+
throw new SesameError('SesameManager not initialized', 'NOT_INITIALIZED');
|
|
973
|
+
}
|
|
974
|
+
// Require timestamp for retry request
|
|
975
|
+
// Client timestamp is the primary identifier for message lookup
|
|
976
|
+
if (failedMessage.timestamp === undefined) {
|
|
977
|
+
throw new SesameError('Cannot create retry request: message has no timestamp', 'MISSING_TIMESTAMP');
|
|
978
|
+
}
|
|
979
|
+
const ratchetKey = this.extractRetryRatchetKey(failedMessage.ciphertext);
|
|
980
|
+
const retryRequest = {
|
|
981
|
+
requesterUserId: this.localUserId,
|
|
982
|
+
requesterDeviceId: this.localDeviceId,
|
|
983
|
+
originalSenderUserId: failedMessage.senderUserId,
|
|
984
|
+
originalSenderDeviceId: failedMessage.senderDeviceId,
|
|
985
|
+
// Primary identifier: client timestamp
|
|
986
|
+
failedTimestamp: failedMessage.timestamp,
|
|
987
|
+
timestamp: Date.now(),
|
|
988
|
+
reason,
|
|
989
|
+
...(ratchetKey !== undefined && { ratchetKey }),
|
|
990
|
+
};
|
|
991
|
+
this.logger.debug('SESAME: Created retry request', {
|
|
992
|
+
category: 'E2EE',
|
|
993
|
+
data: {
|
|
994
|
+
operation: 'sesame-retry-request',
|
|
995
|
+
reason,
|
|
996
|
+
failedTimestamp: failedMessage.timestamp,
|
|
997
|
+
originalSender: `${failedMessage.senderUserId}:${failedMessage.senderDeviceId}`,
|
|
998
|
+
hasRatchetKey: ratchetKey !== undefined,
|
|
999
|
+
},
|
|
1000
|
+
});
|
|
1001
|
+
return retryRequest;
|
|
1002
|
+
}
|
|
1003
|
+
/**
|
|
1004
|
+
* Handle an incoming retry request
|
|
1005
|
+
*
|
|
1006
|
+
* Processes retry requests from recipients who failed to decrypt a message.
|
|
1007
|
+
* Takes appropriate action based on the failure reason:
|
|
1008
|
+
*
|
|
1009
|
+
* - NO_SESSION: Archives our session, signals that a new session is needed
|
|
1010
|
+
* - DECRYPTION_FAILED: Archives our session, signals session reset needed
|
|
1011
|
+
* - SESSION_EXPIRED: Archives our session, signals new session needed
|
|
1012
|
+
* - STALE_DEVICE_LIST: No local action needed, requester should refresh their list
|
|
1013
|
+
* - IDENTITY_KEY_MISMATCH: Logs security event, requires user verification
|
|
1014
|
+
*
|
|
1015
|
+
* @param retryRequest - The retry request from the recipient
|
|
1016
|
+
* @param options - Optional lifecycle handling overrides
|
|
1017
|
+
* @returns Result indicating what actions were taken and what the caller should do
|
|
1018
|
+
*/
|
|
1019
|
+
async handleRetryRequest(retryRequest, options) {
|
|
1020
|
+
if (!this.config.enableRetryRequests) {
|
|
1021
|
+
throw new SesameError('Retry requests are disabled in configuration', 'RETRY_DISABLED');
|
|
1022
|
+
}
|
|
1023
|
+
if (!this.localUserId || !this.localDeviceId) {
|
|
1024
|
+
throw new SesameError('SesameManager not initialized', 'NOT_INITIALIZED');
|
|
1025
|
+
}
|
|
1026
|
+
// Validate retry request is addressed to this device
|
|
1027
|
+
if (retryRequest.originalSenderUserId !== this.localUserId ||
|
|
1028
|
+
retryRequest.originalSenderDeviceId !== this.localDeviceId) {
|
|
1029
|
+
throw new SesameError('Retry request not addressed to this device', 'WRONG_RETRY_DEVICE');
|
|
1030
|
+
}
|
|
1031
|
+
const requesterUserId = retryRequest.requesterUserId;
|
|
1032
|
+
const requesterDeviceId = retryRequest.requesterDeviceId;
|
|
1033
|
+
const lifecycleOnly = options?.skipMessageRecordValidation === true;
|
|
1034
|
+
if (!lifecycleOnly) {
|
|
1035
|
+
// Validate the message corresponds to one we actually sent.
|
|
1036
|
+
// This prevents attackers from forging retry requests to force session renegotiation.
|
|
1037
|
+
// Per SESAME spec §4.1: message existence MUST be verified before processing retries.
|
|
1038
|
+
if (!this.messageRecordStore) {
|
|
1039
|
+
this.logger.warn('SESAME: Retry request rejected - no MessageRecordStore configured', {
|
|
1040
|
+
category: 'SECURITY',
|
|
1041
|
+
data: { requester: `${requesterUserId}:${requesterDeviceId}` },
|
|
1042
|
+
});
|
|
1043
|
+
return {
|
|
1044
|
+
action: 'NO_ACTION',
|
|
1045
|
+
requiresNewSession: false,
|
|
1046
|
+
requiresUserVerification: false,
|
|
1047
|
+
reason: 'MessageRecordStore not configured - cannot validate retry request.',
|
|
1048
|
+
};
|
|
1049
|
+
}
|
|
1050
|
+
// Scope the original-message lookup to the requesting device so one
|
|
1051
|
+
// device cannot trigger a resend intended for another.
|
|
1052
|
+
const requesterSessionId = `${requesterUserId}:${requesterDeviceId}`;
|
|
1053
|
+
const originalMessage = await this.messageRecordStore.getMessageRecord(requesterSessionId, retryRequest.failedTimestamp);
|
|
1054
|
+
if (!originalMessage) {
|
|
1055
|
+
this.logger.warn('SESAME: Retry request for unknown message', {
|
|
1056
|
+
category: 'SECURITY',
|
|
1057
|
+
data: {
|
|
1058
|
+
requester: `${requesterUserId}:${requesterDeviceId}`,
|
|
1059
|
+
failedTimestamp: retryRequest.failedTimestamp,
|
|
1060
|
+
},
|
|
1061
|
+
});
|
|
1062
|
+
return {
|
|
1063
|
+
action: 'NO_ACTION',
|
|
1064
|
+
requiresNewSession: false,
|
|
1065
|
+
requiresUserVerification: false,
|
|
1066
|
+
reason: 'No message found for the specified timestamp.',
|
|
1067
|
+
};
|
|
1068
|
+
}
|
|
1069
|
+
}
|
|
1070
|
+
else {
|
|
1071
|
+
if (retryRequest.reason === RetryReason.DECRYPTION_FAILED) {
|
|
1072
|
+
const activeSession = await this.getActiveSession(requesterUserId, requesterDeviceId);
|
|
1073
|
+
const currentRatchetKey = activeSession?.DHs?.publicKey;
|
|
1074
|
+
// Signal behavior (Android/iOS): only reset session on retry if the ratchet
|
|
1075
|
+
// key from DecryptionErrorMessage matches the current active session.
|
|
1076
|
+
if (!retryRequest.ratchetKey ||
|
|
1077
|
+
!currentRatchetKey ||
|
|
1078
|
+
currentRatchetKey !== retryRequest.ratchetKey) {
|
|
1079
|
+
this.logger.warn('SESAME: Lifecycle-only retry rejected due to ratchet key mismatch', {
|
|
1080
|
+
category: 'SECURITY',
|
|
1081
|
+
data: {
|
|
1082
|
+
requester: `${requesterUserId}:${requesterDeviceId}`,
|
|
1083
|
+
hasRetryRatchetKey: retryRequest.ratchetKey !== undefined,
|
|
1084
|
+
hasActiveRatchetKey: currentRatchetKey !== undefined,
|
|
1085
|
+
},
|
|
1086
|
+
});
|
|
1087
|
+
return {
|
|
1088
|
+
action: 'NO_ACTION',
|
|
1089
|
+
requiresNewSession: false,
|
|
1090
|
+
requiresUserVerification: false,
|
|
1091
|
+
reason: 'Retry ratchet key did not match active session; skipping lifecycle-only session reset.',
|
|
1092
|
+
};
|
|
1093
|
+
}
|
|
1094
|
+
}
|
|
1095
|
+
this.logger.info('SESAME: Handling retry request in lifecycle-only mode', {
|
|
1096
|
+
category: 'E2EE',
|
|
1097
|
+
data: {
|
|
1098
|
+
requester: `${requesterUserId}:${requesterDeviceId}`,
|
|
1099
|
+
failedTimestamp: retryRequest.failedTimestamp,
|
|
1100
|
+
reason: retryRequest.reason,
|
|
1101
|
+
},
|
|
1102
|
+
});
|
|
1103
|
+
}
|
|
1104
|
+
this.logger.info('SESAME: Handling retry request (lifecycle)', {
|
|
1105
|
+
category: 'E2EE',
|
|
1106
|
+
data: {
|
|
1107
|
+
operation: 'sesame-handle-retry',
|
|
1108
|
+
reason: retryRequest.reason,
|
|
1109
|
+
requester: `${requesterUserId}:${requesterDeviceId}`,
|
|
1110
|
+
failedTimestamp: retryRequest.failedTimestamp,
|
|
1111
|
+
localSender: `${this.localUserId}:${this.localDeviceId}`,
|
|
1112
|
+
},
|
|
1113
|
+
});
|
|
1114
|
+
// Based on the retry reason, take appropriate action
|
|
1115
|
+
switch (retryRequest.reason) {
|
|
1116
|
+
case RetryReason.NO_SESSION:
|
|
1117
|
+
// Requester has no session - archive our session and signal that a new session is needed
|
|
1118
|
+
// The caller should establish a new session and resend the message
|
|
1119
|
+
await this.archiveSessionForDevice(requesterUserId, requesterDeviceId);
|
|
1120
|
+
this.logger.info('SESAME: Session archived due to NO_SESSION retry request', {
|
|
1121
|
+
category: 'E2EE',
|
|
1122
|
+
data: {
|
|
1123
|
+
requester: `${requesterUserId}:${requesterDeviceId}`,
|
|
1124
|
+
failedTimestamp: retryRequest.failedTimestamp,
|
|
1125
|
+
},
|
|
1126
|
+
});
|
|
1127
|
+
return {
|
|
1128
|
+
action: 'SESSION_ARCHIVED',
|
|
1129
|
+
requiresNewSession: true,
|
|
1130
|
+
requiresUserVerification: false,
|
|
1131
|
+
reason: 'Recipient has no session. Establish a new session and resend the message.',
|
|
1132
|
+
};
|
|
1133
|
+
case RetryReason.DECRYPTION_FAILED:
|
|
1134
|
+
// Requester couldn't decrypt - session is likely desynchronized
|
|
1135
|
+
// Archive our session so a new one will be established on next send
|
|
1136
|
+
await this.archiveSessionForDevice(requesterUserId, requesterDeviceId);
|
|
1137
|
+
this.logger.warn('SESAME: Session archived due to DECRYPTION_FAILED retry request', {
|
|
1138
|
+
category: 'E2EE',
|
|
1139
|
+
data: {
|
|
1140
|
+
requester: `${requesterUserId}:${requesterDeviceId}`,
|
|
1141
|
+
failedTimestamp: retryRequest.failedTimestamp,
|
|
1142
|
+
},
|
|
1143
|
+
});
|
|
1144
|
+
return {
|
|
1145
|
+
action: 'SESSION_ARCHIVED',
|
|
1146
|
+
requiresNewSession: true,
|
|
1147
|
+
requiresUserVerification: false,
|
|
1148
|
+
reason: 'Decryption failed, session may be desynchronized. Establish a new session and resend.',
|
|
1149
|
+
};
|
|
1150
|
+
case RetryReason.SESSION_EXPIRED:
|
|
1151
|
+
// Requester's session is expired - same as NO_SESSION
|
|
1152
|
+
await this.archiveSessionForDevice(requesterUserId, requesterDeviceId);
|
|
1153
|
+
this.logger.info('SESAME: Session archived due to SESSION_EXPIRED retry request', {
|
|
1154
|
+
category: 'E2EE',
|
|
1155
|
+
data: {
|
|
1156
|
+
requester: `${requesterUserId}:${requesterDeviceId}`,
|
|
1157
|
+
failedTimestamp: retryRequest.failedTimestamp,
|
|
1158
|
+
},
|
|
1159
|
+
});
|
|
1160
|
+
return {
|
|
1161
|
+
action: 'SESSION_ARCHIVED',
|
|
1162
|
+
requiresNewSession: true,
|
|
1163
|
+
requiresUserVerification: false,
|
|
1164
|
+
reason: 'Recipient session expired. Establish a new session and resend the message.',
|
|
1165
|
+
};
|
|
1166
|
+
case RetryReason.STALE_DEVICE_LIST:
|
|
1167
|
+
// Requester has outdated device list - they should refresh
|
|
1168
|
+
// No local action needed on our side
|
|
1169
|
+
this.logger.debug('SESAME: STALE_DEVICE_LIST retry request - no local action needed', {
|
|
1170
|
+
category: 'E2EE',
|
|
1171
|
+
data: {
|
|
1172
|
+
requester: `${requesterUserId}:${requesterDeviceId}`,
|
|
1173
|
+
},
|
|
1174
|
+
});
|
|
1175
|
+
return {
|
|
1176
|
+
action: 'NO_ACTION',
|
|
1177
|
+
requiresNewSession: false,
|
|
1178
|
+
requiresUserVerification: false,
|
|
1179
|
+
reason: 'Recipient has stale device list. They should refresh and retry.',
|
|
1180
|
+
};
|
|
1181
|
+
case RetryReason.IDENTITY_KEY_MISMATCH:
|
|
1182
|
+
// Security issue - identity key changed
|
|
1183
|
+
// This requires user verification before proceeding
|
|
1184
|
+
this.logger.error('SESAME: IDENTITY_KEY_MISMATCH - potential security issue', {
|
|
1185
|
+
category: 'SECURITY',
|
|
1186
|
+
data: {
|
|
1187
|
+
requester: `${requesterUserId}:${requesterDeviceId}`,
|
|
1188
|
+
failedTimestamp: retryRequest.failedTimestamp,
|
|
1189
|
+
},
|
|
1190
|
+
});
|
|
1191
|
+
return {
|
|
1192
|
+
action: 'SECURITY_ALERT',
|
|
1193
|
+
requiresNewSession: false,
|
|
1194
|
+
requiresUserVerification: true,
|
|
1195
|
+
reason: 'Identity key mismatch detected. User must verify safety numbers before proceeding.',
|
|
1196
|
+
};
|
|
1197
|
+
default:
|
|
1198
|
+
this.logger.warn('SESAME: Unknown retry reason', {
|
|
1199
|
+
category: 'E2EE',
|
|
1200
|
+
data: {
|
|
1201
|
+
reason: retryRequest.reason,
|
|
1202
|
+
requester: `${requesterUserId}:${requesterDeviceId}`,
|
|
1203
|
+
},
|
|
1204
|
+
});
|
|
1205
|
+
return {
|
|
1206
|
+
action: 'UNKNOWN',
|
|
1207
|
+
requiresNewSession: false,
|
|
1208
|
+
requiresUserVerification: false,
|
|
1209
|
+
reason: `Unknown retry reason: ${retryRequest.reason}`,
|
|
1210
|
+
};
|
|
1211
|
+
}
|
|
1212
|
+
}
|
|
1213
|
+
/**
|
|
1214
|
+
* Handle PreKeyMessage decryption when no existing sessions are found.
|
|
1215
|
+
*
|
|
1216
|
+
* This method handles the first message from a new sender by:
|
|
1217
|
+
* 1. Attempting to decrypt using protocol.decrypt() (handles session establishment)
|
|
1218
|
+
* 2. Creating DeviceRecord if sender is unknown
|
|
1219
|
+
* 3. Detecting identity key changes for existing senders (device reinstall scenario)
|
|
1220
|
+
* 4. Persisting the new session
|
|
1221
|
+
*
|
|
1222
|
+
* @param message - The incoming SESAME message
|
|
1223
|
+
* @param senderAddress - Protocol address of the sender
|
|
1224
|
+
* @param ciphertext - The encrypted ciphertext
|
|
1225
|
+
* @returns Decrypted plaintext as Uint8Array
|
|
1226
|
+
* @throws DecryptionFailedError if decryption fails
|
|
1227
|
+
*/
|
|
1228
|
+
async handlePreKeyMessage(message, senderAddress, ciphertext) {
|
|
1229
|
+
this.logger.debug('SESAME: No existing sessions, trying PreKeyMessage handling', {
|
|
1230
|
+
category: 'E2EE',
|
|
1231
|
+
data: {
|
|
1232
|
+
operation: 'sesame-receive',
|
|
1233
|
+
senderUserId: message.senderUserId,
|
|
1234
|
+
senderDeviceId: message.senderDeviceId,
|
|
1235
|
+
},
|
|
1236
|
+
});
|
|
1237
|
+
// Note: this.protocol is guaranteed non-null because receive() checks it before calling this method
|
|
1238
|
+
const plaintextString = await this.protocol.decrypt(senderAddress, ciphertext);
|
|
1239
|
+
const decryptedPlaintext = new TextEncoder().encode(plaintextString);
|
|
1240
|
+
// CRITICAL: Sync session from KeyStorage to SESAME layer
|
|
1241
|
+
// The protocol.decrypt() call above establishes the session in KeyStorage (protocol layer).
|
|
1242
|
+
// SESAME needs this session in DeviceRecord.session (SESAME layer) for subsequent messages.
|
|
1243
|
+
// Without this sync, the responder path fails to find the session on later messages.
|
|
1244
|
+
const sessionFromProtocol = await this.protocol.getSession(senderAddress);
|
|
1245
|
+
// Parse PreKeyMessage to get sender's identity key (binary protobuf format)
|
|
1246
|
+
// This is needed for both new senders AND existing senders (to detect identity key changes)
|
|
1247
|
+
let incomingIdentityKey;
|
|
1248
|
+
try {
|
|
1249
|
+
const bytes = base64ToBytes(ciphertext);
|
|
1250
|
+
if (bytes.length < 2)
|
|
1251
|
+
throw new Error('Too short');
|
|
1252
|
+
// Parse PreKeySignalMessage to get identity key
|
|
1253
|
+
const { protobufBytes } = parsePreKeySignalMessageEnvelope(bytes);
|
|
1254
|
+
const preKeyFields = decodePreKeySignalMessage(protobufBytes);
|
|
1255
|
+
if (!preKeyFields.identityKey?.length) {
|
|
1256
|
+
throw new DecryptionFailedError(message.sessionId, 0);
|
|
1257
|
+
}
|
|
1258
|
+
// The independent profile carries exactly one canonical 67-byte composite
|
|
1259
|
+
// tuple. Decode and re-encode so unknown tags/profile bytes fail before
|
|
1260
|
+
// any SESAME user or device record is prepared.
|
|
1261
|
+
incomingIdentityKey = encodeCompositeIdentityV1(decodeCompositeIdentityV1(preKeyFields.identityKey));
|
|
1262
|
+
}
|
|
1263
|
+
catch (e) {
|
|
1264
|
+
if (e instanceof DecryptionFailedError)
|
|
1265
|
+
throw e;
|
|
1266
|
+
throw new DecryptionFailedError(message.sessionId, 0);
|
|
1267
|
+
}
|
|
1268
|
+
// Get existing DeviceRecord for this sender (if any)
|
|
1269
|
+
let deviceRecord = await this.getDeviceRecord(message.senderUserId, message.senderDeviceId);
|
|
1270
|
+
// Track if we need to create/update UserRecord (for new senders only)
|
|
1271
|
+
let pendingUserRecord;
|
|
1272
|
+
if (!deviceRecord) {
|
|
1273
|
+
// First message from new sender - create DeviceRecord with synced session
|
|
1274
|
+
deviceRecord = {
|
|
1275
|
+
userId: message.senderUserId,
|
|
1276
|
+
deviceId: message.senderDeviceId,
|
|
1277
|
+
identityKey: incomingIdentityKey,
|
|
1278
|
+
session: sessionFromProtocol ? updateSessionRecordAfterReceive(sessionFromProtocol) : null, // Sync session from protocol layer with metadata
|
|
1279
|
+
createdAt: Date.now(),
|
|
1280
|
+
updatedAt: Date.now(),
|
|
1281
|
+
};
|
|
1282
|
+
// Prepare UserRecord (will be persisted by caller after successful decrypt)
|
|
1283
|
+
let userRecord = await this.storage.getUserRecord(message.senderUserId);
|
|
1284
|
+
if (!userRecord) {
|
|
1285
|
+
userRecord = {
|
|
1286
|
+
userId: message.senderUserId,
|
|
1287
|
+
devices: new Map(),
|
|
1288
|
+
createdAt: Date.now(),
|
|
1289
|
+
updatedAt: Date.now(),
|
|
1290
|
+
};
|
|
1291
|
+
}
|
|
1292
|
+
userRecord.devices.set(message.senderDeviceId, deviceRecord);
|
|
1293
|
+
userRecord.updatedAt = Date.now();
|
|
1294
|
+
pendingUserRecord = userRecord;
|
|
1295
|
+
// TRANSACTIONAL: DO NOT persist here - caller will persist after successful decrypt
|
|
1296
|
+
// This prevents session state corruption if subsequent processing fails
|
|
1297
|
+
this.logger.debug('SESAME: Prepared DeviceRecord for new sender (pending persist)', {
|
|
1298
|
+
category: 'E2EE',
|
|
1299
|
+
data: { userId: message.senderUserId, deviceId: message.senderDeviceId },
|
|
1300
|
+
});
|
|
1301
|
+
}
|
|
1302
|
+
else {
|
|
1303
|
+
// Existing sender - check if identity key changed (device reinstall scenario)
|
|
1304
|
+
const identityKeyChanged = !constantTimeEqual(deviceRecord.identityKey, incomingIdentityKey);
|
|
1305
|
+
if (identityKeyChanged) {
|
|
1306
|
+
// CRITICAL: Identity key changed - this is either a device reinstall
|
|
1307
|
+
// or a potential security issue (man-in-the-middle attack)
|
|
1308
|
+
this.logger.warn('SESAME: Identity key changed detected in PreKeyMessage', {
|
|
1309
|
+
category: 'SECURITY',
|
|
1310
|
+
data: {
|
|
1311
|
+
userId: message.senderUserId,
|
|
1312
|
+
deviceId: message.senderDeviceId,
|
|
1313
|
+
event: 'identity_key_changed',
|
|
1314
|
+
},
|
|
1315
|
+
});
|
|
1316
|
+
// Update the identity key to the new one
|
|
1317
|
+
deviceRecord.identityKey = incomingIdentityKey;
|
|
1318
|
+
deviceRecord.pendingVerification = true;
|
|
1319
|
+
// Emit identity key changed event (safety number changed)
|
|
1320
|
+
this.events.onIdentityKeyChanged?.(message.senderUserId, incomingIdentityKey);
|
|
1321
|
+
// Also emit security event
|
|
1322
|
+
this.events.onSecurityEvent?.(senderAddress, 'identity_key_changed');
|
|
1323
|
+
this.logger.info('SESAME: Session archived and identity key updated after device reinstall', {
|
|
1324
|
+
category: 'E2EE',
|
|
1325
|
+
data: {
|
|
1326
|
+
userId: message.senderUserId,
|
|
1327
|
+
deviceId: message.senderDeviceId,
|
|
1328
|
+
},
|
|
1329
|
+
});
|
|
1330
|
+
}
|
|
1331
|
+
// Sync the new session from protocol layer to DeviceRecord
|
|
1332
|
+
// This is needed whether identity changed or not - the PreKeyMessage
|
|
1333
|
+
// established a new session that needs to be synced to SESAME layer
|
|
1334
|
+
if (sessionFromProtocol) {
|
|
1335
|
+
// If there was an old session, archive it before setting the new one
|
|
1336
|
+
// This preserves session history for convergence per SESAME spec
|
|
1337
|
+
if (deviceRecord.session?.currentSession) {
|
|
1338
|
+
const archivedRecord = SessionResolver.archiveCurrentSession(deviceRecord.session, this.config.maxInactiveSessions);
|
|
1339
|
+
// Merge archived sessions: preserve ALL sessions from both sources
|
|
1340
|
+
// Use explicit merge to avoid collision-related data loss from spread operator
|
|
1341
|
+
const mergedArchived = {};
|
|
1342
|
+
// First, add all from archived record (preserves existing session history)
|
|
1343
|
+
for (const [key, session] of Object.entries(archivedRecord.archivedSessions)) {
|
|
1344
|
+
if (session)
|
|
1345
|
+
mergedArchived[key] = session;
|
|
1346
|
+
}
|
|
1347
|
+
// Then add from protocol (only if not already present - don't overwrite history)
|
|
1348
|
+
for (const [key, session] of Object.entries(sessionFromProtocol.archivedSessions || {})) {
|
|
1349
|
+
if (session && !(key in mergedArchived)) {
|
|
1350
|
+
mergedArchived[key] = session;
|
|
1351
|
+
}
|
|
1352
|
+
}
|
|
1353
|
+
sessionFromProtocol.archivedSessions = mergedArchived;
|
|
1354
|
+
}
|
|
1355
|
+
deviceRecord.session = updateSessionRecordAfterReceive(sessionFromProtocol);
|
|
1356
|
+
}
|
|
1357
|
+
deviceRecord.updatedAt = Date.now();
|
|
1358
|
+
// TRANSACTIONAL: DO NOT persist here - caller will persist after successful decrypt
|
|
1359
|
+
// This prevents session state corruption if subsequent processing fails
|
|
1360
|
+
}
|
|
1361
|
+
this.logger.debug('SESAME: Session prepared from PreKeyMessage (pending persist)', {
|
|
1362
|
+
category: 'E2EE',
|
|
1363
|
+
data: {
|
|
1364
|
+
operation: 'sesame-receive',
|
|
1365
|
+
senderUserId: message.senderUserId,
|
|
1366
|
+
senderDeviceId: message.senderDeviceId,
|
|
1367
|
+
},
|
|
1368
|
+
});
|
|
1369
|
+
// Return result with pending records - caller MUST persist after confirming success
|
|
1370
|
+
return {
|
|
1371
|
+
plaintext: decryptedPlaintext,
|
|
1372
|
+
pendingDeviceRecord: deviceRecord,
|
|
1373
|
+
pendingUserRecord,
|
|
1374
|
+
};
|
|
1375
|
+
}
|
|
1376
|
+
/**
|
|
1377
|
+
* Update session metadata after receiving a message and persist to storage.
|
|
1378
|
+
*
|
|
1379
|
+
* This is a helper method that reduces duplication between the PreKeyMessage
|
|
1380
|
+
* handling path and the normal receive path.
|
|
1381
|
+
*
|
|
1382
|
+
* @param userId - Sender's user ID
|
|
1383
|
+
* @param deviceId - Sender's device ID
|
|
1384
|
+
* @param session - The session record to update
|
|
1385
|
+
*/
|
|
1386
|
+
async persistSessionAfterReceive(userId, deviceId, session) {
|
|
1387
|
+
const updatedSession = updateSessionRecordAfterReceive(session);
|
|
1388
|
+
const deviceRecord = await this.storage.getDeviceRecord(userId, deviceId);
|
|
1389
|
+
if (deviceRecord) {
|
|
1390
|
+
// Update session index for the new session state
|
|
1391
|
+
this.removeDeviceFromSessionIndex(userId, deviceId);
|
|
1392
|
+
this.indexSessionRecord(userId, deviceId, updatedSession);
|
|
1393
|
+
deviceRecord.session = updatedSession;
|
|
1394
|
+
deviceRecord.updatedAt = Date.now();
|
|
1395
|
+
await this.storage.setDeviceRecord(userId, deviceId, deviceRecord);
|
|
1396
|
+
}
|
|
1397
|
+
}
|
|
1398
|
+
/**
|
|
1399
|
+
* Mark a UserRecord as stale, triggering a fresh device list fetch on next access.
|
|
1400
|
+
* Per SESAME spec §3.3: When a StaleDeviceListError occurs, the UserRecord
|
|
1401
|
+
* is marked stale so the sending device knows to refetch the device list.
|
|
1402
|
+
*
|
|
1403
|
+
* @param userId - The user whose record should be marked stale
|
|
1404
|
+
*/
|
|
1405
|
+
async markUserRecordStale(userId) {
|
|
1406
|
+
const userRecord = await this.storage.getUserRecord(userId);
|
|
1407
|
+
if (userRecord) {
|
|
1408
|
+
userRecord.stale = true;
|
|
1409
|
+
userRecord.updatedAt = Date.now();
|
|
1410
|
+
await this.storage.setUserRecord(userId, userRecord);
|
|
1411
|
+
this.logger.info('SESAME: UserRecord marked stale', {
|
|
1412
|
+
category: 'E2EE',
|
|
1413
|
+
data: {
|
|
1414
|
+
operation: 'sesame-mark-stale',
|
|
1415
|
+
userId,
|
|
1416
|
+
},
|
|
1417
|
+
});
|
|
1418
|
+
}
|
|
1419
|
+
}
|
|
1420
|
+
/**
|
|
1421
|
+
* Archive the active session for a specific device
|
|
1422
|
+
*
|
|
1423
|
+
* Moves the current session to archived, clearing the active session
|
|
1424
|
+
* to allow a new session to be established on the next send attempt.
|
|
1425
|
+
*/
|
|
1426
|
+
async archiveSessionForDevice(userId, deviceId) {
|
|
1427
|
+
const deviceRecord = await this.storage.getDeviceRecord(userId, deviceId);
|
|
1428
|
+
if (!deviceRecord?.session?.currentSession) {
|
|
1429
|
+
// No active session to archive
|
|
1430
|
+
return;
|
|
1431
|
+
}
|
|
1432
|
+
const sessionId = ProtocolAddress.toString(deviceRecord.session.currentSession.remoteAddress);
|
|
1433
|
+
// Archive the current session and clear it using SessionResolver
|
|
1434
|
+
deviceRecord.session = SessionResolver.archiveCurrentSession(deviceRecord.session, this.config.maxInactiveSessions);
|
|
1435
|
+
// Rebuild session index for this device (session moved from current to archived)
|
|
1436
|
+
this.removeDeviceFromSessionIndex(userId, deviceId);
|
|
1437
|
+
this.indexSessionRecord(userId, deviceId, deviceRecord.session);
|
|
1438
|
+
await this.storage.setDeviceRecord(userId, deviceId, deviceRecord);
|
|
1439
|
+
this.logger.debug('SESAME: Session archived', {
|
|
1440
|
+
category: 'E2EE',
|
|
1441
|
+
data: {
|
|
1442
|
+
operation: 'sesame-archive-session',
|
|
1443
|
+
userId,
|
|
1444
|
+
deviceId,
|
|
1445
|
+
sessionId,
|
|
1446
|
+
},
|
|
1447
|
+
});
|
|
1448
|
+
}
|
|
1449
|
+
/**
|
|
1450
|
+
* Extract sender ratchet key from failed message ciphertext for retry requests.
|
|
1451
|
+
*
|
|
1452
|
+
* Retry metadata includes the sender ratchet key for one-to-one
|
|
1453
|
+
* SignalMessage/PreKeySignalMessage failures and omits it for
|
|
1454
|
+
* sender-key messages.
|
|
1455
|
+
*/
|
|
1456
|
+
extractRetryRatchetKey(ciphertext) {
|
|
1457
|
+
if (ciphertext.length < 2) {
|
|
1458
|
+
return undefined;
|
|
1459
|
+
}
|
|
1460
|
+
try {
|
|
1461
|
+
let signalMessageProtobuf;
|
|
1462
|
+
const firstTag = ciphertext[1];
|
|
1463
|
+
const isPreKey = firstTag === 0x08 || firstTag === 0x12;
|
|
1464
|
+
if (isPreKey) {
|
|
1465
|
+
const { protobufBytes: outerProto } = parsePreKeySignalMessageEnvelope(ciphertext);
|
|
1466
|
+
const preKeyFields = decodePreKeySignalMessage(outerProto);
|
|
1467
|
+
const { protobufBytes: innerProto } = parseSignalMessageEnvelope(preKeyFields.message);
|
|
1468
|
+
signalMessageProtobuf = innerProto;
|
|
1469
|
+
}
|
|
1470
|
+
else {
|
|
1471
|
+
const { protobufBytes } = parseSignalMessageEnvelope(ciphertext);
|
|
1472
|
+
signalMessageProtobuf = protobufBytes;
|
|
1473
|
+
}
|
|
1474
|
+
const signalFields = decodeSignalMessage(signalMessageProtobuf);
|
|
1475
|
+
if (!signalFields.ratchetKey?.length) {
|
|
1476
|
+
return undefined;
|
|
1477
|
+
}
|
|
1478
|
+
const ratchetKeyRaw = signalFields.ratchetKey.length === 33
|
|
1479
|
+
? deserializePublicKey(signalFields.ratchetKey)
|
|
1480
|
+
: signalFields.ratchetKey;
|
|
1481
|
+
return bytesToBase64(ratchetKeyRaw);
|
|
1482
|
+
}
|
|
1483
|
+
catch {
|
|
1484
|
+
return undefined;
|
|
1485
|
+
}
|
|
1486
|
+
}
|
|
1487
|
+
/**
|
|
1488
|
+
* Extract the creation timestamp from a SessionRecord.
|
|
1489
|
+
*
|
|
1490
|
+
* Prefers SessionRecordMetadata.createdAt (set by SESAME registerSession),
|
|
1491
|
+
* then falls back to SessionState.createdAt (set by Double Ratchet init).
|
|
1492
|
+
* Returns 0 only if neither is available (fail closed — treats session as
|
|
1493
|
+
* expired at Unix epoch).
|
|
1494
|
+
*/
|
|
1495
|
+
getSessionCreatedAt(session) {
|
|
1496
|
+
return session.metadata?.createdAt ?? session.currentSession?.createdAt ?? 0;
|
|
1497
|
+
}
|
|
1498
|
+
/**
|
|
1499
|
+
* Check if a session can be used for sending.
|
|
1500
|
+
*
|
|
1501
|
+
* Only check age on unacknowledged sessions (no reply received yet).
|
|
1502
|
+
* Acknowledged sessions have no age-based send expiration.
|
|
1503
|
+
*/
|
|
1504
|
+
async canSendOnSession(sessionId) {
|
|
1505
|
+
const session = await this.findSession(sessionId);
|
|
1506
|
+
if (!session?.currentSession) {
|
|
1507
|
+
return false;
|
|
1508
|
+
}
|
|
1509
|
+
// Only check age on unacknowledged sessions (no reply received yet).
|
|
1510
|
+
// Acknowledged sessions have no age-based send expiration.
|
|
1511
|
+
if (session.currentSession.hasReceivedMessage === false) {
|
|
1512
|
+
const createdAt = this.getSessionCreatedAt(session);
|
|
1513
|
+
return Date.now() - createdAt <= this.config.maxUnacknowledgedSessionAge;
|
|
1514
|
+
}
|
|
1515
|
+
return true;
|
|
1516
|
+
}
|
|
1517
|
+
/**
|
|
1518
|
+
* Index all session IDs from a DeviceRecord's SessionRecord into sessionIndex.
|
|
1519
|
+
* Indexes both the current session and all archived sessions.
|
|
1520
|
+
*/
|
|
1521
|
+
indexSessionRecord(userId, deviceId, sessionRecord) {
|
|
1522
|
+
if (!sessionRecord)
|
|
1523
|
+
return;
|
|
1524
|
+
const entry = { userId, deviceId };
|
|
1525
|
+
if (sessionRecord.currentSession?.remoteAddress) {
|
|
1526
|
+
const sid = ProtocolAddress.toString(sessionRecord.currentSession.remoteAddress);
|
|
1527
|
+
this.sessionIndex.set(sid, entry);
|
|
1528
|
+
}
|
|
1529
|
+
for (const archivedSession of Object.values(sessionRecord.archivedSessions)) {
|
|
1530
|
+
if (!archivedSession?.remoteAddress)
|
|
1531
|
+
continue;
|
|
1532
|
+
const sid = ProtocolAddress.toString(archivedSession.remoteAddress);
|
|
1533
|
+
this.sessionIndex.set(sid, entry);
|
|
1534
|
+
}
|
|
1535
|
+
}
|
|
1536
|
+
/**
|
|
1537
|
+
* Remove all session IDs belonging to a specific device from sessionIndex.
|
|
1538
|
+
*/
|
|
1539
|
+
removeDeviceFromSessionIndex(userId, deviceId) {
|
|
1540
|
+
for (const [sid, entry] of this.sessionIndex) {
|
|
1541
|
+
if (entry.userId === userId && entry.deviceId === deviceId) {
|
|
1542
|
+
this.sessionIndex.delete(sid);
|
|
1543
|
+
}
|
|
1544
|
+
}
|
|
1545
|
+
}
|
|
1546
|
+
/**
|
|
1547
|
+
* Find a session by ID using the O(1) session index.
|
|
1548
|
+
* Falls back to direct storage lookup (parsing the sessionId) if the index
|
|
1549
|
+
* has no entry — this handles app restart where the in-memory index is empty
|
|
1550
|
+
* but sessions are persisted in storage.
|
|
1551
|
+
*/
|
|
1552
|
+
async findSession(sessionId) {
|
|
1553
|
+
const entry = this.sessionIndex.get(sessionId);
|
|
1554
|
+
if (entry) {
|
|
1555
|
+
const deviceRecord = await this.storage.getDeviceRecord(entry.userId, entry.deviceId);
|
|
1556
|
+
if (!deviceRecord?.session) {
|
|
1557
|
+
// Index is stale - clean it up
|
|
1558
|
+
this.sessionIndex.delete(sessionId);
|
|
1559
|
+
return null;
|
|
1560
|
+
}
|
|
1561
|
+
return deviceRecord.session;
|
|
1562
|
+
}
|
|
1563
|
+
// Index miss — parse sessionId and look up directly from storage.
|
|
1564
|
+
// This covers the case where the app restarted and the in-memory index
|
|
1565
|
+
// was not rebuilt.
|
|
1566
|
+
let parsed;
|
|
1567
|
+
try {
|
|
1568
|
+
parsed = ProtocolAddress.parse(sessionId);
|
|
1569
|
+
}
|
|
1570
|
+
catch {
|
|
1571
|
+
return null;
|
|
1572
|
+
}
|
|
1573
|
+
const deviceRecord = await this.storage.getDeviceRecord(parsed.userId, parsed.deviceId);
|
|
1574
|
+
if (!deviceRecord?.session) {
|
|
1575
|
+
return null;
|
|
1576
|
+
}
|
|
1577
|
+
// Rebuild the index entry so subsequent lookups are O(1)
|
|
1578
|
+
this.indexSessionRecord(parsed.userId, parsed.deviceId, deviceRecord.session);
|
|
1579
|
+
return deviceRecord.session;
|
|
1580
|
+
}
|
|
1581
|
+
/**
|
|
1582
|
+
* Clean up expired sessions based on maxRecv threshold
|
|
1583
|
+
*/
|
|
1584
|
+
async cleanupExpiredSessions() {
|
|
1585
|
+
const count = await this.storage.cleanupExpiredSessions(this.config.maxRecv);
|
|
1586
|
+
this.logger.debug('SESAME: Cleaned up expired sessions', {
|
|
1587
|
+
category: 'E2EE',
|
|
1588
|
+
data: {
|
|
1589
|
+
operation: 'sesame-cleanup',
|
|
1590
|
+
expiredCount: count,
|
|
1591
|
+
},
|
|
1592
|
+
});
|
|
1593
|
+
return count;
|
|
1594
|
+
}
|
|
1595
|
+
/**
|
|
1596
|
+
* Clean up stale device records with no sessions and age > maxLatency
|
|
1597
|
+
*/
|
|
1598
|
+
async cleanupStaleRecords() {
|
|
1599
|
+
if (!this.config.enableStaleRecordCleanup) {
|
|
1600
|
+
return 0;
|
|
1601
|
+
}
|
|
1602
|
+
const count = await this.storage.deleteStaleRecords(this.config.maxLatency);
|
|
1603
|
+
this.logger.debug('SESAME: Cleaned up stale records', {
|
|
1604
|
+
category: 'E2EE',
|
|
1605
|
+
data: {
|
|
1606
|
+
operation: 'sesame-cleanup',
|
|
1607
|
+
staleCount: count,
|
|
1608
|
+
},
|
|
1609
|
+
});
|
|
1610
|
+
return count;
|
|
1611
|
+
}
|
|
1612
|
+
/**
|
|
1613
|
+
* Synchronize device list from server response
|
|
1614
|
+
*
|
|
1615
|
+
* SESAME Phase 3 in message sending requires validating the device list is current.
|
|
1616
|
+
*/
|
|
1617
|
+
async syncDeviceList(deviceListResponse) {
|
|
1618
|
+
const { userId, deviceIds, version } = deviceListResponse;
|
|
1619
|
+
this.logger.debug('SESAME: Syncing device list', {
|
|
1620
|
+
category: 'E2EE',
|
|
1621
|
+
data: {
|
|
1622
|
+
operation: 'sesame-sync-devices',
|
|
1623
|
+
userId,
|
|
1624
|
+
deviceCount: deviceIds.length,
|
|
1625
|
+
version,
|
|
1626
|
+
},
|
|
1627
|
+
});
|
|
1628
|
+
// Convert deviceIds to devices array, using identity keys from response when available
|
|
1629
|
+
const { identityKeys } = deviceListResponse;
|
|
1630
|
+
const devices = deviceIds.map((deviceId) => ({
|
|
1631
|
+
deviceId,
|
|
1632
|
+
identityKey: identityKeys?.get(deviceId) ?? new Uint8Array(),
|
|
1633
|
+
isActive: true,
|
|
1634
|
+
}));
|
|
1635
|
+
// Get current user record
|
|
1636
|
+
const userRecord = await this.storage.getUserRecord(userId);
|
|
1637
|
+
if (!userRecord) {
|
|
1638
|
+
// New user - create record with all devices
|
|
1639
|
+
for (const device of devices) {
|
|
1640
|
+
if (device.isActive) {
|
|
1641
|
+
await this.addDevice(userId, device.deviceId, device.identityKey);
|
|
1642
|
+
}
|
|
1643
|
+
}
|
|
1644
|
+
return;
|
|
1645
|
+
}
|
|
1646
|
+
// Track which devices exist on server
|
|
1647
|
+
const serverDeviceIds = new Set(devices.map((d) => d.deviceId));
|
|
1648
|
+
// Remove devices that no longer exist on server
|
|
1649
|
+
for (const [deviceId] of userRecord.devices.entries()) {
|
|
1650
|
+
if (!serverDeviceIds.has(deviceId)) {
|
|
1651
|
+
await this.removeDevice(userId, deviceId);
|
|
1652
|
+
}
|
|
1653
|
+
}
|
|
1654
|
+
// Add or update devices from server
|
|
1655
|
+
for (const device of devices) {
|
|
1656
|
+
if (!device.isActive) {
|
|
1657
|
+
await this.removeDevice(userId, device.deviceId);
|
|
1658
|
+
continue;
|
|
1659
|
+
}
|
|
1660
|
+
const existingDevice = await this.getDeviceRecord(userId, device.deviceId);
|
|
1661
|
+
if (!existingDevice) {
|
|
1662
|
+
await this.addDevice(userId, device.deviceId, device.identityKey);
|
|
1663
|
+
}
|
|
1664
|
+
else {
|
|
1665
|
+
// Check if identity key changed
|
|
1666
|
+
const identityKeyChanged = !constantTimeEqual(existingDevice.identityKey, device.identityKey);
|
|
1667
|
+
if (identityKeyChanged) {
|
|
1668
|
+
// Identity key changed - security event
|
|
1669
|
+
// Remove old device and add new one (clears sessions)
|
|
1670
|
+
await this.removeDevice(userId, device.deviceId);
|
|
1671
|
+
await this.addDevice(userId, device.deviceId, device.identityKey);
|
|
1672
|
+
// Mark device as pending verification to block messaging until user verifies
|
|
1673
|
+
const newRecord = await this.getDeviceRecord(userId, device.deviceId);
|
|
1674
|
+
if (newRecord) {
|
|
1675
|
+
newRecord.pendingVerification = true;
|
|
1676
|
+
await this.storage.setDeviceRecord(userId, device.deviceId, newRecord);
|
|
1677
|
+
}
|
|
1678
|
+
// Emit identity key changed event (SECURITY)
|
|
1679
|
+
this.events.onIdentityKeyChanged?.(userId, device.identityKey);
|
|
1680
|
+
// Also emit security event with description
|
|
1681
|
+
const address = ProtocolAddress.create(userId, device.deviceId);
|
|
1682
|
+
this.events.onSecurityEvent?.(address, 'identity_key_changed');
|
|
1683
|
+
}
|
|
1684
|
+
}
|
|
1685
|
+
}
|
|
1686
|
+
// Update user record version if provided (Phase 3 version tracking)
|
|
1687
|
+
if (version !== undefined) {
|
|
1688
|
+
const updatedUserRecord = await this.storage.getUserRecord(userId);
|
|
1689
|
+
if (updatedUserRecord) {
|
|
1690
|
+
updatedUserRecord.deviceListVersion = version;
|
|
1691
|
+
updatedUserRecord.updatedAt = Date.now();
|
|
1692
|
+
await this.storage.setUserRecord(userId, updatedUserRecord);
|
|
1693
|
+
}
|
|
1694
|
+
}
|
|
1695
|
+
}
|
|
1696
|
+
/**
|
|
1697
|
+
* Get statistics about SESAME state
|
|
1698
|
+
*/
|
|
1699
|
+
async getStats() {
|
|
1700
|
+
const allUserIds = await this.storage.getAllUserIds();
|
|
1701
|
+
const now = Date.now();
|
|
1702
|
+
let totalUsers = 0;
|
|
1703
|
+
let totalDevices = 0;
|
|
1704
|
+
let totalActiveSessions = 0;
|
|
1705
|
+
let totalInactiveSessions = 0;
|
|
1706
|
+
let expiredSessions = 0;
|
|
1707
|
+
let staleRecords = 0;
|
|
1708
|
+
for (const userId of allUserIds) {
|
|
1709
|
+
const userRecord = await this.storage.getUserRecord(userId);
|
|
1710
|
+
if (!userRecord)
|
|
1711
|
+
continue;
|
|
1712
|
+
totalUsers++;
|
|
1713
|
+
for (const [, deviceRecord] of userRecord.devices.entries()) {
|
|
1714
|
+
totalDevices++;
|
|
1715
|
+
// Check if device record is stale (no sessions and old)
|
|
1716
|
+
const hasCurrentSession = deviceRecord.session?.currentSession != null;
|
|
1717
|
+
const archivedSessionCount = deviceRecord.session
|
|
1718
|
+
? Object.keys(deviceRecord.session.archivedSessions).length
|
|
1719
|
+
: 0;
|
|
1720
|
+
const hasNoSessions = !hasCurrentSession && archivedSessionCount === 0;
|
|
1721
|
+
const isOld = now - deviceRecord.createdAt > this.config.maxLatency;
|
|
1722
|
+
if (hasNoSessions && isOld) {
|
|
1723
|
+
staleRecords++;
|
|
1724
|
+
}
|
|
1725
|
+
// Count active session and check if expired
|
|
1726
|
+
if (hasCurrentSession) {
|
|
1727
|
+
totalActiveSessions++;
|
|
1728
|
+
const createdAt = deviceRecord.session.metadata?.createdAt ?? 0;
|
|
1729
|
+
const sessionAge = now - createdAt;
|
|
1730
|
+
if (sessionAge > this.config.maxRecv) {
|
|
1731
|
+
expiredSessions++;
|
|
1732
|
+
}
|
|
1733
|
+
}
|
|
1734
|
+
// Count archived sessions and check for expired ones
|
|
1735
|
+
if (deviceRecord.session) {
|
|
1736
|
+
for (const archivedSession of Object.values(deviceRecord.session.archivedSessions)) {
|
|
1737
|
+
if (!archivedSession)
|
|
1738
|
+
continue;
|
|
1739
|
+
totalInactiveSessions++;
|
|
1740
|
+
// Archived sessions don't have their own createdAt - use the session record's
|
|
1741
|
+
const createdAt = deviceRecord.session.metadata?.createdAt ?? 0;
|
|
1742
|
+
const sessionAge = now - createdAt;
|
|
1743
|
+
if (sessionAge > this.config.maxRecv) {
|
|
1744
|
+
expiredSessions++;
|
|
1745
|
+
}
|
|
1746
|
+
}
|
|
1747
|
+
}
|
|
1748
|
+
}
|
|
1749
|
+
}
|
|
1750
|
+
return {
|
|
1751
|
+
totalUsers,
|
|
1752
|
+
totalDevices,
|
|
1753
|
+
totalActiveSessions,
|
|
1754
|
+
totalInactiveSessions,
|
|
1755
|
+
expiredSessions,
|
|
1756
|
+
staleRecords,
|
|
1757
|
+
};
|
|
1758
|
+
}
|
|
1759
|
+
}
|
|
1760
|
+
//# sourceMappingURL=manager.js.map
|