@open-e2ee/signal-protocol-sdk 11.0.0 → 12.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (590) hide show
  1. package/ADAPTERS.md +4 -4
  2. package/ARCHITECTURE.md +6 -8
  3. package/CHANGELOG.md +1348 -0
  4. package/README.md +1 -1
  5. package/SECURITY.md +2 -2
  6. package/TROUBLESHOOTING.md +8 -8
  7. package/client/README.md +70 -37
  8. package/device/README.md +39 -85
  9. package/dist/client/client.d.ts +334 -63
  10. package/dist/client/client.d.ts.map +1 -1
  11. package/dist/client/client.js +1175 -186
  12. package/dist/client/client.js.map +1 -1
  13. package/dist/client/config.d.ts +57 -42
  14. package/dist/client/config.d.ts.map +1 -1
  15. package/dist/client/config.js +1 -1
  16. package/dist/client/config.js.map +1 -1
  17. package/dist/client/constants.d.ts +42 -8
  18. package/dist/client/constants.d.ts.map +1 -1
  19. package/dist/client/constants.js +48 -3
  20. package/dist/client/constants.js.map +1 -1
  21. package/dist/client/content-adapter.d.ts +80 -0
  22. package/dist/client/content-adapter.d.ts.map +1 -1
  23. package/dist/client/content-adapter.js +225 -12
  24. package/dist/client/content-adapter.js.map +1 -1
  25. package/dist/client/delivery-error.d.ts +150 -0
  26. package/dist/client/delivery-error.d.ts.map +1 -0
  27. package/dist/client/delivery-error.js +226 -0
  28. package/dist/client/delivery-error.js.map +1 -0
  29. package/dist/client/delivery-status.d.ts +32 -6
  30. package/dist/client/delivery-status.d.ts.map +1 -1
  31. package/dist/client/delivery-status.js +61 -13
  32. package/dist/client/delivery-status.js.map +1 -1
  33. package/dist/client/device-set-reconciliation.d.ts +196 -0
  34. package/dist/client/device-set-reconciliation.d.ts.map +1 -0
  35. package/dist/client/device-set-reconciliation.js +282 -0
  36. package/dist/client/device-set-reconciliation.js.map +1 -0
  37. package/dist/client/distribution-records.d.ts +29 -0
  38. package/dist/client/distribution-records.d.ts.map +1 -0
  39. package/dist/client/distribution-records.js +33 -0
  40. package/dist/client/distribution-records.js.map +1 -0
  41. package/dist/client/event-hooks.d.ts +280 -14
  42. package/dist/client/event-hooks.d.ts.map +1 -1
  43. package/dist/client/event-hooks.js +8 -0
  44. package/dist/client/event-hooks.js.map +1 -1
  45. package/dist/client/group-device-set.d.ts +47 -0
  46. package/dist/client/group-device-set.d.ts.map +1 -0
  47. package/dist/client/group-device-set.js +65 -0
  48. package/dist/client/group-device-set.js.map +1 -0
  49. package/dist/client/group-fetcher.d.ts +116 -0
  50. package/dist/client/group-fetcher.d.ts.map +1 -0
  51. package/dist/client/group-fetcher.js +598 -0
  52. package/dist/client/group-fetcher.js.map +1 -0
  53. package/dist/client/group-outbox.d.ts +172 -10
  54. package/dist/client/group-outbox.d.ts.map +1 -1
  55. package/dist/client/group-outbox.js +915 -74
  56. package/dist/client/group-outbox.js.map +1 -1
  57. package/dist/client/group-receive-authorization.d.ts +127 -4
  58. package/dist/client/group-receive-authorization.d.ts.map +1 -1
  59. package/dist/client/group-receive-authorization.js +270 -20
  60. package/dist/client/group-receive-authorization.js.map +1 -1
  61. package/dist/client/group-sealed-sender.d.ts +3 -0
  62. package/dist/client/group-sealed-sender.d.ts.map +1 -1
  63. package/dist/client/group-sealed-sender.js +1 -0
  64. package/dist/client/group-sealed-sender.js.map +1 -1
  65. package/dist/client/group-sender-key-operations.d.ts +14 -3
  66. package/dist/client/group-sender-key-operations.d.ts.map +1 -1
  67. package/dist/client/group-sender-key-operations.js +26 -5
  68. package/dist/client/group-sender-key-operations.js.map +1 -1
  69. package/dist/client/groups.d.ts +5 -5
  70. package/dist/client/groups.d.ts.map +1 -1
  71. package/dist/client/groups.js +5 -4
  72. package/dist/client/groups.js.map +1 -1
  73. package/dist/client/hosted-anonymous-delivery.d.ts +61 -9
  74. package/dist/client/hosted-anonymous-delivery.d.ts.map +1 -1
  75. package/dist/client/hosted-anonymous-delivery.js +242 -48
  76. package/dist/client/hosted-anonymous-delivery.js.map +1 -1
  77. package/dist/client/hosted-assertion-id.d.ts +7 -0
  78. package/dist/client/hosted-assertion-id.d.ts.map +1 -0
  79. package/dist/client/hosted-assertion-id.js +51 -0
  80. package/dist/client/hosted-assertion-id.js.map +1 -0
  81. package/dist/client/hosted-mailbox-subscription.d.ts +34 -2
  82. package/dist/client/hosted-mailbox-subscription.d.ts.map +1 -1
  83. package/dist/client/hosted-mailbox-subscription.js +87 -17
  84. package/dist/client/hosted-mailbox-subscription.js.map +1 -1
  85. package/dist/client/hosted-push.d.ts +22 -4
  86. package/dist/client/hosted-push.d.ts.map +1 -1
  87. package/dist/client/hosted-push.js +75 -22
  88. package/dist/client/hosted-push.js.map +1 -1
  89. package/dist/client/hosted-transport.d.ts +22 -28
  90. package/dist/client/hosted-transport.d.ts.map +1 -1
  91. package/dist/client/hosted-transport.js +115 -55
  92. package/dist/client/hosted-transport.js.map +1 -1
  93. package/dist/client/hosted.d.ts +10 -4
  94. package/dist/client/hosted.d.ts.map +1 -1
  95. package/dist/client/hosted.js +10 -4
  96. package/dist/client/hosted.js.map +1 -1
  97. package/dist/client/index.d.ts +5 -3
  98. package/dist/client/index.d.ts.map +1 -1
  99. package/dist/client/index.js +2 -0
  100. package/dist/client/index.js.map +1 -1
  101. package/dist/client/messages.d.ts +25 -3
  102. package/dist/client/messages.d.ts.map +1 -1
  103. package/dist/client/messages.js +111 -20
  104. package/dist/client/messages.js.map +1 -1
  105. package/dist/client/receive-admission.d.ts +58 -0
  106. package/dist/client/receive-admission.d.ts.map +1 -0
  107. package/dist/client/receive-admission.js +78 -0
  108. package/dist/client/receive-admission.js.map +1 -0
  109. package/dist/client/receive-expiry.d.ts +31 -0
  110. package/dist/client/receive-expiry.d.ts.map +1 -0
  111. package/dist/client/receive-expiry.js +35 -0
  112. package/dist/client/receive-expiry.js.map +1 -0
  113. package/dist/client/receive-hook-bound.d.ts +50 -0
  114. package/dist/client/receive-hook-bound.d.ts.map +1 -0
  115. package/dist/client/receive-hook-bound.js +115 -0
  116. package/dist/client/receive-hook-bound.js.map +1 -0
  117. package/dist/client/receive-queue.d.ts +299 -0
  118. package/dist/client/receive-queue.d.ts.map +1 -0
  119. package/dist/client/receive-queue.js +1420 -0
  120. package/dist/client/receive-queue.js.map +1 -0
  121. package/dist/client/receive-work-seed.d.ts +54 -0
  122. package/dist/client/receive-work-seed.d.ts.map +1 -0
  123. package/dist/client/receive-work-seed.js +116 -0
  124. package/dist/client/receive-work-seed.js.map +1 -0
  125. package/dist/client/recovery-driver.d.ts +25 -0
  126. package/dist/client/recovery-driver.d.ts.map +1 -0
  127. package/dist/client/recovery-driver.js +121 -0
  128. package/dist/client/recovery-driver.js.map +1 -0
  129. package/dist/client/relay-acceptance.d.ts +20 -7
  130. package/dist/client/relay-acceptance.d.ts.map +1 -1
  131. package/dist/client/relay-acceptance.js +30 -12
  132. package/dist/client/relay-acceptance.js.map +1 -1
  133. package/dist/client/relay-device-refusal.d.ts +18 -0
  134. package/dist/client/relay-device-refusal.d.ts.map +1 -1
  135. package/dist/client/relay-device-refusal.js +31 -0
  136. package/dist/client/relay-device-refusal.js.map +1 -1
  137. package/dist/client/relay-sealed-route.d.ts +36 -0
  138. package/dist/client/relay-sealed-route.d.ts.map +1 -0
  139. package/dist/client/relay-sealed-route.js +45 -0
  140. package/dist/client/relay-sealed-route.js.map +1 -0
  141. package/dist/client/relay-subscription.d.ts +56 -13
  142. package/dist/client/relay-subscription.d.ts.map +1 -1
  143. package/dist/client/relay-subscription.js +193 -123
  144. package/dist/client/relay-subscription.js.map +1 -1
  145. package/dist/client/resendable-content.d.ts +98 -0
  146. package/dist/client/resendable-content.d.ts.map +1 -0
  147. package/dist/client/resendable-content.js +136 -0
  148. package/dist/client/resendable-content.js.map +1 -0
  149. package/dist/client/retry-family.d.ts +57 -10
  150. package/dist/client/retry-family.d.ts.map +1 -1
  151. package/dist/client/retry-family.js +54 -12
  152. package/dist/client/retry-family.js.map +1 -1
  153. package/dist/client/retry-request-envelope.d.ts +107 -8
  154. package/dist/client/retry-request-envelope.d.ts.map +1 -1
  155. package/dist/client/retry-request-envelope.js +172 -23
  156. package/dist/client/retry-request-envelope.js.map +1 -1
  157. package/dist/client/retry-request-lifecycle.d.ts +70 -14
  158. package/dist/client/retry-request-lifecycle.d.ts.map +1 -1
  159. package/dist/client/retry-request-lifecycle.js +162 -32
  160. package/dist/client/retry-request-lifecycle.js.map +1 -1
  161. package/dist/client/retry-terminal-recovery.d.ts +100 -0
  162. package/dist/client/retry-terminal-recovery.d.ts.map +1 -0
  163. package/dist/client/retry-terminal-recovery.js +164 -0
  164. package/dist/client/retry-terminal-recovery.js.map +1 -0
  165. package/dist/client/retry-utils.d.ts +27 -0
  166. package/dist/client/retry-utils.d.ts.map +1 -1
  167. package/dist/client/retry-utils.js +46 -0
  168. package/dist/client/retry-utils.js.map +1 -1
  169. package/dist/client/retry.d.ts +100 -12
  170. package/dist/client/retry.d.ts.map +1 -1
  171. package/dist/client/retry.js +619 -116
  172. package/dist/client/retry.js.map +1 -1
  173. package/dist/client/sealed-sender.d.ts +23 -6
  174. package/dist/client/sealed-sender.d.ts.map +1 -1
  175. package/dist/client/sealed-sender.js +30 -6
  176. package/dist/client/sealed-sender.js.map +1 -1
  177. package/dist/client/sessions.d.ts +2 -2
  178. package/dist/client/sessions.js +2 -2
  179. package/dist/client/signal-service-cipher.d.ts +726 -19
  180. package/dist/client/signal-service-cipher.d.ts.map +1 -1
  181. package/dist/client/signal-service-cipher.js +2260 -342
  182. package/dist/client/signal-service-cipher.js.map +1 -1
  183. package/dist/client/state.d.ts +5 -0
  184. package/dist/client/state.d.ts.map +1 -1
  185. package/dist/client/state.js +11 -1
  186. package/dist/client/state.js.map +1 -1
  187. package/dist/client/storage-protection.d.ts +64 -0
  188. package/dist/client/storage-protection.d.ts.map +1 -0
  189. package/dist/client/storage-protection.js +150 -0
  190. package/dist/client/storage-protection.js.map +1 -0
  191. package/dist/client/types.d.ts +149 -15
  192. package/dist/client/types.d.ts.map +1 -1
  193. package/dist/client/types.js +1 -1
  194. package/dist/client/types.js.map +1 -1
  195. package/dist/device/constants.d.ts +0 -5
  196. package/dist/device/constants.d.ts.map +1 -1
  197. package/dist/device/constants.js +0 -5
  198. package/dist/device/constants.js.map +1 -1
  199. package/dist/device/expo/index.d.ts +4 -17
  200. package/dist/device/expo/index.d.ts.map +1 -1
  201. package/dist/device/expo/index.js +4 -23
  202. package/dist/device/expo/index.js.map +1 -1
  203. package/dist/device/index.d.ts +0 -2
  204. package/dist/device/index.d.ts.map +1 -1
  205. package/dist/device/index.js +0 -7
  206. package/dist/device/index.js.map +1 -1
  207. package/dist/device/lifecycle/manager.d.ts +5 -4
  208. package/dist/device/lifecycle/manager.d.ts.map +1 -1
  209. package/dist/device/lifecycle/manager.js +16 -16
  210. package/dist/device/lifecycle/manager.js.map +1 -1
  211. package/dist/device/lifecycle/types.d.ts +2 -2
  212. package/dist/device/lifecycle/types.d.ts.map +1 -1
  213. package/dist/device/react-native/index.d.ts +4 -15
  214. package/dist/device/react-native/index.d.ts.map +1 -1
  215. package/dist/device/react-native/index.js +4 -21
  216. package/dist/device/react-native/index.js.map +1 -1
  217. package/dist/device/types.d.ts +1 -1
  218. package/dist/groups/index.d.ts +1 -1
  219. package/dist/groups/index.d.ts.map +1 -1
  220. package/dist/index.d.ts +8 -6
  221. package/dist/index.d.ts.map +1 -1
  222. package/dist/index.js +2 -1
  223. package/dist/index.js.map +1 -1
  224. package/dist/internal/crypto/ec/x25519-validation.d.ts +0 -1
  225. package/dist/internal/crypto/ec/x25519-validation.d.ts.map +1 -1
  226. package/dist/internal/crypto/ec/x25519-validation.js +0 -1
  227. package/dist/internal/crypto/ec/x25519-validation.js.map +1 -1
  228. package/dist/internal/crypto/validation.d.ts +2 -2
  229. package/dist/internal/groups/index.d.ts +1 -0
  230. package/dist/internal/groups/index.d.ts.map +1 -1
  231. package/dist/internal/groups/index.js +1 -0
  232. package/dist/internal/groups/index.js.map +1 -1
  233. package/dist/internal/groups/manager.d.ts +37 -16
  234. package/dist/internal/groups/manager.d.ts.map +1 -1
  235. package/dist/internal/groups/manager.js +46 -1
  236. package/dist/internal/groups/manager.js.map +1 -1
  237. package/dist/internal/groups/receive-record.d.ts +78 -0
  238. package/dist/internal/groups/receive-record.d.ts.map +1 -0
  239. package/dist/internal/groups/receive-record.js +43 -0
  240. package/dist/internal/groups/receive-record.js.map +1 -0
  241. package/dist/internal/groups/sdk-store.d.ts +27 -3
  242. package/dist/internal/groups/sdk-store.d.ts.map +1 -1
  243. package/dist/internal/groups/sdk-store.js +151 -19
  244. package/dist/internal/groups/sdk-store.js.map +1 -1
  245. package/dist/internal/groups/wire.d.ts +12 -1
  246. package/dist/internal/groups/wire.d.ts.map +1 -1
  247. package/dist/internal/groups/wire.js +36 -0
  248. package/dist/internal/groups/wire.js.map +1 -1
  249. package/dist/internal/manager/index.d.ts +1 -1
  250. package/dist/internal/manager/manager.d.ts +26 -20
  251. package/dist/internal/manager/manager.d.ts.map +1 -1
  252. package/dist/internal/manager/manager.js +64 -41
  253. package/dist/internal/manager/manager.js.map +1 -1
  254. package/dist/internal/protocol/double-ratchet/chains.d.ts +4 -18
  255. package/dist/internal/protocol/double-ratchet/chains.d.ts.map +1 -1
  256. package/dist/internal/protocol/double-ratchet/chains.js +23 -74
  257. package/dist/internal/protocol/double-ratchet/chains.js.map +1 -1
  258. package/dist/internal/protocol/double-ratchet/index.d.ts +1 -1
  259. package/dist/internal/protocol/double-ratchet/index.d.ts.map +1 -1
  260. package/dist/internal/protocol/double-ratchet/index.js +1 -1
  261. package/dist/internal/protocol/double-ratchet/index.js.map +1 -1
  262. package/dist/internal/protocol/double-ratchet/ratchet.d.ts +5 -7
  263. package/dist/internal/protocol/double-ratchet/ratchet.d.ts.map +1 -1
  264. package/dist/internal/protocol/double-ratchet/ratchet.js +4 -6
  265. package/dist/internal/protocol/double-ratchet/ratchet.js.map +1 -1
  266. package/dist/internal/protocol/pqxdh/pqxdh.d.ts.map +1 -1
  267. package/dist/internal/protocol/pqxdh/pqxdh.js +2 -1
  268. package/dist/internal/protocol/pqxdh/pqxdh.js.map +1 -1
  269. package/dist/internal/protocol/sealed-sender/types.d.ts +6 -8
  270. package/dist/internal/protocol/sealed-sender/types.d.ts.map +1 -1
  271. package/dist/internal/protocol/sealed-sender/types.js +8 -9
  272. package/dist/internal/protocol/sealed-sender/types.js.map +1 -1
  273. package/dist/internal/protocol/sender-keys/handoff-ledger.d.ts +110 -0
  274. package/dist/internal/protocol/sender-keys/handoff-ledger.d.ts.map +1 -0
  275. package/dist/internal/protocol/sender-keys/handoff-ledger.js +124 -0
  276. package/dist/internal/protocol/sender-keys/handoff-ledger.js.map +1 -0
  277. package/dist/internal/protocol/sender-keys/manager.d.ts +71 -62
  278. package/dist/internal/protocol/sender-keys/manager.d.ts.map +1 -1
  279. package/dist/internal/protocol/sender-keys/manager.js +228 -175
  280. package/dist/internal/protocol/sender-keys/manager.js.map +1 -1
  281. package/dist/internal/protocol/spqr/index.d.ts +2 -2
  282. package/dist/internal/protocol/spqr/index.d.ts.map +1 -1
  283. package/dist/internal/protocol/spqr/index.js +2 -2
  284. package/dist/internal/protocol/spqr/index.js.map +1 -1
  285. package/dist/internal/protocol/spqr/serialize.d.ts +9 -1
  286. package/dist/internal/protocol/spqr/serialize.d.ts.map +1 -1
  287. package/dist/internal/protocol/spqr/serialize.js +56 -16
  288. package/dist/internal/protocol/spqr/serialize.js.map +1 -1
  289. package/dist/internal/protocol/spqr/spqr.d.ts +1 -14
  290. package/dist/internal/protocol/spqr/spqr.d.ts.map +1 -1
  291. package/dist/internal/protocol/spqr/spqr.js +54 -42
  292. package/dist/internal/protocol/spqr/spqr.js.map +1 -1
  293. package/dist/internal/protocol/spqr/validate.d.ts +26 -6
  294. package/dist/internal/protocol/spqr/validate.d.ts.map +1 -1
  295. package/dist/internal/protocol/spqr/validate.js +49 -21
  296. package/dist/internal/protocol/spqr/validate.js.map +1 -1
  297. package/dist/internal/sesame/index.d.ts +1 -1
  298. package/dist/internal/sesame/index.d.ts.map +1 -1
  299. package/dist/internal/sesame/index.js.map +1 -1
  300. package/dist/internal/sesame/manager.d.ts +66 -13
  301. package/dist/internal/sesame/manager.d.ts.map +1 -1
  302. package/dist/internal/sesame/manager.js +221 -87
  303. package/dist/internal/sesame/manager.js.map +1 -1
  304. package/dist/internal/sesame/types.d.ts +95 -17
  305. package/dist/internal/sesame/types.d.ts.map +1 -1
  306. package/dist/internal/sesame/types.js +17 -0
  307. package/dist/internal/sesame/types.js.map +1 -1
  308. package/dist/internal/session/builder.d.ts +5 -5
  309. package/dist/internal/session/builder.d.ts.map +1 -1
  310. package/dist/internal/session/builder.js +12 -17
  311. package/dist/internal/session/builder.js.map +1 -1
  312. package/dist/internal/session/cipher.d.ts +15 -13
  313. package/dist/internal/session/cipher.d.ts.map +1 -1
  314. package/dist/internal/session/cipher.js +41 -23
  315. package/dist/internal/session/cipher.js.map +1 -1
  316. package/dist/internal/session/factory.d.ts +5 -5
  317. package/dist/internal/session/factory.d.ts.map +1 -1
  318. package/dist/internal/session/factory.js +4 -4
  319. package/dist/internal/session/factory.js.map +1 -1
  320. package/dist/internal/session/handshake.d.ts +14 -16
  321. package/dist/internal/session/handshake.d.ts.map +1 -1
  322. package/dist/internal/session/handshake.js +18 -75
  323. package/dist/internal/session/handshake.js.map +1 -1
  324. package/dist/internal/session/index.d.ts +1 -1
  325. package/dist/internal/session/index.js +1 -1
  326. package/dist/internal/session/record-locks.d.ts +17 -6
  327. package/dist/internal/session/record-locks.d.ts.map +1 -1
  328. package/dist/internal/session/record-locks.js +43 -7
  329. package/dist/internal/session/record-locks.js.map +1 -1
  330. package/dist/internal/session/session-resolver.d.ts +1 -1
  331. package/dist/internal/session/session-resolver.js +1 -1
  332. package/dist/internal/session/state.d.ts +2 -2
  333. package/dist/internal/session/state.js +1 -1
  334. package/dist/internal/session/types.d.ts +5 -13
  335. package/dist/internal/session/types.d.ts.map +1 -1
  336. package/dist/internal/session/types.js +1 -1
  337. package/dist/keys/generation.d.ts +2 -2
  338. package/dist/keys/generation.js +2 -2
  339. package/dist/keys/types.d.ts +5 -5
  340. package/dist/keys/types.d.ts.map +1 -1
  341. package/dist/keys/types.js +1 -1
  342. package/dist/layers.d.ts +1 -1
  343. package/dist/layers.js +2 -2
  344. package/dist/layers.js.map +1 -1
  345. package/dist/local/store/expo/adapter.d.ts.map +1 -1
  346. package/dist/local/store/expo/adapter.js +12 -8
  347. package/dist/local/store/expo/adapter.js.map +1 -1
  348. package/dist/local/store/key-value/adapter.d.ts +76 -10
  349. package/dist/local/store/key-value/adapter.d.ts.map +1 -1
  350. package/dist/local/store/key-value/adapter.js +367 -61
  351. package/dist/local/store/key-value/adapter.js.map +1 -1
  352. package/dist/local/store/key-value/backend-conformance.d.ts.map +1 -1
  353. package/dist/local/store/key-value/backend-conformance.js +74 -0
  354. package/dist/local/store/key-value/backend-conformance.js.map +1 -1
  355. package/dist/local/store/key-value/batch.d.ts +2 -0
  356. package/dist/local/store/key-value/batch.d.ts.map +1 -1
  357. package/dist/local/store/key-value/batch.js +26 -0
  358. package/dist/local/store/key-value/batch.js.map +1 -1
  359. package/dist/local/store/key-value/receive-work.d.ts +55 -0
  360. package/dist/local/store/key-value/receive-work.d.ts.map +1 -0
  361. package/dist/local/store/key-value/receive-work.js +162 -0
  362. package/dist/local/store/key-value/receive-work.js.map +1 -0
  363. package/dist/local/store/key-value/send-log.d.ts +61 -0
  364. package/dist/local/store/key-value/send-log.d.ts.map +1 -0
  365. package/dist/local/store/key-value/send-log.js +430 -0
  366. package/dist/local/store/key-value/send-log.js.map +1 -0
  367. package/dist/local/store/key-value/sender-key-handoff.d.ts +68 -0
  368. package/dist/local/store/key-value/sender-key-handoff.d.ts.map +1 -0
  369. package/dist/local/store/key-value/sender-key-handoff.js +189 -0
  370. package/dist/local/store/key-value/sender-key-handoff.js.map +1 -0
  371. package/dist/local/store/key-value/storage.d.ts +15 -0
  372. package/dist/local/store/key-value/storage.d.ts.map +1 -1
  373. package/dist/local/store/keyed-index.d.ts +23 -0
  374. package/dist/local/store/keyed-index.d.ts.map +1 -0
  375. package/dist/local/store/keyed-index.js +41 -0
  376. package/dist/local/store/keyed-index.js.map +1 -0
  377. package/dist/local/store/memory/adapter.d.ts +44 -12
  378. package/dist/local/store/memory/adapter.d.ts.map +1 -1
  379. package/dist/local/store/memory/adapter.js +197 -46
  380. package/dist/local/store/memory/adapter.js.map +1 -1
  381. package/dist/local/store/memory/send-log.d.ts +42 -0
  382. package/dist/local/store/memory/send-log.d.ts.map +1 -0
  383. package/dist/local/store/memory/send-log.js +190 -0
  384. package/dist/local/store/memory/send-log.js.map +1 -0
  385. package/dist/local/store/node/adapter.d.ts.map +1 -1
  386. package/dist/local/store/node/adapter.js +8 -6
  387. package/dist/local/store/node/adapter.js.map +1 -1
  388. package/dist/local/store/react-native/adapter.d.ts.map +1 -1
  389. package/dist/local/store/react-native/adapter.js +12 -8
  390. package/dist/local/store/react-native/adapter.js.map +1 -1
  391. package/dist/local/store/receive-work.d.ts +87 -0
  392. package/dist/local/store/receive-work.d.ts.map +1 -0
  393. package/dist/local/store/receive-work.js +204 -0
  394. package/dist/local/store/receive-work.js.map +1 -0
  395. package/dist/local/store/received-content.d.ts +3 -3
  396. package/dist/local/store/received-content.d.ts.map +1 -1
  397. package/dist/local/store/received-content.js +2 -11
  398. package/dist/local/store/received-content.js.map +1 -1
  399. package/dist/local/store/reliability.d.ts +317 -18
  400. package/dist/local/store/reliability.d.ts.map +1 -1
  401. package/dist/local/store/reliability.js +371 -46
  402. package/dist/local/store/reliability.js.map +1 -1
  403. package/dist/local/store/send-log-order.d.ts +15 -0
  404. package/dist/local/store/send-log-order.d.ts.map +1 -0
  405. package/dist/local/store/send-log-order.js +24 -0
  406. package/dist/local/store/send-log-order.js.map +1 -0
  407. package/dist/local/store/sender-key-handoff-index.d.ts +38 -0
  408. package/dist/local/store/sender-key-handoff-index.d.ts.map +1 -0
  409. package/dist/local/store/sender-key-handoff-index.js +101 -0
  410. package/dist/local/store/sender-key-handoff-index.js.map +1 -0
  411. package/dist/local/store/sender-key-handoff-table.d.ts +29 -0
  412. package/dist/local/store/sender-key-handoff-table.d.ts.map +1 -0
  413. package/dist/local/store/sender-key-handoff-table.js +97 -0
  414. package/dist/local/store/sender-key-handoff-table.js.map +1 -0
  415. package/dist/local/store/sqlite/driver.d.ts +9 -0
  416. package/dist/local/store/sqlite/driver.d.ts.map +1 -1
  417. package/dist/local/store/sqlite/encryption.d.ts +8 -1
  418. package/dist/local/store/sqlite/encryption.d.ts.map +1 -1
  419. package/dist/local/store/sqlite/encryption.js +9 -0
  420. package/dist/local/store/sqlite/encryption.js.map +1 -1
  421. package/dist/local/store/sqlite/key-storage/index.d.ts +25 -4
  422. package/dist/local/store/sqlite/key-storage/index.d.ts.map +1 -1
  423. package/dist/local/store/sqlite/key-storage/index.js +68 -7
  424. package/dist/local/store/sqlite/key-storage/index.js.map +1 -1
  425. package/dist/local/store/sqlite/key-storage/message-records.d.ts +16 -4
  426. package/dist/local/store/sqlite/key-storage/message-records.d.ts.map +1 -1
  427. package/dist/local/store/sqlite/key-storage/message-records.js +49 -6
  428. package/dist/local/store/sqlite/key-storage/message-records.js.map +1 -1
  429. package/dist/local/store/sqlite/key-storage/metadata.d.ts +8 -7
  430. package/dist/local/store/sqlite/key-storage/metadata.d.ts.map +1 -1
  431. package/dist/local/store/sqlite/key-storage/metadata.js +17 -15
  432. package/dist/local/store/sqlite/key-storage/metadata.js.map +1 -1
  433. package/dist/local/store/sqlite/key-storage/receive-work.d.ts +27 -0
  434. package/dist/local/store/sqlite/key-storage/receive-work.d.ts.map +1 -0
  435. package/dist/local/store/sqlite/key-storage/receive-work.js +98 -0
  436. package/dist/local/store/sqlite/key-storage/receive-work.js.map +1 -0
  437. package/dist/local/store/sqlite/key-storage/send-log.d.ts +27 -0
  438. package/dist/local/store/sqlite/key-storage/send-log.d.ts.map +1 -0
  439. package/dist/local/store/sqlite/key-storage/send-log.js +178 -0
  440. package/dist/local/store/sqlite/key-storage/send-log.js.map +1 -0
  441. package/dist/local/store/sqlite/key-storage/sender-key-handoff.d.ts +27 -0
  442. package/dist/local/store/sqlite/key-storage/sender-key-handoff.d.ts.map +1 -0
  443. package/dist/local/store/sqlite/key-storage/sender-key-handoff.js +75 -0
  444. package/dist/local/store/sqlite/key-storage/sender-key-handoff.js.map +1 -0
  445. package/dist/local/store/sqlite/key-storage/session-trust.d.ts +2 -2
  446. package/dist/local/store/sqlite/key-storage/session-trust.js +5 -5
  447. package/dist/local/store/sqlite/key-storage/session-trust.js.map +1 -1
  448. package/dist/local/store/sqlite/migrations.d.ts.map +1 -1
  449. package/dist/local/store/sqlite/migrations.js +101 -0
  450. package/dist/local/store/sqlite/migrations.js.map +1 -1
  451. package/dist/local/store/sqlite/models/index.d.ts +2 -1
  452. package/dist/local/store/sqlite/models/index.d.ts.map +1 -1
  453. package/dist/local/store/sqlite/models/index.js +5 -1
  454. package/dist/local/store/sqlite/models/index.js.map +1 -1
  455. package/dist/local/store/sqlite/models/message-record.d.ts +15 -0
  456. package/dist/local/store/sqlite/models/message-record.d.ts.map +1 -1
  457. package/dist/local/store/sqlite/models/message-record.js +24 -0
  458. package/dist/local/store/sqlite/models/message-record.js.map +1 -1
  459. package/dist/local/store/sqlite/models/send-log.d.ts +51 -0
  460. package/dist/local/store/sqlite/models/send-log.d.ts.map +1 -0
  461. package/dist/local/store/sqlite/models/send-log.js +206 -0
  462. package/dist/local/store/sqlite/models/send-log.js.map +1 -0
  463. package/dist/local/store/sqlite/open-store.d.ts +9 -1
  464. package/dist/local/store/sqlite/open-store.d.ts.map +1 -1
  465. package/dist/local/store/sqlite/open-store.js +20 -1
  466. package/dist/local/store/sqlite/open-store.js.map +1 -1
  467. package/dist/local/store/sqlite/schema.d.ts +34 -1
  468. package/dist/local/store/sqlite/schema.d.ts.map +1 -1
  469. package/dist/local/store/sqlite/schema.js +14 -0
  470. package/dist/local/store/sqlite/schema.js.map +1 -1
  471. package/dist/local/store/sqlite/store.d.ts +61 -11
  472. package/dist/local/store/sqlite/store.d.ts.map +1 -1
  473. package/dist/local/store/sqlite/store.js +191 -27
  474. package/dist/local/store/sqlite/store.js.map +1 -1
  475. package/dist/local/store/sqlite/web/sqlite3mc/sqlite3.mjs +2 -1
  476. package/dist/local/store/sqlite/web/worker.d.ts +8 -0
  477. package/dist/local/store/sqlite/web/worker.d.ts.map +1 -1
  478. package/dist/local/store/sqlite/web/worker.js +64 -2
  479. package/dist/local/store/sqlite/web/worker.js.map +1 -1
  480. package/dist/local/store/web/adapter.d.ts +76 -8
  481. package/dist/local/store/web/adapter.d.ts.map +1 -1
  482. package/dist/local/store/web/adapter.js +579 -127
  483. package/dist/local/store/web/adapter.js.map +1 -1
  484. package/dist/local/store/web/receive-work.d.ts +57 -0
  485. package/dist/local/store/web/receive-work.d.ts.map +1 -0
  486. package/dist/local/store/web/receive-work.js +99 -0
  487. package/dist/local/store/web/receive-work.js.map +1 -0
  488. package/dist/local/store/web/send-log.d.ts +92 -0
  489. package/dist/local/store/web/send-log.d.ts.map +1 -0
  490. package/dist/local/store/web/send-log.js +267 -0
  491. package/dist/local/store/web/send-log.js.map +1 -0
  492. package/dist/local/store/web/sender-key-handoff.d.ts +81 -0
  493. package/dist/local/store/web/sender-key-handoff.d.ts.map +1 -0
  494. package/dist/local/store/web/sender-key-handoff.js +156 -0
  495. package/dist/local/store/web/sender-key-handoff.js.map +1 -0
  496. package/dist/local/store/web-sqlite/adapter.d.ts +2 -0
  497. package/dist/local/store/web-sqlite/adapter.d.ts.map +1 -1
  498. package/dist/local/store/web-sqlite/adapter.js +12 -6
  499. package/dist/local/store/web-sqlite/adapter.js.map +1 -1
  500. package/dist/local/vault/custody.d.ts +8 -0
  501. package/dist/local/vault/custody.d.ts.map +1 -0
  502. package/dist/local/vault/custody.js +9 -0
  503. package/dist/local/vault/custody.js.map +1 -0
  504. package/dist/local/vault/electron-safe-storage.d.ts +3 -1
  505. package/dist/local/vault/electron-safe-storage.d.ts.map +1 -1
  506. package/dist/local/vault/electron-safe-storage.js +2 -0
  507. package/dist/local/vault/electron-safe-storage.js.map +1 -1
  508. package/dist/local/vault/expo-secure-store.d.ts +3 -1
  509. package/dist/local/vault/expo-secure-store.d.ts.map +1 -1
  510. package/dist/local/vault/expo-secure-store.js +2 -0
  511. package/dist/local/vault/expo-secure-store.js.map +1 -1
  512. package/dist/local/vault/indexed-db.d.ts +3 -1
  513. package/dist/local/vault/indexed-db.d.ts.map +1 -1
  514. package/dist/local/vault/indexed-db.js +2 -0
  515. package/dist/local/vault/indexed-db.js.map +1 -1
  516. package/dist/local/vault/react-native-keychain.d.ts +3 -1
  517. package/dist/local/vault/react-native-keychain.d.ts.map +1 -1
  518. package/dist/local/vault/react-native-keychain.js +2 -0
  519. package/dist/local/vault/react-native-keychain.js.map +1 -1
  520. package/dist/remote/relay/device-set.d.ts +94 -0
  521. package/dist/remote/relay/device-set.d.ts.map +1 -0
  522. package/dist/remote/relay/device-set.js +156 -0
  523. package/dist/remote/relay/device-set.js.map +1 -0
  524. package/dist/remote/relay/types.d.ts +92 -107
  525. package/dist/remote/relay/types.d.ts.map +1 -1
  526. package/dist/safety/core.d.ts +15 -6
  527. package/dist/safety/core.d.ts.map +1 -1
  528. package/dist/safety/core.js +41 -27
  529. package/dist/safety/core.js.map +1 -1
  530. package/dist/safety/index.d.ts +2 -1
  531. package/dist/safety/index.d.ts.map +1 -1
  532. package/dist/safety/index.js +12 -18
  533. package/dist/safety/index.js.map +1 -1
  534. package/dist/types/api.d.ts +707 -62
  535. package/dist/types/api.d.ts.map +1 -1
  536. package/dist/types/errors.d.ts +14 -33
  537. package/dist/types/errors.d.ts.map +1 -1
  538. package/dist/types/errors.js +14 -24
  539. package/dist/types/errors.js.map +1 -1
  540. package/dist/types/messages.d.ts +2 -2
  541. package/dist/types/messages.js +1 -1
  542. package/dist/types/protocol-config.d.ts +175 -42
  543. package/dist/types/protocol-config.d.ts.map +1 -1
  544. package/dist/types/protocol-config.js +19 -38
  545. package/dist/types/protocol-config.js.map +1 -1
  546. package/dist/types/protocol-constants.d.ts +6 -6
  547. package/dist/types/protocol-constants.js +6 -6
  548. package/dist/types/session.d.ts +7 -7
  549. package/dist/types/session.d.ts.map +1 -1
  550. package/dist/types/session.js +39 -21
  551. package/dist/types/session.js.map +1 -1
  552. package/dist/username/link.d.ts +2 -2
  553. package/dist/username/link.js +2 -2
  554. package/dist/utils/origin-lock.d.ts +45 -0
  555. package/dist/utils/origin-lock.d.ts.map +1 -0
  556. package/dist/utils/origin-lock.js +80 -0
  557. package/dist/utils/origin-lock.js.map +1 -0
  558. package/docs/ASSURANCE.md +6 -6
  559. package/docs/CLIENT_COMPOSITION.md +2 -2
  560. package/docs/DEVIATIONS.md +677 -182
  561. package/docs/E2EE.md +1 -1
  562. package/docs/ERROR_HANDLING.md +165 -2
  563. package/docs/GETTING_STARTED.md +7 -4
  564. package/docs/INTERFACES.md +1 -1
  565. package/docs/PACKAGE_SURFACE.md +6 -5
  566. package/docs/PROTOCOL_POLICY.md +102 -22
  567. package/docs/RECIPES.md +3 -15
  568. package/docs/SECURITY.md +90 -5
  569. package/keys/README.md +3 -3
  570. package/local/store/README.md +78 -14
  571. package/local/store/key-value/README.md +14 -3
  572. package/local/store/node/README.md +8 -3
  573. package/local/store/web/README.md +9 -0
  574. package/local/store/web-sqlite/README.md +14 -2
  575. package/local/vault/README.md +21 -0
  576. package/package.json +1 -6
  577. package/remote/README.md +0 -1
  578. package/remote/relay/README.md +2 -2
  579. package/dist/device/provisioning.d.ts +0 -242
  580. package/dist/device/provisioning.d.ts.map +0 -1
  581. package/dist/device/provisioning.js +0 -421
  582. package/dist/device/provisioning.js.map +0 -1
  583. package/dist/internal/protocol/x3dh/index.d.ts +0 -15
  584. package/dist/internal/protocol/x3dh/index.d.ts.map +0 -1
  585. package/dist/internal/protocol/x3dh/index.js +0 -13
  586. package/dist/internal/protocol/x3dh/index.js.map +0 -1
  587. package/dist/internal/protocol/x3dh/x3dh.d.ts +0 -131
  588. package/dist/internal/protocol/x3dh/x3dh.d.ts.map +0 -1
  589. package/dist/internal/protocol/x3dh/x3dh.js +0 -261
  590. package/dist/internal/protocol/x3dh/x3dh.js.map +0 -1
@@ -14,18 +14,20 @@
14
14
  */
15
15
  import type { SignalProtocolRelayServer, Envelope, GroupMemberDevice } from '../remote/relay/types.js';
16
16
  import type { SignalProtocolRemoteObjectStore } from '../remote/object-store/index.js';
17
- import type { SignalProtocolLocalStore } from '../types/index.js';
17
+ import type { SignalProtocolLocalStore, ReceiveWorkRecord, ReceiveWorkSeed } from '../types/index.js';
18
+ import type { SenderKeyHandoffDevice } from '../types/api.js';
18
19
  import type { DecryptedEnvelope } from './event-hooks.js';
19
- import type { SesameManager, SesameMessage } from '../internal/sesame/types.js';
20
+ import { type SesameManager, type SesameMessage } from '../internal/sesame/types.js';
20
21
  import { type Logger } from '../logger.js';
21
- import { SenderKeyManager } from '../internal/protocol/sender-keys/index.js';
22
+ import { SenderKeyManager, type SenderKeyDistributionMessage } from '../internal/protocol/sender-keys/index.js';
22
23
  import type { EndorsementManager } from './endorsement-manager.js';
23
- import type { GroupReceiveAuthorizer } from './group-receive-authorization.js';
24
+ import { GroupReceiveRefusedError, GroupReceiveUnavailableError, type GroupReceiveEvaluator } from './group-receive-authorization.js';
24
25
  import type { PreparedAttachmentUpload, SealedReceipt, SendOptions, SendResult } from './types.js';
25
26
  import { ContentHint } from '../types/messages.js';
26
- 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';
27
+ import { type BlockedRecipientsSyncInput, type ConfigurationSyncInput, type GroupContentContext, type InspectedSignalProtocolContent, type MediaAttachmentDeleteSyncInput, type ReadSyncEntryInput, type RecipientUsernameSyncInput, type SignalProtocolContentAdapter, type TaskNotificationAckSyncInput, type UsernameStateSyncInput, type VerificationStateSyncInput, type ViewOnceOpenSyncInput } from './content-adapter.js';
27
28
  import { type RetryResendTarget } from '../local/store/reliability.js';
28
29
  import { type BoundedFanOut } from '../utils/bounded-fan-out.js';
30
+ import { RelayProtocolError } from './device-set-reconciliation.js';
29
31
  import { type SealedSenderProvider as SealedSenderProviderContract } from './sealed-sender.js';
30
32
  import { type ContactProfileStateStore } from '../profile/contact-state.js';
31
33
  /**
@@ -37,6 +39,11 @@ export declare const RECIPIENT_DEVICE_LIST_FRESH_MILLISECONDS = 60000;
37
39
  export declare function sortEnvelopesForDecryption<T extends {
38
40
  messageType?: string;
39
41
  }>(envelopes: T[]): T[];
42
+ /**
43
+ * Give a send error the logical-send identifier of its send, so
44
+ * `isOutgoingMessageError` is true for it.
45
+ */
46
+ export declare function attachClientMessageId(error: unknown, clientMessageId: string): Error;
40
47
  /**
41
48
  * Sealed sender context provider callback
42
49
  *
@@ -97,6 +104,98 @@ export interface SendSessionCallbacks {
97
104
  */
98
105
  export type EndorsementRefresher = (groupId: string, memberUserIds: string[]) => Promise<boolean>;
99
106
  export type GroupSendBarrierChecker = (groupId: string) => Promise<void>;
107
+ /**
108
+ * The receive record that a decrypt commits with its ratchet step, and the
109
+ * admission that runs the decrypt.
110
+ */
111
+ export interface ReceiveCommit {
112
+ /** The receive record ID: the delivered fingerprint of the envelope. */
113
+ readonly workId: string;
114
+ /**
115
+ * Build the record seed for the envelope that the decrypt opens. The
116
+ * envelope is the inner envelope of a seal. It never throws.
117
+ */
118
+ readonly seed: (envelope: Envelope, arrivedSealed: boolean) => ReceiveWorkSeed;
119
+ /**
120
+ * Run the decrypt under the receive admission. Null when the queue has no
121
+ * room: then nothing is decrypted.
122
+ *
123
+ * @param groupId - The raw group of a sender-key message, or null
124
+ */
125
+ readonly admit: <T>(groupId: string | null, decrypt: () => Promise<T>) => Promise<{
126
+ value: T;
127
+ } | null>;
128
+ }
129
+ /** The options of one envelope commit. */
130
+ export interface EnvelopeCommitOptions {
131
+ /** The trust roots of an unidentified_sender envelope. */
132
+ sealedSender?: import('./config.js').SealedSenderConfig | undefined;
133
+ /** When it aborts while the commit waits for a lock, the commit throws RelayWorkStopped. */
134
+ stopSignal?: AbortSignal | undefined;
135
+ /** The receive record to commit. Without it, the decrypt commits no record. */
136
+ work?: ReceiveCommit | undefined;
137
+ }
138
+ /** The sender of committed content. */
139
+ export interface CommittedSender {
140
+ /** The envelope ID, or the sender and the admission time for an envelope with no ID. */
141
+ readonly messageId: string;
142
+ readonly senderUserId: string;
143
+ readonly senderDeviceId: number;
144
+ }
145
+ /** Content that a decrypt committed, checked, and whose distribution installed. */
146
+ export interface CommittedContent extends CommittedSender {
147
+ readonly messageType: DecryptedEnvelope['messageType'];
148
+ readonly serverTimestamp?: number;
149
+ readonly arrivedSealed: boolean;
150
+ readonly plaintext: string;
151
+ readonly inspected: InspectedSignalProtocolContent;
152
+ /** The raw group of the sender key that decrypted the content, or null. */
153
+ readonly transportGroupId: string | null;
154
+ /** The raw group of a distribution that the content carries, or null. */
155
+ readonly distributionGroupId: string | null;
156
+ /** The time of the first durable admission. */
157
+ readonly receivedAt: number;
158
+ }
159
+ /** The result of one envelope commit. */
160
+ export type EnvelopeCommit = {
161
+ readonly kind: 'committed';
162
+ /** The committed receive record. Null with no `work`. */
163
+ readonly record: ReceiveWorkRecord | null;
164
+ /** True when a stored record gave the content, with no ratchet step. */
165
+ readonly reused: boolean;
166
+ readonly content: CommittedContent;
167
+ }
168
+ /** The queue has no room. Nothing is decrypted. */
169
+ | {
170
+ readonly kind: 'refused';
171
+ }
172
+ /** The record holds no content any more: the application got it. */
173
+ | {
174
+ readonly kind: 'settled';
175
+ readonly record: ReceiveWorkRecord;
176
+ }
177
+ /**
178
+ * The content failed a check after its commit. The ratchet step is spent,
179
+ * and no distribution installed.
180
+ */
181
+ | ({
182
+ readonly kind: 'denied';
183
+ readonly error: Error;
184
+ readonly record: ReceiveWorkRecord | null;
185
+ } & CommittedSender);
186
+ /** The group decision on committed content. */
187
+ export type GroupContentDecision = {
188
+ readonly kind: 'authorized';
189
+ readonly groupId: string | null;
190
+ } | {
191
+ readonly kind: 'denied';
192
+ readonly error: GroupReceiveRefusedError;
193
+ } | {
194
+ readonly kind: 'unavailable';
195
+ readonly error: GroupReceiveUnavailableError;
196
+ /** The raw group whose state must update first. */
197
+ readonly groupId: string;
198
+ };
100
199
  /**
101
200
  * SignalProtocolServiceCipher - Routes encryption and decryption to appropriate ciphers
102
201
  *
@@ -130,24 +229,61 @@ export declare class SignalProtocolServiceCipher {
130
229
  private readonly fanOut;
131
230
  private readonly lock;
132
231
  private readonly groupSenderKeys;
232
+ private readonly senderKeyHandoffs;
133
233
  private sessionCallbacks?;
134
234
  private readonly recipientDeviceListCheckedAt;
135
235
  private sealedSenderProvider?;
136
236
  private sealedSenderDeliveryMode;
137
237
  private sealedSenderIdentifiedFallback?;
238
+ private relayProtocolErrorReporter?;
138
239
  private contactProfileStateStore?;
139
240
  private endorsementManager?;
140
241
  private endorsementManagerResolver?;
141
242
  private endorsementRefresher?;
142
243
  private groupSendBarrierChecker?;
143
- private groupReceiveAuthorizer?;
244
+ private groupReceiveEvaluator?;
144
245
  private groupSecretParamsProvider?;
246
+ private groupContextProvider?;
145
247
  constructor(userId: string, deviceId: number, sesameManager: SesameManager, senderKeyManager: SenderKeyManager, storage: SignalProtocolLocalStore, relay?: SignalProtocolRelayServer | undefined, remoteObjectStore?: SignalProtocolRemoteObjectStore | undefined, contentAdapter?: SignalProtocolContentAdapter | undefined, logger?: Required<Logger>, fanOut?: BoundedFanOut);
146
248
  private getResolvedContentAdapter;
147
249
  private getDirectConversationId;
148
250
  private buildSentSyncTranscript;
149
251
  private encodeLosslessPlaintext;
150
252
  private uploadSyncMessages;
253
+ /** A stored sync copy that names the registration of the own device's current session. */
254
+ private prepareStoredSyncMessage;
255
+ /**
256
+ * Post one sync copy to an own device, identified, with the registration
257
+ * of the device's session. When the relay refuses the device as stale, the
258
+ * session of the device is refreshed once, `repair.rebuild` encrypts the
259
+ * transcript again for the device, the new copy replaces the refused copy
260
+ * in the intent named by `repair.intentId`, and the new copy is posted
261
+ * under a repair ID. When the relay refuses the new copy as stale too, the
262
+ * session of the device is archived, the copy leaves the intent, and a
263
+ * warning is logged. The post then resolves, so the send completes without
264
+ * the copy.
265
+ *
266
+ * @throws {EncryptionError} SESSION_ESTABLISHMENT_FAILED when the refresh
267
+ * fails or the rebuild gives the device no copy. The copy stays in the
268
+ * intent, so a replay posts it again.
269
+ */
270
+ private postSyncMessage;
271
+ /**
272
+ * Refresh the session of an own device that refused a sync copy as stale,
273
+ * encrypt the transcript again for the device, and replace the stored copy
274
+ * before its post. The refused ciphertext is never posted again.
275
+ *
276
+ * @throws {EncryptionError} SESSION_ESTABLISHMENT_FAILED when the refresh
277
+ * fails or the rebuild gives the device no copy. The stored copy stays,
278
+ * and the refreshed session is not archived.
279
+ */
280
+ private repairRefusedSyncCopyInTurn;
281
+ /**
282
+ * Send one relay request of a sync copy to an own device.
283
+ *
284
+ * @returns The relay receipt of the post
285
+ */
286
+ private postSyncCopy;
151
287
  /**
152
288
  * Run one relay phase of a send: a task for each device message, at the same
153
289
  * time, under the client's relay request bound. Every device is attempted.
@@ -189,7 +325,19 @@ export declare class SignalProtocolServiceCipher {
189
325
  setSealedSenderProvider(provider: SealedSenderProvider): void;
190
326
  setSealedSenderDeliveryMode(mode: import('./config.js').SealedSenderDeliveryMode): void;
191
327
  setSealedSenderIdentifiedFallback(callback: NonNullable<import('./config.js').SealedSenderConfig['onIdentifiedFallback']>): void;
328
+ /**
329
+ * Set the reporter of a protocol error that no send result carries.
330
+ * Called by SignalProtocolClient after construction. A sync payload has no
331
+ * send result, so the reporter gives its error to the app.
332
+ */
333
+ setRelayProtocolErrorReporter(report: (error: RelayProtocolError) => Promise<void>): void;
192
334
  private reportIdentifiedFallback;
335
+ /**
336
+ * Restrict the cached unidentified access mode of a recipient after the
337
+ * relay rejects a sealed-sender authorization. A failure to update the mode
338
+ * does not block delivery.
339
+ */
340
+ private restrictUnidentifiedAccessMode;
193
341
  private useIdentifiedDeliveryOrThrow;
194
342
  setContactProfileStateStore(store: ContactProfileStateStore): void;
195
343
  /**
@@ -221,22 +369,131 @@ export declare class SignalProtocolServiceCipher {
221
369
  * @param provider - Async callback returning GroupSecretParams or null
222
370
  */
223
371
  setGroupSecretParamsProvider(provider: (groupId: string) => Promise<import('../internal/protocol/zk/groups/group-params.js').GroupSecretParams | null>): void;
224
- /** Bind received group content to verified local membership. */
225
- setGroupReceiveAuthorizer(authorize: GroupReceiveAuthorizer): void;
372
+ /**
373
+ * Set the provider of the group context that each new send to a managed
374
+ * group carries. It answers null for a group with no master key.
375
+ */
376
+ setGroupContextProvider(provider: (groupId: string) => Promise<GroupContentContext | null>): void;
377
+ /** The content of a new group send, with the context of a managed group in it. */
378
+ private contentWithGroupContext;
379
+ /**
380
+ * Decide on received managed-group content against verified group state.
381
+ * Without an evaluator, managed-group content is refused.
382
+ */
383
+ setGroupReceiveEvaluator(evaluate: GroupReceiveEvaluator): void;
226
384
  /**
227
385
  * Decrypt incoming envelope - routes to appropriate cipher
228
386
  *
229
387
  * Routes based on envelope type:
230
- * - ciphertext + groupId → Group cipher (Sender Keys)
388
+ * - sender_key → Group cipher (Sender Keys)
231
389
  * - otherwise → Pairwise cipher (SESAME/Double Ratchet)
232
390
  *
391
+ * The decrypt commits no receive record. It installs a distribution that
392
+ * the content carries, and it runs the group decision of managed-group
393
+ * content before it returns, as `commitEnvelope`, `decideGroupContent`,
394
+ * and `decryptedEnvelopeOf` tell.
395
+ *
233
396
  * @param envelope - Encrypted envelope from relay
397
+ * @param sealedSenderConfig - The trust roots of an unidentified_sender envelope
398
+ * @param stopSignal - When it aborts while the decrypt waits for a lock,
399
+ * the decrypt throws RelayWorkStopped
234
400
  * @returns Decrypted envelope ready for ContentManager
235
401
  * @throws {EncryptionError} DECRYPTION_FAILED if decryption fails
402
+ * @throws {SealedRetryRequestReceived} for a seal that holds a retry request
236
403
  *
237
404
  * @see https://signal.org/docs/specifications/sesame/
238
405
  */
239
- decrypt(envelope: Envelope, sealedSenderConfig?: import('./config.js').SealedSenderConfig, receiveId?: string, stopSignal?: AbortSignal): Promise<DecryptedEnvelope>;
406
+ decrypt(envelope: Envelope, sealedSenderConfig?: import('./config.js').SealedSenderConfig, stopSignal?: AbortSignal): Promise<DecryptedEnvelope>;
407
+ /**
408
+ * Decrypt one envelope and commit its receive record in the same store
409
+ * transaction as the ratchet step. Then check the content and install a
410
+ * distribution that it carries. The group decision does not run here.
411
+ *
412
+ * With `work`, the commit first reads the record of `work.workId`. A
413
+ * record that holds plaintext is a redelivery: the commit reuses the
414
+ * plaintext, spends no ratchet step, and installs the distribution of a
415
+ * Relay record again. A caller record installs nothing.
416
+ * A record that holds no plaintext ends `settled`. With no record, the
417
+ * admission of `work` runs the decrypt, so a full queue ends `refused`
418
+ * with nothing decrypted. A check that fails after the commit ends
419
+ * `denied`, because the ratchet step is spent.
420
+ *
421
+ * @throws {EncryptionError} when the decrypt fails. Nothing is committed.
422
+ * @throws {SealedRetryRequestReceived} for a seal that holds a retry request
423
+ */
424
+ commitEnvelope(envelope: Envelope, options?: EnvelopeCommitOptions): Promise<EnvelopeCommit>;
425
+ private commitAt;
426
+ /** Open a sealed envelope and return the envelope that it holds. */
427
+ private unsealEnvelope;
428
+ /**
429
+ * Fill the sender fields of a converted legacy record from its
430
+ * redelivered envelope. The record keeps its age and its arrival order.
431
+ */
432
+ private fillAwaitingEnvelope;
433
+ /**
434
+ * The checks of committed content that run before its distribution
435
+ * installs: the replay check, sync content from another account, and a
436
+ * distribution inside a sender-key message.
437
+ */
438
+ private checkCommittedContent;
439
+ /**
440
+ * The committed content of a stored receive record, for the receive queue
441
+ * after the release of the record and for a helper receive. It decrypts nothing.
442
+ * It runs the content checks again, so a crash between a failed check and
443
+ * its denied record denies again.
444
+ *
445
+ * For a Relay record it installs the distribution of the content again.
446
+ * One Signal client puts the install in the buffered store of the ratchet step
447
+ * and writes both in one transaction before the acknowledgment. The local
448
+ * store contract commits a session
449
+ * with its receive record, and sender keys apart from it under the group
450
+ * lock, so the commit stores the record before its install, and an install
451
+ * can fail after the commit. A redelivery replays the install, but a pass
452
+ * can complete the record before the redelivery comes, and the key is then
453
+ * lost. A replay of an installed distribution changes nothing while its
454
+ * key is the current state or one of the kept previous states. When the
455
+ * key is neither, the replay installs it again as the current state, and
456
+ * when the record already holds 5 states, the oldest state goes. Test: "the
457
+ * subscription handler returns true only after the commit, the sender key
458
+ * install, and the outcome-1 write". A caller record installs nothing: its
459
+ * commit gives the distribution to the caller and installs no sender key.
460
+ * Test: "gives the content once, and the failed message is a duplicate
461
+ * after a restart".
462
+ *
463
+ * @param record - A record that holds plaintext and its sender. A
464
+ * converted legacy record waits for its envelope, and has no sender.
465
+ * @param stopSignal - Stops the wait for the sender key lock.
466
+ * @returns `committed` with the content, or `denied` when a check fails
467
+ */
468
+ restoreCommitted(record: ReceiveWorkRecord, stopSignal?: AbortSignal): Promise<Extract<EnvelopeCommit, {
469
+ kind: 'committed' | 'denied';
470
+ }>>;
471
+ /**
472
+ * Install an authenticated distribution. A copy of an installed
473
+ * distribution changes nothing while its key is the current state or a
474
+ * kept previous state, so a replay of the install is safe. A copy of a key
475
+ * that is neither installs again as the current state, and when the
476
+ * record already holds 5 states, the oldest state goes.
477
+ *
478
+ * @returns The raw group of the distribution
479
+ */
480
+ installDistribution(senderUserId: string, senderDeviceId: number, distribution: NonNullable<InspectedSignalProtocolContent['senderKeyDistribution']>, stopSignal?: AbortSignal): Promise<string>;
481
+ /**
482
+ * Decide on committed managed-group content against verified group state.
483
+ * Content that names no managed group and carries no context needs no
484
+ * decision.
485
+ *
486
+ * @returns `authorized` with the group of the content, or null for content
487
+ * of no group. `denied` with the refusal. `unavailable` with the raw
488
+ * group whose state must update first.
489
+ */
490
+ decideGroupContent(content: CommittedContent): Promise<GroupContentDecision>;
491
+ /**
492
+ * The envelope that the application gets for authorized content.
493
+ *
494
+ * @param resolvedGroupId - The group of the content, from `decideGroupContent`
495
+ */
496
+ decryptedEnvelopeOf(content: CommittedContent, resolvedGroupId: string | null): DecryptedEnvelope;
240
497
  /**
241
498
  * Encrypt outgoing message - routes based on recipient type
242
499
  *
@@ -289,7 +546,12 @@ export declare class SignalProtocolServiceCipher {
289
546
  * @param options - The client timestamp and the content hint of the
290
547
  * message, and the retry request that a retry resend answers. Without a
291
548
  * retry target, the client message ID is a new UUID and nothing is
292
- * stored. The timestamp goes in the envelope
549
+ * stored. The timestamp goes in the envelope. With `senderKeyHandoff`,
550
+ * the content carries that own sender key of the raw group: each
551
+ * encryption keeps the key, and when the Relay accepts the bytes, the
552
+ * send records a handoff row of the key that they carry. A post that the
553
+ * Relay answers with RETRY_CONFLICT records no row, because the Relay
554
+ * holds an earlier encryption
293
555
  * @param stopSignal - The stop signal of the relay work that sends. When it
294
556
  * aborts while the send waits for the recipient's lock, the send throws
295
557
  * RelayWorkStopped
@@ -303,10 +565,44 @@ export declare class SignalProtocolServiceCipher {
303
565
  timestamp: number;
304
566
  contentHint?: ContentHint;
305
567
  retry?: RetryResendTarget;
568
+ senderKeyHandoff?: {
569
+ groupId: string;
570
+ senderKeyId: string;
571
+ generation: number;
572
+ };
306
573
  }, stopSignal?: AbortSignal): Promise<boolean>;
307
574
  /** Post the encrypted bytes of a resend with their operation epoch, under one client message ID. */
308
575
  private postResend;
309
- /** Encrypt one attempt of a resend, with the current time as its operation epoch. */
576
+ /**
577
+ * The sealed authorization of one resend post, or null when the post goes
578
+ * identified. A stored group endorsement resolves again for the device's
579
+ * account, and resolves to null when the group has none for it.
580
+ */
581
+ private resolveResendAuthorization;
582
+ /**
583
+ * The group of the group send that this client sent to the user at this
584
+ * client timestamp, if any. A retry request names the failed message by
585
+ * its timestamp, and the pre-messages of a group send have the timestamp
586
+ * of the send. The members of a send name only its recipients. They are
587
+ * never a source of current membership.
588
+ */
589
+ findSentGroupId(recipientUserId: string, clientTimestamp: number): Promise<string | undefined>;
590
+ /**
591
+ * The current sender-key distribution of this device for a group, at the
592
+ * current chain index, or null when the device has no sender key for the
593
+ * group. It is read in the group operation, so no send or rotation of the
594
+ * group runs at the same time.
595
+ */
596
+ currentGroupDistribution(groupId: string, stopSignal?: AbortSignal): Promise<{
597
+ groupId: string;
598
+ distribution: SenderKeyDistributionMessage;
599
+ } | null>;
600
+ /**
601
+ * Encrypt one attempt of a resend, with the current time as its operation
602
+ * epoch. The resend of a group send's message takes the sealed
603
+ * authorization of a pre-message: the recipient's access key first, then
604
+ * the group endorsement of the recipient's account.
605
+ */
310
606
  private encryptResend;
311
607
  /**
312
608
  * Encrypt and upload attachment data without sending a standalone message.
@@ -318,6 +614,21 @@ export declare class SignalProtocolServiceCipher {
318
614
  * Convert Envelope to SesameMessage for SESAME receive path
319
615
  */
320
616
  private toSesameMessage;
617
+ /**
618
+ * Archive the session with one device, for the session reset of a retry
619
+ * request that ended as `expired-content`.
620
+ *
621
+ * The archive takes the decrypt lock of the device first, so each decrypt
622
+ * from the device in progress ends before it, and a decrypt that starts
623
+ * later reads the archived state. Under the device locks of the session
624
+ * manager, it then archives the session in the protocol store and in the
625
+ * device record. The next send to the user reads its device list again
626
+ * and starts a new session with the device.
627
+ *
628
+ * @param stopSignal - When it aborts while the archive waits for the
629
+ * decrypt lock, nothing is archived and the call throws RelayWorkStopped
630
+ */
631
+ archiveDeviceSession(userId: string, deviceId: number, stopSignal?: AbortSignal): Promise<void>;
321
632
  /**
322
633
  * Decrypt a pairwise message via SESAME
323
634
  *
@@ -325,15 +636,27 @@ export declare class SignalProtocolServiceCipher {
325
636
  *
326
637
  * @throws {EncryptionError} DECRYPTION_FAILED if decryption fails
327
638
  */
328
- decryptPairwise(sesameMessage: SesameMessage, receiveId?: string): Promise<string>;
639
+ decryptPairwise(sesameMessage: SesameMessage, seed?: ReceiveWorkSeed): Promise<string>;
640
+ /**
641
+ * Resolve the group of a framed SenderKeyMessage from the distribution
642
+ * identifier inside the frame.
643
+ *
644
+ * @throws {EncryptionError} SESSION_NOT_FOUND when no stored sender key
645
+ * claims the identifier
646
+ */
647
+ private resolveFramedGroup;
329
648
  /**
330
649
  * Decrypt a group message via Sender Keys.
331
650
  *
332
651
  * The envelope names no group, so the group is resolved from the opaque
333
652
  * distribution identifier inside the frame and returned alongside the
334
653
  * plaintext. Callers need it for the conversation ID and cannot read it off
335
- * the envelope.
654
+ * the envelope. The admission runs inside the group lock, so it sees the
655
+ * group before the decrypt.
336
656
  *
657
+ * @param seed - Builds the receive record that commits with the ratchet step
658
+ * @param admit - Runs the decrypt under the receive admission
659
+ * @returns Null when the admission refuses the decrypt
337
660
  * @throws {EncryptionError} DECRYPTION_FAILED if decryption fails
338
661
  */
339
662
  private decryptGroup;
@@ -349,6 +672,11 @@ export declare class SignalProtocolServiceCipher {
349
672
  * without a relay read. The relay gives no device-set version, so the window
350
673
  * is the only bound on how long a linked or removed device goes unseen.
351
674
  *
675
+ * A relay that compares device sets refuses a declared post that misses a
676
+ * device or names a removed one, so on such a relay a recipient with an
677
+ * active session is sent to without a relay read at any age. Only a
678
+ * recipient with no session has its list read.
679
+ *
352
680
  * A direct send may post before the read when the relay refuses every post
353
681
  * to a removed device's mailbox, this client read the list in this process,
354
682
  * and that read is younger than
@@ -380,6 +708,35 @@ export declare class SignalProtocolServiceCipher {
380
708
  * failed and the known devices still receive
381
709
  */
382
710
  private readRecipientDeviceList;
711
+ /**
712
+ * Read the sender's own device list.
713
+ *
714
+ * A listed own device with no session gets one first, and each own device
715
+ * record that the list does not show is removed. With no relay there is no
716
+ * list and no sync copy.
717
+ *
718
+ * On a relay that compares device sets, a send declares the own devices
719
+ * that it holds records for, and reads no own list before its recipient
720
+ * post. A 409 or a declared 410 answer to a sync post repairs the own
721
+ * records, as Signal learns of a new or removed own device. A declared
722
+ * direct send reads the own list only when a recipient receipt sets
723
+ * `needsSync` and the send holds no own device record, and a failed read
724
+ * leaves the sync phase pending without failing the send. On a relay that
725
+ * does not compare, each send reads the own list before its recipient
726
+ * post, and a failed read fails the send.
727
+ *
728
+ * @returns The listed own devices other than this device, in list order
729
+ */
730
+ private readOwnDeviceList;
731
+ /**
732
+ * Remove each device record that the device list does not name, and
733
+ * relist each removed record that it names again. A record that is already
734
+ * removed and still unlisted stays as it is, so a second sweep writes no
735
+ * archive and emits no event.
736
+ *
737
+ * @returns The devices that this sweep removed
738
+ */
739
+ private reconcileDeviceRecords;
383
740
  /**
384
741
  * Encrypt to a single user (all their devices) via SESAME
385
742
  */
@@ -409,16 +766,29 @@ export declare class SignalProtocolServiceCipher {
409
766
  * timestamp, so each device receives the same message.
410
767
  */
411
768
  private reconcileDirectIntent;
769
+ /**
770
+ * Apply a read of the sender's own device list to a direct intent on
771
+ * replay: drop the sync copy of each own device that the list does not
772
+ * show, and add a sent transcript of the caller's content for each listed
773
+ * own device that the intent does not address.
774
+ */
775
+ private reconcileDirectSyncDevices;
776
+ /**
777
+ * A sent transcript of a stored direct send for each own device in
778
+ * `deviceIds` that has a session.
779
+ */
780
+ private prepareDirectSyncMessages;
412
781
  /** The sealed-sender context of a new transmission for a stored direct intent. */
413
782
  private resolveStoredDirectSealedSender;
414
783
  private prepareStoredDirectDeviceMessage;
415
784
  /**
416
- * Refresh the session of a rejected device and replace its transmission.
417
- * The device posts of a send run at the same time, so the repairs for one
418
- * recipient take turns: the first session commit with a user pins the
419
- * user's contact identity, and a concurrent commit that read the store
420
- * before it fails.
785
+ * Run the session repair of one recipient in turn. The device posts of a
786
+ * send run at the same time, so the repairs for one recipient take turns:
787
+ * the first session commit with a user pins the user's contact identity,
788
+ * and a concurrent commit that read the store before it fails.
421
789
  */
790
+ private inRepairTurn;
791
+ /** Refresh the session of a rejected device and replace its transmission. */
422
792
  private repairRejectedDirectDeviceMessage;
423
793
  private repairRejectedDirectDeviceMessageInTurn;
424
794
  private sendStoredDirectDeviceMessage;
@@ -430,8 +800,271 @@ export declare class SignalProtocolServiceCipher {
430
800
  * its result or its refusal.
431
801
  */
432
802
  private sendStoredDirectIntent;
803
+ /** True when the relay compares declared device sets, so each send declares them. */
804
+ private declaresDeviceSets;
805
+ /**
806
+ * The own devices other than this device that have a local device record
807
+ * not marked removed.
808
+ */
809
+ private localOwnDevices;
810
+ /**
811
+ * Run one declared phase of a send until the relay accepts every post.
812
+ *
813
+ * Each pass posts every message of the phase, and each post declares every
814
+ * device of its account that the phase addresses. A device that an earlier
815
+ * pass posted gets its stored bytes again. After a refusal, the repair
816
+ * archives and removes each extra device, refreshes the session of each
817
+ * stale device, starts a session with each missing device, and encrypts the
818
+ * message again only for each refreshed or added device. A listed device
819
+ * with no prekey bundle gets no message, so the next pass declares the
820
+ * account without it and the relay refuses the account again. The repair
821
+ * write stores each such device in the intent, so a replay after a restart
822
+ * or a stop starts a session with it before its first post.
823
+ *
824
+ * An account whose stored devices all lack a bundle has no post, so the
825
+ * pass refuses it here. For such an account, a bundle fetch that answers
826
+ * NOT_FOUND removes the device record. Each other device that the record
827
+ * still holds gets a message in the same repair when it has a session or a
828
+ * bundle. An account left with no device record gets one list read.
829
+ *
830
+ * @returns The answers of the last pass and the messages that it posted
831
+ * @throws {DeviceSetReconciliationError} when the phase ends unresolved
832
+ */
833
+ private runDeclaredPhase;
834
+ /**
835
+ * Repair the devices of one account that a refusal names. The caller runs
836
+ * it in the repair turn of the account. An extra device loses its session,
837
+ * its handoff rows, and its record. A stale device gets a new session,
838
+ * unless its current session already has a registration other than the
839
+ * one that the refused post named. A missing device gets a session.
840
+ *
841
+ * Only a listed device with no prekey bundle is bundle-missing, and the
842
+ * loop waits for it. Any other failure to start a session, such as an
843
+ * identity that the store does not trust, ends the send with its error.
844
+ *
845
+ * An unposted account is one that the pass refused here, because each of
846
+ * its stored devices lacked a bundle. The Relay answers NOT_FOUND for the
847
+ * bundle of a device that it does not register, and for a registered
848
+ * device that has no uploaded prekeys. Thus such a device of an unposted
849
+ * account loses its record and leaves the send. The repair then starts a
850
+ * session with each other device that the account record still holds. A
851
+ * device that has a session already counts as started, so it gets a
852
+ * message in the same repair turn. When the account holds no device
853
+ * record, the repair reads its device list once and starts a session with
854
+ * each listed device. A device with no bundle is bundle-missing again, and
855
+ * the restart bound stops the loop.
856
+ *
857
+ * @returns The devices that leave the send, the refreshed or added devices
858
+ * that have a current session, and the devices that got no session
859
+ * @throws The first error of a session start that failed for a reason other
860
+ * than a missing prekey bundle
861
+ */
862
+ private repairRefusedDevices;
863
+ /**
864
+ * Mark a send result whose relay accepted a declared post without the
865
+ * `deviceSetChecked` mark. The send is delivered, and a second post could
866
+ * deliver it twice, so the result does not change. The client reports the
867
+ * error once through `onRelayProtocolError`.
868
+ */
869
+ private markUncheckedDeclaredPosts;
870
+ /**
871
+ * The protocol error of declared posts that the relay accepted without the
872
+ * `deviceSetChecked` mark. The client logs one warning for it.
873
+ */
874
+ private uncheckedDeclaredPostError;
875
+ /**
876
+ * Replay a stored direct send on a relay that compares device sets. A
877
+ * terminal send starts a new run at 0 restarts. A completed send with a
878
+ * pending sync phase posts only its sync messages. It first reads the own
879
+ * device list when the send could not read it: the phase has no sync
880
+ * message and stores no own device with no bundle. A stored device with no
881
+ * bundle goes through the sync phase, which refuses it as missing and
882
+ * retries it as the live run does. A send that is not terminal resumes
883
+ * with its stored restart counts.
884
+ */
885
+ private replayDeclaredDirectIntent;
886
+ /**
887
+ * Add the sync copies of a direct intent from one read of the own device
888
+ * list. A failed read is logged and does not fail the send.
889
+ *
890
+ * @returns The intent, and true when the read failed
891
+ */
892
+ private addDeclaredDirectSync;
893
+ /**
894
+ * Post a stored direct intent on a relay that compares device sets: the
895
+ * recipient phase first, then the sync phase (§5.4, §5.6). The recipient
896
+ * result is stored before the sync phase starts. A failed sync phase gives
897
+ * `syncPending` and does not fail the send, and the intent keeps the sync
898
+ * messages for a replay.
899
+ */
900
+ private sendDeclaredDirectIntent;
901
+ /** Encrypt the sync copy of a direct intent again for one own device. */
902
+ private directSyncEncrypt;
903
+ /**
904
+ * Run the declared sync phase of a completed intent. The phase has its own
905
+ * restart count. A failure or an unresolved end is logged and leaves the
906
+ * phase pending. The outcome keeps the receipt of each accepted sync post,
907
+ * also when the phase fails, so the send reports a receipt without the
908
+ * `deviceSetChecked` mark.
909
+ */
910
+ private finishDeclaredSync;
911
+ /**
912
+ * Post a sync payload to the own devices that this device holds records
913
+ * for, on a relay that compares device sets. The posts share one operation
914
+ * ID, so a restart posts the stored bytes of an accepted device again
915
+ * under the same ID. With no own device record, nothing is posted. A sync
916
+ * payload has no send result, so the reporter gives the protocol error of
917
+ * an accepted post without the `deviceSetChecked` mark to the app.
918
+ *
919
+ * @throws {DeviceSetReconciliationError} when the phase ends unresolved
920
+ */
921
+ private sendDeclaredSyncPayload;
433
922
  private encryptToGroupWithOutbox;
923
+ /**
924
+ * The declared work of a group send on a relay that compares device sets
925
+ * (§5.5 of the device-set contract).
926
+ */
927
+ private groupDeviceSetContext;
928
+ /**
929
+ * The devices of the group members on a relay that compares device sets.
930
+ * Each member with a local device record gives the devices of that record,
931
+ * and the sender device is left out. Only another member with no record
932
+ * has its device list read (§5.2 of the device-set contract).
933
+ */
934
+ private localGroupMemberDevices;
434
935
  private prepareStoredGroupDeviceMessage;
936
+ /** A copy of a stored device message with the sealed transport of its ciphertext. */
937
+ private sealStoredDeviceMessage;
938
+ /**
939
+ * The sealed-sender context of a sender-key pre-message. A pre-message goes
940
+ * to one recipient, so the recipient's access key comes first, and the
941
+ * group endorsement serves a member with no access key. Resolves to null
942
+ * when the pre-message goes identified, and throws SEALED_SENDER_REQUIRED
943
+ * in required mode when neither authorization resolves.
944
+ */
945
+ private resolveDistributionSealedSender;
946
+ /**
947
+ * The transport of one stored pre-message for this dispatch. The
948
+ * authorization resolves again at each dispatch, so a required send checks
949
+ * its privacy before any post. A pre-message that has no sealed transport
950
+ * is sealed from its stored ciphertext, with no new ratchet effect.
951
+ */
952
+ private authorizePreMessage;
953
+ /**
954
+ * Post one pre-message once, sealed when its transport has an
955
+ * authorization. The relay can reject an access key that the client
956
+ * guessed, for a recipient whose access mode it never learned. The
957
+ * rejection restricts the cached mode, and the post goes again with the
958
+ * group endorsement. A preferred post goes identified only when no sealed
959
+ * authorization is accepted. A required post fails then.
960
+ */
961
+ private sendPreMessage;
962
+ /**
963
+ * The group endorsement of one pre-message recipient, or null when the
964
+ * group has none for the recipient.
965
+ */
966
+ private resolveDistributionEndorsement;
967
+ /** One relay post of a stored pre-message, sealed when `auth` is given. */
968
+ private postStoredPreMessage;
969
+ /**
970
+ * Post one pre-message, and repair its session once if the device refuses
971
+ * it conclusively. A NOT_FOUND refusal of a device that the recipient's
972
+ * device list no longer shows drops the pre-message, as a direct send
973
+ * drops a removed device. A replay whose sender key rotated since the send
974
+ * refreshes the session and drops the pre-message, because it has no
975
+ * distribution of the key of the send. Resolves to the pre-message that the
976
+ * relay accepted or that the send dropped, with the outcome.
977
+ */
978
+ private postPreMessage;
979
+ /**
980
+ * Delete the sender-key handoff rows of one device in one group, so the
981
+ * next send gives the current key to that device. True when a row was
982
+ * deleted. The caller runs it in the sender-key turn of the group.
983
+ */
984
+ invalidateSenderKeyHandoff(groupId: string, device: SenderKeyHandoffDevice): Promise<boolean>;
985
+ /**
986
+ * Delete the sender-key handoff rows of every device of one account in
987
+ * every group. True when a row was deleted.
988
+ */
989
+ invalidateAccountSenderKeyHandoffs(userId: string): Promise<boolean>;
990
+ /**
991
+ * Delete the sender-key handoff rows that no current own key covers: every
992
+ * row of a group with no own sender key, and each row whose senderKeyId is
993
+ * not the current one. Each group runs in its own sender-key turn.
994
+ *
995
+ * @returns The count of deleted rows.
996
+ */
997
+ sweepSenderKeyHandoffs(): Promise<number>;
998
+ /**
999
+ * Record the handoff row of a pre-message that the Relay accepted. A
1000
+ * pre-message with no handoff key or no registration ID, as an intent from
1001
+ * an earlier SDK version stores it, records no row, so the next send gives
1002
+ * the key again.
1003
+ */
1004
+ private recordSenderKeyHandoff;
1005
+ /**
1006
+ * True when the relay refused this pre-message with NOT_FOUND and the
1007
+ * recipient's device list no longer shows the device. A device that the
1008
+ * list still shows keeps the refusal as a failure.
1009
+ */
1010
+ private isRemovedDeviceRefusal;
1011
+ /**
1012
+ * Refresh the session of a device that refused a pre-message, encrypt the
1013
+ * distribution again, and replace the stored pre-message before its post.
1014
+ * The saved refused ciphertext is never posted again. Resolves to
1015
+ * undefined when a replay has no distribution of the key of the send.
1016
+ */
1017
+ private repairRejectedPreMessageInTurn;
1018
+ /**
1019
+ * The distribution of a replayed send. The attempt that prepared the send
1020
+ * kept its distribution in memory only, because the outbox is not
1021
+ * encrypted and must hold no chain key. A replay rebuilds the distribution
1022
+ * from the current sender key. Its chain index is past the group message
1023
+ * of the send, so a device that installs it decrypts the later group
1024
+ * messages of the sender, but not this one. Resolves to undefined when the
1025
+ * current sender key is not the key of the send: a rotation since the
1026
+ * send deleted the handoff rows of the group, and the next send gives the
1027
+ * current key to each device.
1028
+ */
1029
+ private currentDistribution;
1030
+ /**
1031
+ * The sender-key pre-messages that give the key of a stored group send to
1032
+ * the listed devices of other members that need it. The attempt that
1033
+ * prepared the send gives the distribution at the chain index of its group
1034
+ * message. A replay gives the current distribution when the current key is
1035
+ * still the key of the send. When the key rotated, a replay gives no
1036
+ * pre-message. The added devices recover through a retry request, and the
1037
+ * next send gives them the current key. `listed` holds only the devices
1038
+ * that can get a pre-message, as `GroupOutboxContext.prepareSenderKeyHandoffs`
1039
+ * states. A device that a stored pre-message of the intent targets gets no
1040
+ * second one. Each pre-message gets a new transport identity.
1041
+ */
1042
+ private prepareIntentSenderKeyHandoffs;
1043
+ /**
1044
+ * Repair a group device post that the Relay refused as a stale device. When
1045
+ * the session still has the refused registration, the repair refreshes the
1046
+ * session, and the archive deletes the handoff rows of the device. When an
1047
+ * earlier repair of this attempt already refreshed it, the session stays.
1048
+ * Then the device gets the key of the send when it has no row, and a new
1049
+ * device message with the registration of the current session.
1050
+ */
1051
+ private repairStaleGroupDevice;
1052
+ /** The plaintext bytes of a sender-key distribution pre-message. */
1053
+ private serializeSenderKeyDistribution;
1054
+ /**
1055
+ * Refresh the group's endorsements when the cache lacks one of the
1056
+ * recipients or expires soon. Resolves to the endorsement manager, or to
1057
+ * null when the client has none.
1058
+ */
1059
+ private refreshGroupSendEndorsements;
1060
+ /**
1061
+ * Refresh the endorsements of a send's pre-messages before their
1062
+ * authorization resolves. A membership change clears the endorsements, and
1063
+ * a pre-message to a member with no access key needs one to stay sealed.
1064
+ * The refresh takes every recipient at once, so the group message reuses
1065
+ * it. It runs only when the send can seal a post with an endorsement.
1066
+ */
1067
+ private refreshPreMessageEndorsements;
435
1068
  private resolveGroupSendAuthorization;
436
1069
  private serializeDirectSealedSenderMessage;
437
1070
  /**
@@ -470,6 +1103,31 @@ export declare class SignalProtocolServiceCipher {
470
1103
  * group send endorsement.
471
1104
  */
472
1105
  sealReceipt(recipientUserId: string, recipientDeviceId: number, ciphertextBase64: string): Promise<SealedReceipt | undefined>;
1106
+ /**
1107
+ * Seal a retry request for anonymous delivery. The seal holds the payload
1108
+ * of the identified envelope as `PLAINTEXT_CONTENT`, and the certificate in
1109
+ * the seal names the requester. A retry request follows the sealed sender
1110
+ * delivery mode, as a receipt does. Resolves to undefined when the request
1111
+ * goes identified: sealed sender is disabled, or it is preferred and the
1112
+ * relay has no anonymous delivery or this client knows no access key of
1113
+ * the recipient. In `'required'` mode a request that cannot be sealed
1114
+ * throws `SEALED_SENDER_REQUIRED`, and the sealed request permits no
1115
+ * identified fallback. A retry request never uses a group send
1116
+ * endorsement.
1117
+ */
1118
+ sealRetryRequest(recipientUserId: string, recipientDeviceId: number, payloadBase64: string): Promise<SealedReceipt | undefined>;
1119
+ /**
1120
+ * The registration ID of the current session with one device. A receipt
1121
+ * and a retry request name it, in the sealed body and on the identified
1122
+ * envelope, so the Relay refuses the post to a reinstalled device.
1123
+ * Undefined when this client has no session with the device.
1124
+ */
1125
+ recipientRegistrationId(userId: string, deviceId: number): Promise<number | undefined>;
1126
+ /**
1127
+ * Seal one direct control envelope under the access key of its recipient.
1128
+ * The body names the registration of the current session with the device.
1129
+ */
1130
+ private sealWithAccessKey;
473
1131
  /**
474
1132
  * Send a single ciphertext to a device, optionally wrapping with sealed sender.
475
1133
  *
@@ -499,6 +1157,55 @@ export declare class SignalProtocolServiceCipher {
499
1157
  */
500
1158
  private resolveGroupMemberDevices;
501
1159
  private prepareGroupSenderKeyPayload;
1160
+ /**
1161
+ * Read the current distribution of the own sender key, then encrypt the
1162
+ * group message with that key. The distribution is at the chain index of
1163
+ * the message.
1164
+ */
1165
+ private encryptWithCurrentDistribution;
1166
+ /**
1167
+ * The sender-key pre-messages of a send: one distribution pre-message for
1168
+ * each listed device of another member that has no handoff row for the
1169
+ * current key and the current session with the device. A device with no
1170
+ * session gets one first, and the freshness window of the device list
1171
+ * does not apply to it. The sender's own devices are never targets: they
1172
+ * get the transcript.
1173
+ *
1174
+ * Each recipient has a session and a resolved privacy policy before the
1175
+ * first distribution encryption, so a required send that cannot seal a
1176
+ * pre-message makes no peer ratchet effect.
1177
+ *
1178
+ * A device that cannot take the distribution is skipped, and the next send
1179
+ * tries it again, because it has no row. Only the listed devices count for
1180
+ * the failure rule. The send fails for a member when each listed device of
1181
+ * the member that needs the key fails, and no other listed device of the
1182
+ * member has the key. A listed device has the key when it has a row, or
1183
+ * when a `pending` pre-message targets it, so such a device is not a
1184
+ * target. `GroupOutboxContext.prepareSenderKeyHandoffs` states the same
1185
+ * rule.
1186
+ */
1187
+ private prepareSenderKeyHandoffMessages;
1188
+ /**
1189
+ * Each member device with the registration ID of its current session. A
1190
+ * device whose record is marked removed has none, so it needs the key and
1191
+ * the session step reads its device list again, which relists it.
1192
+ */
1193
+ private senderKeyHandoffTargets;
1194
+ /**
1195
+ * Give a session to each device of one member that needs the sender key
1196
+ * and has none. The freshness window of the device list does not apply.
1197
+ * The list is the one that this send read.
1198
+ */
1199
+ private ensureSenderKeyHandoffSessions;
1200
+ /**
1201
+ * Encrypt the distribution for each device of one member that needs it.
1202
+ * Each pre-message carries the registration ID of the session that
1203
+ * encrypted it and the key that it gives, for the handoff row.
1204
+ *
1205
+ * @param handedOff - The count of listed devices of the member that have a
1206
+ * row or that a pending pre-message targets
1207
+ */
1208
+ private prepareUserSenderKeyHandoffs;
502
1209
  /**
503
1210
  * Encrypt to a group via Sender Keys (O(1) encryption)
504
1211
  *