@open-e2ee/signal-protocol-sdk 14.1.0 → 14.3.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 (401) hide show
  1. package/ADAPTERS.md +5 -5
  2. package/CHANGELOG.md +505 -0
  3. package/README.md +24 -19
  4. package/SECURITY.md +2 -2
  5. package/TROUBLESHOOTING.md +1 -1
  6. package/client/README.md +30 -18
  7. package/device/README.md +6 -5
  8. package/dist/client/client.d.ts +49 -38
  9. package/dist/client/client.d.ts.map +1 -1
  10. package/dist/client/client.js +231 -155
  11. package/dist/client/client.js.map +1 -1
  12. package/dist/client/compose.d.ts +4 -2
  13. package/dist/client/compose.d.ts.map +1 -1
  14. package/dist/client/compose.js +6 -1
  15. package/dist/client/compose.js.map +1 -1
  16. package/dist/client/config.d.ts +15 -6
  17. package/dist/client/config.d.ts.map +1 -1
  18. package/dist/client/config.js.map +1 -1
  19. package/dist/client/content-adapter.d.ts +9 -0
  20. package/dist/client/content-adapter.d.ts.map +1 -1
  21. package/dist/client/content-adapter.js +6 -0
  22. package/dist/client/content-adapter.js.map +1 -1
  23. package/dist/client/delivery-status.d.ts +2 -2
  24. package/dist/client/delivery-status.d.ts.map +1 -1
  25. package/dist/client/delivery-status.js +10 -4
  26. package/dist/client/delivery-status.js.map +1 -1
  27. package/dist/client/device-set-reconciliation.d.ts +23 -15
  28. package/dist/client/device-set-reconciliation.d.ts.map +1 -1
  29. package/dist/client/device-set-reconciliation.js +16 -13
  30. package/dist/client/device-set-reconciliation.js.map +1 -1
  31. package/dist/client/event-hooks.d.ts +15 -5
  32. package/dist/client/event-hooks.d.ts.map +1 -1
  33. package/dist/client/event-hooks.js +39 -4
  34. package/dist/client/event-hooks.js.map +1 -1
  35. package/dist/client/group-device-set.d.ts +1 -1
  36. package/dist/client/group-device-set.d.ts.map +1 -1
  37. package/dist/client/group-key-sync.js +1 -1
  38. package/dist/client/group-key-sync.js.map +1 -1
  39. package/dist/client/group-outbox.d.ts +7 -7
  40. package/dist/client/group-outbox.d.ts.map +1 -1
  41. package/dist/client/group-outbox.js +24 -24
  42. package/dist/client/group-outbox.js.map +1 -1
  43. package/dist/client/group-sealed-sender.d.ts +1 -1
  44. package/dist/client/group-sealed-sender.d.ts.map +1 -1
  45. package/dist/client/group-sender-key-operations.js +1 -1
  46. package/dist/client/group-sender-key-operations.js.map +1 -1
  47. package/dist/client/headless.d.ts +6 -6
  48. package/dist/client/headless.d.ts.map +1 -1
  49. package/dist/client/headless.js +7 -7
  50. package/dist/client/headless.js.map +1 -1
  51. package/dist/client/hosted-anonymous-delivery.d.ts +6 -6
  52. package/dist/client/hosted-anonymous-delivery.d.ts.map +1 -1
  53. package/dist/client/hosted-anonymous-delivery.js +17 -17
  54. package/dist/client/hosted-anonymous-delivery.js.map +1 -1
  55. package/dist/client/hosted-assertion-id.d.ts +1 -1
  56. package/dist/client/hosted-assertion-id.d.ts.map +1 -1
  57. package/dist/client/hosted-assertion-id.js +1 -1
  58. package/dist/client/hosted-assertion-id.js.map +1 -1
  59. package/dist/client/hosted-connection.d.ts +5 -5
  60. package/dist/client/hosted-connection.d.ts.map +1 -1
  61. package/dist/client/hosted-connection.js +32 -32
  62. package/dist/client/hosted-connection.js.map +1 -1
  63. package/dist/client/hosted-device-link-transport.d.ts +2 -2
  64. package/dist/client/hosted-device-link-transport.d.ts.map +1 -1
  65. package/dist/client/hosted-device-link-transport.js +1 -1
  66. package/dist/client/hosted-device-link-transport.js.map +1 -1
  67. package/dist/client/hosted-device-link.d.ts +5 -1
  68. package/dist/client/hosted-device-link.d.ts.map +1 -1
  69. package/dist/client/hosted-device-link.js +7 -4
  70. package/dist/client/hosted-device-link.js.map +1 -1
  71. package/dist/client/hosted-device-standing.d.ts +13 -5
  72. package/dist/client/hosted-device-standing.d.ts.map +1 -1
  73. package/dist/client/hosted-device-standing.js +11 -6
  74. package/dist/client/hosted-device-standing.js.map +1 -1
  75. package/dist/client/hosted-group-authority.d.ts +2 -2
  76. package/dist/client/hosted-group-authority.d.ts.map +1 -1
  77. package/dist/client/hosted-group-authority.js +8 -8
  78. package/dist/client/hosted-group-authority.js.map +1 -1
  79. package/dist/client/hosted-groups.d.ts +4 -4
  80. package/dist/client/hosted-groups.d.ts.map +1 -1
  81. package/dist/client/hosted-groups.js +8 -8
  82. package/dist/client/hosted-groups.js.map +1 -1
  83. package/dist/client/hosted-http-error.d.ts +7 -3
  84. package/dist/client/hosted-http-error.d.ts.map +1 -1
  85. package/dist/client/hosted-http-error.js +6 -3
  86. package/dist/client/hosted-http-error.js.map +1 -1
  87. package/dist/client/hosted-mailbox-subscription.d.ts +10 -10
  88. package/dist/client/hosted-mailbox-subscription.d.ts.map +1 -1
  89. package/dist/client/hosted-mailbox-subscription.js +17 -17
  90. package/dist/client/hosted-mailbox-subscription.js.map +1 -1
  91. package/dist/client/hosted-prekey-publication.d.ts +9 -9
  92. package/dist/client/hosted-prekey-publication.d.ts.map +1 -1
  93. package/dist/client/hosted-prekey-publication.js.map +1 -1
  94. package/dist/client/hosted-presence-frames.d.ts +62 -38
  95. package/dist/client/hosted-presence-frames.d.ts.map +1 -1
  96. package/dist/client/hosted-presence-frames.js +4 -2
  97. package/dist/client/hosted-presence-frames.js.map +1 -1
  98. package/dist/client/hosted-presence.d.ts +22 -14
  99. package/dist/client/hosted-presence.d.ts.map +1 -1
  100. package/dist/client/hosted-presence.js +26 -17
  101. package/dist/client/hosted-presence.js.map +1 -1
  102. package/dist/client/hosted-profile-keys.d.ts +3 -1
  103. package/dist/client/hosted-profile-keys.d.ts.map +1 -1
  104. package/dist/client/hosted-profile-keys.js +19 -15
  105. package/dist/client/hosted-profile-keys.js.map +1 -1
  106. package/dist/client/hosted-push.d.ts +38 -16
  107. package/dist/client/hosted-push.d.ts.map +1 -1
  108. package/dist/client/hosted-push.js +11 -5
  109. package/dist/client/hosted-push.js.map +1 -1
  110. package/dist/client/hosted-resume-error.d.ts +21 -9
  111. package/dist/client/hosted-resume-error.d.ts.map +1 -1
  112. package/dist/client/hosted-resume-error.js +4 -1
  113. package/dist/client/hosted-resume-error.js.map +1 -1
  114. package/dist/client/hosted-resume.d.ts +3 -3
  115. package/dist/client/hosted-resume.d.ts.map +1 -1
  116. package/dist/client/hosted-resume.js +12 -12
  117. package/dist/client/hosted-resume.js.map +1 -1
  118. package/dist/client/hosted-sandbox-identity.d.ts +32 -18
  119. package/dist/client/hosted-sandbox-identity.d.ts.map +1 -1
  120. package/dist/client/hosted-sandbox-identity.js +46 -27
  121. package/dist/client/hosted-sandbox-identity.js.map +1 -1
  122. package/dist/client/hosted-store-records.d.ts +46 -0
  123. package/dist/client/hosted-store-records.d.ts.map +1 -0
  124. package/dist/client/hosted-store-records.js +32 -0
  125. package/dist/client/hosted-store-records.js.map +1 -0
  126. package/dist/client/hosted-transport.d.ts +41 -33
  127. package/dist/client/hosted-transport.d.ts.map +1 -1
  128. package/dist/client/hosted-transport.js +146 -101
  129. package/dist/client/hosted-transport.js.map +1 -1
  130. package/dist/client/hosted-trust.d.ts +1 -1
  131. package/dist/client/hosted-trust.d.ts.map +1 -1
  132. package/dist/client/hosted-trust.js +1 -1
  133. package/dist/client/hosted-trust.js.map +1 -1
  134. package/dist/client/hosted.d.ts +138 -72
  135. package/dist/client/hosted.d.ts.map +1 -1
  136. package/dist/client/hosted.js +102 -60
  137. package/dist/client/hosted.js.map +1 -1
  138. package/dist/client/index.d.ts +4 -4
  139. package/dist/client/index.d.ts.map +1 -1
  140. package/dist/client/index.js +4 -4
  141. package/dist/client/index.js.map +1 -1
  142. package/dist/client/key-rotation-core.d.ts +4 -4
  143. package/dist/client/key-rotation-core.d.ts.map +1 -1
  144. package/dist/client/key-rotation-core.js +8 -8
  145. package/dist/client/key-rotation-core.js.map +1 -1
  146. package/dist/client/key-rotation.js +2 -2
  147. package/dist/client/key-rotation.js.map +1 -1
  148. package/dist/client/messages.d.ts +3 -3
  149. package/dist/client/messages.d.ts.map +1 -1
  150. package/dist/client/messages.js +18 -18
  151. package/dist/client/messages.js.map +1 -1
  152. package/dist/client/one-time-prekey-refill.d.ts +1 -1
  153. package/dist/client/one-time-prekey-refill.d.ts.map +1 -1
  154. package/dist/client/prekeys.js +17 -17
  155. package/dist/client/prekeys.js.map +1 -1
  156. package/dist/client/receive-queue.d.ts +4 -4
  157. package/dist/client/receive-queue.d.ts.map +1 -1
  158. package/dist/client/receive-queue.js +29 -29
  159. package/dist/client/receive-queue.js.map +1 -1
  160. package/dist/client/receive-work-seed.d.ts +6 -2
  161. package/dist/client/receive-work-seed.d.ts.map +1 -1
  162. package/dist/client/receive-work-seed.js.map +1 -1
  163. package/dist/client/recovery-driver.js +7 -7
  164. package/dist/client/recovery-driver.js.map +1 -1
  165. package/dist/client/retry-request-envelope.d.ts +3 -3
  166. package/dist/client/retry-request-envelope.d.ts.map +1 -1
  167. package/dist/client/retry-request-envelope.js +10 -10
  168. package/dist/client/retry-request-envelope.js.map +1 -1
  169. package/dist/client/retry-request-lifecycle.d.ts +1 -1
  170. package/dist/client/retry-request-lifecycle.d.ts.map +1 -1
  171. package/dist/client/retry-request-lifecycle.js +8 -8
  172. package/dist/client/retry-request-lifecycle.js.map +1 -1
  173. package/dist/client/retry-terminal-recovery.js +2 -2
  174. package/dist/client/retry-terminal-recovery.js.map +1 -1
  175. package/dist/client/retry.js +13 -13
  176. package/dist/client/retry.js.map +1 -1
  177. package/dist/client/sealed-sender.d.ts +13 -4
  178. package/dist/client/sealed-sender.d.ts.map +1 -1
  179. package/dist/client/sealed-sender.js +27 -15
  180. package/dist/client/sealed-sender.js.map +1 -1
  181. package/dist/client/send-deadline.d.ts +6 -6
  182. package/dist/client/send-deadline.d.ts.map +1 -1
  183. package/dist/client/send-deadline.js +37 -23
  184. package/dist/client/send-deadline.js.map +1 -1
  185. package/dist/client/send-intent-driver.js +9 -9
  186. package/dist/client/send-intent-driver.js.map +1 -1
  187. package/dist/client/sessions.js +11 -11
  188. package/dist/client/sessions.js.map +1 -1
  189. package/dist/client/{relay-acceptance.d.ts → signal-relay-acceptance.d.ts} +9 -9
  190. package/dist/client/signal-relay-acceptance.d.ts.map +1 -0
  191. package/dist/client/{relay-acceptance.js → signal-relay-acceptance.js} +7 -7
  192. package/dist/client/signal-relay-acceptance.js.map +1 -0
  193. package/dist/client/{relay-device-refusal.d.ts → signal-relay-device-refusal.d.ts} +7 -7
  194. package/dist/client/signal-relay-device-refusal.d.ts.map +1 -0
  195. package/dist/client/{relay-device-refusal.js → signal-relay-device-refusal.js} +9 -9
  196. package/dist/client/signal-relay-device-refusal.js.map +1 -0
  197. package/dist/client/{relay-lifecycle.d.ts → signal-relay-lifecycle.d.ts} +18 -9
  198. package/dist/client/signal-relay-lifecycle.d.ts.map +1 -0
  199. package/dist/client/{relay-lifecycle.js → signal-relay-lifecycle.js} +16 -7
  200. package/dist/client/signal-relay-lifecycle.js.map +1 -0
  201. package/dist/client/{relay-period-close.d.ts → signal-relay-period-close.d.ts} +1 -1
  202. package/dist/client/signal-relay-period-close.d.ts.map +1 -0
  203. package/dist/client/{relay-period-close.js → signal-relay-period-close.js} +1 -1
  204. package/dist/client/signal-relay-period-close.js.map +1 -0
  205. package/dist/client/{relay-protocol.d.ts → signal-relay-protocol.d.ts} +12 -8
  206. package/dist/client/signal-relay-protocol.d.ts.map +1 -0
  207. package/dist/client/{relay-protocol.js → signal-relay-protocol.js} +13 -10
  208. package/dist/client/signal-relay-protocol.js.map +1 -0
  209. package/dist/client/{relay-receipt-intake.d.ts → signal-relay-receipt-intake.d.ts} +12 -12
  210. package/dist/client/signal-relay-receipt-intake.d.ts.map +1 -0
  211. package/dist/client/{relay-receipt-intake.js → signal-relay-receipt-intake.js} +9 -9
  212. package/dist/client/signal-relay-receipt-intake.js.map +1 -0
  213. package/dist/client/{relay-receipt-join.d.ts → signal-relay-receipt-join.d.ts} +8 -8
  214. package/dist/client/signal-relay-receipt-join.d.ts.map +1 -0
  215. package/dist/client/{relay-receipt-join.js → signal-relay-receipt-join.js} +11 -11
  216. package/dist/client/signal-relay-receipt-join.js.map +1 -0
  217. package/dist/client/{relay-request-deadline.d.ts → signal-relay-request-deadline.d.ts} +3 -3
  218. package/dist/client/signal-relay-request-deadline.d.ts.map +1 -0
  219. package/dist/client/{relay-request-deadline.js → signal-relay-request-deadline.js} +4 -4
  220. package/dist/client/signal-relay-request-deadline.js.map +1 -0
  221. package/dist/client/{relay-sealed-route.d.ts → signal-relay-sealed-route.d.ts} +1 -1
  222. package/dist/client/signal-relay-sealed-route.d.ts.map +1 -0
  223. package/dist/client/{relay-sealed-route.js → signal-relay-sealed-route.js} +1 -1
  224. package/dist/client/signal-relay-sealed-route.js.map +1 -0
  225. package/dist/client/{relay-subscription.d.ts → signal-relay-subscription.d.ts} +12 -12
  226. package/dist/client/signal-relay-subscription.d.ts.map +1 -0
  227. package/dist/client/{relay-subscription.js → signal-relay-subscription.js} +23 -23
  228. package/dist/client/signal-relay-subscription.js.map +1 -0
  229. package/dist/client/{relay-work.d.ts → signal-relay-work.d.ts} +7 -7
  230. package/dist/client/signal-relay-work.d.ts.map +1 -0
  231. package/dist/client/{relay-work.js → signal-relay-work.js} +13 -13
  232. package/dist/client/signal-relay-work.js.map +1 -0
  233. package/dist/client/signal-service-cipher.d.ts +10 -8
  234. package/dist/client/signal-service-cipher.d.ts.map +1 -1
  235. package/dist/client/signal-service-cipher.js +102 -97
  236. package/dist/client/signal-service-cipher.js.map +1 -1
  237. package/dist/client/state.d.ts +4 -4
  238. package/dist/client/state.d.ts.map +1 -1
  239. package/dist/client/state.js +3 -3
  240. package/dist/client/state.js.map +1 -1
  241. package/dist/client/types.d.ts +13 -4
  242. package/dist/client/types.d.ts.map +1 -1
  243. package/dist/client/types.js.map +1 -1
  244. package/dist/device/connection.d.ts +10 -4
  245. package/dist/device/connection.d.ts.map +1 -1
  246. package/dist/device/connection.js +8 -3
  247. package/dist/device/connection.js.map +1 -1
  248. package/dist/device/index.d.ts +2 -2
  249. package/dist/device/index.d.ts.map +1 -1
  250. package/dist/device/index.js +1 -1
  251. package/dist/device/index.js.map +1 -1
  252. package/dist/device/types.d.ts +3 -1
  253. package/dist/device/types.d.ts.map +1 -1
  254. package/dist/hooks/index.d.ts +2 -2
  255. package/dist/hooks/index.d.ts.map +1 -1
  256. package/dist/hooks/index.js +2 -2
  257. package/dist/hooks/index.js.map +1 -1
  258. package/dist/hooks/use-signal-relay-connection-state.d.ts +39 -0
  259. package/dist/hooks/use-signal-relay-connection-state.d.ts.map +1 -0
  260. package/dist/hooks/use-signal-relay-connection-state.js +45 -0
  261. package/dist/hooks/use-signal-relay-connection-state.js.map +1 -0
  262. package/dist/hooks/use-signal-relay-lifecycle.d.ts +43 -0
  263. package/dist/hooks/use-signal-relay-lifecycle.d.ts.map +1 -0
  264. package/dist/hooks/use-signal-relay-lifecycle.js +38 -0
  265. package/dist/hooks/use-signal-relay-lifecycle.js.map +1 -0
  266. package/dist/index.d.ts +16 -9
  267. package/dist/index.d.ts.map +1 -1
  268. package/dist/index.js +6 -5
  269. package/dist/index.js.map +1 -1
  270. package/dist/internal/groups/authority-certificate.d.ts +8 -1
  271. package/dist/internal/groups/authority-certificate.d.ts.map +1 -1
  272. package/dist/internal/groups/authority-certificate.js +29 -6
  273. package/dist/internal/groups/authority-certificate.js.map +1 -1
  274. package/dist/internal/protocol/sealed-sender/certificate.js +2 -2
  275. package/dist/internal/protocol/sealed-sender/certificate.js.map +1 -1
  276. package/dist/internal/protocol/sealed-sender/proto/index.d.ts +1 -1
  277. package/dist/internal/protocol/sealed-sender/proto/index.d.ts.map +1 -1
  278. package/dist/internal/protocol/sealed-sender/proto/index.js +5 -5
  279. package/dist/internal/protocol/sealed-sender/proto/index.js.map +1 -1
  280. package/dist/internal/sesame/device-registry.d.ts +13 -13
  281. package/dist/internal/sesame/device-registry.d.ts.map +1 -1
  282. package/dist/internal/sesame/device-registry.js +20 -20
  283. package/dist/internal/sesame/device-registry.js.map +1 -1
  284. package/dist/local/store/receive-work.d.ts +29 -0
  285. package/dist/local/store/receive-work.d.ts.map +1 -1
  286. package/dist/local/store/receive-work.js +58 -1
  287. package/dist/local/store/receive-work.js.map +1 -1
  288. package/dist/local/store/received-content.d.ts +1 -1
  289. package/dist/local/store/received-content.d.ts.map +1 -1
  290. package/dist/local/store/reliability.d.ts +11 -3
  291. package/dist/local/store/reliability.d.ts.map +1 -1
  292. package/dist/local/store/reliability.js +4 -0
  293. package/dist/local/store/reliability.js.map +1 -1
  294. package/dist/local/store/sqlite/key-storage/index.d.ts +3 -9
  295. package/dist/local/store/sqlite/key-storage/index.d.ts.map +1 -1
  296. package/dist/local/store/sqlite/key-storage/index.js.map +1 -1
  297. package/dist/local/store/sqlite/key-storage/signed-prekeys.d.ts +1 -7
  298. package/dist/local/store/sqlite/key-storage/signed-prekeys.d.ts.map +1 -1
  299. package/dist/local/store/sqlite/key-storage/signed-prekeys.js.map +1 -1
  300. package/dist/local/store/sqlite/models/kyber-prekey.d.ts +4 -9
  301. package/dist/local/store/sqlite/models/kyber-prekey.d.ts.map +1 -1
  302. package/dist/local/store/sqlite/models/kyber-prekey.js +4 -1
  303. package/dist/local/store/sqlite/models/kyber-prekey.js.map +1 -1
  304. package/dist/local/store/sqlite/store.d.ts.map +1 -1
  305. package/dist/local/store/sqlite/store.js +1 -2
  306. package/dist/local/store/sqlite/store.js.map +1 -1
  307. package/dist/remote/signal-relay/connection-state.d.ts +16 -0
  308. package/dist/remote/signal-relay/connection-state.d.ts.map +1 -0
  309. package/dist/remote/{relay → signal-relay}/connection-state.js +1 -1
  310. package/dist/remote/signal-relay/connection-state.js.map +1 -0
  311. package/dist/remote/{relay → signal-relay}/device-set.d.ts +3 -3
  312. package/dist/remote/signal-relay/device-set.d.ts.map +1 -0
  313. package/dist/remote/{relay → signal-relay}/device-set.js +7 -7
  314. package/dist/remote/signal-relay/device-set.js.map +1 -0
  315. package/dist/remote/{relay → signal-relay}/index.d.ts +3 -3
  316. package/dist/remote/signal-relay/index.d.ts.map +1 -0
  317. package/dist/remote/{relay → signal-relay}/index.js +2 -2
  318. package/dist/remote/signal-relay/index.js.map +1 -0
  319. package/dist/remote/{relay → signal-relay}/request-admission.d.ts +2 -2
  320. package/dist/remote/signal-relay/request-admission.d.ts.map +1 -0
  321. package/dist/remote/{relay → signal-relay}/request-admission.js +5 -5
  322. package/dist/remote/signal-relay/request-admission.js.map +1 -0
  323. package/dist/remote/{relay → signal-relay}/types.d.ts +29 -10
  324. package/dist/remote/signal-relay/types.d.ts.map +1 -0
  325. package/dist/remote/{relay → signal-relay}/types.js +1 -1
  326. package/dist/remote/signal-relay/types.js.map +1 -0
  327. package/dist/safety/core.d.ts +1 -1
  328. package/dist/safety/core.js +1 -1
  329. package/dist/types/api.d.ts +38 -15
  330. package/dist/types/api.d.ts.map +1 -1
  331. package/dist/types/errors.d.ts +62 -7
  332. package/dist/types/errors.d.ts.map +1 -1
  333. package/dist/types/errors.js +68 -8
  334. package/dist/types/errors.js.map +1 -1
  335. package/dist/types/renamed-member.d.ts +48 -0
  336. package/dist/types/renamed-member.d.ts.map +1 -0
  337. package/dist/types/renamed-member.js +78 -0
  338. package/dist/types/renamed-member.js.map +1 -0
  339. package/dist/utils/bounded-fan-out.d.ts +2 -2
  340. package/dist/utils/bounded-fan-out.d.ts.map +1 -1
  341. package/dist/utils/bounded-fan-out.js +2 -2
  342. package/dist/utils/bounded-fan-out.js.map +1 -1
  343. package/dist/utils/retry.d.ts +3 -3
  344. package/dist/utils/retry.d.ts.map +1 -1
  345. package/dist/utils/retry.js +4 -3
  346. package/dist/utils/retry.js.map +1 -1
  347. package/docs/ASSURANCE.md +9 -9
  348. package/docs/CLIENT_COMPOSITION.md +7 -5
  349. package/docs/DEVIATIONS.md +8 -5
  350. package/docs/ERROR_HANDLING.md +21 -21
  351. package/docs/GETTING_STARTED.md +22 -15
  352. package/docs/INTERFACES.md +3 -3
  353. package/docs/PACKAGE_SURFACE.md +14 -4
  354. package/docs/RECIPES.md +271 -11
  355. package/hooks/README.md +11 -11
  356. package/local/store/key-value/README.md +1 -1
  357. package/local/store/web-sqlite/README.md +1 -1
  358. package/package.json +16 -6
  359. package/remote/README.md +3 -3
  360. package/remote/{relay → signal-relay}/README.md +15 -6
  361. package/dist/client/relay-acceptance.d.ts.map +0 -1
  362. package/dist/client/relay-acceptance.js.map +0 -1
  363. package/dist/client/relay-device-refusal.d.ts.map +0 -1
  364. package/dist/client/relay-device-refusal.js.map +0 -1
  365. package/dist/client/relay-lifecycle.d.ts.map +0 -1
  366. package/dist/client/relay-lifecycle.js.map +0 -1
  367. package/dist/client/relay-period-close.d.ts.map +0 -1
  368. package/dist/client/relay-period-close.js.map +0 -1
  369. package/dist/client/relay-protocol.d.ts.map +0 -1
  370. package/dist/client/relay-protocol.js.map +0 -1
  371. package/dist/client/relay-receipt-intake.d.ts.map +0 -1
  372. package/dist/client/relay-receipt-intake.js.map +0 -1
  373. package/dist/client/relay-receipt-join.d.ts.map +0 -1
  374. package/dist/client/relay-receipt-join.js.map +0 -1
  375. package/dist/client/relay-request-deadline.d.ts.map +0 -1
  376. package/dist/client/relay-request-deadline.js.map +0 -1
  377. package/dist/client/relay-sealed-route.d.ts.map +0 -1
  378. package/dist/client/relay-sealed-route.js.map +0 -1
  379. package/dist/client/relay-subscription.d.ts.map +0 -1
  380. package/dist/client/relay-subscription.js.map +0 -1
  381. package/dist/client/relay-work.d.ts.map +0 -1
  382. package/dist/client/relay-work.js.map +0 -1
  383. package/dist/hooks/use-relay-connection-state.d.ts +0 -32
  384. package/dist/hooks/use-relay-connection-state.d.ts.map +0 -1
  385. package/dist/hooks/use-relay-connection-state.js +0 -31
  386. package/dist/hooks/use-relay-connection-state.js.map +0 -1
  387. package/dist/hooks/use-relay-lifecycle.d.ts +0 -36
  388. package/dist/hooks/use-relay-lifecycle.d.ts.map +0 -1
  389. package/dist/hooks/use-relay-lifecycle.js +0 -35
  390. package/dist/hooks/use-relay-lifecycle.js.map +0 -1
  391. package/dist/remote/relay/connection-state.d.ts +0 -16
  392. package/dist/remote/relay/connection-state.d.ts.map +0 -1
  393. package/dist/remote/relay/connection-state.js.map +0 -1
  394. package/dist/remote/relay/device-set.d.ts.map +0 -1
  395. package/dist/remote/relay/device-set.js.map +0 -1
  396. package/dist/remote/relay/index.d.ts.map +0 -1
  397. package/dist/remote/relay/index.js.map +0 -1
  398. package/dist/remote/relay/request-admission.d.ts.map +0 -1
  399. package/dist/remote/relay/request-admission.js.map +0 -1
  400. package/dist/remote/relay/types.d.ts.map +0 -1
  401. package/dist/remote/relay/types.js.map +0 -1
@@ -13,9 +13,10 @@
13
13
  * import { createHostedSignalProtocolClient } from '@open-e2ee/signal-protocol-sdk';
14
14
  *
15
15
  * // Supply a device-local store and the configured identity-provider callback.
16
+ * const signalRelayUrl = process.env.OPEN_E2EE_SIGNAL_RELAY_URL!;
16
17
  * const signal = await createHostedSignalProtocolClient({
17
18
  * adapters: { storage },
18
- * hosted: { relayUrl, getIdentityAssertion },
19
+ * hosted: { relayUrl: signalRelayUrl, getIdentityAssertion },
19
20
  * });
20
21
  *
21
22
  * await signal.send(recipientUserId, 'Hello!');
@@ -53,10 +54,11 @@ import { base64ToBytes, bytesToBase64, constantTimeEqual, generateUuidV4 } from
53
54
  import { deriveGroupSecretParams, getGroupPublicParams } from '../internal/protocol/zk/groups/index.js';
54
55
  import { SERVICE_ID_ACI } from '../internal/protocol/zk/groups/uid-struct.js';
55
56
  import { deserializeSenderCertificate, validateSenderCertificate, } from '../internal/protocol/sealed-sender/index.js';
56
- import { assertHookName, callHook, deferHooks, } from './event-hooks.js';
57
- import { relayProtocolErrorOf } from './device-set-reconciliation.js';
57
+ import { assertHookName, assertRenamedHooks, callHook, currentHookName, deferHooks, } from './event-hooks.js';
58
+ import { readRenamedImplementation, readRenamedOption } from '../types/renamed-member.js';
59
+ import { signalRelayProtocolErrorOf } from './device-set-reconciliation.js';
58
60
  import { DeliveryStatusTracker } from './delivery-status.js';
59
- import { relayReceiptIntakeOf } from './relay-receipt-intake.js';
61
+ import { signalRelayReceiptIntakeOf } from './signal-relay-receipt-intake.js';
60
62
  import { ProtocolAddress } from '../types/address.js';
61
63
  import { getActiveIdentityTypes, resolveSignalProtocolStrategy, SEALED_SENDER_CERTIFICATE_MARGIN_MS, } from './config.js';
62
64
  import { resolveSignalProtocolLogger } from '../logger.js';
@@ -76,7 +78,7 @@ import { profileKeyExchange } from './profile-key-exchange.js';
76
78
  import { attachClientMessageId, SignalProtocolServiceCipher, sortEnvelopesForDecryption, } from './signal-service-cipher.js';
77
79
  import { establishMultiDeviceSessions } from '../internal/sesame/device-registry.js';
78
80
  import { isPartialCommitKyberPreKeyUse, isRetryableDecryptionError } from './retry-utils.js';
79
- import { envelopeTypeForContent, SealedRetryRequestReceived, unsealMessage } from './sealed-sender.js';
81
+ import { envelopeTypeForContent, SealedRetryRequestReceived, sealedSenderSignalProtocolRelayScopeId, unsealMessage, } from './sealed-sender.js';
80
82
  import { ResendableContent } from './resendable-content.js';
81
83
  import { decideContentRecovery, readLocalStoreProtection, resolveContentRecoveryPolicy, resolveReceiveQueuePolicy, } from './storage-protection.js';
82
84
  import { ReceiptType } from './types.js';
@@ -96,16 +98,16 @@ import { manualResendOutcomeEvent, SEND_END_REPORT, sendOutcomeEvent, } from './
96
98
  import { intentContent, SendIntentDriver } from './send-intent-driver.js';
97
99
  import { checkNewSendTimestamp, releaseNewSendTimestampWithLock, reserveNewSendTimestamp, SEND_TIMESTAMP_ORIGIN, } from './send-timestamp.js';
98
100
  import { deliveredEnvelopeFingerprint } from '../local/store/received-content.js';
99
- import { RECEIVE_WORK_DEFAULT_LIMIT } from '../local/store/receive-work.js';
101
+ import { isSignalProtocolRelayOrigin, RECEIVE_WORK_DEFAULT_LIMIT, reportedReceiveWorkOrigin, } from '../local/store/receive-work.js';
100
102
  import { awaitReceiveCompletion, blockReceiveWork, completeReceiveWork, denyReceiveWork, ReceiveQueue, } from './receive-queue.js';
101
103
  import { receiveExpiresAt } from './receive-expiry.js';
102
104
  import { boundReceiveHooks } from './receive-hook-bound.js';
103
105
  import { createReceiveCommit } from './receive-work-seed.js';
104
- import * as RelaySubscriptionOps from './relay-subscription.js';
105
- import { relayReceiptJoinOf } from './relay-receipt-join.js';
106
+ import * as SignalProtocolRelaySubscriptionOps from './signal-relay-subscription.js';
107
+ import { signalRelayReceiptJoinOf } from './signal-relay-receipt-join.js';
106
108
  import { SignalProtocolClientState, SIGNAL_PROTOCOL_CLIENT_CONSTANTS } from './state.js';
107
- import { clientRelayFanOut, rethrowRelayWorkStopped, RelayWorkStopped, } from './relay-work.js';
108
- import { StaleSessionRefreshError } from './relay-device-refusal.js';
109
+ import { clientSignalProtocolRelayFanOut, rethrowSignalProtocolRelayWorkStopped, RelayWorkStopped, } from './signal-relay-work.js';
110
+ import { StaleSessionRefreshError } from './signal-relay-device-refusal.js';
109
111
  import { deleteMediaAttachment, resolveMediaAttachment, } from '../media/index.js';
110
112
  import { StorageBackedSignalProtocolClientMedia } from './media.js';
111
113
  // Group state (Signal Private Group System)
@@ -122,6 +124,55 @@ const storageLock = new AsyncLock({
122
124
  timeout: 30000, // 30 second timeout for storage initialization
123
125
  maxPending: 100, // Limit pending operations
124
126
  });
127
+ /**
128
+ * The connection state of a relay, read through `readRenamedImplementation`.
129
+ */
130
+ function signalProtocolRelayConnectionStateOf(signalProtocolRelay) {
131
+ return readRenamedImplementation(signalProtocolRelay, 'signalProtocolRelayConnectionState', 'relayConnectionState');
132
+ }
133
+ /**
134
+ * Subscribe to the connection transitions of a relay, through
135
+ * `readRenamedImplementation`. A relay with neither member gives no
136
+ * subscription.
137
+ */
138
+ function subscribeSignalProtocolRelayConnectionStateOf(signalProtocolRelay, listener) {
139
+ return readRenamedImplementation(signalProtocolRelay, 'subscribeSignalProtocolRelayConnectionState', 'subscribeRelayConnectionState')?.(listener);
140
+ }
141
+ /**
142
+ * Give each renamed option of a client configuration its new name.
143
+ *
144
+ * @throws SignalProtocolRelayNameConflictError when an option and its
145
+ * deprecated name hold different values.
146
+ */
147
+ function withSignalProtocolRelayNames(config) {
148
+ const operation = 'DefaultSignalProtocolClient.create';
149
+ const { relay: earlierSignalProtocolRelay, ...rest } = config;
150
+ const signalProtocolRelay = readRenamedOption(config.signalProtocolRelay, earlierSignalProtocolRelay, {
151
+ newName: 'signalProtocolRelay',
152
+ earlierName: 'relay',
153
+ operation,
154
+ });
155
+ if (config.hooks)
156
+ assertRenamedHooks(config.hooks, operation);
157
+ const sealedSender = config.sealedSender;
158
+ let resolvedSealedSender = sealedSender;
159
+ if (sealedSender && sealedSender.relayScopeId !== undefined) {
160
+ const { relayScopeId: earlierScopeId, ...sealedRest } = sealedSender;
161
+ resolvedSealedSender = {
162
+ ...sealedRest,
163
+ signalProtocolRelayScopeId: readRenamedOption(sealedSender.signalProtocolRelayScopeId, earlierScopeId, {
164
+ newName: 'sealedSender.signalProtocolRelayScopeId',
165
+ earlierName: 'sealedSender.relayScopeId',
166
+ operation,
167
+ }),
168
+ };
169
+ }
170
+ return {
171
+ ...rest,
172
+ ...(signalProtocolRelay === undefined ? {} : { signalProtocolRelay }),
173
+ ...(resolvedSealedSender === undefined ? {} : { sealedSender: resolvedSealedSender }),
174
+ };
175
+ }
125
176
  /** The reason of a `denied` receive outcome. */
126
177
  function receiveDenialReason(error) {
127
178
  if (error instanceof GroupReceiveRefusedError)
@@ -168,7 +219,7 @@ export class DefaultSignalProtocolClient {
168
219
  static #retainedFactory = (createRetainedClient = (userId, config, identities) => DefaultSignalProtocolClient.#createOwned(userId, config, identities));
169
220
  manager;
170
221
  _storage;
171
- relay;
222
+ signalProtocolRelay;
172
223
  remoteObjectStore;
173
224
  config;
174
225
  _userId;
@@ -238,7 +289,7 @@ export class DefaultSignalProtocolClient {
238
289
  get contentRecoveryStatus() {
239
290
  return this._contentRecoveryStatus;
240
291
  }
241
- stoppedRelayConnection = {
292
+ stoppedSignalProtocolRelayConnection = {
242
293
  state: 'stopped',
243
294
  since: Date.now(),
244
295
  };
@@ -249,7 +300,12 @@ export class DefaultSignalProtocolClient {
249
300
  * @see SignalProtocolClient.relayConnectionState
250
301
  */
251
302
  get relayConnectionState() {
252
- return this.relay?.relayConnectionState ?? this.stoppedRelayConnection;
303
+ return this.signalProtocolRelayConnectionState;
304
+ }
305
+ /** @deprecated Use `relayConnectionState`. SDK 15.0.0 removes this name. */
306
+ get signalProtocolRelayConnectionState() {
307
+ return ((this.signalProtocolRelay && signalProtocolRelayConnectionStateOf(this.signalProtocolRelay)) ??
308
+ this.stoppedSignalProtocolRelayConnection);
253
309
  }
254
310
  /**
255
311
  * Subscribe to relay connection transitions. Without a relay, the listener
@@ -258,9 +314,14 @@ export class DefaultSignalProtocolClient {
258
314
  * @see SignalProtocolClient.subscribeRelayConnectionState
259
315
  */
260
316
  subscribeRelayConnectionState(listener) {
261
- return this.relay?.subscribeRelayConnectionState(listener) ?? (() => undefined);
317
+ return this.subscribeSignalProtocolRelayConnectionState(listener);
318
+ }
319
+ /** @deprecated Use `subscribeRelayConnectionState`. SDK 15.0.0 removes this name. */
320
+ subscribeSignalProtocolRelayConnectionState(listener) {
321
+ return ((this.signalProtocolRelay && subscribeSignalProtocolRelayConnectionStateOf(this.signalProtocolRelay, listener)) ??
322
+ (() => undefined));
262
323
  }
263
- relayUnsubscribe;
324
+ signalProtocolRelayUnsubscribe;
264
325
  /**
265
326
  * Cached sender certificate for sealed sender.
266
327
  * Lazily fetched and refreshed one hour before its signed expiration.
@@ -288,16 +349,16 @@ export class DefaultSignalProtocolClient {
288
349
  * startRelaySubscription() start it when a relay is configured, and stop()
289
350
  * stops it. Each pass is relay work, so its hooks run through that work.
290
351
  */
291
- retryRequests = new RetryRequestScheduler(this.state.relayWork, (work) => {
292
- const relay = this.relay;
293
- const context = { ...this.relayWorkContext(work), stopSignal: work.stopSignal };
352
+ retryRequests = new RetryRequestScheduler(this.state.signalRelayWork, (work) => {
353
+ const signalProtocolRelay = this.signalProtocolRelay;
354
+ const context = { ...this.signalRelayWorkContext(work), stopSignal: work.stopSignal };
294
355
  return {
295
356
  storage: this._storage,
296
357
  logger: this.logger,
297
358
  hooks: work.wrapHooks(this.hooks),
298
359
  local: { userId: this.userId, deviceId: this.deviceId },
299
- send: relay
300
- ? retryRequestPost((recipientUserId, recipientDeviceId, payloadBase64) => this.cipher.sealRetryRequest(recipientUserId, recipientDeviceId, payloadBase64), relay, (envelope) => relay.send(envelope), (recipientUserId, recipientDeviceId) => this.cipher.recipientRegistrationId(recipientUserId, recipientDeviceId), (recipientUserId, recipientDeviceId) => this.refreshRefusedSession(context, recipientUserId, recipientDeviceId))
360
+ send: signalProtocolRelay
361
+ ? retryRequestPost((recipientUserId, recipientDeviceId, payloadBase64) => this.cipher.sealRetryRequest(recipientUserId, recipientDeviceId, payloadBase64), signalProtocolRelay, (envelope) => signalProtocolRelay.send(envelope), (recipientUserId, recipientDeviceId) => this.cipher.recipientRegistrationId(recipientUserId, recipientDeviceId), (recipientUserId, recipientDeviceId) => this.refreshRefusedSession(context, recipientUserId, recipientDeviceId))
301
362
  : undefined,
302
363
  reset: this.retryTerminalReset(context),
303
364
  };
@@ -308,8 +369,8 @@ export class DefaultSignalProtocolClient {
308
369
  * transition to connected, and stop() stops it. Each pass is relay work,
309
370
  * so its hooks run through that work.
310
371
  */
311
- resendJobs = new ResendJobDriver(this.state.relayWork, (work) => {
312
- const ctx = this.relayWorkContext(work);
372
+ resendJobs = new ResendJobDriver(this.state.signalRelayWork, (work) => {
373
+ const ctx = this.signalRelayWorkContext(work);
313
374
  return {
314
375
  storage: this._storage,
315
376
  logger: this.logger,
@@ -368,9 +429,9 @@ export class DefaultSignalProtocolClient {
368
429
  this.hooks = config.hooks || {};
369
430
  this.contentAdapter = config.contentAdapter ?? createDefaultSignalProtocolContentAdapter();
370
431
  // Dependency injection: use the provided relay adapter when configured.
371
- this.relay = config.relay;
432
+ this.signalProtocolRelay = config.signalProtocolRelay;
372
433
  // A relay adapter that sends relay requests itself shares its bound.
373
- this.fanOut = clientRelayFanOut(config.relay);
434
+ this.fanOut = clientSignalProtocolRelayFanOut(config.signalProtocolRelay);
374
435
  // Dependency injection: use the remote object store for encrypted attachments.
375
436
  this.remoteObjectStore = config.remoteObjectStore;
376
437
  // Dependency injection: Storage is always provided by create() callers.
@@ -378,8 +439,8 @@ export class DefaultSignalProtocolClient {
378
439
  throw new Error('Storage must be provided by DefaultSignalProtocolClient.create() callers');
379
440
  }
380
441
  this._storage = config.storage;
381
- this.sendIntents = new SendIntentDriver(this.state.relayWork, this._storage, this.logger, (work) => {
382
- const context = this.relayWorkContext(work);
442
+ this.sendIntents = new SendIntentDriver(this.state.signalRelayWork, this._storage, this.logger, (work) => {
443
+ const context = this.signalRelayWorkContext(work);
383
444
  return {
384
445
  end: (clientMessageId, report) => this.cipher.endPastDeadlineIntent(clientMessageId, report),
385
446
  replay: async (intent, content, report) => {
@@ -403,7 +464,7 @@ export class DefaultSignalProtocolClient {
403
464
  this.contentRecoveryPolicy = resolveContentRecoveryPolicy(config.protocol?.contentRecovery);
404
465
  // Each queue pass runs as relay work, so its hooks call the app through
405
466
  // that work and a stop ends it. Each hook runs under the receive hook bound.
406
- this.receiveQueue = new ReceiveQueue(this.state.relayWork, resolveReceiveQueuePolicy(config.protocol?.receiveQueue), (work) => {
467
+ this.receiveQueue = new ReceiveQueue(this.state.signalRelayWork, resolveReceiveQueuePolicy(config.protocol?.receiveQueue), (work) => {
407
468
  const ctx = this.receivePassContext(work);
408
469
  return {
409
470
  ctx: {
@@ -412,8 +473,8 @@ export class DefaultSignalProtocolClient {
412
473
  receiveQueue: this.receiveQueue,
413
474
  stopSignal: work.stopSignal,
414
475
  },
415
- state: this.relaySubscriptionState,
416
- callbacks: this.relaySubscriptionCallbacks(ctx, work.stopSignal),
476
+ state: this.signalRelaySubscriptionState,
477
+ callbacks: this.signalRelaySubscriptionCallbacks(ctx, work.stopSignal),
417
478
  };
418
479
  }, () => this.cleanupStaleDeviceRecords());
419
480
  this._contentRecoveryStatus = decideContentRecovery(readLocalStoreProtection(this._storage), this.contentRecoveryPolicy, config.groups?.resolveAciBytesByUserIds
@@ -466,7 +527,7 @@ export class DefaultSignalProtocolClient {
466
527
  const cached = sessions.get(authority);
467
528
  if (cached)
468
529
  return cached;
469
- const capability = this.relay?.groupServer;
530
+ const capability = this.signalProtocolRelay?.groupServer;
470
531
  const server = groupConfig.server ?? capability?.server;
471
532
  const issueCredential = groupConfig.issueCredential ??
472
533
  (capability ? () => capability.issueAuthCredential(this._userId, authority.authorityKeyId) : undefined);
@@ -522,13 +583,13 @@ export class DefaultSignalProtocolClient {
522
583
  this.groupManager = this.groupSessionFor(config.groups).manager;
523
584
  }
524
585
  // Initialize cipher for encrypt/decrypt coordination
525
- this.cipher = new SignalProtocolServiceCipher(this._userId, deviceId, this.sesameManager, this.senderKeyManager, this._storage, this.relay, this.remoteObjectStore, this.contentAdapter, this.logger, this.fanOut);
586
+ this.cipher = new SignalProtocolServiceCipher(this._userId, deviceId, this.sesameManager, this.senderKeyManager, this._storage, this.signalProtocolRelay, this.remoteObjectStore, this.contentAdapter, this.logger, this.fanOut);
526
587
  if (this.groupManager) {
527
588
  this.cipher.setGroupSendBarrierChecker((groupId) => this.groupManager.assertGroupSendAllowed(groupId));
528
589
  }
529
590
  // The client applies each Relay delivery receipt of its relay.
530
- if (this.relay) {
531
- relayReceiptIntakeOf(this.relay)?.subscribe((receipt) => this.receiveRelayReceipt(receipt));
591
+ if (this.signalProtocolRelay) {
592
+ signalRelayReceiptIntakeOf(this.signalProtocolRelay)?.subscribe((receipt) => this.receiveSignalProtocolRelayReceipt(receipt));
532
593
  }
533
594
  // Set up auto-session establishment and stale-session refresh.
534
595
  // This enables lazy session creation when sending to users without established sessions
@@ -536,7 +597,7 @@ export class DefaultSignalProtocolClient {
536
597
  if (sessions)
537
598
  this.cipher.setSessionCallbacks(sessions);
538
599
  // A sync payload has no send result, so the cipher reports its error.
539
- this.cipher.setRelayProtocolErrorReporter((error) => callHook(this.hooks, 'onRelayProtocolError', error));
600
+ this.cipher.setSignalProtocolRelayProtocolErrorReporter((error) => callHook(this.hooks, 'onSignalProtocolRelayProtocolError', error));
540
601
  if (config?.sealedSender) {
541
602
  this.cipher.setSealedSenderDeliveryMode(config.sealedSender.deliveryMode ?? 'preferred');
542
603
  if (config.sealedSender.onIdentifiedFallback) {
@@ -582,7 +643,7 @@ export class DefaultSignalProtocolClient {
582
643
  // The receive queue owns the content that waits on a group.
583
644
  hasBlockedContent: async (groupId) => (await this._storage.receiveWorkUsage({ groupId })).items > 0,
584
645
  onFetched: (groupId) => this.receiveQueue.wake(groupId),
585
- runInBackground: (pass) => this.state.relayWork.run(() => pass()),
646
+ runInBackground: (pass) => this.state.signalRelayWork.run(() => pass()),
586
647
  logger: this.logger,
587
648
  });
588
649
  this.groupFetcher = fetcher;
@@ -593,7 +654,7 @@ export class DefaultSignalProtocolClient {
593
654
  ...(config.aci?.uuid && { localAci: config.aci.uuid }),
594
655
  ownDevices: () => this.cipher.localOwnSyncDevices(),
595
656
  send: (input, deviceIds, stopSignal) => this.cipher.sendGroupKeySyncToLocalOtherDevices(input, deviceIds, stopSignal),
596
- runInBackground: (job) => this.state.relayWork.run((work) => job(work.stopSignal)),
657
+ runInBackground: (job) => this.state.signalRelayWork.run((work) => job(work.stopSignal)),
597
658
  logger: this.logger,
598
659
  });
599
660
  this.groupKeySync = keySync;
@@ -637,11 +698,11 @@ export class DefaultSignalProtocolClient {
637
698
  // missing members.
638
699
  if (config?.groups?.endorsementManager &&
639
700
  this.groupStore &&
640
- this.relay?.refreshGroupSendEndorsements &&
701
+ this.signalProtocolRelay?.refreshGroupSendEndorsements &&
641
702
  this.groupManager) {
642
703
  const groupConfig = config.groups;
643
704
  const groupStore = this.groupStore;
644
- const relay = this.relay;
705
+ const signalProtocolRelay = this.signalProtocolRelay;
645
706
  const selfUserId = this._userId;
646
707
  this.cipher.setEndorsementRefresher(async (groupId, memberUserIds) => {
647
708
  const { manager: groupManager, endorsementManager } = await this.resolveGroupSession();
@@ -657,7 +718,7 @@ export class DefaultSignalProtocolClient {
657
718
  // 3. Derive the protocol identifier, not the display identifier's UTF-8 bytes.
658
719
  const groupIdBytes = getGroupPublicParams(secretParams).groupId;
659
720
  // 4. Fetch fresh endorsements from server
660
- const { endorsements } = await relay.refreshGroupSendEndorsements(groupIdBytes, authorization);
721
+ const { endorsements } = await signalProtocolRelay.refreshGroupSendEndorsements(groupIdBytes, authorization);
661
722
  // 5. Get cached group state for member ordering (server order)
662
723
  const state = await groupStore.getGroupState(groupId);
663
724
  if (!state || state.members.length === 0)
@@ -716,7 +777,8 @@ export class DefaultSignalProtocolClient {
716
777
  deviceId: this.deviceId,
717
778
  manager: this.manager,
718
779
  storage: this._storage,
719
- relay: this.relay,
780
+ signalProtocolRelay: this.signalProtocolRelay,
781
+ relay: this.signalProtocolRelay,
720
782
  remoteObjectStore: this.remoteObjectStore,
721
783
  config: this.config,
722
784
  logger: this.logger,
@@ -741,11 +803,11 @@ export class DefaultSignalProtocolClient {
741
803
  * `onDelivered` hook. The replay announces each delivery whose hook did not
742
804
  * return.
743
805
  */
744
- async receiveRelayReceipt(receipt) {
806
+ async receiveSignalProtocolRelayReceipt(receipt) {
745
807
  let announced = false;
746
- await this.state.relayWork.run(async (work) => {
808
+ await this.state.signalRelayWork.run(async (work) => {
747
809
  work.proceed();
748
- const events = await this.deliveries.applyRelayReceipt(receipt);
810
+ const events = await this.deliveries.applySignalProtocolRelayReceipt(receipt);
749
811
  await this.deliveries.announce(work.wrapHooks(this.hooks), events);
750
812
  announced = true;
751
813
  });
@@ -758,7 +820,7 @@ export class DefaultSignalProtocolClient {
758
820
  * the next receipt for the message announces it again.
759
821
  */
760
822
  releaseDeliveries(clientMessageId) {
761
- void this.state.relayWork
823
+ void this.state.signalRelayWork
762
824
  .run(async (work) => {
763
825
  work.proceed();
764
826
  const events = await this.deliveries.release(clientMessageId);
@@ -802,8 +864,8 @@ export class DefaultSignalProtocolClient {
802
864
  if (sealedSender.certificateProvider) {
803
865
  certBase64 = await sealedSender.certificateProvider();
804
866
  }
805
- else if (this.relay?.fetchSenderCertificate) {
806
- certBase64 = await this.relay.fetchSenderCertificate(this.deviceId);
867
+ else if (this.signalProtocolRelay?.fetchSenderCertificate) {
868
+ certBase64 = await this.signalProtocolRelay.fetchSenderCertificate(this.deviceId);
807
869
  }
808
870
  else {
809
871
  throw new EncryptionError('No sender certificate provider configured. Set sealedSender.certificateProvider or use a relay that supports fetchSenderCertificate.', EncryptionErrorCode.INITIALIZATION_FAILED);
@@ -812,7 +874,7 @@ export class DefaultSignalProtocolClient {
812
874
  try {
813
875
  certificate = deserializeSenderCertificate(base64ToBytes(certBase64));
814
876
  await validateSenderCertificate(certificate, sealedSender.trustRoots.map((root) => bytesToBase64(root)), now, {
815
- expectedRelayScopeId: bytesToBase64(sealedSender.relayScopeId),
877
+ expectedRelayScopeId: bytesToBase64(sealedSenderSignalProtocolRelayScopeId(sealedSender)),
816
878
  revokedIssuerKeyIds: sealedSender.revokedIssuerKeyIds,
817
879
  });
818
880
  const identity = await this._storage.getIdentityKey();
@@ -885,10 +947,10 @@ export class DefaultSignalProtocolClient {
885
947
  };
886
948
  }
887
949
  /**
888
- * Get relay subscription state (passed to relay-subscription module)
950
+ * Get relay subscription state (passed to signal-relay-subscription module)
889
951
  */
890
- get relaySubscriptionState() {
891
- return this.state.getRelaySubscriptionState();
952
+ get signalRelaySubscriptionState() {
953
+ return this.state.getSignalProtocolRelaySubscriptionState();
892
954
  }
893
955
  /**
894
956
  * Get relay subscription callbacks (delegate back to DefaultSignalProtocolClient methods).
@@ -897,12 +959,12 @@ export class DefaultSignalProtocolClient {
897
959
  * its own. A retry request runs in the current work, so a stop of that work
898
960
  * reaches the receive route, and the route keeps the request envelope.
899
961
  */
900
- relaySubscriptionCallbacks(ctx, stopSignal) {
962
+ signalRelaySubscriptionCallbacks(ctx, stopSignal) {
901
963
  return {
902
964
  forcePreKeyRotation: () => this.regeneratePreKeysWithFreshIds(),
903
965
  handleDeliveryReceipt: (envelope, receipt) => this.handleDeliveryReceipt(envelope, receipt, ctx),
904
966
  handleTypingIndicator: (envelope, typing) => this.handleTypingIndicator(envelope, typing, ctx),
905
- sendDeliveryReceipt: (userId, timestamps) => this.sendDeliveryReceiptAsRelayWork(userId, timestamps),
967
+ sendDeliveryReceipt: (userId, timestamps) => this.sendDeliveryReceiptAsSignalProtocolRelayWork(userId, timestamps),
906
968
  handleRetryRequest: (request, retry) => RetryOps.handleRetryRequestAndResend(ctx, request, this.retryResponseState, this.retryCallbacks(stopSignal, ctx), this.retryConfig, retry),
907
969
  };
908
970
  }
@@ -916,12 +978,12 @@ export class DefaultSignalProtocolClient {
916
978
  * so the receive queue keeps the receipt and sends it after the next
917
979
  * start
918
980
  */
919
- async sendDeliveryReceiptAsRelayWork(userId, timestamps) {
981
+ async sendDeliveryReceiptAsSignalProtocolRelayWork(userId, timestamps) {
920
982
  let sent = false;
921
- await this.state.relayWork.run(async (work) => {
983
+ await this.state.signalRelayWork.run(async (work) => {
922
984
  const send = this.sendDeliveryReceipt(userId, timestamps, {
923
- ...this.relayWorkContext(work),
924
- stopSignal: this.state.relayWork.stopSignal,
985
+ ...this.signalRelayWorkContext(work),
986
+ stopSignal: this.state.signalRelayWork.stopSignal,
925
987
  });
926
988
  this.deliveryReceiptSends.set(work, send);
927
989
  try {
@@ -941,7 +1003,7 @@ export class DefaultSignalProtocolClient {
941
1003
  * promises settle when the sends finish. They never reject.
942
1004
  */
943
1005
  flushPendingDeliveryReceipts() {
944
- return RelaySubscriptionOps.flushPendingReceipts(this.relaySubscriptionState.receiptAccumulator, (userId, timestamps) => this.sendDeliveryReceiptAsRelayWork(userId, timestamps), this.logger);
1006
+ return SignalProtocolRelaySubscriptionOps.flushPendingReceipts(this.signalRelaySubscriptionState.receiptAccumulator, (userId, timestamps) => this.sendDeliveryReceiptAsSignalProtocolRelayWork(userId, timestamps), this.logger);
945
1007
  }
946
1008
  /**
947
1009
  * Wait for the receipt sends that stop() waits for, with their app hooks,
@@ -966,8 +1028,8 @@ export class DefaultSignalProtocolClient {
966
1028
  * requests. There are none without a relay.
967
1029
  */
968
1030
  retryTerminalReset(context) {
969
- const relay = this.relay;
970
- if (!relay)
1031
+ const signalProtocolRelay = this.signalProtocolRelay;
1032
+ if (!signalProtocolRelay)
971
1033
  return undefined;
972
1034
  const { stopSignal } = context;
973
1035
  return {
@@ -987,7 +1049,7 @@ export class DefaultSignalProtocolClient {
987
1049
  sendNullMessage: async ({ userId, deviceId }) => {
988
1050
  const address = ProtocolAddress.create(userId, deviceId);
989
1051
  if (!(await SessionOps.hasSession(context, address))) {
990
- const bundle = await this.fanOut.request(() => relay.fetchPreKeyBundle(userId, deviceId), stopSignal);
1052
+ const bundle = await this.fanOut.request(() => signalProtocolRelay.fetchPreKeyBundle(userId, deviceId), stopSignal);
991
1053
  if (!bundle)
992
1054
  throw new Error('No prekey bundle for the device of a session reset');
993
1055
  await SessionOps.establishSession(context, this.sesameManager, address, bundle);
@@ -1011,12 +1073,12 @@ export class DefaultSignalProtocolClient {
1011
1073
  * session, and the next post uses it.
1012
1074
  */
1013
1075
  async refreshRefusedSession(context, recipientUserId, recipientDeviceId) {
1014
- const relay = this.relay;
1015
- if (!relay)
1076
+ const signalProtocolRelay = this.signalProtocolRelay;
1077
+ if (!signalProtocolRelay)
1016
1078
  return false;
1017
1079
  const address = ProtocolAddress.create(recipientUserId, recipientDeviceId);
1018
1080
  try {
1019
- const freshBundle = await this.fanOut.request(() => relay.fetchPreKeyBundle(recipientUserId, recipientDeviceId), context.stopSignal);
1081
+ const freshBundle = await this.fanOut.request(() => signalProtocolRelay.fetchPreKeyBundle(recipientUserId, recipientDeviceId), context.stopSignal);
1020
1082
  if (!freshBundle) {
1021
1083
  // Per SESAME §3.2: the session is archived, not deleted, to decrypt
1022
1084
  // delayed messages. No bundle is terminal for the post.
@@ -1044,7 +1106,7 @@ export class DefaultSignalProtocolClient {
1044
1106
  return true;
1045
1107
  }
1046
1108
  catch (error) {
1047
- rethrowRelayWorkStopped(error);
1109
+ rethrowSignalProtocolRelayWorkStopped(error);
1048
1110
  this.logger.warn('Failed to refresh stale session, the post retries', {
1049
1111
  category: 'E2EE',
1050
1112
  data: { recipientUserId, recipientDeviceId, error: error.message },
@@ -1053,7 +1115,7 @@ export class DefaultSignalProtocolClient {
1053
1115
  }
1054
1116
  }
1055
1117
  /** Client context whose hooks call the app through the given relay work. */
1056
- relayWorkContext(work) {
1118
+ signalRelayWorkContext(work) {
1057
1119
  return { ...this.ctx, hooks: work.wrapHooks(this.hooks) };
1058
1120
  }
1059
1121
  /**
@@ -1072,14 +1134,14 @@ export class DefaultSignalProtocolClient {
1072
1134
  * the stop signal ends it. There are none without a relay.
1073
1135
  */
1074
1136
  sendSessionCallbacks(context, stopSignal) {
1075
- const relay = this.relay;
1076
- if (!relay)
1137
+ const signalProtocolRelay = this.signalProtocolRelay;
1138
+ if (!signalProtocolRelay)
1077
1139
  return undefined;
1078
1140
  const establishSession = (address, bundle) => SessionOps.establishSession(context(), this.sesameManager, address, bundle);
1079
1141
  return {
1080
- establishSessions: (recipientUserId, listedDevices) => establishMultiDeviceSessions(this, relay, recipientUserId, {
1142
+ establishSessions: (recipientUserId, listedDevices) => establishMultiDeviceSessions(this, signalProtocolRelay, recipientUserId, {
1081
1143
  establishSession,
1082
- rethrowFatal: rethrowRelayWorkStopped,
1144
+ rethrowFatal: rethrowSignalProtocolRelayWorkStopped,
1083
1145
  fanOut: this.fanOut,
1084
1146
  stopSignal,
1085
1147
  ...(listedDevices && { listedDevices }),
@@ -1097,7 +1159,7 @@ export class DefaultSignalProtocolClient {
1097
1159
  data: { recipientUserId, recipientDeviceId },
1098
1160
  });
1099
1161
  // 2. Fetch fresh prekey bundle
1100
- const freshBundle = await this.fanOut.request(() => relay.fetchPreKeyBundle(recipientUserId, recipientDeviceId), stopSignal);
1162
+ const freshBundle = await this.fanOut.request(() => signalProtocolRelay.fetchPreKeyBundle(recipientUserId, recipientDeviceId), stopSignal);
1101
1163
  if (!freshBundle) {
1102
1164
  this.logger.warn('No prekey bundle available for stale session refresh', {
1103
1165
  category: 'E2EE',
@@ -1119,7 +1181,7 @@ export class DefaultSignalProtocolClient {
1119
1181
  return true;
1120
1182
  }
1121
1183
  catch (error) {
1122
- rethrowRelayWorkStopped(error);
1184
+ rethrowSignalProtocolRelayWorkStopped(error);
1123
1185
  this.logger.error('Failed to refresh stale session', {
1124
1186
  category: 'E2EE',
1125
1187
  data: {
@@ -1154,7 +1216,7 @@ export class DefaultSignalProtocolClient {
1154
1216
  /**
1155
1217
  * Get relay subscription config
1156
1218
  */
1157
- get relaySubscriptionConfig() {
1219
+ get signalRelaySubscriptionConfig() {
1158
1220
  return {
1159
1221
  keyRotationDebounceMs: SIGNAL_PROTOCOL_CLIENT_CONSTANTS.KEY_ROTATION_DEBOUNCE_MS,
1160
1222
  };
@@ -1189,7 +1251,7 @@ export class DefaultSignalProtocolClient {
1189
1251
  * });
1190
1252
  *
1191
1253
  * // With an application-owned authenticated relay transport.
1192
- * const relay = appRelayTransport;
1254
+ * const relay = appSignalProtocolRelayTransport;
1193
1255
  * const signal = await DefaultSignalProtocolClient.create('user-123', {
1194
1256
  * storage,
1195
1257
  * relay,
@@ -1220,6 +1282,7 @@ export class DefaultSignalProtocolClient {
1220
1282
  return DefaultSignalProtocolClient.#createOwned(userId, config);
1221
1283
  }
1222
1284
  static async #createOwned(userId, config, retained) {
1285
+ config = withSignalProtocolRelayNames(config);
1223
1286
  const deviceId = config?.deviceId ?? 1; // Default to primary device
1224
1287
  // Use locking to prevent race conditions when multiple create() calls happen concurrently.
1225
1288
  // The lock allows only one storage instance per userId, which prevents database lock
@@ -1289,7 +1352,7 @@ export class DefaultSignalProtocolClient {
1289
1352
  }
1290
1353
  // Auto-sync to server if relay provided
1291
1354
  let syncFailed = false;
1292
- if (finalConfig?.relay) {
1355
+ if (finalConfig?.signalProtocolRelay) {
1293
1356
  try {
1294
1357
  await client.syncToServer(finalConfig.onProgress);
1295
1358
  }
@@ -1301,18 +1364,18 @@ export class DefaultSignalProtocolClient {
1301
1364
  syncFailed = true;
1302
1365
  }
1303
1366
  }
1304
- client._syncStatus = finalConfig?.relay ? (syncFailed ? 'failed' : 'synced') : 'none';
1367
+ client._syncStatus = finalConfig?.signalProtocolRelay ? (syncFailed ? 'failed' : 'synced') : 'none';
1305
1368
  // Start relay subscription if relay is configured with onMessageDecrypted hook
1306
1369
  // Only subscribe if sync succeeded - subscriptions require a valid server session
1307
- if (!syncFailed && finalConfig?.relay && finalConfig?.hooks?.onMessageDecrypted) {
1308
- client.startRelaySubscription();
1370
+ if (!syncFailed && finalConfig?.signalProtocolRelay && finalConfig?.hooks?.onMessageDecrypted) {
1371
+ client.startSignalProtocolRelaySubscription();
1309
1372
  }
1310
1373
  // Post the stored retry requests whose next attempt time has come, and
1311
1374
  // end the requests past their deadlines. Run the pending resend jobs.
1312
1375
  // The passes run in the background.
1313
1376
  // The receive queue resumes the stored receive records first. With no
1314
1377
  // relay, it serves the helper receives alone.
1315
- if (finalConfig?.relay)
1378
+ if (finalConfig?.signalProtocolRelay)
1316
1379
  client.startRetryRequests();
1317
1380
  else
1318
1381
  void client.receiveQueue.start();
@@ -1400,7 +1463,7 @@ export class DefaultSignalProtocolClient {
1400
1463
  * Normal sync and the managed device link never call this operation.
1401
1464
  */
1402
1465
  async rotateAccountIdentity(expectedCurrentCommitment, identityType = 'aci') {
1403
- if (!this.config.relay) {
1466
+ if (!this.config.signalProtocolRelay) {
1404
1467
  throw new EncryptionError('Relay server not configured', EncryptionErrorCode.INITIALIZATION_FAILED);
1405
1468
  }
1406
1469
  if (expectedCurrentCommitment.length !== 32) {
@@ -1412,7 +1475,7 @@ export class DefaultSignalProtocolClient {
1412
1475
  }
1413
1476
  this._syncStatus = 'failed';
1414
1477
  try {
1415
- await this.config.relay.rotateIdentityKey({
1478
+ await this.config.signalProtocolRelay.rotateIdentityKey({
1416
1479
  userId: this.userId,
1417
1480
  deviceId: this.deviceId,
1418
1481
  identity: createCompositeIdentityV1(replacement),
@@ -1557,7 +1620,7 @@ export class DefaultSignalProtocolClient {
1557
1620
  async regeneratePreKeysWithFreshIds() {
1558
1621
  await PreKeyOps.regeneratePreKeysWithFreshIds(this.ctx);
1559
1622
  const now = Date.now();
1560
- // Update debounce timestamp so concurrent call sites (relay-subscription + retry.ts)
1623
+ // Update debounce timestamp so concurrent call sites (signal-relay-subscription + retry.ts)
1561
1624
  // do not both trigger rotation for the same stale prekey event.
1562
1625
  this.state.setLastPreKeyRotationTime(now);
1563
1626
  // Persist the debounce timestamp across application restarts.
@@ -1697,8 +1760,8 @@ export class DefaultSignalProtocolClient {
1697
1760
  async markMessageDeliveredSilently(envelopeId, options) {
1698
1761
  if (!envelopeId)
1699
1762
  return;
1700
- if (this.relay?.markDelivered) {
1701
- await this.relay.markDelivered(envelopeId).catch((_error) => {
1763
+ if (this.signalProtocolRelay?.markDelivered) {
1764
+ await this.signalProtocolRelay.markDelivered(envelopeId).catch((_error) => {
1702
1765
  this.logger.warn('Failed to mark delivered', {
1703
1766
  category: 'E2EE',
1704
1767
  data: { envelopeId },
@@ -1977,7 +2040,7 @@ export class DefaultSignalProtocolClient {
1977
2040
  }
1978
2041
  let commit;
1979
2042
  try {
1980
- commit = await this.cipher.commitEnvelope(this.relayEnvelopeOf(envelope), {
2043
+ commit = await this.cipher.commitEnvelope(this.signalRelayEnvelopeOf(envelope), {
1981
2044
  sealedSender: this.config.sealedSender,
1982
2045
  });
1983
2046
  }
@@ -2007,7 +2070,7 @@ export class DefaultSignalProtocolClient {
2007
2070
  };
2008
2071
  }
2009
2072
  /** The Relay envelope of an envelope that the application passed. */
2010
- relayEnvelopeOf(envelope) {
2073
+ signalRelayEnvelopeOf(envelope) {
2011
2074
  return {
2012
2075
  ...envelope,
2013
2076
  targetUserId: this.userId,
@@ -2054,7 +2117,7 @@ export class DefaultSignalProtocolClient {
2054
2117
  return { outcome: { kind: 'duplicate' } };
2055
2118
  }
2056
2119
  // The receive queue delivers a Relay record to onMessageDecrypted.
2057
- if (record.origin === 'relay') {
2120
+ if (isSignalProtocolRelayOrigin(record.origin)) {
2058
2121
  return {
2059
2122
  outcome: { kind: 'pending', messageId: record.messageId, reason: 'queued' },
2060
2123
  };
@@ -2102,7 +2165,7 @@ export class DefaultSignalProtocolClient {
2102
2165
  senderKeyDistribution: content.inspected.senderKeyDistribution !== undefined,
2103
2166
  content: content.inspected.senderKeyDistribution === undefined ||
2104
2167
  content.inspected.senderKeyDistributionOnly === false,
2105
- ...RelaySubscriptionOps.groupOfFulfill(content),
2168
+ ...SignalProtocolRelaySubscriptionOps.groupOfFulfill(content),
2106
2169
  });
2107
2170
  // A GroupKeySync from an own device is SDK content, so the caller
2108
2171
  // never gets it.
@@ -2211,7 +2274,7 @@ export class DefaultSignalProtocolClient {
2211
2274
  const failure = { reported: false };
2212
2275
  let admitted;
2213
2276
  try {
2214
- const seed = handle.commit.seed(this.relayEnvelopeOf(inner), arrivedSealed);
2277
+ const seed = handle.commit.seed(this.signalRelayEnvelopeOf(inner), arrivedSealed);
2215
2278
  if (inner.messageType === 'sender_key') {
2216
2279
  // `sender_key` says the payload is a framed SenderKeyMessage. It
2217
2280
  // does not say which group, so the group comes from the frame's
@@ -2319,7 +2382,7 @@ export class DefaultSignalProtocolClient {
2319
2382
  return {
2320
2383
  messageId: record.messageId,
2321
2384
  stage: ready ? 'awaiting-completion' : 'decrypted',
2322
- origin: record.origin,
2385
+ origin: reportedReceiveWorkOrigin(record.origin),
2323
2386
  receivedAt: record.receivedAt,
2324
2387
  senderId: record.senderUserId,
2325
2388
  senderDeviceId: record.senderDeviceId,
@@ -2419,7 +2482,7 @@ export class DefaultSignalProtocolClient {
2419
2482
  for (const envelope of sortEnvelopesForDecryption(envelopes)) {
2420
2483
  releases.push(this.receiveQueue.hold(await deliveredEnvelopeFingerprint(this.userId, this.deviceId, envelope)));
2421
2484
  try {
2422
- const processed = await RelaySubscriptionOps.processRelayMessage(context, this.relayEnvelopeOf(envelope), this.relaySubscriptionState, this.relaySubscriptionCallbacks(context), { ...this.relaySubscriptionConfig, acknowledgeFailures: false });
2485
+ const processed = await SignalProtocolRelaySubscriptionOps.processSignalProtocolRelayMessage(context, this.signalRelayEnvelopeOf(envelope), this.signalRelaySubscriptionState, this.signalRelaySubscriptionCallbacks(context), { ...this.signalRelaySubscriptionConfig, acknowledgeFailures: false });
2423
2486
  (processed ? processedMessageIds : failedMessageIds).push(envelope.id);
2424
2487
  }
2425
2488
  catch {
@@ -2529,13 +2592,13 @@ export class DefaultSignalProtocolClient {
2529
2592
  * receipt of a shared body), it throws the first such refusal. Otherwise it
2530
2593
  * throws an `Error` with the stored code of the first refused device that
2531
2594
  * has one, in the order of the destinations. Otherwise it throws
2532
- * `SendNeverAcceptedByRelayError` with code `SEND_NEVER_ACCEPTED`. A send
2595
+ * `SendNeverAcceptedBySignalProtocolRelayError` with code `SEND_NEVER_ACCEPTED`. A send
2533
2596
  * error before the deadline gives `deadlineAt`, and `retryable` is true
2534
2597
  * when a replay can still post the send.
2535
2598
  *
2536
2599
  * A backdated `timestamp` shortens the deadline. A send with a timestamp
2537
2600
  * 23 hours old has at most 1 hour to post. A send with a timestamp 24 hours
2538
- * old posts nothing and throws `SendNeverAcceptedByRelayError`.
2601
+ * old posts nothing and throws `SendNeverAcceptedBySignalProtocolRelayError`.
2539
2602
  *
2540
2603
  * @param recipientId - User ID or group ID (groups use the package group ID prefix)
2541
2604
  * @param content - DataMessageInput, string, or Uint8Array to encrypt and send
@@ -2715,12 +2778,12 @@ export class DefaultSignalProtocolClient {
2715
2778
  }
2716
2779
  // A Relay that accepted a declared post without comparing it does not
2717
2780
  // change the result. The hook reports it once for the completed send.
2718
- const protocolError = relayProtocolErrorOf(result);
2781
+ const protocolError = signalRelayProtocolErrorOf(result);
2719
2782
  this.releaseDeliveries(clientMessageId);
2720
2783
  if (profileKey)
2721
2784
  await profileKeys?.delivered(recipientId, profileKey);
2722
2785
  if (protocolError)
2723
- await callHook(context.hooks, 'onRelayProtocolError', protocolError);
2786
+ await callHook(context.hooks, 'onSignalProtocolRelayProtocolError', protocolError);
2724
2787
  return result;
2725
2788
  }
2726
2789
  /** @see SignalProtocolClient.resendMessage */
@@ -2825,10 +2888,10 @@ export class DefaultSignalProtocolClient {
2825
2888
  * ```
2826
2889
  */
2827
2890
  async markAsRead(messageId) {
2828
- if (!this.relay) {
2891
+ if (!this.signalProtocolRelay) {
2829
2892
  throw new EncryptionError('Relay server not configured', EncryptionErrorCode.INITIALIZATION_FAILED);
2830
2893
  }
2831
- await this.relay.markDelivered(messageId);
2894
+ await this.signalProtocolRelay.markDelivered(messageId);
2832
2895
  this.logger.debug('Message marked as read', {
2833
2896
  category: 'E2EE',
2834
2897
  data: { messageId },
@@ -2861,7 +2924,8 @@ export class DefaultSignalProtocolClient {
2861
2924
  */
2862
2925
  registerHook(name, callback) {
2863
2926
  assertHookName(name);
2864
- this.hooks[name] = callback;
2927
+ // A deprecated hook name registers the hook under its new name.
2928
+ this.hooks[currentHookName(name)] = callback;
2865
2929
  // Received content waits for this hook, or failed in the hook before.
2866
2930
  if (name === 'onMessageDecrypted')
2867
2931
  this.receiveQueue.retryFailedHooks();
@@ -2871,29 +2935,11 @@ export class DefaultSignalProtocolClient {
2871
2935
  });
2872
2936
  }
2873
2937
  // ============================================================================
2874
- // RELAY SUBSCRIPTION (Auto-decrypt and notify ContentManager via hook)
2938
+ // SIGNAL PROTOCOL RELAY SUBSCRIPTION (Auto-decrypt and notify ContentManager via hook)
2875
2939
  // ============================================================================
2876
- /**
2877
- * Start relay subscription for automatic message decryption
2878
- *
2879
- * When configured with both `relay` and `onMessageDecrypted` hook, DefaultSignalProtocolClient will:
2880
- * 1. Subscribe to incoming envelopes from the relay
2881
- * 2. Decrypt messages appropriately (pairwise vs group/sender key)
2882
- * 3. Call onMessageDecrypted hook with DecryptedEnvelope (for ContentManager storage)
2883
- * 4. Mark messages as delivered on the relay
2884
- *
2885
- * This enables ContentManager to store decrypted content in an encrypted SQLite
2886
- * database without any knowledge of cryptography.
2887
- *
2888
- * Callers can run this manually after registering hooks via registerHook().
2889
- * Called automatically by create() when relay + hook configured.
2890
- * A call while stop() runs is refused and logged; start again after stop()
2891
- * resolves.
2892
- *
2893
- * @see SignalProtocolClient.startRelaySubscription
2894
- */
2895
- startRelaySubscription() {
2896
- if (!this.relay) {
2940
+ /** @deprecated Use `startRelaySubscription`. SDK 15.0.0 removes this name. */
2941
+ startSignalProtocolRelaySubscription() {
2942
+ if (!this.signalProtocolRelay) {
2897
2943
  this.logger.warn('Cannot start relay subscription: relay not configured', {
2898
2944
  category: 'E2EE',
2899
2945
  });
@@ -2913,7 +2959,7 @@ export class DefaultSignalProtocolClient {
2913
2959
  return;
2914
2960
  }
2915
2961
  // Avoid duplicate subscriptions
2916
- if (this.relayUnsubscribe) {
2962
+ if (this.signalProtocolRelayUnsubscribe) {
2917
2963
  this.logger.debug('Relay subscription already active', {
2918
2964
  category: 'E2EE',
2919
2965
  });
@@ -2924,15 +2970,15 @@ export class DefaultSignalProtocolClient {
2924
2970
  data: { userId: this.userId, deviceId: this.deviceId },
2925
2971
  });
2926
2972
  this.startRetryRequests();
2927
- this.relayUnsubscribe = this.relay.subscribe(this.userId, this.deviceId, (envelope) => {
2928
- const handled = this.state.relayWork.run((work) => {
2929
- const ctx = this.relayWorkContext(work);
2930
- return RelaySubscriptionOps.handleRelayMessage({
2973
+ this.signalProtocolRelayUnsubscribe = this.signalProtocolRelay.subscribe(this.userId, this.deviceId, (envelope) => {
2974
+ const handled = this.state.signalRelayWork.run((work) => {
2975
+ const ctx = this.signalRelayWorkContext(work);
2976
+ return SignalProtocolRelaySubscriptionOps.handleSignalProtocolRelayMessage({
2931
2977
  ...ctx,
2932
2978
  cipher: this.cipher,
2933
2979
  receiveQueue: this.receiveQueue,
2934
2980
  stopSignal: work.stopSignal,
2935
- }, envelope, this.relaySubscriptionState, this.relaySubscriptionCallbacks(ctx, work.stopSignal), this.relaySubscriptionConfig);
2981
+ }, envelope, this.signalRelaySubscriptionState, this.signalRelaySubscriptionCallbacks(ctx, work.stopSignal), this.signalRelaySubscriptionConfig);
2936
2982
  });
2937
2983
  handled.catch((error) => {
2938
2984
  // The relay delivers an envelope that it did not acknowledge again.
@@ -2949,8 +2995,8 @@ export class DefaultSignalProtocolClient {
2949
2995
  return handled;
2950
2996
  }, {
2951
2997
  // Batching callbacks for notification coalescing
2952
- onBatchStart: () => this.contentAdapter.setRelayBatching(true),
2953
- onBatchEnd: () => this.contentAdapter.setRelayBatching(false),
2998
+ onBatchStart: () => this.setSignalProtocolRelayBatching(true),
2999
+ onBatchEnd: () => this.setSignalProtocolRelayBatching(false),
2954
3000
  });
2955
3001
  }
2956
3002
  /**
@@ -2991,48 +3037,78 @@ export class DefaultSignalProtocolClient {
2991
3037
  });
2992
3038
  void this.groupKeySync?.start();
2993
3039
  void this.resendJobs.start();
2994
- const relay = this.relay;
2995
- if (this.resendJobsOnConnect === undefined && relay) {
2996
- this.resendJobsOnConnect = relay.subscribeRelayConnectionState((connection) => {
3040
+ const signalProtocolRelay = this.signalProtocolRelay;
3041
+ if (this.resendJobsOnConnect === undefined && signalProtocolRelay) {
3042
+ this.resendJobsOnConnect = subscribeSignalProtocolRelayConnectionStateOf(signalProtocolRelay, (connection) => {
2997
3043
  if (connection.state === 'connected')
2998
3044
  void this.resendJobs.start();
2999
3045
  });
3000
3046
  }
3001
3047
  void this.sendIntents.start();
3002
- if (this.sendDriverOnConnect === undefined && relay && this.sendIntents.enabled) {
3003
- this.sendDriverOnConnect = relay.subscribeRelayConnectionState((connection) => {
3048
+ if (this.sendDriverOnConnect === undefined && signalProtocolRelay && this.sendIntents.enabled) {
3049
+ this.sendDriverOnConnect = subscribeSignalProtocolRelayConnectionStateOf(signalProtocolRelay, (connection) => {
3004
3050
  if (connection.state === 'connected')
3005
3051
  void this.sendIntents.start();
3006
3052
  });
3007
3053
  }
3008
3054
  }
3055
+ /** Tell the content adapter that a relay batch starts or ends. */
3056
+ setSignalProtocolRelayBatching(active) {
3057
+ readRenamedImplementation(this.contentAdapter, 'setSignalProtocolRelayBatching', 'setRelayBatching')?.(active);
3058
+ }
3009
3059
  /**
3010
- * Stop the relay subscription
3060
+ * Start relay subscription for automatic message decryption
3011
3061
  *
3012
- * Pauses message processing via the relay subscription without destroying
3013
- * DefaultSignalProtocolClient state. startRelaySubscription() restarts the subscription.
3062
+ * When configured with both `relay` and `onMessageDecrypted` hook, DefaultSignalProtocolClient will:
3063
+ * 1. Subscribe to incoming envelopes from the relay
3064
+ * 2. Decrypt messages appropriately (pairwise vs group/sender key)
3065
+ * 3. Call onMessageDecrypted hook with DecryptedEnvelope (for ContentManager storage)
3066
+ * 4. Mark messages as delivered on the relay
3014
3067
  *
3015
- * Use this when the app backgrounds to let the background task handle messages.
3016
- * Resume when the app foregrounds for real-time message delivery.
3068
+ * This enables ContentManager to store decrypted content in an encrypted SQLite
3069
+ * database without any knowledge of cryptography.
3017
3070
  *
3018
- * @see SignalProtocolClient.stopRelaySubscription
3071
+ * Callers can run this manually after registering hooks via registerHook().
3072
+ * Called automatically by create() when relay + hook configured.
3073
+ * A call while stop() runs is refused and logged; start again after stop()
3074
+ * resolves.
3075
+ *
3076
+ * @see SignalProtocolClient.startRelaySubscription
3019
3077
  */
3020
- stopRelaySubscription() {
3078
+ startRelaySubscription() {
3079
+ this.startSignalProtocolRelaySubscription();
3080
+ }
3081
+ /** @deprecated Use `stopRelaySubscription`. SDK 15.0.0 removes this name. */
3082
+ stopSignalProtocolRelaySubscription() {
3021
3083
  // Send the batched delivery receipts before unsubscribing. During the
3022
3084
  // hold, stop() sends the batches that wait at each of its flushes and
3023
3085
  // drops a batch made after its last flush.
3024
- if (!this.relaySubscriptionState.receiptAccumulator.held) {
3086
+ if (!this.signalRelaySubscriptionState.receiptAccumulator.held) {
3025
3087
  this.flushPendingDeliveryReceipts();
3026
3088
  }
3027
- if (this.relayUnsubscribe) {
3028
- this.relayUnsubscribe();
3029
- this.relayUnsubscribe = undefined;
3089
+ if (this.signalProtocolRelayUnsubscribe) {
3090
+ this.signalProtocolRelayUnsubscribe();
3091
+ this.signalProtocolRelayUnsubscribe = undefined;
3030
3092
  this.logger.debug('Relay subscription stopped', {
3031
3093
  category: 'E2EE',
3032
3094
  data: { userId: this.userId, deviceId: this.deviceId },
3033
3095
  });
3034
3096
  }
3035
3097
  }
3098
+ /**
3099
+ * Stop the relay subscription
3100
+ *
3101
+ * Pauses message processing via the relay subscription without destroying
3102
+ * DefaultSignalProtocolClient state. startRelaySubscription() restarts the subscription.
3103
+ *
3104
+ * Use this when the app backgrounds to let the background task handle messages.
3105
+ * Resume when the app foregrounds for real-time message delivery.
3106
+ *
3107
+ * @see SignalProtocolClient.stopRelaySubscription
3108
+ */
3109
+ stopRelaySubscription() {
3110
+ this.stopSignalProtocolRelaySubscription();
3111
+ }
3036
3112
  /**
3037
3113
  * Send delivery receipt to original sender (all devices)
3038
3114
  *
@@ -3184,7 +3260,7 @@ export class DefaultSignalProtocolClient {
3184
3260
  * wait for the send.
3185
3261
  */
3186
3262
  receiptContext() {
3187
- return { ...this.ctx, stopSignal: this.state.relayWork.stopSignal };
3263
+ return { ...this.ctx, stopSignal: this.state.signalRelayWork.stopSignal };
3188
3264
  }
3189
3265
  /**
3190
3266
  * Internal method to send receipt (delivery or read)
@@ -3293,27 +3369,27 @@ export class DefaultSignalProtocolClient {
3293
3369
  // timer, and stopRelaySubscription() does not send it. Step 5 sends the
3294
3370
  // batches that wait at the end of each wait, again while the deadline is
3295
3371
  // not past. A receipt batched after its last flush is dropped in step 6
3296
- const receiptDeadline = Date.now() + RelaySubscriptionOps.STOP_RECEIPT_FLUSH_MS;
3372
+ const receiptDeadline = Date.now() + SignalProtocolRelaySubscriptionOps.STOP_RECEIPT_FLUSH_MS;
3297
3373
  const receiptSends = [
3298
3374
  ...[...this.deliveryReceiptSends]
3299
3375
  .filter(([work]) => !work.stopSignal.aborted)
3300
3376
  .map(([, send]) => send),
3301
3377
  ...this.flushPendingDeliveryReceipts(),
3302
3378
  ];
3303
- const receiptAccumulator = this.relaySubscriptionState.receiptAccumulator;
3379
+ const receiptAccumulator = this.signalRelaySubscriptionState.receiptAccumulator;
3304
3380
  receiptAccumulator.held = true;
3305
3381
  try {
3306
3382
  // 2. Stop relay subscription. Clear it before the call, so a call that
3307
3383
  // the unsubscribe makes does not unsubscribe it again. If the call
3308
3384
  // throws, put it back, so the next stop() calls it again
3309
- const relayUnsubscribe = this.relayUnsubscribe;
3310
- this.relayUnsubscribe = undefined;
3311
- if (relayUnsubscribe) {
3385
+ const signalProtocolRelayUnsubscribe = this.signalProtocolRelayUnsubscribe;
3386
+ this.signalProtocolRelayUnsubscribe = undefined;
3387
+ if (signalProtocolRelayUnsubscribe) {
3312
3388
  try {
3313
- relayUnsubscribe();
3389
+ signalProtocolRelayUnsubscribe();
3314
3390
  }
3315
3391
  catch (error) {
3316
- this.relayUnsubscribe ??= relayUnsubscribe;
3392
+ this.signalProtocolRelayUnsubscribe ??= signalProtocolRelayUnsubscribe;
3317
3393
  throw error;
3318
3394
  }
3319
3395
  this.logger.debug('Relay subscription stopped', { category: 'E2EE' });
@@ -3327,7 +3403,7 @@ export class DefaultSignalProtocolClient {
3327
3403
  // start. A receipt send is not stopped here, because the relay has the
3328
3404
  // acknowledgment of its messages and does not deliver them again
3329
3405
  if (receiptSends.length > 0) {
3330
- this.state.relayWork.stopAllExcept(new Set(this.deliveryReceiptSends.keys()));
3406
+ this.state.signalRelayWork.stopAllExcept(new Set(this.deliveryReceiptSends.keys()));
3331
3407
  await this.waitForStopReceiptSends(receiptSends, receiptDeadline - Date.now());
3332
3408
  }
3333
3409
  // 4. Stop the relay work in progress and wait for its SDK work. Work
@@ -3336,7 +3412,7 @@ export class DefaultSignalProtocolClient {
3336
3412
  // receipt send that waits in an app hook after the deadline stops, and
3337
3413
  // that receipt is not sent. A receipt send that is still in its relay
3338
3414
  // call is waited for, and that receipt can still be sent
3339
- await this.state.relayWork.settle();
3415
+ await this.state.signalRelayWork.settle();
3340
3416
  // 5. A delivery can finish during steps 3, 4, and 5, and the relay does
3341
3417
  // not deliver it again. A delivery that waits for the Relay reply to its
3342
3418
  // acknowledgment gets no reply after the unsubscribe, so release it to
@@ -3344,14 +3420,14 @@ export class DefaultSignalProtocolClient {
3344
3420
  // wait for them until the same receipt deadline, and stop what is left
3345
3421
  // as step 4 does. Do this again while a batch waits and the deadline
3346
3422
  // is not past
3347
- const receiptJoin = this.relay === undefined ? undefined : relayReceiptJoinOf(this.relay);
3423
+ const receiptJoin = this.signalProtocolRelay === undefined ? undefined : signalRelayReceiptJoinOf(this.signalProtocolRelay);
3348
3424
  do {
3349
3425
  receiptJoin?.release();
3350
3426
  const lateReceiptSends = this.flushPendingDeliveryReceipts();
3351
3427
  if (lateReceiptSends.length === 0)
3352
3428
  break;
3353
3429
  await this.waitForStopReceiptSends(lateReceiptSends, receiptDeadline - Date.now());
3354
- await this.state.relayWork.settle();
3430
+ await this.state.signalRelayWork.settle();
3355
3431
  } while (Date.now() < receiptDeadline);
3356
3432
  // 6. Release a delivery that started to wait for its reply after the
3357
3433
  // last release, so that no reply timer batches its receipt after