@open-e2ee/signal-protocol-sdk 0.1.0-alpha.7 → 0.1.0-alpha.8
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 +1 -1
- package/CHANGELOG.md +680 -2
- package/COMMERCIAL.md +56 -0
- package/README.md +13 -8
- package/SECURITY.md +15 -1
- package/client/README.md +1 -1
- package/dist/client/client.d.ts.map +1 -1
- package/dist/client/client.js +16 -8
- package/dist/client/client.js.map +1 -1
- package/dist/client/config.d.ts +12 -2
- package/dist/client/config.d.ts.map +1 -1
- package/dist/client/config.js.map +1 -1
- package/dist/client/endorsement-manager.d.ts +19 -2
- package/dist/client/endorsement-manager.d.ts.map +1 -1
- package/dist/client/endorsement-manager.js +26 -10
- package/dist/client/endorsement-manager.js.map +1 -1
- package/dist/client/headless.d.ts +1 -1
- package/dist/client/headless.js +1 -1
- package/dist/client/sealed-sender-ops.d.ts +27 -1
- package/dist/client/sealed-sender-ops.d.ts.map +1 -1
- package/dist/client/sealed-sender-ops.js +36 -6
- package/dist/client/sealed-sender-ops.js.map +1 -1
- package/dist/client/signal-service-cipher.d.ts +16 -1
- package/dist/client/signal-service-cipher.d.ts.map +1 -1
- package/dist/client/signal-service-cipher.js +112 -52
- package/dist/client/signal-service-cipher.js.map +1 -1
- package/dist/client/types.d.ts +20 -7
- package/dist/client/types.d.ts.map +1 -1
- package/dist/client/types.js.map +1 -1
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -1
- package/dist/internal/crypto/index.d.ts +1 -1
- package/dist/internal/crypto/index.d.ts.map +1 -1
- package/dist/internal/crypto/index.js +1 -1
- package/dist/internal/crypto/index.js.map +1 -1
- package/dist/internal/crypto/random.d.ts +9 -0
- package/dist/internal/crypto/random.d.ts.map +1 -1
- package/dist/internal/crypto/random.js +16 -0
- package/dist/internal/crypto/random.js.map +1 -1
- package/dist/internal/groups/manager.d.ts +13 -0
- package/dist/internal/groups/manager.d.ts.map +1 -1
- package/dist/internal/groups/manager.js +73 -12
- package/dist/internal/groups/manager.js.map +1 -1
- package/dist/internal/groups/server-engine.d.ts +31 -0
- package/dist/internal/groups/server-engine.d.ts.map +1 -1
- package/dist/internal/groups/server-engine.js +67 -7
- package/dist/internal/groups/server-engine.js.map +1 -1
- package/dist/internal/protocol/sealed-sender/decryption-v2.d.ts.map +1 -1
- package/dist/internal/protocol/sealed-sender/decryption-v2.js +32 -18
- package/dist/internal/protocol/sealed-sender/decryption-v2.js.map +1 -1
- package/dist/internal/protocol/sealed-sender/decryption.d.ts.map +1 -1
- package/dist/internal/protocol/sealed-sender/decryption.js +33 -19
- package/dist/internal/protocol/sealed-sender/decryption.js.map +1 -1
- package/dist/internal/protocol/sealed-sender/encryption-v2.d.ts.map +1 -1
- package/dist/internal/protocol/sealed-sender/encryption-v2.js +8 -14
- package/dist/internal/protocol/sealed-sender/encryption-v2.js.map +1 -1
- package/dist/internal/protocol/sealed-sender/encryption.d.ts +9 -4
- package/dist/internal/protocol/sealed-sender/encryption.d.ts.map +1 -1
- package/dist/internal/protocol/sealed-sender/encryption.js +7 -15
- package/dist/internal/protocol/sealed-sender/encryption.js.map +1 -1
- package/dist/internal/protocol/sealed-sender/proto/index.d.ts +6 -7
- package/dist/internal/protocol/sealed-sender/proto/index.d.ts.map +1 -1
- package/dist/internal/protocol/sealed-sender/proto/index.js +5 -7
- package/dist/internal/protocol/sealed-sender/proto/index.js.map +1 -1
- package/dist/internal/protocol/sealed-sender/trust-root.d.ts +45 -0
- package/dist/internal/protocol/sealed-sender/trust-root.d.ts.map +1 -0
- package/dist/internal/protocol/sealed-sender/trust-root.js +77 -0
- package/dist/internal/protocol/sealed-sender/trust-root.js.map +1 -0
- package/dist/internal/protocol/sealed-sender/types.d.ts +64 -9
- package/dist/internal/protocol/sealed-sender/types.d.ts.map +1 -1
- package/dist/internal/protocol/sealed-sender/types.js +43 -0
- package/dist/internal/protocol/sealed-sender/types.js.map +1 -1
- package/dist/internal/protocol/sender-keys/manager.d.ts +37 -0
- package/dist/internal/protocol/sender-keys/manager.d.ts.map +1 -1
- package/dist/internal/protocol/sender-keys/manager.js +108 -7
- package/dist/internal/protocol/sender-keys/manager.js.map +1 -1
- package/dist/local/store/expo/adapter.d.ts +14 -15
- package/dist/local/store/expo/adapter.d.ts.map +1 -1
- package/dist/local/store/expo/adapter.js +109 -102
- package/dist/local/store/expo/adapter.js.map +1 -1
- package/dist/local/store/expo/db.d.ts +4 -1
- package/dist/local/store/expo/db.d.ts.map +1 -1
- package/dist/local/store/expo/db.js +5 -0
- package/dist/local/store/expo/db.js.map +1 -1
- package/dist/local/store/expo/index.d.ts +0 -2
- package/dist/local/store/expo/index.d.ts.map +1 -1
- package/dist/local/store/expo/index.js +1 -1
- package/dist/local/store/expo/index.js.map +1 -1
- package/dist/local/store/expo/models/index.d.ts +1 -1
- package/dist/local/store/expo/models/index.d.ts.map +1 -1
- package/dist/local/store/expo/models/index.js +2 -2
- package/dist/local/store/expo/models/index.js.map +1 -1
- package/dist/local/store/expo/models/sender-key.d.ts +101 -77
- package/dist/local/store/expo/models/sender-key.d.ts.map +1 -1
- package/dist/local/store/expo/models/sender-key.js +154 -124
- package/dist/local/store/expo/models/sender-key.js.map +1 -1
- package/dist/local/store/expo/schema.d.ts +134 -32
- package/dist/local/store/expo/schema.d.ts.map +1 -1
- package/dist/local/store/expo/schema.js +36 -7
- package/dist/local/store/expo/schema.js.map +1 -1
- package/dist/local/store/mock/adapter.d.ts +1 -0
- package/dist/local/store/mock/adapter.d.ts.map +1 -1
- package/dist/local/store/mock/adapter.js +18 -0
- package/dist/local/store/mock/adapter.js.map +1 -1
- package/dist/local/store/react-native/adapter.d.ts +39 -0
- package/dist/local/store/react-native/adapter.d.ts.map +1 -1
- package/dist/local/store/react-native/adapter.js +163 -8
- package/dist/local/store/react-native/adapter.js.map +1 -1
- package/dist/local/store/web/adapter.d.ts +1 -0
- package/dist/local/store/web/adapter.d.ts.map +1 -1
- package/dist/local/store/web/adapter.js +33 -1
- package/dist/local/store/web/adapter.js.map +1 -1
- package/dist/remote/relay/convex/backend.d.ts +402 -0
- package/dist/remote/relay/convex/backend.d.ts.map +1 -0
- package/dist/remote/relay/convex/backend.js +684 -0
- package/dist/remote/relay/convex/backend.js.map +1 -0
- package/dist/remote/relay/convex/component/_generated/api.d.ts +58 -0
- package/dist/remote/relay/convex/component/_generated/api.d.ts.map +1 -0
- package/dist/remote/relay/convex/component/_generated/api.js +31 -0
- package/dist/remote/relay/convex/component/_generated/api.js.map +1 -0
- package/dist/remote/relay/convex/component/_generated/component.d.ts +480 -0
- package/dist/remote/relay/convex/component/_generated/component.d.ts.map +1 -0
- package/dist/remote/relay/convex/component/_generated/component.js +11 -0
- package/dist/remote/relay/convex/component/_generated/component.js.map +1 -0
- package/dist/remote/relay/convex/component/_generated/dataModel.d.ts +46 -0
- package/dist/remote/relay/convex/component/_generated/dataModel.d.ts.map +1 -0
- package/dist/remote/relay/convex/component/_generated/dataModel.js +11 -0
- package/dist/remote/relay/convex/component/_generated/dataModel.js.map +1 -0
- package/dist/remote/relay/convex/component/_generated/server.d.ts +129 -0
- package/dist/remote/relay/convex/component/_generated/server.d.ts.map +1 -0
- package/dist/remote/relay/convex/component/_generated/server.js +79 -0
- package/dist/remote/relay/convex/component/_generated/server.js.map +1 -0
- package/dist/remote/relay/convex/component/accounts.d.ts +43 -0
- package/dist/remote/relay/convex/component/accounts.d.ts.map +1 -0
- package/dist/remote/relay/convex/component/accounts.js +181 -0
- package/dist/remote/relay/convex/component/accounts.js.map +1 -0
- package/dist/remote/relay/convex/component/certificates.d.ts +10 -0
- package/dist/remote/relay/convex/component/certificates.d.ts.map +1 -0
- package/dist/remote/relay/convex/component/certificates.js +122 -0
- package/dist/remote/relay/convex/component/certificates.js.map +1 -0
- package/dist/remote/relay/convex/component/cleanup.d.ts +26 -0
- package/dist/remote/relay/convex/component/cleanup.d.ts.map +1 -0
- package/dist/remote/relay/convex/component/cleanup.js +127 -0
- package/dist/remote/relay/convex/component/cleanup.js.map +1 -0
- package/dist/remote/relay/convex/component/convex.config.d.ts +5 -0
- package/dist/remote/relay/convex/component/convex.config.d.ts.map +1 -0
- package/dist/remote/relay/convex/component/convex.config.js +33 -0
- package/dist/remote/relay/convex/component/convex.config.js.map +1 -0
- package/dist/remote/relay/convex/component/crons.d.ts +3 -0
- package/dist/remote/relay/convex/component/crons.d.ts.map +1 -0
- package/dist/remote/relay/convex/component/crons.js +9 -0
- package/dist/remote/relay/convex/component/crons.js.map +1 -0
- package/dist/remote/relay/convex/component/devices.d.ts +101 -0
- package/dist/remote/relay/convex/component/devices.d.ts.map +1 -0
- package/dist/remote/relay/convex/component/devices.js +299 -0
- package/dist/remote/relay/convex/component/devices.js.map +1 -0
- package/dist/remote/relay/convex/component/errors.d.ts +22 -0
- package/dist/remote/relay/convex/component/errors.d.ts.map +1 -0
- package/dist/remote/relay/convex/component/errors.js +17 -0
- package/dist/remote/relay/convex/component/errors.js.map +1 -0
- package/dist/remote/relay/convex/component/groups.d.ts +60 -0
- package/dist/remote/relay/convex/component/groups.d.ts.map +1 -0
- package/dist/remote/relay/convex/component/groups.js +331 -0
- package/dist/remote/relay/convex/component/groups.js.map +1 -0
- package/dist/remote/relay/convex/component/keys.d.ts +130 -0
- package/dist/remote/relay/convex/component/keys.d.ts.map +1 -0
- package/dist/remote/relay/convex/component/keys.js +578 -0
- package/dist/remote/relay/convex/component/keys.js.map +1 -0
- package/dist/remote/relay/convex/component/messages.d.ts +119 -0
- package/dist/remote/relay/convex/component/messages.d.ts.map +1 -0
- package/dist/remote/relay/convex/component/messages.js +649 -0
- package/dist/remote/relay/convex/component/messages.js.map +1 -0
- package/dist/remote/relay/convex/component/provisioning.d.ts +92 -0
- package/dist/remote/relay/convex/component/provisioning.d.ts.map +1 -0
- package/dist/remote/relay/convex/component/provisioning.js +359 -0
- package/dist/remote/relay/convex/component/provisioning.js.map +1 -0
- package/dist/remote/relay/convex/component/runtime.d.ts +18 -0
- package/dist/remote/relay/convex/component/runtime.d.ts.map +1 -0
- package/dist/remote/relay/convex/component/runtime.js +142 -0
- package/dist/remote/relay/convex/component/runtime.js.map +1 -0
- package/dist/remote/relay/convex/component/schema.d.ts +344 -0
- package/dist/remote/relay/convex/component/schema.d.ts.map +1 -0
- package/dist/remote/relay/convex/component/schema.js +266 -0
- package/dist/remote/relay/convex/component/schema.js.map +1 -0
- package/dist/remote/relay/convex/component/zkAuth.d.ts +12 -0
- package/dist/remote/relay/convex/component/zkAuth.d.ts.map +1 -0
- package/dist/remote/relay/convex/component/zkAuth.js +71 -0
- package/dist/remote/relay/convex/component/zkAuth.js.map +1 -0
- package/dist/remote/relay/convex/constants.d.ts +3 -0
- package/dist/remote/relay/convex/constants.d.ts.map +1 -0
- package/dist/remote/relay/convex/constants.js +3 -0
- package/dist/remote/relay/convex/constants.js.map +1 -0
- package/dist/remote/relay/convex/group-server.d.ts +4 -2
- package/dist/remote/relay/convex/group-server.d.ts.map +1 -1
- package/dist/remote/relay/convex/group-server.js +4 -2
- package/dist/remote/relay/convex/group-server.js.map +1 -1
- package/dist/remote/relay/convex/index.d.ts +4 -1
- package/dist/remote/relay/convex/index.d.ts.map +1 -1
- package/dist/remote/relay/convex/index.js +3 -1
- package/dist/remote/relay/convex/index.js.map +1 -1
- package/dist/remote/relay/convex/relay.d.ts +42 -63
- package/dist/remote/relay/convex/relay.d.ts.map +1 -1
- package/dist/remote/relay/convex/relay.js +51 -29
- package/dist/remote/relay/convex/relay.js.map +1 -1
- package/dist/remote/relay/convex/types.d.ts +16 -103
- package/dist/remote/relay/convex/types.d.ts.map +1 -1
- package/dist/remote/relay/convex/types.js +8 -13
- package/dist/remote/relay/convex/types.js.map +1 -1
- package/dist/remote/relay/index.d.ts +1 -1
- package/dist/remote/relay/index.d.ts.map +1 -1
- package/dist/remote/relay/index.js.map +1 -1
- package/dist/remote/relay/mock/adapter.d.ts +2 -7
- package/dist/remote/relay/mock/adapter.d.ts.map +1 -1
- package/dist/remote/relay/mock/adapter.js +32 -20
- package/dist/remote/relay/mock/adapter.js.map +1 -1
- package/dist/remote/relay/types.d.ts +32 -69
- package/dist/remote/relay/types.d.ts.map +1 -1
- package/dist/remote/relay/types.js +0 -1
- package/dist/remote/relay/types.js.map +1 -1
- package/dist/types/api.d.ts +21 -0
- package/dist/types/api.d.ts.map +1 -1
- package/dist/types/protocol-config.d.ts +51 -0
- package/dist/types/protocol-config.d.ts.map +1 -1
- package/dist/types/protocol-config.js +46 -0
- package/dist/types/protocol-config.js.map +1 -1
- package/docs/ASSURANCE.md +10 -6
- package/docs/CLIENT_COMPOSITION.md +23 -69
- package/docs/DEVIATIONS.md +44 -11
- package/docs/E2EE.md +71 -6
- package/docs/GETTING_STARTED.md +1 -1
- package/docs/PACKAGE_SURFACE.md +6 -5
- package/docs/RECIPES.md +1 -1
- package/docs/SECURITY.md +8 -0
- package/local/store/expo/README.md +10 -1
- package/local/store/node/README.md +10 -1
- package/package.json +12 -7
- package/remote/relay/convex/README.md +1 -1
- package/remote/relay/convex/component/README.md +428 -0
- package/scripts/oe-groups.mjs +21 -1
- package/dist/remote/relay/convex/server/index.d.ts +0 -2
- package/dist/remote/relay/convex/server/index.d.ts.map +0 -1
- package/dist/remote/relay/convex/server/index.js +0 -2
- package/dist/remote/relay/convex/server/index.js.map +0 -1
- package/dist/remote/relay/convex/server.d.ts +0 -150
- package/dist/remote/relay/convex/server.d.ts.map +0 -1
- package/dist/remote/relay/convex/server.js +0 -506
- package/dist/remote/relay/convex/server.js.map +0 -1
- package/docs/api/README.md +0 -471
- package/docs/api/classes/EncryptionError.md +0 -112
- package/docs/api/classes/EndorsementManager.md +0 -325
- package/docs/api/classes/SealedSenderAuthError.md +0 -127
- package/docs/api/classes/ServerDerivedKeyPair.md +0 -68
- package/docs/api/classes/ServerDerivedPublicKey.md +0 -33
- package/docs/api/classes/ServerRootKeyPair.md +0 -94
- package/docs/api/classes/ServerRootPublicKey.md +0 -72
- package/docs/api/classes/SignalProtocolBlockingManager.md +0 -106
- package/docs/api/classes/SignalProtocolClient.md +0 -2654
- package/docs/api/classes/VerificationFailure.md +0 -25
- package/docs/api/enumerations/ContentHint.md +0 -63
- package/docs/api/enumerations/EncryptionErrorCode.md +0 -488
- package/docs/api/enumerations/IdentityKeyChange.md +0 -65
- package/docs/api/enumerations/MessageType.md +0 -29
- package/docs/api/enumerations/TrustDirection.md +0 -33
- package/docs/api/enumerations/TypingAction.md +0 -31
- package/docs/api/functions/createDefaultSignalProtocolContentAdapter.md +0 -13
- package/docs/api/functions/createDefaultSignalProtocolLogger.md +0 -36
- package/docs/api/functions/createGroupId.md +0 -32
- package/docs/api/functions/createSignalProtocolClient.md +0 -36
- package/docs/api/functions/createSignalProtocolClientConfig.md +0 -24
- package/docs/api/functions/decodeGroupTrustRoot.md +0 -21
- package/docs/api/functions/encodeGroupTrustRoot.md +0 -28
- package/docs/api/functions/extractGroupId.md +0 -32
- package/docs/api/functions/formatVersion.md +0 -25
- package/docs/api/functions/isCompatible.md +0 -31
- package/docs/api/functions/isGroupId.md +0 -37
- package/docs/api/functions/isSealedSenderAuthError.md +0 -25
- package/docs/api/functions/parseVersion.md +0 -29
- package/docs/api/functions/resolveSPQRLimits.md +0 -21
- package/docs/api/functions/resolveSignalProtocolLogger.md +0 -42
- package/docs/api/interfaces/AccountIdentityProvisioning.md +0 -43
- package/docs/api/interfaces/AccountIdentityRotation.md +0 -69
- package/docs/api/interfaces/AttachmentTransferOptions.md +0 -49
- package/docs/api/interfaces/BlockedRecipientEntry.md +0 -25
- package/docs/api/interfaces/BlockedRecipientsSyncInput.md +0 -27
- package/docs/api/interfaces/ConfigurationSyncInput.md +0 -19
- package/docs/api/interfaces/CredentialPublicKey.md +0 -25
- package/docs/api/interfaces/DataMessageInput.md +0 -21
- package/docs/api/interfaces/DecryptedEnvelope.md +0 -95
- package/docs/api/interfaces/DecryptedGroup.md +0 -86
- package/docs/api/interfaces/DeviceInfo.md +0 -79
- package/docs/api/interfaces/DeviceRecord.md +0 -87
- package/docs/api/interfaces/DeviceRegistration.md +0 -27
- package/docs/api/interfaces/DoubleRatchetConfig.md +0 -36
- package/docs/api/interfaces/EcOneTimePreKey.md +0 -27
- package/docs/api/interfaces/EcSignedPreKey.md +0 -39
- package/docs/api/interfaces/EcSignedPreKeyUpload.md +0 -50
- package/docs/api/interfaces/EncryptionErrorContext.md +0 -51
- package/docs/api/interfaces/Envelope.md +0 -154
- package/docs/api/interfaces/ForceKeyResetResult.md +0 -37
- package/docs/api/interfaces/GroupAuthorization.md +0 -23
- package/docs/api/interfaces/GroupChangeEntry.md +0 -42
- package/docs/api/interfaces/GroupMemberDevice.md +0 -26
- package/docs/api/interfaces/GroupTrustRoot.md +0 -33
- package/docs/api/interfaces/IEcOneTimePreKeyStore.md +0 -86
- package/docs/api/interfaces/IEcSignedPreKeyStore.md +0 -133
- package/docs/api/interfaces/IGroupServer.md +0 -120
- package/docs/api/interfaces/IGroupStateStore.md +0 -128
- package/docs/api/interfaces/IIdentityKeyStore.md +0 -312
- package/docs/api/interfaces/IKemPreKeyStore.md +0 -144
- package/docs/api/interfaces/IKyberLastResortPreKeyStore.md +0 -112
- package/docs/api/interfaces/ILogger.md +0 -117
- package/docs/api/interfaces/IProtocolStore.md +0 -1033
- package/docs/api/interfaces/IRelayGroupServer.md +0 -60
- package/docs/api/interfaces/ISenderKeyStore.md +0 -417
- package/docs/api/interfaces/ISesameStore.md +0 -249
- package/docs/api/interfaces/ISessionStore.md +0 -178
- package/docs/api/interfaces/ISignalProtocolClient.md +0 -1185
- package/docs/api/interfaces/ISignalProtocolLocalSecretVault.md +0 -71
- package/docs/api/interfaces/ISignalProtocolLocalStore.md +0 -2053
- package/docs/api/interfaces/ISignalProtocolManager.md +0 -272
- package/docs/api/interfaces/ISignalProtocolRelayServer.md +0 -1337
- package/docs/api/interfaces/IdentityKeyPair.md +0 -49
- package/docs/api/interfaces/IncomingEnvelope.md +0 -91
- package/docs/api/interfaces/InspectedSignalProtocolContent.md +0 -43
- package/docs/api/interfaces/KDFChain.md +0 -31
- package/docs/api/interfaces/KemLastResortPreKeyUpload.md +0 -50
- package/docs/api/interfaces/KeyPair.md +0 -23
- package/docs/api/interfaces/KyberPreKey.md +0 -42
- package/docs/api/interfaces/MLKEMBraidAgentState.md +0 -191
- package/docs/api/interfaces/MLKEMBraidMessage.md +0 -49
- package/docs/api/interfaces/MediaAttachmentDeleteSyncInput.md +0 -31
- package/docs/api/interfaces/MessageHeader.md +0 -49
- package/docs/api/interfaces/MessageRecord.md +0 -86
- package/docs/api/interfaces/ParsedReceiptContent.md +0 -19
- package/docs/api/interfaces/ParsedTypingContent.md +0 -19
- package/docs/api/interfaces/PreKeyMaintenanceStore.md +0 -88
- package/docs/api/interfaces/PreKeyMessage.md +0 -159
- package/docs/api/interfaces/PreKeyStatusResult.md +0 -21
- package/docs/api/interfaces/PreKeyUpload.md +0 -42
- package/docs/api/interfaces/ProcessEnvelopeOptions.md +0 -72
- package/docs/api/interfaces/ProtocolAddress.md +0 -38
- package/docs/api/interfaces/ProtocolStrategyConfig.md +0 -91
- package/docs/api/interfaces/RatchetMessage.md +0 -96
- package/docs/api/interfaces/ReadSyncEntryInput.md +0 -19
- package/docs/api/interfaces/ReceiverChain.md +0 -43
- package/docs/api/interfaces/RecipientUsernameSyncInput.md +0 -31
- package/docs/api/interfaces/RelayPreKeyBundle.md +0 -254
- package/docs/api/interfaces/RemoteObjectDownload.md +0 -33
- package/docs/api/interfaces/RemoteObjectUpload.md +0 -49
- package/docs/api/interfaces/ResolvedSPQRInfoStrings.md +0 -27
- package/docs/api/interfaces/ResolvedSPQRLimits.md +0 -37
- package/docs/api/interfaces/RetryRequest.md +0 -80
- package/docs/api/interfaces/SCKAState.md +0 -65
- package/docs/api/interfaces/SPQRLimits.md +0 -40
- package/docs/api/interfaces/SPQRState.md +0 -191
- package/docs/api/interfaces/SafetyNumber.md +0 -60
- package/docs/api/interfaces/SafetyNumberConfirmation.md +0 -46
- package/docs/api/interfaces/SealedSenderConfig.md +0 -70
- package/docs/api/interfaces/SendOptions.md +0 -191
- package/docs/api/interfaces/SendResult.md +0 -93
- package/docs/api/interfaces/SenderKeyDistributionMessage.md +0 -43
- package/docs/api/interfaces/SenderKeyState.md +0 -76
- package/docs/api/interfaces/SenderKeysConfig.md +0 -65
- package/docs/api/interfaces/SentSyncTranscriptInput.md +0 -31
- package/docs/api/interfaces/ServiceId.md +0 -19
- package/docs/api/interfaces/SesameMessage.md +0 -84
- package/docs/api/interfaces/SesameStats.md +0 -57
- package/docs/api/interfaces/SessionHealthResult.md +0 -120
- package/docs/api/interfaces/SessionRecord.md +0 -80
- package/docs/api/interfaces/SessionRecordMetadata.md +0 -109
- package/docs/api/interfaces/SessionState.md +0 -368
- package/docs/api/interfaces/SessionTrustCommit.md +0 -58
- package/docs/api/interfaces/SignalProtocolBlockingHooks.md +0 -44
- package/docs/api/interfaces/SignalProtocolBlockingManagerOptions.md +0 -31
- package/docs/api/interfaces/SignalProtocolBlockingMirror.md +0 -30
- package/docs/api/interfaces/SignalProtocolBlockingStore.md +0 -83
- package/docs/api/interfaces/SignalProtocolClientAdapterConfig.md +0 -44
- package/docs/api/interfaces/SignalProtocolClientCompositionOptions.md +0 -731
- package/docs/api/interfaces/SignalProtocolClientConfig.md +0 -895
- package/docs/api/interfaces/SignalProtocolClientDeleteLocalAttachmentInput.md +0 -25
- package/docs/api/interfaces/SignalProtocolClientHooks.md +0 -506
- package/docs/api/interfaces/SignalProtocolClientIdentityConfig.md +0 -51
- package/docs/api/interfaces/SignalProtocolClientLoadLocalAttachmentInput.md +0 -187
- package/docs/api/interfaces/SignalProtocolClientLoadedLocalAttachment.md +0 -19
- package/docs/api/interfaces/SignalProtocolClientMedia.md +0 -83
- package/docs/api/interfaces/SignalProtocolClientMediaCompletedResult.md +0 -25
- package/docs/api/interfaces/SignalProtocolClientMediaConfig.md +0 -157
- package/docs/api/interfaces/SignalProtocolClientMediaDownloadCompletedResult.md +0 -37
- package/docs/api/interfaces/SignalProtocolClientMediaDownloadNotNeededResult.md +0 -25
- package/docs/api/interfaces/SignalProtocolClientMediaFailedResult.md +0 -19
- package/docs/api/interfaces/SignalProtocolClientMediaOperationOptions.md +0 -53
- package/docs/api/interfaces/SignalProtocolClientMediaPendingResult.md +0 -19
- package/docs/api/interfaces/SignalProtocolClientMediaProcessResult.md +0 -43
- package/docs/api/interfaces/SignalProtocolClientMediaSkippedResult.md +0 -25
- package/docs/api/interfaces/SignalProtocolClientMediaUploadCompletedResult.md +0 -31
- package/docs/api/interfaces/SignalProtocolClientProcessPendingMediaOptions.md +0 -87
- package/docs/api/interfaces/SignalProtocolClientSaveDownloadedAttachmentInput.md +0 -25
- package/docs/api/interfaces/SignalProtocolClientSaveUploadedAttachmentInput.md +0 -25
- package/docs/api/interfaces/SignalProtocolClientSyncDeleteInput.md +0 -19
- package/docs/api/interfaces/SignalProtocolConfig.md +0 -50
- package/docs/api/interfaces/SignalProtocolContentAdapter.md +0 -325
- package/docs/api/interfaces/SignalProtocolRemoteObjectStore.md +0 -88
- package/docs/api/interfaces/SkippedSenderMessageKey.md +0 -26
- package/docs/api/interfaces/TaskNotificationAckSyncInput.md +0 -31
- package/docs/api/interfaces/TripleRatchetState.md +0 -64
- package/docs/api/interfaces/UserRecord.md +0 -71
- package/docs/api/interfaces/UsernameStateSyncInput.md +0 -19
- package/docs/api/interfaces/VerificationStateSyncInput.md +0 -31
- package/docs/api/interfaces/VersionNegotiationState.md +0 -84
- package/docs/api/interfaces/ViewOnceOpenSyncInput.md +0 -19
- package/docs/api/namespaces/ProtocolAddress/README.md +0 -33
- package/docs/api/namespaces/ProtocolAddress/functions/create.md +0 -41
- package/docs/api/namespaces/ProtocolAddress/functions/equals.md +0 -39
- package/docs/api/namespaces/ProtocolAddress/functions/fromStorageKey.md +0 -36
- package/docs/api/namespaces/ProtocolAddress/functions/isUser.md +0 -39
- package/docs/api/namespaces/ProtocolAddress/functions/isValid.md +0 -34
- package/docs/api/namespaces/ProtocolAddress/functions/parse.md +0 -41
- package/docs/api/namespaces/ProtocolAddress/functions/toStorageKey.md +0 -38
- package/docs/api/namespaces/ProtocolAddress/functions/toString.md +0 -34
- package/docs/api/namespaces/SessionRecord/README.md +0 -30
- package/docs/api/namespaces/SessionRecord/functions/archiveCurrent.md +0 -40
- package/docs/api/namespaces/SessionRecord/functions/archiveCurrentState.md +0 -34
- package/docs/api/namespaces/SessionRecord/functions/create.md +0 -25
- package/docs/api/namespaces/SessionRecord/functions/deserialize.md +0 -29
- package/docs/api/namespaces/SessionRecord/functions/findSession.md +0 -34
- package/docs/api/namespaces/SessionRecord/functions/getAllSessions.md +0 -25
- package/docs/api/namespaces/SessionRecord/functions/getArchivedCount.md +0 -25
- package/docs/api/namespaces/SessionRecord/functions/hasCurrentSession.md +0 -25
- package/docs/api/namespaces/SessionRecord/functions/hasUsableSenderChain.md +0 -36
- package/docs/api/namespaces/SessionRecord/functions/promoteSession.md +0 -34
- package/docs/api/namespaces/SessionRecord/functions/serialize.md +0 -28
- package/docs/api/namespaces/SessionRecord/variables/MAX_ARCHIVED_SESSIONS.md +0 -14
- package/docs/api/namespaces/SessionState/README.md +0 -15
- package/docs/api/namespaces/SessionState/functions/getSessionId.md +0 -32
- package/docs/api/namespaces/blocking/README.md +0 -43
- package/docs/api/namespaces/encoding/README.md +0 -33
- package/docs/api/namespaces/encoding/functions/base64ToUrlSafe.md +0 -28
- package/docs/api/namespaces/encoding/functions/bytesToBase64.md +0 -21
- package/docs/api/namespaces/encoding/functions/bytesToString.md +0 -21
- package/docs/api/namespaces/encoding/functions/bytesToUrlSafeBase64.md +0 -33
- package/docs/api/namespaces/encoding/functions/concatBytes.md +0 -21
- package/docs/api/namespaces/encoding/functions/stringToBytes.md +0 -21
- package/docs/api/namespaces/encoding/functions/urlSafeToBase64.md +0 -27
- package/docs/api/namespaces/keys/README.md +0 -130
- package/docs/api/namespaces/keys/functions/acceptContactIdentityRotation.md +0 -33
- package/docs/api/namespaces/keys/functions/assertIdentityCommitment.md +0 -25
- package/docs/api/namespaces/keys/functions/canonicalizeDeviceIdentityKey.md +0 -30
- package/docs/api/namespaces/keys/functions/compareDeviceIdentityKeys.md +0 -28
- package/docs/api/namespaces/keys/functions/compositeIdentitiesEqual.md +0 -23
- package/docs/api/namespaces/keys/functions/createCompositeIdentityV1.md +0 -19
- package/docs/api/namespaces/keys/functions/createPreKeySignatureContext.md +0 -31
- package/docs/api/namespaces/keys/functions/createUnverifiedContactIdentityRecord.md +0 -23
- package/docs/api/namespaces/keys/functions/decodeCompositeIdentityV1.md +0 -19
- package/docs/api/namespaces/keys/functions/deriveIdentityCommitment.md +0 -19
- package/docs/api/namespaces/keys/functions/encodeCompositeIdentityV1.md +0 -19
- package/docs/api/namespaces/keys/functions/evaluateContactIdentityCandidate.md +0 -27
- package/docs/api/namespaces/keys/functions/generateEcOneTimePreKeys.md +0 -37
- package/docs/api/namespaces/keys/functions/generateEcSignedPreKey.md +0 -39
- package/docs/api/namespaces/keys/functions/generateEcSignedPreKeyId.md +0 -21
- package/docs/api/namespaces/keys/functions/generateIdentityKeyPair.md +0 -24
- package/docs/api/namespaces/keys/functions/generateKemOneTimePreKeys.md +0 -47
- package/docs/api/namespaces/keys/functions/generateKyberLastResortPreKey.md +0 -37
- package/docs/api/namespaces/keys/functions/generateRegistrationId.md +0 -13
- package/docs/api/namespaces/keys/functions/isValidDeviceIdentityKey.md +0 -22
- package/docs/api/namespaces/keys/functions/signMlKem1024PreKey.md +0 -29
- package/docs/api/namespaces/keys/functions/signPreKey.md +0 -31
- package/docs/api/namespaces/keys/functions/validateContactIdentityRecord.md +0 -19
- package/docs/api/namespaces/keys/functions/verifyContactIdentityRecord.md +0 -31
- package/docs/api/namespaces/keys/functions/verifyMlKem1024PreKey.md +0 -33
- package/docs/api/namespaces/keys/functions/verifyPreKeySignature.md +0 -35
- package/docs/api/namespaces/keys/interfaces/CompositeIdentityV1.md +0 -33
- package/docs/api/namespaces/keys/interfaces/ContactIdentityRecord.md +0 -53
- package/docs/api/namespaces/keys/interfaces/KemOneTimePreKey.md +0 -43
- package/docs/api/namespaces/keys/type-aliases/IdentityCandidateStatus.md +0 -9
- package/docs/api/namespaces/keys/type-aliases/IdentityTrustState.md +0 -9
- package/docs/api/namespaces/keys/type-aliases/IdentityType.md +0 -9
- package/docs/api/namespaces/keys/variables/COMPOSITE_IDENTITY_V1_ED25519_TAG.md +0 -9
- package/docs/api/namespaces/keys/variables/COMPOSITE_IDENTITY_V1_LENGTH.md +0 -9
- package/docs/api/namespaces/keys/variables/COMPOSITE_IDENTITY_V1_VERSION.md +0 -9
- package/docs/api/namespaces/keys/variables/COMPOSITE_IDENTITY_V1_X25519_TAG.md +0 -9
- package/docs/api/namespaces/keys/variables/IDENTITY_COMMITMENT_V1_DOMAIN.md +0 -9
- package/docs/api/namespaces/keys/variables/PREKEY_ALGORITHM_ML_KEM_1024.md +0 -9
- package/docs/api/namespaces/keys/variables/PREKEY_ALGORITHM_X25519.md +0 -9
- package/docs/api/namespaces/keys/variables/PREKEY_SIGNATURE_V1_DOMAIN.md +0 -9
- package/docs/api/namespaces/keys/variables/UNPINNED_DEVICE_IDENTITY_KEY.md +0 -18
- package/docs/api/namespaces/media/README.md +0 -105
- package/docs/api/namespaces/media/classes/MediaAttachmentError.md +0 -57
- package/docs/api/namespaces/media/functions/createByteRangeMediaAttachmentTransfer.md +0 -19
- package/docs/api/namespaces/media/functions/createMediaAttachmentDeliveryId.md +0 -29
- package/docs/api/namespaces/media/functions/createMediaAttachmentId.md +0 -19
- package/docs/api/namespaces/media/functions/createMediaAttachmentMessage.md +0 -25
- package/docs/api/namespaces/media/functions/createMediaAttachmentPointer.md +0 -19
- package/docs/api/namespaces/media/functions/createTusMediaAttachmentTransfer.md +0 -19
- package/docs/api/namespaces/media/functions/deleteMediaAttachment.md +0 -23
- package/docs/api/namespaces/media/functions/executeMediaAttachmentJob.md +0 -23
- package/docs/api/namespaces/media/functions/isMediaAttachmentFlagSet.md +0 -19
- package/docs/api/namespaces/media/functions/parseMediaAttachmentMessage.md +0 -19
- package/docs/api/namespaces/media/functions/planMediaAttachmentCleanup.md +0 -23
- package/docs/api/namespaces/media/functions/planMediaAttachmentCleanupJobs.md +0 -19
- package/docs/api/namespaces/media/functions/planMediaAttachmentDeleteSync.md +0 -19
- package/docs/api/namespaces/media/functions/planMediaAttachmentDownloadJob.md +0 -19
- package/docs/api/namespaces/media/functions/planMediaAttachmentOpen.md +0 -19
- package/docs/api/namespaces/media/functions/planMediaAttachmentProcessing.md +0 -19
- package/docs/api/namespaces/media/functions/planMediaAttachmentUploadJob.md +0 -19
- package/docs/api/namespaces/media/functions/prepareMediaAttachmentUpload.md +0 -30
- package/docs/api/namespaces/media/functions/resolveMediaAttachment.md +0 -30
- package/docs/api/namespaces/media/functions/serializeMediaAttachmentMessage.md +0 -25
- package/docs/api/namespaces/media/functions/validateMediaAttachmentPolicy.md +0 -23
- package/docs/api/namespaces/media/interfaces/ByteRangeMediaAttachmentPartialStore.md +0 -68
- package/docs/api/namespaces/media/interfaces/ByteRangeMediaAttachmentTransferOptions.md +0 -91
- package/docs/api/namespaces/media/interfaces/DeleteMediaAttachmentOptions.md +0 -25
- package/docs/api/namespaces/media/interfaces/DeleteMediaAttachmentResult.md +0 -19
- package/docs/api/namespaces/media/interfaces/ExecuteMediaAttachmentJobOptions.md +0 -157
- package/docs/api/namespaces/media/interfaces/MediaAttachmentBackgroundJob.md +0 -85
- package/docs/api/namespaces/media/interfaces/MediaAttachmentCleanupPlan.md +0 -37
- package/docs/api/namespaces/media/interfaces/MediaAttachmentJobExecutionResult.md +0 -55
- package/docs/api/namespaces/media/interfaces/MediaAttachmentMessage.md +0 -31
- package/docs/api/namespaces/media/interfaces/MediaAttachmentOpenDecision.md +0 -31
- package/docs/api/namespaces/media/interfaces/MediaAttachmentPointer.md +0 -133
- package/docs/api/namespaces/media/interfaces/MediaAttachmentPolicy.md +0 -67
- package/docs/api/namespaces/media/interfaces/MediaAttachmentProcessingPlan.md +0 -73
- package/docs/api/namespaces/media/interfaces/MediaAttachmentProgress.md +0 -69
- package/docs/api/namespaces/media/interfaces/MediaAttachmentResumeState.md +0 -37
- package/docs/api/namespaces/media/interfaces/MediaAttachmentRetryOptions.md +0 -31
- package/docs/api/namespaces/media/interfaces/MediaAttachmentTransfer.md +0 -51
- package/docs/api/namespaces/media/interfaces/MediaAttachmentTransferCheckpoint.md +0 -69
- package/docs/api/namespaces/media/interfaces/MediaAttachmentTransferOptions.md +0 -67
- package/docs/api/namespaces/media/interfaces/MediaAttachmentUploadJobData.md +0 -19
- package/docs/api/namespaces/media/interfaces/MediaAttachmentUploadResponse.md +0 -25
- package/docs/api/namespaces/media/interfaces/PlanMediaAttachmentCleanupJobsInput.md +0 -61
- package/docs/api/namespaces/media/interfaces/PlanMediaAttachmentDeleteSyncInput.md +0 -25
- package/docs/api/namespaces/media/interfaces/PlanMediaAttachmentDownloadJobInput.md +0 -161
- package/docs/api/namespaces/media/interfaces/PlanMediaAttachmentOpenInput.md +0 -25
- package/docs/api/namespaces/media/interfaces/PlanMediaAttachmentProcessingInput.md +0 -83
- package/docs/api/namespaces/media/interfaces/PlanMediaAttachmentUploadJobInput.md +0 -147
- package/docs/api/namespaces/media/interfaces/PrepareMediaAttachmentUploadOptions.md +0 -144
- package/docs/api/namespaces/media/interfaces/ResolveMediaAttachmentOptions.md +0 -55
- package/docs/api/namespaces/media/interfaces/ResolvedMediaAttachment.md +0 -109
- package/docs/api/namespaces/media/interfaces/TusMediaAttachmentTransferOptions.md +0 -85
- package/docs/api/namespaces/media/type-aliases/CreateMediaAttachmentPointerInput.md +0 -15
- package/docs/api/namespaces/media/type-aliases/MediaAttachmentCheckpointCallback.md +0 -19
- package/docs/api/namespaces/media/type-aliases/MediaAttachmentCleanupReason.md +0 -9
- package/docs/api/namespaces/media/type-aliases/MediaAttachmentErrorCode.md +0 -9
- package/docs/api/namespaces/media/type-aliases/MediaAttachmentFlag.md +0 -9
- package/docs/api/namespaces/media/type-aliases/MediaAttachmentJobExecutionStatus.md +0 -9
- package/docs/api/namespaces/media/type-aliases/MediaAttachmentJobOperation.md +0 -9
- package/docs/api/namespaces/media/type-aliases/MediaAttachmentJobPriority.md +0 -9
- package/docs/api/namespaces/media/type-aliases/MediaAttachmentJobSkipReason.md +0 -9
- package/docs/api/namespaces/media/type-aliases/MediaAttachmentJobSource.md +0 -9
- package/docs/api/namespaces/media/type-aliases/MediaAttachmentKnownIds.md +0 -9
- package/docs/api/namespaces/media/type-aliases/MediaAttachmentMessageType.md +0 -9
- package/docs/api/namespaces/media/type-aliases/MediaAttachmentProgressCallback.md +0 -19
- package/docs/api/namespaces/media/variables/MEDIA_ATTACHMENT_POLICY_DEFAULTS.md +0 -47
- package/docs/api/namespaces/media/variables/MEDIA_ATTACHMENT_POLICY_PRESETS.md +0 -95
- package/docs/api/namespaces/media/variables/MediaAttachmentCleanupReason.md +0 -27
- package/docs/api/namespaces/media/variables/MediaAttachmentErrorCode.md +0 -75
- package/docs/api/namespaces/media/variables/MediaAttachmentFlag.md +0 -23
- package/docs/api/namespaces/media/variables/MediaAttachmentJobExecutionStatus.md +0 -19
- package/docs/api/namespaces/media/variables/MediaAttachmentJobOperation.md +0 -31
- package/docs/api/namespaces/media/variables/MediaAttachmentJobPriority.md +0 -23
- package/docs/api/namespaces/media/variables/MediaAttachmentJobSource.md +0 -51
- package/docs/api/namespaces/media/variables/MediaAttachmentMessageType.md +0 -15
- package/docs/api/namespaces/media/variables/downloadMediaAttachment.md +0 -30
- package/docs/api/namespaces/safety/README.md +0 -61
- package/docs/api/namespaces/safety/classes/DisplayableFingerprint.md +0 -108
- package/docs/api/namespaces/safety/classes/Fingerprint.md +0 -104
- package/docs/api/namespaces/safety/classes/ScannableFingerprint.md +0 -209
- package/docs/api/namespaces/safety/functions/base64ToBytes.md +0 -21
- package/docs/api/namespaces/safety/functions/clearFingerprintCache.md +0 -15
- package/docs/api/namespaces/safety/functions/compareSafetyNumbers.md +0 -25
- package/docs/api/namespaces/safety/functions/createFingerprintData.md +0 -60
- package/docs/api/namespaces/safety/functions/extractQrData.md +0 -34
- package/docs/api/namespaces/safety/functions/generateCompositeSafetyNumber.md +0 -39
- package/docs/api/namespaces/safety/functions/generateEmojiFingerprint.md +0 -24
- package/docs/api/namespaces/safety/functions/generateSingleKeyReferenceSafetyNumber.md +0 -51
- package/docs/api/namespaces/safety/functions/generateVerifySchemeUrl.md +0 -32
- package/docs/api/namespaces/safety/functions/generateVerifyUrl.md +0 -49
- package/docs/api/namespaces/safety/functions/isValidSafetyNumber.md +0 -21
- package/docs/api/namespaces/safety/functions/isVerifyUrl.md +0 -45
- package/docs/api/namespaces/safety/functions/parseVerifyUrl.md +0 -31
- package/docs/api/namespaces/safety/interfaces/FingerprintData.md +0 -52
- package/docs/api/namespaces/safety/interfaces/SafetyNumber.md +0 -49
- package/docs/api/namespaces/safety/interfaces/VerifyLinkConfig.md +0 -28
- package/docs/api/namespaces/safety/interfaces/VerifyUrlParams.md +0 -49
- package/docs/api/namespaces/safety/type-aliases/CompareResult.md +0 -21
- package/docs/api/namespaces/safety/variables/DEFAULT_VERIFY_LINK_CONFIG.md +0 -12
- package/docs/api/namespaces/safety/variables/FINGERPRINT_ITERATIONS.md +0 -12
- package/docs/api/namespaces/safety/variables/FINGERPRINT_VERSION.md +0 -12
- package/docs/api/namespaces/safety/variables/VERIFY_BASE_URL.md +0 -11
- package/docs/api/namespaces/safety/variables/VERIFY_SCHEME_URL.md +0 -11
- package/docs/api/type-aliases/Base64.md +0 -20
- package/docs/api/type-aliases/BraidPolicy.md +0 -11
- package/docs/api/type-aliases/Bytes.md +0 -20
- package/docs/api/type-aliases/Ciphertext.md +0 -21
- package/docs/api/type-aliases/DeviceType.md +0 -11
- package/docs/api/type-aliases/DownloadedAttachment.md +0 -11
- package/docs/api/type-aliases/GroupId.md +0 -27
- package/docs/api/type-aliases/Hex.md +0 -20
- package/docs/api/type-aliases/HookName.md +0 -11
- package/docs/api/type-aliases/PostQuantumPolicy.md +0 -11
- package/docs/api/type-aliases/PreparedAttachmentUpload.md +0 -14
- package/docs/api/type-aliases/PrivateKey.md +0 -22
- package/docs/api/type-aliases/ProgressCallback.md +0 -45
- package/docs/api/type-aliases/PublicKey.md +0 -22
- package/docs/api/type-aliases/RemoteObjectCompleteUploadRequest.md +0 -19
- package/docs/api/type-aliases/RemoteObjectDeleteRequest.md +0 -19
- package/docs/api/type-aliases/RemoteObjectDownloadRequest.md +0 -19
- package/docs/api/type-aliases/RemoteObjectUploadRequest.md +0 -42
- package/docs/api/type-aliases/SCKAMode.md +0 -11
- package/docs/api/type-aliases/SealedSenderAuth.md +0 -15
- package/docs/api/type-aliases/SignalProtocolClientMediaCleanupInput.md +0 -9
- package/docs/api/type-aliases/SignalProtocolClientMediaCleanupResult.md +0 -9
- package/docs/api/type-aliases/SignalProtocolClientMediaDownloadInput.md +0 -9
- package/docs/api/type-aliases/SignalProtocolClientMediaDownloadResult.md +0 -9
- package/docs/api/type-aliases/SignalProtocolClientMediaOperationResult.md +0 -9
- package/docs/api/type-aliases/SignalProtocolClientMediaUploadInput.md +0 -9
- package/docs/api/type-aliases/SignalProtocolClientMediaUploadResult.md +0 -9
- package/docs/api/type-aliases/Signature.md +0 -21
- package/docs/api/type-aliases/Unsubscribe.md +0 -15
- package/docs/api/variables/BraidPolicy.md +0 -21
- package/docs/api/variables/DEFAULT_DEVICE_ID.md +0 -12
- package/docs/api/variables/DOUBLE_RATCHET_SPEC.md +0 -11
- package/docs/api/variables/GROUP_ID_PREFIX.md +0 -11
- package/docs/api/variables/GROUP_TRUST_ROOT_VERSION.md +0 -11
- package/docs/api/variables/KEY_REFRESH_INTERVAL_MS_DEFAULT.md +0 -11
- package/docs/api/variables/MAX_MESSAGE_KEYS.md +0 -14
- package/docs/api/variables/MAX_PREKEY_AGE_MS_DEFAULT.md +0 -11
- package/docs/api/variables/MAX_RECEIVER_CHAINS.md +0 -14
- package/docs/api/variables/MAX_REGISTRATION_ID.md +0 -16
- package/docs/api/variables/MAX_SKIP.md +0 -11
- package/docs/api/variables/MESSAGE_FORMAT.md +0 -11
- package/docs/api/variables/MIN_REGISTRATION_ID.md +0 -16
- package/docs/api/variables/ML_KEM_BRAID_SPEC.md +0 -11
- package/docs/api/variables/ONE_TIME_PREKEY_BATCH_SIZE.md +0 -21
- package/docs/api/variables/PQXDH_SPEC.md +0 -11
- package/docs/api/variables/PostQuantumPolicy.md +0 -21
- package/docs/api/variables/SENDER_KEY_FORMAT.md +0 -11
- package/docs/api/variables/SENDER_KEY_SPEC.md +0 -11
- package/docs/api/variables/SESAME_SPEC.md +0 -11
- package/docs/api/variables/SESSION_FORMAT.md +0 -11
- package/docs/api/variables/SPQR_LIMITS_DEFAULTS.md +0 -11
- package/docs/api/variables/X3DH_SPEC.md +0 -9
- package/docs/api/variables/defaultSignalProtocolLogger.md +0 -32
- package/remote/relay/convex/server/README.md +0 -146
|
@@ -0,0 +1,649 @@
|
|
|
1
|
+
import { MINUTE, RateLimiter, isRateLimitError, } from '@convex-dev/rate-limiter';
|
|
2
|
+
import { ConvexError, v } from 'convex/values';
|
|
3
|
+
import { base64ToBytes, bytesToBase64, } from '../../../../internal/crypto/utils.js';
|
|
4
|
+
import { MAX_DEVICES } from '../../../../device/constants.js';
|
|
5
|
+
import { serializeReceivedMessage } from '../../../../internal/protocol/sealed-sender/v2-binary.js';
|
|
6
|
+
import { asBase64 } from '../../../../types/utils.js';
|
|
7
|
+
import { components } from './_generated/api.js';
|
|
8
|
+
import { mutation, query } from './_generated/server.js';
|
|
9
|
+
import { authorizeAccessKey, authorizeGroupSendToken, callerIdentityArgs, rememberAccount, } from './accounts.js';
|
|
10
|
+
import { relayError, unauthorized } from './errors.js';
|
|
11
|
+
const MESSAGE_TTL_MS = 7 * 24 * 60 * 60 * 1000;
|
|
12
|
+
const MAX_PENDING_MESSAGES = 1000;
|
|
13
|
+
const MAX_PENDING_RETRY_REQUESTS = 1000;
|
|
14
|
+
const MAX_MULTI_RECIPIENT_DEVICES = 1000;
|
|
15
|
+
/**
|
|
16
|
+
* Ceiling on a single message's content, before base64 framing.
|
|
17
|
+
*
|
|
18
|
+
* 96 KiB for a single-recipient envelope and 256 KiB for the shared
|
|
19
|
+
* multi-recipient payload, matching the reference implementation's bounds.
|
|
20
|
+
* The columns are base64 strings, so the byte ceilings are enforced as
|
|
21
|
+
* string-length ceilings: base64 emits 4 characters per started group of 3
|
|
22
|
+
* bytes, which is 4 * ceil(n / 3) — the ceiling belongs inside the division,
|
|
23
|
+
* or a payload whose size is not a multiple of 3 encodes 2 characters past
|
|
24
|
+
* the advertised limit and full-size messages are refused.
|
|
25
|
+
*/
|
|
26
|
+
const base64LengthOf = (byteLength) => 4 * Math.ceil(byteLength / 3);
|
|
27
|
+
const MAX_MESSAGE_BYTES = 96 * 1024;
|
|
28
|
+
const MAX_MULTI_RECIPIENT_MESSAGE_BYTES = 256 * 1024;
|
|
29
|
+
const MAX_CIPHERTEXT_LENGTH = base64LengthOf(MAX_MESSAGE_BYTES);
|
|
30
|
+
const MAX_MULTI_RECIPIENT_CIPHERTEXT_LENGTH = base64LengthOf(MAX_MULTI_RECIPIENT_MESSAGE_BYTES);
|
|
31
|
+
/**
|
|
32
|
+
* Inbound budget per recipient, spent in ciphertext bytes.
|
|
33
|
+
*
|
|
34
|
+
* Keyed by the *target*, because that is the only stable identity on these
|
|
35
|
+
* paths: a sealed sender is anonymous by design, so any per-sender limit is
|
|
36
|
+
* either meaningless or a hole. The reference implementation bounds inbound
|
|
37
|
+
* message bytes per destination the same way, on its identified and sealed
|
|
38
|
+
* single-recipient paths alike.
|
|
39
|
+
*
|
|
40
|
+
* What this closes is unbounded queue flooding: without it, one anonymous
|
|
41
|
+
* caller holding a valid access key — or any account-authenticated caller on
|
|
42
|
+
* the identified path — can grow a victim's `messages` table without limit
|
|
43
|
+
* for the whole retention window. The budget is generous for real traffic
|
|
44
|
+
* (sealed envelopes run 1-2 KiB, so the sustained rate is hundreds of
|
|
45
|
+
* messages a minute per recipient) and fatal for floods.
|
|
46
|
+
*
|
|
47
|
+
* The multi-recipient path is deliberately not metered, matching the
|
|
48
|
+
* reference: a group-send token already prices that path, and a per-recipient
|
|
49
|
+
* budget there would let one noisy group partially starve delivery to its
|
|
50
|
+
* quietest member. Verified against the reference's MessageController: its
|
|
51
|
+
* inbound-bytes limiter is validated only in `sendIndividualMessage`, never
|
|
52
|
+
* on the multi-recipient route. Metering here would also have to fail the
|
|
53
|
+
* whole fan-out rather than one recipient, since the charge and the inserts
|
|
54
|
+
* share a transaction — so a single recipient at their ceiling would block
|
|
55
|
+
* delivery to everyone else in the call.
|
|
56
|
+
*
|
|
57
|
+
* What the exemption assumes is that one call fans out to distinct devices.
|
|
58
|
+
* The reference gets that from its wire format, which parses recipients into
|
|
59
|
+
* a map keyed by service ID; the flat array here does not, so the handler
|
|
60
|
+
* rejects a repeated device explicitly.
|
|
61
|
+
*/
|
|
62
|
+
const rateLimiter = new RateLimiter(components.rateLimiter, {
|
|
63
|
+
inboundMessageBytes: {
|
|
64
|
+
kind: 'token bucket',
|
|
65
|
+
rate: 1024 * 1024,
|
|
66
|
+
period: MINUTE,
|
|
67
|
+
capacity: 4 * 1024 * 1024,
|
|
68
|
+
},
|
|
69
|
+
// Sub-limit for the identified path, keyed by (sender, target). The
|
|
70
|
+
// shared per-target bucket is forced on the sealed path — there is no
|
|
71
|
+
// sender identity to key on — but on the identified path there is one,
|
|
72
|
+
// and without this a single authenticated account could drain a victim's
|
|
73
|
+
// whole shared budget and 429 every other sender indefinitely. A quarter
|
|
74
|
+
// of the shared bucket keeps one sender from monopolizing it while
|
|
75
|
+
// leaving any real conversation far below the ceiling.
|
|
76
|
+
inboundMessageBytesPerSender: {
|
|
77
|
+
kind: 'token bucket',
|
|
78
|
+
rate: 256 * 1024,
|
|
79
|
+
period: MINUTE,
|
|
80
|
+
capacity: 1024 * 1024,
|
|
81
|
+
},
|
|
82
|
+
// Counted, not metered by size: a retry request is a fixed-shape row. A
|
|
83
|
+
// client coming back from a broken session legitimately asks for one per
|
|
84
|
+
// message it could not decrypt, so the burst allowance is generous; what
|
|
85
|
+
// it refuses is a caller that keeps asking indefinitely.
|
|
86
|
+
retryRequests: {
|
|
87
|
+
kind: 'token bucket',
|
|
88
|
+
rate: 120,
|
|
89
|
+
period: MINUTE,
|
|
90
|
+
capacity: 240,
|
|
91
|
+
},
|
|
92
|
+
});
|
|
93
|
+
/** Approximate decoded size of a base64 column, for budget accounting. */
|
|
94
|
+
function ciphertextBytes(encoded) {
|
|
95
|
+
return Math.floor((encoded.length * 3) / 4);
|
|
96
|
+
}
|
|
97
|
+
function requireCiphertextWithin(encoded, maxLength) {
|
|
98
|
+
if (encoded.length > maxLength) {
|
|
99
|
+
throw relayError('INVALID_REQUEST', 413, 'Message content exceeds the maximum size');
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Re-throw a limiter rejection as a 429, or pass anything else through.
|
|
104
|
+
*
|
|
105
|
+
* The component's limiter writes inside the caller's transaction, so this
|
|
106
|
+
* only ever shapes the error — the charges themselves are undone by the
|
|
107
|
+
* throw, whichever limit produced it.
|
|
108
|
+
*/
|
|
109
|
+
function rethrowRateLimited(error, message) {
|
|
110
|
+
if (isRateLimitError(error)) {
|
|
111
|
+
throw relayError('RATE_LIMITED', 429, message, {
|
|
112
|
+
retryAfter: error.data.retryAfter,
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
if (error instanceof ConvexError) {
|
|
116
|
+
const data = error.data;
|
|
117
|
+
if (data.kind === 'RateLimited') {
|
|
118
|
+
throw relayError('RATE_LIMITED', 429, message, {
|
|
119
|
+
retryAfter: typeof data.retryAfter === 'number' ? data.retryAfter : undefined,
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
throw error;
|
|
124
|
+
}
|
|
125
|
+
async function chargeInboundBudget(ctx, targetUserId, bytes, senderUserId) {
|
|
126
|
+
try {
|
|
127
|
+
// Order between the two buckets carries no meaning: both charges are
|
|
128
|
+
// written in this mutation's transaction, so whichever limit throws
|
|
129
|
+
// discards the other's spend along with everything else. The sub-limit
|
|
130
|
+
// runs first only because it is the more specific diagnosis of the two.
|
|
131
|
+
if (senderUserId !== undefined) {
|
|
132
|
+
await rateLimiter.limit(ctx, 'inboundMessageBytesPerSender', {
|
|
133
|
+
key: JSON.stringify([senderUserId, targetUserId]),
|
|
134
|
+
count: bytes,
|
|
135
|
+
throws: true,
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
await rateLimiter.limit(ctx, 'inboundMessageBytes', {
|
|
139
|
+
key: targetUserId,
|
|
140
|
+
count: bytes,
|
|
141
|
+
throws: true,
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
catch (error) {
|
|
145
|
+
rethrowRateLimited(error, 'Inbound message rate limit exceeded for this recipient');
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Bound how fast one account can create retry-request rows.
|
|
150
|
+
*
|
|
151
|
+
* These rows carry no caller-supplied content, so there is nothing to bound
|
|
152
|
+
* by size — the cost is the row itself, held for the full retention window.
|
|
153
|
+
* Nothing else on this path constrains them: the request names an original
|
|
154
|
+
* sender it never has to have talked to, so there is no relationship to
|
|
155
|
+
* check either.
|
|
156
|
+
*/
|
|
157
|
+
async function chargeRetryRequest(ctx, requesterUserId) {
|
|
158
|
+
try {
|
|
159
|
+
await rateLimiter.limit(ctx, 'retryRequests', {
|
|
160
|
+
key: requesterUserId,
|
|
161
|
+
throws: true,
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
catch (error) {
|
|
165
|
+
rethrowRateLimited(error, 'Retry-request rate limit exceeded');
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Reject a sealed single-recipient send whose target device does not exist.
|
|
170
|
+
*
|
|
171
|
+
* The multi-recipient path already reports unknown devices through
|
|
172
|
+
* `uuids404`, and the reference implementation refuses sealed sends to
|
|
173
|
+
* unknown destinations outright. Without this check the path is a write
|
|
174
|
+
* primitive for rows nothing will ever read: an anonymous caller can address
|
|
175
|
+
* arbitrary device IDs and every insert sits in the table for the full
|
|
176
|
+
* retention window.
|
|
177
|
+
*/
|
|
178
|
+
async function requireActiveDevice(ctx, userId, deviceId) {
|
|
179
|
+
const device = await ctx.db
|
|
180
|
+
.query('devices')
|
|
181
|
+
.withIndex('by_user_id_and_device_id', (q) => q.eq('userId', userId).eq('deviceId', deviceId))
|
|
182
|
+
.unique();
|
|
183
|
+
if (!device?.registered || !device.enabled) {
|
|
184
|
+
throw relayError('NOT_FOUND', 404, 'Unknown destination device');
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
const messageTypeValidator = v.union(v.literal('ciphertext'), v.literal('prekey_bundle'), v.literal('sender_key'), v.literal('server_delivery_receipt'), v.literal('unidentified_sender'));
|
|
188
|
+
const receiptValidator = v.object({
|
|
189
|
+
messageId: v.string(),
|
|
190
|
+
serverTimestamp: v.number(),
|
|
191
|
+
});
|
|
192
|
+
const pendingMessageValidator = v.object({
|
|
193
|
+
id: v.string(),
|
|
194
|
+
targetUserId: v.string(),
|
|
195
|
+
targetDeviceId: v.number(),
|
|
196
|
+
senderUserId: v.string(),
|
|
197
|
+
senderDeviceId: v.number(),
|
|
198
|
+
ciphertext: v.string(),
|
|
199
|
+
messageType: messageTypeValidator,
|
|
200
|
+
urgent: v.optional(v.boolean()),
|
|
201
|
+
ephemeral: v.optional(v.boolean()),
|
|
202
|
+
timestamp: v.number(),
|
|
203
|
+
serverTimestamp: v.number(),
|
|
204
|
+
clientMessageId: v.optional(v.string()),
|
|
205
|
+
expiresAt: v.number(),
|
|
206
|
+
});
|
|
207
|
+
const retryReasonValidator = v.union(v.literal('NO_SESSION'), v.literal('DECRYPTION_FAILED'), v.literal('SESSION_EXPIRED'), v.literal('INVALID_MESSAGE'), v.literal('STALE_DEVICE_LIST'), v.literal('IDENTITY_KEY_MISMATCH'));
|
|
208
|
+
async function insertMessage(ctx, input) {
|
|
209
|
+
if (input.clientMessageId !== undefined) {
|
|
210
|
+
const existing = await ctx.db
|
|
211
|
+
.query('messages')
|
|
212
|
+
.withIndex('by_target_and_client_message_id', (q) => q
|
|
213
|
+
.eq('targetUserId', input.targetUserId)
|
|
214
|
+
.eq('targetDeviceId', input.targetDeviceId)
|
|
215
|
+
.eq('senderUserId', input.senderUserId)
|
|
216
|
+
.eq('clientMessageId', input.clientMessageId))
|
|
217
|
+
.unique();
|
|
218
|
+
if (existing) {
|
|
219
|
+
return {
|
|
220
|
+
messageId: existing.messageId,
|
|
221
|
+
serverTimestamp: existing.serverTimestamp,
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
const serverTimestamp = Date.now();
|
|
226
|
+
const messageId = crypto.randomUUID();
|
|
227
|
+
await ctx.db.insert('messages', {
|
|
228
|
+
...input,
|
|
229
|
+
messageId,
|
|
230
|
+
serverTimestamp,
|
|
231
|
+
expiresAt: serverTimestamp + MESSAGE_TTL_MS,
|
|
232
|
+
});
|
|
233
|
+
return { messageId, serverTimestamp };
|
|
234
|
+
}
|
|
235
|
+
export const send = mutation({
|
|
236
|
+
args: {
|
|
237
|
+
...callerIdentityArgs,
|
|
238
|
+
targetUserId: v.string(),
|
|
239
|
+
targetDeviceId: v.number(),
|
|
240
|
+
senderDeviceId: v.number(),
|
|
241
|
+
ciphertext: v.string(),
|
|
242
|
+
messageType: messageTypeValidator,
|
|
243
|
+
urgent: v.optional(v.boolean()),
|
|
244
|
+
ephemeral: v.optional(v.boolean()),
|
|
245
|
+
timestamp: v.number(),
|
|
246
|
+
clientMessageId: v.optional(v.string()),
|
|
247
|
+
recipientRegistrationId: v.optional(v.number()),
|
|
248
|
+
},
|
|
249
|
+
returns: receiptValidator,
|
|
250
|
+
handler: async (ctx, input) => {
|
|
251
|
+
await rememberAccount(ctx, input);
|
|
252
|
+
requireCiphertextWithin(input.ciphertext, MAX_CIPHERTEXT_LENGTH);
|
|
253
|
+
if (input.recipientRegistrationId !== undefined) {
|
|
254
|
+
const registration = await ctx.db
|
|
255
|
+
.query('identityRegistrations')
|
|
256
|
+
.withIndex('by_user_id_and_device_id_and_identity_type', (q) => q
|
|
257
|
+
.eq('userId', input.targetUserId)
|
|
258
|
+
.eq('deviceId', input.targetDeviceId)
|
|
259
|
+
.eq('identityType', 'aci'))
|
|
260
|
+
.unique();
|
|
261
|
+
if (registration &&
|
|
262
|
+
registration.registrationId !== input.recipientRegistrationId) {
|
|
263
|
+
// Names only the stale device, matching the reference's 410 body.
|
|
264
|
+
// The current registration ID stays out: the sender re-fetches the
|
|
265
|
+
// prekey bundle to recover, and that path is rate limited, whereas
|
|
266
|
+
// this one would otherwise hand any account-authenticated caller a
|
|
267
|
+
// free oracle for registration-ID changes on arbitrary devices.
|
|
268
|
+
throw relayError('STALE_DEVICE', 410, 'Recipient device registration changed', {
|
|
269
|
+
staleDevices: [input.targetDeviceId],
|
|
270
|
+
reason: 'device_reinstalled',
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
// Placed after the registration check for readability, not for safety: a
|
|
275
|
+
// send that 410s could charge first and still cost nothing, because the
|
|
276
|
+
// throw rolls the charge back with the rest of the mutation. Nothing on
|
|
277
|
+
// this path depends on the order.
|
|
278
|
+
await chargeInboundBudget(ctx, input.targetUserId, ciphertextBytes(input.ciphertext), input.callerUserId);
|
|
279
|
+
return await insertMessage(ctx, {
|
|
280
|
+
targetUserId: input.targetUserId,
|
|
281
|
+
targetDeviceId: input.targetDeviceId,
|
|
282
|
+
senderUserId: input.callerUserId,
|
|
283
|
+
senderDeviceId: input.senderDeviceId,
|
|
284
|
+
ciphertext: input.ciphertext,
|
|
285
|
+
messageType: input.messageType,
|
|
286
|
+
urgent: input.urgent,
|
|
287
|
+
ephemeral: input.ephemeral,
|
|
288
|
+
timestamp: input.timestamp,
|
|
289
|
+
clientMessageId: input.clientMessageId,
|
|
290
|
+
});
|
|
291
|
+
},
|
|
292
|
+
});
|
|
293
|
+
export const getPendingMessages = query({
|
|
294
|
+
args: {
|
|
295
|
+
...callerIdentityArgs,
|
|
296
|
+
deviceId: v.number(),
|
|
297
|
+
},
|
|
298
|
+
returns: v.array(pendingMessageValidator),
|
|
299
|
+
handler: async (ctx, input) => {
|
|
300
|
+
// Read-time expiry filter: the hourly cron eventually deletes expired
|
|
301
|
+
// rows, but until it runs they must neither be delivered nor consume
|
|
302
|
+
// the pending-message budget.
|
|
303
|
+
//
|
|
304
|
+
// Date.now() is fixed per transaction and cached with the query result,
|
|
305
|
+
// so a subscribed client does not see a row drop out the instant it
|
|
306
|
+
// expires — only when a write to this index range invalidates the
|
|
307
|
+
// subscription, which any new message for this device or the cron's
|
|
308
|
+
// delete does. Staleness is therefore bounded by the cron interval, and
|
|
309
|
+
// the effect is a message delivered late rather than one delivered
|
|
310
|
+
// wrongly: expiresAt is a retention bound, not an authorization gate.
|
|
311
|
+
const now = Date.now();
|
|
312
|
+
const rows = (await ctx.db
|
|
313
|
+
.query('messages')
|
|
314
|
+
.withIndex('by_target_user_id_and_target_device_id', (q) => q
|
|
315
|
+
.eq('targetUserId', input.callerUserId)
|
|
316
|
+
.eq('targetDeviceId', input.deviceId))
|
|
317
|
+
.take(MAX_PENDING_MESSAGES)).filter((row) => row.expiresAt > now);
|
|
318
|
+
return rows.map(({ messageId, targetUserId, targetDeviceId, senderUserId, senderDeviceId, ciphertext, messageType, urgent, ephemeral, timestamp, serverTimestamp, clientMessageId, expiresAt, }) => ({
|
|
319
|
+
id: messageId,
|
|
320
|
+
targetUserId,
|
|
321
|
+
targetDeviceId,
|
|
322
|
+
senderUserId,
|
|
323
|
+
senderDeviceId,
|
|
324
|
+
ciphertext,
|
|
325
|
+
messageType,
|
|
326
|
+
urgent,
|
|
327
|
+
ephemeral,
|
|
328
|
+
timestamp,
|
|
329
|
+
serverTimestamp,
|
|
330
|
+
clientMessageId,
|
|
331
|
+
expiresAt,
|
|
332
|
+
}));
|
|
333
|
+
},
|
|
334
|
+
});
|
|
335
|
+
export const markDelivered = mutation({
|
|
336
|
+
args: {
|
|
337
|
+
...callerIdentityArgs,
|
|
338
|
+
messageId: v.string(),
|
|
339
|
+
},
|
|
340
|
+
returns: v.null(),
|
|
341
|
+
handler: async (ctx, input) => {
|
|
342
|
+
await rememberAccount(ctx, input);
|
|
343
|
+
const message = await ctx.db
|
|
344
|
+
.query('messages')
|
|
345
|
+
.withIndex('by_message_id', (q) => q.eq('messageId', input.messageId))
|
|
346
|
+
.unique();
|
|
347
|
+
if (!message)
|
|
348
|
+
return null;
|
|
349
|
+
if (message.targetUserId !== input.callerUserId) {
|
|
350
|
+
throw unauthorized('only the target account can mark a message delivered');
|
|
351
|
+
}
|
|
352
|
+
await ctx.db.delete(message._id);
|
|
353
|
+
return null;
|
|
354
|
+
},
|
|
355
|
+
});
|
|
356
|
+
// There is deliberately no `getGroupMembers` endpoint, and the component
|
|
357
|
+
// derives no membership map from group state: group authorization is proved
|
|
358
|
+
// entirely by zero-knowledge presentations, so `groups` rows never name an
|
|
359
|
+
// account. Membership is local-first — senders resolve fan-out recipients
|
|
360
|
+
// from their own decrypted group state and supply them to the send path.
|
|
361
|
+
//
|
|
362
|
+
// Nothing a `messages` row stores *names* a group either. The row carries a
|
|
363
|
+
// `sender_key` message type, which says the payload is group traffic without
|
|
364
|
+
// saying which group, and the distribution identifier inside the frame is
|
|
365
|
+
// opaque.
|
|
366
|
+
//
|
|
367
|
+
// That closes the group's name, not the group partition, and the difference is
|
|
368
|
+
// easy to overstate. The distribution identifier is unencrypted, sits inside
|
|
369
|
+
// the `ciphertext` column, and is stable for the life of a sender key — keys
|
|
370
|
+
// rotate on membership change, never on a timer — so grouping rows by it
|
|
371
|
+
// recovers a sender's group traffic. One send also produces byte-identical
|
|
372
|
+
// ciphertext on every recipient row, and the multi-recipient sealed path is
|
|
373
|
+
// handed the roster outright. An operator therefore sees who talked to whom
|
|
374
|
+
// and can partition those pairs into unlabeled groups; what it cannot do is
|
|
375
|
+
// put a meaningful, cross-send label on one. See the group metadata privacy
|
|
376
|
+
// note in README.md, which states the remaining channels in full.
|
|
377
|
+
export const getActiveDevices = query({
|
|
378
|
+
args: {
|
|
379
|
+
...callerIdentityArgs,
|
|
380
|
+
userId: v.string(),
|
|
381
|
+
},
|
|
382
|
+
returns: v.array(v.object({
|
|
383
|
+
userId: v.string(),
|
|
384
|
+
deviceId: v.number(),
|
|
385
|
+
})),
|
|
386
|
+
handler: async (ctx, input) => {
|
|
387
|
+
const rows = await ctx.db
|
|
388
|
+
.query('devices')
|
|
389
|
+
.withIndex('by_user_id', (q) => q.eq('userId', input.userId))
|
|
390
|
+
.take(MAX_DEVICES);
|
|
391
|
+
return rows
|
|
392
|
+
.filter((row) => row.registered && row.enabled)
|
|
393
|
+
.map((row) => ({
|
|
394
|
+
userId: input.userId,
|
|
395
|
+
deviceId: row.deviceId,
|
|
396
|
+
}));
|
|
397
|
+
},
|
|
398
|
+
});
|
|
399
|
+
async function authorizeUnidentified(ctx, recipients, auth) {
|
|
400
|
+
const hasAccessKey = auth.unidentifiedAccessKey !== undefined;
|
|
401
|
+
const hasGroupToken = auth.groupSendToken !== undefined;
|
|
402
|
+
if (hasAccessKey === hasGroupToken) {
|
|
403
|
+
throw unauthorized('exactly one sealed-sender authorization is required');
|
|
404
|
+
}
|
|
405
|
+
if (auth.groupSendToken !== undefined) {
|
|
406
|
+
// The caller names the ACI it claims for each recipient so the token —
|
|
407
|
+
// which endorses ACIs, not user IDs — can be verified before any account
|
|
408
|
+
// is read. See authorizeGroupSendToken for why that ordering matters.
|
|
409
|
+
const named = [];
|
|
410
|
+
for (const recipient of recipients) {
|
|
411
|
+
if (recipient.aciBytes === undefined) {
|
|
412
|
+
throw unauthorized('a group-send token requires an ACI for every recipient');
|
|
413
|
+
}
|
|
414
|
+
named.push({ userId: recipient.userId, aciBytes: recipient.aciBytes });
|
|
415
|
+
}
|
|
416
|
+
await authorizeGroupSendToken(ctx, named, auth.groupSendToken);
|
|
417
|
+
return;
|
|
418
|
+
}
|
|
419
|
+
const distinctRecipients = [
|
|
420
|
+
...new Set(recipients.map((recipient) => recipient.userId)),
|
|
421
|
+
];
|
|
422
|
+
for (const userId of distinctRecipients) {
|
|
423
|
+
await authorizeAccessKey(ctx, userId, auth.unidentifiedAccessKey);
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
export const sendUnidentified = mutation({
|
|
427
|
+
args: {
|
|
428
|
+
targetUserId: v.string(),
|
|
429
|
+
targetDeviceId: v.number(),
|
|
430
|
+
/** The recipient ACI the caller claims; required with a group-send
|
|
431
|
+
* token, which endorses ACIs rather than user IDs. */
|
|
432
|
+
targetAciBytes: v.optional(v.bytes()),
|
|
433
|
+
ciphertext: v.string(),
|
|
434
|
+
timestamp: v.number(),
|
|
435
|
+
clientMessageId: v.optional(v.string()),
|
|
436
|
+
unidentifiedAccessKey: v.optional(v.string()),
|
|
437
|
+
groupSendToken: v.optional(v.bytes()),
|
|
438
|
+
},
|
|
439
|
+
returns: receiptValidator,
|
|
440
|
+
handler: async (ctx, input) => {
|
|
441
|
+
requireCiphertextWithin(input.ciphertext, MAX_CIPHERTEXT_LENGTH);
|
|
442
|
+
await authorizeUnidentified(ctx, [{ userId: input.targetUserId, aciBytes: input.targetAciBytes }], input);
|
|
443
|
+
await requireActiveDevice(ctx, input.targetUserId, input.targetDeviceId);
|
|
444
|
+
await chargeInboundBudget(ctx, input.targetUserId, ciphertextBytes(input.ciphertext));
|
|
445
|
+
return await insertMessage(ctx, {
|
|
446
|
+
targetUserId: input.targetUserId,
|
|
447
|
+
targetDeviceId: input.targetDeviceId,
|
|
448
|
+
senderUserId: '',
|
|
449
|
+
senderDeviceId: 0,
|
|
450
|
+
ciphertext: input.ciphertext,
|
|
451
|
+
messageType: 'unidentified_sender',
|
|
452
|
+
timestamp: input.timestamp,
|
|
453
|
+
clientMessageId: input.clientMessageId,
|
|
454
|
+
});
|
|
455
|
+
},
|
|
456
|
+
});
|
|
457
|
+
const multiRecipientValidator = v.object({
|
|
458
|
+
userId: v.string(),
|
|
459
|
+
deviceId: v.number(),
|
|
460
|
+
registrationId: v.number(),
|
|
461
|
+
/** The recipient ACI the caller claims; required with a group-send token,
|
|
462
|
+
* which endorses ACIs rather than user IDs. */
|
|
463
|
+
aciBytes: v.optional(v.bytes()),
|
|
464
|
+
encryptedMessageKeyBase64: v.string(),
|
|
465
|
+
authenticationTagBase64: v.string(),
|
|
466
|
+
});
|
|
467
|
+
export const sendMultiRecipientUnidentified = mutation({
|
|
468
|
+
args: {
|
|
469
|
+
recipients: v.array(multiRecipientValidator),
|
|
470
|
+
ephemeralPublicBase64: v.string(),
|
|
471
|
+
messageCiphertextBase64: v.string(),
|
|
472
|
+
timestamp: v.number(),
|
|
473
|
+
clientMessageId: v.optional(v.string()),
|
|
474
|
+
unidentifiedAccessKey: v.optional(v.string()),
|
|
475
|
+
groupSendToken: v.optional(v.bytes()),
|
|
476
|
+
},
|
|
477
|
+
returns: v.object({
|
|
478
|
+
messageId: v.string(),
|
|
479
|
+
serverTimestamp: v.number(),
|
|
480
|
+
uuids404: v.array(v.string()),
|
|
481
|
+
}),
|
|
482
|
+
handler: async (ctx, input) => {
|
|
483
|
+
if (input.recipients.length > MAX_MULTI_RECIPIENT_DEVICES) {
|
|
484
|
+
throw relayError('INVALID_REQUEST', 400, `Multi-recipient delivery supports at most ${MAX_MULTI_RECIPIENT_DEVICES} devices`);
|
|
485
|
+
}
|
|
486
|
+
requireCiphertextWithin(input.messageCiphertextBase64, MAX_MULTI_RECIPIENT_CIPHERTEXT_LENGTH);
|
|
487
|
+
// Per-recipient key material is a fixed-size key and tag; the reference
|
|
488
|
+
// budgets ~100 bytes per recipient block. 512 base64 characters is far
|
|
489
|
+
// above any real encoding and far below a useful flood.
|
|
490
|
+
//
|
|
491
|
+
// One entry per (userId, deviceId). The fan-out below stores a full copy
|
|
492
|
+
// of the shared ciphertext for every entry it accepts, so a request
|
|
493
|
+
// naming one device N times stores N copies of it — and a group-send
|
|
494
|
+
// token endorses the recipient *set*, saying nothing about how many
|
|
495
|
+
// times a member may appear in it. Rejecting rather than collapsing: a
|
|
496
|
+
// repeat is a client bug, and quietly picking one of two conflicting key
|
|
497
|
+
// blocks would bury it.
|
|
498
|
+
const seenDevices = new Set();
|
|
499
|
+
for (const recipient of input.recipients) {
|
|
500
|
+
requireCiphertextWithin(recipient.encryptedMessageKeyBase64, 512);
|
|
501
|
+
requireCiphertextWithin(recipient.authenticationTagBase64, 512);
|
|
502
|
+
const deviceKey = JSON.stringify([recipient.userId, recipient.deviceId]);
|
|
503
|
+
if (seenDevices.has(deviceKey)) {
|
|
504
|
+
throw relayError('INVALID_REQUEST', 400, 'Multi-recipient delivery names the same device more than once');
|
|
505
|
+
}
|
|
506
|
+
seenDevices.add(deviceKey);
|
|
507
|
+
}
|
|
508
|
+
await authorizeUnidentified(ctx, input.recipients.map((recipient) => ({
|
|
509
|
+
userId: recipient.userId,
|
|
510
|
+
aciBytes: recipient.aciBytes,
|
|
511
|
+
})), input);
|
|
512
|
+
const ephemeralPublic = base64ToBytes(asBase64(input.ephemeralPublicBase64));
|
|
513
|
+
const messageCiphertext = base64ToBytes(asBase64(input.messageCiphertextBase64));
|
|
514
|
+
let first;
|
|
515
|
+
const uuids404 = new Set();
|
|
516
|
+
for (const recipient of input.recipients) {
|
|
517
|
+
const device = await ctx.db
|
|
518
|
+
.query('devices')
|
|
519
|
+
.withIndex('by_user_id_and_device_id', (q) => q
|
|
520
|
+
.eq('userId', recipient.userId)
|
|
521
|
+
.eq('deviceId', recipient.deviceId))
|
|
522
|
+
.unique();
|
|
523
|
+
if (!device?.registered || !device.enabled) {
|
|
524
|
+
uuids404.add(recipient.userId);
|
|
525
|
+
continue;
|
|
526
|
+
}
|
|
527
|
+
const registration = await ctx.db
|
|
528
|
+
.query('identityRegistrations')
|
|
529
|
+
.withIndex('by_user_id_and_device_id_and_identity_type', (q) => q
|
|
530
|
+
.eq('userId', recipient.userId)
|
|
531
|
+
.eq('deviceId', recipient.deviceId)
|
|
532
|
+
.eq('identityType', 'aci'))
|
|
533
|
+
.unique();
|
|
534
|
+
if (registration &&
|
|
535
|
+
registration.registrationId !== recipient.registrationId) {
|
|
536
|
+
uuids404.add(recipient.userId);
|
|
537
|
+
continue;
|
|
538
|
+
}
|
|
539
|
+
const receivedMessage = serializeReceivedMessage(base64ToBytes(asBase64(recipient.encryptedMessageKeyBase64)), base64ToBytes(asBase64(recipient.authenticationTagBase64)), ephemeralPublic, messageCiphertext);
|
|
540
|
+
const result = await insertMessage(ctx, {
|
|
541
|
+
targetUserId: recipient.userId,
|
|
542
|
+
targetDeviceId: recipient.deviceId,
|
|
543
|
+
senderUserId: '',
|
|
544
|
+
senderDeviceId: 0,
|
|
545
|
+
ciphertext: bytesToBase64(receivedMessage),
|
|
546
|
+
messageType: 'unidentified_sender',
|
|
547
|
+
timestamp: input.timestamp,
|
|
548
|
+
clientMessageId: input.clientMessageId,
|
|
549
|
+
});
|
|
550
|
+
first ??= result;
|
|
551
|
+
}
|
|
552
|
+
const fallbackTimestamp = Date.now();
|
|
553
|
+
return {
|
|
554
|
+
messageId: first?.messageId ?? `multi-${crypto.randomUUID()}`,
|
|
555
|
+
serverTimestamp: first?.serverTimestamp ?? fallbackTimestamp,
|
|
556
|
+
uuids404: [...uuids404],
|
|
557
|
+
};
|
|
558
|
+
},
|
|
559
|
+
});
|
|
560
|
+
export const sendRetryRequest = mutation({
|
|
561
|
+
args: {
|
|
562
|
+
...callerIdentityArgs,
|
|
563
|
+
requesterDeviceId: v.number(),
|
|
564
|
+
originalSenderUserId: v.string(),
|
|
565
|
+
originalSenderDeviceId: v.number(),
|
|
566
|
+
failedTimestamp: v.number(),
|
|
567
|
+
timestamp: v.number(),
|
|
568
|
+
reason: retryReasonValidator,
|
|
569
|
+
},
|
|
570
|
+
returns: v.null(),
|
|
571
|
+
handler: async (ctx, input) => {
|
|
572
|
+
await rememberAccount(ctx, input);
|
|
573
|
+
await chargeRetryRequest(ctx, input.callerUserId);
|
|
574
|
+
await ctx.db.insert('retryRequests', {
|
|
575
|
+
requestId: crypto.randomUUID(),
|
|
576
|
+
requesterUserId: input.callerUserId,
|
|
577
|
+
requesterDeviceId: input.requesterDeviceId,
|
|
578
|
+
originalSenderUserId: input.originalSenderUserId,
|
|
579
|
+
originalSenderDeviceId: input.originalSenderDeviceId,
|
|
580
|
+
failedTimestamp: input.failedTimestamp,
|
|
581
|
+
timestamp: input.timestamp,
|
|
582
|
+
reason: input.reason,
|
|
583
|
+
expiresAt: Date.now() + MESSAGE_TTL_MS,
|
|
584
|
+
});
|
|
585
|
+
return null;
|
|
586
|
+
},
|
|
587
|
+
});
|
|
588
|
+
const retryRequestValidator = v.object({
|
|
589
|
+
id: v.string(),
|
|
590
|
+
requesterUserId: v.string(),
|
|
591
|
+
requesterDeviceId: v.number(),
|
|
592
|
+
originalSenderUserId: v.string(),
|
|
593
|
+
originalSenderDeviceId: v.number(),
|
|
594
|
+
failedTimestamp: v.number(),
|
|
595
|
+
timestamp: v.number(),
|
|
596
|
+
reason: retryReasonValidator,
|
|
597
|
+
});
|
|
598
|
+
export const getPendingRetryRequests = query({
|
|
599
|
+
args: {
|
|
600
|
+
...callerIdentityArgs,
|
|
601
|
+
deviceId: v.number(),
|
|
602
|
+
},
|
|
603
|
+
returns: v.array(retryRequestValidator),
|
|
604
|
+
handler: async (ctx, input) => {
|
|
605
|
+
// Same read-time expiry filter and the same transaction-fixed clock as
|
|
606
|
+
// getPendingMessages: an expired retry request may survive in a cached
|
|
607
|
+
// subscription until the hourly cron deletes it. Acting on a stale retry
|
|
608
|
+
// request costs one redundant re-send, so the window is harmless.
|
|
609
|
+
const now = Date.now();
|
|
610
|
+
const rows = (await ctx.db
|
|
611
|
+
.query('retryRequests')
|
|
612
|
+
.withIndex('by_original_sender_user_id_and_original_sender_device_id', (q) => q
|
|
613
|
+
.eq('originalSenderUserId', input.callerUserId)
|
|
614
|
+
.eq('originalSenderDeviceId', input.deviceId))
|
|
615
|
+
.take(MAX_PENDING_RETRY_REQUESTS)).filter((row) => row.expiresAt > now);
|
|
616
|
+
return rows.map(({ requestId, ...request }) => ({
|
|
617
|
+
id: requestId,
|
|
618
|
+
requesterUserId: request.requesterUserId,
|
|
619
|
+
requesterDeviceId: request.requesterDeviceId,
|
|
620
|
+
originalSenderUserId: request.originalSenderUserId,
|
|
621
|
+
originalSenderDeviceId: request.originalSenderDeviceId,
|
|
622
|
+
failedTimestamp: request.failedTimestamp,
|
|
623
|
+
timestamp: request.timestamp,
|
|
624
|
+
reason: request.reason,
|
|
625
|
+
}));
|
|
626
|
+
},
|
|
627
|
+
});
|
|
628
|
+
export const markRetryRequestHandled = mutation({
|
|
629
|
+
args: {
|
|
630
|
+
...callerIdentityArgs,
|
|
631
|
+
requestId: v.string(),
|
|
632
|
+
},
|
|
633
|
+
returns: v.null(),
|
|
634
|
+
handler: async (ctx, input) => {
|
|
635
|
+
await rememberAccount(ctx, input);
|
|
636
|
+
const request = await ctx.db
|
|
637
|
+
.query('retryRequests')
|
|
638
|
+
.withIndex('by_request_id', (q) => q.eq('requestId', input.requestId))
|
|
639
|
+
.unique();
|
|
640
|
+
if (!request)
|
|
641
|
+
return null;
|
|
642
|
+
if (request.originalSenderUserId !== input.callerUserId) {
|
|
643
|
+
throw unauthorized('only the original sender can handle a retry request');
|
|
644
|
+
}
|
|
645
|
+
await ctx.db.delete(request._id);
|
|
646
|
+
return null;
|
|
647
|
+
},
|
|
648
|
+
});
|
|
649
|
+
//# sourceMappingURL=messages.js.map
|