@open-e2ee/signal-protocol-sdk 14.0.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 (406) hide show
  1. package/ADAPTERS.md +5 -5
  2. package/ARCHITECTURE.md +1 -1
  3. package/CHANGELOG.md +461 -0
  4. package/README.md +21 -15
  5. package/SECURITY.md +2 -2
  6. package/TROUBLESHOOTING.md +1 -1
  7. package/client/README.md +35 -22
  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 +18 -6
  53. package/dist/client/hosted-anonymous-delivery.d.ts.map +1 -1
  54. package/dist/client/hosted-anonymous-delivery.js +63 -20
  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 +16 -15
  89. package/dist/client/hosted-mailbox-subscription.d.ts.map +1 -1
  90. package/dist/client/hosted-mailbox-subscription.js +21 -25
  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 +82 -5
  120. package/dist/client/hosted-sandbox-identity.d.ts.map +1 -1
  121. package/dist/client/hosted-sandbox-identity.js +160 -50
  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 +53 -33
  128. package/dist/client/hosted-transport.d.ts.map +1 -1
  129. package/dist/client/hosted-transport.js +225 -138
  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 +144 -75
  136. package/dist/client/hosted.d.ts.map +1 -1
  137. package/dist/client/hosted.js +106 -61
  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 +8 -7
  183. package/dist/client/send-deadline.d.ts.map +1 -1
  184. package/dist/client/send-deadline.js +41 -23
  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/signal-relay-period-close.d.ts +35 -0
  203. package/dist/client/signal-relay-period-close.d.ts.map +1 -0
  204. package/dist/client/signal-relay-period-close.js +63 -0
  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 +7 -5
  321. package/dist/remote/signal-relay/request-admission.d.ts.map +1 -0
  322. package/dist/remote/{relay → signal-relay}/request-admission.js +7 -6
  323. package/dist/remote/signal-relay/request-admission.js.map +1 -0
  324. package/dist/remote/{relay → signal-relay}/types.d.ts +30 -12
  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 +8 -8
  349. package/docs/CLIENT_COMPOSITION.md +11 -7
  350. package/docs/DEVIATIONS.md +58 -8
  351. package/docs/ERROR_HANDLING.md +24 -24
  352. package/docs/GETTING_STARTED.md +25 -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 +22 -7
  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 +16 -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-protocol.d.ts.map +0 -1
  375. package/dist/client/relay-protocol.js.map +0 -1
  376. package/dist/client/relay-receipt-intake.d.ts.map +0 -1
  377. package/dist/client/relay-receipt-intake.js.map +0 -1
  378. package/dist/client/relay-receipt-join.d.ts.map +0 -1
  379. package/dist/client/relay-receipt-join.js.map +0 -1
  380. package/dist/client/relay-request-deadline.d.ts.map +0 -1
  381. package/dist/client/relay-request-deadline.js.map +0 -1
  382. package/dist/client/relay-sealed-route.d.ts.map +0 -1
  383. package/dist/client/relay-sealed-route.js.map +0 -1
  384. package/dist/client/relay-subscription.d.ts.map +0 -1
  385. package/dist/client/relay-subscription.js.map +0 -1
  386. package/dist/client/relay-work.d.ts.map +0 -1
  387. package/dist/client/relay-work.js.map +0 -1
  388. package/dist/hooks/use-relay-connection-state.d.ts +0 -32
  389. package/dist/hooks/use-relay-connection-state.d.ts.map +0 -1
  390. package/dist/hooks/use-relay-connection-state.js +0 -31
  391. package/dist/hooks/use-relay-connection-state.js.map +0 -1
  392. package/dist/hooks/use-relay-lifecycle.d.ts +0 -36
  393. package/dist/hooks/use-relay-lifecycle.d.ts.map +0 -1
  394. package/dist/hooks/use-relay-lifecycle.js +0 -35
  395. package/dist/hooks/use-relay-lifecycle.js.map +0 -1
  396. package/dist/remote/relay/connection-state.d.ts +0 -16
  397. package/dist/remote/relay/connection-state.d.ts.map +0 -1
  398. package/dist/remote/relay/connection-state.js.map +0 -1
  399. package/dist/remote/relay/device-set.d.ts.map +0 -1
  400. package/dist/remote/relay/device-set.js.map +0 -1
  401. package/dist/remote/relay/index.d.ts.map +0 -1
  402. package/dist/remote/relay/index.js.map +0 -1
  403. package/dist/remote/relay/request-admission.d.ts.map +0 -1
  404. package/dist/remote/relay/request-admission.js.map +0 -1
  405. package/dist/remote/relay/types.d.ts.map +0 -1
  406. package/dist/remote/relay/types.js.map +0 -1
@@ -1,6 +1,6 @@
1
1
  let retainCleanup;
2
2
  /** A strict-resume refusal. An unresolved cleanup remains owned by this error. */
3
- export class HostedRelayResumeError extends Error {
3
+ export class HostedSignalProtocolRelayResumeError extends Error {
4
4
  code;
5
5
  phase;
6
6
  #cleanup;
@@ -41,4 +41,7 @@ export class HostedRelayResumeError extends Error {
41
41
  export function retainHostedResumeCleanup(error, cleanup) {
42
42
  retainCleanup(error, cleanup);
43
43
  }
44
+ // Names before the Signal Protocol Relay rename. SDK 15.0.0 removes them.
45
+ /** @deprecated Use `HostedSignalProtocolRelayResumeError`. SDK 15.0.0 removes this name. */
46
+ export const HostedRelayResumeError = HostedSignalProtocolRelayResumeError;
44
47
  //# sourceMappingURL=hosted-resume-error.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"hosted-resume-error.js","sourceRoot":"","sources":["../../client/hosted-resume-error.ts"],"names":[],"mappings":"AAiBA,IAAI,aAGK,CAAC;AACV,kFAAkF;AAClF,MAAM,OAAO,sBAAuB,SAAQ,KAAK;IAOpC,IAAI;IACJ,KAAK;IAPhB,QAAQ,CAAuB;IAC/B,SAAS,CAAiB;IAC1B,MAAM,CAAC,gBAAgB,GAAG,CAAC,aAAa,GAAG,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;QAC5D,KAAK,CAAC,QAAQ,GAAG,OAAO,CAA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EAAE,EAAE;QAC5D,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC3B,CAAC,CAAC,CAAC;IACH,YACW,IAA8C,EAC9C,KAA2C,EACpD,OAAsB;QAEtB,KAAK,CAAC,kDAAkD,EAAE,OAAO,CAAC,CAAC;oBAJ1D,IAAI;qBACJ,KAAK;QAId,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;IACvC,CAAC;IACD,8EAA8E;IAC9E,IAAI,cAAc;QAChB,OAAO,IAAI,CAAC,QAAQ,KAAK,SAAS,CAAC;IACrC,CAAC;IACD,iFAAiF;IACjF,KAAK,CAAC,YAAY;QAChB,IAAI,IAAI,CAAC,SAAS;YAAE,OAAO,IAAI,CAAC,SAAS,CAAC;QAC1C,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC9B,IAAI,CAAC,OAAO;YAAE,OAAO;QACrB,IAAI,CAAC,SAAS,GAAG,CAAC,KAAK,IAAI,EAAE;YAC3B,MAAM,OAAO,EAAE,CAAC;YAChB,IAAI,CAAC,QAAQ,GAAG,SAAS,CAAC;QAC5B,CAAC,CAAC,EAAE,CAAC;QACL,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,SAAS,CAAC;QACvB,CAAC;gBAAS,CAAC;YACT,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC7B,CAAC;IACH,CAAC;CACF;AACD,8EAA8E;AAC9E,MAAM,UAAU,yBAAyB,CACvC,KAA2C,EAC3C,OAA4B;IAE5B,aAAa,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;AAChC,CAAC;AAED,0EAA0E;AAC1E,4FAA4F;AAC5F,MAAM,CAAC,MAAM,sBAAsB,GAAG,oCAAoC,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import { type DefaultSignalProtocolClient } from './client.js';
2
2
  import { type HostedSignalProtocolClientOptions } from './hosted.js';
3
- import { type HostedRelayResumeProgressCallback } from './hosted-resume-error.js';
3
+ import { type HostedSignalProtocolRelayResumeProgressCallback } from './hosted-resume-error.js';
4
4
  /** Existing hosted options without any registration/assertion authority. */
5
5
  export type HostedSignalProtocolResumeOptions = Omit<HostedSignalProtocolClientOptions, 'adapters' | 'hosted'> & {
6
6
  readonly adapters: Omit<HostedSignalProtocolClientOptions['adapters'], 'protocolManager'> & {
@@ -10,7 +10,7 @@ export type HostedSignalProtocolResumeOptions = Omit<HostedSignalProtocolClientO
10
10
  readonly getIdentityAssertion?: never;
11
11
  readonly assertionPurpose?: never;
12
12
  readonly assurance?: never;
13
- readonly onProgress?: HostedRelayResumeProgressCallback;
13
+ readonly onProgress?: HostedSignalProtocolRelayResumeProgressCallback;
14
14
  };
15
15
  };
16
16
  /**
@@ -18,7 +18,7 @@ export type HostedSignalProtocolResumeOptions = Omit<HostedSignalProtocolClientO
18
18
  * Renews the token and starts the ordinary client, including prekey maintenance and
19
19
  * automatic subscription. Never requests assertions or registers a replacement.
20
20
  * The caller owns the already-open store and must not use it concurrently.
21
- * On an unresolved stop, the thrown HostedRelayResumeError owns retryCleanup().
21
+ * On an unresolved stop, the thrown HostedSignalProtocolRelayResumeError owns retryCleanup().
22
22
  */
23
23
  export declare function resumeHostedSignalProtocolClient(options: HostedSignalProtocolResumeOptions): Promise<DefaultSignalProtocolClient>;
24
24
  //# sourceMappingURL=hosted-resume.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"hosted-resume.d.ts","sourceRoot":"","sources":["../../client/hosted-resume.ts"],"names":[],"mappings":"AAKA,OAAO,EAEL,KAAK,2BAA2B,EACjC,MAAM,UAAU,CAAC;AAElB,OAAO,EAGL,KAAK,iCAAiC,EACvC,MAAM,UAAU,CAAC;AAIlB,OAAO,EAIL,KAAK,iCAAiC,EACvC,MAAM,uBAAuB,CAAC;AAE/B,4EAA4E;AAC5E,MAAM,MAAM,iCAAiC,GAAG,IAAI,CAClD,iCAAiC,EACjC,UAAU,GAAG,QAAQ,CACtB,GAAG;IACF,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAC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AY,CACzE,GAAG;QACF,QAAQ,CAAC,oBAAoB,CAAC,EAAE,KAAK,CAAC;QACtC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,KAAK,CAAC;QAClC,QAAQ,CAAC,SAAS,CAAC,EAAE,KAAK,CAAC;QAC3B,QAAQ,CAAC,UAAU,CAAC,EAAE,+CAA+C,CAAC;KACvE,CAAC;CACH,CAAC;AAEF;;;;;;GAMG;AACH,wBAAsB,gCAAgC,CACpD,OAAO,EAAE,iCAAiC,GACzC,OAAO,CAAC,2BAA2B,CAAC,CAoGtC"}
@@ -2,17 +2,17 @@
2
2
  import { readRetainedIdentities, RetainedIdentityError, } from '../internal/manager/retained-identity.js';
3
3
  import { createClientWithRetainedIdentities, } from './client.js';
4
4
  import { ClientStartupCleanupError } from './startup-cleanup.js';
5
- import { createClientFromHostedResult, getExistingDeviceAuthentication, } from './hosted.js';
6
- import { resolveHostedRelayConnection } from './hosted-connection.js';
7
- import { resumeHostedRelayTransport } from './hosted-transport.js';
8
- import { assertHostedRelayProfileKeys } from './hosted-profile-keys.js';
9
- import { HostedRelayResumeError, retainHostedResumeCleanup, } from './hosted-resume-error.js';
5
+ import { createClientFromHostedResult, getExistingDeviceAuthentication, hostedSignalProtocolRelayUrl, } from './hosted.js';
6
+ import { resolveHostedSignalProtocolRelayConnection } from './hosted-connection.js';
7
+ import { resumeHostedSignalProtocolRelayTransport } from './hosted-transport.js';
8
+ import { assertHostedSignalProtocolRelayProfileKeys } from './hosted-profile-keys.js';
9
+ import { HostedSignalProtocolRelayResumeError, retainHostedResumeCleanup, } from './hosted-resume-error.js';
10
10
  /**
11
11
  * Require the existing permanent identities, device key and scoped hosted session.
12
12
  * Renews the token and starts the ordinary client, including prekey maintenance and
13
13
  * automatic subscription. Never requests assertions or registers a replacement.
14
14
  * The caller owns the already-open store and must not use it concurrently.
15
- * On an unresolved stop, the thrown HostedRelayResumeError owns retryCleanup().
15
+ * On an unresolved stop, the thrown HostedSignalProtocolRelayResumeError owns retryCleanup().
16
16
  */
17
17
  export async function resumeHostedSignalProtocolClient(options) {
18
18
  const { adapters, hosted, ...clientOptions } = options;
@@ -21,7 +21,7 @@ export async function resumeHostedSignalProtocolClient(options) {
21
21
  throw new TypeError('Strict hosted resume does not accept registration options or a custom protocol manager.');
22
22
  }
23
23
  if (hosted.profileKeys !== undefined)
24
- assertHostedRelayProfileKeys(hosted.profileKeys);
24
+ assertHostedSignalProtocolRelayProfileKeys(hosted.profileKeys);
25
25
  let phase = 'reading-local-state';
26
26
  let captured;
27
27
  const progress = (next) => {
@@ -32,9 +32,9 @@ export async function resumeHostedSignalProtocolClient(options) {
32
32
  progress('reading-local-state');
33
33
  // Hosted composition activates ACI. The manager checks all actual active types.
34
34
  const identities = await readRetainedIdentities(adapters.storage, ['aci']);
35
- const connection = await resolveHostedRelayConnection(hosted.relayUrl);
35
+ const connection = await resolveHostedSignalProtocolRelayConnection(hostedSignalProtocolRelayUrl(hosted, 'resumeHostedSignalProtocolClient'));
36
36
  const deviceAuthentication = await getExistingDeviceAuthentication(adapters.storage, connection.publishableKey, true);
37
- const resumed = await resumeHostedRelayTransport({
37
+ const resumed = await resumeHostedSignalProtocolRelayTransport({
38
38
  connection,
39
39
  deviceAuthentication,
40
40
  storage: adapters.storage,
@@ -42,7 +42,7 @@ export async function resumeHostedSignalProtocolClient(options) {
42
42
  onAuthenticating: () => progress('authenticating'),
43
43
  });
44
44
  if (!resumed)
45
- throw new HostedRelayResumeError('RETAINED_SESSION_UNAVAILABLE', 'reading-local-state');
45
+ throw new HostedSignalProtocolRelayResumeError('RETAINED_SESSION_UNAVAILABLE', 'reading-local-state');
46
46
  progress('initializing');
47
47
  const client = await createClientFromHostedResult(resumed, connection, adapters, clientOptions, hosted.sealedSenderAccessMode, resumed.remoteObjectStore, resumed.transport, hosted.profileKeys, async (userId, config) => {
48
48
  captured = await createClientWithRetainedIdentities(userId, config, identities);
@@ -64,7 +64,7 @@ export async function resumeHostedSignalProtocolClient(options) {
64
64
  }
65
65
  }
66
66
  if (failure instanceof ClientStartupCleanupError) {
67
- const error = new HostedRelayResumeError('RESUME_CLEANUP_UNRESOLVED', phase, { cause: failure.failure });
67
+ const error = new HostedSignalProtocolRelayResumeError('RESUME_CLEANUP_UNRESOLVED', phase, { cause: failure.failure });
68
68
  retainHostedResumeCleanup(error, failure.retryCleanup);
69
69
  throw error;
70
70
  }
@@ -74,7 +74,7 @@ export async function resumeHostedSignalProtocolClient(options) {
74
74
  : failure.reason === 'unreadable'
75
75
  ? 'RETAINED_STATE_UNREADABLE'
76
76
  : 'RETAINED_IDENTITY_UNAVAILABLE';
77
- throw new HostedRelayResumeError(code, phase, { cause: failure });
77
+ throw new HostedSignalProtocolRelayResumeError(code, phase, { cause: failure });
78
78
  }
79
79
  throw failure;
80
80
  }
@@ -1 +1 @@
1
- {"version":3,"file":"hosted-resume.js","sourceRoot":"","sources":["../../client/hosted-resume.ts"],"names":[],"mappings":"AAAA,sFAAsF;AACtF,OAAO,EACL,sBAAsB,EACtB,qBAAqB,GACtB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EACL,kCAAkC,GAEnC,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EACL,4BAA4B,EAC5B,+BAA+B,GAEhC,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,EACL,sBAAsB,EACtB,yBAAyB,GAG1B,MAAM,uBAAuB,CAAC;AAsB/B;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,gCAAgC,CACpD,OAA0C;IAE1C,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,aAAa,EAAE,GAAG,OAAO,CAAC;IACvD,IACE,QAAQ,CAAC,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AAC,CAAC,2BAA2B;oBAC7B,CAAC,CAAC,+BAA+B,CAAC;YACxC,MAAM,IAAI,oCAAoC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC;QAClF,CAAC;QACD,MAAM,OAAO,CAAC;IAChB,CAAC;AACH,CAAC"}
@@ -12,21 +12,98 @@ import type { GetIdentityAssertion } from './hosted.js';
12
12
  * Sandbox account. Another device of the account joins through device linking.
13
13
  *
14
14
  * The callback rejects a request for a production environment, for recovery,
15
- * for provider migration, or for recent or step-up assurance. Production needs
16
- * a `getIdentityAssertion` callback for its configured application-bound or
15
+ * for provider migration, or for recent or step-up assurance. This helper is
16
+ * the Sandbox-only guard, and it is not deprecated. For a Production project in
17
+ * device-owned mode, use {@link hostedSignalProtocolRelayDeviceOwnedIdentity}. For a
18
+ * Production project in application-bound mode, supply a `getIdentityAssertion`
19
+ * callback that returns an assertion from your backend.
20
+ *
21
+ * The key is stored under a metadata key prefix followed by the base64
22
+ * SHA-256 digest of the publishable key. The helper reads the prefix
23
+ * `'signalRelay.sandboxIdentity.v2:'` first and the prefix
24
+ * `'hostedRelay.sandboxIdentity.v1:'` second. This release stores a new key
25
+ * under `'hostedRelay.sandboxIdentity.v1:'`, the prefix that SDK 14.1.0 and
26
+ * earlier read and write. A later release stores a new key under
27
+ * `'signalRelay.sandboxIdentity.v2:'`. SDK 15 still reads the earlier prefix,
28
+ * so an existing Sandbox account keeps its key. Both helpers keep this
29
+ * persisted format. So for the same store and publishable key, both helpers
30
+ * sign with the same key.
31
+ *
32
+ * @example
33
+ * ```ts
34
+ * const storage = inMemoryStore();
35
+ * const client = await createHostedSignalProtocolClient({
36
+ * adapters: { storage },
37
+ * hosted: {
38
+ * signalProtocolRelayUrl: process.env.OPEN_E2EE_SIGNAL_RELAY_URL ?? process.env.OPEN_E2EE_RELAY_URL!,
39
+ * getIdentityAssertion: hostedSignalProtocolRelaySandboxIdentity(storage),
40
+ * },
41
+ * });
42
+ * ```
43
+ */
44
+ export declare function hostedSignalProtocolRelaySandboxIdentity(storage: SignalProtocolLocalStore): GetIdentityAssertion;
45
+ /**
46
+ * Creates the identity assertion callback for a device-owned account in a
47
+ * Sandbox environment, or in a Production environment that is configured in
17
48
  * device-owned identity mode.
18
49
  *
50
+ * The callback signs a short-lived device-owned assertion with an Ed25519 key
51
+ * that it keeps in `storage`. It creates the key on the first call and uses the
52
+ * same key after that, so the Relay returns the same account each time the
53
+ * device registers. The key is separate for each publishable key. Pass the
54
+ * same store as `adapters.storage`. The key never leaves the store. A device
55
+ * that loses the store loses the account, and its next registration creates a
56
+ * new account: the Relay refuses device-owned recovery. Another device of the
57
+ * account joins through device linking.
58
+ *
59
+ * The assertion is a compact JWS. Its protected header is
60
+ * `{ alg: 'EdDSA', typ: 'JWT', jwk: { kty: 'OKP', crv: 'Ed25519', x } }`,
61
+ * where `x` is the base64url public key. Its claims are:
62
+ *
63
+ * - `iss`: `'https://relay.open-e2ee.dev/device-owned'`.
64
+ * - `aud`: the publishable key of the request.
65
+ * - `sub`: the RFC 7638 SHA-256 thumbprint of the embedded JWK, base64url.
66
+ * - `iat` and `nbf`: the issue time in seconds. `exp`: `iat + 300`.
67
+ * - `jti`: a new UUID for each assertion.
68
+ * - `purpose`: `'register'`. `assurance`: `'normal'`.
69
+ * `token_use`: `'identity'`.
70
+ *
71
+ * The callback rejects a request for an environment other than Sandbox or
72
+ * Production, for recovery, for refresh or provider migration, or for recent or
73
+ * step-up assurance. It creates no key for a request that it rejects.
74
+ *
75
+ * The Production project must be configured in device-owned identity mode. A
76
+ * project in application-bound mode refuses this assertion with
77
+ * `ASSERTION_INVALID`. For that mode, supply a `getIdentityAssertion` callback
78
+ * that returns an assertion from your backend.
79
+ *
80
+ * The key is stored under a metadata key prefix followed by the base64
81
+ * SHA-256 digest of the publishable key. The helper reads the prefix
82
+ * `'signalRelay.sandboxIdentity.v2:'` first and the prefix
83
+ * `'hostedRelay.sandboxIdentity.v1:'` second. This release stores a new key
84
+ * under `'hostedRelay.sandboxIdentity.v1:'`, the prefix that SDK 14.1.0 and
85
+ * earlier read and write. A later release stores a new key under
86
+ * `'signalRelay.sandboxIdentity.v2:'`. SDK 15 still reads the earlier prefix,
87
+ * so an existing account keeps its key. Both helpers keep this persisted
88
+ * format. So for the same store and publishable key, this helper and
89
+ * {@link hostedSignalProtocolRelaySandboxIdentity} sign with the same key, and
90
+ * the Relay returns the same account.
91
+ *
19
92
  * @example
20
93
  * ```ts
21
94
  * const storage = inMemoryStore();
22
95
  * const client = await createHostedSignalProtocolClient({
23
96
  * adapters: { storage },
24
97
  * hosted: {
25
- * relayUrl: process.env.OPEN_E2EE_RELAY_URL!,
26
- * getIdentityAssertion: hostedRelaySandboxIdentity(storage),
98
+ * signalProtocolRelayUrl: process.env.OPEN_E2EE_SIGNAL_RELAY_URL ?? process.env.OPEN_E2EE_RELAY_URL!,
99
+ * getIdentityAssertion: hostedSignalProtocolRelayDeviceOwnedIdentity(storage),
27
100
  * },
28
101
  * });
29
102
  * ```
30
103
  */
31
- export declare function hostedRelaySandboxIdentity(storage: SignalProtocolLocalStore): GetIdentityAssertion;
104
+ export declare function hostedSignalProtocolRelayDeviceOwnedIdentity(storage: SignalProtocolLocalStore): GetIdentityAssertion;
105
+ /** @deprecated Use `hostedSignalProtocolRelayDeviceOwnedIdentity`. SDK 15.0.0 removes this name. */
106
+ export declare const hostedRelayDeviceOwnedIdentity: typeof hostedSignalProtocolRelayDeviceOwnedIdentity;
107
+ /** @deprecated Use `hostedSignalProtocolRelaySandboxIdentity`. SDK 15.0.0 removes this name. */
108
+ export declare const hostedRelaySandboxIdentity: typeof hostedSignalProtocolRelaySandboxIdentity;
32
109
  //# sourceMappingURL=hosted-sandbox-identity.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"hosted-sandbox-identity.d.ts","sourceRoot":"","sources":["../../client/hosted-sandbox-identity.ts"],"names":[],"mappings":"AA2BA,OAAO,KAAK,EAAU,wBAAwB,EAAE,MAAM,UAAU,CAAC;AACjE,OAAO,KAAK,EAAE,oBAAoB,EAA4B,MAAM,UAAU,CAAC;AAqH/E;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,wBAAwB,GAChC,oBAAoB,CA6BtB"}
1
+ {"version":3,"file":"hosted-sandbox-identity.d.ts","sourceRoot":"","sources":["../../client/hosted-sandbox-identity.ts"],"names":[],"mappings":"AA8BA,OAAO,KAAK,EAAU,wBAAwB,EAAE,MAAM,UAAU,CAAC;AACjE,OAAO,KAAK,EAAE,oBAAoB,EAA4B,MAAM,UAAU,CAAC;AAkM/E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,wBAAgB,wCAAwC,CACtD,OAAO,EAAE,wBAAwB,GAChC,oBAAoB,CAEtB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DG;AACH,wBAAgB,4CAA4C,CAC1D,OAAO,EAAE,wBAAwB,GAChC,oBAAoB,CAEtB;AAGD,oGAAoG;AACpG,eAAO,MAAM,8BAA8B,qDAA+C,CAAC;AAC3F,gGAAgG;AAChG,eAAO,MAAM,0BAA0B,iDAA2C,CAAC"}
@@ -1,20 +1,32 @@
1
1
  /**
2
- * Device-owned identity for a Sandbox environment of the Signal Protocol Relay.
2
+ * Device-owned identity for the Signal Protocol Relay.
3
3
  *
4
- * A Sandbox environment verifies a device-owned assertion: a JWT that the
5
- * device signs with its own Ed25519 key and that carries the public key in
6
- * its header. The Relay binds the account to the RFC 7638 thumbprint of that
7
- * key. So the key is the account identity in the environment, and this module
8
- * keeps it in the device-local store next to the protocol identity. A device
9
- * that loses its store loses the account. Another device of the account joins
10
- * through device linking, not with a copy of this key.
4
+ * A Sandbox environment, and a Production environment in device-owned mode,
5
+ * verify a device-owned assertion: a JWT that the device signs with its own
6
+ * Ed25519 key and that carries the public key in its header. The Relay binds
7
+ * the account to the RFC 7638 thumbprint of that key. So the key is the
8
+ * account identity in the environment, and this module keeps it in the
9
+ * device-local store next to the protocol identity. A device that loses its
10
+ * store loses the account. Another device of the account joins through device
11
+ * linking, not with a copy of this key.
11
12
  *
12
- * The helper signs only registration assertions for a Sandbox connection. A
13
- * production environment, recovery, and provider migration need an identity
14
- * provider that authenticates the user.
13
+ * The helpers sign only registration assertions. `hostedSignalProtocolRelaySandboxIdentity`
14
+ * serves only a Sandbox connection. `hostedSignalProtocolRelayDeviceOwnedIdentity` serves a
15
+ * Sandbox connection or a device-owned Production connection. An
16
+ * application-bound Production project needs an application callback. Recovery
17
+ * and provider migration need an identity provider that authenticates the user.
15
18
  */
16
19
  import { base64ToBytes, bytesToBase64, bytesToUrlSafeBase64, generateSigningKeyPair, generateUuidV4, sha256, sign, stringToBytes, verify, } from '../internal/crypto/index.js';
17
- const SANDBOX_IDENTITY_METADATA_PREFIX = 'hostedRelay.sandboxIdentity.v1:';
20
+ import { hostedStoreRecordKey, readHostedStoreRecord, writeHostedStoreRecord, } from './hosted-store-records.js';
21
+ /**
22
+ * The metadata key prefixes of the stored device-owned key. They are a
23
+ * persisted format that both helpers keep. A read that skipped the earlier
24
+ * prefix would orphan the existing keys, and so the existing accounts.
25
+ */
26
+ const SANDBOX_IDENTITY_METADATA_PREFIX = {
27
+ current: 'signalRelay.sandboxIdentity.v2:',
28
+ earlier: 'hostedRelay.sandboxIdentity.v1:',
29
+ };
18
30
  const DEVICE_OWNED_ISSUER = 'https://relay.open-e2ee.dev/device-owned';
19
31
  /** The Relay accepts a lifetime of up to 600 seconds. */
20
32
  const ASSERTION_LIFETIME_SECONDS = 300;
@@ -53,15 +65,15 @@ function decodeStoredKey(value) {
53
65
  };
54
66
  }
55
67
  async function metadataKey(publishableKey) {
56
- return `${SANDBOX_IDENTITY_METADATA_PREFIX}${bytesToBase64(await sha256(stringToBytes(publishableKey)))}`;
68
+ return hostedStoreRecordKey(SANDBOX_IDENTITY_METADATA_PREFIX, bytesToBase64(await sha256(stringToBytes(publishableKey))));
57
69
  }
58
70
  async function loadOrCreateKey(storage, publishableKey) {
59
71
  const key = await metadataKey(publishableKey);
60
- const stored = await storage.getMetadata(key);
72
+ const stored = await readHostedStoreRecord(storage, key);
61
73
  if (stored)
62
74
  return decodeStoredKey(stored);
63
75
  const created = await generateSigningKeyPair();
64
- await storage.setMetadata(key, JSON.stringify(created));
76
+ await writeHostedStoreRecord(storage, key, JSON.stringify(created));
65
77
  return created;
66
78
  }
67
79
  /**
@@ -84,51 +96,38 @@ function sandboxIdentityKey(storage, publishableKey) {
84
96
  pending.set(publishableKey, created);
85
97
  return created;
86
98
  }
87
- function assertSandboxRegistration(request) {
88
- if (request.environment !== 'sandbox') {
89
- throw new Error('Signal Protocol Relay sandbox identity works only with a Sandbox environment');
99
+ const SANDBOX_SCOPE = {
100
+ name: 'sandbox identity',
101
+ environments: ['sandbox'],
102
+ environmentsLabel: 'a Sandbox environment',
103
+ };
104
+ const DEVICE_OWNED_SCOPE = {
105
+ name: 'device-owned identity',
106
+ environments: ['sandbox', 'production'],
107
+ environmentsLabel: 'a Sandbox or Production environment',
108
+ };
109
+ /**
110
+ * Accepts only a normal-assurance registration request for an environment of
111
+ * the scope. The Relay refuses device-owned recovery and migration away from
112
+ * device-owned mode, so registration is the whole device-owned path.
113
+ */
114
+ function assertRegistration(request, scope) {
115
+ if (!scope.environments.includes(request.environment)) {
116
+ throw new Error(`Signal Protocol Relay ${scope.name} works only with ${scope.environmentsLabel}`);
90
117
  }
91
118
  if (request.purpose !== 'register' || request.migration !== undefined) {
92
- throw new Error('Signal Protocol Relay sandbox identity supports only device registration');
119
+ throw new Error(`Signal Protocol Relay ${scope.name} supports only device registration`);
93
120
  }
94
121
  if (request.assurance !== undefined && request.assurance !== 'normal') {
95
- throw new Error('Signal Protocol Relay sandbox identity cannot assert recent or step-up assurance');
122
+ throw new Error(`Signal Protocol Relay ${scope.name} cannot assert recent or step-up assurance`);
96
123
  }
97
124
  }
98
125
  function encodeSegment(value) {
99
126
  return bytesToUrlSafeBase64(stringToBytes(JSON.stringify(value)));
100
127
  }
101
- /**
102
- * Creates the identity assertion callback for a Sandbox environment of the
103
- * Signal Protocol Relay.
104
- *
105
- * The callback signs a short-lived device-owned assertion with an Ed25519 key
106
- * that it keeps in `storage`. It creates the key on the first call and uses the
107
- * same key after that, so the Relay returns the same account each time the
108
- * device registers. The key is separate for each publishable key. Pass the
109
- * same store as `adapters.storage`. A device that loses the store loses the
110
- * Sandbox account. Another device of the account joins through device linking.
111
- *
112
- * The callback rejects a request for a production environment, for recovery,
113
- * for provider migration, or for recent or step-up assurance. Production needs
114
- * a `getIdentityAssertion` callback for its configured application-bound or
115
- * device-owned identity mode.
116
- *
117
- * @example
118
- * ```ts
119
- * const storage = inMemoryStore();
120
- * const client = await createHostedSignalProtocolClient({
121
- * adapters: { storage },
122
- * hosted: {
123
- * relayUrl: process.env.OPEN_E2EE_RELAY_URL!,
124
- * getIdentityAssertion: hostedRelaySandboxIdentity(storage),
125
- * },
126
- * });
127
- * ```
128
- */
129
- export function hostedRelaySandboxIdentity(storage) {
128
+ function deviceOwnedIdentity(storage, scope) {
130
129
  return async (request) => {
131
- assertSandboxRegistration(request);
130
+ assertRegistration(request, scope);
132
131
  const key = await sandboxIdentityKey(storage, request.publishableKey);
133
132
  const x = bytesToUrlSafeBase64(base64ToBytes(key.publicKey));
134
133
  const jwk = { crv: 'Ed25519', kty: 'OKP', x };
@@ -154,4 +153,115 @@ export function hostedRelaySandboxIdentity(storage) {
154
153
  return `${signingInput}.${bytesToUrlSafeBase64(base64ToBytes(signature))}`;
155
154
  };
156
155
  }
156
+ /**
157
+ * Creates the identity assertion callback for a Sandbox environment of the
158
+ * Signal Protocol Relay.
159
+ *
160
+ * The callback signs a short-lived device-owned assertion with an Ed25519 key
161
+ * that it keeps in `storage`. It creates the key on the first call and uses the
162
+ * same key after that, so the Relay returns the same account each time the
163
+ * device registers. The key is separate for each publishable key. Pass the
164
+ * same store as `adapters.storage`. A device that loses the store loses the
165
+ * Sandbox account. Another device of the account joins through device linking.
166
+ *
167
+ * The callback rejects a request for a production environment, for recovery,
168
+ * for provider migration, or for recent or step-up assurance. This helper is
169
+ * the Sandbox-only guard, and it is not deprecated. For a Production project in
170
+ * device-owned mode, use {@link hostedSignalProtocolRelayDeviceOwnedIdentity}. For a
171
+ * Production project in application-bound mode, supply a `getIdentityAssertion`
172
+ * callback that returns an assertion from your backend.
173
+ *
174
+ * The key is stored under a metadata key prefix followed by the base64
175
+ * SHA-256 digest of the publishable key. The helper reads the prefix
176
+ * `'signalRelay.sandboxIdentity.v2:'` first and the prefix
177
+ * `'hostedRelay.sandboxIdentity.v1:'` second. This release stores a new key
178
+ * under `'hostedRelay.sandboxIdentity.v1:'`, the prefix that SDK 14.1.0 and
179
+ * earlier read and write. A later release stores a new key under
180
+ * `'signalRelay.sandboxIdentity.v2:'`. SDK 15 still reads the earlier prefix,
181
+ * so an existing Sandbox account keeps its key. Both helpers keep this
182
+ * persisted format. So for the same store and publishable key, both helpers
183
+ * sign with the same key.
184
+ *
185
+ * @example
186
+ * ```ts
187
+ * const storage = inMemoryStore();
188
+ * const client = await createHostedSignalProtocolClient({
189
+ * adapters: { storage },
190
+ * hosted: {
191
+ * signalProtocolRelayUrl: process.env.OPEN_E2EE_SIGNAL_RELAY_URL ?? process.env.OPEN_E2EE_RELAY_URL!,
192
+ * getIdentityAssertion: hostedSignalProtocolRelaySandboxIdentity(storage),
193
+ * },
194
+ * });
195
+ * ```
196
+ */
197
+ export function hostedSignalProtocolRelaySandboxIdentity(storage) {
198
+ return deviceOwnedIdentity(storage, SANDBOX_SCOPE);
199
+ }
200
+ /**
201
+ * Creates the identity assertion callback for a device-owned account in a
202
+ * Sandbox environment, or in a Production environment that is configured in
203
+ * device-owned identity mode.
204
+ *
205
+ * The callback signs a short-lived device-owned assertion with an Ed25519 key
206
+ * that it keeps in `storage`. It creates the key on the first call and uses the
207
+ * same key after that, so the Relay returns the same account each time the
208
+ * device registers. The key is separate for each publishable key. Pass the
209
+ * same store as `adapters.storage`. The key never leaves the store. A device
210
+ * that loses the store loses the account, and its next registration creates a
211
+ * new account: the Relay refuses device-owned recovery. Another device of the
212
+ * account joins through device linking.
213
+ *
214
+ * The assertion is a compact JWS. Its protected header is
215
+ * `{ alg: 'EdDSA', typ: 'JWT', jwk: { kty: 'OKP', crv: 'Ed25519', x } }`,
216
+ * where `x` is the base64url public key. Its claims are:
217
+ *
218
+ * - `iss`: `'https://relay.open-e2ee.dev/device-owned'`.
219
+ * - `aud`: the publishable key of the request.
220
+ * - `sub`: the RFC 7638 SHA-256 thumbprint of the embedded JWK, base64url.
221
+ * - `iat` and `nbf`: the issue time in seconds. `exp`: `iat + 300`.
222
+ * - `jti`: a new UUID for each assertion.
223
+ * - `purpose`: `'register'`. `assurance`: `'normal'`.
224
+ * `token_use`: `'identity'`.
225
+ *
226
+ * The callback rejects a request for an environment other than Sandbox or
227
+ * Production, for recovery, for refresh or provider migration, or for recent or
228
+ * step-up assurance. It creates no key for a request that it rejects.
229
+ *
230
+ * The Production project must be configured in device-owned identity mode. A
231
+ * project in application-bound mode refuses this assertion with
232
+ * `ASSERTION_INVALID`. For that mode, supply a `getIdentityAssertion` callback
233
+ * that returns an assertion from your backend.
234
+ *
235
+ * The key is stored under a metadata key prefix followed by the base64
236
+ * SHA-256 digest of the publishable key. The helper reads the prefix
237
+ * `'signalRelay.sandboxIdentity.v2:'` first and the prefix
238
+ * `'hostedRelay.sandboxIdentity.v1:'` second. This release stores a new key
239
+ * under `'hostedRelay.sandboxIdentity.v1:'`, the prefix that SDK 14.1.0 and
240
+ * earlier read and write. A later release stores a new key under
241
+ * `'signalRelay.sandboxIdentity.v2:'`. SDK 15 still reads the earlier prefix,
242
+ * so an existing account keeps its key. Both helpers keep this persisted
243
+ * format. So for the same store and publishable key, this helper and
244
+ * {@link hostedSignalProtocolRelaySandboxIdentity} sign with the same key, and
245
+ * the Relay returns the same account.
246
+ *
247
+ * @example
248
+ * ```ts
249
+ * const storage = inMemoryStore();
250
+ * const client = await createHostedSignalProtocolClient({
251
+ * adapters: { storage },
252
+ * hosted: {
253
+ * signalProtocolRelayUrl: process.env.OPEN_E2EE_SIGNAL_RELAY_URL ?? process.env.OPEN_E2EE_RELAY_URL!,
254
+ * getIdentityAssertion: hostedSignalProtocolRelayDeviceOwnedIdentity(storage),
255
+ * },
256
+ * });
257
+ * ```
258
+ */
259
+ export function hostedSignalProtocolRelayDeviceOwnedIdentity(storage) {
260
+ return deviceOwnedIdentity(storage, DEVICE_OWNED_SCOPE);
261
+ }
262
+ // Names before the Signal Protocol Relay rename. SDK 15.0.0 removes them.
263
+ /** @deprecated Use `hostedSignalProtocolRelayDeviceOwnedIdentity`. SDK 15.0.0 removes this name. */
264
+ export const hostedRelayDeviceOwnedIdentity = hostedSignalProtocolRelayDeviceOwnedIdentity;
265
+ /** @deprecated Use `hostedSignalProtocolRelaySandboxIdentity`. SDK 15.0.0 removes this name. */
266
+ export const hostedRelaySandboxIdentity = hostedSignalProtocolRelaySandboxIdentity;
157
267
  //# sourceMappingURL=hosted-sandbox-identity.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"hosted-sandbox-identity.js","sourceRoot":"","sources":["../../client/hosted-sandbox-identity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EACL,aAAa,EACb,aAAa,EACb,oBAAoB,EACpB,sBAAsB,EACtB,cAAc,EACd,MAAM,EACN,IAAI,EACJ,aAAa,EACb,MAAM,GACP,MAAM,oBAAoB,CAAC;AAK5B,MAAM,gCAAgC,GAAG,iCAAiC,CAAC;AAC3E,MAAM,mBAAmB,GAAG,0CAA0C,CAAC;AACvE,yDAAyD;AACzD,MAAM,0BAA0B,GAAG,GAAG,CAAC;AACvC,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAO7B,+DAA+D;AAC/D,MAAM,WAAW,GAAG,IAAI,OAAO,EAG5B,CAAC;AAEJ,SAAS,e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CG;AACH,MAAM,UAAU,wCAAwC,CACtD,OAAiC;IAEjC,OAAO,mBAAmB,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;AACrD,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DG;AACH,MAAM,UAAU,4CAA4C,CAC1D,OAAiC;IAEjC,OAAO,mBAAmB,CAAC,OAAO,EAAE,kBAAkB,CAAC,CAAC;AAC1D,CAAC;AAED,0EAA0E;AAC1E,oGAAoG;AACpG,MAAM,CAAC,MAAM,8BAA8B,GAAG,4CAA4C,CAAC;AAC3F,gGAAgG;AAChG,MAAM,CAAC,MAAM,0BAA0B,GAAG,wCAAwC,CAAC"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * The metadata keys of the hosted records in the application store.
3
+ *
4
+ * Each hosted record has two keys. The current key has the prefix
5
+ * `signalRelay.<record>.v2:`. The earlier key has the `.v1:` prefix that SDK
6
+ * 14.1.0 and earlier read and write. Each file that owns a record names its
7
+ * two prefixes. The suffix after the prefix is the same in the two keys.
8
+ *
9
+ * In this release a read takes the current key first and the earlier key
10
+ * second, and a write keeps the earlier key. So a store that SDK 14.1.0 wrote
11
+ * opens with its records, and a return to SDK 14.1.0 still finds every
12
+ * record. A later release writes the current key. A write also updates a
13
+ * current key that the store holds, so the current key, which a read prefers,
14
+ * never keeps a value that a later write replaced. SDK 15 still reads the
15
+ * earlier key.
16
+ */
17
+ import type { SignalProtocolLocalStore } from '../types/index.js';
18
+ /** The two metadata key prefixes of one hosted record. */
19
+ export interface HostedStoreRecordPrefix {
20
+ /** The `signalRelay.<record>.v2:` prefix. A read takes it first. */
21
+ readonly current: string;
22
+ /** The `.v1:` prefix that SDK 14.1.0 writes. A read takes it second. */
23
+ readonly earlier: string;
24
+ }
25
+ /** The two metadata keys of one hosted record. */
26
+ export type HostedStoreRecordKey = HostedStoreRecordPrefix;
27
+ type RecordReader = Pick<SignalProtocolLocalStore, 'getMetadata'>;
28
+ type RecordWriter = Pick<SignalProtocolLocalStore, 'getMetadata' | 'setMetadata'>;
29
+ type RecordRemover = Pick<SignalProtocolLocalStore, 'deleteMetadata'>;
30
+ /** The keys of the record that `suffix` names under `prefix`. */
31
+ export declare function hostedStoreRecordKey(prefix: HostedStoreRecordPrefix, suffix: string): HostedStoreRecordKey;
32
+ /**
33
+ * The stored value of a record, or `null` when neither key holds one. The
34
+ * current key wins when the store holds both keys.
35
+ */
36
+ export declare function readHostedStoreRecord(store: RecordReader, key: HostedStoreRecordKey): Promise<string | null>;
37
+ /**
38
+ * Stores a record under its earlier key. It first replaces a current key that
39
+ * the store holds, so that a failure between the two writes leaves the newer
40
+ * value under the key that a read prefers.
41
+ */
42
+ export declare function writeHostedStoreRecord(store: RecordWriter, key: HostedStoreRecordKey, value: string): Promise<void>;
43
+ /** Deletes both keys of a record, so a read finds no earlier value. */
44
+ export declare function deleteHostedStoreRecord(store: RecordRemover, key: HostedStoreRecordKey): Promise<void>;
45
+ export {};
46
+ //# sourceMappingURL=hosted-store-records.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hosted-store-records.d.ts","sourceRoot":"","sources":["../../client/hosted-store-records.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;AAEzD,0DAA0D;AAC1D,MAAM,WAAW,uBAAuB;IACtC,oEAAoE;IACpE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,wEAAwE;IACxE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED,kDAAkD;AAClD,MAAM,MAAM,oBAAoB,GAAG,uBAAuB,CAAC;AAE3D,KAAK,YAAY,GAAG,IAAI,CAAC,wBAAwB,EAAE,aAAa,CAAC,CAAC;AAClE,KAAK,YAAY,GAAG,IAAI,CAAC,wBAAwB,EAAE,aAAa,GAAG,aAAa,CAAC,CAAC;AAClF,KAAK,aAAa,GAAG,IAAI,CAAC,wBAAwB,EAAE,gBAAgB,CAAC,CAAC;AAEtE,iEAAiE;AACjE,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,uBAAuB,EAC/B,MAAM,EAAE,MAAM,GACb,oBAAoB,CAKtB;AAED;;;GAGG;AACH,wBAAsB,qBAAqB,CACzC,KAAK,EAAE,YAAY,EACnB,GAAG,EAAE,oBAAoB,GACxB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAGxB;AAED;;;;GAIG;AACH,wBAAsB,sBAAsB,CAC1C,KAAK,EAAE,YAAY,EACnB,GAAG,EAAE,oBAAoB,EACzB,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,IAAI,CAAC,CAKf;AAED,uEAAuE;AACvE,wBAAsB,uBAAuB,CAC3C,KAAK,EAAE,aAAa,EACpB,GAAG,EAAE,oBAAoB,GACxB,OAAO,CAAC,IAAI,CAAC,CAGf"}
@@ -0,0 +1,32 @@
1
+ /** The keys of the record that `suffix` names under `prefix`. */
2
+ export function hostedStoreRecordKey(prefix, suffix) {
3
+ return {
4
+ current: `${prefix.current}${suffix}`,
5
+ earlier: `${prefix.earlier}${suffix}`,
6
+ };
7
+ }
8
+ /**
9
+ * The stored value of a record, or `null` when neither key holds one. The
10
+ * current key wins when the store holds both keys.
11
+ */
12
+ export async function readHostedStoreRecord(store, key) {
13
+ const current = await store.getMetadata(key.current);
14
+ return current !== null ? current : store.getMetadata(key.earlier);
15
+ }
16
+ /**
17
+ * Stores a record under its earlier key. It first replaces a current key that
18
+ * the store holds, so that a failure between the two writes leaves the newer
19
+ * value under the key that a read prefers.
20
+ */
21
+ export async function writeHostedStoreRecord(store, key, value) {
22
+ if ((await store.getMetadata(key.current)) !== null) {
23
+ await store.setMetadata(key.current, value);
24
+ }
25
+ await store.setMetadata(key.earlier, value);
26
+ }
27
+ /** Deletes both keys of a record, so a read finds no earlier value. */
28
+ export async function deleteHostedStoreRecord(store, key) {
29
+ await store.deleteMetadata(key.current);
30
+ await store.deleteMetadata(key.earlier);
31
+ }
32
+ //# sourceMappingURL=hosted-store-records.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hosted-store-records.js","sourceRoot":"","sources":["../../client/hosted-store-records.ts"],"names":[],"mappings":"AAiCA,iEAAiE;AACjE,MAAM,UAAU,oBAAoB,CAClC,MAA+B,EAC/B,MAAc;IAEd,OAAO;QACL,OAAO,EAAE,GAAG,MAAM,CAAC,OAAO,GAAG,MAAM,EAAE;QACrC,OAAO,EAAE,GAAG,MAAM,CAAC,OAAO,GAAG,MAAM,EAAE;KACtC,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,KAAmB,EACnB,GAAyB;IAEzB,MAAM,OAAO,GAAG,MAAM,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACrD,OAAO,OAAO,KAAK,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;AACrE,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,KAAmB,EACnB,GAAyB,EACzB,KAAa;IAEb,IAAI,CAAC,MAAM,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;QACpD,MAAM,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IAC9C,CAAC;IACD,MAAM,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;AAC9C,CAAC;AAED,uEAAuE;AACvE,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAC3C,KAAoB,EACpB,GAAyB;IAEzB,MAAM,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACxC,MAAM,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;AAC1C,CAAC"}