@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,1506 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SignalServiceCipher - Cipher coordination for Signal Protocol
|
|
3
|
+
*
|
|
4
|
+
* @layer 1 - API
|
|
5
|
+
*
|
|
6
|
+
* Public coordination surface:
|
|
7
|
+
* - `decrypt(envelope)` → DecryptedEnvelope
|
|
8
|
+
* - `encrypt(recipientId, content)` → SendResult
|
|
9
|
+
*
|
|
10
|
+
* Separates cipher coordination (encrypt/decrypt routing) from lifecycle
|
|
11
|
+
* management (sessions, keys, hooks, subscriptions) in SignalProtocolClient.
|
|
12
|
+
*
|
|
13
|
+
* @see https://signal.org/docs/specifications/sesame/
|
|
14
|
+
*/
|
|
15
|
+
import AsyncLock from 'async-lock';
|
|
16
|
+
import { EncryptionError, EncryptionErrorCode } from '../types/index.js';
|
|
17
|
+
import { SealedSenderAuthError } from '../types/errors.js';
|
|
18
|
+
import { base64ToBytes } from '../internal/crypto/index.js';
|
|
19
|
+
import { recordServerClockSample } from '../server-clock.js';
|
|
20
|
+
import { ProtocolAddress } from '../types/address.js';
|
|
21
|
+
import { defaultSignalLogger } from '../logger.js';
|
|
22
|
+
import { isGroupId, extractGroupId } from '../internal/groups/index.js';
|
|
23
|
+
import { createDefaultSignalContentAdapter, } from './content-adapter.js';
|
|
24
|
+
import * as CryptoUtils from '../internal/crypto/index.js';
|
|
25
|
+
import { withRetry } from '../utils/retry.js';
|
|
26
|
+
import { prepareMediaAttachmentUpload, serializeMediaAttachmentMessage } from '../media/index.js';
|
|
27
|
+
import { UnidentifiedAccessMode, } from '../profile/contact-state.js';
|
|
28
|
+
export function sortEnvelopesForDecryption(envelopes) {
|
|
29
|
+
return [...envelopes].sort((a, b) => {
|
|
30
|
+
// Treat undefined messageType as non-prekey (ciphertext comes after prekey_bundle)
|
|
31
|
+
const aIsPreKey = a.messageType === 'prekey_bundle' ? 0 : 1;
|
|
32
|
+
const bIsPreKey = b.messageType === 'prekey_bundle' ? 0 : 1;
|
|
33
|
+
return aIsPreKey - bIsPreKey;
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Detect actual message type from ciphertext for envelope metadata
|
|
38
|
+
*
|
|
39
|
+
* PreKeyMessages (first messages) should have messageType: 'prekey_bundle'
|
|
40
|
+
* Regular ratchet messages should have messageType: 'ciphertext'
|
|
41
|
+
*
|
|
42
|
+
* @param ciphertext - The encrypted message content (string or Uint8Array)
|
|
43
|
+
* @returns 'prekey_bundle' for PreKeyMessages, 'ciphertext' for regular messages
|
|
44
|
+
*/
|
|
45
|
+
function getEnvelopeMessageType(ciphertext) {
|
|
46
|
+
const text = typeof ciphertext === 'string' ? ciphertext : new TextDecoder().decode(ciphertext);
|
|
47
|
+
// Binary protobuf format: base64 decode, check first protobuf tag
|
|
48
|
+
try {
|
|
49
|
+
const bytes = CryptoUtils.base64ToBytes(text);
|
|
50
|
+
if (bytes.length >= 2) {
|
|
51
|
+
const firstTag = bytes[1];
|
|
52
|
+
// PreKeySignalMessage: first tag is 0x08 (field 1 uint32) or 0x12 (field 2 bytes)
|
|
53
|
+
if (firstTag === 0x08 || firstTag === 0x12) {
|
|
54
|
+
return 'prekey_bundle';
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
// Not valid base64 binary
|
|
60
|
+
}
|
|
61
|
+
return 'ciphertext';
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Detect if an error is a stale session error from the server
|
|
65
|
+
*
|
|
66
|
+
* The relay returns STALE_DEVICE when a PreKeyMessage uses an outdated
|
|
67
|
+
* registration ID.
|
|
68
|
+
*
|
|
69
|
+
* This SDK validates registration IDs at the relay boundary. Stale-prekey
|
|
70
|
+
* detection remains client-side through authentication failure and retry.
|
|
71
|
+
*
|
|
72
|
+
* @param error - The error to check
|
|
73
|
+
* @returns True if error indicates stale session requiring bundle refresh
|
|
74
|
+
*/
|
|
75
|
+
function isStaleSessionError(error) {
|
|
76
|
+
if (error && typeof error === 'object' && 'data' in error) {
|
|
77
|
+
const data = error.data;
|
|
78
|
+
if (data && typeof data === 'object' && 'code' in data) {
|
|
79
|
+
const code = data.code;
|
|
80
|
+
return code === 'STALE_DEVICE';
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Detect 409 mismatched devices error from V2 multi-recipient send.
|
|
87
|
+
*
|
|
88
|
+
* Server returns this when the device list in the request doesn't match
|
|
89
|
+
* the recipient's current device list (device added/removed since last check).
|
|
90
|
+
* Our Convex server throws errors with 'MISMATCHED_DEVICES' in the message.
|
|
91
|
+
*
|
|
92
|
+
*/
|
|
93
|
+
function isMismatchedDevicesError(message) {
|
|
94
|
+
return message.includes('MISMATCHED_DEVICES');
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Detect 410 stale sessions error from V2 multi-recipient send.
|
|
98
|
+
*
|
|
99
|
+
* Server returns this when registration IDs in the request don't match
|
|
100
|
+
* (device was reinstalled). Sessions need to be archived and re-established.
|
|
101
|
+
* Our Convex server throws errors with 'STALE_DEVICE' in the message.
|
|
102
|
+
*
|
|
103
|
+
*/
|
|
104
|
+
function isStaleSessionV2Error(message) {
|
|
105
|
+
return message.includes('STALE_DEVICE');
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* SignalServiceCipher - Routes encryption and decryption to appropriate ciphers
|
|
109
|
+
*
|
|
110
|
+
* Handles:
|
|
111
|
+
* - Pairwise messages via SESAME/Double Ratchet
|
|
112
|
+
* - Group messages via Sender Keys
|
|
113
|
+
* - Binary content with two-layer encryption (AES-GCM + Signal Protocol)
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* ```typescript
|
|
117
|
+
* // Created by SignalProtocolClient - not instantiated directly
|
|
118
|
+
* const cipher = new SignalServiceCipher(userId, deviceId, sesameManager, ...);
|
|
119
|
+
*
|
|
120
|
+
* // Decrypt incoming envelope
|
|
121
|
+
* const decrypted = await cipher.decrypt(envelope);
|
|
122
|
+
*
|
|
123
|
+
* // Encrypt outgoing message
|
|
124
|
+
* const result = await cipher.encrypt('bob', 'Hello!');
|
|
125
|
+
* ```
|
|
126
|
+
*/
|
|
127
|
+
export class SignalServiceCipher {
|
|
128
|
+
userId;
|
|
129
|
+
deviceId;
|
|
130
|
+
sesameManager;
|
|
131
|
+
senderKeyManager;
|
|
132
|
+
storage;
|
|
133
|
+
relay;
|
|
134
|
+
remoteObjectStore;
|
|
135
|
+
contentAdapter;
|
|
136
|
+
logger;
|
|
137
|
+
lock = new AsyncLock();
|
|
138
|
+
sessionEstablisher;
|
|
139
|
+
staleSessionRefresher;
|
|
140
|
+
sealedSenderProvider;
|
|
141
|
+
contactProfileStateStore;
|
|
142
|
+
endorsementManager;
|
|
143
|
+
endorsementRefresher;
|
|
144
|
+
groupSecretParamsProvider;
|
|
145
|
+
constructor(userId, deviceId, sesameManager, senderKeyManager, storage, relay, remoteObjectStore, contentAdapter, logger = defaultSignalLogger) {
|
|
146
|
+
this.userId = userId;
|
|
147
|
+
this.deviceId = deviceId;
|
|
148
|
+
this.sesameManager = sesameManager;
|
|
149
|
+
this.senderKeyManager = senderKeyManager;
|
|
150
|
+
this.storage = storage;
|
|
151
|
+
this.relay = relay;
|
|
152
|
+
this.remoteObjectStore = remoteObjectStore;
|
|
153
|
+
this.contentAdapter = contentAdapter;
|
|
154
|
+
this.logger = logger;
|
|
155
|
+
}
|
|
156
|
+
getResolvedContentAdapter() {
|
|
157
|
+
return this.contentAdapter ?? createDefaultSignalContentAdapter();
|
|
158
|
+
}
|
|
159
|
+
getDirectConversationId(recipientUserId) {
|
|
160
|
+
const sortedIds = [this.userId, recipientUserId].sort();
|
|
161
|
+
return `dm:${sortedIds[0]}_${sortedIds[1]}`;
|
|
162
|
+
}
|
|
163
|
+
buildSentSyncTranscript(conversationId, plaintextBytes, timestamp, recipientUserId) {
|
|
164
|
+
return this.getResolvedContentAdapter().serializeSentTranscript({
|
|
165
|
+
conversationId,
|
|
166
|
+
serializedContent: plaintextBytes,
|
|
167
|
+
timestamp,
|
|
168
|
+
recipientUserId,
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
encodeLosslessPlaintext(plaintextBytes) {
|
|
172
|
+
const text = new TextDecoder().decode(plaintextBytes);
|
|
173
|
+
const roundTrip = new TextEncoder().encode(text);
|
|
174
|
+
if (roundTrip.length === plaintextBytes.length &&
|
|
175
|
+
roundTrip.every((byte, index) => byte === plaintextBytes[index])) {
|
|
176
|
+
return text;
|
|
177
|
+
}
|
|
178
|
+
return CryptoUtils.bytesToBase64(plaintextBytes);
|
|
179
|
+
}
|
|
180
|
+
async uploadSyncMessages(syncMessages) {
|
|
181
|
+
if (!this.relay || syncMessages.length === 0) {
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
for (const syncMsg of syncMessages) {
|
|
185
|
+
await this.relay.send({
|
|
186
|
+
targetUserId: syncMsg.recipientUserId,
|
|
187
|
+
targetDeviceId: syncMsg.recipientDeviceId,
|
|
188
|
+
senderUserId: this.userId,
|
|
189
|
+
senderDeviceId: this.deviceId,
|
|
190
|
+
ciphertext: typeof syncMsg.ciphertext === 'string'
|
|
191
|
+
? syncMsg.ciphertext
|
|
192
|
+
: CryptoUtils.bytesToBase64(syncMsg.ciphertext),
|
|
193
|
+
messageType: getEnvelopeMessageType(syncMsg.ciphertext),
|
|
194
|
+
timestamp: syncMsg.timestamp,
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
async sendSyncTranscriptToLocalOtherDevices(conversationId, plaintextBytes, timestamp, recipientUserId) {
|
|
199
|
+
const transcriptBytes = this.buildSentSyncTranscript(conversationId, plaintextBytes, timestamp, recipientUserId);
|
|
200
|
+
await this.sendSyncPayloadToLocalOtherDevices(transcriptBytes, timestamp);
|
|
201
|
+
}
|
|
202
|
+
async sendSyncPayloadToLocalOtherDevices(payloadBytes, timestamp) {
|
|
203
|
+
if (!this.relay) {
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
const syncMessages = await this.sesameManager.sendToLocalOtherDevices(payloadBytes, {
|
|
207
|
+
clientTimestamp: timestamp,
|
|
208
|
+
includeSyncMessages: false,
|
|
209
|
+
});
|
|
210
|
+
await this.uploadSyncMessages(syncMessages);
|
|
211
|
+
}
|
|
212
|
+
async sendReadSyncToLocalOtherDevices(entries) {
|
|
213
|
+
if (entries.length === 0) {
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
const timestamp = Date.now();
|
|
217
|
+
const payloadBytes = this.getResolvedContentAdapter().serializeReadSync(entries);
|
|
218
|
+
await this.sendSyncPayloadToLocalOtherDevices(payloadBytes, timestamp);
|
|
219
|
+
}
|
|
220
|
+
async sendViewOnceOpenSyncToLocalOtherDevices(entry) {
|
|
221
|
+
const timestamp = Date.now();
|
|
222
|
+
const payloadBytes = this.getResolvedContentAdapter().serializeViewOnceOpenSync(entry);
|
|
223
|
+
await this.sendSyncPayloadToLocalOtherDevices(payloadBytes, timestamp);
|
|
224
|
+
}
|
|
225
|
+
async sendMediaAttachmentDeleteSyncToLocalOtherDevices(entry) {
|
|
226
|
+
const payloadBytes = this.getResolvedContentAdapter().serializeMediaAttachmentDeleteSync(entry);
|
|
227
|
+
await this.sendSyncPayloadToLocalOtherDevices(payloadBytes, entry.deletedAt);
|
|
228
|
+
}
|
|
229
|
+
async sendConfigurationSyncToLocalOtherDevices(configuration) {
|
|
230
|
+
const timestamp = Date.now();
|
|
231
|
+
const payloadBytes = this.getResolvedContentAdapter().serializeConfigurationSync(configuration);
|
|
232
|
+
await this.sendSyncPayloadToLocalOtherDevices(payloadBytes, timestamp);
|
|
233
|
+
}
|
|
234
|
+
async sendUsernameStateSyncToLocalOtherDevices(usernameState) {
|
|
235
|
+
const timestamp = Date.now();
|
|
236
|
+
const payloadBytes = this.getResolvedContentAdapter().serializeUsernameStateSync(usernameState);
|
|
237
|
+
await this.sendSyncPayloadToLocalOtherDevices(payloadBytes, timestamp);
|
|
238
|
+
}
|
|
239
|
+
async sendRecipientUsernameSyncToLocalOtherDevices(recipientUsername) {
|
|
240
|
+
const payloadBytes = this.getResolvedContentAdapter().serializeRecipientUsernameSync(recipientUsername);
|
|
241
|
+
await this.sendSyncPayloadToLocalOtherDevices(payloadBytes, recipientUsername.learnedAt);
|
|
242
|
+
}
|
|
243
|
+
async sendVerificationStateSyncToLocalOtherDevices(verificationState) {
|
|
244
|
+
const payloadBytes = this.getResolvedContentAdapter().serializeVerificationStateSync(verificationState);
|
|
245
|
+
await this.sendSyncPayloadToLocalOtherDevices(payloadBytes, verificationState.changedAt);
|
|
246
|
+
}
|
|
247
|
+
async sendTaskNotificationAckSyncToLocalOtherDevices(ack) {
|
|
248
|
+
const payloadBytes = this.getResolvedContentAdapter().serializeTaskNotificationAckSync(ack);
|
|
249
|
+
await this.sendSyncPayloadToLocalOtherDevices(payloadBytes, ack.acknowledgedAt);
|
|
250
|
+
}
|
|
251
|
+
async sendBlockedRecipientsSyncToLocalOtherDevices(blocked) {
|
|
252
|
+
const payloadBytes = this.getResolvedContentAdapter().serializeBlockedRecipientsSync(blocked);
|
|
253
|
+
await this.sendSyncPayloadToLocalOtherDevices(payloadBytes, blocked.syncedAt);
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Set the session establisher callback
|
|
257
|
+
* Called by SignalProtocolClient after construction to inject session establishment logic
|
|
258
|
+
*/
|
|
259
|
+
setSessionEstablisher(establisher) {
|
|
260
|
+
this.sessionEstablisher = establisher;
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Set the stale session refresher callback
|
|
264
|
+
* Called by SignalProtocolClient after construction to inject session refresh logic
|
|
265
|
+
*
|
|
266
|
+
* Used when server returns STALE_DEVICE errors (device reinstalled).
|
|
267
|
+
*/
|
|
268
|
+
setStaleSessionRefresher(refresher) {
|
|
269
|
+
this.staleSessionRefresher = refresher;
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Set the sealed sender provider callback
|
|
273
|
+
* Called by SignalProtocolClient after construction to inject sealed sender support.
|
|
274
|
+
*
|
|
275
|
+
* Provides the sender certificate and identity key needed for sealing messages.
|
|
276
|
+
*/
|
|
277
|
+
setSealedSenderProvider(provider) {
|
|
278
|
+
this.sealedSenderProvider = provider;
|
|
279
|
+
}
|
|
280
|
+
setContactProfileStateStore(store) {
|
|
281
|
+
this.contactProfileStateStore = store;
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Set the endorsement manager for group send endorsement-based auth.
|
|
285
|
+
*
|
|
286
|
+
* When set, group messages will prefer endorsement tokens over UAK-based
|
|
287
|
+
* sealed sender. This avoids needing the recipient's profile key for
|
|
288
|
+
* group messages and provides stronger group membership verification.
|
|
289
|
+
*
|
|
290
|
+
*/
|
|
291
|
+
setEndorsementManager(manager) {
|
|
292
|
+
this.endorsementManager = manager;
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Set the endorsement refresher callback.
|
|
296
|
+
*
|
|
297
|
+
* Called before V2 multi-recipient sends when endorsements are missing or
|
|
298
|
+
* expiring soon. The implementation fetches endorsements from the server
|
|
299
|
+
* and caches them via EndorsementManager.
|
|
300
|
+
*
|
|
301
|
+
*/
|
|
302
|
+
setEndorsementRefresher(refresher) {
|
|
303
|
+
this.endorsementRefresher = refresher;
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Set the group secret params provider callback.
|
|
307
|
+
*
|
|
308
|
+
* Required for endorsement-based sealed sender in groups. The provider
|
|
309
|
+
* looks up GroupSecretParams from the local database for a given group ID.
|
|
310
|
+
*
|
|
311
|
+
* @param provider - Async callback returning GroupSecretParams or null
|
|
312
|
+
*/
|
|
313
|
+
setGroupSecretParamsProvider(provider) {
|
|
314
|
+
this.groupSecretParamsProvider = provider;
|
|
315
|
+
}
|
|
316
|
+
// ============================================================================
|
|
317
|
+
// Public API
|
|
318
|
+
// ============================================================================
|
|
319
|
+
/**
|
|
320
|
+
* Decrypt incoming envelope - routes to appropriate cipher
|
|
321
|
+
*
|
|
322
|
+
* Routes based on envelope type:
|
|
323
|
+
* - ciphertext + groupId → Group cipher (Sender Keys)
|
|
324
|
+
* - otherwise → Pairwise cipher (SESAME/Double Ratchet)
|
|
325
|
+
*
|
|
326
|
+
* @param envelope - Encrypted envelope from relay
|
|
327
|
+
* @returns Decrypted envelope ready for ContentManager
|
|
328
|
+
* @throws {EncryptionError} DECRYPTION_FAILED if decryption fails
|
|
329
|
+
*
|
|
330
|
+
* @see https://signal.org/docs/specifications/sesame/
|
|
331
|
+
*/
|
|
332
|
+
async decrypt(envelope, sealedSenderConfig) {
|
|
333
|
+
// Handle sealed sender (unidentified_sender) envelopes by unsealing first
|
|
334
|
+
if (envelope.messageType === 'unidentified_sender') {
|
|
335
|
+
if (!sealedSenderConfig || sealedSenderConfig.trustRoots.length === 0) {
|
|
336
|
+
throw new EncryptionError('Received sealed sender message but no trust roots configured', EncryptionErrorCode.INVALID_CIPHERTEXT, { messageType: envelope.messageType });
|
|
337
|
+
}
|
|
338
|
+
const { unsealMessage, reconstructEnvelope } = await import('./sealed-sender-ops.js');
|
|
339
|
+
// Get recipient's X25519 identity private key for unsealing
|
|
340
|
+
const identityKeyPair = await this.storage.getIdentityKey();
|
|
341
|
+
if (!identityKeyPair) {
|
|
342
|
+
throw new EncryptionError('No identity key pair for sealed sender decryption', EncryptionErrorCode.DECRYPTION_FAILED);
|
|
343
|
+
}
|
|
344
|
+
// Convert branded Base64 private key to Uint8Array for sealed sender
|
|
345
|
+
const recipientPrivateKeyBytes = base64ToBytes(identityKeyPair.dhKey.privateKey);
|
|
346
|
+
const ciphertextStr = typeof envelope.ciphertext === 'string'
|
|
347
|
+
? envelope.ciphertext
|
|
348
|
+
: CryptoUtils.bytesToBase64(envelope.ciphertext);
|
|
349
|
+
const unsealed = await unsealMessage(ciphertextStr, recipientPrivateKeyBytes, this.userId, this.deviceId, sealedSenderConfig, this.logger);
|
|
350
|
+
// Reconstruct envelope with revealed sender identity
|
|
351
|
+
const innerEnvelope = reconstructEnvelope(envelope, unsealed);
|
|
352
|
+
// Recursively decrypt the inner message (now a standard ciphertext)
|
|
353
|
+
return this.decrypt(innerEnvelope);
|
|
354
|
+
}
|
|
355
|
+
// Validate message type before processing
|
|
356
|
+
// Server only sends the 5 envelope types; client-to-client types (typing_indicator,
|
|
357
|
+
// delivery_receipt, sender_key_distribution) are encrypted Content inside ciphertext.
|
|
358
|
+
const validMessageTypes = [
|
|
359
|
+
'prekey_bundle',
|
|
360
|
+
'ciphertext',
|
|
361
|
+
'plaintext_content',
|
|
362
|
+
'server_delivery_receipt',
|
|
363
|
+
'unidentified_sender',
|
|
364
|
+
];
|
|
365
|
+
if (!validMessageTypes.includes(envelope.messageType)) {
|
|
366
|
+
throw new EncryptionError(`Unknown message type: ${envelope.messageType}`, EncryptionErrorCode.INVALID_CIPHERTEXT, { messageType: envelope.messageType, senderId: envelope.senderUserId });
|
|
367
|
+
}
|
|
368
|
+
const lockKey = `decrypt:${envelope.senderUserId}:${envelope.senderDeviceId}`;
|
|
369
|
+
return this.lock.acquire(lockKey, async () => {
|
|
370
|
+
this.logger.debug('Handling incoming envelope', {
|
|
371
|
+
category: 'E2EE',
|
|
372
|
+
data: {
|
|
373
|
+
envelopeId: envelope.id,
|
|
374
|
+
senderId: envelope.senderUserId,
|
|
375
|
+
senderDeviceId: envelope.senderDeviceId,
|
|
376
|
+
messageType: envelope.messageType,
|
|
377
|
+
groupId: envelope.groupId,
|
|
378
|
+
},
|
|
379
|
+
});
|
|
380
|
+
let plaintext;
|
|
381
|
+
// Route to appropriate decryption based on context
|
|
382
|
+
// Group messages arrive as 'ciphertext' with groupId set (the server doesn't
|
|
383
|
+
// distinguish group vs pairwise — both are ciphertext envelopes)
|
|
384
|
+
if (envelope.groupId && envelope.messageType === 'ciphertext') {
|
|
385
|
+
// Group message encrypted with Sender Keys
|
|
386
|
+
plaintext = await this.decryptGroup(envelope);
|
|
387
|
+
}
|
|
388
|
+
else {
|
|
389
|
+
// Pairwise message - use SESAME for session convergence
|
|
390
|
+
const sesameMessage = this.toSesameMessage(envelope);
|
|
391
|
+
plaintext = await this.decryptPairwise(sesameMessage);
|
|
392
|
+
}
|
|
393
|
+
// Create decrypted envelope for hook
|
|
394
|
+
const receivedAt = Date.now();
|
|
395
|
+
const inspectedContent = this.getResolvedContentAdapter().inspectContent(plaintext);
|
|
396
|
+
// For DMs, compute canonical conversation ID: dm:${sorted(user1, user2)}
|
|
397
|
+
// Groups use their group ID directly. Sent sync transcripts override this
|
|
398
|
+
// with the transcript's destination conversation.
|
|
399
|
+
const conversationId = inspectedContent?.conversationId ||
|
|
400
|
+
envelope.groupId ||
|
|
401
|
+
this.getDirectConversationId(envelope.senderUserId);
|
|
402
|
+
// Extract client timestamp from decrypted content
|
|
403
|
+
// Text messages: dataMessage.timestamp, Attachments: timestamp at top level
|
|
404
|
+
let clientTimestamp = receivedAt;
|
|
405
|
+
let hasContentTimestamp = false;
|
|
406
|
+
const contentTimestamp = inspectedContent?.timestamp;
|
|
407
|
+
if (typeof contentTimestamp === 'number') {
|
|
408
|
+
clientTimestamp = contentTimestamp;
|
|
409
|
+
hasContentTimestamp = true;
|
|
410
|
+
}
|
|
411
|
+
// Replay attack prevention
|
|
412
|
+
// Validate envelope.timestamp matches content timestamp after decryption
|
|
413
|
+
if (envelope.timestamp !== undefined && hasContentTimestamp) {
|
|
414
|
+
if (envelope.timestamp !== clientTimestamp) {
|
|
415
|
+
throw new EncryptionError(`Timestamp mismatch: envelope=${envelope.timestamp}, content=${clientTimestamp}. Potential replay attack.`, EncryptionErrorCode.REPLAY_DETECTED);
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
recordServerClockSample(envelope.serverTimestamp, receivedAt);
|
|
419
|
+
const decryptedEnvelope = {
|
|
420
|
+
messageId: envelope.id || `${envelope.senderUserId}-${receivedAt}`,
|
|
421
|
+
sessionId: ProtocolAddress.toString(ProtocolAddress.create(envelope.senderUserId, envelope.senderDeviceId)),
|
|
422
|
+
senderId: envelope.senderUserId,
|
|
423
|
+
senderDeviceId: envelope.senderDeviceId,
|
|
424
|
+
conversationId,
|
|
425
|
+
content: plaintext,
|
|
426
|
+
timestamp: clientTimestamp, // Use client timestamp for receipt matching
|
|
427
|
+
serverTimestamp: envelope.serverTimestamp,
|
|
428
|
+
receivedAt,
|
|
429
|
+
isGroup: !!envelope.groupId,
|
|
430
|
+
messageType: envelope.messageType,
|
|
431
|
+
};
|
|
432
|
+
return decryptedEnvelope;
|
|
433
|
+
});
|
|
434
|
+
}
|
|
435
|
+
/**
|
|
436
|
+
* Encrypt outgoing message - routes based on recipient type
|
|
437
|
+
*
|
|
438
|
+
* Routes based on recipientId:
|
|
439
|
+
* - Group ID (prefixed) → encryptToGroup (Sender Keys)
|
|
440
|
+
* - Binary content with mimeType → encryptBlob (two-layer encryption)
|
|
441
|
+
* - User ID → encryptToUser (SESAME)
|
|
442
|
+
*
|
|
443
|
+
* @param recipientId - User ID or group ID (groups use Signal V2 prefix)
|
|
444
|
+
* @param content - Uint8Array bytes to encrypt and send
|
|
445
|
+
* @param options - Optional send options (mimeType for binary content, etc.)
|
|
446
|
+
* @returns SendResult with messageId, timestamp, and device count
|
|
447
|
+
*
|
|
448
|
+
* @see https://signal.org/docs/specifications/sesame/
|
|
449
|
+
*/
|
|
450
|
+
async encrypt(recipientId, content, options) {
|
|
451
|
+
const lockKey = `encrypt:${recipientId}`;
|
|
452
|
+
return this.lock.acquire(lockKey, async () => {
|
|
453
|
+
// 1. Route binary file data (Uint8Array with isBinary flag) to blob encryption
|
|
454
|
+
if (options?.isBinary) {
|
|
455
|
+
return this.encryptBinaryAttachment(recipientId, content, options);
|
|
456
|
+
}
|
|
457
|
+
// 2. Detect recipient type (group vs user)
|
|
458
|
+
if (isGroupId(recipientId)) {
|
|
459
|
+
return this.encryptToGroup(recipientId, content, options);
|
|
460
|
+
}
|
|
461
|
+
// 3. Send to user (existing SESAME path)
|
|
462
|
+
return this.encryptToUser(recipientId, content, options);
|
|
463
|
+
});
|
|
464
|
+
}
|
|
465
|
+
/**
|
|
466
|
+
* Encrypt and upload attachment data without sending a standalone message.
|
|
467
|
+
*/
|
|
468
|
+
async uploadAttachment(data, options) {
|
|
469
|
+
const lockKey = `attachment-upload:${options.mimeType}`;
|
|
470
|
+
return this.lock.acquire(lockKey, async () => this.prepareAttachmentUpload(data, options));
|
|
471
|
+
}
|
|
472
|
+
// ============================================================================
|
|
473
|
+
// PRIVATE - Decryption
|
|
474
|
+
// ============================================================================
|
|
475
|
+
/**
|
|
476
|
+
* Convert Envelope to SesameMessage for SESAME receive path
|
|
477
|
+
*/
|
|
478
|
+
toSesameMessage(envelope) {
|
|
479
|
+
// SessionID format is "userId:deviceId" (from ProtocolAddress.toString())
|
|
480
|
+
const sessionId = `${envelope.senderUserId}:${envelope.senderDeviceId}`;
|
|
481
|
+
return {
|
|
482
|
+
senderUserId: envelope.senderUserId,
|
|
483
|
+
senderDeviceId: envelope.senderDeviceId,
|
|
484
|
+
recipientUserId: this.userId, // We are the recipient
|
|
485
|
+
recipientDeviceId: this.deviceId,
|
|
486
|
+
sessionId,
|
|
487
|
+
// Ciphertext is base64-encoded on relay, convert back to Uint8Array
|
|
488
|
+
// SESAME will deserialize it back to Ciphertext (branded base64 string) internally
|
|
489
|
+
ciphertext: typeof envelope.ciphertext === 'string'
|
|
490
|
+
? base64ToBytes(envelope.ciphertext)
|
|
491
|
+
: envelope.ciphertext,
|
|
492
|
+
isInitiating: envelope.messageType === 'prekey_bundle',
|
|
493
|
+
initHeader: null, // Extracted from ciphertext by SESAME
|
|
494
|
+
timestamp: envelope.timestamp,
|
|
495
|
+
};
|
|
496
|
+
}
|
|
497
|
+
/**
|
|
498
|
+
* Decrypt a pairwise message via SESAME
|
|
499
|
+
*
|
|
500
|
+
* Public for use by SignalProtocolClient.receive() which takes raw SesameMessage.
|
|
501
|
+
*
|
|
502
|
+
* @throws {EncryptionError} DECRYPTION_FAILED if decryption fails
|
|
503
|
+
*/
|
|
504
|
+
async decryptPairwise(sesameMessage) {
|
|
505
|
+
try {
|
|
506
|
+
const plaintextBytes = await this.sesameManager.receive(sesameMessage);
|
|
507
|
+
const plaintext = this.encodeLosslessPlaintext(plaintextBytes);
|
|
508
|
+
this.logger.debug('Message received and decrypted', {
|
|
509
|
+
category: 'E2EE',
|
|
510
|
+
data: {
|
|
511
|
+
senderUserId: sesameMessage.senderUserId,
|
|
512
|
+
senderDeviceId: sesameMessage.senderDeviceId,
|
|
513
|
+
},
|
|
514
|
+
});
|
|
515
|
+
return plaintext;
|
|
516
|
+
}
|
|
517
|
+
catch (error) {
|
|
518
|
+
// Preserve EncryptionError for client-layer handling (e.g., PREKEY_NOT_FOUND triggers key rotation)
|
|
519
|
+
if (error instanceof EncryptionError) {
|
|
520
|
+
throw error;
|
|
521
|
+
}
|
|
522
|
+
throw new EncryptionError('Failed to decrypt message', EncryptionErrorCode.DECRYPTION_FAILED, {
|
|
523
|
+
originalError: error,
|
|
524
|
+
senderUserId: sesameMessage.senderUserId,
|
|
525
|
+
});
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
/**
|
|
529
|
+
* Decrypt a group message via Sender Keys
|
|
530
|
+
*
|
|
531
|
+
* @throws {EncryptionError} DECRYPTION_FAILED if decryption fails
|
|
532
|
+
*/
|
|
533
|
+
async decryptGroup(envelope) {
|
|
534
|
+
// Get the framed SenderKeyMessage bytes
|
|
535
|
+
let framedBytes;
|
|
536
|
+
if (typeof envelope.ciphertext === 'string') {
|
|
537
|
+
// Base64-encoded framed SenderKeyMessage
|
|
538
|
+
framedBytes = CryptoUtils.base64ToBytes(envelope.ciphertext);
|
|
539
|
+
}
|
|
540
|
+
else {
|
|
541
|
+
framedBytes = envelope.ciphertext;
|
|
542
|
+
}
|
|
543
|
+
try {
|
|
544
|
+
const plaintext = await this.senderKeyManager.decryptGroupMessage(envelope.groupId, envelope.senderUserId, envelope.senderDeviceId, framedBytes);
|
|
545
|
+
this.logger.debug('Decrypted group message', {
|
|
546
|
+
category: 'E2EE',
|
|
547
|
+
data: {
|
|
548
|
+
groupId: envelope.groupId,
|
|
549
|
+
senderId: envelope.senderUserId,
|
|
550
|
+
},
|
|
551
|
+
});
|
|
552
|
+
return plaintext;
|
|
553
|
+
}
|
|
554
|
+
catch (error) {
|
|
555
|
+
const err = error;
|
|
556
|
+
if (err.message?.includes('SENDER_KEY_NOT_FOUND')) {
|
|
557
|
+
throw new EncryptionError(`No sender key from ${envelope.senderUserId} for group ${envelope.groupId} - request key distribution`, EncryptionErrorCode.SESSION_NOT_FOUND, { originalError: err });
|
|
558
|
+
}
|
|
559
|
+
if (err.message?.includes('INVALID_SIGNATURE')) {
|
|
560
|
+
throw new EncryptionError(`Invalid signature on group message from ${envelope.senderUserId}`, EncryptionErrorCode.DECRYPTION_FAILED, { originalError: err });
|
|
561
|
+
}
|
|
562
|
+
if (err.message?.includes('MESSAGE_TOO_OLD')) {
|
|
563
|
+
throw new EncryptionError('Cannot decrypt old group message (forward secrecy)', EncryptionErrorCode.DECRYPTION_FAILED, { originalError: err });
|
|
564
|
+
}
|
|
565
|
+
throw new EncryptionError(`Failed to decrypt group message from ${envelope.senderUserId}`, EncryptionErrorCode.DECRYPTION_FAILED, { originalError: err });
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
// ============================================================================
|
|
569
|
+
// PRIVATE - Encryption
|
|
570
|
+
// ============================================================================
|
|
571
|
+
/**
|
|
572
|
+
* Ensure sessions exist with a recipient user
|
|
573
|
+
*
|
|
574
|
+
* Checks if any session exists with the recipient. If not, uses the session
|
|
575
|
+
* establisher callback to fetch prekey bundles and create sessions.
|
|
576
|
+
*
|
|
577
|
+
* @throws {EncryptionError} SESSION_NOT_FOUND if sessions cannot be established
|
|
578
|
+
*/
|
|
579
|
+
async ensureSessionsForUser(recipientUserId) {
|
|
580
|
+
// Check if we have any session with this user via SESAME UserRecord
|
|
581
|
+
const userRecord = await this.sesameManager.getUserRecord(recipientUserId);
|
|
582
|
+
if (userRecord && userRecord.devices.size > 0) {
|
|
583
|
+
// Check if at least one device has an active session
|
|
584
|
+
const hasActiveSession = Array.from(userRecord.devices.values()).some((device) => device.session?.currentSession !== null);
|
|
585
|
+
if (hasActiveSession) {
|
|
586
|
+
return; // Sessions exist, nothing to do
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
// No sessions exist - need to establish them
|
|
590
|
+
this.logger.debug('No session exists, auto-establishing', {
|
|
591
|
+
category: 'E2EE',
|
|
592
|
+
data: { recipientUserId, hasUserRecord: !!userRecord },
|
|
593
|
+
});
|
|
594
|
+
if (!this.sessionEstablisher) {
|
|
595
|
+
throw new EncryptionError(`No session with ${recipientUserId} and auto-establishment not configured`, EncryptionErrorCode.SESSION_NOT_FOUND, { recipientUserId });
|
|
596
|
+
}
|
|
597
|
+
if (!this.relay) {
|
|
598
|
+
throw new EncryptionError('Cannot auto-establish session: relay server not configured', EncryptionErrorCode.INITIALIZATION_FAILED, { recipientUserId });
|
|
599
|
+
}
|
|
600
|
+
try {
|
|
601
|
+
// Use retry logic for transient network failures
|
|
602
|
+
const result = await withRetry(() => this.sessionEstablisher(recipientUserId), {
|
|
603
|
+
operationName: 'establishSession',
|
|
604
|
+
maxRetries: 2,
|
|
605
|
+
baseDelay: 500,
|
|
606
|
+
});
|
|
607
|
+
if (result.establishedDevices.length === 0) {
|
|
608
|
+
throw new EncryptionError(`Recipient ${recipientUserId} has no available prekey bundles - they may not have registered encryption keys`, EncryptionErrorCode.RECIPIENT_NOT_REGISTERED, { recipientUserId, failedDevices: result.failedDevices });
|
|
609
|
+
}
|
|
610
|
+
this.logger.info('Auto-established sessions', {
|
|
611
|
+
category: 'E2EE',
|
|
612
|
+
data: {
|
|
613
|
+
recipientUserId,
|
|
614
|
+
establishedDevices: result.establishedDevices,
|
|
615
|
+
failedDevices: result.failedDevices,
|
|
616
|
+
},
|
|
617
|
+
});
|
|
618
|
+
}
|
|
619
|
+
catch (error) {
|
|
620
|
+
// Re-throw EncryptionErrors, wrap others
|
|
621
|
+
if (error instanceof EncryptionError) {
|
|
622
|
+
throw error;
|
|
623
|
+
}
|
|
624
|
+
// Check for rate limiting
|
|
625
|
+
const errorMessage = error.message?.toLowerCase() || '';
|
|
626
|
+
if (errorMessage.includes('rate limit')) {
|
|
627
|
+
throw new EncryptionError(`Rate limited while establishing session with ${recipientUserId}`, EncryptionErrorCode.PREKEY_FETCH_RATE_LIMITED, { originalError: error, recipientUserId });
|
|
628
|
+
}
|
|
629
|
+
throw new EncryptionError(`Failed to establish session with ${recipientUserId} after retries`, EncryptionErrorCode.SESSION_ESTABLISHMENT_FAILED, { originalError: error, recipientUserId });
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
/**
|
|
633
|
+
* Encrypt to a single user (all their devices) via SESAME
|
|
634
|
+
*/
|
|
635
|
+
async encryptToUser(recipientUserId, plaintextBytes, options) {
|
|
636
|
+
// Auto-establish sessions if needed (lazy session creation)
|
|
637
|
+
await this.ensureSessionsForUser(recipientUserId);
|
|
638
|
+
// SESAME multi-device encryption: encrypt for all recipient devices
|
|
639
|
+
let batch;
|
|
640
|
+
try {
|
|
641
|
+
const clientTimestamp = options?.timestamp ?? Date.now();
|
|
642
|
+
const syncPlaintext = this.buildSentSyncTranscript(this.getDirectConversationId(recipientUserId), plaintextBytes, clientTimestamp, recipientUserId);
|
|
643
|
+
batch = await this.sesameManager.send(recipientUserId, plaintextBytes, {
|
|
644
|
+
clientTimestamp,
|
|
645
|
+
syncPlaintext,
|
|
646
|
+
});
|
|
647
|
+
}
|
|
648
|
+
catch (error) {
|
|
649
|
+
// Preserve EncryptionError codes
|
|
650
|
+
if (error instanceof EncryptionError) {
|
|
651
|
+
throw error;
|
|
652
|
+
}
|
|
653
|
+
throw new EncryptionError('Failed to encrypt message for user', EncryptionErrorCode.ENCRYPTION_FAILED, { originalError: error, recipientUserId });
|
|
654
|
+
}
|
|
655
|
+
this.logger.debug('Message encrypted for user devices', {
|
|
656
|
+
category: 'E2EE',
|
|
657
|
+
data: {
|
|
658
|
+
recipientUserId,
|
|
659
|
+
deviceCount: batch.deviceMessages.length,
|
|
660
|
+
syncCount: batch.syncMessages.length,
|
|
661
|
+
},
|
|
662
|
+
});
|
|
663
|
+
// Upload messages to relay server if configured
|
|
664
|
+
let messageId = `local-${Date.now()}`;
|
|
665
|
+
let timestamp = Date.now(); // Fallback if no relay
|
|
666
|
+
if (this.relay) {
|
|
667
|
+
// Resolve sealed sender context once per send (avoid re-fetching per device)
|
|
668
|
+
const sealedSender = await this.resolveSealedSenderContext(recipientUserId);
|
|
669
|
+
// Send to each recipient device with stale session handling
|
|
670
|
+
for (const msg of batch.deviceMessages) {
|
|
671
|
+
const messageType = getEnvelopeMessageType(msg.ciphertext);
|
|
672
|
+
const ciphertextBase64 = typeof msg.ciphertext === 'string'
|
|
673
|
+
? msg.ciphertext
|
|
674
|
+
: CryptoUtils.bytesToBase64(msg.ciphertext);
|
|
675
|
+
// For PreKeyMessages, get session metadata for server-side validation
|
|
676
|
+
// Signal only validates registrationId server-side (device reinstall detection)
|
|
677
|
+
// Stale prekey detection is handled client-side via MAC failure + retry
|
|
678
|
+
let recipientRegistrationId;
|
|
679
|
+
if (messageType === 'prekey_bundle') {
|
|
680
|
+
const session = await this.sesameManager.getSession(msg.recipientUserId, msg.recipientDeviceId);
|
|
681
|
+
if (session?.currentSession) {
|
|
682
|
+
recipientRegistrationId = session.currentSession.remoteRegistrationId;
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
try {
|
|
686
|
+
const result = await this.sendToDevice(msg, ciphertextBase64, messageType, recipientRegistrationId, sealedSender, options?.contentHint, options?.clientMessageId);
|
|
687
|
+
// Use first envelope ID and serverTimestamp as the canonical values
|
|
688
|
+
if (messageId.startsWith('local-')) {
|
|
689
|
+
messageId = result.messageId;
|
|
690
|
+
timestamp = result.serverTimestamp;
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
catch (error) {
|
|
694
|
+
// Recover from a relay stale-device response.
|
|
695
|
+
if (isStaleSessionError(error) && this.staleSessionRefresher) {
|
|
696
|
+
const staleData = error.data;
|
|
697
|
+
this.logger.info('Server detected stale session, refreshing', {
|
|
698
|
+
category: 'E2EE',
|
|
699
|
+
data: {
|
|
700
|
+
code: staleData.code,
|
|
701
|
+
reason: staleData.reason,
|
|
702
|
+
recipientUserId: msg.recipientUserId,
|
|
703
|
+
recipientDeviceId: msg.recipientDeviceId,
|
|
704
|
+
},
|
|
705
|
+
});
|
|
706
|
+
// Refresh the stale session (archive + fetch fresh bundle + re-establish)
|
|
707
|
+
const refreshed = await this.staleSessionRefresher(msg.recipientUserId, msg.recipientDeviceId);
|
|
708
|
+
if (refreshed) {
|
|
709
|
+
// Re-encrypt and retry with fresh session
|
|
710
|
+
const freshBatch = await this.sesameManager.send(recipientUserId, plaintextBytes, {
|
|
711
|
+
clientTimestamp: options?.timestamp,
|
|
712
|
+
});
|
|
713
|
+
const freshMsg = freshBatch.deviceMessages.find((m) => m.recipientUserId === msg.recipientUserId &&
|
|
714
|
+
m.recipientDeviceId === msg.recipientDeviceId);
|
|
715
|
+
if (freshMsg) {
|
|
716
|
+
const freshCiphertext = typeof freshMsg.ciphertext === 'string'
|
|
717
|
+
? freshMsg.ciphertext
|
|
718
|
+
: CryptoUtils.bytesToBase64(freshMsg.ciphertext);
|
|
719
|
+
// Get fresh session metadata
|
|
720
|
+
const freshSession = await this.sesameManager.getSession(msg.recipientUserId, msg.recipientDeviceId);
|
|
721
|
+
const retryResult = await this.sendToDevice(freshMsg, freshCiphertext, getEnvelopeMessageType(freshMsg.ciphertext), freshSession?.currentSession?.remoteRegistrationId, sealedSender, options?.contentHint, options?.clientMessageId);
|
|
722
|
+
if (messageId.startsWith('local-')) {
|
|
723
|
+
messageId = retryResult.messageId;
|
|
724
|
+
timestamp = retryResult.serverTimestamp;
|
|
725
|
+
}
|
|
726
|
+
this.logger.info('Successfully sent after stale session refresh', {
|
|
727
|
+
category: 'E2EE',
|
|
728
|
+
data: {
|
|
729
|
+
recipientUserId: msg.recipientUserId,
|
|
730
|
+
recipientDeviceId: msg.recipientDeviceId,
|
|
731
|
+
},
|
|
732
|
+
});
|
|
733
|
+
continue; // Successfully sent after refresh
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
// If refresh failed or no message for device, throw original error
|
|
737
|
+
throw new EncryptionError(`Failed to refresh stale session: ${staleData.reason}`, EncryptionErrorCode.SESSION_ESTABLISHMENT_FAILED, {
|
|
738
|
+
originalError: error,
|
|
739
|
+
recipientUserId: msg.recipientUserId,
|
|
740
|
+
});
|
|
741
|
+
}
|
|
742
|
+
// Re-throw non-stale errors
|
|
743
|
+
throw error;
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
await this.uploadSyncMessages(batch.syncMessages);
|
|
747
|
+
}
|
|
748
|
+
return {
|
|
749
|
+
messageId,
|
|
750
|
+
timestamp,
|
|
751
|
+
recipientDeviceCount: batch.deviceMessages.length,
|
|
752
|
+
};
|
|
753
|
+
}
|
|
754
|
+
/**
|
|
755
|
+
* Resolve sealed sender context for a recipient.
|
|
756
|
+
*
|
|
757
|
+
* Authorization priority:
|
|
758
|
+
* 1. GroupSend endorsement token (for group messages when endorsementManager is set)
|
|
759
|
+
* 2. Per-contact mode-based UAK (existing path)
|
|
760
|
+
*
|
|
761
|
+
* Mode-aware selection for priority 2:
|
|
762
|
+
*
|
|
763
|
+
* | Mode | Behavior |
|
|
764
|
+
* |--------------|----------------------------------------------------------------|
|
|
765
|
+
* | DISABLED | Return null immediately (skip sealed sender) |
|
|
766
|
+
* | UNRESTRICTED | Use zeroed 16-byte key (no profile key needed) |
|
|
767
|
+
* | ENABLED | Derive UAK from profile key; return null if no profile key |
|
|
768
|
+
* | UNKNOWN | Use derived UAK if profile key available, else use zeroed key |
|
|
769
|
+
*
|
|
770
|
+
* Returns null if sealed sender is not enabled or recipient identity is not known.
|
|
771
|
+
* Pre-fetches the sender certificate and identity keys so they can be reused
|
|
772
|
+
* across all device messages in a send batch.
|
|
773
|
+
*
|
|
774
|
+
* @param recipientUserId - User ID of the message recipient
|
|
775
|
+
* @param groupId - Optional group ID; when provided, endorsement-based auth is attempted first
|
|
776
|
+
*
|
|
777
|
+
*/
|
|
778
|
+
async resolveSealedSenderContext(recipientUserId, groupId) {
|
|
779
|
+
if (!this.sealedSenderProvider || !this.relay?.sendUnidentified) {
|
|
780
|
+
return null;
|
|
781
|
+
}
|
|
782
|
+
try {
|
|
783
|
+
// Priority 1: GroupSend endorsement (preferred for groups)
|
|
784
|
+
// No profile key needed — endorsement tokens prove group membership via ZK credential
|
|
785
|
+
if (groupId && this.endorsementManager) {
|
|
786
|
+
try {
|
|
787
|
+
// Resolve group secret params for endorsement token generation
|
|
788
|
+
const groupSecretParams = this.groupSecretParamsProvider
|
|
789
|
+
? await this.groupSecretParamsProvider(groupId)
|
|
790
|
+
: null;
|
|
791
|
+
const endorsementToken = await this.endorsementManager.getTokenForRecipient(groupId, recipientUserId, groupSecretParams ?? undefined);
|
|
792
|
+
if (endorsementToken) {
|
|
793
|
+
const { senderCertificateBase64, senderIdentityPrivate, config } = await this.sealedSenderProvider();
|
|
794
|
+
const recipientAddress = ProtocolAddress.create(recipientUserId, 1);
|
|
795
|
+
const recipientIdentityRecord = await this.storage.getContactIdentity(recipientAddress);
|
|
796
|
+
if (recipientIdentityRecord) {
|
|
797
|
+
const recipientIdentityPublic = base64ToBytes(recipientIdentityRecord.identity.x25519PublicKey);
|
|
798
|
+
return {
|
|
799
|
+
senderCertificateBase64,
|
|
800
|
+
senderIdentityPrivate,
|
|
801
|
+
recipientIdentityPublic,
|
|
802
|
+
config,
|
|
803
|
+
auth: {
|
|
804
|
+
type: 'groupSendToken',
|
|
805
|
+
groupSendToken: endorsementToken.token,
|
|
806
|
+
},
|
|
807
|
+
};
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
catch (endorsementError) {
|
|
812
|
+
// Endorsement lookup failed — fall through to UAK path
|
|
813
|
+
this.logger.debug('Endorsement lookup failed, trying UAK', {
|
|
814
|
+
category: 'E2EE',
|
|
815
|
+
data: {
|
|
816
|
+
recipientUserId,
|
|
817
|
+
groupId,
|
|
818
|
+
error: endorsementError.message,
|
|
819
|
+
},
|
|
820
|
+
});
|
|
821
|
+
}
|
|
822
|
+
}
|
|
823
|
+
// Priority 2: Per-contact mode-based UAK (existing path)
|
|
824
|
+
// Check mode first — DISABLED skips sealed sender entirely
|
|
825
|
+
const contactStateStore = this.contactProfileStateStore;
|
|
826
|
+
if (!contactStateStore) {
|
|
827
|
+
this.logger.debug('No contact profile state store configured, using identified delivery', {
|
|
828
|
+
category: 'E2EE',
|
|
829
|
+
data: { recipientUserId, groupId },
|
|
830
|
+
});
|
|
831
|
+
return null;
|
|
832
|
+
}
|
|
833
|
+
const mode = await contactStateStore.getUnidentifiedAccessMode(recipientUserId);
|
|
834
|
+
if (mode === UnidentifiedAccessMode.DISABLED) {
|
|
835
|
+
this.logger.debug('Sealed sender disabled for recipient, using identified delivery', {
|
|
836
|
+
category: 'E2EE',
|
|
837
|
+
data: { recipientUserId, mode },
|
|
838
|
+
});
|
|
839
|
+
return null;
|
|
840
|
+
}
|
|
841
|
+
// Resolve access key based on mode
|
|
842
|
+
const { deriveAccessKey } = await import('../internal/protocol/sealed-sender/delivery-token.js');
|
|
843
|
+
const { bytesToBase64 } = await import('../internal/crypto/index.js');
|
|
844
|
+
let auth;
|
|
845
|
+
switch (mode) {
|
|
846
|
+
case UnidentifiedAccessMode.UNRESTRICTED: {
|
|
847
|
+
// Anyone can send sealed sender — use zeroed 16-byte key
|
|
848
|
+
const zeroedKey = new Uint8Array(16);
|
|
849
|
+
auth = {
|
|
850
|
+
type: 'accessKey',
|
|
851
|
+
unidentifiedAccessKey: bytesToBase64(zeroedKey),
|
|
852
|
+
};
|
|
853
|
+
break;
|
|
854
|
+
}
|
|
855
|
+
case UnidentifiedAccessMode.ENABLED: {
|
|
856
|
+
// Must derive from profile key — fail if unavailable
|
|
857
|
+
const recipientProfileKey = await contactStateStore.getContactProfileKey(recipientUserId);
|
|
858
|
+
if (!recipientProfileKey) {
|
|
859
|
+
this.logger.debug('No profile key for ENABLED recipient, using identified delivery', {
|
|
860
|
+
category: 'E2EE',
|
|
861
|
+
data: { recipientUserId },
|
|
862
|
+
});
|
|
863
|
+
return null;
|
|
864
|
+
}
|
|
865
|
+
const accessKey = await deriveAccessKey(recipientProfileKey);
|
|
866
|
+
auth = {
|
|
867
|
+
type: 'accessKey',
|
|
868
|
+
unidentifiedAccessKey: bytesToBase64(accessKey),
|
|
869
|
+
};
|
|
870
|
+
break;
|
|
871
|
+
}
|
|
872
|
+
case UnidentifiedAccessMode.UNKNOWN:
|
|
873
|
+
default: {
|
|
874
|
+
// Best effort: use derived key if available, else zeroed key
|
|
875
|
+
const recipientProfileKey = await contactStateStore.getContactProfileKey(recipientUserId);
|
|
876
|
+
if (recipientProfileKey) {
|
|
877
|
+
const accessKey = await deriveAccessKey(recipientProfileKey);
|
|
878
|
+
auth = {
|
|
879
|
+
type: 'accessKey',
|
|
880
|
+
unidentifiedAccessKey: bytesToBase64(accessKey),
|
|
881
|
+
};
|
|
882
|
+
}
|
|
883
|
+
else {
|
|
884
|
+
const zeroedKey = new Uint8Array(16);
|
|
885
|
+
auth = {
|
|
886
|
+
type: 'accessKey',
|
|
887
|
+
unidentifiedAccessKey: bytesToBase64(zeroedKey),
|
|
888
|
+
};
|
|
889
|
+
}
|
|
890
|
+
break;
|
|
891
|
+
}
|
|
892
|
+
}
|
|
893
|
+
// Get sender certificate and identity keys
|
|
894
|
+
const { senderCertificateBase64, senderIdentityPrivate, config } = await this.sealedSenderProvider();
|
|
895
|
+
// Get recipient's identity public key (needed for sealed sender DH)
|
|
896
|
+
const recipientAddress = ProtocolAddress.create(recipientUserId, 1);
|
|
897
|
+
const recipientIdentityRecord = await this.storage.getContactIdentity(recipientAddress);
|
|
898
|
+
if (!recipientIdentityRecord) {
|
|
899
|
+
// No identity key on file - fall back to identified delivery
|
|
900
|
+
this.logger.debug('No identity key for recipient, using identified delivery', {
|
|
901
|
+
category: 'E2EE',
|
|
902
|
+
data: { recipientUserId },
|
|
903
|
+
});
|
|
904
|
+
return null;
|
|
905
|
+
}
|
|
906
|
+
const recipientIdentityPublic = base64ToBytes(recipientIdentityRecord.identity.x25519PublicKey);
|
|
907
|
+
return {
|
|
908
|
+
senderCertificateBase64,
|
|
909
|
+
senderIdentityPrivate,
|
|
910
|
+
recipientIdentityPublic,
|
|
911
|
+
config,
|
|
912
|
+
auth,
|
|
913
|
+
};
|
|
914
|
+
}
|
|
915
|
+
catch (error) {
|
|
916
|
+
// Sealed sender is best-effort; fall back to identified delivery on failure
|
|
917
|
+
this.logger.warn('Failed to resolve sealed sender context, using identified delivery', {
|
|
918
|
+
category: 'E2EE',
|
|
919
|
+
data: { recipientUserId, error: error.message },
|
|
920
|
+
});
|
|
921
|
+
return null;
|
|
922
|
+
}
|
|
923
|
+
}
|
|
924
|
+
/**
|
|
925
|
+
* Send a single ciphertext to a device, optionally wrapping with sealed sender.
|
|
926
|
+
*
|
|
927
|
+
* When sealed sender context is available:
|
|
928
|
+
* 1. Wraps the ciphertext with seal() to hide sender identity
|
|
929
|
+
* 2. Uses relay.sendUnidentified() for anonymous delivery
|
|
930
|
+
*
|
|
931
|
+
* On sealed sender auth failure, transitions the recipient's
|
|
932
|
+
* UnidentifiedAccessMode before falling back to identified delivery:
|
|
933
|
+
*
|
|
934
|
+
* | Current Mode | -> New Mode | Rationale |
|
|
935
|
+
* |----------------|-------------|----------------------------------|
|
|
936
|
+
* | UNRESTRICTED | UNKNOWN | Might have wrong info, re-verify |
|
|
937
|
+
* | ENABLED | DISABLED | Key definitely wrong |
|
|
938
|
+
* | UNKNOWN | DISABLED | Confirmed doesn't work |
|
|
939
|
+
*
|
|
940
|
+
*/
|
|
941
|
+
async sendToDevice(msg, ciphertextBase64, messageType, recipientRegistrationId, sealedSender, contentHint, clientMessageId) {
|
|
942
|
+
const effectiveClientMessageId = msg.clientMessageId ?? clientMessageId;
|
|
943
|
+
// Sealed sender path: wrap with seal() and use anonymous delivery
|
|
944
|
+
if (sealedSender && this.relay.sendUnidentified) {
|
|
945
|
+
const { sealMessage } = await import('./sealed-sender-ops.js');
|
|
946
|
+
const sealedCiphertext = await sealMessage(ciphertextBase64, sealedSender.senderCertificateBase64, sealedSender.senderIdentityPrivate, sealedSender.recipientIdentityPublic, sealedSender.config, this.logger);
|
|
947
|
+
try {
|
|
948
|
+
return await this.relay.sendUnidentified({
|
|
949
|
+
targetUserId: msg.recipientUserId,
|
|
950
|
+
targetDeviceId: msg.recipientDeviceId,
|
|
951
|
+
senderUserId: '', // Hidden from server
|
|
952
|
+
senderDeviceId: 0,
|
|
953
|
+
ciphertext: sealedCiphertext,
|
|
954
|
+
messageType: 'unidentified_sender',
|
|
955
|
+
groupId: msg.groupId,
|
|
956
|
+
timestamp: msg.timestamp,
|
|
957
|
+
clientMessageId: effectiveClientMessageId,
|
|
958
|
+
contentHint,
|
|
959
|
+
}, sealedSender.auth);
|
|
960
|
+
}
|
|
961
|
+
catch (error) {
|
|
962
|
+
// Fall back to identified delivery only for sealed-sender authorization
|
|
963
|
+
// failures. Other failures retain their original error semantics.
|
|
964
|
+
if (error instanceof SealedSenderAuthError) {
|
|
965
|
+
// Restrict the cached mode after authorization fails.
|
|
966
|
+
try {
|
|
967
|
+
if (this.contactProfileStateStore) {
|
|
968
|
+
const currentMode = await this.contactProfileStateStore.getUnidentifiedAccessMode(msg.recipientUserId);
|
|
969
|
+
let newMode;
|
|
970
|
+
switch (currentMode) {
|
|
971
|
+
case UnidentifiedAccessMode.UNRESTRICTED:
|
|
972
|
+
newMode = UnidentifiedAccessMode.UNKNOWN;
|
|
973
|
+
break;
|
|
974
|
+
case UnidentifiedAccessMode.ENABLED:
|
|
975
|
+
case UnidentifiedAccessMode.UNKNOWN:
|
|
976
|
+
default:
|
|
977
|
+
newMode = UnidentifiedAccessMode.DISABLED;
|
|
978
|
+
break;
|
|
979
|
+
}
|
|
980
|
+
await this.contactProfileStateStore.updateUnidentifiedAccessMode(msg.recipientUserId, newMode);
|
|
981
|
+
this.logger.info('Sealed sender auth failed, transitioned mode and falling back to identified delivery', {
|
|
982
|
+
category: 'E2EE',
|
|
983
|
+
data: {
|
|
984
|
+
recipientUserId: msg.recipientUserId,
|
|
985
|
+
previousMode: currentMode,
|
|
986
|
+
newMode,
|
|
987
|
+
},
|
|
988
|
+
});
|
|
989
|
+
}
|
|
990
|
+
else {
|
|
991
|
+
this.logger.debug('No contact profile state store configured after sealed sender failure', {
|
|
992
|
+
category: 'E2EE',
|
|
993
|
+
data: { recipientUserId: msg.recipientUserId },
|
|
994
|
+
});
|
|
995
|
+
}
|
|
996
|
+
}
|
|
997
|
+
catch (modeError) {
|
|
998
|
+
// Non-fatal: mode transition failure shouldn't block message delivery
|
|
999
|
+
this.logger.warn('Failed to update unidentified access mode after auth failure', {
|
|
1000
|
+
category: 'E2EE',
|
|
1001
|
+
data: {
|
|
1002
|
+
recipientUserId: msg.recipientUserId,
|
|
1003
|
+
error: modeError.message,
|
|
1004
|
+
},
|
|
1005
|
+
});
|
|
1006
|
+
}
|
|
1007
|
+
// Fall through to identified path below
|
|
1008
|
+
}
|
|
1009
|
+
else {
|
|
1010
|
+
throw error;
|
|
1011
|
+
}
|
|
1012
|
+
}
|
|
1013
|
+
}
|
|
1014
|
+
// Identified sender path: standard relay send
|
|
1015
|
+
return this.relay.send({
|
|
1016
|
+
targetUserId: msg.recipientUserId,
|
|
1017
|
+
targetDeviceId: msg.recipientDeviceId,
|
|
1018
|
+
senderUserId: this.userId,
|
|
1019
|
+
senderDeviceId: this.deviceId,
|
|
1020
|
+
ciphertext: ciphertextBase64,
|
|
1021
|
+
messageType,
|
|
1022
|
+
groupId: msg.groupId,
|
|
1023
|
+
timestamp: msg.timestamp,
|
|
1024
|
+
clientMessageId: effectiveClientMessageId,
|
|
1025
|
+
recipientRegistrationId,
|
|
1026
|
+
contentHint,
|
|
1027
|
+
});
|
|
1028
|
+
}
|
|
1029
|
+
/**
|
|
1030
|
+
* Attempt V2 multi-recipient sealed sender send.
|
|
1031
|
+
* Returns null if unavailable — caller falls back to V1.
|
|
1032
|
+
*
|
|
1033
|
+
* Recovery behavior:
|
|
1034
|
+
* - 409 (mismatched devices): refresh device lists, rebuild recipient list, retry once
|
|
1035
|
+
* - 410 (stale sessions): archive stale sessions, retry once
|
|
1036
|
+
* - Other errors: return null for full V1 fallback
|
|
1037
|
+
*
|
|
1038
|
+
*/
|
|
1039
|
+
async tryMultiRecipientSend(groupId, otherMembers, encryptedMessageJson, sendTimestamp, clientMessageId) {
|
|
1040
|
+
// Guard checks — return null to trigger V1 fallback
|
|
1041
|
+
if (!this.sealedSenderProvider)
|
|
1042
|
+
return null;
|
|
1043
|
+
if (!this.relay?.sendMultiRecipientUnidentified)
|
|
1044
|
+
return null;
|
|
1045
|
+
if (otherMembers.length < 2)
|
|
1046
|
+
return null;
|
|
1047
|
+
// outer recovery state flags — prevent infinite retry loops
|
|
1048
|
+
//
|
|
1049
|
+
let hasRetriedDevices = false;
|
|
1050
|
+
let hasRetriedSessions = false;
|
|
1051
|
+
let currentMembers = otherMembers;
|
|
1052
|
+
const attemptV2Send = async () => {
|
|
1053
|
+
// Get sender keys (certificate + identity)
|
|
1054
|
+
const senderKeys = await this.sealedSenderProvider();
|
|
1055
|
+
const { base64ToBytes: b64ToBytes, bytesToBase64: bytesToB64 } = await import('../internal/crypto/index.js');
|
|
1056
|
+
// Gather recipient identity keys (per unique userId)
|
|
1057
|
+
const identityByUser = new Map();
|
|
1058
|
+
const uniqueUserIds = [...new Set(currentMembers.map((m) => m.userId))];
|
|
1059
|
+
for (const userId of uniqueUserIds) {
|
|
1060
|
+
const address = ProtocolAddress.create(userId, 1);
|
|
1061
|
+
const identityRecord = await this.storage.getContactIdentity(address);
|
|
1062
|
+
if (identityRecord) {
|
|
1063
|
+
identityByUser.set(userId, b64ToBytes(identityRecord.identity.x25519PublicKey));
|
|
1064
|
+
}
|
|
1065
|
+
}
|
|
1066
|
+
// Split V2-eligible vs V1-fallback
|
|
1067
|
+
const v2Members = [];
|
|
1068
|
+
const v1FallbackMembers = [];
|
|
1069
|
+
for (const member of currentMembers) {
|
|
1070
|
+
if (identityByUser.has(member.userId)) {
|
|
1071
|
+
v2Members.push(member);
|
|
1072
|
+
}
|
|
1073
|
+
else {
|
|
1074
|
+
v1FallbackMembers.push(member);
|
|
1075
|
+
}
|
|
1076
|
+
}
|
|
1077
|
+
// Need at least 2 V2-eligible unique users
|
|
1078
|
+
const v2UniqueUsers = new Set(v2Members.map((m) => m.userId));
|
|
1079
|
+
if (v2UniqueUsers.size < 2)
|
|
1080
|
+
return null;
|
|
1081
|
+
// Build V2 recipients with registration IDs from session state
|
|
1082
|
+
const v2Recipients = [];
|
|
1083
|
+
for (const member of v2Members) {
|
|
1084
|
+
const session = await this.storage.getSessionRecord(ProtocolAddress.create(member.userId, member.deviceId));
|
|
1085
|
+
let registrationId = 0;
|
|
1086
|
+
if (session?.currentSession) {
|
|
1087
|
+
registrationId = session.currentSession.remoteRegistrationId;
|
|
1088
|
+
}
|
|
1089
|
+
v2Recipients.push({
|
|
1090
|
+
serviceId: member.userId,
|
|
1091
|
+
deviceId: member.deviceId,
|
|
1092
|
+
registrationId,
|
|
1093
|
+
identityPublic: identityByUser.get(member.userId),
|
|
1094
|
+
});
|
|
1095
|
+
}
|
|
1096
|
+
// Call sealMultiRecipient()
|
|
1097
|
+
const { sealMultiRecipient } = await import('../internal/protocol/sealed-sender/index.js');
|
|
1098
|
+
const { deserializeSenderCertificate } = await import('../internal/protocol/sealed-sender/index.js');
|
|
1099
|
+
// Parse sender certificate
|
|
1100
|
+
const certBytes = b64ToBytes(senderKeys.senderCertificateBase64);
|
|
1101
|
+
const senderCertificate = deserializeSenderCertificate(certBytes);
|
|
1102
|
+
// Convert encryptedMessageJson to bytes for the seal
|
|
1103
|
+
const signalProtocolMessage = new TextEncoder().encode(encryptedMessageJson);
|
|
1104
|
+
// Group ID as bytes
|
|
1105
|
+
const groupIdBytes = new TextEncoder().encode(groupId);
|
|
1106
|
+
const sealResult = await sealMultiRecipient({
|
|
1107
|
+
senderCertificate,
|
|
1108
|
+
senderIdentityPrivate: senderKeys.senderIdentityPrivate,
|
|
1109
|
+
senderIdentityPublic: senderKeys.senderIdentityPublic,
|
|
1110
|
+
recipients: v2Recipients,
|
|
1111
|
+
signalProtocolMessage,
|
|
1112
|
+
groupId: groupIdBytes,
|
|
1113
|
+
});
|
|
1114
|
+
// Serialize to binary
|
|
1115
|
+
const { serializeSentMessage } = await import('../internal/protocol/sealed-sender/v2-binary.js');
|
|
1116
|
+
// Group recipients by serviceId for the binary format
|
|
1117
|
+
const recipientsByUser = new Map();
|
|
1118
|
+
for (const entry of sealResult.recipients) {
|
|
1119
|
+
const existing = recipientsByUser.get(entry.serviceId);
|
|
1120
|
+
if (existing) {
|
|
1121
|
+
existing.devices.push({
|
|
1122
|
+
deviceId: entry.deviceId,
|
|
1123
|
+
registrationId: entry.registrationId,
|
|
1124
|
+
});
|
|
1125
|
+
}
|
|
1126
|
+
else {
|
|
1127
|
+
recipientsByUser.set(entry.serviceId, {
|
|
1128
|
+
serviceId: entry.serviceId,
|
|
1129
|
+
devices: [
|
|
1130
|
+
{
|
|
1131
|
+
deviceId: entry.deviceId,
|
|
1132
|
+
registrationId: entry.registrationId,
|
|
1133
|
+
},
|
|
1134
|
+
],
|
|
1135
|
+
encryptedMessageKey: b64ToBytes(entry.encryptedMessageKey),
|
|
1136
|
+
authenticationTag: b64ToBytes(entry.authenticationTag),
|
|
1137
|
+
});
|
|
1138
|
+
}
|
|
1139
|
+
}
|
|
1140
|
+
const binaryBlob = serializeSentMessage(Array.from(recipientsByUser.values()), [], // No excluded recipients for now
|
|
1141
|
+
b64ToBytes(sealResult.ephemeralPublic), b64ToBytes(sealResult.messageCiphertext));
|
|
1142
|
+
const sentMessageBase64 = bytesToB64(binaryBlob);
|
|
1143
|
+
// Get combined auth token
|
|
1144
|
+
if (!this.endorsementManager)
|
|
1145
|
+
return null;
|
|
1146
|
+
const groupSecretParams = this.groupSecretParamsProvider
|
|
1147
|
+
? await this.groupSecretParamsProvider(groupId)
|
|
1148
|
+
: null;
|
|
1149
|
+
const v2UserIds = [...v2UniqueUsers];
|
|
1150
|
+
// Pre-send endorsement refresh
|
|
1151
|
+
const { needsRefresh, reason } = await this.endorsementManager.shouldRefreshEndorsements(groupId, v2UserIds);
|
|
1152
|
+
if (needsRefresh && this.endorsementRefresher) {
|
|
1153
|
+
try {
|
|
1154
|
+
await this.endorsementRefresher(groupId, v2UserIds);
|
|
1155
|
+
this.logger.debug('Refreshed endorsements before V2 send', {
|
|
1156
|
+
category: 'E2EE',
|
|
1157
|
+
data: { groupId, reason },
|
|
1158
|
+
});
|
|
1159
|
+
}
|
|
1160
|
+
catch (refreshErr) {
|
|
1161
|
+
this.logger.debug('Pre-send endorsement refresh failed, will attempt V1 fallback', {
|
|
1162
|
+
category: 'E2EE',
|
|
1163
|
+
data: { groupId, error: refreshErr.message },
|
|
1164
|
+
});
|
|
1165
|
+
}
|
|
1166
|
+
}
|
|
1167
|
+
const combinedToken = await this.endorsementManager.getCombinedToken(groupId, v2UserIds, groupSecretParams ?? undefined);
|
|
1168
|
+
if (!combinedToken)
|
|
1169
|
+
return null;
|
|
1170
|
+
const auth = {
|
|
1171
|
+
type: 'groupSendToken',
|
|
1172
|
+
groupSendToken: combinedToken.token,
|
|
1173
|
+
};
|
|
1174
|
+
// Send via relay
|
|
1175
|
+
const recipientUserIds = Array.from(recipientsByUser.keys());
|
|
1176
|
+
const result = await this.relay.sendMultiRecipientUnidentified(sentMessageBase64, auth, sendTimestamp, groupId, recipientUserIds, clientMessageId);
|
|
1177
|
+
// Send to V1 fallback members via per-device fanout
|
|
1178
|
+
if (v1FallbackMembers.length > 0) {
|
|
1179
|
+
const sealedSenderByUser = new Map();
|
|
1180
|
+
const fallbackUserIds = [...new Set(v1FallbackMembers.map((m) => m.userId))];
|
|
1181
|
+
for (const userId of fallbackUserIds) {
|
|
1182
|
+
sealedSenderByUser.set(userId, await this.resolveSealedSenderContext(userId, groupId));
|
|
1183
|
+
}
|
|
1184
|
+
for (const member of v1FallbackMembers) {
|
|
1185
|
+
const sealedSender = sealedSenderByUser.get(member.userId) ?? null;
|
|
1186
|
+
await this.sendToDevice({
|
|
1187
|
+
recipientUserId: member.userId,
|
|
1188
|
+
recipientDeviceId: member.deviceId,
|
|
1189
|
+
timestamp: sendTimestamp,
|
|
1190
|
+
groupId,
|
|
1191
|
+
}, encryptedMessageJson, 'ciphertext', undefined, sealedSender, undefined, clientMessageId);
|
|
1192
|
+
}
|
|
1193
|
+
}
|
|
1194
|
+
return {
|
|
1195
|
+
messageId: result.messageId,
|
|
1196
|
+
serverTimestamp: result.serverTimestamp,
|
|
1197
|
+
};
|
|
1198
|
+
};
|
|
1199
|
+
try {
|
|
1200
|
+
return await attemptV2Send();
|
|
1201
|
+
}
|
|
1202
|
+
catch (error) {
|
|
1203
|
+
const errorMessage = error.message ?? '';
|
|
1204
|
+
// 409: Mismatched devices — refresh device lists and retry once
|
|
1205
|
+
// the application send pipeline
|
|
1206
|
+
if (!hasRetriedDevices && isMismatchedDevicesError(errorMessage)) {
|
|
1207
|
+
hasRetriedDevices = true;
|
|
1208
|
+
this.logger.info('V2 send got mismatched devices (409), refreshing and retrying', {
|
|
1209
|
+
category: 'E2EE',
|
|
1210
|
+
data: { groupId },
|
|
1211
|
+
});
|
|
1212
|
+
try {
|
|
1213
|
+
// Refresh device lists for all affected users
|
|
1214
|
+
const uniqueUserIds = [...new Set(currentMembers.map((m) => m.userId))];
|
|
1215
|
+
const refreshedDevices = await Promise.all(uniqueUserIds.map((uid) => this.relay.getActiveDevices(uid)));
|
|
1216
|
+
currentMembers = refreshedDevices.flat().filter((m) => m.userId !== this.userId);
|
|
1217
|
+
return await attemptV2Send();
|
|
1218
|
+
}
|
|
1219
|
+
catch (retryError) {
|
|
1220
|
+
this.logger.debug('V2 retry after device refresh failed, falling back to V1', {
|
|
1221
|
+
category: 'E2EE',
|
|
1222
|
+
data: { groupId, error: retryError.message },
|
|
1223
|
+
});
|
|
1224
|
+
return null;
|
|
1225
|
+
}
|
|
1226
|
+
}
|
|
1227
|
+
// 410: Stale sessions — archive and retry once
|
|
1228
|
+
// the application send pipeline
|
|
1229
|
+
if (!hasRetriedSessions && isStaleSessionV2Error(errorMessage)) {
|
|
1230
|
+
hasRetriedSessions = true;
|
|
1231
|
+
this.logger.info('V2 send got stale sessions (410), archiving and retrying', {
|
|
1232
|
+
category: 'E2EE',
|
|
1233
|
+
data: { groupId },
|
|
1234
|
+
});
|
|
1235
|
+
try {
|
|
1236
|
+
// Archive stale sessions for all affected devices and re-establish
|
|
1237
|
+
if (this.staleSessionRefresher) {
|
|
1238
|
+
for (const member of currentMembers) {
|
|
1239
|
+
await this.staleSessionRefresher(member.userId, member.deviceId).catch(() => {
|
|
1240
|
+
// Non-fatal: some devices might not have stale sessions
|
|
1241
|
+
});
|
|
1242
|
+
}
|
|
1243
|
+
}
|
|
1244
|
+
return await attemptV2Send();
|
|
1245
|
+
}
|
|
1246
|
+
catch (retryError) {
|
|
1247
|
+
this.logger.debug('V2 retry after session refresh failed, falling back to V1', {
|
|
1248
|
+
category: 'E2EE',
|
|
1249
|
+
data: { groupId, error: retryError.message },
|
|
1250
|
+
});
|
|
1251
|
+
return null;
|
|
1252
|
+
}
|
|
1253
|
+
}
|
|
1254
|
+
// All other errors: V1 fallback
|
|
1255
|
+
this.logger.debug('V2 multi-recipient send failed, falling back to V1', {
|
|
1256
|
+
category: 'E2EE',
|
|
1257
|
+
data: { groupId, error: errorMessage },
|
|
1258
|
+
});
|
|
1259
|
+
return null;
|
|
1260
|
+
}
|
|
1261
|
+
}
|
|
1262
|
+
/**
|
|
1263
|
+
* V1 per-device sealed sender fanout (legacy path, used as fallback).
|
|
1264
|
+
*/
|
|
1265
|
+
async perDeviceFanoutSend(groupId, otherMembers, encryptedMessageJson, sendTimestamp, clientMessageId) {
|
|
1266
|
+
// Pre-send endorsement freshness check (non-blocking, log only)
|
|
1267
|
+
// Actual refresh is handled at orchestration layer (group-service.ts)
|
|
1268
|
+
if (this.endorsementManager) {
|
|
1269
|
+
const uniqueUserIds = [...new Set(otherMembers.map((m) => m.userId))];
|
|
1270
|
+
const { needsRefresh, reason } = await this.endorsementManager.shouldRefreshEndorsements(groupId, uniqueUserIds);
|
|
1271
|
+
if (needsRefresh) {
|
|
1272
|
+
this.logger.debug('Group endorsements need refresh before send', {
|
|
1273
|
+
category: 'E2EE',
|
|
1274
|
+
data: { groupId, reason },
|
|
1275
|
+
});
|
|
1276
|
+
}
|
|
1277
|
+
}
|
|
1278
|
+
// Resolve sealed sender context per unique recipient (not per device)
|
|
1279
|
+
// Identity keys and endorsement tokens are per-user, shared across devices
|
|
1280
|
+
const sealedSenderByUser = new Map();
|
|
1281
|
+
const uniqueRecipientIds = [...new Set(otherMembers.map((m) => m.userId))];
|
|
1282
|
+
for (const userId of uniqueRecipientIds) {
|
|
1283
|
+
sealedSenderByUser.set(userId, await this.resolveSealedSenderContext(userId, groupId));
|
|
1284
|
+
}
|
|
1285
|
+
// Send to each member device (sendToDevice handles seal + fallback)
|
|
1286
|
+
let firstResult;
|
|
1287
|
+
for (const member of otherMembers) {
|
|
1288
|
+
const sealedSender = sealedSenderByUser.get(member.userId) ?? null;
|
|
1289
|
+
const result = await this.sendToDevice({
|
|
1290
|
+
recipientUserId: member.userId,
|
|
1291
|
+
recipientDeviceId: member.deviceId,
|
|
1292
|
+
timestamp: sendTimestamp,
|
|
1293
|
+
groupId,
|
|
1294
|
+
}, encryptedMessageJson, 'ciphertext', undefined, sealedSender, undefined, clientMessageId);
|
|
1295
|
+
if (!firstResult)
|
|
1296
|
+
firstResult = result;
|
|
1297
|
+
}
|
|
1298
|
+
return firstResult;
|
|
1299
|
+
}
|
|
1300
|
+
/**
|
|
1301
|
+
* Encrypt to a group via Sender Keys (O(1) encryption)
|
|
1302
|
+
*
|
|
1303
|
+
* Prefers V2 multi-recipient sealed sender when available, falls back to
|
|
1304
|
+
* V1 per-device fanout.
|
|
1305
|
+
*/
|
|
1306
|
+
async encryptToGroup(groupId, plaintextBytes, options) {
|
|
1307
|
+
// Extract actual group ID from prefixed format
|
|
1308
|
+
const actualGroupId = extractGroupId(groupId);
|
|
1309
|
+
// Require sender key to exist - caller (SignalProtocolClient.createGroupSenderKey) must create it first
|
|
1310
|
+
// This ensures proper sender key distribution to group members before sending
|
|
1311
|
+
const existingKey = await this.storage.getSenderKey(actualGroupId, this.userId, this.deviceId);
|
|
1312
|
+
if (!existingKey) {
|
|
1313
|
+
throw new EncryptionError(`No sender key for group ${actualGroupId}. Call createGroupSenderKey() first to create and distribute the key.`, EncryptionErrorCode.SESSION_NOT_FOUND, {
|
|
1314
|
+
groupId: actualGroupId,
|
|
1315
|
+
userId: this.userId,
|
|
1316
|
+
deviceId: this.deviceId,
|
|
1317
|
+
});
|
|
1318
|
+
}
|
|
1319
|
+
// Encrypt with sender key (O(1) - single encryption for all members)
|
|
1320
|
+
// Auto-rotate on SENDER_KEY_EXPIRED
|
|
1321
|
+
let encrypted;
|
|
1322
|
+
try {
|
|
1323
|
+
encrypted = await this.senderKeyManager.encryptGroupMessage(actualGroupId, this.userId, this.deviceId, plaintextBytes);
|
|
1324
|
+
}
|
|
1325
|
+
catch (error) {
|
|
1326
|
+
if (error instanceof EncryptionError &&
|
|
1327
|
+
error.code === EncryptionErrorCode.SENDER_KEY_EXPIRED) {
|
|
1328
|
+
this.logger.info('Sender key expired, auto-rotating', {
|
|
1329
|
+
category: 'E2EE',
|
|
1330
|
+
data: { groupId: actualGroupId },
|
|
1331
|
+
});
|
|
1332
|
+
// Rotate sender key (generates new key material + increments generation)
|
|
1333
|
+
const { distributionMessage } = await this.senderKeyManager.rotateSenderKey(actualGroupId, this.userId, this.deviceId);
|
|
1334
|
+
// Redistribute new sender key to all group members via relay
|
|
1335
|
+
if (this.relay) {
|
|
1336
|
+
const members = options?.groupMemberUserIds?.length
|
|
1337
|
+
? (await Promise.all(options.groupMemberUserIds.map((uid) => this.relay.getActiveDevices(uid)))).flat()
|
|
1338
|
+
: await this.relay.getGroupMembers(actualGroupId);
|
|
1339
|
+
const otherMembers = members.filter((m) => m.userId !== this.userId);
|
|
1340
|
+
for (const member of otherMembers) {
|
|
1341
|
+
// Send SKDM via pairwise session (same as initial distribution)
|
|
1342
|
+
await this.ensureSessionsForUser(member.userId);
|
|
1343
|
+
// Serialize SKDM as ProtoContentData with senderKeyDistributionMessage field
|
|
1344
|
+
// The string field contains JSON-encoded {groupId, ...distributionMessage}
|
|
1345
|
+
const skdmBytes = this.contentAdapter
|
|
1346
|
+
? this.contentAdapter.serializeSenderKeyDistributionBytes(actualGroupId, distributionMessage)
|
|
1347
|
+
: new TextEncoder().encode(JSON.stringify({
|
|
1348
|
+
senderKeyDistributionMessage: JSON.stringify({
|
|
1349
|
+
groupId: actualGroupId,
|
|
1350
|
+
...distributionMessage,
|
|
1351
|
+
}),
|
|
1352
|
+
}));
|
|
1353
|
+
const batch = await this.sesameManager.send(member.userId, skdmBytes, {});
|
|
1354
|
+
for (const msg of batch.deviceMessages) {
|
|
1355
|
+
const ciphertextBase64 = typeof msg.ciphertext === 'string'
|
|
1356
|
+
? msg.ciphertext
|
|
1357
|
+
: CryptoUtils.bytesToBase64(msg.ciphertext);
|
|
1358
|
+
await this.relay.send({
|
|
1359
|
+
targetUserId: msg.recipientUserId,
|
|
1360
|
+
targetDeviceId: msg.recipientDeviceId,
|
|
1361
|
+
senderUserId: this.userId,
|
|
1362
|
+
senderDeviceId: this.deviceId,
|
|
1363
|
+
ciphertext: ciphertextBase64,
|
|
1364
|
+
messageType: getEnvelopeMessageType(msg.ciphertext),
|
|
1365
|
+
groupId: actualGroupId,
|
|
1366
|
+
timestamp: msg.timestamp,
|
|
1367
|
+
});
|
|
1368
|
+
}
|
|
1369
|
+
}
|
|
1370
|
+
}
|
|
1371
|
+
// Retry encryption with the new key (once — no infinite loop)
|
|
1372
|
+
encrypted = await this.senderKeyManager.encryptGroupMessage(actualGroupId, this.userId, this.deviceId, plaintextBytes);
|
|
1373
|
+
}
|
|
1374
|
+
else {
|
|
1375
|
+
throw error;
|
|
1376
|
+
}
|
|
1377
|
+
}
|
|
1378
|
+
// Send encrypted message via relay
|
|
1379
|
+
let messageId = `local-${Date.now()}`;
|
|
1380
|
+
let timestamp = Date.now(); // Fallback if no relay
|
|
1381
|
+
let recipientDeviceCount = 0;
|
|
1382
|
+
if (this.relay) {
|
|
1383
|
+
// Resolve group members → devices. Prefer caller-provided member list
|
|
1384
|
+
// (local-first: membership lives in SQLite, not on server).
|
|
1385
|
+
// Falls back to relay.getGroupMembers() for in-memory adapters.
|
|
1386
|
+
let members;
|
|
1387
|
+
if (options?.groupMemberUserIds?.length) {
|
|
1388
|
+
const deviceResults = await Promise.all(options.groupMemberUserIds.map((userId) => this.relay.getActiveDevices(userId)));
|
|
1389
|
+
members = deviceResults.flat();
|
|
1390
|
+
}
|
|
1391
|
+
else {
|
|
1392
|
+
members = await this.relay.getGroupMembers(actualGroupId);
|
|
1393
|
+
}
|
|
1394
|
+
// Framed SenderKeyMessage bytes → base64 for transport
|
|
1395
|
+
const encryptedMessageJson = CryptoUtils.bytesToBase64(encrypted);
|
|
1396
|
+
const sendTimestamp = options?.timestamp ?? Date.now();
|
|
1397
|
+
// Filter to other members (skip self — the application send pipeline)
|
|
1398
|
+
const otherMembers = members.filter((m) => m.userId !== this.userId);
|
|
1399
|
+
recipientDeviceCount = otherMembers.length;
|
|
1400
|
+
// Try V2 multi-recipient first
|
|
1401
|
+
const v2Result = await this.tryMultiRecipientSend(actualGroupId, otherMembers, encryptedMessageJson, sendTimestamp, options?.clientMessageId);
|
|
1402
|
+
if (v2Result) {
|
|
1403
|
+
messageId = v2Result.messageId;
|
|
1404
|
+
timestamp = v2Result.serverTimestamp;
|
|
1405
|
+
this.logger.debug('Group message sent via V2 multi-recipient', {
|
|
1406
|
+
category: 'E2EE',
|
|
1407
|
+
data: { groupId: actualGroupId, recipientDeviceCount, messageId },
|
|
1408
|
+
});
|
|
1409
|
+
}
|
|
1410
|
+
else {
|
|
1411
|
+
// V1 fallback
|
|
1412
|
+
const v1Result = await this.perDeviceFanoutSend(actualGroupId, otherMembers, encryptedMessageJson, sendTimestamp, options?.clientMessageId);
|
|
1413
|
+
if (v1Result) {
|
|
1414
|
+
messageId = v1Result.messageId;
|
|
1415
|
+
timestamp = v1Result.serverTimestamp;
|
|
1416
|
+
}
|
|
1417
|
+
else {
|
|
1418
|
+
messageId = `group-${actualGroupId}-${timestamp}`;
|
|
1419
|
+
}
|
|
1420
|
+
this.logger.debug('Group message sent via V1 per-device fanout', {
|
|
1421
|
+
category: 'E2EE',
|
|
1422
|
+
data: { groupId: actualGroupId, recipientDeviceCount, messageId },
|
|
1423
|
+
});
|
|
1424
|
+
}
|
|
1425
|
+
await this.sendSyncTranscriptToLocalOtherDevices(actualGroupId, plaintextBytes, sendTimestamp);
|
|
1426
|
+
}
|
|
1427
|
+
return {
|
|
1428
|
+
messageId,
|
|
1429
|
+
timestamp,
|
|
1430
|
+
recipientDeviceCount,
|
|
1431
|
+
groupId: actualGroupId,
|
|
1432
|
+
};
|
|
1433
|
+
}
|
|
1434
|
+
/**
|
|
1435
|
+
* Encrypt binary attachment with two-layer encryption
|
|
1436
|
+
*
|
|
1437
|
+
* Layer 1: AES-GCM-HKDF Streaming encrypts the file (Tink format)
|
|
1438
|
+
* Layer 2: Signal Protocol encrypts the AES key + metadata
|
|
1439
|
+
*
|
|
1440
|
+
* Uses streaming AEAD for:
|
|
1441
|
+
* - Per-chunk integrity verification
|
|
1442
|
+
* - Streaming decryption (video playback while downloading)
|
|
1443
|
+
* - Truncation detection via last-segment flag
|
|
1444
|
+
*
|
|
1445
|
+
* @param recipientId - User or group ID to send to
|
|
1446
|
+
* @param data - Binary file data as Uint8Array (use expo-file-system File.bytes())
|
|
1447
|
+
* @param options - Send options including mimeType, blurHash, dimensions
|
|
1448
|
+
*
|
|
1449
|
+
* @see https://developers.google.com/tink/streaming-aead/aes_gcm_hkdf_streaming
|
|
1450
|
+
*/
|
|
1451
|
+
async encryptBinaryAttachment(recipientId, data, options) {
|
|
1452
|
+
if (!this.relay) {
|
|
1453
|
+
throw new EncryptionError('Relay server not configured. Cannot send attachments without server connection.', EncryptionErrorCode.INITIALIZATION_FAILED);
|
|
1454
|
+
}
|
|
1455
|
+
const uploaded = await this.prepareAttachmentUpload(data, options);
|
|
1456
|
+
const attachmentPayload = serializeMediaAttachmentMessage({
|
|
1457
|
+
attachment: uploaded,
|
|
1458
|
+
timestamp: options?.timestamp ?? Date.now(),
|
|
1459
|
+
});
|
|
1460
|
+
const attachmentBytes = new TextEncoder().encode(attachmentPayload);
|
|
1461
|
+
let result;
|
|
1462
|
+
if (isGroupId(recipientId)) {
|
|
1463
|
+
result = await this.encryptToGroup(recipientId, attachmentBytes, options);
|
|
1464
|
+
}
|
|
1465
|
+
else {
|
|
1466
|
+
result = await this.encryptToUser(recipientId, attachmentBytes, options);
|
|
1467
|
+
}
|
|
1468
|
+
return {
|
|
1469
|
+
...result,
|
|
1470
|
+
storageId: uploaded.storageId,
|
|
1471
|
+
aesKey: uploaded.key,
|
|
1472
|
+
segmentSize: uploaded.segmentSize,
|
|
1473
|
+
digest: uploaded.digest,
|
|
1474
|
+
contentType: uploaded.contentType,
|
|
1475
|
+
};
|
|
1476
|
+
}
|
|
1477
|
+
async prepareAttachmentUpload(data, options) {
|
|
1478
|
+
if (!this.remoteObjectStore) {
|
|
1479
|
+
throw new EncryptionError('Remote object storage not configured. Provide remoteObjectStore in SignalProtocolClient.create() config.', EncryptionErrorCode.INITIALIZATION_FAILED);
|
|
1480
|
+
}
|
|
1481
|
+
return prepareMediaAttachmentUpload(data, {
|
|
1482
|
+
remoteObjectStore: this.remoteObjectStore,
|
|
1483
|
+
transfer: options?.attachment?.transfer,
|
|
1484
|
+
retry: options?.attachment?.retry,
|
|
1485
|
+
policy: options?.attachment?.policy,
|
|
1486
|
+
signal: options?.attachment?.signal,
|
|
1487
|
+
onProgress: options?.attachment?.onProgress,
|
|
1488
|
+
onCheckpoint: options?.attachment?.onCheckpoint,
|
|
1489
|
+
resume: options?.attachment?.resume,
|
|
1490
|
+
contentType: options?.mimeType || 'application/octet-stream',
|
|
1491
|
+
blurHash: options?.blurHash,
|
|
1492
|
+
thumbnail: options?.thumbnail,
|
|
1493
|
+
width: options?.width,
|
|
1494
|
+
height: options?.height,
|
|
1495
|
+
durationMs: options?.durationMs,
|
|
1496
|
+
waveform: options?.waveform,
|
|
1497
|
+
fileName: options?.fileName,
|
|
1498
|
+
caption: options?.caption,
|
|
1499
|
+
isViewOnce: options?.isViewOnce,
|
|
1500
|
+
flags: options?.flags,
|
|
1501
|
+
clientUuid: options?.clientUuid,
|
|
1502
|
+
cdnNumber: options?.cdnNumber,
|
|
1503
|
+
});
|
|
1504
|
+
}
|
|
1505
|
+
}
|
|
1506
|
+
//# sourceMappingURL=signal-service-cipher.js.map
|