@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,2296 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SignalProtocolClient - initialized client class for encrypted messaging.
|
|
3
|
+
*
|
|
4
|
+
* @layer 1 - API
|
|
5
|
+
* @boundary ISignalProtocolClient
|
|
6
|
+
*
|
|
7
|
+
* Application code should usually create clients with `createSignalProtocolClient()`.
|
|
8
|
+
* Use `SignalProtocolClient.create()` directly when lower-level integration code already
|
|
9
|
+
* owns the flattened config shape.
|
|
10
|
+
*
|
|
11
|
+
* @example Basic usage
|
|
12
|
+
* ```typescript
|
|
13
|
+
* import { createSignalProtocolClient } from '@open-e2ee/signal-protocol-sdk';
|
|
14
|
+
* import { mockStore } from '@open-e2ee/signal-protocol-sdk/local/store/mock';
|
|
15
|
+
* import { mockRelay } from '@open-e2ee/signal-protocol-sdk/remote/relay/mock';
|
|
16
|
+
*
|
|
17
|
+
* const relay = mockRelay();
|
|
18
|
+
* const signal = await createSignalProtocolClient({
|
|
19
|
+
* identity: { userId: 'alice' },
|
|
20
|
+
* adapters: { storage: mockStore(), relay },
|
|
21
|
+
* });
|
|
22
|
+
*
|
|
23
|
+
* await signal.syncToServer();
|
|
24
|
+
* await signal.send('bob', 'Hello!');
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* @example With product security policy
|
|
28
|
+
* ```typescript
|
|
29
|
+
* const signal = await createSignalProtocolClient({
|
|
30
|
+
* identity: { userId },
|
|
31
|
+
* adapters: { storage, relay },
|
|
32
|
+
* protocol: { postQuantum: 'required', braid: 'required' },
|
|
33
|
+
* });
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* @example Low-level factory
|
|
37
|
+
* ```typescript
|
|
38
|
+
* import { SignalProtocolClient } from '@open-e2ee/signal-protocol-sdk';
|
|
39
|
+
*
|
|
40
|
+
* const signal = await SignalProtocolClient.create(userId, {
|
|
41
|
+
* storage,
|
|
42
|
+
* relay,
|
|
43
|
+
* });
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
import AsyncLock from 'async-lock';
|
|
47
|
+
import { SignalProtocolManager } from '../internal/manager/index.js';
|
|
48
|
+
import { SesameManager } from '../internal/sesame/index.js';
|
|
49
|
+
import { createCompositeIdentityV1 } from '../keys/identity.js';
|
|
50
|
+
import { EncryptionError, EncryptionErrorCode } from '../types/index.js';
|
|
51
|
+
import { base64ToBytes } from '../internal/crypto/index.js';
|
|
52
|
+
import { ProtocolAddress } from '../types/address.js';
|
|
53
|
+
import { getActiveIdentityTypes, resolveSignalProtocolStrategy, } from './config.js';
|
|
54
|
+
import { resolveSignalLogger } from '../logger.js';
|
|
55
|
+
import { SenderKeyManager, } from '../internal/protocol/sender-keys/index.js';
|
|
56
|
+
import { createDefaultSignalContentAdapter, } from './content-adapter.js';
|
|
57
|
+
// Note: group utilities (isGroupId, extractGroupId, createGroupId) are used by SignalServiceCipher
|
|
58
|
+
import { SignalServiceCipher, sortEnvelopesForDecryption } from './signal-service-cipher.js';
|
|
59
|
+
import { establishMultiDeviceSessions } from '../internal/sesame/device-registry.js';
|
|
60
|
+
import { isRetryableDecryptionError } from './retry-utils.js';
|
|
61
|
+
import { MESSAGE_RECORD_TTL_MS } from './constants.js';
|
|
62
|
+
import { ReceiptType } from './types.js';
|
|
63
|
+
import * as MessageOps from './messages.js';
|
|
64
|
+
import * as FileOps from './files.js';
|
|
65
|
+
import * as KeyRotationOps from './key-rotation.js';
|
|
66
|
+
import * as SessionOps from './sessions.js';
|
|
67
|
+
import * as GroupOps from './groups.js';
|
|
68
|
+
import * as PreKeyOps from './prekeys.js';
|
|
69
|
+
import * as RetryOps from './retry.js';
|
|
70
|
+
import * as RelaySubscriptionOps from './relay-subscription.js';
|
|
71
|
+
import { SignalProtocolClientState, SIGNAL_PROTOCOL_CLIENT_CONSTANTS } from './state.js';
|
|
72
|
+
import { deleteMediaAttachment, resolveMediaAttachment, } from '../media/index.js';
|
|
73
|
+
import { StorageBackedSignalProtocolClientMedia } from './media.js';
|
|
74
|
+
// GroupsV2 (Signal Private Group System)
|
|
75
|
+
import { GroupsV2Manager } from '../internal/groups-v2/index.js';
|
|
76
|
+
export { IMPLICIT_ENVELOPE_TYPES } from './constants.js';
|
|
77
|
+
/**
|
|
78
|
+
* Module-level lock for storage initialization.
|
|
79
|
+
* Prevents multiple concurrent SignalProtocolClient.create() calls from creating
|
|
80
|
+
* duplicate storage adapters that compete for database locks.
|
|
81
|
+
*/
|
|
82
|
+
const storageLock = new AsyncLock({
|
|
83
|
+
timeout: 30000, // 30 second timeout for storage initialization
|
|
84
|
+
maxPending: 100, // Limit pending operations
|
|
85
|
+
});
|
|
86
|
+
/**
|
|
87
|
+
* Type guard: DataMessage is a plain object (not string or Uint8Array).
|
|
88
|
+
* TypeScript enforces correct content types at compile time; this routes at runtime.
|
|
89
|
+
*/
|
|
90
|
+
function isDataMessage(content) {
|
|
91
|
+
return (typeof content === 'object' &&
|
|
92
|
+
content !== null &&
|
|
93
|
+
!(content instanceof Uint8Array) &&
|
|
94
|
+
!ArrayBuffer.isView(content));
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Modern Signal Protocol Client
|
|
98
|
+
*
|
|
99
|
+
* Provides a clean, testable, and flexible API for Signal Protocol operations.
|
|
100
|
+
* Uses static factory pattern for type-safe async initialization:
|
|
101
|
+
* - Guaranteed initialization via create() method
|
|
102
|
+
* - Dependency injection support
|
|
103
|
+
* - Configuration object pattern
|
|
104
|
+
* - Clear error handling
|
|
105
|
+
* - Type-safe API
|
|
106
|
+
*
|
|
107
|
+
* This client implements the ISignalProtocolClient interface and wraps
|
|
108
|
+
* SignalProtocolManager with additional high-level functionality.
|
|
109
|
+
*
|
|
110
|
+
* @category Primary API
|
|
111
|
+
*/
|
|
112
|
+
export class SignalProtocolClient {
|
|
113
|
+
manager;
|
|
114
|
+
_storage;
|
|
115
|
+
relay;
|
|
116
|
+
remoteObjectStore;
|
|
117
|
+
config;
|
|
118
|
+
_userId;
|
|
119
|
+
logger;
|
|
120
|
+
hooks;
|
|
121
|
+
contentAdapter;
|
|
122
|
+
// Multi-device support (Phase 2)
|
|
123
|
+
deviceId; // 1 = primary, 2-5 = linked devices
|
|
124
|
+
/**
|
|
125
|
+
* Get user ID for this client instance
|
|
126
|
+
* @see ISignalProtocolClient.userId
|
|
127
|
+
*/
|
|
128
|
+
get userId() {
|
|
129
|
+
return this._userId;
|
|
130
|
+
}
|
|
131
|
+
sesameManager; // Sesame protocol manager for multi-device support
|
|
132
|
+
_address; // Cached own address
|
|
133
|
+
// Group messaging support (Sender Keys)
|
|
134
|
+
senderKeyManager;
|
|
135
|
+
// GroupsV2 state management (Phase 6)
|
|
136
|
+
groupsV2Manager;
|
|
137
|
+
// Cipher coordination (encrypts/decrypts, routes to appropriate cipher)
|
|
138
|
+
cipher;
|
|
139
|
+
/**
|
|
140
|
+
* Durable media job facade backed by the configured Signal local store.
|
|
141
|
+
*
|
|
142
|
+
* Use this for background-safe attachment uploads, downloads, and cleanup
|
|
143
|
+
* when the app provides media lifecycle callbacks in `config.media`.
|
|
144
|
+
*/
|
|
145
|
+
media;
|
|
146
|
+
/**
|
|
147
|
+
* Indicates the result of initial server sync during create().
|
|
148
|
+
* 'synced' = successful, 'failed' = sync threw (offline mode), 'none' = no relay configured.
|
|
149
|
+
*/
|
|
150
|
+
_syncStatus = 'none';
|
|
151
|
+
get syncStatus() {
|
|
152
|
+
return this._syncStatus;
|
|
153
|
+
}
|
|
154
|
+
relayUnsubscribe;
|
|
155
|
+
retryUnsubscribe;
|
|
156
|
+
/**
|
|
157
|
+
* Cached sender certificate for sealed sender.
|
|
158
|
+
* Lazily fetched and refreshed when expired (24h validity, 5min margin).
|
|
159
|
+
*/
|
|
160
|
+
cachedSenderCertificate = null;
|
|
161
|
+
cachedCertificateExpiry = 0;
|
|
162
|
+
/**
|
|
163
|
+
* Centralized state management for retry/rotation tracking
|
|
164
|
+
* @see SignalProtocolClientState for state details
|
|
165
|
+
*/
|
|
166
|
+
state = new SignalProtocolClientState();
|
|
167
|
+
/**
|
|
168
|
+
* Get retry rate limiting state for retry operations
|
|
169
|
+
*/
|
|
170
|
+
get rateLimitState() {
|
|
171
|
+
return this.state.getRateLimitState();
|
|
172
|
+
}
|
|
173
|
+
// Constants are now imported from state.ts for single source of truth
|
|
174
|
+
// See SIGNAL_PROTOCOL_CLIENT_CONSTANTS for timing and retry configuration
|
|
175
|
+
/**
|
|
176
|
+
* Private constructor - use SignalProtocolClient.create() to instantiate
|
|
177
|
+
*
|
|
178
|
+
* @param userId - User identifier
|
|
179
|
+
* @param deviceId - Device identifier (1 = primary, 2-5 = linked devices)
|
|
180
|
+
* @param config - Configuration for the client
|
|
181
|
+
*/
|
|
182
|
+
constructor(userId, deviceId, config) {
|
|
183
|
+
this._userId = userId;
|
|
184
|
+
this.deviceId = deviceId;
|
|
185
|
+
this.config = config;
|
|
186
|
+
this.logger = resolveSignalLogger(config.logger);
|
|
187
|
+
this.hooks = config.hooks || {};
|
|
188
|
+
this.contentAdapter = config.contentAdapter ?? createDefaultSignalContentAdapter();
|
|
189
|
+
// Dependency injection: use the provided relay adapter when configured.
|
|
190
|
+
this.relay = config.relay;
|
|
191
|
+
// Dependency injection: use the remote object store for encrypted attachments.
|
|
192
|
+
this.remoteObjectStore = config.remoteObjectStore;
|
|
193
|
+
// Dependency injection: Storage is always provided by create() callers.
|
|
194
|
+
if (!config.storage) {
|
|
195
|
+
throw new Error('Storage must be provided by SignalProtocolClient.create() callers');
|
|
196
|
+
}
|
|
197
|
+
this._storage = config.storage;
|
|
198
|
+
this._storage.setLogger?.(this.logger);
|
|
199
|
+
this.media = new StorageBackedSignalProtocolClientMedia({
|
|
200
|
+
storage: this._storage,
|
|
201
|
+
remoteObjectStore: this.remoteObjectStore,
|
|
202
|
+
config: config.media,
|
|
203
|
+
});
|
|
204
|
+
// Dependency injection: Use provided protocol manager or create new one with our storage and protocol strategy
|
|
205
|
+
this.manager =
|
|
206
|
+
config.protocolManager ??
|
|
207
|
+
new SignalProtocolManager(this._storage, config.protocolStrategy, this.logger);
|
|
208
|
+
// Validate manager was created successfully before initializing Sesame
|
|
209
|
+
if (!this.manager) {
|
|
210
|
+
throw new EncryptionError('Protocol manager must be initialized before Sesame manager', EncryptionErrorCode.INITIALIZATION_FAILED);
|
|
211
|
+
}
|
|
212
|
+
// Initialize Sesame manager for multi-device support
|
|
213
|
+
this.sesameManager = new SesameManager(this._storage, {}, // Use default Sesame config
|
|
214
|
+
this.manager, undefined, this.logger);
|
|
215
|
+
// Wire up MessageRecord storage for retry request support (SESAME spec §6.2)
|
|
216
|
+
this.sesameManager.setMessageRecordStore(this._storage);
|
|
217
|
+
// Initialize Sender Key manager for group messaging
|
|
218
|
+
this.senderKeyManager = new SenderKeyManager(this._storage, config?.senderKeys, this.logger);
|
|
219
|
+
// Initialize GroupsV2 manager if configured
|
|
220
|
+
if (config?.groupsV2) {
|
|
221
|
+
this.groupsV2Manager = new GroupsV2Manager({
|
|
222
|
+
store: config.groupsV2.store,
|
|
223
|
+
server: config.groupsV2.server,
|
|
224
|
+
issueCredential: () => {
|
|
225
|
+
if (!this.relay)
|
|
226
|
+
throw new Error('GroupsV2 requires a relay server');
|
|
227
|
+
return this.relay.issueAuthCredential(this._userId);
|
|
228
|
+
},
|
|
229
|
+
credentialPublicKey: config.groupsV2.credentialPublicKey,
|
|
230
|
+
aci: config.groupsV2.aci,
|
|
231
|
+
pni: config.groupsV2.pni,
|
|
232
|
+
onSenderKeyRotation: async (groupId) => {
|
|
233
|
+
// Forward to existing sender key rotation
|
|
234
|
+
await this.rotateGroupSenderKey(groupId);
|
|
235
|
+
},
|
|
236
|
+
onEndorsementsInvalidated: config.groupsV2.endorsementManager
|
|
237
|
+
? async (groupId) => {
|
|
238
|
+
await config.groupsV2.endorsementManager.clearGroupEndorsements(groupId);
|
|
239
|
+
}
|
|
240
|
+
: undefined,
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
// Initialize cipher for encrypt/decrypt coordination
|
|
244
|
+
this.cipher = new SignalServiceCipher(this._userId, deviceId, this.sesameManager, this.senderKeyManager, this._storage, this.relay, this.remoteObjectStore, this.contentAdapter, this.logger);
|
|
245
|
+
// Set up auto-session establishment callback
|
|
246
|
+
// This enables lazy session creation when sending to users without established sessions
|
|
247
|
+
if (this.relay) {
|
|
248
|
+
this.cipher.setSessionEstablisher(async (recipientUserId) => {
|
|
249
|
+
return establishMultiDeviceSessions(this, this.relay, recipientUserId);
|
|
250
|
+
});
|
|
251
|
+
// Set up stale session refresh callback
|
|
252
|
+
// Stale-device recovery archives the old session, fetches a fresh bundle,
|
|
253
|
+
// and establishes a replacement.
|
|
254
|
+
// Per SESAME §3.2: session is archived (not deleted) to handle delayed messages
|
|
255
|
+
this.cipher.setStaleSessionRefresher(async (recipientUserId, recipientDeviceId) => {
|
|
256
|
+
try {
|
|
257
|
+
const address = ProtocolAddress.create(recipientUserId, recipientDeviceId);
|
|
258
|
+
// 1. Archive the stale session (preserves for delayed message decryption)
|
|
259
|
+
await this.archiveSession(address);
|
|
260
|
+
this.logger.debug('Archived stale session for refresh', {
|
|
261
|
+
category: 'E2EE',
|
|
262
|
+
data: { recipientUserId, recipientDeviceId },
|
|
263
|
+
});
|
|
264
|
+
// 2. Fetch fresh prekey bundle
|
|
265
|
+
const freshBundle = await this.relay.fetchPreKeyBundle(recipientUserId, recipientDeviceId);
|
|
266
|
+
if (!freshBundle) {
|
|
267
|
+
this.logger.warn('No prekey bundle available for stale session refresh', {
|
|
268
|
+
category: 'E2EE',
|
|
269
|
+
data: { recipientUserId, recipientDeviceId },
|
|
270
|
+
});
|
|
271
|
+
return false;
|
|
272
|
+
}
|
|
273
|
+
// 3. Establish new session with fresh keys
|
|
274
|
+
await this.establishSession(address, freshBundle);
|
|
275
|
+
this.logger.info('Refreshed stale session with fresh bundle', {
|
|
276
|
+
category: 'E2EE',
|
|
277
|
+
data: {
|
|
278
|
+
recipientUserId,
|
|
279
|
+
recipientDeviceId,
|
|
280
|
+
newSignedPreKeyId: freshBundle.ecSignedPreKey.keyId,
|
|
281
|
+
newRegistrationId: freshBundle.registrationId,
|
|
282
|
+
},
|
|
283
|
+
});
|
|
284
|
+
return true;
|
|
285
|
+
}
|
|
286
|
+
catch (error) {
|
|
287
|
+
this.logger.error('Failed to refresh stale session', {
|
|
288
|
+
category: 'E2EE',
|
|
289
|
+
data: {
|
|
290
|
+
recipientUserId,
|
|
291
|
+
recipientDeviceId,
|
|
292
|
+
error: error.message,
|
|
293
|
+
},
|
|
294
|
+
});
|
|
295
|
+
return false;
|
|
296
|
+
}
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
// Set up sealed sender provider if configured
|
|
300
|
+
if (this.isSealedSenderEnabled) {
|
|
301
|
+
this.cipher.setSealedSenderProvider(async () => {
|
|
302
|
+
const certBase64 = await this.fetchSenderCertificate();
|
|
303
|
+
const identityKeyPair = await this._storage.getIdentityKey();
|
|
304
|
+
if (!identityKeyPair) {
|
|
305
|
+
throw new EncryptionError('No identity key pair for sealed sender', EncryptionErrorCode.INITIALIZATION_FAILED);
|
|
306
|
+
}
|
|
307
|
+
const { base64ToBytes: b64ToBytes } = await import('../internal/crypto/index.js');
|
|
308
|
+
return {
|
|
309
|
+
senderCertificateBase64: certBase64,
|
|
310
|
+
senderIdentityPrivate: b64ToBytes(identityKeyPair.dhKey.privateKey),
|
|
311
|
+
senderIdentityPublic: b64ToBytes(identityKeyPair.dhKey.publicKey),
|
|
312
|
+
config: this.config.sealedSender,
|
|
313
|
+
};
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
if (config?.sealedSender?.contactStateStore) {
|
|
317
|
+
this.cipher.setContactProfileStateStore(config.sealedSender.contactStateStore);
|
|
318
|
+
}
|
|
319
|
+
// Set up endorsement manager if configured
|
|
320
|
+
if (config?.groupsV2?.endorsementManager) {
|
|
321
|
+
this.cipher.setEndorsementManager(config.groupsV2.endorsementManager);
|
|
322
|
+
}
|
|
323
|
+
// Set up group secret params provider — derives params from master key in store
|
|
324
|
+
if (config?.groupsV2?.store) {
|
|
325
|
+
const store = config.groupsV2.store;
|
|
326
|
+
this.cipher.setGroupSecretParamsProvider(async (groupId) => {
|
|
327
|
+
const masterKey = await store.getMasterKey(groupId);
|
|
328
|
+
if (!masterKey)
|
|
329
|
+
return null;
|
|
330
|
+
const { deriveGroupSecretParams } = await import('../internal/protocol/zk/groups/index.js');
|
|
331
|
+
return deriveGroupSecretParams(masterKey);
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
// Set up endorsement refresher for pre-send V2 sealed sender refresh.
|
|
335
|
+
// Fetches fresh endorsements from server when cache is empty, expiring, or
|
|
336
|
+
// missing members.
|
|
337
|
+
if (config?.groupsV2?.endorsementManager &&
|
|
338
|
+
config?.groupsV2?.store &&
|
|
339
|
+
this.relay?.refreshGroupSendEndorsements &&
|
|
340
|
+
this.groupsV2Manager) {
|
|
341
|
+
const groupsV2Config = config.groupsV2;
|
|
342
|
+
const endorsementManager = groupsV2Config.endorsementManager;
|
|
343
|
+
const groupStore = groupsV2Config.store;
|
|
344
|
+
const groupsV2Manager = this.groupsV2Manager;
|
|
345
|
+
const relay = this.relay;
|
|
346
|
+
const selfUserId = this._userId;
|
|
347
|
+
this.cipher.setEndorsementRefresher(async (groupId, memberUserIds) => {
|
|
348
|
+
// 1. Build ZK authorization (credential presentation + group public params)
|
|
349
|
+
const authorization = await groupsV2Manager.getAuthorization(groupId);
|
|
350
|
+
// 2. Get group secret params for endorsement processing
|
|
351
|
+
const masterKey = await groupStore.getMasterKey(groupId);
|
|
352
|
+
if (!masterKey)
|
|
353
|
+
return false;
|
|
354
|
+
const { deriveGroupSecretParams } = await import('../internal/protocol/zk/groups/index.js');
|
|
355
|
+
const secretParams = deriveGroupSecretParams(masterKey);
|
|
356
|
+
// 3. Convert groupId to bytes for relay call
|
|
357
|
+
const groupIdBytes = new TextEncoder().encode(groupId);
|
|
358
|
+
// 4. Fetch fresh endorsements from server
|
|
359
|
+
const { endorsements } = await relay.refreshGroupSendEndorsements(groupIdBytes, authorization);
|
|
360
|
+
// 5. Get cached group state for member ordering (server order)
|
|
361
|
+
const state = await groupStore.getGroupState(groupId);
|
|
362
|
+
if (!state || state.members.length === 0)
|
|
363
|
+
return false;
|
|
364
|
+
// 6. Build ACI→userId mapping from known members + self
|
|
365
|
+
// Endorsements are issued in group-state member order, so we must
|
|
366
|
+
// build parallel arrays matching that order.
|
|
367
|
+
const { SERVICE_ID_ACI } = await import('../internal/protocol/zk/groups/uid-struct.js');
|
|
368
|
+
const allUserIds = [...memberUserIds, selfUserId];
|
|
369
|
+
const aciHexToUserId = new Map();
|
|
370
|
+
const resolvedAciBytes = groupsV2Config.resolveAciBytesByUserIds
|
|
371
|
+
? await groupsV2Config.resolveAciBytesByUserIds(allUserIds)
|
|
372
|
+
: new Map();
|
|
373
|
+
for (const [userId, aciBytes] of resolvedAciBytes.entries()) {
|
|
374
|
+
const hex = Array.from(aciBytes)
|
|
375
|
+
.map((b) => b.toString(16).padStart(2, '0'))
|
|
376
|
+
.join('');
|
|
377
|
+
aciHexToUserId.set(hex, userId);
|
|
378
|
+
}
|
|
379
|
+
// 7. Build parallel arrays in group-state member order
|
|
380
|
+
const memberServiceIds = [];
|
|
381
|
+
const orderedUserIds = [];
|
|
382
|
+
for (const member of state.members) {
|
|
383
|
+
const hex = Array.from(member.aciBytes)
|
|
384
|
+
.map((b) => b.toString(16).padStart(2, '0'))
|
|
385
|
+
.join('');
|
|
386
|
+
const userId = aciHexToUserId.get(hex);
|
|
387
|
+
if (!userId)
|
|
388
|
+
continue; // Unknown member — skip
|
|
389
|
+
memberServiceIds.push({
|
|
390
|
+
kind: SERVICE_ID_ACI,
|
|
391
|
+
uuid: member.aciBytes,
|
|
392
|
+
});
|
|
393
|
+
orderedUserIds.push(userId);
|
|
394
|
+
}
|
|
395
|
+
// 8. Process and cache endorsements
|
|
396
|
+
await endorsementManager.processAndCacheEndorsements(groupId, endorsements, memberServiceIds, orderedUserIds, selfUserId, secretParams);
|
|
397
|
+
return true;
|
|
398
|
+
});
|
|
399
|
+
}
|
|
400
|
+
// NOTE: hooks are initialized in constructor (this.hooks = config?.hooks || {})
|
|
401
|
+
if (config?.enableDebugLogging) {
|
|
402
|
+
this.logger.debug('SignalProtocolClient created', {
|
|
403
|
+
category: 'E2EE',
|
|
404
|
+
data: { userId, deviceId, config: this.sanitizeConfig(config) },
|
|
405
|
+
});
|
|
406
|
+
}
|
|
407
|
+
// Cache own address (userId and deviceId are immutable)
|
|
408
|
+
this._address = ProtocolAddress.create(this.userId, this.deviceId);
|
|
409
|
+
}
|
|
410
|
+
/**
|
|
411
|
+
* Get client context for operation modules
|
|
412
|
+
*/
|
|
413
|
+
get ctx() {
|
|
414
|
+
return {
|
|
415
|
+
userId: this.userId,
|
|
416
|
+
deviceId: this.deviceId,
|
|
417
|
+
manager: this.manager,
|
|
418
|
+
storage: this._storage,
|
|
419
|
+
relay: this.relay,
|
|
420
|
+
remoteObjectStore: this.remoteObjectStore,
|
|
421
|
+
config: this.config,
|
|
422
|
+
logger: this.logger,
|
|
423
|
+
hooks: this.hooks,
|
|
424
|
+
sesameManager: this.sesameManager,
|
|
425
|
+
contentAdapter: this.contentAdapter,
|
|
426
|
+
};
|
|
427
|
+
}
|
|
428
|
+
/**
|
|
429
|
+
* Whether sealed sender is enabled and configured.
|
|
430
|
+
*/
|
|
431
|
+
get isSealedSenderEnabled() {
|
|
432
|
+
const ss = this.config.sealedSender;
|
|
433
|
+
return !!(ss && ss.accessMode !== 'disabled' && ss.trustRoots.length > 0);
|
|
434
|
+
}
|
|
435
|
+
/**
|
|
436
|
+
* Fetch (or return cached) sender certificate for sealed sender.
|
|
437
|
+
*
|
|
438
|
+
* Uses the configured certificateProvider or relay.fetchSenderCertificate().
|
|
439
|
+
* Caches the result until expiry (24h certificate, 5min safety margin).
|
|
440
|
+
*
|
|
441
|
+
* @returns Base64-encoded serialized SenderCertificate
|
|
442
|
+
* @throws if no certificate provider is available
|
|
443
|
+
*/
|
|
444
|
+
async fetchSenderCertificate() {
|
|
445
|
+
const { SEALED_SENDER_CERTIFICATE_MARGIN_MS } = await import('./config.js');
|
|
446
|
+
// Return cached if still valid (with 5min safety margin)
|
|
447
|
+
if (this.cachedSenderCertificate && Date.now() < this.cachedCertificateExpiry) {
|
|
448
|
+
return this.cachedSenderCertificate;
|
|
449
|
+
}
|
|
450
|
+
// Fetch from configured provider or relay
|
|
451
|
+
let certBase64;
|
|
452
|
+
if (this.config.sealedSender?.certificateProvider) {
|
|
453
|
+
certBase64 = await this.config.sealedSender.certificateProvider();
|
|
454
|
+
}
|
|
455
|
+
else if (this.relay?.fetchSenderCertificate) {
|
|
456
|
+
certBase64 = await this.relay.fetchSenderCertificate(this.deviceId);
|
|
457
|
+
}
|
|
458
|
+
else {
|
|
459
|
+
throw new EncryptionError('No sender certificate provider configured. Set sealedSender.certificateProvider or use a relay that supports fetchSenderCertificate.', EncryptionErrorCode.INITIALIZATION_FAILED);
|
|
460
|
+
}
|
|
461
|
+
// Cache with margin
|
|
462
|
+
const CERTIFICATE_VALIDITY_MS = 24 * 60 * 60 * 1000;
|
|
463
|
+
this.cachedSenderCertificate = certBase64;
|
|
464
|
+
this.cachedCertificateExpiry =
|
|
465
|
+
Date.now() + CERTIFICATE_VALIDITY_MS - SEALED_SENDER_CERTIFICATE_MARGIN_MS;
|
|
466
|
+
return certBase64;
|
|
467
|
+
}
|
|
468
|
+
/**
|
|
469
|
+
* Get GroupsV2Manager, throwing if not configured.
|
|
470
|
+
*/
|
|
471
|
+
get groupsV2() {
|
|
472
|
+
if (!this.groupsV2Manager) {
|
|
473
|
+
throw new EncryptionError('GroupsV2 not configured. Provide groupsV2 config to SignalProtocolClient.create().', EncryptionErrorCode.INITIALIZATION_FAILED);
|
|
474
|
+
}
|
|
475
|
+
return this.groupsV2Manager;
|
|
476
|
+
}
|
|
477
|
+
/**
|
|
478
|
+
* Get retry configuration for retry operations
|
|
479
|
+
*/
|
|
480
|
+
get retryConfig() {
|
|
481
|
+
return {
|
|
482
|
+
keyRotationDebounceMs: SIGNAL_PROTOCOL_CLIENT_CONSTANTS.KEY_ROTATION_DEBOUNCE_MS,
|
|
483
|
+
retryDedupWindowMs: SIGNAL_PROTOCOL_CLIENT_CONSTANTS.RETRY_DEDUP_WINDOW_MS,
|
|
484
|
+
retryCleanupIntervalMs: SIGNAL_PROTOCOL_CLIENT_CONSTANTS.RETRY_CLEANUP_INTERVAL_MS,
|
|
485
|
+
};
|
|
486
|
+
}
|
|
487
|
+
/**
|
|
488
|
+
* Get retry dedup state for retry operations
|
|
489
|
+
*/
|
|
490
|
+
get retryDedupState() {
|
|
491
|
+
return this.state.getRetryDedupState();
|
|
492
|
+
}
|
|
493
|
+
/**
|
|
494
|
+
* Get retry callbacks for retry operations
|
|
495
|
+
*/
|
|
496
|
+
get retryCallbacks() {
|
|
497
|
+
return {
|
|
498
|
+
archiveSession: (address) => this.archiveSession(address),
|
|
499
|
+
establishSession: (address, bundle) => this.establishSession(address, bundle),
|
|
500
|
+
send: (recipientId, content, options) => this.send(recipientId, content, options),
|
|
501
|
+
forcePreKeyRotation: () => this.regeneratePreKeysWithFreshIds(),
|
|
502
|
+
};
|
|
503
|
+
}
|
|
504
|
+
/**
|
|
505
|
+
* Get relay subscription state (passed to relay-subscription module)
|
|
506
|
+
*/
|
|
507
|
+
get relaySubscriptionState() {
|
|
508
|
+
return this.state.getRelaySubscriptionState();
|
|
509
|
+
}
|
|
510
|
+
/**
|
|
511
|
+
* Get relay subscription callbacks (delegate back to SignalProtocolClient methods)
|
|
512
|
+
*/
|
|
513
|
+
get relaySubscriptionCallbacks() {
|
|
514
|
+
return {
|
|
515
|
+
forcePreKeyRotation: () => this.regeneratePreKeysWithFreshIds(),
|
|
516
|
+
handleDeliveryReceipt: (envelope, receipt) => this.handleDeliveryReceipt(envelope, receipt),
|
|
517
|
+
handleTypingIndicator: (envelope, typing) => this.handleTypingIndicator(envelope, typing),
|
|
518
|
+
sendDeliveryReceipt: (userId, timestamps) => this.sendDeliveryReceipt(userId, timestamps),
|
|
519
|
+
};
|
|
520
|
+
}
|
|
521
|
+
/**
|
|
522
|
+
* Get relay subscription config
|
|
523
|
+
*/
|
|
524
|
+
get relaySubscriptionConfig() {
|
|
525
|
+
return {
|
|
526
|
+
keyRotationDebounceMs: SIGNAL_PROTOCOL_CLIENT_CONSTANTS.KEY_ROTATION_DEBOUNCE_MS,
|
|
527
|
+
};
|
|
528
|
+
}
|
|
529
|
+
/**
|
|
530
|
+
* Create and initialize a new SignalProtocolClient instance.
|
|
531
|
+
*
|
|
532
|
+
* This low-level factory ensures the client is fully initialized before it is
|
|
533
|
+
* returned. Most app code should prefer `createSignalProtocolClient()` so identity,
|
|
534
|
+
* adapters, and protocol policy are grouped in one object.
|
|
535
|
+
*
|
|
536
|
+
* If `relay` is provided in config, the client automatically uploads the
|
|
537
|
+
* public prekey bundle needed for end-to-end encrypted messaging.
|
|
538
|
+
*
|
|
539
|
+
* @param userId - User identifier for this device/client
|
|
540
|
+
* @param config - Optional configuration for the client
|
|
541
|
+
* @returns Fully initialized SignalProtocolClient instance
|
|
542
|
+
*
|
|
543
|
+
* @example
|
|
544
|
+
* ```typescript
|
|
545
|
+
* import { SignalProtocolClient } from '@open-e2ee/signal-protocol-sdk';
|
|
546
|
+
* import { convexRelay } from '@open-e2ee/signal-protocol-sdk/remote/relay/convex';
|
|
547
|
+
*
|
|
548
|
+
* // Local-only primary device.
|
|
549
|
+
* const signal = await SignalProtocolClient.create('user-123', {
|
|
550
|
+
* storage,
|
|
551
|
+
* });
|
|
552
|
+
*
|
|
553
|
+
* // Linked device; storage must already contain provisioned identity material.
|
|
554
|
+
* const signal = await SignalProtocolClient.create('user-123', {
|
|
555
|
+
* deviceId: 2,
|
|
556
|
+
* storage: provisionedLinkedDeviceStorage
|
|
557
|
+
* });
|
|
558
|
+
*
|
|
559
|
+
* // With relay sync.
|
|
560
|
+
* const relay = convexRelay({ convex, api: signalApi, currentUserId: userId });
|
|
561
|
+
* const signal = await SignalProtocolClient.create('user-123', {
|
|
562
|
+
* storage,
|
|
563
|
+
* relay,
|
|
564
|
+
* onProgress: ({ stage, percent, message }) => {
|
|
565
|
+
* console.log(`${stage}: ${percent}% - ${message}`);
|
|
566
|
+
* }
|
|
567
|
+
* });
|
|
568
|
+
*
|
|
569
|
+
* // With full configuration
|
|
570
|
+
* const signal = await SignalProtocolClient.create('user-123', {
|
|
571
|
+
* deviceId: 1,
|
|
572
|
+
* storage,
|
|
573
|
+
* relay,
|
|
574
|
+
* protocol: { postQuantum: 'required', braid: 'required' },
|
|
575
|
+
* onProgress,
|
|
576
|
+
* enableDebugLogging: true,
|
|
577
|
+
* ratchetConfig: { maxSkip: 2000 }
|
|
578
|
+
* });
|
|
579
|
+
*
|
|
580
|
+
* // For local development with in-memory adapters
|
|
581
|
+
* const signal = await SignalProtocolClient.create('local-user', {
|
|
582
|
+
* protocolManager: mockManager,
|
|
583
|
+
* storage: mockStorage
|
|
584
|
+
* });
|
|
585
|
+
* ```
|
|
586
|
+
*/
|
|
587
|
+
static async create(userId, config) {
|
|
588
|
+
const deviceId = config?.deviceId ?? 1; // Default to primary device
|
|
589
|
+
// Use locking to prevent race conditions when multiple create() calls happen concurrently.
|
|
590
|
+
// This ensures only one storage instance per userId is created, preventing database lock
|
|
591
|
+
// contention and session state corruption.
|
|
592
|
+
return storageLock.acquire(`storage-init-${userId}`, async () => {
|
|
593
|
+
// Storage is required - SignalProtocolClient is platform-agnostic
|
|
594
|
+
// Each platform must provide its own storage implementation
|
|
595
|
+
if (!config?.storage) {
|
|
596
|
+
throw new Error('SignalProtocolClient.create() requires storage. ' +
|
|
597
|
+
'Expo: import { expoStore } from "@open-e2ee/signal-protocol-sdk/local/store/expo"; ' +
|
|
598
|
+
'Web: import { indexedDbStore } from "@open-e2ee/signal-protocol-sdk/local/store/web"; ' +
|
|
599
|
+
'Node: import { nodeStore } from "@open-e2ee/signal-protocol-sdk/local/store/node";');
|
|
600
|
+
}
|
|
601
|
+
const finalConfig = {
|
|
602
|
+
...config,
|
|
603
|
+
protocolStrategy: resolveSignalProtocolStrategy(config),
|
|
604
|
+
storage: config.storage,
|
|
605
|
+
};
|
|
606
|
+
const activeIdentityTypes = getActiveIdentityTypes(finalConfig);
|
|
607
|
+
if (deviceId > 1) {
|
|
608
|
+
for (const identityType of activeIdentityTypes) {
|
|
609
|
+
const hasIdentityKey = await finalConfig.storage.hasIdentityKey(identityType);
|
|
610
|
+
if (!hasIdentityKey) {
|
|
611
|
+
throw new Error(`Linked device ${deviceId} requires a provisioned ${identityType.toUpperCase()} identity key in storage. ` +
|
|
612
|
+
'Provision the device first, then create the client with that storage.');
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
const client = new SignalProtocolClient(userId, deviceId, finalConfig);
|
|
617
|
+
await client.initialize();
|
|
618
|
+
await client.hydratePersistedState();
|
|
619
|
+
// Cleanup expired sessions and message records on startup.
|
|
620
|
+
// Signal relies on event-driven cleanup (identity change, retry, end-session);
|
|
621
|
+
// we additionally enforce our maxRecv TTL here to prevent unbounded session growth.
|
|
622
|
+
try {
|
|
623
|
+
await client.sesameManager.cleanupExpiredSessions();
|
|
624
|
+
await client._storage.deleteExpiredMessageRecords(MESSAGE_RECORD_TTL_MS);
|
|
625
|
+
}
|
|
626
|
+
catch (cleanupError) {
|
|
627
|
+
// Non-fatal: cleanup failures should not prevent client creation
|
|
628
|
+
client.logger.debug('Startup session/record cleanup failed', {
|
|
629
|
+
category: 'E2EE',
|
|
630
|
+
data: { error: cleanupError.message },
|
|
631
|
+
});
|
|
632
|
+
}
|
|
633
|
+
// Auto-sync to server if relay provided
|
|
634
|
+
let syncFailed = false;
|
|
635
|
+
if (finalConfig?.relay) {
|
|
636
|
+
try {
|
|
637
|
+
await client.syncToServer(finalConfig.onProgress);
|
|
638
|
+
}
|
|
639
|
+
catch (e) {
|
|
640
|
+
client.logger.warn('Initial sync failed, client created in offline mode', {
|
|
641
|
+
category: 'E2EE',
|
|
642
|
+
data: { error: e },
|
|
643
|
+
});
|
|
644
|
+
syncFailed = true;
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
client._syncStatus = finalConfig?.relay ? (syncFailed ? 'failed' : 'synced') : 'none';
|
|
648
|
+
// Start relay subscription if relay is configured with onMessageDecrypted hook
|
|
649
|
+
// Only subscribe if sync succeeded - subscriptions require a valid server session
|
|
650
|
+
if (!syncFailed && finalConfig?.relay && finalConfig?.hooks?.onMessageDecrypted) {
|
|
651
|
+
client.startRelaySubscription();
|
|
652
|
+
}
|
|
653
|
+
// Start retry request subscription if relay supports it (SESAME spec §6.2)
|
|
654
|
+
if (!syncFailed && finalConfig?.relay?.subscribeRetryRequests) {
|
|
655
|
+
client.startRetryRequestSubscription();
|
|
656
|
+
}
|
|
657
|
+
// Validate sender keys config and warn on extreme values
|
|
658
|
+
if (finalConfig?.senderKeys) {
|
|
659
|
+
const sk = finalConfig.senderKeys;
|
|
660
|
+
if (sk.maxChainAdvance !== undefined && sk.maxChainAdvance < 100) {
|
|
661
|
+
client.logger.warn('senderKeys.maxChainAdvance < 100 may reject legitimate delayed messages', {
|
|
662
|
+
category: 'E2EE',
|
|
663
|
+
data: { value: sk.maxChainAdvance },
|
|
664
|
+
});
|
|
665
|
+
}
|
|
666
|
+
if (sk.maxSkippedKeys !== undefined && sk.maxSkippedKeys > 10000) {
|
|
667
|
+
client.logger.warn('senderKeys.maxSkippedKeys > 10000 may cause memory issues', {
|
|
668
|
+
category: 'E2EE',
|
|
669
|
+
data: { value: sk.maxSkippedKeys },
|
|
670
|
+
});
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
return client;
|
|
674
|
+
});
|
|
675
|
+
}
|
|
676
|
+
// ============================================================================
|
|
677
|
+
// INITIALIZATION & SETUP
|
|
678
|
+
// ============================================================================
|
|
679
|
+
/**
|
|
680
|
+
* Initialize the Signal Protocol on this device (private - called by create())
|
|
681
|
+
*
|
|
682
|
+
* Generates identity keys if they don't exist and prepares the client for use.
|
|
683
|
+
*/
|
|
684
|
+
async initialize() {
|
|
685
|
+
try {
|
|
686
|
+
await this.manager.initialize(getActiveIdentityTypes(this.config));
|
|
687
|
+
// Set local identity so manager knows who we are for session operations
|
|
688
|
+
// This is needed even without server sync (local-only mode)
|
|
689
|
+
this.manager.setLocalIdentity(this.userId, this.deviceId);
|
|
690
|
+
// UserID is plain string, DeviceID is plain number - no cast needed
|
|
691
|
+
await this.sesameManager.initialize(this.userId, this.deviceId);
|
|
692
|
+
this.logger.debug('Signal Protocol initialized', {
|
|
693
|
+
category: 'E2EE',
|
|
694
|
+
data: { userId: this.userId, deviceId: this.deviceId },
|
|
695
|
+
});
|
|
696
|
+
}
|
|
697
|
+
catch (error) {
|
|
698
|
+
throw new EncryptionError('Failed to initialize Signal Protocol', EncryptionErrorCode.INITIALIZATION_FAILED, { originalError: error });
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
/**
|
|
702
|
+
* Sync the public prekey bundle to the configured relay.
|
|
703
|
+
*
|
|
704
|
+
* Called automatically by create() when a relay is configured.
|
|
705
|
+
* Can also be called manually to retry after a failed initial sync.
|
|
706
|
+
*
|
|
707
|
+
* Delegates to PreKeyOps.syncToServer for implementation.
|
|
708
|
+
*/
|
|
709
|
+
async syncToServer(onProgress) {
|
|
710
|
+
await PreKeyOps.syncToServer(this.ctx, onProgress);
|
|
711
|
+
this._syncStatus = 'synced';
|
|
712
|
+
}
|
|
713
|
+
/**
|
|
714
|
+
* Explicitly rotate this account's relay identity using a caller-authenticated
|
|
715
|
+
* compare-and-swap commitment, then publish fresh prekeys for that namespace.
|
|
716
|
+
* Normal sync and linked-device provisioning never call this operation.
|
|
717
|
+
*/
|
|
718
|
+
async rotateAccountIdentity(expectedCurrentCommitment, identityType = 'aci') {
|
|
719
|
+
if (!this.config.relay) {
|
|
720
|
+
throw new EncryptionError('Relay server not configured', EncryptionErrorCode.INITIALIZATION_FAILED);
|
|
721
|
+
}
|
|
722
|
+
if (expectedCurrentCommitment.length !== 32) {
|
|
723
|
+
throw new Error('Expected current identity commitment must contain exactly 32 bytes');
|
|
724
|
+
}
|
|
725
|
+
const replacement = await this._storage.getIdentityKey(identityType);
|
|
726
|
+
if (!replacement) {
|
|
727
|
+
throw new Error(`Cannot rotate missing local ${identityType.toUpperCase()} identity`);
|
|
728
|
+
}
|
|
729
|
+
this._syncStatus = 'failed';
|
|
730
|
+
try {
|
|
731
|
+
await this.config.relay.rotateIdentityKey({
|
|
732
|
+
userId: this.userId,
|
|
733
|
+
deviceId: this.deviceId,
|
|
734
|
+
identity: createCompositeIdentityV1(replacement),
|
|
735
|
+
registrationId: replacement.registrationId,
|
|
736
|
+
identityType,
|
|
737
|
+
expectedCurrentCommitment,
|
|
738
|
+
});
|
|
739
|
+
await PreKeyOps.syncIdentityToServer(this.ctx, identityType);
|
|
740
|
+
this._syncStatus = 'synced';
|
|
741
|
+
}
|
|
742
|
+
catch (error) {
|
|
743
|
+
// A relay may have committed the CAS rotation before a later prekey
|
|
744
|
+
// upload failed. Keep the client explicitly offline; syncToServer() is
|
|
745
|
+
// the idempotent recovery operation for that availability-only gap.
|
|
746
|
+
this._syncStatus = 'failed';
|
|
747
|
+
throw error;
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
// ============================================================================
|
|
751
|
+
// Key Recovery / Forced Rotation
|
|
752
|
+
// ============================================================================
|
|
753
|
+
/**
|
|
754
|
+
* Force prekey rotation: generate new keys with fresh IDs and upload.
|
|
755
|
+
*
|
|
756
|
+
* Called automatically on stale prekey detection and as recovery for
|
|
757
|
+
* PQXDH §4.13 identifier collisions.
|
|
758
|
+
*
|
|
759
|
+
* Delegates to PreKeyOps.regeneratePreKeysWithFreshIds for implementation.
|
|
760
|
+
*/
|
|
761
|
+
/**
|
|
762
|
+
* Hydrate state from persistent storage.
|
|
763
|
+
*/
|
|
764
|
+
async hydratePersistedState() {
|
|
765
|
+
try {
|
|
766
|
+
const stored = await this._storage.getMetadata('lastForcedPreKeyRotation');
|
|
767
|
+
if (stored) {
|
|
768
|
+
const timestamp = parseInt(stored, 10);
|
|
769
|
+
if (!isNaN(timestamp) && timestamp > 0) {
|
|
770
|
+
this.state.setLastPreKeyRotationTime(timestamp);
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
catch (error) {
|
|
775
|
+
// Best-effort: if storage read fails, start with timestamp 0.
|
|
776
|
+
// Next stale-prekey error will trigger rotation immediately (safe).
|
|
777
|
+
this.logger.debug('Failed to hydrate persisted rotation state', {
|
|
778
|
+
category: 'E2EE',
|
|
779
|
+
data: { error: error.message },
|
|
780
|
+
});
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
async regeneratePreKeysWithFreshIds() {
|
|
784
|
+
await PreKeyOps.regeneratePreKeysWithFreshIds(this.ctx);
|
|
785
|
+
const now = Date.now();
|
|
786
|
+
// Update debounce timestamp so concurrent call sites (relay-subscription + retry.ts)
|
|
787
|
+
// don't both trigger rotation for the same stale prekey event.
|
|
788
|
+
this.state.setLastPreKeyRotationTime(now);
|
|
789
|
+
// Persist the debounce timestamp across application restarts.
|
|
790
|
+
await this._storage.setMetadata('lastForcedPreKeyRotation', String(now));
|
|
791
|
+
}
|
|
792
|
+
/**
|
|
793
|
+
* Verify server has correct keys after upload.
|
|
794
|
+
*
|
|
795
|
+
* Delegates to PreKeyOps.verifyServerKeys for implementation.
|
|
796
|
+
*/
|
|
797
|
+
async verifyServerKeys(signedPreKey, kyberPreKey, operation) {
|
|
798
|
+
return PreKeyOps.verifyServerKeys(this.ctx, signedPreKey, kyberPreKey, operation);
|
|
799
|
+
}
|
|
800
|
+
/**
|
|
801
|
+
* Force complete key reset (development/debugging only).
|
|
802
|
+
*
|
|
803
|
+
* Delegates to PreKeyOps.forceCompleteKeyReset for implementation.
|
|
804
|
+
*/
|
|
805
|
+
async forceCompleteKeyReset() {
|
|
806
|
+
const result = await PreKeyOps.forceCompleteKeyReset(this.ctx);
|
|
807
|
+
// Clear internal tracking state via state manager
|
|
808
|
+
this.state.clearForStop();
|
|
809
|
+
return result;
|
|
810
|
+
}
|
|
811
|
+
/**
|
|
812
|
+
* Check if client is initialized
|
|
813
|
+
*
|
|
814
|
+
* @returns True if identity keys exist and client is ready to use
|
|
815
|
+
*/
|
|
816
|
+
async isInitialized() {
|
|
817
|
+
return await this._storage.hasIdentityKey();
|
|
818
|
+
}
|
|
819
|
+
/**
|
|
820
|
+
* Get client's identity public key
|
|
821
|
+
*
|
|
822
|
+
* @returns Public key for this device's identity
|
|
823
|
+
*/
|
|
824
|
+
async getIdentityPublicKey() {
|
|
825
|
+
const identityKey = await this._storage.getIdentityKey();
|
|
826
|
+
if (!identityKey) {
|
|
827
|
+
throw new EncryptionError('Identity key not found - client not initialized', EncryptionErrorCode.INITIALIZATION_FAILED);
|
|
828
|
+
}
|
|
829
|
+
return identityKey.signingKey.publicKey;
|
|
830
|
+
}
|
|
831
|
+
/**
|
|
832
|
+
* Get the ProtocolAddress for this client's device.
|
|
833
|
+
*
|
|
834
|
+
* Useful when an integration needs to reference the local device.
|
|
835
|
+
*
|
|
836
|
+
* @returns ProtocolAddress for this client (userId:deviceId)
|
|
837
|
+
*
|
|
838
|
+
* @example
|
|
839
|
+
* ```typescript
|
|
840
|
+
* const alice = await SignalProtocolClient.create('alice', { storage: aliceStorage });
|
|
841
|
+
* const bob = await SignalProtocolClient.create('bob', { storage: bobStorage });
|
|
842
|
+
*
|
|
843
|
+
* // Use address() to reference the local device
|
|
844
|
+
* await alice.encryptMessage(bob.address(), 'Hello');
|
|
845
|
+
* await bob.decryptMessage(alice.address(), encrypted);
|
|
846
|
+
*
|
|
847
|
+
* // Access userId if needed
|
|
848
|
+
* console.log(alice.address().userId); // 'alice'
|
|
849
|
+
* ```
|
|
850
|
+
*/
|
|
851
|
+
address() {
|
|
852
|
+
return this._address;
|
|
853
|
+
}
|
|
854
|
+
// ============================================================================
|
|
855
|
+
// SESSION MANAGEMENT
|
|
856
|
+
// ============================================================================
|
|
857
|
+
/**
|
|
858
|
+
* Establish a new session with a specific remote device.
|
|
859
|
+
*
|
|
860
|
+
* Advanced direct-device API. Normal app code can call `send(recipientUserId, content)`;
|
|
861
|
+
* the client will fetch remote device bundles through the configured relay and
|
|
862
|
+
* use the selected protocol policy. Direct callers must provide the remote
|
|
863
|
+
* device's prekey bundle themselves.
|
|
864
|
+
*
|
|
865
|
+
* @param remoteAddress - Partner's protocol address (userId + deviceId)
|
|
866
|
+
* @param prekeyBundle - Partner's prekey bundle (fetched from server)
|
|
867
|
+
*
|
|
868
|
+
* @example
|
|
869
|
+
* ```typescript
|
|
870
|
+
* import { ProtocolAddress } from '@open-e2ee/signal-protocol-sdk';
|
|
871
|
+
*
|
|
872
|
+
* const remoteAddress = ProtocolAddress.create('bob', 1);
|
|
873
|
+
* const bundle = await relay.fetchPreKeyBundle(remoteAddress.userId);
|
|
874
|
+
* await signal.establishSession(remoteAddress, bundle);
|
|
875
|
+
* ```
|
|
876
|
+
*/
|
|
877
|
+
async establishSession(remoteAddress, prekeyBundle, recipientIdentityType = 'aci') {
|
|
878
|
+
return SessionOps.establishSession(this.ctx, this.sesameManager, remoteAddress, prekeyBundle, recipientIdentityType);
|
|
879
|
+
}
|
|
880
|
+
/**
|
|
881
|
+
* Check if a session exists
|
|
882
|
+
*
|
|
883
|
+
* @param remoteAddress - Remote device's protocol address
|
|
884
|
+
* @returns True if session exists
|
|
885
|
+
*/
|
|
886
|
+
async hasSession(remoteAddress) {
|
|
887
|
+
return SessionOps.hasSession(this.ctx, remoteAddress);
|
|
888
|
+
}
|
|
889
|
+
/**
|
|
890
|
+
* Delete a session
|
|
891
|
+
*
|
|
892
|
+
* Use this to reset encryption for a session (e.g., after a security incident).
|
|
893
|
+
* You'll need to establish a new session before sending/receiving messages.
|
|
894
|
+
*
|
|
895
|
+
* @param remoteAddress - Remote device's protocol address
|
|
896
|
+
*/
|
|
897
|
+
async deleteSession(remoteAddress) {
|
|
898
|
+
return SessionOps.deleteSession(this.ctx, remoteAddress);
|
|
899
|
+
}
|
|
900
|
+
/**
|
|
901
|
+
* Archive a session after a stale-device response.
|
|
902
|
+
*
|
|
903
|
+
* Moves current session to inactive list, preserving it for delayed message decryption.
|
|
904
|
+
* Per SESAME §3.2: "previously active session is moved to the head of the inactive sessions list"
|
|
905
|
+
*
|
|
906
|
+
* Use this when handling stale device errors (410) - the old session may still be needed
|
|
907
|
+
* to decrypt messages that were in-flight during the session refresh.
|
|
908
|
+
*
|
|
909
|
+
* @param remoteAddress - Remote device's protocol address
|
|
910
|
+
*/
|
|
911
|
+
async archiveSession(remoteAddress) {
|
|
912
|
+
return SessionOps.archiveSession(this.ctx, remoteAddress);
|
|
913
|
+
}
|
|
914
|
+
/**
|
|
915
|
+
* Mark a message as delivered, silently ignoring errors.
|
|
916
|
+
*
|
|
917
|
+
* Used when discarding undecryptable messages (IMPLICIT content, stale prekeys)
|
|
918
|
+
* to prevent them from reappearing in the queue.
|
|
919
|
+
*
|
|
920
|
+
* @param envelopeId - The envelope ID to mark as delivered
|
|
921
|
+
* @param options - Decryption options containing optional markDelivered callback
|
|
922
|
+
*/
|
|
923
|
+
async markMessageDeliveredSilently(envelopeId, options) {
|
|
924
|
+
if (!envelopeId)
|
|
925
|
+
return;
|
|
926
|
+
if (this.relay?.markDelivered) {
|
|
927
|
+
await this.relay.markDelivered(envelopeId).catch((_error) => {
|
|
928
|
+
this.logger.warn('Failed to mark delivered', {
|
|
929
|
+
category: 'E2EE',
|
|
930
|
+
data: { envelopeId },
|
|
931
|
+
});
|
|
932
|
+
});
|
|
933
|
+
}
|
|
934
|
+
else if (options?.markDelivered) {
|
|
935
|
+
await options.markDelivered(envelopeId).catch((_error) => {
|
|
936
|
+
this.logger.warn('Failed to mark delivered', {
|
|
937
|
+
category: 'E2EE',
|
|
938
|
+
data: { envelopeId },
|
|
939
|
+
});
|
|
940
|
+
});
|
|
941
|
+
}
|
|
942
|
+
}
|
|
943
|
+
// ============================================================================
|
|
944
|
+
// MESSAGE ENCRYPTION/DECRYPTION (delegated to messages.ts)
|
|
945
|
+
// ============================================================================
|
|
946
|
+
/** @see MessageOps.encryptMessage */
|
|
947
|
+
async encryptMessage(remoteAddress, plaintext) {
|
|
948
|
+
return MessageOps.encryptMessage(this.ctx, remoteAddress, plaintext);
|
|
949
|
+
}
|
|
950
|
+
/**
|
|
951
|
+
* Decrypt a message from a session
|
|
952
|
+
*
|
|
953
|
+
* Uses the Double Ratchet algorithm to decrypt ciphertext, handling
|
|
954
|
+
* out-of-order messages and updating session state.
|
|
955
|
+
*
|
|
956
|
+
* @param remoteAddress - Remote device's protocol address
|
|
957
|
+
* @param ciphertext - Message to decrypt
|
|
958
|
+
* @returns Decrypted plaintext
|
|
959
|
+
*/
|
|
960
|
+
async decryptMessage(remoteAddress, ciphertext) {
|
|
961
|
+
return MessageOps.decryptMessage(this.ctx, remoteAddress, ciphertext);
|
|
962
|
+
}
|
|
963
|
+
/**
|
|
964
|
+
* Encrypt multiple messages in batch
|
|
965
|
+
*
|
|
966
|
+
* More efficient than calling encryptMessage() multiple times.
|
|
967
|
+
* Operations are performed atomically - if any encryption fails,
|
|
968
|
+
* none of the messages are encrypted.
|
|
969
|
+
*
|
|
970
|
+
* @param remoteAddress - Remote device's protocol address
|
|
971
|
+
* @param plaintexts - Array of messages to encrypt
|
|
972
|
+
* @returns Array of encrypted ciphertexts in the same order
|
|
973
|
+
*/
|
|
974
|
+
async encryptMessages(remoteAddress, plaintexts) {
|
|
975
|
+
return MessageOps.encryptMessages(this.ctx, remoteAddress, plaintexts);
|
|
976
|
+
}
|
|
977
|
+
/**
|
|
978
|
+
* Decrypt multiple messages in batch
|
|
979
|
+
*
|
|
980
|
+
* More efficient than calling decryptMessage() multiple times.
|
|
981
|
+
* Handles out-of-order messages correctly.
|
|
982
|
+
*
|
|
983
|
+
* @param remoteAddress - Remote device's protocol address
|
|
984
|
+
* @param ciphertexts - Array of messages to decrypt
|
|
985
|
+
* @returns Array of decrypted plaintexts in the same order
|
|
986
|
+
*/
|
|
987
|
+
async decryptMessages(remoteAddress, ciphertexts) {
|
|
988
|
+
return MessageOps.decryptMessages(this.ctx, remoteAddress, ciphertexts);
|
|
989
|
+
}
|
|
990
|
+
/**
|
|
991
|
+
* Process an incoming encrypted message envelope.
|
|
992
|
+
*
|
|
993
|
+
* Unified entry point for both foreground (relay) and background (HTTP) message processing.
|
|
994
|
+
* Handles decryption and automatically sends SESAME retry requests on retryable failures.
|
|
995
|
+
*
|
|
996
|
+
* This method:
|
|
997
|
+
* 1. Decodes base64 ciphertext from the envelope
|
|
998
|
+
* 2. Decrypts message using Double Ratchet
|
|
999
|
+
* 3. On retryable error: sends retry request via relay or options callback
|
|
1000
|
+
* 4. Re-throws error for caller to handle
|
|
1001
|
+
*
|
|
1002
|
+
* @param envelope - The encrypted message envelope
|
|
1003
|
+
* @param options - Transport callbacks for background (no relay) scenarios
|
|
1004
|
+
* @returns Decrypted plaintext
|
|
1005
|
+
* @throws EncryptionError after sending retry request if decryption fails
|
|
1006
|
+
*/
|
|
1007
|
+
async processIncomingEnvelope(envelope, options) {
|
|
1008
|
+
// Handle sealed sender envelopes: unseal to reveal sender before decrypting
|
|
1009
|
+
if (envelope.messageType === 'unidentified_sender' && this.config.sealedSender) {
|
|
1010
|
+
const { unsealMessage } = await import('./sealed-sender-ops.js');
|
|
1011
|
+
const identityKeyPair = await this._storage.getIdentityKey();
|
|
1012
|
+
if (!identityKeyPair) {
|
|
1013
|
+
throw new EncryptionError('No identity key pair for sealed sender decryption', EncryptionErrorCode.DECRYPTION_FAILED);
|
|
1014
|
+
}
|
|
1015
|
+
const recipientPrivateKeyBytes = base64ToBytes(identityKeyPair.dhKey.privateKey);
|
|
1016
|
+
const unsealed = await unsealMessage(envelope.ciphertext, recipientPrivateKeyBytes, this.userId, this.deviceId, this.config.sealedSender, this.logger);
|
|
1017
|
+
// Process the inner envelope with revealed sender identity
|
|
1018
|
+
// Detect group messages from groupId on the sealed envelope
|
|
1019
|
+
return this.processIncomingEnvelope({
|
|
1020
|
+
...envelope,
|
|
1021
|
+
senderUserId: unsealed.senderUserId,
|
|
1022
|
+
senderDeviceId: unsealed.senderDeviceId,
|
|
1023
|
+
ciphertext: unsealed.innerCiphertextBase64,
|
|
1024
|
+
messageType: 'ciphertext',
|
|
1025
|
+
}, options);
|
|
1026
|
+
}
|
|
1027
|
+
// Route group messages to sender key decryption
|
|
1028
|
+
// Group messages arrive as 'ciphertext' with groupId set
|
|
1029
|
+
if (envelope.groupId && envelope.messageType === 'ciphertext') {
|
|
1030
|
+
// Framed SenderKeyMessage: base64 → bytes (Uint8Array)
|
|
1031
|
+
const framedBytes = base64ToBytes(envelope.ciphertext);
|
|
1032
|
+
return this.decryptGroupMessage(envelope.groupId, envelope.senderUserId, envelope.senderDeviceId, framedBytes);
|
|
1033
|
+
}
|
|
1034
|
+
const senderAddress = ProtocolAddress.create(envelope.senderUserId, envelope.senderDeviceId);
|
|
1035
|
+
try {
|
|
1036
|
+
// Decode ciphertext: base64 → UTF-8 bytes → JSON string
|
|
1037
|
+
// Relay stores as base64(UTF-8(JSON)), we need to reverse both encodings
|
|
1038
|
+
const ciphertextBytes = base64ToBytes(envelope.ciphertext);
|
|
1039
|
+
const ciphertext = new TextDecoder().decode(ciphertextBytes);
|
|
1040
|
+
// Decrypt message using Double Ratchet
|
|
1041
|
+
const plaintext = await this.decryptMessage(senderAddress, ciphertext);
|
|
1042
|
+
return plaintext;
|
|
1043
|
+
}
|
|
1044
|
+
catch (error) {
|
|
1045
|
+
// Send retry request if error is retryable (per SESAME spec §4.1)
|
|
1046
|
+
if (isRetryableDecryptionError(error)) {
|
|
1047
|
+
await this.sendRetryRequestInternal(envelope, error, options);
|
|
1048
|
+
}
|
|
1049
|
+
// Re-throw so caller can handle (log, skip message, etc.)
|
|
1050
|
+
throw error;
|
|
1051
|
+
}
|
|
1052
|
+
}
|
|
1053
|
+
/**
|
|
1054
|
+
* Process multiple incoming encrypted message envelopes.
|
|
1055
|
+
*
|
|
1056
|
+
* This is the preferred method for batch message processing. It handles:
|
|
1057
|
+
* 1. Sorting PreKeyMessages before ciphertexts (SESAME session convergence)
|
|
1058
|
+
* 2. Processing each envelope in order
|
|
1059
|
+
* 3. Collecting results/errors for caller to handle
|
|
1060
|
+
*
|
|
1061
|
+
* The sorting ensures PreKeyMessages (which establish sessions) are processed
|
|
1062
|
+
* before ciphertexts that depend on those sessions. This is required for
|
|
1063
|
+
* SESAME Section 3.4 session convergence when archived sessions are promoted.
|
|
1064
|
+
*
|
|
1065
|
+
* @param envelopes - Array of encrypted message envelopes
|
|
1066
|
+
* @param options - Transport callbacks for background scenarios
|
|
1067
|
+
* @returns Array of results, each either success (plaintext) or failure (error)
|
|
1068
|
+
*
|
|
1069
|
+
* @example
|
|
1070
|
+
* ```typescript
|
|
1071
|
+
* const results = await signal.processIncomingEnvelopes(pendingMessages);
|
|
1072
|
+
* for (const result of results) {
|
|
1073
|
+
* if ('plaintext' in result) {
|
|
1074
|
+
* handleDecryptedMessage(result.envelope, result.plaintext);
|
|
1075
|
+
* } else {
|
|
1076
|
+
* handleDecryptionError(result.envelope, result.error);
|
|
1077
|
+
* }
|
|
1078
|
+
* }
|
|
1079
|
+
* ```
|
|
1080
|
+
*
|
|
1081
|
+
* @see https://signal.org/docs/specifications/sesame/ Section 3.4
|
|
1082
|
+
*/
|
|
1083
|
+
async processIncomingEnvelopes(envelopes, options) {
|
|
1084
|
+
// Sort PreKeyMessages first - they establish sessions needed by subsequent ciphertexts
|
|
1085
|
+
// This is internal - callers don't need to know about SESAME session convergence
|
|
1086
|
+
const sorted = sortEnvelopesForDecryption(envelopes);
|
|
1087
|
+
const results = [];
|
|
1088
|
+
for (const envelope of sorted) {
|
|
1089
|
+
try {
|
|
1090
|
+
const plaintext = await this.processIncomingEnvelope(envelope, options);
|
|
1091
|
+
results.push({ envelope, plaintext });
|
|
1092
|
+
}
|
|
1093
|
+
catch (error) {
|
|
1094
|
+
results.push({ envelope, error: error });
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
return results;
|
|
1098
|
+
}
|
|
1099
|
+
/**
|
|
1100
|
+
* Internal: Send SESAME retry request for failed decryption.
|
|
1101
|
+
*
|
|
1102
|
+
* Uses relay if available, otherwise falls back to options callback.
|
|
1103
|
+
* Called automatically by processIncomingEnvelope on retryable errors.
|
|
1104
|
+
*
|
|
1105
|
+
* @param envelope - The failed message envelope
|
|
1106
|
+
* @param error - The decryption error
|
|
1107
|
+
* @param options - Optional transport callbacks (for background without relay)
|
|
1108
|
+
*/
|
|
1109
|
+
async sendRetryRequestInternal(envelope, error, options) {
|
|
1110
|
+
return RetryOps.sendRetryRequestInternal(this.ctx, envelope, error, this.rateLimitState, { forcePreKeyRotation: () => this.regeneratePreKeysWithFreshIds() }, this.retryConfig, options);
|
|
1111
|
+
}
|
|
1112
|
+
// ============================================================================
|
|
1113
|
+
// FILE ENCRYPTION/DECRYPTION (delegated to files.ts)
|
|
1114
|
+
// ============================================================================
|
|
1115
|
+
/**
|
|
1116
|
+
* Encrypt file blob with two-layer encryption
|
|
1117
|
+
*
|
|
1118
|
+
* Layer 1: Random symmetric key encrypts the file
|
|
1119
|
+
* Layer 2: Signal Protocol encrypts the symmetric key
|
|
1120
|
+
*
|
|
1121
|
+
* This allows efficient storage of large files with Signal Protocol key rotation.
|
|
1122
|
+
*
|
|
1123
|
+
* @param remoteAddress - Remote device's protocol address
|
|
1124
|
+
* @param fileBlob - File data to encrypt
|
|
1125
|
+
* @param mimeType - Optional MIME type (defaults to fileBlob.type)
|
|
1126
|
+
* @returns Encrypted blob, key ID, and encrypted key
|
|
1127
|
+
*/
|
|
1128
|
+
async encryptFile(remoteAddress, fileBlob, mimeType) {
|
|
1129
|
+
return FileOps.encryptFile(this.ctx, remoteAddress, fileBlob, mimeType);
|
|
1130
|
+
}
|
|
1131
|
+
/**
|
|
1132
|
+
* Decrypt file blob
|
|
1133
|
+
*
|
|
1134
|
+
* @param remoteAddress - Remote device's protocol address
|
|
1135
|
+
* @param encryptedBlob - Encrypted file data
|
|
1136
|
+
* @param encryptedKey - Encrypted symmetric key
|
|
1137
|
+
* @returns Decrypted file blob with correct MIME type
|
|
1138
|
+
*/
|
|
1139
|
+
async decryptFile(remoteAddress, encryptedBlob, encryptedKey) {
|
|
1140
|
+
return FileOps.decryptFile(this.ctx, remoteAddress, encryptedBlob, encryptedKey);
|
|
1141
|
+
}
|
|
1142
|
+
/**
|
|
1143
|
+
* Encrypt multiple files in batch
|
|
1144
|
+
*
|
|
1145
|
+
* More efficient than calling encryptFile() multiple times.
|
|
1146
|
+
* Each file gets its own encryption key for granular access control.
|
|
1147
|
+
*
|
|
1148
|
+
* @param remoteAddress - Remote device's protocol address
|
|
1149
|
+
* @param files - Array of file blobs with optional MIME types
|
|
1150
|
+
* @returns Array of encrypted file results in the same order
|
|
1151
|
+
*/
|
|
1152
|
+
async encryptFiles(remoteAddress, files) {
|
|
1153
|
+
return FileOps.encryptFiles(this.ctx, remoteAddress, files);
|
|
1154
|
+
}
|
|
1155
|
+
/**
|
|
1156
|
+
* Decrypt multiple files in batch
|
|
1157
|
+
*
|
|
1158
|
+
* More efficient than calling decryptFile() multiple times.
|
|
1159
|
+
*
|
|
1160
|
+
* @param remoteAddress - Remote device's protocol address
|
|
1161
|
+
* @param files - Array of encrypted file data
|
|
1162
|
+
* @returns Array of decrypted file blobs in the same order
|
|
1163
|
+
*/
|
|
1164
|
+
async decryptFiles(remoteAddress, files) {
|
|
1165
|
+
return FileOps.decryptFiles(this.ctx, remoteAddress, files);
|
|
1166
|
+
}
|
|
1167
|
+
// ============================================================================
|
|
1168
|
+
// PRIMARY PUBLIC API
|
|
1169
|
+
// ============================================================================
|
|
1170
|
+
/**
|
|
1171
|
+
* Send encrypted content to a user or group
|
|
1172
|
+
*
|
|
1173
|
+
* This is the ONE way to send content. Handles:
|
|
1174
|
+
* - DataMessageInput: Structured proto content (serialized to protobuf)
|
|
1175
|
+
* - String content: Text or structured data (encoded to UTF-8 bytes)
|
|
1176
|
+
* - Uint8Array: Pre-serialized binary content (passed through)
|
|
1177
|
+
* - User recipients: Encrypts for all user's devices via SESAME
|
|
1178
|
+
* - Group recipients: Uses Sender Keys for O(1) encryption
|
|
1179
|
+
*
|
|
1180
|
+
* All inputs are normalized to Uint8Array before reaching the cipher layer.
|
|
1181
|
+
*
|
|
1182
|
+
* @param recipientId - User ID or group ID (groups use Signal V2 prefix)
|
|
1183
|
+
* @param content - DataMessageInput, string, or Uint8Array to encrypt and send
|
|
1184
|
+
* @param options - Optional send options (isBinary for blob encryption, etc.)
|
|
1185
|
+
* @returns SendResult with messageId, timestamp, and device count
|
|
1186
|
+
*
|
|
1187
|
+
* @example
|
|
1188
|
+
* ```typescript
|
|
1189
|
+
* import { createGroupId } from '@open-e2ee/signal-protocol-sdk';
|
|
1190
|
+
*
|
|
1191
|
+
* // Send text message
|
|
1192
|
+
* await signal.send('bob', 'Hello!');
|
|
1193
|
+
*
|
|
1194
|
+
* // Send structured data
|
|
1195
|
+
* await signal.send('bob', { body: 'Hello!', timestamp: Date.now() });
|
|
1196
|
+
*
|
|
1197
|
+
* // Send binary attachment (two-layer encryption)
|
|
1198
|
+
* await signal.send('bob', photoBytes, { isBinary: true, mimeType: 'image/jpeg' });
|
|
1199
|
+
*
|
|
1200
|
+
* // Send to group (use createGroupId helper)
|
|
1201
|
+
* await signal.send(createGroupId('abc123'), 'Hello everyone!');
|
|
1202
|
+
* ```
|
|
1203
|
+
*/
|
|
1204
|
+
async send(recipientId, content, options) {
|
|
1205
|
+
// Normalize all inputs to Uint8Array before calling cipher.encrypt()
|
|
1206
|
+
let plaintextBytes;
|
|
1207
|
+
let clientTimestamp;
|
|
1208
|
+
if (isDataMessage(content)) {
|
|
1209
|
+
// DataMessage path: build Content, set timestamp, serialize to protobuf (application send-pipeline ordering)
|
|
1210
|
+
const timestamp = content.timestamp ?? Date.now();
|
|
1211
|
+
clientTimestamp = timestamp;
|
|
1212
|
+
const dm = { ...content, timestamp };
|
|
1213
|
+
plaintextBytes = this.contentAdapter.serializeDataMessage(dm);
|
|
1214
|
+
}
|
|
1215
|
+
else if (typeof content === 'string') {
|
|
1216
|
+
plaintextBytes = new TextEncoder().encode(content);
|
|
1217
|
+
}
|
|
1218
|
+
else {
|
|
1219
|
+
plaintextBytes = content; // already Uint8Array
|
|
1220
|
+
}
|
|
1221
|
+
const result = await this.cipher.encrypt(recipientId, plaintextBytes, {
|
|
1222
|
+
...options,
|
|
1223
|
+
...(clientTimestamp !== undefined && { timestamp: clientTimestamp }),
|
|
1224
|
+
});
|
|
1225
|
+
return clientTimestamp !== undefined ? { ...result, clientTimestamp } : result;
|
|
1226
|
+
}
|
|
1227
|
+
async uploadAttachment(data, options) {
|
|
1228
|
+
return this.cipher.uploadAttachment(data, options);
|
|
1229
|
+
}
|
|
1230
|
+
async downloadAttachment(attachment, options) {
|
|
1231
|
+
if (!this.remoteObjectStore) {
|
|
1232
|
+
throw new EncryptionError('Remote object storage not configured. Provide remoteObjectStore in SignalProtocolClient.create() config.', EncryptionErrorCode.INITIALIZATION_FAILED);
|
|
1233
|
+
}
|
|
1234
|
+
return resolveMediaAttachment(attachment, {
|
|
1235
|
+
remoteObjectStore: this.remoteObjectStore,
|
|
1236
|
+
transfer: options?.transfer,
|
|
1237
|
+
retry: options?.retry,
|
|
1238
|
+
policy: options?.policy,
|
|
1239
|
+
signal: options?.signal,
|
|
1240
|
+
onProgress: options?.onProgress,
|
|
1241
|
+
onCheckpoint: options?.onCheckpoint,
|
|
1242
|
+
resume: options?.resume,
|
|
1243
|
+
});
|
|
1244
|
+
}
|
|
1245
|
+
async deleteRemoteAttachment(attachment, options) {
|
|
1246
|
+
if (!this.remoteObjectStore) {
|
|
1247
|
+
throw new EncryptionError('Remote object storage not configured. Provide remoteObjectStore in SignalProtocolClient.create() config.', EncryptionErrorCode.INITIALIZATION_FAILED);
|
|
1248
|
+
}
|
|
1249
|
+
await deleteMediaAttachment(attachment, {
|
|
1250
|
+
remoteObjectStore: this.remoteObjectStore,
|
|
1251
|
+
signal: options?.signal,
|
|
1252
|
+
onProgress: options?.onProgress,
|
|
1253
|
+
});
|
|
1254
|
+
}
|
|
1255
|
+
/**
|
|
1256
|
+
* Generate safety number for verifying identity with another user
|
|
1257
|
+
*
|
|
1258
|
+
* Safety numbers allow users to verify they're communicating with the
|
|
1259
|
+
* intended person and detect man-in-the-middle attacks.
|
|
1260
|
+
*
|
|
1261
|
+
* @param userId - The user ID to generate safety number for
|
|
1262
|
+
* @returns SafetyNumber with numeric code and fingerprint for QR
|
|
1263
|
+
*
|
|
1264
|
+
* @example
|
|
1265
|
+
* ```typescript
|
|
1266
|
+
* const safetyNum = await signal.verify('bob');
|
|
1267
|
+
*
|
|
1268
|
+
* // Show numeric code for phone/voice verification
|
|
1269
|
+
* console.log(`Safety Number: ${safetyNum.numeric}`);
|
|
1270
|
+
*
|
|
1271
|
+
* // Generate QR code from fingerprint
|
|
1272
|
+
* const qrCode = generateQR(safetyNum.fingerprint);
|
|
1273
|
+
* ```
|
|
1274
|
+
*/
|
|
1275
|
+
async verify(userId, identityType = 'aci') {
|
|
1276
|
+
return SessionOps.verify(this.ctx, userId, identityType);
|
|
1277
|
+
}
|
|
1278
|
+
/** Confirm an authenticated comparison of the currently displayed tuple. */
|
|
1279
|
+
async confirmSafetyNumber(confirmation) {
|
|
1280
|
+
await SessionOps.confirmSafetyNumber(this.ctx, confirmation);
|
|
1281
|
+
}
|
|
1282
|
+
/** Accept an authenticated composite-identity rotation and reset bound sessions. */
|
|
1283
|
+
async acceptIdentityRotation(userId, identity, identityType = 'aci') {
|
|
1284
|
+
const accepted = await SessionOps.acceptIdentityRotation(this.ctx, userId, identity, identityType);
|
|
1285
|
+
// A retry that first discovered the changed tuple may already have failed
|
|
1286
|
+
// closed and entered the short-lived dedup window. Explicit acceptance is
|
|
1287
|
+
// the authority to try those still-pending requests again; it is never
|
|
1288
|
+
// inferred from the retry request itself.
|
|
1289
|
+
const retryPrefix = `${userId}:`;
|
|
1290
|
+
for (const key of this.retryDedupState.recentRetryRequests.keys()) {
|
|
1291
|
+
if (key.startsWith(retryPrefix)) {
|
|
1292
|
+
this.retryDedupState.recentRetryRequests.delete(key);
|
|
1293
|
+
}
|
|
1294
|
+
}
|
|
1295
|
+
if (this.retryUnsubscribe) {
|
|
1296
|
+
this.retryUnsubscribe();
|
|
1297
|
+
this.retryUnsubscribe = undefined;
|
|
1298
|
+
this.startRetryRequestSubscription();
|
|
1299
|
+
}
|
|
1300
|
+
return accepted;
|
|
1301
|
+
}
|
|
1302
|
+
/**
|
|
1303
|
+
* Mark a message as read/delivered
|
|
1304
|
+
*
|
|
1305
|
+
* Signals to the server that the message was successfully received
|
|
1306
|
+
* and processed. Server may delete the message based on privacy settings.
|
|
1307
|
+
*
|
|
1308
|
+
* @param messageId - The message ID from SendResult
|
|
1309
|
+
*
|
|
1310
|
+
* @example
|
|
1311
|
+
* ```typescript
|
|
1312
|
+
* // After processing received message
|
|
1313
|
+
* await signal.markAsRead(envelope.id);
|
|
1314
|
+
* ```
|
|
1315
|
+
*/
|
|
1316
|
+
async markAsRead(messageId) {
|
|
1317
|
+
if (!this.relay) {
|
|
1318
|
+
throw new EncryptionError('Relay server not configured', EncryptionErrorCode.INITIALIZATION_FAILED);
|
|
1319
|
+
}
|
|
1320
|
+
await this.relay.markDelivered(messageId);
|
|
1321
|
+
this.logger.debug('Message marked as read', {
|
|
1322
|
+
category: 'E2EE',
|
|
1323
|
+
data: { messageId },
|
|
1324
|
+
});
|
|
1325
|
+
}
|
|
1326
|
+
// ============================================================================
|
|
1327
|
+
// HOOK REGISTRATION (For post-construction hook registration)
|
|
1328
|
+
// ============================================================================
|
|
1329
|
+
/**
|
|
1330
|
+
* Register a hook callback after construction
|
|
1331
|
+
*
|
|
1332
|
+
* Enables dependency injection patterns where hooks are registered
|
|
1333
|
+
* after SignalProtocolClient is created. This is used by ServicesProvider
|
|
1334
|
+
* to wire up ContentManager's decryption hook.
|
|
1335
|
+
*
|
|
1336
|
+
* @param name - The hook name to register
|
|
1337
|
+
* @param callback - The callback function to invoke
|
|
1338
|
+
*
|
|
1339
|
+
* @example
|
|
1340
|
+
* ```typescript
|
|
1341
|
+
* // In ServicesProvider: wire up ContentManager after creation
|
|
1342
|
+
* const signal = await SignalProtocolClient.create(userId, { storage, relay });
|
|
1343
|
+
* const content = new ContentManager({ db, signal });
|
|
1344
|
+
*
|
|
1345
|
+
* signal.registerHook('onMessageDecrypted', content.getDecryptionHook());
|
|
1346
|
+
* signal.startRelaySubscription(); // Now safe to start
|
|
1347
|
+
* ```
|
|
1348
|
+
*
|
|
1349
|
+
* @see ISignalProtocolClient.registerHook
|
|
1350
|
+
*/
|
|
1351
|
+
registerHook(name, callback) {
|
|
1352
|
+
this.hooks[name] = callback;
|
|
1353
|
+
this.logger.debug('Hook registered', {
|
|
1354
|
+
category: 'E2EE',
|
|
1355
|
+
data: { hookName: name },
|
|
1356
|
+
});
|
|
1357
|
+
}
|
|
1358
|
+
// ============================================================================
|
|
1359
|
+
// RELAY SUBSCRIPTION (Auto-decrypt and notify ContentManager via hook)
|
|
1360
|
+
// ============================================================================
|
|
1361
|
+
/**
|
|
1362
|
+
* Start relay subscription for automatic message decryption
|
|
1363
|
+
*
|
|
1364
|
+
* When configured with both `relay` and `onMessageDecrypted` hook, SignalProtocolClient will:
|
|
1365
|
+
* 1. Subscribe to incoming envelopes from the relay
|
|
1366
|
+
* 2. Decrypt messages appropriately (pairwise vs group/sender key)
|
|
1367
|
+
* 3. Call onMessageDecrypted hook with DecryptedEnvelope (for ContentManager storage)
|
|
1368
|
+
* 4. Mark messages as delivered on the relay
|
|
1369
|
+
*
|
|
1370
|
+
* This enables ContentManager to store decrypted content in an encrypted SQLite
|
|
1371
|
+
* database without any knowledge of cryptography.
|
|
1372
|
+
*
|
|
1373
|
+
* Can be called manually after registering hooks via registerHook().
|
|
1374
|
+
* Called automatically by create() when relay + hook configured.
|
|
1375
|
+
*
|
|
1376
|
+
* @see ISignalProtocolClient.startRelaySubscription
|
|
1377
|
+
*/
|
|
1378
|
+
startRelaySubscription() {
|
|
1379
|
+
if (!this.relay) {
|
|
1380
|
+
this.logger.warn('Cannot start relay subscription: relay not configured', {
|
|
1381
|
+
category: 'E2EE',
|
|
1382
|
+
});
|
|
1383
|
+
return;
|
|
1384
|
+
}
|
|
1385
|
+
if (!this.hooks?.onMessageDecrypted) {
|
|
1386
|
+
this.logger.warn('Cannot start relay subscription: onMessageDecrypted hook required', {
|
|
1387
|
+
category: 'E2EE',
|
|
1388
|
+
});
|
|
1389
|
+
return;
|
|
1390
|
+
}
|
|
1391
|
+
// Avoid duplicate subscriptions
|
|
1392
|
+
if (this.relayUnsubscribe) {
|
|
1393
|
+
this.logger.debug('Relay subscription already active', {
|
|
1394
|
+
category: 'E2EE',
|
|
1395
|
+
});
|
|
1396
|
+
return;
|
|
1397
|
+
}
|
|
1398
|
+
this.logger.debug('Starting relay subscription', {
|
|
1399
|
+
category: 'E2EE',
|
|
1400
|
+
data: { userId: this.userId, deviceId: this.deviceId },
|
|
1401
|
+
});
|
|
1402
|
+
// Create extended context with cipher for relay subscription operations
|
|
1403
|
+
const relayCtx = {
|
|
1404
|
+
...this.ctx,
|
|
1405
|
+
cipher: this.cipher,
|
|
1406
|
+
};
|
|
1407
|
+
this.relayUnsubscribe = this.relay.subscribe(this.userId, this.deviceId, async (envelope) => {
|
|
1408
|
+
await RelaySubscriptionOps.handleRelayMessage(relayCtx, envelope, this.relaySubscriptionState, this.relaySubscriptionCallbacks, this.relaySubscriptionConfig);
|
|
1409
|
+
}, {
|
|
1410
|
+
// Batching callbacks for notification coalescing
|
|
1411
|
+
onBatchStart: () => this.contentAdapter.setRelayBatching(true),
|
|
1412
|
+
onBatchEnd: () => this.contentAdapter.setRelayBatching(false),
|
|
1413
|
+
});
|
|
1414
|
+
}
|
|
1415
|
+
/**
|
|
1416
|
+
* Stop the relay subscription
|
|
1417
|
+
*
|
|
1418
|
+
* Pauses message processing via the relay subscription without destroying
|
|
1419
|
+
* SignalProtocolClient state. The subscription can be restarted with startRelaySubscription().
|
|
1420
|
+
*
|
|
1421
|
+
* Use this when the app backgrounds to let the background task handle messages.
|
|
1422
|
+
* Resume when the app foregrounds for real-time message delivery.
|
|
1423
|
+
*
|
|
1424
|
+
* @see ISignalProtocolClient.stopRelaySubscription
|
|
1425
|
+
*/
|
|
1426
|
+
stopRelaySubscription() {
|
|
1427
|
+
// Flush any pending batched delivery receipts before unsubscribing
|
|
1428
|
+
const { receiptAccumulator } = this.relaySubscriptionState;
|
|
1429
|
+
for (const [userId, timestamps] of receiptAccumulator.pending) {
|
|
1430
|
+
if (timestamps.length > 0) {
|
|
1431
|
+
this.sendDeliveryReceipt(userId, timestamps).catch((_error) => {
|
|
1432
|
+
this.logger.warn('Failed to send delivery receipt', {
|
|
1433
|
+
category: 'E2EE',
|
|
1434
|
+
data: { userId },
|
|
1435
|
+
});
|
|
1436
|
+
});
|
|
1437
|
+
}
|
|
1438
|
+
}
|
|
1439
|
+
if (this.relayUnsubscribe) {
|
|
1440
|
+
this.relayUnsubscribe();
|
|
1441
|
+
this.relayUnsubscribe = undefined;
|
|
1442
|
+
this.logger.debug('Relay subscription stopped', {
|
|
1443
|
+
category: 'E2EE',
|
|
1444
|
+
data: { userId: this.userId, deviceId: this.deviceId },
|
|
1445
|
+
});
|
|
1446
|
+
}
|
|
1447
|
+
}
|
|
1448
|
+
/**
|
|
1449
|
+
* Start listening for retry requests from recipients (SESAME spec §6.2)
|
|
1450
|
+
*
|
|
1451
|
+
* When a recipient cannot decrypt a message, they send a retry request.
|
|
1452
|
+
* This method subscribes to incoming retry requests and processes them
|
|
1453
|
+
* by resending the original message with a new session.
|
|
1454
|
+
*
|
|
1455
|
+
* Automatically started if relay.subscribeRetryRequests is available.
|
|
1456
|
+
* Can be called manually if you need to restart the subscription.
|
|
1457
|
+
*/
|
|
1458
|
+
startRetryRequestSubscription() {
|
|
1459
|
+
if (!this.relay || !this.relay.subscribeRetryRequests) {
|
|
1460
|
+
this.logger.debug('Relay does not support retry request subscription', {
|
|
1461
|
+
category: 'E2EE',
|
|
1462
|
+
});
|
|
1463
|
+
return;
|
|
1464
|
+
}
|
|
1465
|
+
// Avoid duplicate subscriptions
|
|
1466
|
+
if (this.retryUnsubscribe) {
|
|
1467
|
+
this.logger.debug('Retry request subscription already active', {
|
|
1468
|
+
category: 'E2EE',
|
|
1469
|
+
});
|
|
1470
|
+
return;
|
|
1471
|
+
}
|
|
1472
|
+
this.logger.debug('Starting retry request subscription', {
|
|
1473
|
+
category: 'E2EE',
|
|
1474
|
+
data: { userId: this.userId, deviceId: this.deviceId },
|
|
1475
|
+
});
|
|
1476
|
+
this.retryUnsubscribe = this.relay.subscribeRetryRequests(this.userId, this.deviceId, async (retryRequest) => {
|
|
1477
|
+
await this.handleRetryRequestAndResend(retryRequest);
|
|
1478
|
+
});
|
|
1479
|
+
}
|
|
1480
|
+
/**
|
|
1481
|
+
* Handle a retry request and resend the original message
|
|
1482
|
+
*
|
|
1483
|
+
* Per SESAME spec §4.1 (Resending Process):
|
|
1484
|
+
* 1. Look up MessageRecord by sequence number
|
|
1485
|
+
* 2. Validate retry limits and message TTL
|
|
1486
|
+
* 3. Check session state:
|
|
1487
|
+
* - If NO active session OR active session IS orphaned (matches MessageRecord.sessionStateId):
|
|
1488
|
+
* → Fetch prekey bundle and create new session
|
|
1489
|
+
* - If DIFFERENT active session exists:
|
|
1490
|
+
* → Use it directly (no prekey fetch, prevents rate limit issues)
|
|
1491
|
+
* 4. Re-encrypt and send the original message
|
|
1492
|
+
*
|
|
1493
|
+
* This prevents infinite retry loops where each retry creates a new session
|
|
1494
|
+
* with different header keys.
|
|
1495
|
+
*
|
|
1496
|
+
* @param retryRequest - The retry request from the recipient
|
|
1497
|
+
*/
|
|
1498
|
+
async handleRetryRequestAndResend(retryRequest) {
|
|
1499
|
+
return RetryOps.handleRetryRequestAndResend(this.ctx, retryRequest, this.retryDedupState, this.retryCallbacks, this.retryConfig);
|
|
1500
|
+
}
|
|
1501
|
+
/**
|
|
1502
|
+
* Send delivery receipt to original sender (all devices)
|
|
1503
|
+
*
|
|
1504
|
+
* Per Signal Protocol, after successfully decrypting a message, the recipient
|
|
1505
|
+
* sends a delivery receipt back to the sender. The receipt identifies messages
|
|
1506
|
+
* by their timestamps (not sequence numbers).
|
|
1507
|
+
*
|
|
1508
|
+
* Multi-device: fans out to all known devices for the sender.
|
|
1509
|
+
*
|
|
1510
|
+
* @param recipientUserId - The sender's user ID (we're receipting TO them)
|
|
1511
|
+
* @param timestamps - Array of message timestamps that have been delivered
|
|
1512
|
+
*
|
|
1513
|
+
*/
|
|
1514
|
+
async sendDeliveryReceipt(recipientUserId, timestamps) {
|
|
1515
|
+
return this.sendReceipt(recipientUserId, timestamps, ReceiptType.DELIVERY);
|
|
1516
|
+
}
|
|
1517
|
+
/**
|
|
1518
|
+
* Send read receipt to original message sender (all devices)
|
|
1519
|
+
*
|
|
1520
|
+
* Called when the user views messages in a conversation.
|
|
1521
|
+
* Similar to delivery receipts but indicates message was actually read.
|
|
1522
|
+
*
|
|
1523
|
+
* Respects SDK privacy settings: if read receipts are disabled,
|
|
1524
|
+
* this method returns early without sending.
|
|
1525
|
+
*
|
|
1526
|
+
* @param recipientUserId - Original sender's user ID
|
|
1527
|
+
* @param timestamps - Server timestamps of messages that were read
|
|
1528
|
+
*/
|
|
1529
|
+
async sendReadReceipt(recipientUserId, timestamps) {
|
|
1530
|
+
// Check privacy setting at protocol layer
|
|
1531
|
+
const enabled = await this.contentAdapter.areReadReceiptsEnabled();
|
|
1532
|
+
if (!enabled) {
|
|
1533
|
+
this.logger.debug('Read receipts disabled by user preference', {
|
|
1534
|
+
category: 'E2EE',
|
|
1535
|
+
});
|
|
1536
|
+
return;
|
|
1537
|
+
}
|
|
1538
|
+
return this.sendReceipt(recipientUserId, timestamps, ReceiptType.READ);
|
|
1539
|
+
}
|
|
1540
|
+
/**
|
|
1541
|
+
* Send viewed receipt to original message sender (all devices).
|
|
1542
|
+
*
|
|
1543
|
+
* Uses the same privacy gate as read receipts.
|
|
1544
|
+
*/
|
|
1545
|
+
async sendViewedReceipt(recipientUserId, timestamps) {
|
|
1546
|
+
const enabled = await this.contentAdapter.areReadReceiptsEnabled();
|
|
1547
|
+
if (!enabled) {
|
|
1548
|
+
this.logger.debug('Viewed receipts disabled by user preference', {
|
|
1549
|
+
category: 'E2EE',
|
|
1550
|
+
});
|
|
1551
|
+
return;
|
|
1552
|
+
}
|
|
1553
|
+
return this.sendReceipt(recipientUserId, timestamps, ReceiptType.VIEWED);
|
|
1554
|
+
}
|
|
1555
|
+
/**
|
|
1556
|
+
* Sync local read state to our other linked devices.
|
|
1557
|
+
*
|
|
1558
|
+
* Unlike read receipts, this is account-local multi-device state and should
|
|
1559
|
+
* happen regardless of the user's remote read-receipt privacy preference.
|
|
1560
|
+
*/
|
|
1561
|
+
async syncReadToLinkedDevices(entries) {
|
|
1562
|
+
await this.cipher.sendReadSyncToLocalOtherDevices(entries);
|
|
1563
|
+
}
|
|
1564
|
+
/**
|
|
1565
|
+
* Sync a local view-once open event to our other linked devices.
|
|
1566
|
+
*/
|
|
1567
|
+
async syncViewOnceOpenToLinkedDevices(entry) {
|
|
1568
|
+
await this.cipher.sendViewOnceOpenSyncToLocalOtherDevices(entry);
|
|
1569
|
+
}
|
|
1570
|
+
/**
|
|
1571
|
+
* Sync a local media attachment delete event to our other linked devices.
|
|
1572
|
+
*/
|
|
1573
|
+
async syncMediaAttachmentDeleteToLinkedDevices(entry) {
|
|
1574
|
+
await this.cipher.sendMediaAttachmentDeleteSyncToLocalOtherDevices(entry);
|
|
1575
|
+
}
|
|
1576
|
+
/**
|
|
1577
|
+
* Sync local account-level communication/privacy configuration to our other linked devices.
|
|
1578
|
+
*/
|
|
1579
|
+
async syncConfigurationToLinkedDevices(configuration) {
|
|
1580
|
+
await this.cipher.sendConfigurationSyncToLocalOtherDevices(configuration);
|
|
1581
|
+
}
|
|
1582
|
+
/**
|
|
1583
|
+
* Sync local username and username-link state to the account's other linked devices.
|
|
1584
|
+
*
|
|
1585
|
+
* Linked devices converge on the same username-link handle and entropy
|
|
1586
|
+
* without rotating it.
|
|
1587
|
+
*/
|
|
1588
|
+
async syncUsernameStateToLinkedDevices(usernameState) {
|
|
1589
|
+
await this.cipher.sendUsernameStateSyncToLocalOtherDevices(usernameState);
|
|
1590
|
+
}
|
|
1591
|
+
/**
|
|
1592
|
+
* Sync learned recipient username metadata to the account's other linked devices.
|
|
1593
|
+
*
|
|
1594
|
+
* Remote usernames are transient metadata, but once one local device learns
|
|
1595
|
+
* them they should converge across the account's linked devices.
|
|
1596
|
+
*/
|
|
1597
|
+
async syncRecipientUsernameToLinkedDevices(recipientUsername) {
|
|
1598
|
+
await this.cipher.sendRecipientUsernameSyncToLocalOtherDevices(recipientUsername);
|
|
1599
|
+
}
|
|
1600
|
+
/**
|
|
1601
|
+
* Sync local safety-number verification state to our other linked devices.
|
|
1602
|
+
*
|
|
1603
|
+
* Only explicit `verified` and cleared-to-`default` states are synced;
|
|
1604
|
+
* key-conflict/untrusted state remains local and derived from identity-key
|
|
1605
|
+
* changes.
|
|
1606
|
+
*/
|
|
1607
|
+
async syncVerificationStateToLinkedDevices(verificationState) {
|
|
1608
|
+
await this.cipher.sendVerificationStateSyncToLocalOtherDevices(verificationState);
|
|
1609
|
+
}
|
|
1610
|
+
/**
|
|
1611
|
+
* Sync task-notification acknowledgment state to our other linked devices.
|
|
1612
|
+
*
|
|
1613
|
+
* This is account-local notification state: if one device dismisses or acts
|
|
1614
|
+
* on a task reminder, the user's other devices should cancel their copies.
|
|
1615
|
+
*/
|
|
1616
|
+
async syncTaskNotificationAckToLinkedDevices(input) {
|
|
1617
|
+
await this.cipher.sendTaskNotificationAckSyncToLocalOtherDevices({
|
|
1618
|
+
...input,
|
|
1619
|
+
acknowledgedOnDevice: this.deviceId,
|
|
1620
|
+
});
|
|
1621
|
+
}
|
|
1622
|
+
/**
|
|
1623
|
+
* Sync the current blocked-recipient snapshot to the account's other linked devices.
|
|
1624
|
+
*
|
|
1625
|
+
* The payload is a full snapshot, not a block/unblock delta.
|
|
1626
|
+
*/
|
|
1627
|
+
async syncBlockedRecipientsToLinkedDevices(blocked) {
|
|
1628
|
+
await this.cipher.sendBlockedRecipientsSyncToLocalOtherDevices(blocked);
|
|
1629
|
+
}
|
|
1630
|
+
/**
|
|
1631
|
+
* Send typing indicator to conversation recipient
|
|
1632
|
+
*
|
|
1633
|
+
* Delegates to MessageOps.sendTypingIndicator for implementation.
|
|
1634
|
+
*/
|
|
1635
|
+
async sendTypingIndicator(recipientUserId, recipientDeviceId, conversationId, action, groupId) {
|
|
1636
|
+
return MessageOps.sendTypingIndicator(this.ctx, recipientUserId, recipientDeviceId, conversationId, action, groupId);
|
|
1637
|
+
}
|
|
1638
|
+
/**
|
|
1639
|
+
* Internal method to send receipt (delivery or read)
|
|
1640
|
+
*
|
|
1641
|
+
* Delegates to MessageOps.sendReceipt for implementation.
|
|
1642
|
+
*/
|
|
1643
|
+
async sendReceipt(recipientUserId, timestamps, type) {
|
|
1644
|
+
return MessageOps.sendReceipt(this.ctx, recipientUserId, timestamps, type);
|
|
1645
|
+
}
|
|
1646
|
+
/**
|
|
1647
|
+
* Handle incoming delivery/read receipt and clean up MessageRecords
|
|
1648
|
+
*
|
|
1649
|
+
* Delegates to MessageOps.handleDeliveryReceipt for implementation.
|
|
1650
|
+
*/
|
|
1651
|
+
async handleDeliveryReceipt(envelope, receipt) {
|
|
1652
|
+
return MessageOps.handleDeliveryReceipt(this.ctx, envelope, receipt);
|
|
1653
|
+
}
|
|
1654
|
+
/**
|
|
1655
|
+
* Handle incoming typing indicator
|
|
1656
|
+
*
|
|
1657
|
+
* Delegates to MessageOps.handleTypingIndicator for implementation.
|
|
1658
|
+
*/
|
|
1659
|
+
async handleTypingIndicator(envelope, typing) {
|
|
1660
|
+
return MessageOps.handleTypingIndicator(this.ctx, envelope, typing);
|
|
1661
|
+
}
|
|
1662
|
+
/**
|
|
1663
|
+
* Stop the Signal Protocol client and clean up resources
|
|
1664
|
+
*
|
|
1665
|
+
* Call this when the user logs out or the app is being destroyed.
|
|
1666
|
+
* Unsubscribes from relay server and cleans up any pending operations.
|
|
1667
|
+
*
|
|
1668
|
+
* @example
|
|
1669
|
+
* ```typescript
|
|
1670
|
+
* // On logout
|
|
1671
|
+
* await signal.stop();
|
|
1672
|
+
* ```
|
|
1673
|
+
*/
|
|
1674
|
+
async stop() {
|
|
1675
|
+
// 1. Stop relay subscription
|
|
1676
|
+
if (this.relayUnsubscribe) {
|
|
1677
|
+
this.relayUnsubscribe();
|
|
1678
|
+
this.relayUnsubscribe = undefined;
|
|
1679
|
+
this.logger.debug('Relay subscription stopped', { category: 'E2EE' });
|
|
1680
|
+
}
|
|
1681
|
+
// 2. Stop retry request subscription
|
|
1682
|
+
if (this.retryUnsubscribe) {
|
|
1683
|
+
this.retryUnsubscribe();
|
|
1684
|
+
this.retryUnsubscribe = undefined;
|
|
1685
|
+
this.logger.debug('Retry request subscription stopped', {
|
|
1686
|
+
category: 'E2EE',
|
|
1687
|
+
});
|
|
1688
|
+
}
|
|
1689
|
+
// 3. Cleanup expired Sesame sessions
|
|
1690
|
+
try {
|
|
1691
|
+
await this.sesameManager.cleanupExpiredSessions();
|
|
1692
|
+
}
|
|
1693
|
+
catch (error) {
|
|
1694
|
+
this.logger.warn('Error cleaning up Sesame sessions', {
|
|
1695
|
+
category: 'E2EE',
|
|
1696
|
+
data: { error: error.message },
|
|
1697
|
+
});
|
|
1698
|
+
}
|
|
1699
|
+
// 4. Cleanup expired message records (SESAME spec §6.2)
|
|
1700
|
+
try {
|
|
1701
|
+
const deleted = await this._storage.deleteExpiredMessageRecords(MESSAGE_RECORD_TTL_MS);
|
|
1702
|
+
if (deleted > 0) {
|
|
1703
|
+
this.logger.debug('Cleaned up expired message records', {
|
|
1704
|
+
category: 'E2EE',
|
|
1705
|
+
data: { deleted },
|
|
1706
|
+
});
|
|
1707
|
+
}
|
|
1708
|
+
}
|
|
1709
|
+
catch (error) {
|
|
1710
|
+
// Log but don't fail stop
|
|
1711
|
+
this.logger.warn('Error cleaning up message records', {
|
|
1712
|
+
category: 'E2EE',
|
|
1713
|
+
data: { error: error.message },
|
|
1714
|
+
});
|
|
1715
|
+
}
|
|
1716
|
+
// 5. Clear internal tracking state via state manager
|
|
1717
|
+
this.state.clearForStop();
|
|
1718
|
+
this.logger.debug('SignalProtocolClient stopped', {
|
|
1719
|
+
category: 'E2EE',
|
|
1720
|
+
data: { userId: this.userId, deviceId: this.deviceId },
|
|
1721
|
+
});
|
|
1722
|
+
}
|
|
1723
|
+
/**
|
|
1724
|
+
* Receive and decrypt message from another device (multi-device support)
|
|
1725
|
+
*
|
|
1726
|
+
* Implements session convergence per SESAME spec.
|
|
1727
|
+
*
|
|
1728
|
+
* @param message - The encrypted Sesame message envelope
|
|
1729
|
+
* @returns Decrypted plaintext
|
|
1730
|
+
*/
|
|
1731
|
+
async receive(message) {
|
|
1732
|
+
return this.cipher.decryptPairwise(message);
|
|
1733
|
+
}
|
|
1734
|
+
/**
|
|
1735
|
+
* Get Sesame session statistics (for debugging)
|
|
1736
|
+
*
|
|
1737
|
+
* Returns information about users, devices, and sessions.
|
|
1738
|
+
*
|
|
1739
|
+
* @returns Session statistics
|
|
1740
|
+
*/
|
|
1741
|
+
async getSesameStats() {
|
|
1742
|
+
return this.sesameManager.getStats();
|
|
1743
|
+
}
|
|
1744
|
+
/**
|
|
1745
|
+
* Cleanup expired Sesame sessions
|
|
1746
|
+
*
|
|
1747
|
+
* Removes inactive sessions that are older than the configured TTL.
|
|
1748
|
+
* Should be called periodically (e.g., daily) to prevent database bloat.
|
|
1749
|
+
*
|
|
1750
|
+
* @returns Number of sessions cleaned up
|
|
1751
|
+
*/
|
|
1752
|
+
async cleanupExpiredSesameSessions() {
|
|
1753
|
+
const cleaned = await this.sesameManager.cleanupExpiredSessions();
|
|
1754
|
+
this.logger.debug('Expired Sesame sessions cleaned up', {
|
|
1755
|
+
category: 'E2EE',
|
|
1756
|
+
data: { count: cleaned },
|
|
1757
|
+
});
|
|
1758
|
+
return cleaned;
|
|
1759
|
+
}
|
|
1760
|
+
/**
|
|
1761
|
+
* Run periodic cleanup of internal tracking state.
|
|
1762
|
+
*
|
|
1763
|
+
* Safe to call frequently - internally throttled to avoid overhead.
|
|
1764
|
+
* Recommended call sites:
|
|
1765
|
+
* - App foreground transition
|
|
1766
|
+
* - After successful message batch processing
|
|
1767
|
+
* - Periodically during long sessions
|
|
1768
|
+
*
|
|
1769
|
+
* Cleans up:
|
|
1770
|
+
* - Expired retry dedup entries (recentRetryRequests)
|
|
1771
|
+
*
|
|
1772
|
+
* @returns Number of entries cleaned up
|
|
1773
|
+
*/
|
|
1774
|
+
runPeriodicCleanup() {
|
|
1775
|
+
const result = this.state.runPeriodicCleanup();
|
|
1776
|
+
if (result.cleaned > 0) {
|
|
1777
|
+
this.logger.debug('Periodic cleanup completed', {
|
|
1778
|
+
category: 'E2EE',
|
|
1779
|
+
data: { cleaned: result.cleaned },
|
|
1780
|
+
});
|
|
1781
|
+
}
|
|
1782
|
+
return result.cleaned;
|
|
1783
|
+
}
|
|
1784
|
+
// ============================================================================
|
|
1785
|
+
// KEY ROTATION (delegated to key-rotation.ts)
|
|
1786
|
+
// ============================================================================
|
|
1787
|
+
/**
|
|
1788
|
+
* Rotate EC signed prekey
|
|
1789
|
+
*
|
|
1790
|
+
* Should be called weekly to maintain forward secrecy.
|
|
1791
|
+
* Generates a new EC signed prekey and uploads it to the relay if configured.
|
|
1792
|
+
*
|
|
1793
|
+
* @returns True if rotation was performed, false if not needed yet
|
|
1794
|
+
*/
|
|
1795
|
+
async rotateEcSignedPreKey() {
|
|
1796
|
+
return KeyRotationOps.rotateEcSignedPreKey(this.ctx);
|
|
1797
|
+
}
|
|
1798
|
+
/**
|
|
1799
|
+
* Rotate the post-quantum KEM last-resort prekey.
|
|
1800
|
+
*
|
|
1801
|
+
* Should be called weekly alongside signed prekey rotation.
|
|
1802
|
+
* Generates fresh ML-KEM/Kyber-compatible key material and uploads it to the
|
|
1803
|
+
* relay if configured.
|
|
1804
|
+
*
|
|
1805
|
+
* @returns True if rotation was performed, false if not needed yet
|
|
1806
|
+
*/
|
|
1807
|
+
async rotateKyberPreKey() {
|
|
1808
|
+
return KeyRotationOps.rotateKyberPreKey(this.ctx);
|
|
1809
|
+
}
|
|
1810
|
+
// ============================================================================
|
|
1811
|
+
// GROUP MESSAGING (Sender Keys)
|
|
1812
|
+
// ============================================================================
|
|
1813
|
+
/**
|
|
1814
|
+
* Create a new sender key for group messaging
|
|
1815
|
+
*
|
|
1816
|
+
* Call this when joining a group or when key rotation is needed.
|
|
1817
|
+
* Distribute the returned message to all group members via pairwise sessions.
|
|
1818
|
+
*
|
|
1819
|
+
* @param groupId - Unique identifier for the group
|
|
1820
|
+
* @returns Distribution message to share with group members
|
|
1821
|
+
*
|
|
1822
|
+
* @example
|
|
1823
|
+
* ```typescript
|
|
1824
|
+
* // Create sender key when joining a group
|
|
1825
|
+
* const { distributionMessage } = await signal.createGroupSenderKey('group-123');
|
|
1826
|
+
*
|
|
1827
|
+
* // Distribute to all members via pairwise encryption
|
|
1828
|
+
* for (const member of groupMembers) {
|
|
1829
|
+
* const encrypted = await signal.encryptMessage(member.address, JSON.stringify(distributionMessage));
|
|
1830
|
+
* await sendToMember(member, encrypted);
|
|
1831
|
+
* }
|
|
1832
|
+
* ```
|
|
1833
|
+
*/
|
|
1834
|
+
async createGroupSenderKey(groupId) {
|
|
1835
|
+
return GroupOps.createGroupSenderKey(this.ctx, this.senderKeyManager, groupId);
|
|
1836
|
+
}
|
|
1837
|
+
/**
|
|
1838
|
+
* Process a sender key distribution message from another group member
|
|
1839
|
+
*
|
|
1840
|
+
* Call this when receiving a sender key distribution message from a group member.
|
|
1841
|
+
* After processing, you can decrypt messages from that member.
|
|
1842
|
+
*
|
|
1843
|
+
* @param groupId - Group identifier
|
|
1844
|
+
* @param senderId - Sender's user ID
|
|
1845
|
+
* @param senderDeviceId - Sender's device ID
|
|
1846
|
+
* @param message - Distribution message containing the sender key
|
|
1847
|
+
*
|
|
1848
|
+
* @example
|
|
1849
|
+
* ```typescript
|
|
1850
|
+
* // Receive and process distribution message
|
|
1851
|
+
* const distributionMessage = JSON.parse(decryptedContent);
|
|
1852
|
+
* await signal.processGroupSenderKeyDistribution(
|
|
1853
|
+
* 'group-123',
|
|
1854
|
+
* senderId,
|
|
1855
|
+
* senderDeviceId,
|
|
1856
|
+
* distributionMessage
|
|
1857
|
+
* );
|
|
1858
|
+
* ```
|
|
1859
|
+
*/
|
|
1860
|
+
async processGroupSenderKeyDistribution(groupId, senderId, senderDeviceId, message) {
|
|
1861
|
+
return GroupOps.processSenderKeyDistribution(this.ctx, this.senderKeyManager, groupId, senderId, senderDeviceId, message);
|
|
1862
|
+
}
|
|
1863
|
+
/**
|
|
1864
|
+
* Encrypt a message for group using sender key (O(1) encryption)
|
|
1865
|
+
*
|
|
1866
|
+
* After creating your sender key and distributing it to members,
|
|
1867
|
+
* use this to encrypt messages. All group members can decrypt
|
|
1868
|
+
* the same ciphertext, making it efficient for large groups.
|
|
1869
|
+
*
|
|
1870
|
+
* @param groupId - Group identifier
|
|
1871
|
+
* @param plaintext - Message to encrypt
|
|
1872
|
+
* @returns Framed SenderKeyMessage bytes
|
|
1873
|
+
*
|
|
1874
|
+
* @example
|
|
1875
|
+
* ```typescript
|
|
1876
|
+
* // Encrypt once, send to all members
|
|
1877
|
+
* const encrypted = await signal.encryptGroupMessage('group-123', 'Hello everyone!');
|
|
1878
|
+
*
|
|
1879
|
+
* // Broadcast same ciphertext to all members
|
|
1880
|
+
* for (const member of groupMembers) {
|
|
1881
|
+
* await sendToMember(member, encrypted);
|
|
1882
|
+
* }
|
|
1883
|
+
* ```
|
|
1884
|
+
*/
|
|
1885
|
+
async encryptGroupMessage(groupId, plaintext) {
|
|
1886
|
+
return GroupOps.encryptGroupMessage(this.ctx, this.senderKeyManager, groupId, plaintext);
|
|
1887
|
+
}
|
|
1888
|
+
/**
|
|
1889
|
+
* Decrypt a group message from a sender
|
|
1890
|
+
*
|
|
1891
|
+
* Use this to decrypt messages from other group members.
|
|
1892
|
+
* You must have processed the sender's distribution message first.
|
|
1893
|
+
*
|
|
1894
|
+
* @param groupId - Group identifier
|
|
1895
|
+
* @param senderId - Sender's user ID
|
|
1896
|
+
* @param senderDeviceId - Sender's device ID
|
|
1897
|
+
* @param framedMessage - Framed SenderKeyMessage bytes
|
|
1898
|
+
* @returns Decrypted plaintext
|
|
1899
|
+
*
|
|
1900
|
+
* @example
|
|
1901
|
+
* ```typescript
|
|
1902
|
+
* const plaintext = await signal.decryptGroupMessage(
|
|
1903
|
+
* 'group-123',
|
|
1904
|
+
* senderId,
|
|
1905
|
+
* senderDeviceId,
|
|
1906
|
+
* encryptedMessage
|
|
1907
|
+
* );
|
|
1908
|
+
* console.log('Message:', plaintext);
|
|
1909
|
+
* ```
|
|
1910
|
+
*/
|
|
1911
|
+
async decryptGroupMessage(groupId, senderId, senderDeviceId, framedMessage) {
|
|
1912
|
+
return GroupOps.decryptGroupMessage(this.ctx, this.senderKeyManager, groupId, senderId, senderDeviceId, framedMessage);
|
|
1913
|
+
}
|
|
1914
|
+
/**
|
|
1915
|
+
* Rotate sender key for a group (forward secrecy on membership changes).
|
|
1916
|
+
*
|
|
1917
|
+
* ## When to Call
|
|
1918
|
+
*
|
|
1919
|
+
* Per Signal Protocol specification, rotate sender keys on **membership changes**:
|
|
1920
|
+
*
|
|
1921
|
+
* | Event | Action |
|
|
1922
|
+
* |-------|--------|
|
|
1923
|
+
* | Member REMOVED | **ALL members** must rotate (forward secrecy) |
|
|
1924
|
+
* | Member ADDED | Distribute current key to new member (no rotation needed) |
|
|
1925
|
+
* | Group metadata changed | Rotate recommended |
|
|
1926
|
+
*
|
|
1927
|
+
* **Important**: Signal does NOT use periodic or message-count-based rotation.
|
|
1928
|
+
* Only rotate when membership changes to maintain forward secrecy.
|
|
1929
|
+
*
|
|
1930
|
+
* ## Why Rotate on Member Removal?
|
|
1931
|
+
*
|
|
1932
|
+
* When a member is removed, they still have the old sender key and could decrypt
|
|
1933
|
+
* future messages if the key isn't rotated. ALL remaining members must generate
|
|
1934
|
+
* new sender keys to prevent the removed member from reading future messages.
|
|
1935
|
+
*
|
|
1936
|
+
* @param groupId - Group identifier
|
|
1937
|
+
* @returns New distribution message to share with remaining members
|
|
1938
|
+
*
|
|
1939
|
+
* @example
|
|
1940
|
+
* ```typescript
|
|
1941
|
+
* // When removing a member from a group
|
|
1942
|
+
* async function onMemberRemoved(groupId: string, remainingMembers: Member[]) {
|
|
1943
|
+
* // Rotate our sender key (forward secrecy)
|
|
1944
|
+
* const { distributionMessage } = await signal.rotateGroupSenderKey(groupId);
|
|
1945
|
+
*
|
|
1946
|
+
* // Distribute new key to remaining members via pairwise encryption
|
|
1947
|
+
* for (const member of remainingMembers) {
|
|
1948
|
+
* const encrypted = await signal.encryptMessage(
|
|
1949
|
+
* member.address,
|
|
1950
|
+
* JSON.stringify(distributionMessage)
|
|
1951
|
+
* );
|
|
1952
|
+
* await sendToMember(member, encrypted);
|
|
1953
|
+
* }
|
|
1954
|
+
* }
|
|
1955
|
+
*
|
|
1956
|
+
* // When adding a member - no rotation needed, just distribute current key
|
|
1957
|
+
* async function onMemberAdded(groupId: string, newMember: Member) {
|
|
1958
|
+
* const { distributionMessage } = await signal.createGroupSenderKey(groupId);
|
|
1959
|
+
* // Or get existing: signal.getGroupSenderKeyDistribution(groupId)
|
|
1960
|
+
* const encrypted = await signal.encryptMessage(
|
|
1961
|
+
* newMember.address,
|
|
1962
|
+
* JSON.stringify(distributionMessage)
|
|
1963
|
+
* );
|
|
1964
|
+
* await sendToMember(newMember, encrypted);
|
|
1965
|
+
* }
|
|
1966
|
+
* ```
|
|
1967
|
+
*
|
|
1968
|
+
* @see handleGroupMembershipChange - Helper method for common membership patterns
|
|
1969
|
+
*/
|
|
1970
|
+
async rotateGroupSenderKey(groupId) {
|
|
1971
|
+
return GroupOps.rotateGroupSenderKey(this.ctx, this.senderKeyManager, groupId, this.config.onGroupSenderKeyRotated);
|
|
1972
|
+
}
|
|
1973
|
+
/**
|
|
1974
|
+
* Delete sender key when leaving a group
|
|
1975
|
+
*
|
|
1976
|
+
* @param groupId - Group identifier
|
|
1977
|
+
*/
|
|
1978
|
+
async deleteGroupSenderKey(groupId) {
|
|
1979
|
+
return GroupOps.deleteGroupSenderKey(this.ctx, this.senderKeyManager, groupId);
|
|
1980
|
+
}
|
|
1981
|
+
/**
|
|
1982
|
+
* Check if we have a sender key for a group
|
|
1983
|
+
*
|
|
1984
|
+
* @param groupId - Group identifier
|
|
1985
|
+
* @returns True if sender key exists for this device
|
|
1986
|
+
*/
|
|
1987
|
+
async hasGroupSenderKey(groupId) {
|
|
1988
|
+
return GroupOps.hasGroupSenderKey(this.ctx, groupId);
|
|
1989
|
+
}
|
|
1990
|
+
/**
|
|
1991
|
+
* Get the current sender key distribution message for a group
|
|
1992
|
+
*
|
|
1993
|
+
* If no sender key exists, returns null. Use createGroupSenderKey() first.
|
|
1994
|
+
*
|
|
1995
|
+
* @param groupId - Group identifier
|
|
1996
|
+
* @returns Distribution message or null if no key exists
|
|
1997
|
+
*/
|
|
1998
|
+
async getGroupSenderKeyDistribution(groupId) {
|
|
1999
|
+
return GroupOps.getGroupSenderKeyDistribution(this.ctx, groupId);
|
|
2000
|
+
}
|
|
2001
|
+
/**
|
|
2002
|
+
* Distribute sender key to a specific user via pairwise encryption.
|
|
2003
|
+
*
|
|
2004
|
+
* Distribution messages are transmitted through authenticated, encrypted
|
|
2005
|
+
* pairwise channels.
|
|
2006
|
+
*
|
|
2007
|
+
* This method:
|
|
2008
|
+
* 1. Gets or creates sender key for this group
|
|
2009
|
+
* 2. Encrypts the distribution message using pairwise Signal Protocol
|
|
2010
|
+
* 3. Sends via SESAME to all of the recipient's devices
|
|
2011
|
+
*
|
|
2012
|
+
* @param groupId - Group identifier
|
|
2013
|
+
* @param recipientUserId - Recipient user ID to distribute key to
|
|
2014
|
+
*
|
|
2015
|
+
* @example
|
|
2016
|
+
* ```typescript
|
|
2017
|
+
* // Distribute key to a specific user
|
|
2018
|
+
* await signal.distributeSenderKeyToUser('group-123', 'bob');
|
|
2019
|
+
* ```
|
|
2020
|
+
*/
|
|
2021
|
+
async distributeSenderKeyToUser(groupId, recipientUserId) {
|
|
2022
|
+
// Don't distribute to self
|
|
2023
|
+
if (recipientUserId === this.userId) {
|
|
2024
|
+
return;
|
|
2025
|
+
}
|
|
2026
|
+
// Get or create sender key
|
|
2027
|
+
let distribution = await this.getGroupSenderKeyDistribution(groupId);
|
|
2028
|
+
if (!distribution) {
|
|
2029
|
+
const result = await this.createGroupSenderKey(groupId);
|
|
2030
|
+
distribution = result.distributionMessage;
|
|
2031
|
+
}
|
|
2032
|
+
// Create the distribution payload using ProtoContentData format
|
|
2033
|
+
// senderKeyDistributionMessage is a string field containing JSON-encoded SKDM data
|
|
2034
|
+
const payload = this.contentAdapter.serializeSenderKeyDistributionText(groupId, distribution);
|
|
2035
|
+
// Send via pairwise encryption (SESAME handles multi-device)
|
|
2036
|
+
await this.send(recipientUserId, payload);
|
|
2037
|
+
this.logger.debug('Distributed sender key to user', {
|
|
2038
|
+
category: 'E2EE',
|
|
2039
|
+
data: { groupId, recipientUserId, generation: distribution.generation },
|
|
2040
|
+
});
|
|
2041
|
+
}
|
|
2042
|
+
/**
|
|
2043
|
+
* Distribute sender key to all group members.
|
|
2044
|
+
*
|
|
2045
|
+
* Called after group creation or after key rotation.
|
|
2046
|
+
* Skips self and sends to all other members via pairwise encryption.
|
|
2047
|
+
*
|
|
2048
|
+
* @param groupId - Group identifier
|
|
2049
|
+
* @param memberUserIds - Array of all member user IDs
|
|
2050
|
+
*
|
|
2051
|
+
* @example
|
|
2052
|
+
* ```typescript
|
|
2053
|
+
* // After creating a group
|
|
2054
|
+
* const memberIds = ['alice', 'bob', 'charlie'];
|
|
2055
|
+
* await signal.distributeGroupSenderKey('group-123', memberIds);
|
|
2056
|
+
* ```
|
|
2057
|
+
*/
|
|
2058
|
+
async distributeGroupSenderKey(groupId, memberUserIds) {
|
|
2059
|
+
// Filter out self
|
|
2060
|
+
const recipients = memberUserIds.filter((id) => id !== this.userId);
|
|
2061
|
+
if (recipients.length === 0) {
|
|
2062
|
+
this.logger.debug('No recipients for sender key distribution', {
|
|
2063
|
+
category: 'E2EE',
|
|
2064
|
+
data: { groupId },
|
|
2065
|
+
});
|
|
2066
|
+
return;
|
|
2067
|
+
}
|
|
2068
|
+
// Distribute to each member
|
|
2069
|
+
const results = await Promise.allSettled(recipients.map((userId) => this.distributeSenderKeyToUser(groupId, userId)));
|
|
2070
|
+
// Count successes and failures
|
|
2071
|
+
const succeeded = results.filter((r) => r.status === 'fulfilled').length;
|
|
2072
|
+
const failed = results.filter((r) => r.status === 'rejected').length;
|
|
2073
|
+
this.logger.debug('Distributed sender key to group', {
|
|
2074
|
+
category: 'E2EE',
|
|
2075
|
+
data: { groupId, succeeded, failed, total: recipients.length },
|
|
2076
|
+
});
|
|
2077
|
+
// If all failed, throw an error
|
|
2078
|
+
if (failed === recipients.length) {
|
|
2079
|
+
throw new EncryptionError(`Failed to distribute sender key to any group members`, EncryptionErrorCode.ENCRYPTION_FAILED);
|
|
2080
|
+
}
|
|
2081
|
+
}
|
|
2082
|
+
// ============================================================================
|
|
2083
|
+
// UTILITY METHODS
|
|
2084
|
+
// ============================================================================
|
|
2085
|
+
/**
|
|
2086
|
+
* Clean up expired message keys for a session
|
|
2087
|
+
*
|
|
2088
|
+
* Signal Protocol Section 8.4 recommends deleting message keys older than
|
|
2089
|
+
* one week to avoid excessive storage. This method explicitly triggers cleanup.
|
|
2090
|
+
*
|
|
2091
|
+
* Note: Cleanup also happens automatically during encrypt/decrypt operations.
|
|
2092
|
+
*
|
|
2093
|
+
* @param remoteAddress - Remote party's protocol address (userId:deviceId)
|
|
2094
|
+
* @returns true if cleanup succeeded, false otherwise
|
|
2095
|
+
*/
|
|
2096
|
+
async cleanupExpiredKeys(remoteAddress) {
|
|
2097
|
+
return SessionOps.cleanupExpiredKeys(this.ctx, remoteAddress);
|
|
2098
|
+
}
|
|
2099
|
+
/**
|
|
2100
|
+
* Get encryption statistics
|
|
2101
|
+
*
|
|
2102
|
+
* @returns Statistics about sessions, keys, and usage
|
|
2103
|
+
*/
|
|
2104
|
+
async getStats() {
|
|
2105
|
+
return SessionOps.getStats(this.ctx);
|
|
2106
|
+
}
|
|
2107
|
+
/**
|
|
2108
|
+
* Get health status for encryption sessions with a specific user.
|
|
2109
|
+
*
|
|
2110
|
+
* Delegates to SessionOps.getSessionHealth for implementation.
|
|
2111
|
+
*/
|
|
2112
|
+
async getSessionHealth(userId) {
|
|
2113
|
+
return SessionOps.getSessionHealth(this.ctx, userId);
|
|
2114
|
+
}
|
|
2115
|
+
/**
|
|
2116
|
+
* Check prekey status and trigger warning if running low
|
|
2117
|
+
*
|
|
2118
|
+
* Returns the current prekey count and whether replenishment is needed.
|
|
2119
|
+
* If configured with `onPreKeyLow` callback, it will be called when
|
|
2120
|
+
* the count drops below the threshold.
|
|
2121
|
+
*
|
|
2122
|
+
* @returns Prekey status with remaining count and replenishment flag
|
|
2123
|
+
*
|
|
2124
|
+
* @example
|
|
2125
|
+
* ```typescript
|
|
2126
|
+
* const status = await signal.checkPreKeyStatus();
|
|
2127
|
+
* if (status.needsReplenishment) {
|
|
2128
|
+
* // Generate and upload more prekeys
|
|
2129
|
+
* await backend.replenishPrekeys(userId);
|
|
2130
|
+
* }
|
|
2131
|
+
* ```
|
|
2132
|
+
*/
|
|
2133
|
+
async checkPreKeyStatus() {
|
|
2134
|
+
return PreKeyOps.checkPreKeyStatus(this.ctx, this.config.preKeyLowThreshold ?? 50, this.config.onPreKeyLow);
|
|
2135
|
+
}
|
|
2136
|
+
/**
|
|
2137
|
+
* Clear all encryption data
|
|
2138
|
+
*
|
|
2139
|
+
* WARNING: This permanently deletes all keys and sessions.
|
|
2140
|
+
* Use only for local development or when resetting the app.
|
|
2141
|
+
*/
|
|
2142
|
+
async clearAllData() {
|
|
2143
|
+
await this._storage.clearAllKeys();
|
|
2144
|
+
this.logger.warn('All encryption data cleared', {
|
|
2145
|
+
category: 'E2EE',
|
|
2146
|
+
data: { userId: this.userId },
|
|
2147
|
+
});
|
|
2148
|
+
}
|
|
2149
|
+
/**
|
|
2150
|
+
* Get statistics for a group sender key.
|
|
2151
|
+
*
|
|
2152
|
+
* Useful for debugging and monitoring group messaging health.
|
|
2153
|
+
*
|
|
2154
|
+
* @param groupId - Group identifier
|
|
2155
|
+
* @param senderId - Sender user identifier
|
|
2156
|
+
* @param senderDeviceId - Sender device identifier
|
|
2157
|
+
* @returns Stats including chain position, generation, and skipped keys count
|
|
2158
|
+
*
|
|
2159
|
+
* @example
|
|
2160
|
+
* ```typescript
|
|
2161
|
+
* const stats = await signal.getGroupSenderKeyStats('group-123', 'alice', 1);
|
|
2162
|
+
* console.log(`Chain at ${stats.chainIndex}, gen ${stats.generation}`);
|
|
2163
|
+
* console.log(`${stats.skippedKeysCount} skipped keys stored`);
|
|
2164
|
+
* ```
|
|
2165
|
+
*/
|
|
2166
|
+
async getGroupSenderKeyStats(groupId, senderId, senderDeviceId) {
|
|
2167
|
+
return this.senderKeyManager.getStats(groupId, senderId, senderDeviceId);
|
|
2168
|
+
}
|
|
2169
|
+
/**
|
|
2170
|
+
* Handle group membership change with appropriate sender key actions.
|
|
2171
|
+
*
|
|
2172
|
+
* This convenience method applies the sender-key lifecycle for membership
|
|
2173
|
+
* changes:
|
|
2174
|
+
* - Member removed: Rotate sender key (forward secrecy)
|
|
2175
|
+
* - Member added: No rotation needed (just distribute current key)
|
|
2176
|
+
* - Metadata changed: Rotate recommended
|
|
2177
|
+
*
|
|
2178
|
+
* @param groupId - Group identifier
|
|
2179
|
+
* @param change - Type of membership change
|
|
2180
|
+
* @returns Distribution message if rotation occurred, for sending to members
|
|
2181
|
+
*
|
|
2182
|
+
* @example
|
|
2183
|
+
* ```typescript
|
|
2184
|
+
* // When a member is removed
|
|
2185
|
+
* const result = await signal.handleGroupMembershipChange(
|
|
2186
|
+
* 'group-123',
|
|
2187
|
+
* 'member_removed'
|
|
2188
|
+
* );
|
|
2189
|
+
*
|
|
2190
|
+
* if (result.rotated) {
|
|
2191
|
+
* // Distribute new key to remaining members
|
|
2192
|
+
* for (const member of remainingMembers) {
|
|
2193
|
+
* const encrypted = await signal.encryptMessage(
|
|
2194
|
+
* member.address,
|
|
2195
|
+
* JSON.stringify(result.distributionMessage)
|
|
2196
|
+
* );
|
|
2197
|
+
* await sendToMember(member, encrypted);
|
|
2198
|
+
* }
|
|
2199
|
+
* }
|
|
2200
|
+
* ```
|
|
2201
|
+
*/
|
|
2202
|
+
async handleGroupMembershipChange(groupId, change) {
|
|
2203
|
+
if (change === 'member_removed' || change === 'metadata_changed') {
|
|
2204
|
+
// Per the Signal Protocol sender-key model: rotate on removal or metadata
|
|
2205
|
+
// change for forward secrecy.
|
|
2206
|
+
const { distributionMessage } = await this.rotateGroupSenderKey(groupId);
|
|
2207
|
+
return { rotated: true, distributionMessage };
|
|
2208
|
+
}
|
|
2209
|
+
// member_added: no rotation needed, just distribute current key
|
|
2210
|
+
return { rotated: false };
|
|
2211
|
+
}
|
|
2212
|
+
// ============================================================================
|
|
2213
|
+
// GROUPS V2 (Signal Private Group System)
|
|
2214
|
+
// ============================================================================
|
|
2215
|
+
/**
|
|
2216
|
+
* Create a new GroupsV2 group.
|
|
2217
|
+
*/
|
|
2218
|
+
async createGroupV2(creatorAci, creatorProfileKey, members, title, options) {
|
|
2219
|
+
return GroupOps.createGroupV2(this.ctx, this.groupsV2, creatorAci, creatorProfileKey, members, title, options);
|
|
2220
|
+
}
|
|
2221
|
+
/**
|
|
2222
|
+
* Get decrypted group state (from cache or server).
|
|
2223
|
+
*/
|
|
2224
|
+
async getGroupStateV2(groupId) {
|
|
2225
|
+
return GroupOps.getGroupStateV2(this.ctx, this.groupsV2, groupId);
|
|
2226
|
+
}
|
|
2227
|
+
/**
|
|
2228
|
+
* Sync group state from server.
|
|
2229
|
+
*/
|
|
2230
|
+
async syncGroupV2(groupId) {
|
|
2231
|
+
return GroupOps.syncGroupV2(this.ctx, this.groupsV2, groupId);
|
|
2232
|
+
}
|
|
2233
|
+
/**
|
|
2234
|
+
* Add a member to a GroupsV2 group.
|
|
2235
|
+
*/
|
|
2236
|
+
async addGroupMemberV2(groupId, editorAci, newMemberAci, newMemberProfileKey) {
|
|
2237
|
+
return GroupOps.addGroupMemberV2(this.ctx, this.groupsV2, groupId, editorAci, newMemberAci, newMemberProfileKey);
|
|
2238
|
+
}
|
|
2239
|
+
/**
|
|
2240
|
+
* Remove a member from a GroupsV2 group. Triggers sender key rotation.
|
|
2241
|
+
*/
|
|
2242
|
+
async removeGroupMemberV2(groupId, editorAci, targetAci) {
|
|
2243
|
+
return GroupOps.removeGroupMemberV2(this.ctx, this.groupsV2, groupId, editorAci, targetAci);
|
|
2244
|
+
}
|
|
2245
|
+
/**
|
|
2246
|
+
* Leave a GroupsV2 group.
|
|
2247
|
+
*/
|
|
2248
|
+
async leaveGroupV2(groupId, userAci) {
|
|
2249
|
+
return GroupOps.leaveGroupV2(this.ctx, this.groupsV2, groupId, userAci);
|
|
2250
|
+
}
|
|
2251
|
+
/**
|
|
2252
|
+
* Update GroupsV2 group title.
|
|
2253
|
+
*/
|
|
2254
|
+
async updateGroupTitleV2(groupId, editorAci, title) {
|
|
2255
|
+
return GroupOps.updateGroupTitleV2(this.ctx, this.groupsV2, groupId, editorAci, title);
|
|
2256
|
+
}
|
|
2257
|
+
/**
|
|
2258
|
+
* Update GroupsV2 group description.
|
|
2259
|
+
*/
|
|
2260
|
+
async updateGroupDescriptionV2(groupId, editorAci, description) {
|
|
2261
|
+
return GroupOps.updateGroupDescriptionV2(this.ctx, this.groupsV2, groupId, editorAci, description);
|
|
2262
|
+
}
|
|
2263
|
+
/**
|
|
2264
|
+
* Update GroupsV2 group access control.
|
|
2265
|
+
*/
|
|
2266
|
+
async updateGroupAccessControlV2(groupId, editorAci, updates) {
|
|
2267
|
+
return GroupOps.updateGroupAccessControlV2(this.ctx, this.groupsV2, groupId, editorAci, updates);
|
|
2268
|
+
}
|
|
2269
|
+
/**
|
|
2270
|
+
* Create an invite link for a GroupsV2 group.
|
|
2271
|
+
*/
|
|
2272
|
+
async createGroupInviteLinkV2(groupId, editorAci) {
|
|
2273
|
+
return GroupOps.createGroupInviteLinkV2(this.ctx, this.groupsV2, groupId, editorAci);
|
|
2274
|
+
}
|
|
2275
|
+
/**
|
|
2276
|
+
* Join a GroupsV2 group via invite link.
|
|
2277
|
+
*/
|
|
2278
|
+
async joinGroupViaInviteLinkV2(url, userAci, userProfileKey) {
|
|
2279
|
+
return GroupOps.joinGroupViaInviteLinkV2(this.ctx, this.groupsV2, url, userAci, userProfileKey);
|
|
2280
|
+
}
|
|
2281
|
+
// ============================================================================
|
|
2282
|
+
// PRIVATE METHODS
|
|
2283
|
+
// ============================================================================
|
|
2284
|
+
/**
|
|
2285
|
+
* Sanitize config for logging (remove sensitive data)
|
|
2286
|
+
*/
|
|
2287
|
+
sanitizeConfig(config) {
|
|
2288
|
+
return {
|
|
2289
|
+
hasStorage: !!config.storage,
|
|
2290
|
+
hasProtocolManager: !!config.protocolManager,
|
|
2291
|
+
enableDebugLogging: config.enableDebugLogging,
|
|
2292
|
+
throwDetailedErrors: config.throwDetailedErrors,
|
|
2293
|
+
};
|
|
2294
|
+
}
|
|
2295
|
+
}
|
|
2296
|
+
//# sourceMappingURL=client.js.map
|