@open-e2ee/signal-protocol-sdk 7.1.0 → 8.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (698) hide show
  1. package/ADAPTERS.md +55 -6
  2. package/ARCHITECTURE.md +1 -0
  3. package/CHANGELOG.md +565 -0
  4. package/README.md +19 -5
  5. package/SECURITY.md +2 -2
  6. package/THIRD_PARTY_NOTICES.md +429 -0
  7. package/TROUBLESHOOTING.md +10 -0
  8. package/client/README.md +1 -2
  9. package/device/README.md +50 -19
  10. package/dist/client/client.d.ts +31 -5
  11. package/dist/client/client.d.ts.map +1 -1
  12. package/dist/client/client.js +149 -90
  13. package/dist/client/client.js.map +1 -1
  14. package/dist/client/event-hooks.d.ts.map +1 -1
  15. package/dist/client/event-hooks.js +2 -0
  16. package/dist/client/event-hooks.js.map +1 -1
  17. package/dist/client/files.d.ts.map +1 -1
  18. package/dist/client/files.js +19 -2
  19. package/dist/client/files.js.map +1 -1
  20. package/dist/client/headless.d.ts +1 -1
  21. package/dist/client/headless.js +1 -1
  22. package/dist/client/hosted-anonymous-delivery.d.ts.map +1 -1
  23. package/dist/client/hosted-anonymous-delivery.js +2 -1
  24. package/dist/client/hosted-anonymous-delivery.js.map +1 -1
  25. package/dist/client/hosted-connection.d.ts +1 -1
  26. package/dist/client/hosted-connection.d.ts.map +1 -1
  27. package/dist/client/hosted-connection.js +8 -12
  28. package/dist/client/hosted-connection.js.map +1 -1
  29. package/dist/client/hosted-group-authority.d.ts.map +1 -1
  30. package/dist/client/hosted-group-authority.js +2 -1
  31. package/dist/client/hosted-group-authority.js.map +1 -1
  32. package/dist/client/hosted-groups.d.ts.map +1 -1
  33. package/dist/client/hosted-groups.js +2 -1
  34. package/dist/client/hosted-groups.js.map +1 -1
  35. package/dist/client/hosted-push.d.ts.map +1 -1
  36. package/dist/client/hosted-push.js +2 -1
  37. package/dist/client/hosted-push.js.map +1 -1
  38. package/dist/client/hosted-transport.d.ts.map +1 -1
  39. package/dist/client/hosted-transport.js +10 -11
  40. package/dist/client/hosted-transport.js.map +1 -1
  41. package/dist/client/hosted-trust.d.ts +11 -11
  42. package/dist/client/hosted-trust.d.ts.map +1 -1
  43. package/dist/client/hosted-trust.js +12 -12
  44. package/dist/client/hosted-trust.js.map +1 -1
  45. package/dist/client/messages.d.ts.map +1 -1
  46. package/dist/client/messages.js +6 -1
  47. package/dist/client/messages.js.map +1 -1
  48. package/dist/client/multi-device.d.ts.map +1 -1
  49. package/dist/client/multi-device.js +2 -1
  50. package/dist/client/multi-device.js.map +1 -1
  51. package/dist/client/relay-lifecycle.d.ts +6 -2
  52. package/dist/client/relay-lifecycle.d.ts.map +1 -1
  53. package/dist/client/relay-lifecycle.js.map +1 -1
  54. package/dist/client/relay-work.d.ts +30 -0
  55. package/dist/client/relay-work.d.ts.map +1 -0
  56. package/dist/client/relay-work.js +189 -0
  57. package/dist/client/relay-work.js.map +1 -0
  58. package/dist/client/retry.d.ts.map +1 -1
  59. package/dist/client/retry.js +2 -0
  60. package/dist/client/retry.js.map +1 -1
  61. package/dist/client/sessions.d.ts.map +1 -1
  62. package/dist/client/sessions.js +3 -0
  63. package/dist/client/sessions.js.map +1 -1
  64. package/dist/client/signal-service-cipher.d.ts +39 -16
  65. package/dist/client/signal-service-cipher.d.ts.map +1 -1
  66. package/dist/client/signal-service-cipher.js +100 -60
  67. package/dist/client/signal-service-cipher.js.map +1 -1
  68. package/dist/client/state.d.ts +8 -0
  69. package/dist/client/state.d.ts.map +1 -1
  70. package/dist/client/state.js +11 -0
  71. package/dist/client/state.js.map +1 -1
  72. package/dist/client/types.d.ts +5 -1
  73. package/dist/client/types.d.ts.map +1 -1
  74. package/dist/client/types.js.map +1 -1
  75. package/dist/device/connection.d.ts +1 -1
  76. package/dist/device/connection.d.ts.map +1 -1
  77. package/dist/device/connection.js +4 -11
  78. package/dist/device/connection.js.map +1 -1
  79. package/dist/device/device-id.d.ts +10 -4
  80. package/dist/device/device-id.d.ts.map +1 -1
  81. package/dist/device/device-id.js +15 -9
  82. package/dist/device/device-id.js.map +1 -1
  83. package/dist/device/device-name-crypto.d.ts.map +1 -1
  84. package/dist/device/device-name-crypto.js +2 -2
  85. package/dist/device/device-name-crypto.js.map +1 -1
  86. package/dist/device/expo/index.d.ts +25 -8
  87. package/dist/device/expo/index.d.ts.map +1 -1
  88. package/dist/device/expo/index.js +58 -8
  89. package/dist/device/expo/index.js.map +1 -1
  90. package/dist/device/index.d.ts +2 -2
  91. package/dist/device/index.d.ts.map +1 -1
  92. package/dist/device/index.js +3 -2
  93. package/dist/device/index.js.map +1 -1
  94. package/dist/device/lifecycle/index.d.ts +4 -2
  95. package/dist/device/lifecycle/index.d.ts.map +1 -1
  96. package/dist/device/lifecycle/index.js.map +1 -1
  97. package/dist/device/lifecycle/manager.d.ts +12 -14
  98. package/dist/device/lifecycle/manager.d.ts.map +1 -1
  99. package/dist/device/lifecycle/manager.js +52 -97
  100. package/dist/device/lifecycle/manager.js.map +1 -1
  101. package/dist/device/lifecycle/types.d.ts +26 -16
  102. package/dist/device/lifecycle/types.d.ts.map +1 -1
  103. package/dist/device/lifecycle/utils.d.ts +8 -4
  104. package/dist/device/lifecycle/utils.d.ts.map +1 -1
  105. package/dist/device/lifecycle/utils.js +12 -16
  106. package/dist/device/lifecycle/utils.js.map +1 -1
  107. package/dist/device/provisioning.d.ts.map +1 -1
  108. package/dist/device/provisioning.js +6 -8
  109. package/dist/device/provisioning.js.map +1 -1
  110. package/dist/device/react-native/index.d.ts +40 -0
  111. package/dist/device/react-native/index.d.ts.map +1 -0
  112. package/dist/device/react-native/index.js +74 -0
  113. package/dist/device/react-native/index.js.map +1 -0
  114. package/dist/device/transfer.d.ts +15 -7
  115. package/dist/device/transfer.d.ts.map +1 -1
  116. package/dist/device/transfer.js +30 -22
  117. package/dist/device/transfer.js.map +1 -1
  118. package/dist/device/types.d.ts +15 -7
  119. package/dist/device/types.d.ts.map +1 -1
  120. package/dist/device/types.js.map +1 -1
  121. package/dist/device/vault-text.d.ts +13 -0
  122. package/dist/device/vault-text.d.ts.map +1 -0
  123. package/dist/device/vault-text.js +17 -0
  124. package/dist/device/vault-text.js.map +1 -0
  125. package/dist/hooks/use-key-rotation.d.ts.map +1 -1
  126. package/dist/hooks/use-key-rotation.js +2 -1
  127. package/dist/hooks/use-key-rotation.js.map +1 -1
  128. package/dist/index.d.ts +9 -5
  129. package/dist/index.d.ts.map +1 -1
  130. package/dist/index.js +9 -5
  131. package/dist/index.js.map +1 -1
  132. package/dist/internal/crypto/index.d.ts +3 -3
  133. package/dist/internal/crypto/index.d.ts.map +1 -1
  134. package/dist/internal/crypto/index.js +3 -3
  135. package/dist/internal/crypto/index.js.map +1 -1
  136. package/dist/internal/crypto/random-host.d.ts +1 -1
  137. package/dist/internal/crypto/random-host.d.ts.map +1 -1
  138. package/dist/internal/crypto/random-host.js +3 -2
  139. package/dist/internal/crypto/random-host.js.map +1 -1
  140. package/dist/internal/crypto/random-host.native.d.ts +6 -1
  141. package/dist/internal/crypto/random-host.native.d.ts.map +1 -1
  142. package/dist/internal/crypto/random-host.native.js +14 -10
  143. package/dist/internal/crypto/random-host.native.js.map +1 -1
  144. package/dist/internal/crypto/random-host.node.d.ts +1 -1
  145. package/dist/internal/crypto/random-host.node.d.ts.map +1 -1
  146. package/dist/internal/crypto/random-host.node.js +1 -1
  147. package/dist/internal/crypto/random-host.node.js.map +1 -1
  148. package/dist/internal/crypto/random.d.ts +12 -3
  149. package/dist/internal/crypto/random.d.ts.map +1 -1
  150. package/dist/internal/crypto/random.js +14 -3
  151. package/dist/internal/crypto/random.js.map +1 -1
  152. package/dist/internal/crypto/utils.d.ts.map +1 -1
  153. package/dist/internal/crypto/utils.js +10 -6
  154. package/dist/internal/crypto/utils.js.map +1 -1
  155. package/dist/internal/encoding/proto/primitives.d.ts +2 -0
  156. package/dist/internal/encoding/proto/primitives.d.ts.map +1 -1
  157. package/dist/internal/encoding/proto/primitives.js +2 -1
  158. package/dist/internal/encoding/proto/primitives.js.map +1 -1
  159. package/dist/internal/encoding/proto/signal-message.d.ts +1 -0
  160. package/dist/internal/encoding/proto/signal-message.d.ts.map +1 -1
  161. package/dist/internal/encoding/proto/signal-message.js +2 -1
  162. package/dist/internal/encoding/proto/signal-message.js.map +1 -1
  163. package/dist/internal/groups/authority-certificate.d.ts.map +1 -1
  164. package/dist/internal/groups/authority-certificate.js +2 -1
  165. package/dist/internal/groups/authority-certificate.js.map +1 -1
  166. package/dist/internal/groups/encrypted-state.d.ts.map +1 -1
  167. package/dist/internal/groups/encrypted-state.js +9 -7
  168. package/dist/internal/groups/encrypted-state.js.map +1 -1
  169. package/dist/internal/groups/invite-link.d.ts.map +1 -1
  170. package/dist/internal/groups/invite-link.js +2 -1
  171. package/dist/internal/groups/invite-link.js.map +1 -1
  172. package/dist/internal/groups/manager.d.ts.map +1 -1
  173. package/dist/internal/groups/manager.js +5 -5
  174. package/dist/internal/groups/manager.js.map +1 -1
  175. package/dist/internal/groups/sdk-store.d.ts.map +1 -1
  176. package/dist/internal/groups/sdk-store.js +4 -3
  177. package/dist/internal/groups/sdk-store.js.map +1 -1
  178. package/dist/internal/groups/server-engine.d.ts +6 -1
  179. package/dist/internal/groups/server-engine.d.ts.map +1 -1
  180. package/dist/internal/groups/server-engine.js +11 -15
  181. package/dist/internal/groups/server-engine.js.map +1 -1
  182. package/dist/internal/groups/wire.d.ts.map +1 -1
  183. package/dist/internal/groups/wire.js +2 -1
  184. package/dist/internal/groups/wire.js.map +1 -1
  185. package/dist/internal/platform/blob.d.ts +10 -0
  186. package/dist/internal/platform/blob.d.ts.map +1 -0
  187. package/dist/internal/platform/blob.js +30 -0
  188. package/dist/internal/platform/blob.js.map +1 -0
  189. package/dist/internal/platform/env.d.ts +13 -0
  190. package/dist/internal/platform/env.d.ts.map +1 -0
  191. package/dist/internal/platform/env.js +17 -0
  192. package/dist/internal/platform/env.js.map +1 -0
  193. package/dist/internal/platform/index.d.ts +5 -0
  194. package/dist/internal/platform/index.d.ts.map +1 -0
  195. package/dist/internal/platform/index.js +5 -0
  196. package/dist/internal/platform/index.js.map +1 -0
  197. package/dist/internal/platform/url.d.ts +72 -0
  198. package/dist/internal/platform/url.d.ts.map +1 -0
  199. package/dist/internal/platform/url.js +275 -0
  200. package/dist/internal/platform/url.js.map +1 -0
  201. package/dist/internal/platform/utf8.d.ts +28 -0
  202. package/dist/internal/platform/utf8.d.ts.map +1 -0
  203. package/dist/internal/platform/utf8.js +167 -0
  204. package/dist/internal/platform/utf8.js.map +1 -0
  205. package/dist/internal/protocol/sealed-sender/delivery-token.d.ts +1 -1
  206. package/dist/internal/protocol/sealed-sender/delivery-token.d.ts.map +1 -1
  207. package/dist/internal/protocol/sealed-sender/delivery-token.js +5 -10
  208. package/dist/internal/protocol/sealed-sender/delivery-token.js.map +1 -1
  209. package/dist/internal/protocol/sealed-sender/proto/index.d.ts.map +1 -1
  210. package/dist/internal/protocol/sealed-sender/proto/index.js +2 -4
  211. package/dist/internal/protocol/sealed-sender/proto/index.js.map +1 -1
  212. package/dist/internal/protocol/sender-keys/manager.d.ts.map +1 -1
  213. package/dist/internal/protocol/sender-keys/manager.js +4 -3
  214. package/dist/internal/protocol/sender-keys/manager.js.map +1 -1
  215. package/dist/internal/protocol/spqr/ml-kem-braid/noble-pq/index.d.ts +4 -4
  216. package/dist/internal/protocol/spqr/ml-kem-braid/noble-pq/index.d.ts.map +1 -1
  217. package/dist/internal/protocol/spqr/ml-kem-braid/noble-pq/index.js +8 -10
  218. package/dist/internal/protocol/spqr/ml-kem-braid/noble-pq/index.js.map +1 -1
  219. package/dist/internal/protocol/username/hash.d.ts.map +1 -1
  220. package/dist/internal/protocol/username/hash.js +18 -3
  221. package/dist/internal/protocol/username/hash.js.map +1 -1
  222. package/dist/internal/protocol/username/link.d.ts.map +1 -1
  223. package/dist/internal/protocol/username/link.js +2 -1
  224. package/dist/internal/protocol/username/link.js.map +1 -1
  225. package/dist/internal/protocol/username/proof.d.ts.map +1 -1
  226. package/dist/internal/protocol/username/proof.js +2 -1
  227. package/dist/internal/protocol/username/proof.js.map +1 -1
  228. package/dist/internal/sesame/device-registry.d.ts +22 -6
  229. package/dist/internal/sesame/device-registry.d.ts.map +1 -1
  230. package/dist/internal/sesame/device-registry.js +18 -12
  231. package/dist/internal/sesame/device-registry.js.map +1 -1
  232. package/dist/internal/sesame/index.d.ts +1 -1
  233. package/dist/internal/sesame/index.d.ts.map +1 -1
  234. package/dist/internal/sesame/manager.d.ts.map +1 -1
  235. package/dist/internal/sesame/manager.js +3 -2
  236. package/dist/internal/sesame/manager.js.map +1 -1
  237. package/dist/internal/session/index.d.ts +1 -2
  238. package/dist/internal/session/index.d.ts.map +1 -1
  239. package/dist/internal/session/index.js +1 -1
  240. package/dist/internal/session/index.js.map +1 -1
  241. package/dist/internal/session/validation.d.ts +0 -80
  242. package/dist/internal/session/validation.d.ts.map +1 -1
  243. package/dist/internal/session/validation.js +0 -134
  244. package/dist/internal/session/validation.js.map +1 -1
  245. package/dist/local/store/device-record.d.ts +18 -0
  246. package/dist/local/store/device-record.d.ts.map +1 -0
  247. package/dist/local/store/device-record.js +34 -0
  248. package/dist/local/store/device-record.js.map +1 -0
  249. package/dist/local/store/expo/adapter.d.ts +59 -238
  250. package/dist/local/store/expo/adapter.d.ts.map +1 -1
  251. package/dist/local/store/expo/adapter.js +83 -640
  252. package/dist/local/store/expo/adapter.js.map +1 -1
  253. package/dist/local/store/expo/driver.d.ts +16 -0
  254. package/dist/local/store/expo/driver.d.ts.map +1 -0
  255. package/dist/local/store/expo/driver.js +141 -0
  256. package/dist/local/store/expo/driver.js.map +1 -0
  257. package/dist/local/store/expo/index.d.ts +3 -12
  258. package/dist/local/store/expo/index.d.ts.map +1 -1
  259. package/dist/local/store/expo/index.js +1 -8
  260. package/dist/local/store/expo/index.js.map +1 -1
  261. package/dist/local/store/expo/maintenance.d.ts +3 -2
  262. package/dist/local/store/expo/maintenance.d.ts.map +1 -1
  263. package/dist/local/store/expo/maintenance.js +5 -34
  264. package/dist/local/store/expo/maintenance.js.map +1 -1
  265. package/dist/local/store/index.d.ts +10 -5
  266. package/dist/local/store/index.d.ts.map +1 -1
  267. package/dist/local/store/index.js +10 -5
  268. package/dist/local/store/index.js.map +1 -1
  269. package/dist/local/store/key-value/adapter.d.ts +326 -0
  270. package/dist/local/store/key-value/adapter.d.ts.map +1 -0
  271. package/dist/local/store/key-value/adapter.js +1472 -0
  272. package/dist/local/store/key-value/adapter.js.map +1 -0
  273. package/dist/local/store/{react-native → key-value}/backend-conformance.d.ts +7 -8
  274. package/dist/local/store/key-value/backend-conformance.d.ts.map +1 -0
  275. package/dist/local/store/{react-native → key-value}/backend-conformance.js +4 -5
  276. package/dist/local/store/key-value/backend-conformance.js.map +1 -0
  277. package/dist/local/store/key-value/batch.d.ts +41 -0
  278. package/dist/local/store/key-value/batch.d.ts.map +1 -0
  279. package/dist/local/store/key-value/batch.js +77 -0
  280. package/dist/local/store/key-value/batch.js.map +1 -0
  281. package/dist/local/store/key-value/device-record.d.ts +23 -0
  282. package/dist/local/store/key-value/device-record.d.ts.map +1 -0
  283. package/dist/local/store/key-value/device-record.js +33 -0
  284. package/dist/local/store/key-value/device-record.js.map +1 -0
  285. package/dist/local/store/key-value/index.d.ts +24 -0
  286. package/dist/local/store/key-value/index.d.ts.map +1 -0
  287. package/dist/local/store/key-value/index.js +8 -0
  288. package/dist/local/store/key-value/index.js.map +1 -0
  289. package/dist/local/store/key-value/realm/index.d.ts +83 -0
  290. package/dist/local/store/key-value/realm/index.d.ts.map +1 -0
  291. package/dist/local/store/key-value/realm/index.js +102 -0
  292. package/dist/local/store/key-value/realm/index.js.map +1 -0
  293. package/dist/local/store/{react-native → key-value}/storage.d.ts +6 -6
  294. package/dist/local/store/key-value/storage.d.ts.map +1 -0
  295. package/dist/local/store/key-value/storage.js.map +1 -0
  296. package/dist/local/store/key-value/transactional-backend.d.ts +50 -0
  297. package/dist/local/store/key-value/transactional-backend.d.ts.map +1 -0
  298. package/dist/local/store/key-value/transactional-backend.js +90 -0
  299. package/dist/local/store/key-value/transactional-backend.js.map +1 -0
  300. package/dist/local/store/key-value/value-key.d.ts +34 -0
  301. package/dist/local/store/key-value/value-key.d.ts.map +1 -0
  302. package/dist/local/store/key-value/value-key.js +83 -0
  303. package/dist/local/store/key-value/value-key.js.map +1 -0
  304. package/dist/local/store/memory/adapter.d.ts +8 -0
  305. package/dist/local/store/memory/adapter.d.ts.map +1 -1
  306. package/dist/local/store/memory/adapter.js +60 -75
  307. package/dist/local/store/memory/adapter.js.map +1 -1
  308. package/dist/local/store/node/adapter.d.ts +74 -130
  309. package/dist/local/store/node/adapter.d.ts.map +1 -1
  310. package/dist/local/store/node/adapter.js +83 -727
  311. package/dist/local/store/node/adapter.js.map +1 -1
  312. package/dist/local/store/node/index.d.ts +8 -6
  313. package/dist/local/store/node/index.d.ts.map +1 -1
  314. package/dist/local/store/node/index.js +3 -7
  315. package/dist/local/store/node/index.js.map +1 -1
  316. package/dist/local/store/node/maintenance.d.ts +5 -0
  317. package/dist/local/store/node/maintenance.d.ts.map +1 -0
  318. package/dist/local/store/node/maintenance.js +7 -0
  319. package/dist/local/store/node/maintenance.js.map +1 -0
  320. package/dist/local/store/node/owner-lock.d.ts +26 -0
  321. package/dist/local/store/node/owner-lock.d.ts.map +1 -0
  322. package/dist/local/store/node/owner-lock.js +88 -0
  323. package/dist/local/store/node/owner-lock.js.map +1 -0
  324. package/dist/local/store/react-native/adapter.d.ts +63 -273
  325. package/dist/local/store/react-native/adapter.d.ts.map +1 -1
  326. package/dist/local/store/react-native/adapter.js +80 -1405
  327. package/dist/local/store/react-native/adapter.js.map +1 -1
  328. package/dist/local/store/react-native/index.d.ts +7 -19
  329. package/dist/local/store/react-native/index.d.ts.map +1 -1
  330. package/dist/local/store/react-native/index.js +2 -7
  331. package/dist/local/store/react-native/index.js.map +1 -1
  332. package/dist/local/store/react-native/maintenance.d.ts +5 -0
  333. package/dist/local/store/react-native/maintenance.d.ts.map +1 -0
  334. package/dist/local/store/react-native/maintenance.js +7 -0
  335. package/dist/local/store/react-native/maintenance.js.map +1 -0
  336. package/dist/local/store/sqlite/better-sqlite3-multiple-ciphers-driver.d.ts +38 -0
  337. package/dist/local/store/sqlite/better-sqlite3-multiple-ciphers-driver.d.ts.map +1 -0
  338. package/dist/local/store/sqlite/better-sqlite3-multiple-ciphers-driver.js +196 -0
  339. package/dist/local/store/sqlite/better-sqlite3-multiple-ciphers-driver.js.map +1 -0
  340. package/dist/local/store/sqlite/database.d.ts +20 -0
  341. package/dist/local/store/sqlite/database.d.ts.map +1 -0
  342. package/dist/local/store/sqlite/database.js +41 -0
  343. package/dist/local/store/sqlite/database.js.map +1 -0
  344. package/dist/local/store/sqlite/driver.d.ts +138 -0
  345. package/dist/local/store/sqlite/driver.d.ts.map +1 -0
  346. package/dist/local/store/sqlite/driver.js +10 -0
  347. package/dist/local/store/sqlite/driver.js.map +1 -0
  348. package/dist/local/store/sqlite/encryption.d.ts +61 -0
  349. package/dist/local/store/sqlite/encryption.d.ts.map +1 -0
  350. package/dist/local/store/sqlite/encryption.js +98 -0
  351. package/dist/local/store/sqlite/encryption.js.map +1 -0
  352. package/dist/local/store/sqlite/errors.d.ts +70 -0
  353. package/dist/local/store/sqlite/errors.d.ts.map +1 -0
  354. package/dist/local/store/sqlite/errors.js +101 -0
  355. package/dist/local/store/sqlite/errors.js.map +1 -0
  356. package/dist/local/store/sqlite/executor.d.ts +22 -0
  357. package/dist/local/store/sqlite/executor.d.ts.map +1 -0
  358. package/dist/local/store/sqlite/executor.js +129 -0
  359. package/dist/local/store/sqlite/executor.js.map +1 -0
  360. package/dist/local/store/sqlite/index.d.ts +20 -0
  361. package/dist/local/store/sqlite/index.d.ts.map +1 -0
  362. package/dist/local/store/sqlite/index.js +18 -0
  363. package/dist/local/store/sqlite/index.js.map +1 -0
  364. package/dist/local/store/sqlite/key-storage/account.d.ts +45 -0
  365. package/dist/local/store/sqlite/key-storage/account.d.ts.map +1 -0
  366. package/dist/local/store/sqlite/key-storage/account.js +125 -0
  367. package/dist/local/store/sqlite/key-storage/account.js.map +1 -0
  368. package/dist/local/store/sqlite/key-storage/contact-identities.d.ts +19 -0
  369. package/dist/local/store/sqlite/key-storage/contact-identities.d.ts.map +1 -0
  370. package/dist/local/store/sqlite/key-storage/contact-identities.js +85 -0
  371. package/dist/local/store/sqlite/key-storage/contact-identities.js.map +1 -0
  372. package/dist/local/store/sqlite/key-storage/context.d.ts +19 -0
  373. package/dist/local/store/sqlite/key-storage/context.d.ts.map +1 -0
  374. package/dist/local/store/sqlite/key-storage/context.js +18 -0
  375. package/dist/local/store/sqlite/key-storage/context.js.map +1 -0
  376. package/dist/local/store/sqlite/key-storage/identity-keys.d.ts +18 -0
  377. package/dist/local/store/sqlite/key-storage/identity-keys.d.ts.map +1 -0
  378. package/dist/local/store/sqlite/key-storage/identity-keys.js +88 -0
  379. package/dist/local/store/sqlite/key-storage/identity-keys.js.map +1 -0
  380. package/dist/local/store/sqlite/key-storage/index.d.ts +108 -0
  381. package/dist/local/store/sqlite/key-storage/index.d.ts.map +1 -0
  382. package/dist/local/store/sqlite/key-storage/index.js +241 -0
  383. package/dist/local/store/sqlite/key-storage/index.js.map +1 -0
  384. package/dist/local/store/sqlite/key-storage/message-records.d.ts +41 -0
  385. package/dist/local/store/sqlite/key-storage/message-records.d.ts.map +1 -0
  386. package/dist/local/store/sqlite/key-storage/message-records.js +133 -0
  387. package/dist/local/store/sqlite/key-storage/message-records.js.map +1 -0
  388. package/dist/local/store/sqlite/key-storage/metadata.d.ts +16 -0
  389. package/dist/local/store/sqlite/key-storage/metadata.d.ts.map +1 -0
  390. package/dist/local/store/sqlite/key-storage/metadata.js +53 -0
  391. package/dist/local/store/sqlite/key-storage/metadata.js.map +1 -0
  392. package/dist/local/store/sqlite/key-storage/one-time-prekeys.d.ts +36 -0
  393. package/dist/local/store/sqlite/key-storage/one-time-prekeys.d.ts.map +1 -0
  394. package/dist/local/store/sqlite/key-storage/one-time-prekeys.js +129 -0
  395. package/dist/local/store/sqlite/key-storage/one-time-prekeys.js.map +1 -0
  396. package/dist/local/store/sqlite/key-storage/session-trust.d.ts +10 -0
  397. package/dist/local/store/sqlite/key-storage/session-trust.d.ts.map +1 -0
  398. package/dist/local/store/sqlite/key-storage/session-trust.js +88 -0
  399. package/dist/local/store/sqlite/key-storage/session-trust.js.map +1 -0
  400. package/dist/local/store/sqlite/key-storage/sessions.d.ts +50 -0
  401. package/dist/local/store/sqlite/key-storage/sessions.d.ts.map +1 -0
  402. package/dist/local/store/sqlite/key-storage/sessions.js +209 -0
  403. package/dist/local/store/sqlite/key-storage/sessions.js.map +1 -0
  404. package/dist/local/store/sqlite/key-storage/signed-prekeys.d.ts +69 -0
  405. package/dist/local/store/sqlite/key-storage/signed-prekeys.d.ts.map +1 -0
  406. package/dist/local/store/sqlite/key-storage/signed-prekeys.js +219 -0
  407. package/dist/local/store/sqlite/key-storage/signed-prekeys.js.map +1 -0
  408. package/dist/local/store/sqlite/maintenance.d.ts +7 -0
  409. package/dist/local/store/sqlite/maintenance.d.ts.map +1 -0
  410. package/dist/local/store/sqlite/maintenance.js +32 -0
  411. package/dist/local/store/sqlite/maintenance.js.map +1 -0
  412. package/dist/local/store/sqlite/migrations.d.ts +31 -0
  413. package/dist/local/store/sqlite/migrations.d.ts.map +1 -0
  414. package/dist/local/store/sqlite/migrations.js +232 -0
  415. package/dist/local/store/sqlite/migrations.js.map +1 -0
  416. package/dist/local/store/{expo → sqlite}/models/ec-one-time-prekey.d.ts +17 -22
  417. package/dist/local/store/sqlite/models/ec-one-time-prekey.d.ts.map +1 -0
  418. package/dist/local/store/{expo → sqlite}/models/ec-one-time-prekey.js +61 -99
  419. package/dist/local/store/sqlite/models/ec-one-time-prekey.js.map +1 -0
  420. package/dist/local/store/{expo → sqlite}/models/ec-signed-prekey.d.ts +22 -25
  421. package/dist/local/store/sqlite/models/ec-signed-prekey.d.ts.map +1 -0
  422. package/dist/local/store/{expo → sqlite}/models/ec-signed-prekey.js +82 -128
  423. package/dist/local/store/sqlite/models/ec-signed-prekey.js.map +1 -0
  424. package/dist/local/store/sqlite/models/identity-key-id.d.ts.map +1 -0
  425. package/dist/local/store/sqlite/models/identity-key-id.js.map +1 -0
  426. package/dist/local/store/{expo → sqlite}/models/index.d.ts +5 -5
  427. package/dist/local/store/sqlite/models/index.d.ts.map +1 -0
  428. package/dist/local/store/{expo → sqlite}/models/index.js +12 -5
  429. package/dist/local/store/sqlite/models/index.js.map +1 -0
  430. package/dist/local/store/{expo → sqlite}/models/kyber-one-time-prekey.d.ts +17 -20
  431. package/dist/local/store/sqlite/models/kyber-one-time-prekey.d.ts.map +1 -0
  432. package/dist/local/store/{expo → sqlite}/models/kyber-one-time-prekey.js +65 -105
  433. package/dist/local/store/sqlite/models/kyber-one-time-prekey.js.map +1 -0
  434. package/dist/local/store/{expo → sqlite}/models/kyber-prekey-used.d.ts +3 -3
  435. package/dist/local/store/sqlite/models/kyber-prekey-used.d.ts.map +1 -0
  436. package/dist/local/store/{expo → sqlite}/models/kyber-prekey-used.js +13 -25
  437. package/dist/local/store/sqlite/models/kyber-prekey-used.js.map +1 -0
  438. package/dist/local/store/{expo → sqlite}/models/kyber-prekey.d.ts +16 -19
  439. package/dist/local/store/sqlite/models/kyber-prekey.d.ts.map +1 -0
  440. package/dist/local/store/{expo → sqlite}/models/kyber-prekey.js +67 -111
  441. package/dist/local/store/sqlite/models/kyber-prekey.js.map +1 -0
  442. package/dist/local/store/sqlite/models/local-identity.d.ts +51 -0
  443. package/dist/local/store/sqlite/models/local-identity.d.ts.map +1 -0
  444. package/dist/local/store/sqlite/models/local-identity.js +150 -0
  445. package/dist/local/store/sqlite/models/local-identity.js.map +1 -0
  446. package/dist/local/store/{expo → sqlite}/models/message-record.d.ts +15 -44
  447. package/dist/local/store/sqlite/models/message-record.d.ts.map +1 -0
  448. package/dist/local/store/{expo → sqlite}/models/message-record.js +43 -109
  449. package/dist/local/store/sqlite/models/message-record.js.map +1 -0
  450. package/dist/local/store/sqlite/models/recipient-identity.d.ts +21 -0
  451. package/dist/local/store/sqlite/models/recipient-identity.d.ts.map +1 -0
  452. package/dist/local/store/sqlite/models/recipient-identity.js +59 -0
  453. package/dist/local/store/sqlite/models/recipient-identity.js.map +1 -0
  454. package/dist/local/store/sqlite/models/replaced-prekeys.d.ts +23 -0
  455. package/dist/local/store/sqlite/models/replaced-prekeys.d.ts.map +1 -0
  456. package/dist/local/store/sqlite/models/replaced-prekeys.js +42 -0
  457. package/dist/local/store/sqlite/models/replaced-prekeys.js.map +1 -0
  458. package/dist/local/store/{expo → sqlite}/models/sender-key.d.ts +22 -23
  459. package/dist/local/store/sqlite/models/sender-key.d.ts.map +1 -0
  460. package/dist/local/store/{expo → sqlite}/models/sender-key.js +66 -94
  461. package/dist/local/store/sqlite/models/sender-key.js.map +1 -0
  462. package/dist/local/store/sqlite/models/sesame-user-record.d.ts +32 -0
  463. package/dist/local/store/sqlite/models/sesame-user-record.d.ts.map +1 -0
  464. package/dist/local/store/sqlite/models/sesame-user-record.js +78 -0
  465. package/dist/local/store/sqlite/models/sesame-user-record.js.map +1 -0
  466. package/dist/local/store/{expo → sqlite}/models/session.d.ts +24 -20
  467. package/dist/local/store/sqlite/models/session.d.ts.map +1 -0
  468. package/dist/local/store/{expo → sqlite}/models/session.js +54 -72
  469. package/dist/local/store/sqlite/models/session.js.map +1 -0
  470. package/dist/local/store/sqlite/models/skipped-sender-key.d.ts +24 -0
  471. package/dist/local/store/sqlite/models/skipped-sender-key.d.ts.map +1 -0
  472. package/dist/local/store/sqlite/models/skipped-sender-key.js +62 -0
  473. package/dist/local/store/sqlite/models/skipped-sender-key.js.map +1 -0
  474. package/dist/local/store/sqlite/op-sqlite-driver.d.ts +14 -0
  475. package/dist/local/store/sqlite/op-sqlite-driver.d.ts.map +1 -0
  476. package/dist/local/store/sqlite/op-sqlite-driver.js +180 -0
  477. package/dist/local/store/sqlite/op-sqlite-driver.js.map +1 -0
  478. package/dist/local/store/sqlite/open-store.d.ts +83 -0
  479. package/dist/local/store/sqlite/open-store.d.ts.map +1 -0
  480. package/dist/local/store/sqlite/open-store.js +177 -0
  481. package/dist/local/store/sqlite/open-store.js.map +1 -0
  482. package/dist/local/store/sqlite/schema.d.ts +102 -0
  483. package/dist/local/store/sqlite/schema.d.ts.map +1 -0
  484. package/dist/local/store/sqlite/schema.js +61 -0
  485. package/dist/local/store/sqlite/schema.js.map +1 -0
  486. package/dist/local/store/sqlite/store.d.ts +199 -0
  487. package/dist/local/store/sqlite/store.d.ts.map +1 -0
  488. package/dist/local/store/sqlite/store.js +494 -0
  489. package/dist/local/store/sqlite/store.js.map +1 -0
  490. package/dist/local/store/sqlite/web/driver.d.ts +50 -0
  491. package/dist/local/store/sqlite/web/driver.d.ts.map +1 -0
  492. package/dist/local/store/sqlite/web/driver.js +169 -0
  493. package/dist/local/store/sqlite/web/driver.js.map +1 -0
  494. package/dist/local/store/sqlite/web/protocol.d.ts +80 -0
  495. package/dist/local/store/sqlite/web/protocol.d.ts.map +1 -0
  496. package/dist/local/store/sqlite/web/protocol.js +13 -0
  497. package/dist/local/store/sqlite/web/protocol.js.map +1 -0
  498. package/dist/local/store/sqlite/web/sqlite3mc/sqlite3.mjs +14526 -0
  499. package/dist/local/store/sqlite/web/sqlite3mc/sqlite3.wasm +0 -0
  500. package/dist/local/store/sqlite/web/worker.d.ts +36 -0
  501. package/dist/local/store/sqlite/web/worker.d.ts.map +1 -0
  502. package/dist/local/store/sqlite/web/worker.js +616 -0
  503. package/dist/local/store/sqlite/web/worker.js.map +1 -0
  504. package/dist/local/store/web/adapter.d.ts +5 -14
  505. package/dist/local/store/web/adapter.d.ts.map +1 -1
  506. package/dist/local/store/web/adapter.js +119 -106
  507. package/dist/local/store/web/adapter.js.map +1 -1
  508. package/dist/local/store/web/device-record.d.ts +23 -0
  509. package/dist/local/store/web/device-record.d.ts.map +1 -0
  510. package/dist/local/store/web/device-record.js +31 -0
  511. package/dist/local/store/web/device-record.js.map +1 -0
  512. package/dist/local/store/web-sqlite/adapter.d.ts +98 -0
  513. package/dist/local/store/web-sqlite/adapter.d.ts.map +1 -0
  514. package/dist/local/store/web-sqlite/adapter.js +151 -0
  515. package/dist/local/store/web-sqlite/adapter.js.map +1 -0
  516. package/dist/local/store/web-sqlite/index.d.ts +14 -0
  517. package/dist/local/store/web-sqlite/index.d.ts.map +1 -0
  518. package/dist/local/store/web-sqlite/index.js +3 -0
  519. package/dist/local/store/web-sqlite/index.js.map +1 -0
  520. package/dist/local/store/web-sqlite/maintenance.d.ts +5 -0
  521. package/dist/local/store/web-sqlite/maintenance.d.ts.map +1 -0
  522. package/dist/local/store/web-sqlite/maintenance.js +7 -0
  523. package/dist/local/store/web-sqlite/maintenance.js.map +1 -0
  524. package/dist/local/store/web-sqlite/store-locks.d.ts +33 -0
  525. package/dist/local/store/web-sqlite/store-locks.d.ts.map +1 -0
  526. package/dist/local/store/web-sqlite/store-locks.js +60 -0
  527. package/dist/local/store/web-sqlite/store-locks.js.map +1 -0
  528. package/dist/local/vault/electron-safe-storage.d.ts +45 -0
  529. package/dist/local/vault/electron-safe-storage.d.ts.map +1 -0
  530. package/dist/local/vault/electron-safe-storage.js +212 -0
  531. package/dist/local/vault/electron-safe-storage.js.map +1 -0
  532. package/dist/local/vault/index.d.ts +4 -2
  533. package/dist/local/vault/index.d.ts.map +1 -1
  534. package/dist/local/vault/indexed-db.d.ts +37 -0
  535. package/dist/local/vault/indexed-db.d.ts.map +1 -0
  536. package/dist/local/vault/indexed-db.js +102 -0
  537. package/dist/local/vault/indexed-db.js.map +1 -0
  538. package/dist/local/vault/react-native-keychain.d.ts +12 -0
  539. package/dist/local/vault/react-native-keychain.d.ts.map +1 -0
  540. package/dist/local/vault/react-native-keychain.js +71 -0
  541. package/dist/local/vault/react-native-keychain.js.map +1 -0
  542. package/dist/local/vault/require.d.ts +10 -0
  543. package/dist/local/vault/require.d.ts.map +1 -0
  544. package/dist/local/vault/require.js +16 -0
  545. package/dist/local/vault/require.js.map +1 -0
  546. package/dist/logger.d.ts.map +1 -1
  547. package/dist/logger.js +2 -1
  548. package/dist/logger.js.map +1 -1
  549. package/dist/media/index.d.ts.map +1 -1
  550. package/dist/media/index.js +2 -1
  551. package/dist/media/index.js.map +1 -1
  552. package/dist/profile/contact-state.d.ts.map +1 -1
  553. package/dist/profile/contact-state.js +2 -4
  554. package/dist/profile/contact-state.js.map +1 -1
  555. package/dist/profile/index.d.ts +0 -1
  556. package/dist/profile/index.d.ts.map +1 -1
  557. package/dist/profile/index.js +0 -2
  558. package/dist/profile/index.js.map +1 -1
  559. package/dist/profile/profile-key.d.ts +16 -11
  560. package/dist/profile/profile-key.d.ts.map +1 -1
  561. package/dist/profile/profile-key.js +29 -29
  562. package/dist/profile/profile-key.js.map +1 -1
  563. package/dist/profile/update-service.d.ts +6 -0
  564. package/dist/profile/update-service.d.ts.map +1 -1
  565. package/dist/profile/update-service.js +3 -1
  566. package/dist/profile/update-service.js.map +1 -1
  567. package/dist/remote/object-store/validation.d.ts.map +1 -1
  568. package/dist/remote/object-store/validation.js +2 -1
  569. package/dist/remote/object-store/validation.js.map +1 -1
  570. package/dist/remote/relay/memory/adapter.d.ts +2 -3
  571. package/dist/remote/relay/memory/adapter.d.ts.map +1 -1
  572. package/dist/remote/relay/memory/adapter.js +22 -30
  573. package/dist/remote/relay/memory/adapter.js.map +1 -1
  574. package/dist/remote/relay/memory/failures.d.ts.map +1 -1
  575. package/dist/remote/relay/memory/failures.js +2 -1
  576. package/dist/remote/relay/memory/failures.js.map +1 -1
  577. package/dist/remote/relay/memory/group-server.d.ts +5 -1
  578. package/dist/remote/relay/memory/group-server.d.ts.map +1 -1
  579. package/dist/remote/relay/memory/group-server.js +11 -1
  580. package/dist/remote/relay/memory/group-server.js.map +1 -1
  581. package/dist/safety/url.d.ts.map +1 -1
  582. package/dist/safety/url.js +21 -26
  583. package/dist/safety/url.js.map +1 -1
  584. package/dist/types/api.d.ts +15 -2
  585. package/dist/types/api.d.ts.map +1 -1
  586. package/dist/types/errors.d.ts +97 -1
  587. package/dist/types/errors.d.ts.map +1 -1
  588. package/dist/types/errors.js +105 -1
  589. package/dist/types/errors.js.map +1 -1
  590. package/dist/types/session.d.ts.map +1 -1
  591. package/dist/types/session.js +2 -1
  592. package/dist/types/session.js.map +1 -1
  593. package/dist/utils/retry.d.ts +2 -0
  594. package/dist/utils/retry.d.ts.map +1 -1
  595. package/dist/utils/retry.js +4 -2
  596. package/dist/utils/retry.js.map +1 -1
  597. package/docs/ASSURANCE.md +81 -8
  598. package/docs/CLIENT_COMPOSITION.md +1 -2
  599. package/docs/DEVIATIONS.md +27 -3
  600. package/docs/ERROR_HANDLING.md +6 -0
  601. package/docs/GETTING_STARTED.md +1 -2
  602. package/docs/PACKAGE_SURFACE.md +29 -11
  603. package/docs/RECIPES.md +1 -2
  604. package/examples/browser/index.html +1 -1
  605. package/local/store/README.md +117 -34
  606. package/local/store/expo/README.md +67 -47
  607. package/local/store/key-value/README.md +278 -0
  608. package/local/store/node/README.md +206 -45
  609. package/local/store/react-native/README.md +121 -52
  610. package/local/store/web/README.md +9 -0
  611. package/local/store/web-sqlite/README.md +202 -0
  612. package/local/vault/README.md +115 -2
  613. package/package.json +61 -42
  614. package/profile/README.md +9 -11
  615. package/remote/README.md +1 -2
  616. package/dist/local/store/expo/database-key.d.ts +0 -142
  617. package/dist/local/store/expo/database-key.d.ts.map +0 -1
  618. package/dist/local/store/expo/database-key.js +0 -312
  619. package/dist/local/store/expo/database-key.js.map +0 -1
  620. package/dist/local/store/expo/db.d.ts +0 -95
  621. package/dist/local/store/expo/db.d.ts.map +0 -1
  622. package/dist/local/store/expo/db.js +0 -147
  623. package/dist/local/store/expo/db.js.map +0 -1
  624. package/dist/local/store/expo/key-storage.d.ts +0 -429
  625. package/dist/local/store/expo/key-storage.d.ts.map +0 -1
  626. package/dist/local/store/expo/key-storage.js +0 -1361
  627. package/dist/local/store/expo/key-storage.js.map +0 -1
  628. package/dist/local/store/expo/models/ec-one-time-prekey.d.ts.map +0 -1
  629. package/dist/local/store/expo/models/ec-one-time-prekey.js.map +0 -1
  630. package/dist/local/store/expo/models/ec-signed-prekey.d.ts.map +0 -1
  631. package/dist/local/store/expo/models/ec-signed-prekey.js.map +0 -1
  632. package/dist/local/store/expo/models/identity-key-id.d.ts.map +0 -1
  633. package/dist/local/store/expo/models/identity-key-id.js.map +0 -1
  634. package/dist/local/store/expo/models/index.d.ts.map +0 -1
  635. package/dist/local/store/expo/models/index.js.map +0 -1
  636. package/dist/local/store/expo/models/kyber-one-time-prekey.d.ts.map +0 -1
  637. package/dist/local/store/expo/models/kyber-one-time-prekey.js.map +0 -1
  638. package/dist/local/store/expo/models/kyber-prekey-used.d.ts.map +0 -1
  639. package/dist/local/store/expo/models/kyber-prekey-used.js.map +0 -1
  640. package/dist/local/store/expo/models/kyber-prekey.d.ts.map +0 -1
  641. package/dist/local/store/expo/models/kyber-prekey.js.map +0 -1
  642. package/dist/local/store/expo/models/local-identity.d.ts +0 -52
  643. package/dist/local/store/expo/models/local-identity.d.ts.map +0 -1
  644. package/dist/local/store/expo/models/local-identity.js +0 -166
  645. package/dist/local/store/expo/models/local-identity.js.map +0 -1
  646. package/dist/local/store/expo/models/message-record.d.ts.map +0 -1
  647. package/dist/local/store/expo/models/message-record.js.map +0 -1
  648. package/dist/local/store/expo/models/recipient-identity.d.ts +0 -21
  649. package/dist/local/store/expo/models/recipient-identity.d.ts.map +0 -1
  650. package/dist/local/store/expo/models/recipient-identity.js +0 -66
  651. package/dist/local/store/expo/models/recipient-identity.js.map +0 -1
  652. package/dist/local/store/expo/models/replaced-prekey-utils.d.ts +0 -33
  653. package/dist/local/store/expo/models/replaced-prekey-utils.d.ts.map +0 -1
  654. package/dist/local/store/expo/models/replaced-prekey-utils.js +0 -54
  655. package/dist/local/store/expo/models/replaced-prekey-utils.js.map +0 -1
  656. package/dist/local/store/expo/models/sender-key.d.ts.map +0 -1
  657. package/dist/local/store/expo/models/sender-key.js.map +0 -1
  658. package/dist/local/store/expo/models/session.d.ts.map +0 -1
  659. package/dist/local/store/expo/models/session.js.map +0 -1
  660. package/dist/local/store/expo/schema.d.ts +0 -1917
  661. package/dist/local/store/expo/schema.d.ts.map +0 -1
  662. package/dist/local/store/expo/schema.js +0 -197
  663. package/dist/local/store/expo/schema.js.map +0 -1
  664. package/dist/local/store/node/database-encryption.d.ts +0 -109
  665. package/dist/local/store/node/database-encryption.d.ts.map +0 -1
  666. package/dist/local/store/node/database-encryption.js +0 -202
  667. package/dist/local/store/node/database-encryption.js.map +0 -1
  668. package/dist/local/store/node/database-file-commit.d.ts +0 -8
  669. package/dist/local/store/node/database-file-commit.d.ts.map +0 -1
  670. package/dist/local/store/node/database-file-commit.js +0 -62
  671. package/dist/local/store/node/database-file-commit.js.map +0 -1
  672. package/dist/local/store/node/database-key.d.ts +0 -129
  673. package/dist/local/store/node/database-key.d.ts.map +0 -1
  674. package/dist/local/store/node/database-key.js +0 -293
  675. package/dist/local/store/node/database-key.js.map +0 -1
  676. package/dist/local/store/node/database-lock.d.ts +0 -8
  677. package/dist/local/store/node/database-lock.d.ts.map +0 -1
  678. package/dist/local/store/node/database-lock.js +0 -44
  679. package/dist/local/store/node/database-lock.js.map +0 -1
  680. package/dist/local/store/node/database.d.ts +0 -226
  681. package/dist/local/store/node/database.d.ts.map +0 -1
  682. package/dist/local/store/node/database.js +0 -813
  683. package/dist/local/store/node/database.js.map +0 -1
  684. package/dist/local/store/react-native/backend-conformance.d.ts.map +0 -1
  685. package/dist/local/store/react-native/backend-conformance.js.map +0 -1
  686. package/dist/local/store/react-native/reference-backend.d.ts +0 -43
  687. package/dist/local/store/react-native/reference-backend.d.ts.map +0 -1
  688. package/dist/local/store/react-native/reference-backend.js +0 -178
  689. package/dist/local/store/react-native/reference-backend.js.map +0 -1
  690. package/dist/local/store/react-native/storage.d.ts.map +0 -1
  691. package/dist/local/store/react-native/storage.js.map +0 -1
  692. package/dist/profile/storage.d.ts +0 -61
  693. package/dist/profile/storage.d.ts.map +0 -1
  694. package/dist/profile/storage.js +0 -145
  695. package/dist/profile/storage.js.map +0 -1
  696. /package/dist/local/store/{react-native → key-value}/storage.js +0 -0
  697. /package/dist/local/store/{expo → sqlite}/models/identity-key-id.d.ts +0 -0
  698. /package/dist/local/store/{expo → sqlite}/models/identity-key-id.js +0 -0
@@ -1,1423 +1,98 @@
1
1
  /**
2
- * React Native Storage Adapter (Bare Workflow)
2
+ * React Native SQLite Signal Protocol Store
3
3
  *
4
- * Storage adapter for React Native applications without Expo.
5
- * Uses:
6
- * - a caller-provided persistent key-value backend
7
- * - expo-crypto for secure random number generation
8
- * - Signal Protocol crypto module for AES-256-GCM encryption (via Web Crypto API)
9
- *
10
- * Security Considerations:
11
- * - All sensitive data encrypted with AES-256-GCM (128-bit auth tag)
12
- * - Database encryption key stored in the provided key-value backend
13
- * - For production apps, keep the database key in a platform secret vault
14
- * - Requires a Web Crypto API polyfill (e.g., react-native-quick-crypto) for bare RN
15
- *
16
- * @example
17
- * ```typescript
18
- * const keyValueStorage = yourPersistentKeyValueStorage;
19
- * const storage = await ReactNativeSignalProtocolStore.create({ storage: keyValueStorage });
20
- *
21
- * // Store identity key
22
- * await storage.storeIdentityKey(keyPair);
23
- * ```
4
+ * The SDK owns the database file. One call opens it in the op-sqlite default
5
+ * location, gets or creates its key through the local secret vault, applies
6
+ * the SDK migrations, and returns the store.
24
7
  */
25
- import * as Crypto from 'expo-crypto';
26
- import * as SignalProtocolCrypto from '../../../internal/crypto/index.js';
27
- import { MAX_UNACKNOWLEDGED_SESSION_AGE_MS } from '../../../types/protocol-config.js';
28
- import { assertCurrentSessionRecord } from '../../../types/session.js';
29
- import { acceptContactIdentityRotation as acceptRotation, createUnverifiedContactIdentityRecord, evaluateContactIdentityCandidate, validateContactIdentityRecord, verifyContactIdentityRecord, } from '../../../keys/identity.js';
30
- import { IdentityKeyChange, StorageQuotaExceededError } from '../../../types/index.js';
31
- import { deserializeSessionRecord, serializeSessionRecord } from '../session-codec.js';
32
- import { parseReceivedContent } from '../received-content.js';
33
- import { createKyberPreKeyState, createKyberPreKeyInstanceId, getCurrentKyberPreKey, getRetainedKyberPreKey, recordKyberPreKeyUse, recordKyberPreKeyUseById, retainKyberPreKey, } from '../kyber-prekey-lifecycle.js';
34
- const STORAGE_KEYS = {
35
- DATABASE_KEY: '@signal:databaseKey',
36
- IDENTITY_KEY_PREFIX: '@signal:identity:keyPair:',
37
- REGISTRATION_ID_PREFIX: '@signal:metadata:registrationId:',
38
- METADATA_PREFIX: '@signal:metadata:value:',
39
- CONTACT_PREFIX: '@signal:contacts:',
40
- CONTACT_V1_PREFIX: '@signal:contacts:v1:',
41
- PREKEY_PREFIX: '@signal:prekeys:',
42
- SESSION_PREFIX: '@signal:sessions:',
43
- SESAME_USER_PREFIX: '@signal:sesame:user:',
44
- SENDER_KEY_RECORD_PREFIX: '@signal:sender-key-record:',
45
- // Maps an opaque `senderKeyId` to the record that holds it. A received group
46
- // message names its sender key by that id and nothing else. This backend is
47
- // a flat key-value store with no secondary indexes, so the reverse lookup
48
- // has to be a stored pointer. The pointer value is a record key, not key
49
- // material. The ids in it already travel unencrypted on the wire.
50
- //
51
- // The pointer is scoped by sender, not by id alone. A sender chooses its own
52
- // id and announces it in a distribution message. Two senders can therefore
53
- // name the same one, by accident or deliberately, after reading a shared
54
- // group's distribution. A single global slot per id would let the second
55
- // writer silently take over the first's pointer. Every subsequent message
56
- // from the first sender would then fail to resolve.
57
- // See `getSenderKeyIdPointerKey`.
58
- SENDER_KEY_ID_INDEX_PREFIX: '@signal:sender-key-id:',
59
- SKIPPED_SENDER_KEY_PREFIX: '@signal:skipped-sender-key:',
60
- MESSAGE_RECORD_PREFIX: '@signal:message-record:',
61
- SECURITY_EVENTS: '@signal:security-events',
62
- };
63
- /**
64
- * Escape a value so it cannot contain the `:` that joins composite keys.
65
- *
66
- * Composite keys in this backend are `:`-joined strings. The components are
67
- * identifiers the adapter does not get to choose. They are group IDs, sender
68
- * key IDs read straight off the wire, and user IDs handed over by the host
69
- * application's identify hook.
70
- *
71
- * None of them are validated, and a tenant-scoped `tenant:alice` is an
72
- * ordinary thing for a host to produce. So "components contain no `:`" is an
73
- * assumption rather than a fact, and the encoding has to make it one.
74
- *
75
- * `%` is escaped first so the escape character itself round-trips: without it
76
- * a literal `%3A` in an identifier would unescape into a separator. Values
77
- * containing neither character escape to themselves, so an existing
78
- * deployment whose IDs are already well behaved keeps the keys it has.
79
- */
80
- function escapeKeyComponent(value) {
81
- return value.replace(/%/g, '%25').replace(/:/g, '%3A');
8
+ import { ReactNativeKeychainSignalProtocolSecretVault } from '../../vault/react-native-keychain.js';
9
+ import { createOpSqliteDriver } from '../sqlite/op-sqlite-driver.js';
10
+ import { openSqliteStore, resetSqliteStore, } from '../sqlite/open-store.js';
11
+ import { SqliteSignalProtocolStore } from '../sqlite/store.js';
12
+ /** The database file name when the options name none. */
13
+ const DEFAULT_DATABASE_NAME = 'open-e2ee-signal-protocol.db';
14
+ function storeOptions(options) {
15
+ return {
16
+ ...options,
17
+ driver: createOpSqliteDriver(),
18
+ name: options.name ?? DEFAULT_DATABASE_NAME,
19
+ vault: options.vault ?? new ReactNativeKeychainSignalProtocolSecretVault(),
20
+ };
82
21
  }
83
- /** Inverse of {@link escapeKeyComponent}. It unescapes in the opposite order. */
84
- function unescapeKeyComponent(value) {
85
- return value.replace(/%3A/g, ':').replace(/%25/g, '%');
22
+ /** The database of each open store, for the helpers of this entry. */
23
+ const databases = new WeakMap();
24
+ /** The executor of an open store. Not exported from the entry. */
25
+ export function reactNativeStoreDatabase(store) {
26
+ const database = databases.get(store);
27
+ if (!database)
28
+ throw new TypeError('Open the store with reactNativeStore().');
29
+ return database;
86
30
  }
87
31
  /**
88
- * A write the injected backend rejects for want of space fails with an error
89
- * named `QuotaExceededError`. Checked by name rather than instanceof, as in
90
- * the web adapter. The backend is application-supplied, so no error class is
91
- * shared with it, and the name is the documented signal.
92
- */
93
- function isQuotaExceededError(error) {
94
- return (typeof error === 'object' &&
95
- error !== null &&
96
- error.name === 'QuotaExceededError');
97
- }
98
- function mapQuotaFailure(operation, error) {
99
- if (!isQuotaExceededError(error))
100
- return error;
101
- // The failure is Error-shaped by the name check above, but not always
102
- // instanceof Error: a backend may surface a platform exception object.
103
- return new StorageQuotaExceededError(operation, error);
104
- }
105
- /**
106
- * Rebinds every method of the store so a QuotaExceededError from the
107
- * injected backend crosses the adapter boundary as the typed
108
- * StorageQuotaExceededError. Quota exhaustion can surface from any setItem
109
- * or atomicWrite the backend runs. The mapping therefore lives at this one
110
- * seam, instead of inside each of the adapter's write paths. A method added
111
- * later is covered without a wrapper of its own. The backend contract
112
- * commits nothing from a rejected write, so the typed error always means
113
- * the write did not persist.
114
- *
115
- * Wrapping runs inside the private constructor, and `create` is the only
116
- * construction path, so every caller-visible instance is wrapped before any
117
- * method can run.
118
- */
119
- function mapQuotaFailuresAtBoundary(store) {
120
- const methods = new Map();
121
- for (let prototype = Object.getPrototypeOf(store); prototype !== null && prototype !== Object.prototype; prototype = Object.getPrototypeOf(prototype)) {
122
- for (const name of Object.getOwnPropertyNames(prototype)) {
123
- // First found wins: the walk goes most-derived first.
124
- if (name === 'constructor' || methods.has(name))
125
- continue;
126
- const descriptor = Object.getOwnPropertyDescriptor(prototype, name);
127
- if (typeof descriptor?.value !== 'function')
128
- continue;
129
- methods.set(name, descriptor.value);
130
- }
131
- }
132
- for (const [name, method] of methods) {
133
- store[name] = function mapped(...args) {
134
- let result;
135
- try {
136
- result = method.apply(this, args);
137
- }
138
- catch (error) {
139
- throw mapQuotaFailure(name, error);
140
- }
141
- // Duck-typed rather than instanceof Promise so a cross-realm
142
- // promise or plain thenable from an override maps too.
143
- if (result !== null &&
144
- typeof result === 'object' &&
145
- typeof result.then === 'function') {
146
- return Promise.resolve(result).catch((error) => {
147
- throw mapQuotaFailure(name, error);
148
- });
149
- }
150
- return result;
151
- };
152
- }
153
- }
154
- /**
155
- * React Native storage adapter implementation
156
- *
157
- * Provides secure storage for Signal Protocol keys using an injected
158
- * React Native key-value backend and expo-crypto.
32
+ * Local Signal Protocol state for bare React Native, in an SDK-owned SQLCipher
33
+ * database on op-sqlite.
159
34
  *
160
- * @example
161
- * ```typescript
162
- * const keyValueStorage = yourPersistentKeyValueStorage;
163
- * const storage = await ReactNativeSignalProtocolStore.create({ storage: keyValueStorage });
35
+ * Open it with {@link reactNativeStore}. The store holds the database
36
+ * file until {@link ReactNativeSignalProtocolStore.close}. A second open
37
+ * of the same name in the process fails with `INVALID_STATE`.
164
38
  *
165
- * // Store identity key
166
- * await storage.storeIdentityKey(keyPair);
39
+ * Every table holds material that must not leave the device, including the
40
+ * group sender keys. SQLCipher encrypts the whole file, so the database key
41
+ * in the vault is the only thing that protects it.
167
42
  *
168
- * // Get identity key
169
- * const keyPair = await storage.getIdentityKey();
170
- * ```
43
+ * @category Key Storage
44
+ * @see {@link SignalProtocolLocalStore} for interface documentation
171
45
  */
172
- export class ReactNativeSignalProtocolStore {
173
- databaseKey = null;
174
- initialized = false;
175
- storageBackend;
176
- constructor(options) {
177
- this.storageBackend = options.storage;
178
- mapQuotaFailuresAtBoundary(this);
179
- }
180
- static async create(options) {
181
- const store = new ReactNativeSignalProtocolStore(options);
182
- await store.initialize();
183
- return store;
184
- }
185
- // ============================================================================
186
- // Initialization
187
- // ============================================================================
188
- /**
189
- * Initialize the storage adapter
190
- *
191
- * - Loads or generates database encryption key
192
- * - Stores key in the configured key-value backend
193
- */
194
- async initialize() {
195
- if (this.initialized) {
196
- return;
197
- }
198
- // Get or generate database encryption key
199
- const storedKey = await this.storageBackend.getItem(STORAGE_KEYS.DATABASE_KEY);
200
- if (storedKey) {
201
- // Decode from base64
202
- this.databaseKey = this.base64ToUint8Array(storedKey);
203
- }
204
- else {
205
- // Generate new 32-byte key
206
- this.databaseKey = Crypto.getRandomBytes(32);
207
- // Store as base64
208
- await this.storageBackend.setItem(STORAGE_KEYS.DATABASE_KEY, this.uint8ArrayToBase64(this.databaseKey));
209
- console.warn('[ReactNativeSignalProtocolStore] Database encryption key stored in the configured React Native storage backend. ' +
210
- 'For production apps, configure a platform secret vault for database-key custody.');
211
- }
212
- this.initialized = true;
213
- }
214
- /**
215
- * Get the database encryption key
216
- *
217
- * @returns 32-byte AES-256 key
218
- * @throws Error if not initialized
219
- */
220
- async getDatabaseKey() {
221
- this.ensureInitialized();
222
- return this.databaseKey;
223
- }
224
- // ============================================================================
225
- // Identity Key Management - Own Keys
226
- // ============================================================================
227
- async storeIdentityKey(keyPair, identityType) {
228
- this.ensureInitialized();
229
- const encrypted = await this.encrypt(JSON.stringify(keyPair));
230
- await this.storageBackend.setItem(this.getIdentityKeyStorageKey(identityType), encrypted);
231
- }
232
- async getIdentityKey(identityType) {
233
- this.ensureInitialized();
234
- const encrypted = await this.storageBackend.getItem(this.getIdentityKeyStorageKey(identityType));
235
- if (!encrypted)
236
- return null;
237
- const decrypted = await this.decrypt(encrypted);
238
- return JSON.parse(decrypted);
239
- }
240
- async hasIdentityKey(identityType) {
241
- this.ensureInitialized();
242
- const key = await this.storageBackend.getItem(this.getIdentityKeyStorageKey(identityType));
243
- return key !== null;
244
- }
245
- async getLocalRegistrationId(identityType) {
246
- this.ensureInitialized();
247
- const id = await this.storageBackend.getItem(this.getRegistrationIdStorageKey(identityType));
248
- if (!id)
249
- return 0;
250
- return parseInt(id, 10);
251
- }
252
- async setLocalRegistrationId(id, identityType) {
253
- this.ensureInitialized();
254
- await this.storageBackend.setItem(this.getRegistrationIdStorageKey(identityType), id.toString());
255
- }
256
- // ============================================================================
257
- // Identity Verification - Contact Keys (TOFU)
258
- // ============================================================================
259
- async saveContactIdentity(address, identity, identityType, suppliedCommitment) {
260
- this.ensureInitialized();
261
- const storageKey = this.getContactStorageKey(address, identityType);
262
- const existing = await this.readContactRecord(address, identityType);
263
- const status = evaluateContactIdentityCandidate(existing, identity, suppliedCommitment);
264
- if (status === 'NEW') {
265
- await this.writeContactRecord(storageKey, createUnverifiedContactIdentityRecord(identity, Date.now()));
266
- return IdentityKeyChange.NEW_IDENTITY;
267
- }
268
- if (status === 'MATCH')
269
- return IdentityKeyChange.UNCHANGED;
270
- if (status === 'ROLLBACK')
271
- return IdentityKeyChange.ROLLBACK;
272
- return IdentityKeyChange.CHANGED;
273
- }
274
- async getContactIdentity(address, identityType) {
275
- this.ensureInitialized();
276
- return await this.readContactRecord(address, identityType);
277
- }
278
- async acceptContactIdentityRotation(address, identity, identityType, suppliedCommitment) {
279
- return await this.acceptContactIdentityRotationAndDeleteSessions(address, identity, identityType, suppliedCommitment);
280
- }
281
- async acceptContactIdentityRotationAndDeleteSessions(address, identity, identityType, suppliedCommitment) {
282
- this.ensureInitialized();
283
- const contactKey = this.getContactStorageKey(address, identityType);
284
- const existingValue = await this.storageBackend.getItem(contactKey);
285
- if (!existingValue)
286
- throw new Error('Cannot rotate an unseen identity');
287
- const existing = JSON.parse(await this.decrypt(existingValue));
288
- validateContactIdentityRecord(existing);
289
- const replacement = acceptRotation(existing, identity, Date.now(), suppliedCommitment);
290
- validateContactIdentityRecord(replacement);
291
- await this.storageBackend.atomicWrite([
292
- { type: 'check', key: contactKey, expectedValue: existingValue },
293
- { type: 'set', key: contactKey, value: await this.encrypt(JSON.stringify(replacement)) },
294
- {
295
- type: 'removeSessionsForUser',
296
- keyPrefix: STORAGE_KEYS.SESSION_PREFIX,
297
- userId: address.userId,
298
- },
299
- ]);
300
- return replacement;
301
- }
302
- async verifyContactIdentity(address, identity, identityType, suppliedCommitment) {
303
- this.ensureInitialized();
304
- const contactKey = this.getContactStorageKey(address, identityType);
305
- const existingValue = await this.storageBackend.getItem(contactKey);
306
- const existing = existingValue
307
- ? JSON.parse(await this.decrypt(existingValue))
308
- : null;
309
- if (!existing)
310
- throw new Error('Cannot verify an unseen identity');
311
- validateContactIdentityRecord(existing);
312
- const verified = verifyContactIdentityRecord(existing, identity, Date.now(), suppliedCommitment);
313
- await this.storageBackend.atomicWrite([
314
- { type: 'check', key: contactKey, expectedValue: existingValue },
315
- { type: 'set', key: contactKey, value: await this.encrypt(JSON.stringify(verified)) },
316
- ]);
317
- return verified;
318
- }
319
- async isTrustedIdentity(address, identity, _direction, identityType) {
320
- this.ensureInitialized();
321
- const status = evaluateContactIdentityCandidate(await this.readContactRecord(address, identityType), identity);
322
- return status === 'NEW' || status === 'MATCH';
323
- }
324
- // ============================================================================
325
- // PreKey Management
326
- // ============================================================================
327
- async storeEcSignedPreKey(signedPreKey, identityType) {
328
- this.ensureInitialized();
329
- // Get existing prekeys and add/update the new one
330
- const allPrekeys = await this.getAllEcSignedPreKeys(identityType);
331
- const existingIndex = allPrekeys.findIndex((k) => k.keyId === signedPreKey.keyId);
332
- if (existingIndex >= 0) {
333
- allPrekeys[existingIndex] = signedPreKey;
334
- }
335
- else {
336
- allPrekeys.push(signedPreKey);
337
- }
338
- // Cleanup expired prekeys
339
- const cutoff = Date.now() - MAX_UNACKNOWLEDGED_SESSION_AGE_MS;
340
- const newest = allPrekeys.reduce((a, b) => (a.keyId > b.keyId ? a : b));
341
- const filtered = allPrekeys.filter((k) => k.keyId === newest.keyId || (k.timestamp && k.timestamp > cutoff));
342
- const encrypted = await this.encrypt(JSON.stringify(filtered));
343
- await this.storageBackend.setItem(this.getSignedPreKeyStorageKey(identityType), encrypted);
344
- }
345
- async getEcSignedPreKey(keyId, identityType) {
346
- this.ensureInitialized();
347
- const allPrekeys = await this.getAllEcSignedPreKeys(identityType);
348
- if (allPrekeys.length === 0)
349
- return null;
350
- if (keyId !== undefined) {
351
- // Look up by specific keyId
352
- return allPrekeys.find((k) => k.keyId === keyId) ?? null;
353
- }
354
- // Return the most recent (highest keyId)
355
- return allPrekeys.reduce((latest, current) => current.keyId > latest.keyId ? current : latest);
356
- }
357
- async getAllEcSignedPreKeys(identityType) {
358
- this.ensureInitialized();
359
- const encrypted = await this.storageBackend.getItem(this.getSignedPreKeyStorageKey(identityType));
360
- if (!encrypted) {
361
- return [];
362
- }
363
- const decrypted = await this.decrypt(encrypted);
364
- return JSON.parse(decrypted);
365
- }
366
- async removeEcSignedPreKey(keyId, identityType) {
367
- this.ensureInitialized();
368
- const allPrekeys = await this.getAllEcSignedPreKeys(identityType);
369
- const filtered = allPrekeys.filter((k) => k.keyId !== keyId);
370
- const encrypted = await this.encrypt(JSON.stringify(filtered));
371
- await this.storageBackend.setItem(this.getSignedPreKeyStorageKey(identityType), encrypted);
372
- }
373
- async storeEcOneTimePreKeys(prekeys, identityType) {
374
- this.ensureInitialized();
375
- const existing = await this.getEcOneTimePreKeys(identityType);
376
- await this.storageBackend.setItem(this.getEcOneTimePreKeyStorageKey(identityType), await this.encrypt(JSON.stringify([...existing, ...prekeys])));
377
- }
378
- async getEcOneTimePreKeys(identityType) {
379
- this.ensureInitialized();
380
- const encrypted = await this.storageBackend.getItem(this.getEcOneTimePreKeyStorageKey(identityType));
381
- if (!encrypted)
382
- return [];
383
- const decrypted = await this.decrypt(encrypted);
384
- return JSON.parse(decrypted);
385
- }
386
- async removeEcOneTimePreKey(preKeyId, identityType) {
387
- this.ensureInitialized();
388
- const prekeys = await this.getEcOneTimePreKeys(identityType);
389
- const filtered = prekeys.filter((pk) => pk.keyId !== preKeyId);
390
- await this.storageBackend.setItem(this.getEcOneTimePreKeyStorageKey(identityType), await this.encrypt(JSON.stringify(filtered)));
391
- }
392
- async storeKyberPreKey(kyberPreKey, identityType) {
393
- this.ensureInitialized();
394
- const it = identityType ?? 'aci';
395
- const storageKey = this.getKyberPreKeyStorageKey(it);
396
- const stored = await this.storageBackend.getItem(storageKey);
397
- const state = stored
398
- ? JSON.parse(await this.decrypt(stored))
399
- : createKyberPreKeyState();
400
- const instanceId = await createKyberPreKeyInstanceId();
401
- if (!retainKyberPreKey(state, kyberPreKey, it, Date.now(), instanceId))
402
- return;
403
- await this.storageBackend.atomicWrite([
404
- { type: 'check', key: storageKey, expectedValue: stored },
405
- { type: 'set', key: storageKey, value: await this.encrypt(JSON.stringify(state)) },
406
- ]);
407
- }
408
- async getKyberPreKey(identityType) {
409
- this.ensureInitialized();
410
- const encrypted = await this.storageBackend.getItem(this.getKyberPreKeyStorageKey(identityType));
411
- if (!encrypted)
412
- return null;
413
- const decrypted = await this.decrypt(encrypted);
414
- return getCurrentKyberPreKey(JSON.parse(decrypted));
415
- }
416
- async getKyberPreKeyById(keyId, identityType) {
417
- this.ensureInitialized();
418
- const encrypted = await this.storageBackend.getItem(this.getKyberPreKeyStorageKey(identityType));
419
- if (!encrypted)
420
- return null;
421
- return getRetainedKyberPreKey(JSON.parse(await this.decrypt(encrypted)), keyId);
422
- }
423
- async markKyberPreKeyUsed(kyberPreKeyId, signedPreKeyId, baseKeyBytes, identityType) {
424
- this.ensureInitialized();
425
- const it = identityType ?? 'aci';
426
- const storageKey = this.getKyberPreKeyStorageKey(it);
427
- const stored = await this.storageBackend.getItem(storageKey);
428
- const state = stored
429
- ? JSON.parse(await this.decrypt(stored))
430
- : null;
431
- recordKyberPreKeyUseById(state, it, { kyberPreKeyId, signedPreKeyId, baseKeyBytes });
432
- await this.storageBackend.atomicWrite([
433
- { type: 'check', key: storageKey, expectedValue: stored },
434
- { type: 'set', key: storageKey, value: await this.encrypt(JSON.stringify(state)) },
435
- ]);
436
- }
437
- // ============================================================================
438
- // KEM One-Time PreKey Management (Per-Session Post-Quantum Forward Secrecy)
439
- // ============================================================================
440
- // NOTE: This adapter is for bare React Native (non-Expo) apps.
441
- // Expo apps should still prefer ExpoSignalProtocolStore for the native SQLite backend.
442
- async storeKemOneTimePreKeys(prekeys, identityType) {
443
- this.ensureInitialized();
444
- const existing = await this.getKemOneTimePreKeys(identityType);
445
- await this.storageBackend.setItem(this.getKemOneTimePreKeyStorageKey(identityType), await this.encrypt(JSON.stringify([...existing, ...prekeys])));
446
- }
447
- async getKemOneTimePreKeys(identityType) {
448
- this.ensureInitialized();
449
- const encrypted = await this.storageBackend.getItem(this.getKemOneTimePreKeyStorageKey(identityType));
450
- if (!encrypted)
451
- return [];
452
- const decrypted = await this.decrypt(encrypted);
453
- return JSON.parse(decrypted);
454
- }
455
- async getKemOneTimePreKey(keyId, identityType) {
456
- const prekeys = await this.getKemOneTimePreKeys(identityType);
457
- return prekeys.find((prekey) => prekey.keyId === keyId) ?? null;
458
- }
459
- async removeKemOneTimePreKey(keyId, identityType) {
460
- this.ensureInitialized();
461
- const prekeys = await this.getKemOneTimePreKeys(identityType);
462
- const filtered = prekeys.filter((prekey) => prekey.keyId !== keyId);
463
- await this.storageBackend.setItem(this.getKemOneTimePreKeyStorageKey(identityType), await this.encrypt(JSON.stringify(filtered)));
464
- }
465
- async getKemOneTimePreKeyCount(identityType) {
466
- const prekeys = await this.getKemOneTimePreKeys(identityType);
467
- return prekeys.length;
468
- }
469
- // ============================================================================
470
- // Session Management - Modern API
471
- // ============================================================================
472
- async storeSessionRecord(address, record) {
473
- this.ensureInitialized();
474
- assertCurrentSessionRecord(record);
475
- const addressKey = this.serializeAddress(address);
476
- const storageKey = `${STORAGE_KEYS.SESSION_PREFIX}${addressKey}`;
477
- const encrypted = await this.encrypt(serializeSessionRecord(record));
478
- const storedRecord = {
479
- userId: address.userId,
480
- deviceId: address.deviceId,
481
- data: encrypted,
482
- updatedAt: Date.now(),
483
- };
484
- await this.storageBackend.setItem(storageKey, JSON.stringify(storedRecord));
485
- }
486
- async getSessionRecord(address) {
487
- this.ensureInitialized();
488
- const addressKey = this.serializeAddress(address);
489
- const storageKey = `${STORAGE_KEYS.SESSION_PREFIX}${addressKey}`;
490
- const storedJson = await this.storageBackend.getItem(storageKey);
491
- if (!storedJson)
492
- return null;
493
- const stored = JSON.parse(storedJson);
494
- const decrypted = await this.decrypt(stored.data);
495
- try {
496
- return deserializeSessionRecord(decrypted);
497
- }
498
- catch {
499
- await this.storageBackend.removeItem(storageKey);
500
- return null;
501
- }
502
- }
503
- async commitSessionTrust(commit) {
504
- this.ensureInitialized();
505
- assertCurrentSessionRecord(commit.record);
506
- const addressKey = this.serializeAddress(commit.address);
507
- const contactStorageKey = this.getContactStorageKey(commit.address, commit.contactIdentityType);
508
- const existingContactValue = await this.storageBackend.getItem(contactStorageKey);
509
- const existingContact = existingContactValue
510
- ? JSON.parse(await this.decrypt(existingContactValue))
511
- : null;
512
- if (existingContact)
513
- validateContactIdentityRecord(existingContact);
514
- const contactStatus = evaluateContactIdentityCandidate(existingContact, commit.contactIdentity);
515
- if (contactStatus !== 'NEW' && contactStatus !== 'MATCH') {
516
- throw new Error(`Atomic session/trust commit rejected contact identity status ${contactStatus}`);
517
- }
518
- const sessionStorageKey = `${STORAGE_KEYS.SESSION_PREFIX}${addressKey}`;
519
- const sessionValue = JSON.stringify({
520
- userId: commit.address.userId,
521
- deviceId: commit.address.deviceId,
522
- data: await this.encrypt(serializeSessionRecord(commit.record)),
523
- updatedAt: Date.now(),
524
- });
525
- const ecStorageKey = this.getEcOneTimePreKeyStorageKey(commit.localIdentityType);
526
- const kemStorageKey = this.getKemOneTimePreKeyStorageKey(commit.localIdentityType);
527
- const ecPrekeyValue = commit.oneTimePreKeyId === undefined ? null : await this.storageBackend.getItem(ecStorageKey);
528
- const kemPrekeyValue = commit.kemOneTimePreKeyId === undefined
529
- ? null
530
- : await this.storageBackend.getItem(kemStorageKey);
531
- const kyberStorageKey = this.getKyberPreKeyStorageKey(commit.localIdentityType);
532
- const kyberStateValue = commit.kyberPreKeyUse
533
- ? await this.storageBackend.getItem(kyberStorageKey)
534
- : null;
535
- const ecPrekeys = ecPrekeyValue
536
- ? JSON.parse(await this.decrypt(ecPrekeyValue))
537
- : [];
538
- const kemPrekeys = kemPrekeyValue
539
- ? JSON.parse(await this.decrypt(kemPrekeyValue))
540
- : [];
541
- if (commit.oneTimePreKeyId !== undefined &&
542
- !ecPrekeys.some((key) => key.keyId === commit.oneTimePreKeyId)) {
543
- throw new Error('Atomic session/trust commit cannot consume a missing EC one-time prekey');
544
- }
545
- if (commit.kemOneTimePreKeyId !== undefined &&
546
- !kemPrekeys.some((key) => key.keyId === commit.kemOneTimePreKeyId)) {
547
- throw new Error('Atomic session/trust commit cannot consume a missing KEM one-time prekey');
548
- }
549
- let updatedKyberStateValue = null;
550
- if (commit.kyberPreKeyUse) {
551
- const state = kyberStateValue
552
- ? JSON.parse(await this.decrypt(kyberStateValue))
553
- : null;
554
- recordKyberPreKeyUse(state, commit.localIdentityType, commit.kyberPreKeyUse);
555
- updatedKyberStateValue = await this.encrypt(JSON.stringify(state));
556
- }
557
- const operations = [
558
- { type: 'check', key: contactStorageKey, expectedValue: existingContactValue },
559
- { type: 'set', key: sessionStorageKey, value: sessionValue },
560
- ];
561
- if (contactStatus === 'NEW') {
562
- const newContact = createUnverifiedContactIdentityRecord(commit.contactIdentity, Date.now());
563
- operations.push({
564
- type: 'set',
565
- key: contactStorageKey,
566
- value: await this.encrypt(JSON.stringify(newContact)),
567
- });
568
- }
569
- if (commit.oneTimePreKeyId !== undefined) {
570
- operations.push({ type: 'check', key: ecStorageKey, expectedValue: ecPrekeyValue });
571
- operations.push({
572
- type: 'set',
573
- key: ecStorageKey,
574
- value: await this.encrypt(JSON.stringify(ecPrekeys.filter((key) => key.keyId !== commit.oneTimePreKeyId))),
575
- });
576
- }
577
- if (commit.kemOneTimePreKeyId !== undefined) {
578
- operations.push({ type: 'check', key: kemStorageKey, expectedValue: kemPrekeyValue });
579
- operations.push({
580
- type: 'set',
581
- key: kemStorageKey,
582
- value: await this.encrypt(JSON.stringify(kemPrekeys.filter((key) => key.keyId !== commit.kemOneTimePreKeyId))),
583
- });
584
- }
585
- if (commit.kyberPreKeyUse && updatedKyberStateValue) {
586
- operations.push({ type: 'check', key: kyberStorageKey, expectedValue: kyberStateValue });
587
- operations.push({ type: 'set', key: kyberStorageKey, value: updatedKyberStateValue });
588
- }
589
- if (commit.receivedContent)
590
- operations.push({
591
- type: 'set',
592
- key: `@signal:received-content:${commit.receivedContent.id}`,
593
- value: await this.encrypt(JSON.stringify(commit.receivedContent)),
594
- });
595
- await this.storageBackend.atomicWrite(operations);
596
- }
597
- async getReceivedContent(id) {
598
- this.ensureInitialized();
599
- const value = await this.storageBackend.getItem(`@signal:received-content:${id}`);
600
- return value ? parseReceivedContent(await this.decrypt(value), id) : null;
601
- }
602
- async deleteReceivedContent(id) {
603
- this.ensureInitialized();
604
- await this.storageBackend.removeItem(`@signal:received-content:${id}`);
605
- }
606
- async deleteExpiredReceivedContent(before) {
607
- this.ensureInitialized();
608
- const prefix = '@signal:received-content:';
609
- const keys = (await this.storageBackend.getAllKeys()).filter((key) => key.startsWith(prefix));
610
- const expired = [];
611
- for (const key of keys) {
612
- const value = await this.getReceivedContent(key.slice(prefix.length));
613
- if (value && value.receivedAt < before)
614
- expired.push(key);
615
- }
616
- if (expired.length)
617
- await this.storageBackend.atomicWrite(expired.map((key) => ({ type: 'remove', key })));
618
- return expired.length;
619
- }
620
- async deleteSessionRecord(address) {
621
- this.ensureInitialized();
622
- const addressKey = this.serializeAddress(address);
623
- const storageKey = `${STORAGE_KEYS.SESSION_PREFIX}${addressKey}`;
624
- await this.storageBackend.removeItem(storageKey);
625
- }
626
- async archiveCurrentSession(address, newSession) {
627
- this.ensureInitialized();
628
- // With SessionRecord, archiving is handled at the DeviceRecord level
629
- // This method updates or replaces the session state
630
- if (newSession) {
631
- const record = await this.getSessionRecord(address);
632
- if (record) {
633
- // Update existing session with new state
634
- record.currentSession = newSession;
635
- if (record.metadata) {
636
- record.metadata.lastSentAt = Date.now();
637
- }
638
- await this.storeSessionRecord(address, record);
639
- }
640
- }
641
- else {
642
- // If no new session, just delete the old one
643
- await this.deleteSessionRecord(address);
644
- }
645
- }
646
- async getSessionsForUser(userId) {
647
- this.ensureInitialized();
648
- // Get all keys with session prefix
649
- const allKeys = await this.storageBackend.getAllKeys();
650
- const sessionKeys = allKeys.filter((key) => key.startsWith(STORAGE_KEYS.SESSION_PREFIX));
651
- const sessions = [];
652
- for (const key of sessionKeys) {
653
- const storedJson = await this.storageBackend.getItem(key);
654
- if (storedJson) {
655
- const stored = JSON.parse(storedJson);
656
- if (stored.userId === userId) {
657
- const decrypted = await this.decrypt(stored.data);
658
- try {
659
- sessions.push(deserializeSessionRecord(decrypted));
660
- }
661
- catch {
662
- await this.storageBackend.removeItem(key);
663
- }
664
- }
665
- }
666
- }
667
- return sessions;
668
- }
669
- async hasSession(address) {
670
- this.ensureInitialized();
671
- const record = await this.getSessionRecord(address);
672
- return record !== null && record.currentSession !== null;
673
- }
674
- // ============================================================================
675
- // Utility
676
- // ============================================================================
677
- async getSessionCount() {
678
- this.ensureInitialized();
679
- // Get all session keys
680
- const allKeys = await this.storageBackend.getAllKeys();
681
- const sessionKeys = allKeys.filter((key) => key.startsWith(STORAGE_KEYS.SESSION_PREFIX));
682
- return sessionKeys.length;
683
- }
684
- async clearAllKeys() {
685
- this.ensureInitialized();
686
- // Get all keys
687
- const allKeys = await this.storageBackend.getAllKeys();
688
- // Filter for signal keys
689
- const signalKeys = allKeys.filter((key) => key.startsWith('@signal:'));
690
- // Remove all signal keys
691
- await this.storageBackend.removeMany(signalKeys);
692
- // Regenerate database key
693
- this.databaseKey = Crypto.getRandomBytes(32);
694
- await this.storageBackend.setItem(STORAGE_KEYS.DATABASE_KEY, this.uint8ArrayToBase64(this.databaseKey));
695
- }
696
- // ============================================================================
697
- // Metadata storage
698
- // ============================================================================
699
- async getMetadata(key) {
700
- return this.storageBackend.getItem(this.getMetadataStorageKey(key));
701
- }
702
- async setMetadata(key, value) {
703
- await this.storageBackend.setItem(this.getMetadataStorageKey(key), value);
704
- }
705
- async deleteMetadata(key) {
706
- await this.storageBackend.removeItem(this.getMetadataStorageKey(key));
707
- }
708
- async compareAndSetMetadata(key, expected, value) {
709
- const storageKey = this.getMetadataStorageKey(key);
710
- try {
711
- await this.storageBackend.atomicWrite([
712
- { type: 'check', key: storageKey, expectedValue: expected },
713
- value === null
714
- ? { type: 'remove', key: storageKey }
715
- : { type: 'set', key: storageKey, value },
716
- ]);
717
- return true;
718
- }
719
- catch (error) {
720
- // A failed batch commits nothing. Do not report capacity failure as contention.
721
- if (error &&
722
- typeof error === 'object' &&
723
- 'name' in error &&
724
- error.name === 'QuotaExceededError')
725
- throw error;
726
- if ((await this.storageBackend.getItem(storageKey)) !== expected)
727
- return false;
728
- throw error;
729
- }
730
- }
731
- // ============================================================================
732
- // Private Helper Methods
733
- // ============================================================================
734
- /**
735
- * Throw when the adapter is not initialized
736
- * @throws Error if not initialized
737
- */
738
- ensureInitialized() {
739
- if (!this.initialized || !this.databaseKey) {
740
- throw new Error('ReactNativeSignalProtocolStore was used before initialization completed. Create it with ReactNativeSignalProtocolStore.create(...).');
741
- }
742
- }
743
- /**
744
- * Serialize ProtocolAddress to string key
745
- */
746
- serializeAddress(address) {
747
- return `${address.userId}.${address.deviceId}`;
748
- }
749
- getContactStorageKey(address, identityType) {
750
- return `${STORAGE_KEYS.CONTACT_V1_PREFIX}${address.userId}:${identityType ?? 'aci'}`;
751
- }
752
- async readContactRecord(address, identityType) {
753
- const encrypted = await this.storageBackend.getItem(this.getContactStorageKey(address, identityType));
754
- if (!encrypted) {
755
- // A miss here can still leave an obsolete single-publicKey row under the
756
- // unsuffixed key, which no read path can interpret. Delete it.
757
- await this.storageBackend.removeItem(`${STORAGE_KEYS.CONTACT_PREFIX}${address.userId}`);
758
- return null;
759
- }
760
- const record = JSON.parse(await this.decrypt(encrypted));
761
- validateContactIdentityRecord(record);
762
- return record;
763
- }
764
- async writeContactRecord(storageKey, record) {
765
- validateContactIdentityRecord(record);
766
- await this.storageBackend.setItem(storageKey, await this.encrypt(JSON.stringify(record)));
767
- }
768
- /**
769
- * Encrypt data using AES-256-GCM
770
- *
771
- * Uses Signal Protocol crypto module with Web Crypto API.
772
- *
773
- * @param plaintext - Data to encrypt
774
- * @returns Base64-encoded: IV (12 bytes) + ciphertext + auth tag (16 bytes)
775
- */
776
- async encrypt(plaintext) {
777
- if (!this.databaseKey) {
778
- throw new Error('Database key not available');
779
- }
780
- // Generate random IV (12 bytes for GCM)
781
- const iv = Crypto.getRandomBytes(12);
782
- // Encode plaintext
783
- const data = new TextEncoder().encode(plaintext);
784
- // Encrypt using proper AES-256-GCM via Signal Protocol crypto module
785
- const encrypted = await this.aesGcmEncrypt(data, this.databaseKey, iv);
786
- // Combine IV + ciphertext and encode as base64
787
- const combined = new Uint8Array(12 + encrypted.length);
788
- combined.set(iv, 0);
789
- combined.set(encrypted, 12);
790
- return this.uint8ArrayToBase64(combined);
791
- }
792
- /**
793
- * Decrypt data using AES-256-GCM
794
- *
795
- * @param encrypted - Base64-encoded: IV (12 bytes) + ciphertext + auth tag (16 bytes)
796
- * @returns Decrypted plaintext
797
- */
798
- async decrypt(encrypted) {
799
- if (!this.databaseKey) {
800
- throw new Error('Database key not available');
801
- }
802
- // Decode from base64
803
- const combined = this.base64ToUint8Array(encrypted);
804
- // Extract IV and ciphertext
805
- const iv = combined.slice(0, 12);
806
- const ciphertext = combined.slice(12);
807
- // Decrypt
808
- const plaintext = await this.aesGcmDecrypt(ciphertext, this.databaseKey, iv);
809
- // Decode plaintext
810
- return new TextDecoder().decode(plaintext);
811
- }
812
- /**
813
- * AES-256-GCM encryption using Web Crypto API
814
- *
815
- * Uses the Signal Protocol crypto module which provides proper AES-256-GCM.
816
- * Requires a Web Crypto API polyfill in bare React Native (e.g., react-native-quick-crypto).
817
- *
818
- * @param data - Plaintext to encrypt
819
- * @param key - 32-byte AES-256 key
820
- * @param iv - 12-byte initialization vector (already generated in encrypt())
821
- * @returns Ciphertext with appended 16-byte auth tag
822
- */
823
- async aesGcmEncrypt(data, key, iv) {
824
- // Use the Signal Protocol crypto module's AES-GCM implementation
825
- const result = await SignalProtocolCrypto.aesGcmEncryptWithIV(key, data, iv);
826
- // Combine ciphertext + authTag into single buffer
827
- const ciphertextBytes = SignalProtocolCrypto.base64ToBytes(result.ciphertext);
828
- const authTagBytes = SignalProtocolCrypto.base64ToBytes(result.authTag);
829
- const combined = new Uint8Array(ciphertextBytes.length + authTagBytes.length);
830
- combined.set(ciphertextBytes, 0);
831
- combined.set(authTagBytes, ciphertextBytes.length);
832
- return combined;
833
- }
834
- /**
835
- * AES-256-GCM decryption using Web Crypto API
836
- *
837
- * Uses the Signal Protocol crypto module which provides proper AES-256-GCM.
838
- * Requires a Web Crypto API polyfill in bare React Native (e.g., react-native-quick-crypto).
839
- *
840
- * @param ciphertext - Encrypted data with appended 16-byte auth tag
841
- * @param key - 32-byte AES-256 key
842
- * @param iv - 12-byte initialization vector
843
- * @returns Decrypted plaintext
844
- */
845
- async aesGcmDecrypt(ciphertext, key, iv) {
846
- // Validate minimum ciphertext length (must be at least 16 bytes for auth tag)
847
- const AES_GCM_TAG_BYTES = 16;
848
- if (ciphertext.length < AES_GCM_TAG_BYTES) {
849
- throw new Error(`Ciphertext too short: ${ciphertext.length} bytes (minimum ${AES_GCM_TAG_BYTES} for auth tag)`);
850
- }
851
- // Split ciphertext and auth tag (last 16 bytes)
852
- const ciphertextOnly = ciphertext.slice(0, -AES_GCM_TAG_BYTES);
853
- const authTag = ciphertext.slice(-AES_GCM_TAG_BYTES);
854
- // Use the Signal Protocol crypto module's AES-GCM implementation
855
- return await SignalProtocolCrypto.aesGcmDecrypt(key, SignalProtocolCrypto.bytesToBase64(ciphertextOnly), SignalProtocolCrypto.bytesToBase64(iv), SignalProtocolCrypto.bytesToBase64(authTag));
856
- }
857
- /**
858
- * Log security event
859
- */
860
- async logSecurityEvent(event) {
861
- const eventsJson = await this.storageBackend.getItem(STORAGE_KEYS.SECURITY_EVENTS);
862
- const events = eventsJson ? JSON.parse(eventsJson) : [];
863
- events.push(event);
864
- // Keep only last 100 events
865
- const trimmed = events.slice(-100);
866
- await this.storageBackend.setItem(STORAGE_KEYS.SECURITY_EVENTS, JSON.stringify(trimmed));
867
- }
868
- /**
869
- * Convert Uint8Array to base64
870
- */
871
- uint8ArrayToBase64(bytes) {
872
- let binary = '';
873
- for (let i = 0; i < bytes.length; i++) {
874
- binary += String.fromCharCode(bytes[i]);
875
- }
876
- return Buffer.from(binary, 'binary').toString('base64');
877
- }
878
- /**
879
- * Convert base64 to Uint8Array
880
- */
881
- base64ToUint8Array(base64) {
882
- const binary = Buffer.from(base64, 'base64').toString('binary');
883
- const bytes = new Uint8Array(binary.length);
884
- for (let i = 0; i < binary.length; i++) {
885
- bytes[i] = binary.charCodeAt(i);
886
- }
887
- return bytes;
888
- }
889
- serializeUserRecord(record) {
890
- return { ...record, devices: Array.from(record.devices.entries()) };
891
- }
892
- deserializeUserRecord(data) {
893
- return { ...data, devices: new Map(data.devices) };
894
- }
895
- getIdentityKeyStorageKey(identityType) {
896
- return `${STORAGE_KEYS.IDENTITY_KEY_PREFIX}${identityType ?? 'aci'}`;
897
- }
898
- getRegistrationIdStorageKey(identityType) {
899
- return `${STORAGE_KEYS.REGISTRATION_ID_PREFIX}${identityType ?? 'aci'}`;
900
- }
901
- getMetadataStorageKey(key) {
902
- return `${STORAGE_KEYS.METADATA_PREFIX}${key}`;
903
- }
904
- getSignedPreKeyStorageKey(identityType) {
905
- return `${STORAGE_KEYS.PREKEY_PREFIX}signed-all:${identityType ?? 'aci'}`;
906
- }
907
- getEcOneTimePreKeyStorageKey(identityType) {
908
- return `${STORAGE_KEYS.PREKEY_PREFIX}one-time:${identityType ?? 'aci'}`;
909
- }
910
- getKyberPreKeyStorageKey(identityType) {
911
- return `${STORAGE_KEYS.PREKEY_PREFIX}kyber:${identityType ?? 'aci'}`;
912
- }
913
- getKemOneTimePreKeyStorageKey(identityType) {
914
- return `${STORAGE_KEYS.PREKEY_PREFIX}kem-one-time:${identityType ?? 'aci'}`;
915
- }
916
- getSesameUserStorageKey(userId) {
917
- return `${STORAGE_KEYS.SESAME_USER_PREFIX}${userId}`;
918
- }
919
- getSenderKeyRecordStorageKey(groupId, userId, deviceId) {
920
- return `${this.getSenderKeyRecordGroupPrefix(groupId)}${escapeKeyComponent(userId)}:${deviceId}`;
921
- }
922
- /** Prefix matching every sender key record stored for one group. */
923
- getSenderKeyRecordGroupPrefix(groupId) {
924
- return `${STORAGE_KEYS.SENDER_KEY_RECORD_PREFIX}${escapeKeyComponent(groupId)}:`;
925
- }
926
- /**
927
- * Prefix matching every skipped key of one sender in one group.
928
- *
929
- * Trailing `:` included: the chain index follows it, and without it the
930
- * prefix for device 1 would also match device 10's keys.
931
- */
932
- getSkippedSenderKeyPrefix(groupId, senderId, senderDeviceId) {
933
- return `${STORAGE_KEYS.SKIPPED_SENDER_KEY_PREFIX}${escapeKeyComponent(groupId)}:${escapeKeyComponent(senderId)}:${senderDeviceId}:`;
934
- }
935
- getSkippedSenderKeyStorageKey(groupId, senderId, senderDeviceId, chainIndex) {
936
- return `${this.getSkippedSenderKeyPrefix(groupId, senderId, senderDeviceId)}${chainIndex}`;
937
- }
938
- getMessageRecordStorageKey(sessionId, timestamp) {
939
- return `${this.getMessageRecordSessionPrefix(sessionId)}${timestamp}`;
940
- }
941
- /** Prefix matching every retry record stored for one session. */
942
- getMessageRecordSessionPrefix(sessionId) {
943
- return `${STORAGE_KEYS.MESSAGE_RECORD_PREFIX}${escapeKeyComponent(sessionId)}:`;
944
- }
945
- // ============================================================================
946
- // SESAME Multi-Device Session Management
947
- // ============================================================================
948
- async getUserRecord(userId) {
949
- this.ensureInitialized();
950
- const encrypted = await this.storageBackend.getItem(this.getSesameUserStorageKey(userId));
951
- if (!encrypted) {
952
- return null;
953
- }
954
- const decrypted = await this.decrypt(encrypted);
955
- return this.deserializeUserRecord(JSON.parse(decrypted));
956
- }
957
- async setUserRecord(userId, record) {
958
- this.ensureInitialized();
959
- const encrypted = await this.encrypt(JSON.stringify(this.serializeUserRecord(record)));
960
- await this.storageBackend.setItem(this.getSesameUserStorageKey(userId), encrypted);
961
- }
962
- async getDeviceRecord(userId, deviceId) {
963
- const userRecord = await this.getUserRecord(userId);
964
- return userRecord?.devices.get(deviceId) ?? null;
965
- }
966
- async setDeviceRecord(userId, deviceId, record) {
967
- let userRecord = await this.getUserRecord(userId);
968
- if (!userRecord) {
969
- userRecord = { userId, devices: new Map(), createdAt: Date.now(), updatedAt: Date.now() };
970
- }
971
- userRecord.devices.set(deviceId, record);
972
- userRecord.updatedAt = Date.now();
973
- await this.setUserRecord(userId, userRecord);
974
- }
975
- async deleteDeviceRecord(userId, deviceId) {
976
- const userRecord = await this.getUserRecord(userId);
977
- if (!userRecord) {
978
- return;
979
- }
980
- userRecord.devices.delete(deviceId);
981
- userRecord.updatedAt = Date.now();
982
- if (userRecord.devices.size === 0) {
983
- await this.storageBackend.removeItem(this.getSesameUserStorageKey(userId));
984
- return;
985
- }
986
- await this.setUserRecord(userId, userRecord);
987
- }
988
- async deleteStaleRecords(maxLatency) {
989
- const now = Date.now();
990
- let deletedCount = 0;
991
- for (const userId of await this.getAllUserIds()) {
992
- const userRecord = await this.getUserRecord(userId);
993
- if (!userRecord)
994
- continue;
995
- const devicesToDelete = [];
996
- for (const [deviceId, deviceRecord] of userRecord.devices) {
997
- const hasNoSessions = !deviceRecord.session ||
998
- (!deviceRecord.session.currentSession &&
999
- Object.keys(deviceRecord.session.archivedSessions).length === 0);
1000
- const isStale = now - deviceRecord.updatedAt > maxLatency;
1001
- if (hasNoSessions && isStale) {
1002
- devicesToDelete.push(deviceId);
1003
- }
1004
- }
1005
- for (const deviceId of devicesToDelete) {
1006
- await this.deleteDeviceRecord(userId, deviceId);
1007
- deletedCount++;
1008
- }
1009
- }
1010
- return deletedCount;
46
+ export class ReactNativeSignalProtocolStore extends SqliteSignalProtocolStore {
47
+ constructor(database, logger) {
48
+ super(database, { logger });
49
+ databases.set(this, database);
1011
50
  }
1012
- async cleanupExpiredSessions(maxRecv) {
1013
- const now = Date.now();
1014
- let deletedCount = 0;
1015
- for (const userId of await this.getAllUserIds()) {
1016
- const userRecord = await this.getUserRecord(userId);
1017
- if (!userRecord)
1018
- continue;
1019
- for (const [deviceId, deviceRecord] of userRecord.devices) {
1020
- if (!deviceRecord.session)
1021
- continue;
1022
- let modified = false;
1023
- if (deviceRecord.session.currentSession) {
1024
- const createdAt = deviceRecord.session.metadata?.createdAt ??
1025
- deviceRecord.session.currentSession.createdAt;
1026
- if (now - createdAt > maxRecv) {
1027
- deviceRecord.session.currentSession = null;
1028
- modified = true;
1029
- deletedCount++;
1030
- }
1031
- }
1032
- const originalCount = Object.keys(deviceRecord.session.archivedSessions).length;
1033
- const archivedKeys = Object.keys(deviceRecord.session.archivedSessions);
1034
- for (const baseKey of archivedKeys) {
1035
- const session = deviceRecord.session.archivedSessions[baseKey];
1036
- if (session && now - session.createdAt > maxRecv) {
1037
- delete deviceRecord.session.archivedSessions[baseKey];
1038
- }
1039
- }
1040
- const removed = originalCount - Object.keys(deviceRecord.session.archivedSessions).length;
1041
- if (removed > 0) {
1042
- deletedCount += removed;
1043
- modified = true;
1044
- }
1045
- if (modified) {
1046
- deviceRecord.updatedAt = Date.now();
1047
- await this.setDeviceRecord(userId, deviceId, deviceRecord);
1048
- }
1049
- }
1050
- }
1051
- return deletedCount;
51
+ /** @internal Use {@link reactNativeStore}. */
52
+ static async open(options) {
53
+ const database = await openSqliteStore(storeOptions(options));
54
+ return new ReactNativeSignalProtocolStore(database, options.logger);
1052
55
  }
1053
- async getAllUserIds() {
1054
- this.ensureInitialized();
1055
- const allKeys = await this.storageBackend.getAllKeys();
1056
- return allKeys
1057
- .filter((key) => key.startsWith(STORAGE_KEYS.SESAME_USER_PREFIX))
1058
- .map((key) => key.slice(STORAGE_KEYS.SESAME_USER_PREFIX.length));
1059
- }
1060
- async getSesameDeviceIds(userId) {
1061
- const userRecord = await this.getUserRecord(userId);
1062
- return userRecord ? Array.from(userRecord.devices.keys()) : [];
1063
- }
1064
- async getDeviceSession(userId, deviceId) {
1065
- const deviceRecord = await this.getDeviceRecord(userId, deviceId);
1066
- return deviceRecord?.session ?? null;
1067
- }
1068
- async setDeviceSession(userId, deviceId, session) {
1069
- const deviceRecord = await this.getDeviceRecord(userId, deviceId);
1070
- if (deviceRecord) {
1071
- deviceRecord.session = session;
1072
- await this.setDeviceRecord(userId, deviceId, deviceRecord);
1073
- }
1074
- }
1075
- // ============================================================================
1076
- // Sender Keys Management (Group Messaging)
1077
- // ============================================================================
1078
- async storeSenderKey(groupId, userId, deviceId, state) {
1079
- await this.storeSenderKeyRecord(groupId, userId, deviceId, [state]);
1080
- }
1081
- async getSenderKey(groupId, userId, deviceId) {
1082
- const record = await this.getSenderKeyRecord(groupId, userId, deviceId);
1083
- return record?.[0] ?? null;
1084
- }
1085
- async deleteSenderKey(groupId, userId, deviceId) {
1086
- this.ensureInitialized();
1087
- await this.removeSenderKeyIdPointers(groupId, userId, deviceId);
1088
- await this.storageBackend.removeItem(this.getSenderKeyRecordStorageKey(groupId, userId, deviceId));
56
+ /** @internal Use {@link resetReactNativeStore}. */
57
+ static async reset(options) {
58
+ const database = await resetSqliteStore(storeOptions(options));
59
+ return new ReactNativeSignalProtocolStore(database, options.logger);
1089
60
  }
1090
61
  /**
1091
- * Build the storage key for a `senderKeyId` pointer.
1092
- *
1093
- * Scoped by sender, so one sender's id can never displace another's. That
1094
- * scoping is only worth anything if the join is injective, and a
1095
- * `senderKeyId` is the component least entitled to trust. It is whatever
1096
- * bytes the sender put in the frame's distribution field, validated
1097
- * nowhere, so it is escaped rather than reasoned about. With every
1098
- * component escaped, no choice of id can synthesize another sender's
1099
- * `:<deviceId>:<userId>` tail.
62
+ * Wait for the queued work, then close the database. Every later call
63
+ * rejects with `SqliteStoreClosedError`.
1100
64
  */
1101
- getSenderKeyIdPointerKey(senderKeyId, userId, deviceId) {
1102
- return `${STORAGE_KEYS.SENDER_KEY_ID_INDEX_PREFIX}${escapeKeyComponent(senderKeyId)}:${deviceId}:${escapeKeyComponent(userId)}`;
1103
- }
1104
- /**
1105
- * Drop the `senderKeyId` pointers a record owns, before the record goes.
1106
- *
1107
- * Ordered that way deliberately. A pointer that outlives its record is
1108
- * self-healing, because `resolveGroupForSenderKeyId` confirms and deletes
1109
- * it. A record that outlives its pointers is simply unreachable by id.
1110
- */
1111
- async removeSenderKeyIdPointers(groupId, userId, deviceId) {
1112
- const record = await this.getSenderKeyRecord(groupId, userId, deviceId);
1113
- if (!record)
1114
- return;
1115
- await this.storageBackend.removeMany(record
1116
- .map((state) => state.senderKeyId)
1117
- .filter(Boolean)
1118
- .map((senderKeyId) => this.getSenderKeyIdPointerKey(senderKeyId, userId, deviceId)));
1119
- }
1120
- async resolveGroupForSenderKeyId(senderKeyId, userId, deviceId) {
1121
- this.ensureInitialized();
1122
- if (!senderKeyId)
1123
- return null;
1124
- const recordKey = await this.storageBackend.getItem(this.getSenderKeyIdPointerKey(senderKeyId, userId, deviceId));
1125
- if (!recordKey)
1126
- return null;
1127
- // The pointer is a cache over the records, so it is confirmed against the
1128
- // record rather than trusted. The sender check is an invariant assertion
1129
- // now that the pointer key is itself sender-scoped. A mismatch would mean
1130
- // the two disagree, so resolve to nothing rather than reaching into
1131
- // another sender's record. It is deliberately not deleted. The key
1132
- // belongs to this sender, and a wrong value is a bug to notice, not a
1133
- // stale entry to sweep.
1134
- const parsed = this.parseSenderKeyRecordStorageKey(recordKey);
1135
- if (!parsed || parsed.userId !== userId || parsed.deviceId !== deviceId) {
1136
- return null;
1137
- }
1138
- const record = await this.getSenderKeyRecord(parsed.groupId, userId, deviceId);
1139
- if (!record?.some((state) => state.senderKeyId === senderKeyId)) {
1140
- await this.storageBackend.removeItem(this.getSenderKeyIdPointerKey(senderKeyId, userId, deviceId));
1141
- return null;
1142
- }
1143
- return parsed.groupId;
1144
- }
1145
- /**
1146
- * Split a record storage key back into its parts.
1147
- *
1148
- * The components were escaped on the way in, so the body holds exactly three
1149
- * `:`-separated fields and the split is unambiguous. Anything else is a key
1150
- * this adapter did not write.
1151
- */
1152
- parseSenderKeyRecordStorageKey(recordKey) {
1153
- if (!recordKey.startsWith(STORAGE_KEYS.SENDER_KEY_RECORD_PREFIX))
1154
- return null;
1155
- const body = recordKey.slice(STORAGE_KEYS.SENDER_KEY_RECORD_PREFIX.length);
1156
- const parts = body.split(':');
1157
- if (parts.length !== 3)
1158
- return null;
1159
- const [groupId, userId, device] = parts;
1160
- if (!groupId || !userId || !device)
1161
- return null;
1162
- const deviceId = Number(device);
1163
- if (!Number.isInteger(deviceId))
1164
- return null;
1165
- return {
1166
- groupId: unescapeKeyComponent(groupId),
1167
- userId: unescapeKeyComponent(userId),
1168
- deviceId,
1169
- };
1170
- }
1171
- async getAllSenderKeysForGroup(groupId) {
1172
- this.ensureInitialized();
1173
- const allKeys = await this.storageBackend.getAllKeys();
1174
- const senderKeys = allKeys.filter((key) => key.startsWith(this.getSenderKeyRecordGroupPrefix(groupId)));
1175
- const states = [];
1176
- for (const key of senderKeys) {
1177
- const encrypted = await this.storageBackend.getItem(key);
1178
- if (!encrypted)
1179
- continue;
1180
- const decrypted = await this.decrypt(encrypted);
1181
- const record = JSON.parse(decrypted);
1182
- if (record[0]) {
1183
- states.push(record[0]);
1184
- }
1185
- }
1186
- return states;
1187
- }
1188
- async deleteAllSenderKeysForGroup(groupId) {
1189
- this.ensureInitialized();
1190
- const allKeys = await this.storageBackend.getAllKeys();
1191
- const senderKeys = allKeys.filter((key) => key.startsWith(this.getSenderKeyRecordGroupPrefix(groupId)));
1192
- for (const recordKey of senderKeys) {
1193
- const parsed = this.parseSenderKeyRecordStorageKey(recordKey);
1194
- if (parsed) {
1195
- await this.removeSenderKeyIdPointers(parsed.groupId, parsed.userId, parsed.deviceId);
1196
- }
1197
- }
1198
- await this.storageBackend.removeMany(senderKeys);
1199
- return senderKeys.length;
1200
- }
1201
- async storeSenderKeyRecord(groupId, userId, deviceId, states, receive) {
1202
- this.ensureInitialized();
1203
- if (states.length === 0) {
1204
- return;
1205
- }
1206
- const recordKey = this.getSenderKeyRecordStorageKey(groupId, userId, deviceId);
1207
- // Rotation drops the oldest state out of the record. Its pointer has to go
1208
- // with it. Otherwise a replayed message naming a discarded key still
1209
- // resolves to a group, and fails one layer deeper than it should.
1210
- const superseded = await this.getSenderKeyRecord(groupId, userId, deviceId);
1211
- const retained = new Set(states.map((state) => state.senderKeyId));
1212
- const operations = [];
1213
- if (superseded) {
1214
- operations.push(...superseded
1215
- .map((state) => state.senderKeyId)
1216
- .filter((senderKeyId) => senderKeyId && !retained.has(senderKeyId))
1217
- .map((senderKeyId) => ({
1218
- type: 'remove',
1219
- key: this.getSenderKeyIdPointerKey(senderKeyId, userId, deviceId),
1220
- })));
1221
- }
1222
- operations.push({
1223
- type: 'set',
1224
- key: recordKey,
1225
- value: await this.encrypt(JSON.stringify(states)),
1226
- });
1227
- for (const senderKeyId of retained) {
1228
- if (!senderKeyId)
1229
- continue;
1230
- operations.push({
1231
- type: 'set',
1232
- key: this.getSenderKeyIdPointerKey(senderKeyId, userId, deviceId),
1233
- value: recordKey,
1234
- });
1235
- }
1236
- if (receive) {
1237
- operations.push({
1238
- type: 'set',
1239
- key: `@signal:received-content:${receive.content.id}`,
1240
- value: await this.encrypt(JSON.stringify(receive.content)),
1241
- });
1242
- if (receive.consumedChainIndex !== undefined)
1243
- operations.push({
1244
- type: 'remove',
1245
- key: this.getSkippedSenderKeyStorageKey(groupId, userId, deviceId, receive.consumedChainIndex),
1246
- });
1247
- }
1248
- await this.storageBackend.atomicWrite(operations);
1249
- }
1250
- async getSenderKeyRecord(groupId, userId, deviceId) {
1251
- this.ensureInitialized();
1252
- const encrypted = await this.storageBackend.getItem(this.getSenderKeyRecordStorageKey(groupId, userId, deviceId));
1253
- if (!encrypted) {
1254
- return null;
1255
- }
1256
- const decrypted = await this.decrypt(encrypted);
1257
- return JSON.parse(decrypted);
1258
- }
1259
- // ============================================================================
1260
- // Skipped Sender Keys
1261
- // ============================================================================
1262
- async storeSkippedSenderKey(groupId, senderId, senderDeviceId, chainIndex, messageKey) {
1263
- this.ensureInitialized();
1264
- await this.storageBackend.setItem(this.getSkippedSenderKeyStorageKey(groupId, senderId, senderDeviceId, chainIndex), await this.encrypt(JSON.stringify(messageKey)));
1265
- }
1266
- async getSkippedSenderKey(groupId, senderId, senderDeviceId, chainIndex) {
1267
- this.ensureInitialized();
1268
- const encrypted = await this.storageBackend.getItem(this.getSkippedSenderKeyStorageKey(groupId, senderId, senderDeviceId, chainIndex));
1269
- if (!encrypted) {
1270
- return null;
1271
- }
1272
- const decrypted = await this.decrypt(encrypted);
1273
- return JSON.parse(decrypted);
1274
- }
1275
- async deleteSkippedSenderKey(groupId, senderId, senderDeviceId, chainIndex) {
1276
- this.ensureInitialized();
1277
- await this.storageBackend.removeItem(this.getSkippedSenderKeyStorageKey(groupId, senderId, senderDeviceId, chainIndex));
1278
- }
1279
- async countSkippedSenderKeys(groupId, senderId, senderDeviceId) {
1280
- this.ensureInitialized();
1281
- const allKeys = await this.storageBackend.getAllKeys();
1282
- return allKeys.filter((key) => key.startsWith(this.getSkippedSenderKeyPrefix(groupId, senderId, senderDeviceId))).length;
1283
- }
1284
- async deleteOldestSkippedSenderKeys(groupId, senderId, senderDeviceId, count) {
1285
- this.ensureInitialized();
1286
- const allKeys = await this.storageBackend.getAllKeys();
1287
- const prefix = this.getSkippedSenderKeyPrefix(groupId, senderId, senderDeviceId);
1288
- const matches = allKeys
1289
- .filter((key) => key.startsWith(prefix))
1290
- .map((key) => ({ key, chainIndex: parseInt(key.split(':').pop() ?? '0', 10) }))
1291
- .sort((a, b) => a.chainIndex - b.chainIndex)
1292
- .slice(0, count);
1293
- await this.storageBackend.removeMany(matches.map(({ key }) => key));
1294
- return matches.length;
1295
- }
1296
- // ============================================================================
1297
- // Message Record Storage (Not Yet Implemented)
1298
- // Retry records are indexed by the client timestamp assigned before encryption.
1299
- // ============================================================================
1300
- async storeMessageRecord(record) {
1301
- this.ensureInitialized();
1302
- await this.storageBackend.setItem(this.getMessageRecordStorageKey(record.sessionId, record.timestamp), await this.encrypt(JSON.stringify(record)));
1303
- }
1304
- async getMessageRecord(sessionId, timestamp) {
1305
- this.ensureInitialized();
1306
- const encrypted = await this.storageBackend.getItem(this.getMessageRecordStorageKey(sessionId, timestamp));
1307
- if (!encrypted) {
1308
- return null;
1309
- }
1310
- const decrypted = await this.decrypt(encrypted);
1311
- return JSON.parse(decrypted);
1312
- }
1313
- async deleteMessageRecord(sessionId, timestamp) {
1314
- this.ensureInitialized();
1315
- await this.storageBackend.removeItem(this.getMessageRecordStorageKey(sessionId, timestamp));
1316
- }
1317
- async deleteExpiredMessageRecords(maxAgeMs) {
1318
- this.ensureInitialized();
1319
- const cutoff = Date.now() - maxAgeMs;
1320
- const allKeys = await this.storageBackend.getAllKeys();
1321
- const messageKeys = allKeys.filter((key) => key.startsWith(STORAGE_KEYS.MESSAGE_RECORD_PREFIX));
1322
- const toDelete = [];
1323
- for (const key of messageKeys) {
1324
- const encrypted = await this.storageBackend.getItem(key);
1325
- if (!encrypted)
1326
- continue;
1327
- const decrypted = await this.decrypt(encrypted);
1328
- const record = JSON.parse(decrypted);
1329
- if (record.createdAt < cutoff) {
1330
- toDelete.push(key);
1331
- }
1332
- }
1333
- if (toDelete.length > 0) {
1334
- await this.storageBackend.removeMany(toDelete);
1335
- }
1336
- return toDelete.length;
1337
- }
1338
- async clearAllMessageRecords() {
1339
- this.ensureInitialized();
1340
- const allKeys = await this.storageBackend.getAllKeys();
1341
- const messageKeys = allKeys.filter((key) => key.startsWith(STORAGE_KEYS.MESSAGE_RECORD_PREFIX));
1342
- if (messageKeys.length > 0) {
1343
- await this.storageBackend.removeMany(messageKeys);
1344
- }
1345
- return messageKeys.length;
1346
- }
1347
- async deleteMessageRecordsForSession(sessionId) {
1348
- this.ensureInitialized();
1349
- const allKeys = await this.storageBackend.getAllKeys();
1350
- const messageKeys = allKeys.filter((key) => key.startsWith(this.getMessageRecordSessionPrefix(sessionId)));
1351
- if (messageKeys.length > 0) {
1352
- await this.storageBackend.removeMany(messageKeys);
1353
- }
1354
- return messageKeys.length;
1355
- }
1356
- // ============================================================================
1357
- // Key Recovery Methods (Bug #7 - Identifier Collision Recovery)
1358
- // ============================================================================
1359
- async getEcSignedPreKeyMaxId(identityType) {
1360
- const prekeys = await this.getAllEcSignedPreKeys(identityType);
1361
- return prekeys.reduce((max, prekey) => Math.max(max, prekey.keyId), 0);
1362
- }
1363
- async getKyberPreKeyMaxId(identityType) {
1364
- const stored = await this.storageBackend.getItem(this.getKyberPreKeyStorageKey(identityType));
1365
- if (!stored)
1366
- return 0;
1367
- const state = JSON.parse(await this.decrypt(stored));
1368
- return Object.keys(state.instances).reduce((max, id) => Math.max(max, Number(id)), 0);
1369
- }
1370
- async deleteAllPreKeys(identityType) {
1371
- this.ensureInitialized();
1372
- const signedPreKeys = await this.getAllEcSignedPreKeys(identityType);
1373
- const ecOneTimePreKeys = await this.getEcOneTimePreKeys(identityType);
1374
- const kyberStateValue = await this.storageBackend.getItem(this.getKyberPreKeyStorageKey(identityType));
1375
- const kyberPreKeyCount = kyberStateValue
1376
- ? Object.keys(JSON.parse(await this.decrypt(kyberStateValue)).instances).length
1377
- : 0;
1378
- const kemOneTimePreKeys = await this.getKemOneTimePreKeys(identityType);
1379
- const it = identityType ?? 'aci';
1380
- await this.storageBackend.removeMany([
1381
- this.getSignedPreKeyStorageKey(identityType),
1382
- this.getEcOneTimePreKeyStorageKey(identityType),
1383
- this.getKyberPreKeyStorageKey(identityType),
1384
- this.getKemOneTimePreKeyStorageKey(identityType),
1385
- ]);
1386
- const allKeys = await this.storageBackend.getAllKeys();
1387
- const kyberUsageKeys = allKeys.filter((key) => key.startsWith(`${STORAGE_KEYS.PREKEY_PREFIX}kyber-usage:${it}:`));
1388
- if (kyberUsageKeys.length > 0) {
1389
- await this.storageBackend.removeMany(kyberUsageKeys);
1390
- }
1391
- return {
1392
- ecSignedPreKeys: signedPreKeys.length,
1393
- ecOneTimePreKeys: ecOneTimePreKeys.length,
1394
- kyberPreKeys: kyberPreKeyCount,
1395
- kemOneTimePreKeys: kemOneTimePreKeys.length,
1396
- };
1397
- }
1398
- async clearAllSessions() {
1399
- this.ensureInitialized();
1400
- const allKeys = await this.storageBackend.getAllKeys();
1401
- const sessionKeys = allKeys.filter((key) => key.startsWith(STORAGE_KEYS.SESSION_PREFIX) ||
1402
- key.startsWith(STORAGE_KEYS.SESAME_USER_PREFIX));
1403
- if (sessionKeys.length > 0) {
1404
- await this.storageBackend.removeMany(sessionKeys);
1405
- }
1406
- }
1407
- async getDetailedStats() {
1408
- this.ensureInitialized();
1409
- const allKeys = await this.storageBackend.getAllKeys();
1410
- return {
1411
- sessions: allKeys.filter((key) => key.startsWith(STORAGE_KEYS.SESSION_PREFIX)).length,
1412
- ecSignedPreKeys: (await this.getAllEcSignedPreKeys('aci')).length +
1413
- (await this.getAllEcSignedPreKeys('pni')).length,
1414
- ecOneTimePreKeys: (await this.getEcOneTimePreKeys('aci')).length +
1415
- (await this.getEcOneTimePreKeys('pni')).length,
1416
- kyberPreKeys: ((await this.getKyberPreKey('aci')) ? 1 : 0) + ((await this.getKyberPreKey('pni')) ? 1 : 0),
1417
- kemOneTimePreKeys: (await this.getKemOneTimePreKeys('aci')).length +
1418
- (await this.getKemOneTimePreKeys('pni')).length,
1419
- users: allKeys.filter((key) => key.startsWith(STORAGE_KEYS.SESAME_USER_PREFIX)).length,
1420
- };
65
+ close() {
66
+ return reactNativeStoreDatabase(this).close();
1421
67
  }
1422
68
  }
69
+ /**
70
+ * Open the store. On first use it creates the database key in the vault, then
71
+ * the database file. With `encryptionAtRest: false` it does not use the vault.
72
+ *
73
+ * @throws EncryptionError with `LOCAL_STORE_KEY_LOST` when the database file
74
+ * exists and the vault holds no key for it. Restore the vault entry, or call
75
+ * {@link resetReactNativeStore}.
76
+ * @throws EncryptionError with `KEY_STORAGE_ERROR` when the vault fails or
77
+ * holds a key of the wrong size, when the key does not open the file, when
78
+ * the file was created with the other `encryptionAtRest` setting, when
79
+ * op-sqlite is not built with SQLCipher, or when another connection holds
80
+ * the file.
81
+ * @throws EncryptionError with `INVALID_STATE` when the name is not valid,
82
+ * when a store of this process holds the name, or when a newer SDK wrote
83
+ * the file.
84
+ */
85
+ export function reactNativeStore(options = {}) {
86
+ return ReactNativeSignalProtocolStore.open(options);
87
+ }
88
+ /**
89
+ * Delete the database file, then create a new key, and return the open, empty
90
+ * store. This is the only way to open a store whose key is lost.
91
+ *
92
+ * @throws EncryptionError with `INVALID_STATE` when the name is not valid, or
93
+ * when a store of this process holds the name. Close that store first.
94
+ */
95
+ export function resetReactNativeStore(options = {}) {
96
+ return ReactNativeSignalProtocolStore.reset(options);
97
+ }
1423
98
  //# sourceMappingURL=adapter.js.map