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