@open-e2ee/signal-protocol-sdk 0.4.0 → 2.0.0

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.
Files changed (255) hide show
  1. package/CHANGELOG.md +126 -5
  2. package/COMMERCIAL.md +1 -1
  3. package/README.md +10 -7
  4. package/SECURITY.md +2 -2
  5. package/THIRD_PARTY_NOTICES.md +1 -1
  6. package/device/README.md +7 -5
  7. package/dist/client/client.d.ts +3 -2
  8. package/dist/client/client.d.ts.map +1 -1
  9. package/dist/client/client.js +58 -25
  10. package/dist/client/client.js.map +1 -1
  11. package/dist/client/config.d.ts +46 -7
  12. package/dist/client/config.d.ts.map +1 -1
  13. package/dist/client/config.js +2 -2
  14. package/dist/client/config.js.map +1 -1
  15. package/dist/client/constants.d.ts +4 -2
  16. package/dist/client/constants.d.ts.map +1 -1
  17. package/dist/client/constants.js +4 -2
  18. package/dist/client/constants.js.map +1 -1
  19. package/dist/client/group-outbox.d.ts +38 -0
  20. package/dist/client/group-outbox.d.ts.map +1 -0
  21. package/dist/client/group-outbox.js +224 -0
  22. package/dist/client/group-outbox.js.map +1 -0
  23. package/dist/client/group-sealed-sender.d.ts +28 -0
  24. package/dist/client/group-sealed-sender.d.ts.map +1 -0
  25. package/dist/client/group-sealed-sender.js +74 -0
  26. package/dist/client/group-sealed-sender.js.map +1 -0
  27. package/dist/client/hosted-connection.d.ts +16 -0
  28. package/dist/client/hosted-connection.d.ts.map +1 -0
  29. package/dist/client/hosted-connection.js +255 -0
  30. package/dist/client/hosted-connection.js.map +1 -0
  31. package/dist/client/hosted-push.d.ts +57 -0
  32. package/dist/client/hosted-push.d.ts.map +1 -0
  33. package/dist/client/hosted-push.js +115 -0
  34. package/dist/client/hosted-push.js.map +1 -0
  35. package/dist/client/hosted-transport.d.ts +158 -0
  36. package/dist/client/hosted-transport.d.ts.map +1 -0
  37. package/dist/client/hosted-transport.js +926 -0
  38. package/dist/client/hosted-transport.js.map +1 -0
  39. package/dist/client/hosted.d.ts +223 -0
  40. package/dist/client/hosted.d.ts.map +1 -0
  41. package/dist/client/hosted.js +541 -0
  42. package/dist/client/hosted.js.map +1 -0
  43. package/dist/client/index.d.ts +5 -3
  44. package/dist/client/index.d.ts.map +1 -1
  45. package/dist/client/index.js +2 -0
  46. package/dist/client/index.js.map +1 -1
  47. package/dist/client/messages.d.ts.map +1 -1
  48. package/dist/client/messages.js +4 -5
  49. package/dist/client/messages.js.map +1 -1
  50. package/dist/client/relay-subscription.d.ts.map +1 -1
  51. package/dist/client/relay-subscription.js +37 -7
  52. package/dist/client/relay-subscription.js.map +1 -1
  53. package/dist/client/{sealed-sender-ops.d.ts → sealed-sender.d.ts} +39 -22
  54. package/dist/client/sealed-sender.d.ts.map +1 -0
  55. package/dist/client/sealed-sender.js +296 -0
  56. package/dist/client/sealed-sender.js.map +1 -0
  57. package/dist/client/signal-service-cipher.d.ts +23 -26
  58. package/dist/client/signal-service-cipher.d.ts.map +1 -1
  59. package/dist/client/signal-service-cipher.js +468 -706
  60. package/dist/client/signal-service-cipher.js.map +1 -1
  61. package/dist/client/types.d.ts +18 -3
  62. package/dist/client/types.d.ts.map +1 -1
  63. package/dist/client/types.js +6 -0
  64. package/dist/client/types.js.map +1 -1
  65. package/dist/device/index.d.ts +2 -2
  66. package/dist/device/index.d.ts.map +1 -1
  67. package/dist/device/index.js +1 -1
  68. package/dist/device/index.js.map +1 -1
  69. package/dist/device/transfer.d.ts +7 -43
  70. package/dist/device/transfer.d.ts.map +1 -1
  71. package/dist/device/transfer.js +31 -150
  72. package/dist/device/transfer.js.map +1 -1
  73. package/dist/device/types.d.ts +6 -47
  74. package/dist/device/types.d.ts.map +1 -1
  75. package/dist/device/types.js +1 -1
  76. package/dist/device/types.js.map +1 -1
  77. package/dist/index.d.ts +6 -5
  78. package/dist/index.d.ts.map +1 -1
  79. package/dist/index.js +2 -1
  80. package/dist/index.js.map +1 -1
  81. package/dist/internal/encoding/proto/pq-ratchet-serialize.js +1 -1
  82. package/dist/internal/encoding/proto/pq-ratchet-serialize.js.map +1 -1
  83. package/dist/internal/encoding/proto/primitives.js +1 -1
  84. package/dist/internal/encoding/proto/primitives.js.map +1 -1
  85. package/dist/internal/groups/manager.d.ts +3 -3
  86. package/dist/internal/groups/manager.d.ts.map +1 -1
  87. package/dist/internal/groups/manager.js +5 -4
  88. package/dist/internal/groups/manager.js.map +1 -1
  89. package/dist/internal/protocol/sealed-sender/certificate.d.ts +10 -4
  90. package/dist/internal/protocol/sealed-sender/certificate.d.ts.map +1 -1
  91. package/dist/internal/protocol/sealed-sender/certificate.js +64 -7
  92. package/dist/internal/protocol/sealed-sender/certificate.js.map +1 -1
  93. package/dist/internal/protocol/sealed-sender/decryption.d.ts +34 -47
  94. package/dist/internal/protocol/sealed-sender/decryption.d.ts.map +1 -1
  95. package/dist/internal/protocol/sealed-sender/decryption.js +95 -182
  96. package/dist/internal/protocol/sealed-sender/decryption.js.map +1 -1
  97. package/dist/internal/protocol/sealed-sender/encryption.d.ts +49 -64
  98. package/dist/internal/protocol/sealed-sender/encryption.d.ts.map +1 -1
  99. package/dist/internal/protocol/sealed-sender/encryption.js +120 -123
  100. package/dist/internal/protocol/sealed-sender/encryption.js.map +1 -1
  101. package/dist/internal/protocol/sealed-sender/index.d.ts +5 -7
  102. package/dist/internal/protocol/sealed-sender/index.d.ts.map +1 -1
  103. package/dist/internal/protocol/sealed-sender/index.js +4 -12
  104. package/dist/internal/protocol/sealed-sender/index.js.map +1 -1
  105. package/dist/internal/protocol/sealed-sender/{v2-helpers.d.ts → multi-recipient-crypto.d.ts} +1 -1
  106. package/dist/internal/protocol/sealed-sender/multi-recipient-crypto.d.ts.map +1 -0
  107. package/dist/internal/protocol/sealed-sender/{v2-helpers.js → multi-recipient-crypto.js} +1 -1
  108. package/dist/internal/protocol/sealed-sender/multi-recipient-crypto.js.map +1 -0
  109. package/dist/internal/protocol/sealed-sender/{v2-binary.d.ts → multi-recipient-message.d.ts} +3 -2
  110. package/dist/internal/protocol/sealed-sender/multi-recipient-message.d.ts.map +1 -0
  111. package/dist/internal/protocol/sealed-sender/{v2-binary.js → multi-recipient-message.js} +16 -8
  112. package/dist/internal/protocol/sealed-sender/multi-recipient-message.js.map +1 -0
  113. package/dist/internal/protocol/sealed-sender/proto/index.d.ts +3 -0
  114. package/dist/internal/protocol/sealed-sender/proto/index.d.ts.map +1 -1
  115. package/dist/internal/protocol/sealed-sender/proto/index.js +25 -2
  116. package/dist/internal/protocol/sealed-sender/proto/index.js.map +1 -1
  117. package/dist/internal/protocol/sealed-sender/trust-root.d.ts +11 -1
  118. package/dist/internal/protocol/sealed-sender/trust-root.d.ts.map +1 -1
  119. package/dist/internal/protocol/sealed-sender/trust-root.js +13 -1
  120. package/dist/internal/protocol/sealed-sender/trust-root.js.map +1 -1
  121. package/dist/internal/protocol/sealed-sender/types.d.ts +20 -135
  122. package/dist/internal/protocol/sealed-sender/types.d.ts.map +1 -1
  123. package/dist/internal/protocol/sealed-sender/types.js +15 -6
  124. package/dist/internal/protocol/sealed-sender/types.js.map +1 -1
  125. package/dist/internal/protocol/sender-keys/manager.d.ts +22 -1
  126. package/dist/internal/protocol/sender-keys/manager.d.ts.map +1 -1
  127. package/dist/internal/protocol/sender-keys/manager.js +39 -4
  128. package/dist/internal/protocol/sender-keys/manager.js.map +1 -1
  129. package/dist/internal/protocol/spqr/braid-serialize.js +1 -1
  130. package/dist/internal/protocol/spqr/braid-serialize.js.map +1 -1
  131. package/dist/internal/protocol/spqr/ml-kem-braid/state-machine.js +4 -4
  132. package/dist/internal/protocol/spqr/ml-kem-braid/state-machine.js.map +1 -1
  133. package/dist/internal/protocol/zk/groups/index.d.ts +1 -1
  134. package/dist/internal/protocol/zk/groups/index.d.ts.map +1 -1
  135. package/dist/internal/protocol/zk/groups/index.js +1 -1
  136. package/dist/internal/protocol/zk/groups/index.js.map +1 -1
  137. package/dist/internal/protocol/zk/groups/profile-key-credential.d.ts +37 -12
  138. package/dist/internal/protocol/zk/groups/profile-key-credential.d.ts.map +1 -1
  139. package/dist/internal/protocol/zk/groups/profile-key-credential.js +104 -31
  140. package/dist/internal/protocol/zk/groups/profile-key-credential.js.map +1 -1
  141. package/dist/local/store/expo/adapter.d.ts +1 -0
  142. package/dist/local/store/expo/adapter.d.ts.map +1 -1
  143. package/dist/local/store/expo/adapter.js +3 -0
  144. package/dist/local/store/expo/adapter.js.map +1 -1
  145. package/dist/local/store/expo/key-storage.d.ts +1 -0
  146. package/dist/local/store/expo/key-storage.d.ts.map +1 -1
  147. package/dist/local/store/expo/key-storage.js +4 -0
  148. package/dist/local/store/expo/key-storage.js.map +1 -1
  149. package/dist/local/store/memory/adapter.d.ts +1 -0
  150. package/dist/local/store/memory/adapter.d.ts.map +1 -1
  151. package/dist/local/store/memory/adapter.js +4 -0
  152. package/dist/local/store/memory/adapter.js.map +1 -1
  153. package/dist/local/store/node/adapter.d.ts +1 -0
  154. package/dist/local/store/node/adapter.d.ts.map +1 -1
  155. package/dist/local/store/node/adapter.js +3 -0
  156. package/dist/local/store/node/adapter.js.map +1 -1
  157. package/dist/local/store/node/database.d.ts +1 -0
  158. package/dist/local/store/node/database.d.ts.map +1 -1
  159. package/dist/local/store/node/database.js +5 -0
  160. package/dist/local/store/node/database.js.map +1 -1
  161. package/dist/local/store/react-native/adapter.d.ts +1 -0
  162. package/dist/local/store/react-native/adapter.d.ts.map +1 -1
  163. package/dist/local/store/react-native/adapter.js +4 -0
  164. package/dist/local/store/react-native/adapter.js.map +1 -1
  165. package/dist/local/store/react-native/reference-backend.js +1 -1
  166. package/dist/local/store/react-native/reference-backend.js.map +1 -1
  167. package/dist/local/store/reliability.d.ts +63 -0
  168. package/dist/local/store/reliability.d.ts.map +1 -0
  169. package/dist/local/store/reliability.js +219 -0
  170. package/dist/local/store/reliability.js.map +1 -0
  171. package/dist/local/store/web/adapter.d.ts +1 -0
  172. package/dist/local/store/web/adapter.d.ts.map +1 -1
  173. package/dist/local/store/web/adapter.js +5 -0
  174. package/dist/local/store/web/adapter.js.map +1 -1
  175. package/dist/media/index.d.ts.map +1 -1
  176. package/dist/media/index.js +7 -4
  177. package/dist/media/index.js.map +1 -1
  178. package/dist/remote/object-store/convex-r2/server.d.ts +4 -2
  179. package/dist/remote/object-store/convex-r2/server.d.ts.map +1 -1
  180. package/dist/remote/object-store/convex-r2/server.js +8 -0
  181. package/dist/remote/object-store/convex-r2/server.js.map +1 -1
  182. package/dist/remote/object-store/convex-r2/storage.d.ts +5 -1
  183. package/dist/remote/object-store/convex-r2/storage.d.ts.map +1 -1
  184. package/dist/remote/object-store/convex-r2/storage.js +1 -0
  185. package/dist/remote/object-store/convex-r2/storage.js.map +1 -1
  186. package/dist/remote/object-store/types.d.ts +2 -0
  187. package/dist/remote/object-store/types.d.ts.map +1 -1
  188. package/dist/remote/object-store/validation.d.ts.map +1 -1
  189. package/dist/remote/object-store/validation.js +3 -0
  190. package/dist/remote/object-store/validation.js.map +1 -1
  191. package/dist/remote/relay/convex/backend.d.ts +7 -18
  192. package/dist/remote/relay/convex/backend.d.ts.map +1 -1
  193. package/dist/remote/relay/convex/backend.js +15 -24
  194. package/dist/remote/relay/convex/backend.js.map +1 -1
  195. package/dist/remote/relay/convex/component/_generated/component.d.ts +10 -18
  196. package/dist/remote/relay/convex/component/_generated/component.d.ts.map +1 -1
  197. package/dist/remote/relay/convex/component/certificates.d.ts.map +1 -1
  198. package/dist/remote/relay/convex/component/certificates.js +14 -5
  199. package/dist/remote/relay/convex/component/certificates.js.map +1 -1
  200. package/dist/remote/relay/convex/component/messages.d.ts +3 -17
  201. package/dist/remote/relay/convex/component/messages.d.ts.map +1 -1
  202. package/dist/remote/relay/convex/component/messages.js +28 -56
  203. package/dist/remote/relay/convex/component/messages.js.map +1 -1
  204. package/dist/remote/relay/convex/component/schema.d.ts +6 -6
  205. package/dist/remote/relay/convex/component/schema.js +2 -2
  206. package/dist/remote/relay/convex/component/schema.js.map +1 -1
  207. package/dist/remote/relay/convex/component/zkAuth.d.ts +7 -1
  208. package/dist/remote/relay/convex/component/zkAuth.d.ts.map +1 -1
  209. package/dist/remote/relay/convex/component/zkAuth.js +29 -14
  210. package/dist/remote/relay/convex/component/zkAuth.js.map +1 -1
  211. package/dist/remote/relay/convex/relay.d.ts +3 -6
  212. package/dist/remote/relay/convex/relay.d.ts.map +1 -1
  213. package/dist/remote/relay/convex/relay.js +23 -50
  214. package/dist/remote/relay/convex/relay.js.map +1 -1
  215. package/dist/remote/relay/index.d.ts +1 -1
  216. package/dist/remote/relay/index.d.ts.map +1 -1
  217. package/dist/remote/relay/index.js.map +1 -1
  218. package/dist/remote/relay/memory/adapter.d.ts +5 -11
  219. package/dist/remote/relay/memory/adapter.d.ts.map +1 -1
  220. package/dist/remote/relay/memory/adapter.js +41 -34
  221. package/dist/remote/relay/memory/adapter.js.map +1 -1
  222. package/dist/remote/relay/types.d.ts +19 -29
  223. package/dist/remote/relay/types.d.ts.map +1 -1
  224. package/dist/types/api.d.ts +2 -0
  225. package/dist/types/api.d.ts.map +1 -1
  226. package/dist/types/errors.d.ts +8 -1
  227. package/dist/types/errors.d.ts.map +1 -1
  228. package/dist/types/errors.js +9 -2
  229. package/dist/types/errors.js.map +1 -1
  230. package/dist/types/protocol-config.d.ts +1 -1
  231. package/dist/username/link.d.ts.map +1 -1
  232. package/dist/username/link.js +1 -1
  233. package/dist/username/link.js.map +1 -1
  234. package/docs/ASSURANCE.md +5 -5
  235. package/docs/DEVIATIONS.md +32 -61
  236. package/docs/GETTING_STARTED.md +7 -0
  237. package/docs/SECURITY.md +6 -0
  238. package/package.json +2 -2
  239. package/remote/relay/convex/component/README.md +28 -24
  240. package/scripts/oe-groups.mjs +5 -1
  241. package/dist/client/sealed-sender-ops.d.ts.map +0 -1
  242. package/dist/client/sealed-sender-ops.js +0 -203
  243. package/dist/client/sealed-sender-ops.js.map +0 -1
  244. package/dist/internal/protocol/sealed-sender/decryption-v2.d.ts +0 -46
  245. package/dist/internal/protocol/sealed-sender/decryption-v2.d.ts.map +0 -1
  246. package/dist/internal/protocol/sealed-sender/decryption-v2.js +0 -198
  247. package/dist/internal/protocol/sealed-sender/decryption-v2.js.map +0 -1
  248. package/dist/internal/protocol/sealed-sender/encryption-v2.d.ts +0 -56
  249. package/dist/internal/protocol/sealed-sender/encryption-v2.d.ts.map +0 -1
  250. package/dist/internal/protocol/sealed-sender/encryption-v2.js +0 -163
  251. package/dist/internal/protocol/sealed-sender/encryption-v2.js.map +0 -1
  252. package/dist/internal/protocol/sealed-sender/v2-binary.d.ts.map +0 -1
  253. package/dist/internal/protocol/sealed-sender/v2-binary.js.map +0 -1
  254. package/dist/internal/protocol/sealed-sender/v2-helpers.d.ts.map +0 -1
  255. package/dist/internal/protocol/sealed-sender/v2-helpers.js.map +0 -1
@@ -0,0 +1,296 @@
1
+ /**
2
+ * Sealed Sender Client Boundary
3
+ *
4
+ * Provides seal/unseal wrapping for the message send/receive pipeline.
5
+ * Called by SignalProtocolServiceCipher when sealed sender is enabled.
6
+ *
7
+ * @see https://signal.org/blog/sealed-sender/
8
+ */
9
+ import { resolveSignalProtocolLogger } from '../logger.js';
10
+ import { ProtocolAddress } from '../types/address.js';
11
+ import { base64ToBytes } from '../internal/crypto/index.js';
12
+ import { UnidentifiedAccessMode } from '../profile/contact-state.js';
13
+ import { SealedSenderContentType, SEALED_SENDER_V2_SERVICE_ID_VERSION, SEALED_SENDER_V2_UUID_VERSION, } from '../internal/protocol/sealed-sender/types.js';
14
+ export async function serializeDirectSealedSenderMessage(msg, ciphertextBase64, messageType, recipientRegistrationId, sealedSender) {
15
+ const { sealMultiRecipient, deserializeSenderCertificate } = await import('../internal/protocol/sealed-sender/index.js');
16
+ const { serializeSentMessage } = await import('../internal/protocol/sealed-sender/multi-recipient-message.js');
17
+ const { base64ToBytes: b64ToBytes, bytesToBase64: bytesToB64 } = await import('../internal/crypto/index.js');
18
+ const senderCertificate = deserializeSenderCertificate(b64ToBytes(sealedSender.senderCertificateBase64));
19
+ const sealed = await sealMultiRecipient({
20
+ senderCertificate,
21
+ senderIdentityPrivate: sealedSender.senderIdentityPrivate,
22
+ senderIdentityPublic: sealedSender.senderIdentityPublic,
23
+ recipients: [
24
+ {
25
+ serviceId: msg.recipientUserId,
26
+ deviceId: msg.recipientDeviceId,
27
+ registrationId: recipientRegistrationId ?? 0,
28
+ identityPublic: sealedSender.recipientIdentityPublic,
29
+ },
30
+ ],
31
+ signalProtocolMessage: b64ToBytes(ciphertextBase64),
32
+ contentType: messageType === 'sender_key'
33
+ ? SealedSenderContentType.SENDERKEY_MESSAGE
34
+ : messageType === 'prekey_bundle'
35
+ ? SealedSenderContentType.PREKEY_MESSAGE
36
+ : SealedSenderContentType.MESSAGE,
37
+ });
38
+ const recipient = sealed.recipients[0];
39
+ if (!recipient)
40
+ throw new Error('Sealed sender produced no direct recipient');
41
+ return bytesToB64(serializeSentMessage([
42
+ {
43
+ serviceId: recipient.serviceId,
44
+ devices: [
45
+ {
46
+ deviceId: recipient.deviceId,
47
+ registrationId: recipient.registrationId,
48
+ },
49
+ ],
50
+ encryptedMessageKey: b64ToBytes(recipient.encryptedMessageKey),
51
+ authenticationTag: b64ToBytes(recipient.authenticationTag),
52
+ },
53
+ ], [], b64ToBytes(sealed.ephemeralPublic), b64ToBytes(sealed.messageCiphertext)));
54
+ }
55
+ export async function resolveSealedSenderContext(context, recipientUserId, groupId) {
56
+ if (context.deliveryMode === 'disabled')
57
+ return null;
58
+ if (!context.provider || !context.relaySupportsUnidentified) {
59
+ return context.useIdentifiedDeliveryOrThrow(recipientUserId, 'anonymous relay capability is not configured');
60
+ }
61
+ if (groupId && context.endorsementManager) {
62
+ const groupSecretParams = context.groupSecretParamsProvider
63
+ ? await context.groupSecretParamsProvider(groupId)
64
+ : null;
65
+ const endorsementToken = await context.endorsementManager.getTokenForRecipient(groupId, recipientUserId, groupSecretParams ?? undefined);
66
+ if (endorsementToken) {
67
+ const { senderCertificateBase64, senderIdentityPrivate, senderIdentityPublic, config } = await context.provider();
68
+ const recipientIdentityRecord = await context.storage.getContactIdentity(ProtocolAddress.create(recipientUserId, 1));
69
+ if (recipientIdentityRecord) {
70
+ return {
71
+ senderCertificateBase64,
72
+ senderIdentityPrivate,
73
+ senderIdentityPublic,
74
+ recipientIdentityPublic: base64ToBytes(recipientIdentityRecord.identity.x25519PublicKey),
75
+ config,
76
+ auth: {
77
+ type: 'groupSendToken',
78
+ groupSendToken: endorsementToken.token,
79
+ recipientAciBytes: new Map([[recipientUserId, endorsementToken.aciBytes]]),
80
+ },
81
+ };
82
+ }
83
+ }
84
+ }
85
+ const contactStateStore = context.contactProfileStateStore;
86
+ if (!contactStateStore) {
87
+ context.logger.debug('No contact profile state store configured, using identified delivery', {
88
+ category: 'E2EE',
89
+ data: { recipientUserId, groupId },
90
+ });
91
+ return context.useIdentifiedDeliveryOrThrow(recipientUserId, 'recipient capability store is not configured');
92
+ }
93
+ const mode = await contactStateStore.getUnidentifiedAccessMode(recipientUserId);
94
+ if (mode === UnidentifiedAccessMode.DISABLED) {
95
+ context.logger.debug('Sealed sender disabled for recipient, using identified delivery', {
96
+ category: 'E2EE',
97
+ data: { recipientUserId, mode },
98
+ });
99
+ return context.useIdentifiedDeliveryOrThrow(recipientUserId, 'recipient disabled anonymous access');
100
+ }
101
+ const { deriveAccessKey } = await import('../internal/protocol/sealed-sender/delivery-token.js');
102
+ const { bytesToBase64 } = await import('../internal/crypto/index.js');
103
+ let auth;
104
+ switch (mode) {
105
+ case UnidentifiedAccessMode.UNRESTRICTED:
106
+ auth = {
107
+ type: 'accessKey',
108
+ unidentifiedAccessKey: bytesToBase64(new Uint8Array(16)),
109
+ };
110
+ break;
111
+ case UnidentifiedAccessMode.ENABLED: {
112
+ const recipientProfileKey = await contactStateStore.getContactProfileKey(recipientUserId);
113
+ if (!recipientProfileKey) {
114
+ context.logger.debug('No profile key for ENABLED recipient, using identified delivery', {
115
+ category: 'E2EE',
116
+ data: { recipientUserId },
117
+ });
118
+ return context.useIdentifiedDeliveryOrThrow(recipientUserId, 'recipient access key is unavailable');
119
+ }
120
+ auth = {
121
+ type: 'accessKey',
122
+ unidentifiedAccessKey: bytesToBase64(await deriveAccessKey(recipientProfileKey)),
123
+ };
124
+ break;
125
+ }
126
+ case UnidentifiedAccessMode.UNKNOWN:
127
+ default: {
128
+ const recipientProfileKey = await contactStateStore.getContactProfileKey(recipientUserId);
129
+ auth = {
130
+ type: 'accessKey',
131
+ unidentifiedAccessKey: bytesToBase64(recipientProfileKey ? await deriveAccessKey(recipientProfileKey) : new Uint8Array(16)),
132
+ };
133
+ break;
134
+ }
135
+ }
136
+ const { senderCertificateBase64, senderIdentityPrivate, senderIdentityPublic, config } = await context.provider();
137
+ const recipientIdentityRecord = await context.storage.getContactIdentity(ProtocolAddress.create(recipientUserId, 1));
138
+ if (!recipientIdentityRecord) {
139
+ context.logger.debug('No identity key for recipient, using identified delivery', {
140
+ category: 'E2EE',
141
+ data: { recipientUserId },
142
+ });
143
+ return context.useIdentifiedDeliveryOrThrow(recipientUserId, 'recipient identity key is unavailable');
144
+ }
145
+ return {
146
+ senderCertificateBase64,
147
+ senderIdentityPrivate,
148
+ senderIdentityPublic,
149
+ recipientIdentityPublic: base64ToBytes(recipientIdentityRecord.identity.x25519PublicKey),
150
+ config,
151
+ auth,
152
+ };
153
+ }
154
+ /**
155
+ * Unseal a sealed sender message to reveal the sender and inner ciphertext.
156
+ *
157
+ * Called when an incoming envelope has messageType === 'unidentified_sender'.
158
+ * Validates the certificate chain, reveals sender identity, and returns
159
+ * the inner Signal Protocol ciphertext for normal decryption.
160
+ *
161
+ * @param sealedCiphertextBase64 - Base64-encoded sealed sender message
162
+ * @param recipientIdentityPrivate - Recipient's X25519 identity private key
163
+ * @param recipientUuid - Recipient's user ID (for self-send detection)
164
+ * @param recipientDeviceId - Recipient's device ID
165
+ * @param config - Sealed sender config with trust roots
166
+ * @param relayEnqueueTime - Immutable time when Relay accepted the message
167
+ * @returns Unsealed envelope info with sender identity and inner ciphertext
168
+ */
169
+ export async function unsealMessage(sealedCiphertextBase64, recipientIdentityPrivate, recipientUuid, recipientDeviceId, config, relayEnqueueTime, providedLogger) {
170
+ if (typeof relayEnqueueTime !== 'number' ||
171
+ !Number.isSafeInteger(relayEnqueueTime) ||
172
+ relayEnqueueTime <= 0) {
173
+ throw new Error('Sealed sender verification requires an immutable Relay enqueue time');
174
+ }
175
+ const logger = resolveSignalProtocolLogger(providedLogger);
176
+ const { base64ToBytes, bytesToBase64 } = await import('../internal/crypto/index.js');
177
+ // Decode the only supported sealed-sender transport format.
178
+ const sealedBytes = base64ToBytes(sealedCiphertextBase64);
179
+ const versionByte = sealedBytes[0];
180
+ if (versionByte === SEALED_SENDER_V2_UUID_VERSION ||
181
+ versionByte === SEALED_SENDER_V2_SERVICE_ID_VERSION) {
182
+ return unsealReceivedMessage(sealedBytes, recipientIdentityPrivate, recipientUuid, recipientDeviceId, config, relayEnqueueTime, logger);
183
+ }
184
+ throw new Error('Unsupported sealed sender transport version');
185
+ }
186
+ /**
187
+ * Unseal a multi-recipient sealed sender message (per-device view).
188
+ *
189
+ * The server constructs a per-device view: [0x22][C_i(32)][AT_i(16)][e_pub(32)][ciphertext]
190
+ * We deserialize this, build a sealed message, and call unseal().
191
+ */
192
+ async function unsealReceivedMessage(sealedBytes, recipientIdentityPrivate, recipientUuid, recipientDeviceId, config, relayEnqueueTime, logger) {
193
+ const { deserializeReceivedMessage } = await import('../internal/protocol/sealed-sender/multi-recipient-message.js');
194
+ const { unseal } = await import('../internal/protocol/sealed-sender/decryption.js');
195
+ const { bytesToBase64 } = await import('../internal/crypto/index.js');
196
+ const { x25519 } = await import('@noble/curves/ed25519.js');
197
+ // 1. Deserialize per-device ReceivedMessage
198
+ const deserialized = deserializeReceivedMessage(sealedBytes);
199
+ // 2. Derive recipient public key from private
200
+ const recipientIdentityPublic = x25519.getPublicKey(recipientIdentityPrivate);
201
+ // 3. Build the sealed message with one recipient entry.
202
+ const message = {
203
+ version: SEALED_SENDER_V2_UUID_VERSION,
204
+ ephemeralPublic: bytesToBase64(deserialized.ephemeralPublic),
205
+ recipients: [
206
+ {
207
+ serviceId: recipientUuid,
208
+ deviceId: recipientDeviceId,
209
+ registrationId: 0, // Not needed for unseal. Only used in send path
210
+ encryptedMessageKey: bytesToBase64(deserialized.encryptedMessageKey),
211
+ authenticationTag: bytesToBase64(deserialized.authenticationTag),
212
+ },
213
+ ],
214
+ messageCiphertext: bytesToBase64(deserialized.messageCiphertext),
215
+ };
216
+ // 4. Build trust roots as Base64 strings
217
+ const trustRoots = config.trustRoots.map((root) => bytesToBase64(root));
218
+ const certificatePolicy = {
219
+ expectedRelayScopeId: bytesToBase64(config.relayScopeId),
220
+ revokedIssuerKeyIds: config.revokedIssuerKeyIds,
221
+ };
222
+ // 5. Unseal and validate the sender credential.
223
+ const content = await unseal({
224
+ sealedMessage: message,
225
+ recipientIdentityPrivate,
226
+ recipientIdentityPublic,
227
+ recipientServiceId: recipientUuid,
228
+ recipientDeviceId,
229
+ trustRoots,
230
+ currentTime: relayEnqueueTime,
231
+ certificatePolicy,
232
+ });
233
+ logger.debug('Sealed sender message unsealed', {
234
+ category: 'E2EE',
235
+ data: {
236
+ senderUuid: content.senderCertificate.senderUuid,
237
+ senderDeviceId: content.senderCertificate.senderDeviceId,
238
+ },
239
+ });
240
+ return {
241
+ senderUserId: content.senderCertificate.senderUuid,
242
+ senderDeviceId: content.senderCertificate.senderDeviceId,
243
+ innerCiphertextBase64: content.signalProtocolMessage,
244
+ contentType: content.contentType,
245
+ };
246
+ }
247
+ /**
248
+ * Reconstruct an Envelope from an unsealed message.
249
+ *
250
+ * Takes the original sealed sender envelope (with empty sender fields)
251
+ * and fills in the sender identity revealed by unsealing.
252
+ *
253
+ * @param originalEnvelope - The incoming envelope with messageType 'unidentified_sender'
254
+ * @param unsealed - The unsealed sender info and inner ciphertext
255
+ * @returns A new envelope with real sender info and the inner ciphertext
256
+ */
257
+ export function reconstructEnvelope(originalEnvelope, unsealed) {
258
+ return {
259
+ ...originalEnvelope,
260
+ senderUserId: unsealed.senderUserId,
261
+ senderDeviceId: unsealed.senderDeviceId,
262
+ ciphertext: unsealed.innerCiphertextBase64,
263
+ messageType: envelopeTypeForContent(unsealed.contentType),
264
+ };
265
+ }
266
+ /**
267
+ * Map a sealed envelope's content type onto the envelope type the decrypt
268
+ * path routes on.
269
+ *
270
+ * Exported because both receive paths need it. `SignalProtocolServiceCipher`
271
+ * via `reconstructEnvelope`, and `SignalProtocolClient.processIncomingEnvelope`
272
+ * directly. Two copies of this mapping would drift.
273
+ *
274
+ * `SENDERKEY_MESSAGE` is the only case that matters here. It is what keeps
275
+ * group routing working now that no group identifier travels on an envelope,
276
+ * sealed or otherwise. Both `PREKEY_MESSAGE` and `MESSAGE` decrypt as pairwise
277
+ * ratchet messages, and the ratchet distinguishes them from the payload
278
+ * itself.
279
+ *
280
+ * The default is unreachable: `isSealedSenderContentType` rejects every other
281
+ * value at the parse, so nothing arrives here that this function cannot map.
282
+ * It exists so that adding an enum member without a route fails loudly rather
283
+ * than silently decrypting as something it is not.
284
+ */
285
+ export function envelopeTypeForContent(contentType) {
286
+ switch (contentType) {
287
+ case SealedSenderContentType.SENDERKEY_MESSAGE:
288
+ return 'sender_key';
289
+ case SealedSenderContentType.PREKEY_MESSAGE:
290
+ case SealedSenderContentType.MESSAGE:
291
+ return 'ciphertext';
292
+ default:
293
+ throw new Error('Unsupported sealed sender content type');
294
+ }
295
+ }
296
+ //# sourceMappingURL=sealed-sender.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sealed-sender.js","sourceRoot":"","sources":["../../client/sealed-sender.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,EAAE,2BAA2B,EAAgB,MAAM,WAAW,CAAC;AAEtE,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,OAAO,EAAE,sBAAsB,EAAiC,MAAM,0BAA0B,CAAC;AACjG,OAAO,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,gBAA0B,EAC1B,QAKC;IAED,OAAO;QACL,GAAG,gBAAgB;QACnB,YAAY,EAAE,QAAQ,CAAC,YAAY;QACnC,cAAc,EAAE,QAAQ,CAAC,cAAc;QACvC,UAAU,EAAE,QAAQ,CAAC,qBAAqB;QAC1C,WAAW,EAAE,sBAAsB,CAAC,QAAQ,CAAC,WAAW,CAAC;KAC1D,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,sBAAsB,CACpC,WAAoC;IAEpC,QAAQ,WAAW,EAAE,CAAC;QACpB,KAAK,uBAAuB,CAAC,iBAAiB;YAC5C,OAAO,YAAY,CAAC;QACtB,KAAK,uBAAuB,CAAC,cAAc,CAAC;QAC5C,KAAK,uBAAuB,CAAC,OAAO;YAClC,OAAO,YAAY,CAAC;QACtB;YACE,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;IAC9D,CAAC;AACH,CAAC"}
@@ -22,6 +22,7 @@ import { SenderKeyManager } from '../internal/protocol/sender-keys/index.js';
22
22
  import type { EndorsementManager } from './endorsement-manager.js';
23
23
  import type { PreparedAttachmentUpload, SendOptions, SendResult } from './types.js';
24
24
  import { type BlockedRecipientsSyncInput, type ConfigurationSyncInput, type MediaAttachmentDeleteSyncInput, type ReadSyncEntryInput, type RecipientUsernameSyncInput, type SignalProtocolContentAdapter, type TaskNotificationAckSyncInput, type UsernameStateSyncInput, type VerificationStateSyncInput, type ViewOnceOpenSyncInput } from './content-adapter.js';
25
+ import { type SealedSenderProvider as SealedSenderProviderContract } from './sealed-sender.js';
25
26
  import { type ContactProfileStateStore } from '../profile/contact-state.js';
26
27
  export declare function sortEnvelopesForDecryption<T extends {
27
28
  messageType?: string;
@@ -35,12 +36,7 @@ export declare function sortEnvelopesForDecryption<T extends {
35
36
  *
36
37
  * @returns Sender certificate (base64), sender private key (bytes), and config
37
38
  */
38
- export type SealedSenderProvider = () => Promise<{
39
- senderCertificateBase64: string;
40
- senderIdentityPrivate: Uint8Array;
41
- senderIdentityPublic: Uint8Array;
42
- config: import('./config.js').SealedSenderConfig;
43
- }>;
39
+ export type SealedSenderProvider = SealedSenderProviderContract;
44
40
  /**
45
41
  * Callback for establishing sessions when none exist
46
42
  * Allows SignalProtocolClient to inject its session establishment logic
@@ -113,6 +109,8 @@ export declare class SignalProtocolServiceCipher {
113
109
  private sessionEstablisher?;
114
110
  private staleSessionRefresher?;
115
111
  private sealedSenderProvider?;
112
+ private sealedSenderDeliveryMode;
113
+ private sealedSenderIdentifiedFallback?;
116
114
  private contactProfileStateStore?;
117
115
  private endorsementManager?;
118
116
  private endorsementRefresher?;
@@ -124,7 +122,6 @@ export declare class SignalProtocolServiceCipher {
124
122
  private buildSentSyncTranscript;
125
123
  private encodeLosslessPlaintext;
126
124
  private uploadSyncMessages;
127
- private sendSyncTranscriptToLocalOtherDevices;
128
125
  private sendSyncPayloadToLocalOtherDevices;
129
126
  sendReadSyncToLocalOtherDevices(entries: ReadSyncEntryInput[]): Promise<void>;
130
127
  sendViewOnceOpenSyncToLocalOtherDevices(entry: ViewOnceOpenSyncInput): Promise<void>;
@@ -154,6 +151,10 @@ export declare class SignalProtocolServiceCipher {
154
151
  * Provides the sender certificate and identity key needed for sealing messages.
155
152
  */
156
153
  setSealedSenderProvider(provider: SealedSenderProvider): void;
154
+ setSealedSenderDeliveryMode(mode: import('./config.js').SealedSenderDeliveryMode): void;
155
+ setSealedSenderIdentifiedFallback(callback: NonNullable<import('./config.js').SealedSenderConfig['onIdentifiedFallback']>): void;
156
+ private reportIdentifiedFallback;
157
+ private useIdentifiedDeliveryOrThrow;
157
158
  setContactProfileStateStore(store: ContactProfileStateStore): void;
158
159
  /**
159
160
  * Set the endorsement manager for group send endorsement-based auth.
@@ -256,6 +257,16 @@ export declare class SignalProtocolServiceCipher {
256
257
  * Encrypt to a single user (all their devices) via SESAME
257
258
  */
258
259
  private encryptToUser;
260
+ private encryptToUserWithOutbox;
261
+ private encryptToUserWithOutboxLocked;
262
+ private prepareStoredDirectDeviceMessage;
263
+ private repairRejectedDirectDeviceMessage;
264
+ private sendStoredDirectDeviceMessage;
265
+ private sendStoredDirectIntent;
266
+ private encryptToGroupWithOutbox;
267
+ private prepareStoredGroupDeviceMessage;
268
+ private resolveGroupSendAuthorization;
269
+ private serializeDirectSealedSenderMessage;
259
270
  /**
260
271
  * Resolve sealed sender context for a recipient.
261
272
  *
@@ -285,8 +296,8 @@ export declare class SignalProtocolServiceCipher {
285
296
  * Send a single ciphertext to a device, optionally wrapping with sealed sender.
286
297
  *
287
298
  * When sealed sender context is available:
288
- * 1. Wraps the ciphertext with seal() to hide sender identity
289
- * 2. Uses relay.sendUnidentified() for anonymous delivery
299
+ * 1. Wraps the ciphertext with the multi-recipient format for one recipient
300
+ * 2. Uses relay.sendMultiRecipientUnidentified() for anonymous delivery
290
301
  *
291
302
  * On sealed sender auth failure, transitions the recipient's
292
303
  * UnidentifiedAccessMode before falling back to identified delivery:
@@ -299,21 +310,6 @@ export declare class SignalProtocolServiceCipher {
299
310
  *
300
311
  */
301
312
  private sendToDevice;
302
- /**
303
- * Attempt V2 multi-recipient sealed sender send.
304
- * Returns null if unavailable. Caller falls back to V1.
305
- *
306
- * Recovery behavior:
307
- * - 409 (mismatched devices): refresh device lists, rebuild recipient list, retry once
308
- * - 410 (stale sessions): archive stale sessions, retry once
309
- * - Other errors: return null for full V1 fallback
310
- *
311
- */
312
- private tryMultiRecipientSend;
313
- /**
314
- * V1 per-device sealed sender fanout (legacy path, used as fallback).
315
- */
316
- private perDeviceFanoutSend;
317
313
  /**
318
314
  * Resolve the group roster to concrete devices via the relay.
319
315
  *
@@ -324,11 +320,12 @@ export declare class SignalProtocolServiceCipher {
324
320
  * the zero-knowledge group design exists to hide.
325
321
  */
326
322
  private resolveGroupMemberDevices;
323
+ private prepareGroupSenderKeyPayload;
327
324
  /**
328
325
  * Encrypt to a group via Sender Keys (O(1) encryption)
329
326
  *
330
- * Prefers V2 multi-recipient sealed sender when available, falls back to
331
- * V1 per-device fanout.
327
+ * Uses the multi-recipient sealed-sender transport when anonymous delivery
328
+ * is available, with exact per-device identified delivery otherwise.
332
329
  */
333
330
  private encryptToGroup;
334
331
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"signal-service-cipher.d.ts","sourceRoot":"","sources":["../../client/signal-service-cipher.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,KAAK,EACV,0BAA0B,EAC1B,QAAQ,EAIT,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,wBAAwB,CAAC;AAC9E,OAAO,KAAK,EAAE,yBAAyB,EAAU,MAAM,UAAU,CAAC;AAIlE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAGvD,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAwB,MAAM,0BAA0B,CAAC;AACpG,OAAO,EAA+B,KAAK,OAAO,EAAE,MAAM,WAAW,CAAC;AACtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAEpE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,KAAK,EAAE,wBAAwB,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAGjF,OAAO,EACL,KAAK,0BAA0B,EAE/B,KAAK,sBAAsB,EAC3B,KAAK,8BAA8B,EACnC,KAAK,kBAAkB,EACvB,KAAK,0BAA0B,EAC/B,KAAK,4BAA4B,EACjC,KAAK,4BAA4B,EACjC,KAAK,sBAAsB,EAC3B,KAAK,0BAA0B,EAC/B,KAAK,qBAAqB,EAC3B,MAAM,mBAAmB,CAAC;AAI3B,OAAO,EAEL,KAAK,wBAAwB,EAE9B,MAAM,0BAA0B,CAAC;AAgBlC,wBAAgB,0BAA0B,CAAC,CAAC,SAAS;IAAE,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,EAC3E,SAAS,EAAE,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