@open-e2ee/signal-protocol-sdk 11.0.0 → 12.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 (583) hide show
  1. package/ADAPTERS.md +4 -4
  2. package/ARCHITECTURE.md +6 -8
  3. package/CHANGELOG.md +1315 -0
  4. package/README.md +1 -1
  5. package/SECURITY.md +2 -2
  6. package/TROUBLESHOOTING.md +1 -1
  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 +1168 -184
  12. package/dist/client/client.js.map +1 -1
  13. package/dist/client/config.d.ts +40 -32
  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 +20 -19
  251. package/dist/internal/manager/manager.d.ts.map +1 -1
  252. package/dist/internal/manager/manager.js +56 -39
  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 +13 -11
  313. package/dist/internal/session/cipher.d.ts.map +1 -1
  314. package/dist/internal/session/cipher.js +40 -22
  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 +4 -12
  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/encryption.d.ts +8 -1
  416. package/dist/local/store/sqlite/encryption.d.ts.map +1 -1
  417. package/dist/local/store/sqlite/encryption.js +9 -0
  418. package/dist/local/store/sqlite/encryption.js.map +1 -1
  419. package/dist/local/store/sqlite/key-storage/index.d.ts +25 -4
  420. package/dist/local/store/sqlite/key-storage/index.d.ts.map +1 -1
  421. package/dist/local/store/sqlite/key-storage/index.js +68 -7
  422. package/dist/local/store/sqlite/key-storage/index.js.map +1 -1
  423. package/dist/local/store/sqlite/key-storage/message-records.d.ts +16 -4
  424. package/dist/local/store/sqlite/key-storage/message-records.d.ts.map +1 -1
  425. package/dist/local/store/sqlite/key-storage/message-records.js +49 -6
  426. package/dist/local/store/sqlite/key-storage/message-records.js.map +1 -1
  427. package/dist/local/store/sqlite/key-storage/metadata.d.ts +8 -7
  428. package/dist/local/store/sqlite/key-storage/metadata.d.ts.map +1 -1
  429. package/dist/local/store/sqlite/key-storage/metadata.js +17 -15
  430. package/dist/local/store/sqlite/key-storage/metadata.js.map +1 -1
  431. package/dist/local/store/sqlite/key-storage/receive-work.d.ts +27 -0
  432. package/dist/local/store/sqlite/key-storage/receive-work.d.ts.map +1 -0
  433. package/dist/local/store/sqlite/key-storage/receive-work.js +98 -0
  434. package/dist/local/store/sqlite/key-storage/receive-work.js.map +1 -0
  435. package/dist/local/store/sqlite/key-storage/send-log.d.ts +27 -0
  436. package/dist/local/store/sqlite/key-storage/send-log.d.ts.map +1 -0
  437. package/dist/local/store/sqlite/key-storage/send-log.js +178 -0
  438. package/dist/local/store/sqlite/key-storage/send-log.js.map +1 -0
  439. package/dist/local/store/sqlite/key-storage/sender-key-handoff.d.ts +27 -0
  440. package/dist/local/store/sqlite/key-storage/sender-key-handoff.d.ts.map +1 -0
  441. package/dist/local/store/sqlite/key-storage/sender-key-handoff.js +75 -0
  442. package/dist/local/store/sqlite/key-storage/sender-key-handoff.js.map +1 -0
  443. package/dist/local/store/sqlite/key-storage/session-trust.d.ts +2 -2
  444. package/dist/local/store/sqlite/key-storage/session-trust.js +5 -5
  445. package/dist/local/store/sqlite/key-storage/session-trust.js.map +1 -1
  446. package/dist/local/store/sqlite/migrations.d.ts.map +1 -1
  447. package/dist/local/store/sqlite/migrations.js +101 -0
  448. package/dist/local/store/sqlite/migrations.js.map +1 -1
  449. package/dist/local/store/sqlite/models/index.d.ts +2 -1
  450. package/dist/local/store/sqlite/models/index.d.ts.map +1 -1
  451. package/dist/local/store/sqlite/models/index.js +5 -1
  452. package/dist/local/store/sqlite/models/index.js.map +1 -1
  453. package/dist/local/store/sqlite/models/message-record.d.ts +15 -0
  454. package/dist/local/store/sqlite/models/message-record.d.ts.map +1 -1
  455. package/dist/local/store/sqlite/models/message-record.js +24 -0
  456. package/dist/local/store/sqlite/models/message-record.js.map +1 -1
  457. package/dist/local/store/sqlite/models/send-log.d.ts +51 -0
  458. package/dist/local/store/sqlite/models/send-log.d.ts.map +1 -0
  459. package/dist/local/store/sqlite/models/send-log.js +206 -0
  460. package/dist/local/store/sqlite/models/send-log.js.map +1 -0
  461. package/dist/local/store/sqlite/open-store.d.ts +9 -1
  462. package/dist/local/store/sqlite/open-store.d.ts.map +1 -1
  463. package/dist/local/store/sqlite/open-store.js +20 -1
  464. package/dist/local/store/sqlite/open-store.js.map +1 -1
  465. package/dist/local/store/sqlite/schema.d.ts +34 -1
  466. package/dist/local/store/sqlite/schema.d.ts.map +1 -1
  467. package/dist/local/store/sqlite/schema.js +14 -0
  468. package/dist/local/store/sqlite/schema.js.map +1 -1
  469. package/dist/local/store/sqlite/store.d.ts +61 -11
  470. package/dist/local/store/sqlite/store.d.ts.map +1 -1
  471. package/dist/local/store/sqlite/store.js +191 -27
  472. package/dist/local/store/sqlite/store.js.map +1 -1
  473. package/dist/local/store/web/adapter.d.ts +76 -8
  474. package/dist/local/store/web/adapter.d.ts.map +1 -1
  475. package/dist/local/store/web/adapter.js +579 -127
  476. package/dist/local/store/web/adapter.js.map +1 -1
  477. package/dist/local/store/web/receive-work.d.ts +57 -0
  478. package/dist/local/store/web/receive-work.d.ts.map +1 -0
  479. package/dist/local/store/web/receive-work.js +99 -0
  480. package/dist/local/store/web/receive-work.js.map +1 -0
  481. package/dist/local/store/web/send-log.d.ts +92 -0
  482. package/dist/local/store/web/send-log.d.ts.map +1 -0
  483. package/dist/local/store/web/send-log.js +267 -0
  484. package/dist/local/store/web/send-log.js.map +1 -0
  485. package/dist/local/store/web/sender-key-handoff.d.ts +81 -0
  486. package/dist/local/store/web/sender-key-handoff.d.ts.map +1 -0
  487. package/dist/local/store/web/sender-key-handoff.js +156 -0
  488. package/dist/local/store/web/sender-key-handoff.js.map +1 -0
  489. package/dist/local/store/web-sqlite/adapter.d.ts +2 -0
  490. package/dist/local/store/web-sqlite/adapter.d.ts.map +1 -1
  491. package/dist/local/store/web-sqlite/adapter.js +12 -6
  492. package/dist/local/store/web-sqlite/adapter.js.map +1 -1
  493. package/dist/local/vault/custody.d.ts +8 -0
  494. package/dist/local/vault/custody.d.ts.map +1 -0
  495. package/dist/local/vault/custody.js +9 -0
  496. package/dist/local/vault/custody.js.map +1 -0
  497. package/dist/local/vault/electron-safe-storage.d.ts +3 -1
  498. package/dist/local/vault/electron-safe-storage.d.ts.map +1 -1
  499. package/dist/local/vault/electron-safe-storage.js +2 -0
  500. package/dist/local/vault/electron-safe-storage.js.map +1 -1
  501. package/dist/local/vault/expo-secure-store.d.ts +3 -1
  502. package/dist/local/vault/expo-secure-store.d.ts.map +1 -1
  503. package/dist/local/vault/expo-secure-store.js +2 -0
  504. package/dist/local/vault/expo-secure-store.js.map +1 -1
  505. package/dist/local/vault/indexed-db.d.ts +3 -1
  506. package/dist/local/vault/indexed-db.d.ts.map +1 -1
  507. package/dist/local/vault/indexed-db.js +2 -0
  508. package/dist/local/vault/indexed-db.js.map +1 -1
  509. package/dist/local/vault/react-native-keychain.d.ts +3 -1
  510. package/dist/local/vault/react-native-keychain.d.ts.map +1 -1
  511. package/dist/local/vault/react-native-keychain.js +2 -0
  512. package/dist/local/vault/react-native-keychain.js.map +1 -1
  513. package/dist/remote/relay/device-set.d.ts +94 -0
  514. package/dist/remote/relay/device-set.d.ts.map +1 -0
  515. package/dist/remote/relay/device-set.js +156 -0
  516. package/dist/remote/relay/device-set.js.map +1 -0
  517. package/dist/remote/relay/types.d.ts +92 -107
  518. package/dist/remote/relay/types.d.ts.map +1 -1
  519. package/dist/safety/core.d.ts +15 -6
  520. package/dist/safety/core.d.ts.map +1 -1
  521. package/dist/safety/core.js +41 -27
  522. package/dist/safety/core.js.map +1 -1
  523. package/dist/safety/index.d.ts +2 -1
  524. package/dist/safety/index.d.ts.map +1 -1
  525. package/dist/safety/index.js +12 -18
  526. package/dist/safety/index.js.map +1 -1
  527. package/dist/types/api.d.ts +707 -62
  528. package/dist/types/api.d.ts.map +1 -1
  529. package/dist/types/errors.d.ts +14 -33
  530. package/dist/types/errors.d.ts.map +1 -1
  531. package/dist/types/errors.js +14 -24
  532. package/dist/types/errors.js.map +1 -1
  533. package/dist/types/messages.d.ts +2 -2
  534. package/dist/types/messages.js +1 -1
  535. package/dist/types/protocol-config.d.ts +175 -42
  536. package/dist/types/protocol-config.d.ts.map +1 -1
  537. package/dist/types/protocol-config.js +19 -38
  538. package/dist/types/protocol-config.js.map +1 -1
  539. package/dist/types/protocol-constants.d.ts +6 -6
  540. package/dist/types/protocol-constants.js +6 -6
  541. package/dist/types/session.d.ts +7 -7
  542. package/dist/types/session.d.ts.map +1 -1
  543. package/dist/types/session.js +39 -21
  544. package/dist/types/session.js.map +1 -1
  545. package/dist/username/link.d.ts +2 -2
  546. package/dist/username/link.js +2 -2
  547. package/dist/utils/origin-lock.d.ts +45 -0
  548. package/dist/utils/origin-lock.d.ts.map +1 -0
  549. package/dist/utils/origin-lock.js +80 -0
  550. package/dist/utils/origin-lock.js.map +1 -0
  551. package/docs/ASSURANCE.md +6 -6
  552. package/docs/CLIENT_COMPOSITION.md +2 -2
  553. package/docs/DEVIATIONS.md +677 -182
  554. package/docs/E2EE.md +1 -1
  555. package/docs/ERROR_HANDLING.md +165 -2
  556. package/docs/GETTING_STARTED.md +7 -4
  557. package/docs/INTERFACES.md +1 -1
  558. package/docs/PACKAGE_SURFACE.md +6 -5
  559. package/docs/PROTOCOL_POLICY.md +102 -22
  560. package/docs/RECIPES.md +3 -15
  561. package/docs/SECURITY.md +90 -5
  562. package/keys/README.md +3 -3
  563. package/local/store/README.md +78 -14
  564. package/local/store/key-value/README.md +14 -3
  565. package/local/store/node/README.md +8 -3
  566. package/local/store/web/README.md +9 -0
  567. package/local/store/web-sqlite/README.md +14 -2
  568. package/local/vault/README.md +21 -0
  569. package/package.json +1 -6
  570. package/remote/README.md +0 -1
  571. package/remote/relay/README.md +2 -2
  572. package/dist/device/provisioning.d.ts +0 -242
  573. package/dist/device/provisioning.d.ts.map +0 -1
  574. package/dist/device/provisioning.js +0 -421
  575. package/dist/device/provisioning.js.map +0 -1
  576. package/dist/internal/protocol/x3dh/index.d.ts +0 -15
  577. package/dist/internal/protocol/x3dh/index.d.ts.map +0 -1
  578. package/dist/internal/protocol/x3dh/index.js +0 -13
  579. package/dist/internal/protocol/x3dh/index.js.map +0 -1
  580. package/dist/internal/protocol/x3dh/x3dh.d.ts +0 -131
  581. package/dist/internal/protocol/x3dh/x3dh.d.ts.map +0 -1
  582. package/dist/internal/protocol/x3dh/x3dh.js +0 -261
  583. package/dist/internal/protocol/x3dh/x3dh.js.map +0 -1
@@ -6,14 +6,20 @@
6
6
  * failed envelope posts nothing while the record exists. A post that fails
7
7
  * with a retryable class is posted again by the scheduler at its next
8
8
  * attempt time. A post that fails with a conclusive class, the deadline of
9
- * the record, and an exhausted abuse allowance end the request. Each end
10
- * calls the `onRetryTerminal` hook once.
9
+ * the record, a failed resend of the last answered attempt, and an
10
+ * exhausted abuse allowance end the request. Each end calls the
11
+ * `onRetryTerminal` hook at least once: the record is marked emitted only
12
+ * after the hook returns. Each request and each scheduler pass also checks
13
+ * the delivery error of the record, as `reportDeliveryError` tells. Each
14
+ * scheduler pass also runs a recovery that the hook did not mark, as
15
+ * `reportDeliveryRecovered` tells.
11
16
  */
12
- import { getRetryRequest, listRetryRequestIds, RETRY_REQUEST_DEADLINE_MS, storeRetryRequest, updateRetryRequest, withProcessedEnvelopeLock, } from '../local/store/reliability.js';
17
+ import { getProcessedEnvelope, getRetryRequest, listRetryRequestIds, RETRY_REQUEST_DEADLINE_MS, storeRetryRequest, updateRetryRequest, withProcessedEnvelopeLock, } from '../local/store/reliability.js';
13
18
  import { generateUuidV4 } from '../internal/crypto/index.js';
14
- import { callHook } from './event-hooks.js';
15
- import { postRetryRequest, postStoredRetryRequest, readRetryRequestEnvelope, } from './retry-request-envelope.js';
19
+ import { reportDeliveryError, reportDeliveryRecovered } from './delivery-error.js';
20
+ import { answeredLastRetryAttempt, postRetryRequest, postStoredRetryRequest, readRetryRequestEnvelope, } from './retry-request-envelope.js';
16
21
  import { rethrowRelayWorkStopped } from './relay-work.js';
22
+ import { resetRetryTerminalSession, } from './retry-terminal-recovery.js';
17
23
  /**
18
24
  * Tell whether the receive path acknowledges a failed envelope after its
19
25
  * retry request. A failed envelope is acknowledged once a record owns its
@@ -27,17 +33,43 @@ export function acknowledgesRetryRequest(outcome, member) {
27
33
  }
28
34
  /**
29
35
  * Call the `onRetryTerminal` hook for the terminal state of a request
30
- * record, once. It reads the record, calls the hook when the terminal state
31
- * is not emitted, and then stores it as emitted. A RelayWorkStopped from the
32
- * hook propagates and leaves the state not emitted, so the next scheduler
33
- * pass or redelivery calls the hook again.
36
+ * record, once. It reads the record, and when the terminal state is not
37
+ * emitted, it first resets the session of an `expired-content` end with
38
+ * `resetRetryTerminalSession`. It then calls the hook and stores the state
39
+ * as emitted. The other classes reset nothing.
40
+ *
41
+ * The hook is called directly, not through `callHook`, so a hook that
42
+ * throws, and the RelayWorkStopped of a stop or of the reset, propagate and
43
+ * leave the state not emitted. The rule is: mark only after the hook
44
+ * returns, and keep the caller alive. The scheduler logs the error and goes
45
+ * on with the next record, and the receive path does not acknowledge the
46
+ * failed envelope. The next scheduler pass, at the next start or the next
47
+ * armed time, or the redelivery continues the reset from its stored steps
48
+ * and calls the hook again. The record holds no emit count, so a hook that
49
+ * keeps throwing runs once each pass until the record expires.
34
50
  */
35
- export async function emitRetryTerminal(storage, hooks, failedEnvelopeId) {
36
- const record = await getRetryRequest(storage, failedEnvelopeId);
51
+ export async function emitRetryTerminal(context, failedEnvelopeId) {
52
+ const { storage, hooks } = context;
53
+ const record = await resetRetryTerminalSession(context, failedEnvelopeId);
37
54
  const terminal = record?.terminal;
38
55
  if (!record || !terminal || terminal.emitted)
39
56
  return;
40
- await callHook(hooks, 'onRetryTerminal', { class: terminal.class, failedEnvelopeId });
57
+ const hook = hooks?.onRetryTerminal;
58
+ if (hook) {
59
+ const { recovery } = record;
60
+ await hook({
61
+ class: terminal.class,
62
+ failedEnvelopeId,
63
+ ...(recovery?.nullMessage && {
64
+ recovery: {
65
+ userId: recovery.userId,
66
+ deviceId: recovery.deviceId,
67
+ senderKey: recovery.senderKey,
68
+ nullMessage: recovery.nullMessage.outcome,
69
+ },
70
+ }),
71
+ });
72
+ }
41
73
  await updateRetryRequest(storage, failedEnvelopeId, record.retryId, record.attempt, {
42
74
  terminal: { ...terminal, emitted: true },
43
75
  });
@@ -52,6 +84,10 @@ export async function emitRetryTerminal(storage, hooks, failedEnvelopeId) {
52
84
  * - A failed envelope with no record spends one request of the rate limit.
53
85
  * A refusal stores a record that ends as `abuse-allowance-exhausted`.
54
86
  * - A member of a request that ended posts nothing and gives `terminal`.
87
+ * - A member whose stored attempt is answered and is the last attempt, as
88
+ * `answeredLastRetryAttempt` tells, ends the request as
89
+ * `attempts-exhausted` and gives `terminal`. The rate limit does not
90
+ * count it.
55
91
  * - A member whose stored attempt is answered, or that has no record,
56
92
  * spends one request of the rate limit, unless an earlier refusal set a
57
93
  * next attempt time that has not come. A refusal sets that time to the
@@ -60,17 +96,20 @@ export async function emitRetryTerminal(storage, hooks, failedEnvelopeId) {
60
96
  * rate limit.
61
97
  *
62
98
  * After a post, a terminal outcome calls the hook, and any other outcome
63
- * arms the scheduler for the record.
99
+ * arms the scheduler for the record. Then, for each failed envelope with
100
+ * an ID, it runs `onDeliveryError` when the error of the record is due,
101
+ * and arms the scheduler for an error that is due later.
64
102
  */
65
103
  export async function requestRetryInFamily(family, fingerprint, source) {
66
- const { storage, logger, hooks } = source;
104
+ const { storage, hooks, logger } = source;
67
105
  const refused = () => {
68
106
  logger.warn('Retry rate limit exceeded for sender', {
69
107
  category: 'E2EE',
70
108
  data: { senderId: source.senderUserId, windowMs: source.windowMs },
71
109
  });
72
110
  };
73
- return family.requestRetry(fingerprint, async (failed) => {
111
+ const sender = { userId: source.senderUserId, deviceId: source.senderDeviceId };
112
+ const request = async (failed) => {
74
113
  const failedEnvelopeId = failed.id;
75
114
  const { stored } = failed;
76
115
  if (failedEnvelopeId === undefined) {
@@ -81,12 +120,13 @@ export async function requestRetryInFamily(family, fingerprint, source) {
81
120
  }
82
121
  else if (failed.member === undefined) {
83
122
  if (stored) {
84
- await emitRetryTerminal(storage, hooks, failedEnvelopeId);
123
+ await emitRetryTerminal(source, failedEnvelopeId);
85
124
  return 'owned';
86
125
  }
87
126
  if (!source.allow()) {
88
127
  refused();
89
128
  const now = Date.now();
129
+ const own = source.failedEnvelope;
90
130
  await storeRetryRequest(storage, {
91
131
  failedEnvelopeId,
92
132
  retryId: await generateUuidV4(),
@@ -94,17 +134,28 @@ export async function requestRetryInFamily(family, fingerprint, source) {
94
134
  requestedAt: now,
95
135
  ...(failed.fingerprint !== undefined && { fingerprint: failed.fingerprint }),
96
136
  answered: false,
137
+ ...(own?.groupMessage && { groupMessage: true }),
138
+ ...(own?.clientMessageId !== undefined && {
139
+ failedClientMessageId: own.clientMessageId,
140
+ }),
141
+ ...(failedGroupId(source) !== undefined && { groupId: failedGroupId(source) }),
142
+ receivedAt: now,
143
+ ...(own?.contentHint !== undefined && { contentHint: own.contentHint }),
144
+ failedSender: sender,
97
145
  deadlineAt: now + RETRY_REQUEST_DEADLINE_MS,
98
146
  terminal: { class: 'abuse-allowance-exhausted', at: now, emitted: false },
99
147
  });
100
- await emitRetryTerminal(storage, hooks, failedEnvelopeId);
148
+ await emitRetryTerminal(source, failedEnvelopeId);
101
149
  return 'terminal';
102
150
  }
103
151
  }
104
152
  else if (stored?.terminal) {
105
- await emitRetryTerminal(storage, hooks, failedEnvelopeId);
153
+ await emitRetryTerminal(source, failedEnvelopeId);
106
154
  return 'terminal';
107
155
  }
156
+ else if (stored && answeredLastRetryAttempt(stored)) {
157
+ // The post ends the request, so it spends no request of the rate limit.
158
+ }
108
159
  else if (!stored || stored.answered) {
109
160
  const now = Date.now();
110
161
  if (stored?.lastFailureClass === 'rate-refusal' && (stored.nextAttemptAt ?? 0) > now) {
@@ -125,11 +176,21 @@ export async function requestRetryInFamily(family, fingerprint, source) {
125
176
  logger.warn('Cannot send retry request: no relay or callback', { category: 'E2EE' });
126
177
  return 'skipped';
127
178
  }
128
- const outcome = await postRetryRequest(storage, failed, () => source.createRequest(), source.local, source.send);
179
+ const own = failed.member === undefined ? source.failedEnvelope : undefined;
180
+ const groupId = failed.member === undefined ? failedGroupId(source) : undefined;
181
+ const senderKey = failed.member === undefined ? own?.senderKey === true : stored?.groupMessage === true;
182
+ const outcome = await postRetryRequest(storage, {
183
+ ...failed,
184
+ ...(own?.groupMessage && { groupMessage: true }),
185
+ ...(own?.clientMessageId !== undefined && { clientMessageId: own.clientMessageId }),
186
+ ...(groupId !== undefined && { groupId }),
187
+ ...(own?.contentHint !== undefined && { contentHint: own.contentHint }),
188
+ sender,
189
+ }, () => source.createRequest(senderKey), source.local, source.send);
129
190
  if (failedEnvelopeId === undefined)
130
191
  return outcome;
131
192
  if (outcome === 'terminal') {
132
- await emitRetryTerminal(storage, hooks, failedEnvelopeId);
193
+ await emitRetryTerminal(source, failedEnvelopeId);
133
194
  }
134
195
  else {
135
196
  const record = await getRetryRequest(storage, failedEnvelopeId);
@@ -137,15 +198,39 @@ export async function requestRetryInFamily(family, fingerprint, source) {
137
198
  source.schedule?.(record.nextAttemptAt ?? record.deadlineAt);
138
199
  }
139
200
  return outcome;
201
+ };
202
+ return family.requestRetry(fingerprint, async (failed) => {
203
+ const outcome = await request(failed);
204
+ if (failed.id !== undefined) {
205
+ const errorAt = await reportDeliveryError(storage, hooks, failed.id);
206
+ if (errorAt !== Infinity)
207
+ source.schedule?.(errorAt);
208
+ }
209
+ return outcome;
140
210
  });
141
211
  }
212
+ /**
213
+ * The raw group ID of the failed envelope of a new record: the group that
214
+ * the receive resolved, or else the group of the sender key that the
215
+ * envelope names.
216
+ */
217
+ function failedGroupId(source) {
218
+ return source.groupId ?? source.failedEnvelope?.groupId;
219
+ }
142
220
  /** The longest delay that a timer takes. */
143
221
  const MAX_TIMER_DELAY_MS = 2 ** 31 - 1;
144
222
  /**
145
223
  * Posts each stored retry request whose next attempt time has come, ends
146
- * each request at its deadline, and calls the hook for each terminal state
147
- * that is not emitted. A pass runs at start() and at the earliest next
148
- * attempt time or deadline of the records. Each pass is relay work, so a
224
+ * each request at its deadline, also when its stored attempt is answered,
225
+ * and calls the hook for each terminal state that is not emitted. A request
226
+ * whose failed envelope is fulfilled has its content, so the scheduler
227
+ * neither posts nor ends it. It then runs `onDeliveryError` for each record whose
228
+ * error is due, and `onDeliveryRecovered` for each fulfilled record whose
229
+ * recovery the hook did not mark. A hook error for one record is logged,
230
+ * the record keeps the time of its next attempt or deadline, and the pass
231
+ * goes on with the next record. A pass runs at start() and at
232
+ * the earliest next attempt
233
+ * time, deadline or error time of the records. Each pass is relay work, so a
149
234
  * client stop stops it. Each record is read and posted under the processed
150
235
  * lock of its failed envelope, as a receive does.
151
236
  *
@@ -253,42 +338,87 @@ export class RetryRequestScheduler {
253
338
  if (next !== Infinity)
254
339
  this.schedule(next);
255
340
  }
256
- /** Handle one record. It returns the time of the next pass for the record. */
341
+ /**
342
+ * Handle one record. It returns the time of the next pass for the record.
343
+ * A delivery hook that throws is logged for the record, and the record
344
+ * keeps the time of its next attempt or deadline. The next pass runs the
345
+ * hook again.
346
+ */
257
347
  async passRecord(pass, failedEnvelopeId) {
258
- const { storage, hooks, send } = pass;
348
+ const next = await this.attemptRecord(pass, failedEnvelopeId);
349
+ let errorAt = Infinity;
350
+ try {
351
+ errorAt = await reportDeliveryError(pass.storage, pass.hooks, failedEnvelopeId);
352
+ }
353
+ catch (error) {
354
+ hookFailed(pass, failedEnvelopeId, 'onDeliveryError', error);
355
+ }
356
+ try {
357
+ await reportDeliveryRecovered(pass.storage, pass.hooks, failedEnvelopeId);
358
+ }
359
+ catch (error) {
360
+ hookFailed(pass, failedEnvelopeId, 'onDeliveryRecovered', error);
361
+ }
362
+ return Math.min(next, errorAt);
363
+ }
364
+ /** Post or end the request of one record. It returns the time of its next attempt. */
365
+ async attemptRecord(pass, failedEnvelopeId) {
366
+ const { storage, send } = pass;
259
367
  const record = await getRetryRequest(storage, failedEnvelopeId);
260
368
  if (record?.terminal) {
261
- await emitRetryTerminal(storage, hooks, failedEnvelopeId);
369
+ await emitRetryTerminal(pass, failedEnvelopeId);
262
370
  return Infinity;
263
371
  }
264
- if (!record || record.answered)
265
- return Infinity;
266
- if (!send)
372
+ if (!record || !send)
267
373
  return Infinity;
268
374
  const now = Date.now();
375
+ if ((await getProcessedEnvelope(storage, failedEnvelopeId, now))?.fulfilled)
376
+ return Infinity;
269
377
  if (now >= record.deadlineAt) {
270
378
  await updateRetryRequest(storage, failedEnvelopeId, record.retryId, record.attempt, {
271
379
  terminal: { class: 'expired-content', at: now, emitted: false },
272
380
  nextAttemptAt: undefined,
273
381
  });
274
- await emitRetryTerminal(storage, hooks, failedEnvelopeId);
382
+ await emitRetryTerminal(pass, failedEnvelopeId);
275
383
  return Infinity;
276
384
  }
385
+ // An answered attempt waits for its resend, or for its deadline.
386
+ if (record.answered)
387
+ return record.deadlineAt;
277
388
  // With no next attempt time, the Relay holds the stored attempt.
278
389
  if (record.nextAttemptAt === undefined || record.nextAttemptAt > now) {
279
390
  return Math.min(record.nextAttemptAt ?? Infinity, record.deadlineAt);
280
391
  }
281
392
  const outcome = await postStoredRetryRequest(storage, record, () => storedRequest(record), pass.local, send);
282
393
  if (outcome === 'terminal') {
283
- await emitRetryTerminal(storage, hooks, failedEnvelopeId);
394
+ await emitRetryTerminal(pass, failedEnvelopeId);
284
395
  return Infinity;
285
396
  }
286
397
  const after = await getRetryRequest(storage, failedEnvelopeId);
287
- if (!after || after.terminal || after.answered)
398
+ if (!after || after.terminal)
288
399
  return Infinity;
400
+ if (after.answered)
401
+ return after.deadlineAt;
289
402
  return Math.min(after.nextAttemptAt ?? Infinity, after.deadlineAt);
290
403
  }
291
404
  }
405
+ /**
406
+ * Log a delivery hook that failed in a scheduler pass. A stop still ends the
407
+ * pass.
408
+ */
409
+ function hookFailed(pass, failedEnvelopeId, hook, error) {
410
+ rethrowRelayWorkStopped(error);
411
+ pass.logger.warn(`The ${hook} hook failed`, {
412
+ category: 'E2EE',
413
+ data: {
414
+ failedEnvelopeId,
415
+ behavior: hook === 'onDeliveryError'
416
+ ? 'DELIVERY_ERROR_HOOK_FAILED'
417
+ : 'DELIVERY_RECOVERED_HOOK_FAILED',
418
+ error: error.message,
419
+ },
420
+ });
421
+ }
292
422
  /**
293
423
  * The request of a new attempt for a stored record, from its stored
294
424
  * envelope, with the time of now. The scheduler has no failed envelope, so
@@ -1 +1 @@
1
- {"version":3,"file":"retry-request-lifecycle.js","sourceRoot":"","sources":["../../client/retry-request-lifecycle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAKH,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,yBAAyB,EACzB,iBAAiB,EACjB,kBAAkB,EAClB,yBAAyB,GAE1B,MAAM,4BAA4B,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C,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,aAAa,IAAI,QAAQ,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;IACrE,CAAC;CACF;AAED;;;GAGG;AACH,SAAS,UAAU,CACjB,IAAsB,EACtB,gBAAwB,EACxB,IAA+C,EAC/C,KAAc;IAEd,uBAAuB,CAAC,KAAK,CAAC,CAAC;IAC/B,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,IAAI,cAAc,EAAE;QAC1C,QAAQ,EAAE,MAAM;QAChB,IAAI,EAAE;YACJ,gBAAgB;YAChB,QAAQ,EACN,IAAI,KAAK,iBAAiB;gBACxB,CAAC,CAAC,4BAA4B;gBAC9B,CAAC,CAAC,gCAAgC;YACtC,KAAK,EAAG,KAAe,CAAC,OAAO;SAChC;KACF,CAAC,CAAC;AACL,CAAC;AAED;;;;GAIG;AACH,KAAK,UAAU,aAAa,CAAC,MAA0B;IACrD,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAS,CAAC;IAClC,MAAM,IAAI,GAAG,wBAAwB,CAAC,QAAQ,EAAE;QAC9C,MAAM,EAAE,QAAQ,CAAC,YAAY;QAC7B,QAAQ,EAAE,QAAQ,CAAC,cAAc;KAClC,CAAC,CAAC;IACH,IAAI,CAAC,IAAI,CAAC,EAAE;QAAE,MAAM,IAAI,KAAK,CAAC,6CAA6C,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;IACzF,OAAO,EAAE,GAAG,IAAI,CAAC,OAAO,EAAE,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC;AACpD,CAAC"}
@@ -0,0 +1,100 @@
1
+ /**
2
+ * The session reset of the requester after a retry request ends as
3
+ * `expired-content`.
4
+ *
5
+ * The request got no answer before its deadline, so the session with the
6
+ * device that sent the failed envelope can be out of step. The requester
7
+ * archives that session, deletes its sender-key handoff rows for each device
8
+ * of that account in every group, and sends one null message to the
9
+ * device, at most once an hour for each device. The null message, or else
10
+ * the next ordinary message, starts a new session with the device. The
11
+ * other terminal classes and a retryable post failure reset nothing.
12
+ *
13
+ * Each step is stored on the request record when it ends, so a replay of
14
+ * the terminal state after a restart or a client stop does not archive a
15
+ * newer session.
16
+ */
17
+ import type { Logger } from '../logger.js';
18
+ import { getRetryRequest, type StoredRetryRequest } from '../local/store/reliability.js';
19
+ import { type SignalProtocolClientHooks } from './event-hooks.js';
20
+ type RetryRecordStore = Parameters<typeof getRetryRequest>[0];
21
+ /** The device that sent a failed envelope. */
22
+ export interface RetryTerminalDevice {
23
+ readonly userId: string;
24
+ readonly deviceId: number;
25
+ }
26
+ /**
27
+ * The session reset steps. The client gives them, bound to the relay work
28
+ * that runs the reset.
29
+ */
30
+ export interface RetryTerminalResetSteps {
31
+ /**
32
+ * Wait for each decrypt from the device that is in progress, and then
33
+ * archive the session with the device in the protocol store and in its
34
+ * device record. The next send to the user reads its device list again.
35
+ */
36
+ archiveSession(device: RetryTerminalDevice): Promise<void>;
37
+ /**
38
+ * Delete the sender-key handoff rows of every device of the account in
39
+ * every group, with no rotation, so the next send of each group gives the
40
+ * current key to each of those devices. With the raw group ID of the
41
+ * failed envelope, the delete runs in the sender-key turn of that group.
42
+ * True when the requester has a sender key for that group, false when it
43
+ * has none or no group is given. A client stop does not stop it, so a
44
+ * stop does not split the archive from the invalidation.
45
+ */
46
+ invalidateAccountSenderKeyHandoffs(userId: string, groupId: string | undefined): Promise<boolean>;
47
+ /**
48
+ * Start a session with the device when there is none, and post one null
49
+ * message to it with the implicit content hint.
50
+ */
51
+ sendNullMessage(device: RetryTerminalDevice): Promise<void>;
52
+ }
53
+ /** What the reset of one terminal state uses. */
54
+ export interface RetryTerminalResetContext {
55
+ readonly storage: RetryRecordStore;
56
+ readonly logger: Required<Logger>;
57
+ readonly hooks: SignalProtocolClientHooks | undefined;
58
+ /** Without them, the terminal state resets nothing. */
59
+ readonly reset: RetryTerminalResetSteps | undefined;
60
+ }
61
+ /**
62
+ * Reset the session with the sender device of an `expired-content` request
63
+ * whose terminal state is not emitted. Another class, an emitted state, and
64
+ * a context with no reset steps do nothing.
65
+ *
66
+ * The steps run in this order. A step that a stored marker shows as done
67
+ * does not run again.
68
+ *
69
+ * 1. The session with the device is archived, after its decrypts that are
70
+ * in progress end.
71
+ * 2. The handoff rows of each device of the account in every group are
72
+ * deleted, after the archive, as one Signal client does at an automatic
73
+ * session reset. The step runs for a group message and for a
74
+ * pairwise message. The next send of each group gives its current key to
75
+ * each device of the account, and to the device through the new session.
76
+ * 3. The record stores the archived device and the sender key outcome,
77
+ * and the `onSessionArchived` hook runs.
78
+ * 4. Under one lock for each device, a null message goes to the device
79
+ * when no other request sent one to it in the last hour. The record
80
+ * stores the outcome.
81
+ *
82
+ * A RelayWorkStopped while the archive waits for the decrypt lock
83
+ * propagates, and the replay runs the reset again. A failure of steps 1 to
84
+ * 3 also propagates. A crash between the archive and its stored marker
85
+ * archives again at the replay. A failed null message is stored as
86
+ * `failed`.
87
+ *
88
+ * @returns The stored record after the reset.
89
+ */
90
+ export declare function resetRetryTerminalSession(context: RetryTerminalResetContext, failedEnvelopeId: string): Promise<StoredRetryRequest | null>;
91
+ /**
92
+ * Attach the raw group ID of a group message to an error that its decrypt
93
+ * threw. The retry request record of the failed envelope then keeps the
94
+ * group, so an `expired-content` end marks the sender key of that group.
95
+ */
96
+ export declare function attachFailedGroup(error: unknown, groupId: string): void;
97
+ /** The raw group ID that `attachFailedGroup` attached to an error. */
98
+ export declare function failedGroupOf(error: unknown): string | undefined;
99
+ export {};
100
+ //# sourceMappingURL=retry-terminal-recovery.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"retry-terminal-recovery.d.ts","sourceRoot":"","sources":["../../client/retry-terminal-recovery.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EACL,eAAe,EAMf,KAAK,kBAAkB,EACxB,MAAM,4BAA4B,CAAC;A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KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAEhE"}
@@ -0,0 +1,164 @@
1
+ /**
2
+ * The session reset of the requester after a retry request ends as
3
+ * `expired-content`.
4
+ *
5
+ * The request got no answer before its deadline, so the session with the
6
+ * device that sent the failed envelope can be out of step. The requester
7
+ * archives that session, deletes its sender-key handoff rows for each device
8
+ * of that account in every group, and sends one null message to the
9
+ * device, at most once an hour for each device. The null message, or else
10
+ * the next ordinary message, starts a new session with the device. The
11
+ * other terminal classes and a retryable post failure reset nothing.
12
+ *
13
+ * Each step is stored on the request record when it ends, so a replay of
14
+ * the terminal state after a restart or a client stop does not archive a
15
+ * newer session.
16
+ */
17
+ import { getRetryRequest, listRetryRequestIds, RETRY_TERMINAL_NULL_MESSAGE_INTERVAL_MS, updateRetryRequest, } from '../local/store/reliability.js';
18
+ import { createKeyedLocks, withKeyedLock } from '../utils/keyed-lock.js';
19
+ import { callHook } from './event-hooks.js';
20
+ import { rethrowRelayWorkStopped } from './relay-work.js';
21
+ /**
22
+ * Reset the session with the sender device of an `expired-content` request
23
+ * whose terminal state is not emitted. Another class, an emitted state, and
24
+ * a context with no reset steps do nothing.
25
+ *
26
+ * The steps run in this order. A step that a stored marker shows as done
27
+ * does not run again.
28
+ *
29
+ * 1. The session with the device is archived, after its decrypts that are
30
+ * in progress end.
31
+ * 2. The handoff rows of each device of the account in every group are
32
+ * deleted, after the archive, as one Signal client does at an automatic
33
+ * session reset. The step runs for a group message and for a
34
+ * pairwise message. The next send of each group gives its current key to
35
+ * each device of the account, and to the device through the new session.
36
+ * 3. The record stores the archived device and the sender key outcome,
37
+ * and the `onSessionArchived` hook runs.
38
+ * 4. Under one lock for each device, a null message goes to the device
39
+ * when no other request sent one to it in the last hour. The record
40
+ * stores the outcome.
41
+ *
42
+ * A RelayWorkStopped while the archive waits for the decrypt lock
43
+ * propagates, and the replay runs the reset again. A failure of steps 1 to
44
+ * 3 also propagates. A crash between the archive and its stored marker
45
+ * archives again at the replay. A failed null message is stored as
46
+ * `failed`.
47
+ *
48
+ * @returns The stored record after the reset.
49
+ */
50
+ export async function resetRetryTerminalSession(context, failedEnvelopeId) {
51
+ const { storage, reset } = context;
52
+ let record = await getRetryRequest(storage, failedEnvelopeId);
53
+ const terminal = record?.terminal;
54
+ if (!record || !terminal || terminal.emitted || terminal.class !== 'expired-content') {
55
+ return record;
56
+ }
57
+ // An expired request always has its stored envelope. Its target is the
58
+ // device that sent the failed envelope.
59
+ if (!reset || !record.envelope)
60
+ return record;
61
+ const device = {
62
+ userId: record.envelope.targetUserId,
63
+ deviceId: record.envelope.targetDeviceId,
64
+ };
65
+ let recovery = record.recovery;
66
+ if (!recovery) {
67
+ await reset.archiveSession(device);
68
+ const senderKey = (await reset.invalidateAccountSenderKeyHandoffs(device.userId, record.groupId))
69
+ ? 'applied'
70
+ : 'skipped';
71
+ recovery = { userId: device.userId, deviceId: device.deviceId, senderKey };
72
+ record = await updateRetryRequest(storage, failedEnvelopeId, record.retryId, record.attempt, {
73
+ recovery,
74
+ });
75
+ if (!record)
76
+ return null;
77
+ context.logger.info('Archived the session with the sender of an expired retry request', {
78
+ category: 'E2EE',
79
+ data: {
80
+ failedEnvelopeId,
81
+ sender: `${device.userId}:${device.deviceId}`,
82
+ senderKey,
83
+ behavior: 'RETRY_TERMINAL_SESSION_RESET',
84
+ },
85
+ });
86
+ await callHook(context.hooks, 'onSessionArchived', `${device.userId}:${device.deviceId}`);
87
+ }
88
+ if (recovery.nullMessage)
89
+ return record;
90
+ const archived = recovery;
91
+ const stored = record;
92
+ return withKeyedLock(nullMessageLocks, storage, `${device.userId}:${device.deviceId}`, async () => {
93
+ const nullMessage = await sendResetNullMessage(context, reset, device);
94
+ return updateRetryRequest(storage, failedEnvelopeId, stored.retryId, stored.attempt, {
95
+ recovery: { ...archived, nullMessage },
96
+ });
97
+ });
98
+ }
99
+ /** One null message check and send at a time for each device of a store. */
100
+ const nullMessageLocks = createKeyedLocks();
101
+ /** Send the null message of a reset, unless the limit for the device refuses it. */
102
+ async function sendResetNullMessage(context, reset, device) {
103
+ const now = Date.now();
104
+ if (await sentNullMessageSince(context, device, now - RETRY_TERMINAL_NULL_MESSAGE_INTERVAL_MS)) {
105
+ return { outcome: 'limited', at: now };
106
+ }
107
+ try {
108
+ await reset.sendNullMessage(device);
109
+ return { outcome: 'sent', at: Date.now() };
110
+ }
111
+ catch (error) {
112
+ rethrowRelayWorkStopped(error);
113
+ // The archived session stays archived, so the next ordinary message
114
+ // starts the new session.
115
+ context.logger.warn('The null message of a session reset failed', {
116
+ category: 'E2EE',
117
+ data: {
118
+ recipient: `${device.userId}:${device.deviceId}`,
119
+ behavior: 'RETRY_TERMINAL_NULL_MESSAGE_FAILED',
120
+ error: error.message,
121
+ },
122
+ });
123
+ return { outcome: 'failed', at: Date.now() };
124
+ }
125
+ }
126
+ /**
127
+ * True when a stored reset sent a null message to the device at or after
128
+ * the given time. The request records hold the send times, and they live
129
+ * longer than the limit interval.
130
+ */
131
+ async function sentNullMessageSince(context, device, since) {
132
+ for (const id of await listRetryRequestIds(context.storage)) {
133
+ let recovery;
134
+ try {
135
+ recovery = (await getRetryRequest(context.storage, id))?.recovery;
136
+ }
137
+ catch {
138
+ // A corrupt record holds no send time. The scheduler reports it.
139
+ continue;
140
+ }
141
+ if (recovery?.userId === device.userId &&
142
+ recovery.deviceId === device.deviceId &&
143
+ recovery.nullMessage?.outcome === 'sent' &&
144
+ recovery.nullMessage.at >= since) {
145
+ return true;
146
+ }
147
+ }
148
+ return false;
149
+ }
150
+ const failedGroups = new WeakMap();
151
+ /**
152
+ * Attach the raw group ID of a group message to an error that its decrypt
153
+ * threw. The retry request record of the failed envelope then keeps the
154
+ * group, so an `expired-content` end marks the sender key of that group.
155
+ */
156
+ export function attachFailedGroup(error, groupId) {
157
+ if (typeof error === 'object' && error !== null)
158
+ failedGroups.set(error, groupId);
159
+ }
160
+ /** The raw group ID that `attachFailedGroup` attached to an error. */
161
+ export function failedGroupOf(error) {
162
+ return typeof error === 'object' && error !== null ? failedGroups.get(error) : undefined;
163
+ }
164
+ //# sourceMappingURL=retry-terminal-recovery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"retry-terminal-recovery.js","sourceRoot":"","sources":["../../client/retry-terminal-recovery.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,uCAAuC,EACvC,kBAAkB,GAInB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACtE,OAAO,EAAE,QAAQ,EAAkC,MAAM,eAAe,CAAC;AACzE,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AA+CvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAC7C,OAAkC,EAClC,gBAAwB;IAExB,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC;IACnC,IAAI,MAAM,GAAG,MAAM,eAAe,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAC;IAC9D,MAAM,QAAQ,GAAG,MAAM,EAAE,QAAQ,CAAC;IAClC,IAAI,CAAC,MAAM,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC,OAAO,IAAI,QAAQ,CAAC,KAAK,KAAK,iBAAiB,EAAE,CAAC;QACrF,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,uEAAuE;IACvE,wCAAwC;IACxC,IAAI,CAAC,KAAK,IAAI,CAAC,MAAM,CAAC,QAAQ;QAAE,OAAO,MAAM,CAAC;IAC9C,MAAM,MAAM,GAAwB;QAClC,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,YAAY;QACpC,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC,cAAc;KACzC,CAAC;IAEF,IAAI,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;IAC/B,IAAI,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