@open-e2ee/signal-protocol-sdk 7.2.0 → 8.1.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 (721) hide show
  1. package/ADAPTERS.md +55 -8
  2. package/ARCHITECTURE.md +1 -0
  3. package/CHANGELOG.md +538 -0
  4. package/README.md +10 -6
  5. package/SECURITY.md +2 -2
  6. package/THIRD_PARTY_NOTICES.md +429 -0
  7. package/client/README.md +1 -2
  8. package/device/README.md +50 -19
  9. package/dist/client/client.d.ts +31 -5
  10. package/dist/client/client.d.ts.map +1 -1
  11. package/dist/client/client.js +151 -91
  12. package/dist/client/client.js.map +1 -1
  13. package/dist/client/event-hooks.d.ts.map +1 -1
  14. package/dist/client/event-hooks.js +2 -0
  15. package/dist/client/event-hooks.js.map +1 -1
  16. package/dist/client/files.d.ts.map +1 -1
  17. package/dist/client/files.js +19 -2
  18. package/dist/client/files.js.map +1 -1
  19. package/dist/client/headless.d.ts +1 -1
  20. package/dist/client/headless.js +1 -1
  21. package/dist/client/hosted-anonymous-delivery.d.ts.map +1 -1
  22. package/dist/client/hosted-anonymous-delivery.js +2 -1
  23. package/dist/client/hosted-anonymous-delivery.js.map +1 -1
  24. package/dist/client/hosted-connection.d.ts +1 -1
  25. package/dist/client/hosted-connection.d.ts.map +1 -1
  26. package/dist/client/hosted-connection.js +8 -12
  27. package/dist/client/hosted-connection.js.map +1 -1
  28. package/dist/client/hosted-group-authority.d.ts.map +1 -1
  29. package/dist/client/hosted-group-authority.js +2 -1
  30. package/dist/client/hosted-group-authority.js.map +1 -1
  31. package/dist/client/hosted-groups.d.ts.map +1 -1
  32. package/dist/client/hosted-groups.js +2 -1
  33. package/dist/client/hosted-groups.js.map +1 -1
  34. package/dist/client/hosted-push.d.ts.map +1 -1
  35. package/dist/client/hosted-push.js +2 -1
  36. package/dist/client/hosted-push.js.map +1 -1
  37. package/dist/client/hosted-transport.d.ts +9 -0
  38. package/dist/client/hosted-transport.d.ts.map +1 -1
  39. package/dist/client/hosted-transport.js +59 -24
  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-work.d.ts +30 -0
  52. package/dist/client/relay-work.d.ts.map +1 -0
  53. package/dist/client/relay-work.js +189 -0
  54. package/dist/client/relay-work.js.map +1 -0
  55. package/dist/client/retry.d.ts.map +1 -1
  56. package/dist/client/retry.js +2 -0
  57. package/dist/client/retry.js.map +1 -1
  58. package/dist/client/sessions.d.ts.map +1 -1
  59. package/dist/client/sessions.js +3 -0
  60. package/dist/client/sessions.js.map +1 -1
  61. package/dist/client/signal-service-cipher.d.ts +19 -11
  62. package/dist/client/signal-service-cipher.d.ts.map +1 -1
  63. package/dist/client/signal-service-cipher.js +48 -46
  64. package/dist/client/signal-service-cipher.js.map +1 -1
  65. package/dist/client/state.d.ts +8 -0
  66. package/dist/client/state.d.ts.map +1 -1
  67. package/dist/client/state.js +11 -0
  68. package/dist/client/state.js.map +1 -1
  69. package/dist/device/connection.d.ts +1 -1
  70. package/dist/device/connection.d.ts.map +1 -1
  71. package/dist/device/connection.js +4 -11
  72. package/dist/device/connection.js.map +1 -1
  73. package/dist/device/device-id.d.ts +10 -4
  74. package/dist/device/device-id.d.ts.map +1 -1
  75. package/dist/device/device-id.js +15 -9
  76. package/dist/device/device-id.js.map +1 -1
  77. package/dist/device/device-name-crypto.d.ts.map +1 -1
  78. package/dist/device/device-name-crypto.js +2 -2
  79. package/dist/device/device-name-crypto.js.map +1 -1
  80. package/dist/device/expo/index.d.ts +25 -8
  81. package/dist/device/expo/index.d.ts.map +1 -1
  82. package/dist/device/expo/index.js +58 -8
  83. package/dist/device/expo/index.js.map +1 -1
  84. package/dist/device/index.d.ts +2 -2
  85. package/dist/device/index.d.ts.map +1 -1
  86. package/dist/device/index.js +3 -2
  87. package/dist/device/index.js.map +1 -1
  88. package/dist/device/lifecycle/index.d.ts +4 -2
  89. package/dist/device/lifecycle/index.d.ts.map +1 -1
  90. package/dist/device/lifecycle/index.js.map +1 -1
  91. package/dist/device/lifecycle/manager.d.ts +12 -14
  92. package/dist/device/lifecycle/manager.d.ts.map +1 -1
  93. package/dist/device/lifecycle/manager.js +52 -97
  94. package/dist/device/lifecycle/manager.js.map +1 -1
  95. package/dist/device/lifecycle/types.d.ts +26 -16
  96. package/dist/device/lifecycle/types.d.ts.map +1 -1
  97. package/dist/device/lifecycle/utils.d.ts +8 -4
  98. package/dist/device/lifecycle/utils.d.ts.map +1 -1
  99. package/dist/device/lifecycle/utils.js +12 -16
  100. package/dist/device/lifecycle/utils.js.map +1 -1
  101. package/dist/device/provisioning.d.ts.map +1 -1
  102. package/dist/device/provisioning.js +6 -8
  103. package/dist/device/provisioning.js.map +1 -1
  104. package/dist/device/react-native/index.d.ts +40 -0
  105. package/dist/device/react-native/index.d.ts.map +1 -0
  106. package/dist/device/react-native/index.js +74 -0
  107. package/dist/device/react-native/index.js.map +1 -0
  108. package/dist/device/transfer.d.ts +15 -7
  109. package/dist/device/transfer.d.ts.map +1 -1
  110. package/dist/device/transfer.js +30 -22
  111. package/dist/device/transfer.js.map +1 -1
  112. package/dist/device/types.d.ts +15 -7
  113. package/dist/device/types.d.ts.map +1 -1
  114. package/dist/device/types.js.map +1 -1
  115. package/dist/device/vault-text.d.ts +13 -0
  116. package/dist/device/vault-text.d.ts.map +1 -0
  117. package/dist/device/vault-text.js +17 -0
  118. package/dist/device/vault-text.js.map +1 -0
  119. package/dist/index.d.ts +9 -5
  120. package/dist/index.d.ts.map +1 -1
  121. package/dist/index.js +9 -5
  122. package/dist/index.js.map +1 -1
  123. package/dist/internal/crypto/index.d.ts +3 -3
  124. package/dist/internal/crypto/index.d.ts.map +1 -1
  125. package/dist/internal/crypto/index.js +3 -3
  126. package/dist/internal/crypto/index.js.map +1 -1
  127. package/dist/internal/crypto/random-host.d.ts +1 -1
  128. package/dist/internal/crypto/random-host.d.ts.map +1 -1
  129. package/dist/internal/crypto/random-host.js +3 -2
  130. package/dist/internal/crypto/random-host.js.map +1 -1
  131. package/dist/internal/crypto/random-host.native.d.ts +6 -1
  132. package/dist/internal/crypto/random-host.native.d.ts.map +1 -1
  133. package/dist/internal/crypto/random-host.native.js +14 -10
  134. package/dist/internal/crypto/random-host.native.js.map +1 -1
  135. package/dist/internal/crypto/random-host.node.d.ts +1 -1
  136. package/dist/internal/crypto/random-host.node.d.ts.map +1 -1
  137. package/dist/internal/crypto/random-host.node.js +1 -1
  138. package/dist/internal/crypto/random-host.node.js.map +1 -1
  139. package/dist/internal/crypto/random.d.ts +12 -3
  140. package/dist/internal/crypto/random.d.ts.map +1 -1
  141. package/dist/internal/crypto/random.js +14 -3
  142. package/dist/internal/crypto/random.js.map +1 -1
  143. package/dist/internal/crypto/utils.d.ts.map +1 -1
  144. package/dist/internal/crypto/utils.js +10 -6
  145. package/dist/internal/crypto/utils.js.map +1 -1
  146. package/dist/internal/encoding/proto/primitives.d.ts +2 -0
  147. package/dist/internal/encoding/proto/primitives.d.ts.map +1 -1
  148. package/dist/internal/encoding/proto/primitives.js +2 -1
  149. package/dist/internal/encoding/proto/primitives.js.map +1 -1
  150. package/dist/internal/encoding/proto/signal-message.d.ts +1 -0
  151. package/dist/internal/encoding/proto/signal-message.d.ts.map +1 -1
  152. package/dist/internal/encoding/proto/signal-message.js +2 -1
  153. package/dist/internal/encoding/proto/signal-message.js.map +1 -1
  154. package/dist/internal/groups/authority-certificate.d.ts.map +1 -1
  155. package/dist/internal/groups/authority-certificate.js +2 -1
  156. package/dist/internal/groups/authority-certificate.js.map +1 -1
  157. package/dist/internal/groups/encrypted-state.d.ts.map +1 -1
  158. package/dist/internal/groups/encrypted-state.js +9 -7
  159. package/dist/internal/groups/encrypted-state.js.map +1 -1
  160. package/dist/internal/groups/invite-link.d.ts.map +1 -1
  161. package/dist/internal/groups/invite-link.js +2 -1
  162. package/dist/internal/groups/invite-link.js.map +1 -1
  163. package/dist/internal/groups/manager.d.ts.map +1 -1
  164. package/dist/internal/groups/manager.js +5 -5
  165. package/dist/internal/groups/manager.js.map +1 -1
  166. package/dist/internal/groups/sdk-store.d.ts.map +1 -1
  167. package/dist/internal/groups/sdk-store.js +4 -3
  168. package/dist/internal/groups/sdk-store.js.map +1 -1
  169. package/dist/internal/groups/server-engine.d.ts +6 -1
  170. package/dist/internal/groups/server-engine.d.ts.map +1 -1
  171. package/dist/internal/groups/server-engine.js +11 -15
  172. package/dist/internal/groups/server-engine.js.map +1 -1
  173. package/dist/internal/groups/wire.d.ts.map +1 -1
  174. package/dist/internal/groups/wire.js +2 -1
  175. package/dist/internal/groups/wire.js.map +1 -1
  176. package/dist/internal/platform/blob.d.ts +10 -0
  177. package/dist/internal/platform/blob.d.ts.map +1 -0
  178. package/dist/internal/platform/blob.js +30 -0
  179. package/dist/internal/platform/blob.js.map +1 -0
  180. package/dist/internal/platform/env.d.ts +13 -0
  181. package/dist/internal/platform/env.d.ts.map +1 -0
  182. package/dist/internal/platform/env.js +17 -0
  183. package/dist/internal/platform/env.js.map +1 -0
  184. package/dist/internal/platform/index.d.ts +5 -0
  185. package/dist/internal/platform/index.d.ts.map +1 -0
  186. package/dist/internal/platform/index.js +5 -0
  187. package/dist/internal/platform/index.js.map +1 -0
  188. package/dist/internal/platform/url.d.ts +72 -0
  189. package/dist/internal/platform/url.d.ts.map +1 -0
  190. package/dist/internal/platform/url.js +275 -0
  191. package/dist/internal/platform/url.js.map +1 -0
  192. package/dist/internal/platform/utf8.d.ts +28 -0
  193. package/dist/internal/platform/utf8.d.ts.map +1 -0
  194. package/dist/internal/platform/utf8.js +167 -0
  195. package/dist/internal/platform/utf8.js.map +1 -0
  196. package/dist/internal/protocol/sealed-sender/delivery-token.d.ts +1 -1
  197. package/dist/internal/protocol/sealed-sender/delivery-token.d.ts.map +1 -1
  198. package/dist/internal/protocol/sealed-sender/delivery-token.js +5 -10
  199. package/dist/internal/protocol/sealed-sender/delivery-token.js.map +1 -1
  200. package/dist/internal/protocol/sealed-sender/proto/index.d.ts.map +1 -1
  201. package/dist/internal/protocol/sealed-sender/proto/index.js +2 -4
  202. package/dist/internal/protocol/sealed-sender/proto/index.js.map +1 -1
  203. package/dist/internal/protocol/sender-keys/manager.d.ts.map +1 -1
  204. package/dist/internal/protocol/sender-keys/manager.js +4 -3
  205. package/dist/internal/protocol/sender-keys/manager.js.map +1 -1
  206. package/dist/internal/protocol/spqr/ml-kem-braid/noble-pq/index.d.ts +4 -4
  207. package/dist/internal/protocol/spqr/ml-kem-braid/noble-pq/index.d.ts.map +1 -1
  208. package/dist/internal/protocol/spqr/ml-kem-braid/noble-pq/index.js +8 -10
  209. package/dist/internal/protocol/spqr/ml-kem-braid/noble-pq/index.js.map +1 -1
  210. package/dist/internal/protocol/username/hash.d.ts.map +1 -1
  211. package/dist/internal/protocol/username/hash.js +18 -3
  212. package/dist/internal/protocol/username/hash.js.map +1 -1
  213. package/dist/internal/protocol/username/link.d.ts.map +1 -1
  214. package/dist/internal/protocol/username/link.js +2 -1
  215. package/dist/internal/protocol/username/link.js.map +1 -1
  216. package/dist/internal/protocol/username/proof.d.ts.map +1 -1
  217. package/dist/internal/protocol/username/proof.js +2 -1
  218. package/dist/internal/protocol/username/proof.js.map +1 -1
  219. package/dist/internal/protocol/zk/credentials/attributes.d.ts.map +1 -1
  220. package/dist/internal/protocol/zk/credentials/attributes.js +2 -1
  221. package/dist/internal/protocol/zk/credentials/attributes.js.map +1 -1
  222. package/dist/internal/protocol/zk/credentials/credentials.d.ts.map +1 -1
  223. package/dist/internal/protocol/zk/credentials/credentials.js +8 -6
  224. package/dist/internal/protocol/zk/credentials/credentials.js.map +1 -1
  225. package/dist/internal/protocol/zk/credentials/presentation.d.ts.map +1 -1
  226. package/dist/internal/protocol/zk/credentials/presentation.js +19 -13
  227. package/dist/internal/protocol/zk/credentials/presentation.js.map +1 -1
  228. package/dist/internal/protocol/zk/groups/lizard.d.ts +8 -0
  229. package/dist/internal/protocol/zk/groups/lizard.d.ts.map +1 -1
  230. package/dist/internal/protocol/zk/groups/lizard.js +18 -5
  231. package/dist/internal/protocol/zk/groups/lizard.js.map +1 -1
  232. package/dist/internal/protocol/zk/groups/profile-key-commitment.d.ts.map +1 -1
  233. package/dist/internal/protocol/zk/groups/profile-key-commitment.js +7 -6
  234. package/dist/internal/protocol/zk/groups/profile-key-commitment.js.map +1 -1
  235. package/dist/internal/protocol/zk/groups/profile-key-encryption.d.ts.map +1 -1
  236. package/dist/internal/protocol/zk/groups/profile-key-encryption.js +3 -2
  237. package/dist/internal/protocol/zk/groups/profile-key-encryption.js.map +1 -1
  238. package/dist/internal/protocol/zk/groups/uid-encryption.d.ts.map +1 -1
  239. package/dist/internal/protocol/zk/groups/uid-encryption.js +3 -2
  240. package/dist/internal/protocol/zk/groups/uid-encryption.js.map +1 -1
  241. package/dist/internal/protocol/zk/proofs/point-multiplication.d.ts +53 -0
  242. package/dist/internal/protocol/zk/proofs/point-multiplication.d.ts.map +1 -0
  243. package/dist/internal/protocol/zk/proofs/point-multiplication.js +164 -0
  244. package/dist/internal/protocol/zk/proofs/point-multiplication.js.map +1 -0
  245. package/dist/internal/protocol/zk/proofs/sho.d.ts +1 -0
  246. package/dist/internal/protocol/zk/proofs/sho.d.ts.map +1 -1
  247. package/dist/internal/protocol/zk/proofs/sho.js.map +1 -1
  248. package/dist/internal/protocol/zk/proofs/statement.d.ts.map +1 -1
  249. package/dist/internal/protocol/zk/proofs/statement.js +11 -11
  250. package/dist/internal/protocol/zk/proofs/statement.js.map +1 -1
  251. package/dist/internal/sesame/device-registry.d.ts +16 -3
  252. package/dist/internal/sesame/device-registry.d.ts.map +1 -1
  253. package/dist/internal/sesame/device-registry.js +10 -7
  254. package/dist/internal/sesame/device-registry.js.map +1 -1
  255. package/dist/internal/sesame/index.d.ts +1 -1
  256. package/dist/internal/sesame/index.d.ts.map +1 -1
  257. package/dist/internal/sesame/manager.d.ts.map +1 -1
  258. package/dist/internal/sesame/manager.js +3 -2
  259. package/dist/internal/sesame/manager.js.map +1 -1
  260. package/dist/internal/session/index.d.ts +1 -2
  261. package/dist/internal/session/index.d.ts.map +1 -1
  262. package/dist/internal/session/index.js +1 -1
  263. package/dist/internal/session/index.js.map +1 -1
  264. package/dist/internal/session/validation.d.ts +0 -80
  265. package/dist/internal/session/validation.d.ts.map +1 -1
  266. package/dist/internal/session/validation.js +0 -134
  267. package/dist/internal/session/validation.js.map +1 -1
  268. package/dist/local/store/device-record.d.ts +18 -0
  269. package/dist/local/store/device-record.d.ts.map +1 -0
  270. package/dist/local/store/device-record.js +34 -0
  271. package/dist/local/store/device-record.js.map +1 -0
  272. package/dist/local/store/expo/adapter.d.ts +59 -238
  273. package/dist/local/store/expo/adapter.d.ts.map +1 -1
  274. package/dist/local/store/expo/adapter.js +83 -640
  275. package/dist/local/store/expo/adapter.js.map +1 -1
  276. package/dist/local/store/expo/driver.d.ts +16 -0
  277. package/dist/local/store/expo/driver.d.ts.map +1 -0
  278. package/dist/local/store/expo/driver.js +141 -0
  279. package/dist/local/store/expo/driver.js.map +1 -0
  280. package/dist/local/store/expo/index.d.ts +3 -12
  281. package/dist/local/store/expo/index.d.ts.map +1 -1
  282. package/dist/local/store/expo/index.js +1 -8
  283. package/dist/local/store/expo/index.js.map +1 -1
  284. package/dist/local/store/expo/maintenance.d.ts +3 -2
  285. package/dist/local/store/expo/maintenance.d.ts.map +1 -1
  286. package/dist/local/store/expo/maintenance.js +5 -34
  287. package/dist/local/store/expo/maintenance.js.map +1 -1
  288. package/dist/local/store/index.d.ts +11 -6
  289. package/dist/local/store/index.d.ts.map +1 -1
  290. package/dist/local/store/index.js +11 -6
  291. package/dist/local/store/index.js.map +1 -1
  292. package/dist/local/store/key-value/adapter.d.ts +326 -0
  293. package/dist/local/store/key-value/adapter.d.ts.map +1 -0
  294. package/dist/local/store/key-value/adapter.js +1472 -0
  295. package/dist/local/store/key-value/adapter.js.map +1 -0
  296. package/dist/local/store/{react-native → key-value}/backend-conformance.d.ts +6 -6
  297. package/dist/local/store/key-value/backend-conformance.d.ts.map +1 -0
  298. package/dist/local/store/{react-native → key-value}/backend-conformance.js +3 -3
  299. package/dist/local/store/key-value/backend-conformance.js.map +1 -0
  300. package/dist/local/store/key-value/batch.d.ts +41 -0
  301. package/dist/local/store/key-value/batch.d.ts.map +1 -0
  302. package/dist/local/store/key-value/batch.js +77 -0
  303. package/dist/local/store/key-value/batch.js.map +1 -0
  304. package/dist/local/store/key-value/device-record.d.ts +23 -0
  305. package/dist/local/store/key-value/device-record.d.ts.map +1 -0
  306. package/dist/local/store/key-value/device-record.js +33 -0
  307. package/dist/local/store/key-value/device-record.js.map +1 -0
  308. package/dist/local/store/key-value/index.d.ts +24 -0
  309. package/dist/local/store/key-value/index.d.ts.map +1 -0
  310. package/dist/local/store/key-value/index.js +8 -0
  311. package/dist/local/store/key-value/index.js.map +1 -0
  312. package/dist/local/store/key-value/realm/index.d.ts +83 -0
  313. package/dist/local/store/key-value/realm/index.d.ts.map +1 -0
  314. package/dist/local/store/key-value/realm/index.js +102 -0
  315. package/dist/local/store/key-value/realm/index.js.map +1 -0
  316. package/dist/local/store/{react-native → key-value}/storage.d.ts +6 -6
  317. package/dist/local/store/key-value/storage.d.ts.map +1 -0
  318. package/dist/local/store/key-value/storage.js.map +1 -0
  319. package/dist/local/store/key-value/transactional-backend.d.ts +50 -0
  320. package/dist/local/store/key-value/transactional-backend.d.ts.map +1 -0
  321. package/dist/local/store/key-value/transactional-backend.js +90 -0
  322. package/dist/local/store/key-value/transactional-backend.js.map +1 -0
  323. package/dist/local/store/key-value/value-key.d.ts +34 -0
  324. package/dist/local/store/key-value/value-key.d.ts.map +1 -0
  325. package/dist/local/store/key-value/value-key.js +83 -0
  326. package/dist/local/store/key-value/value-key.js.map +1 -0
  327. package/dist/local/store/memory/adapter.d.ts +8 -0
  328. package/dist/local/store/memory/adapter.d.ts.map +1 -1
  329. package/dist/local/store/memory/adapter.js +60 -75
  330. package/dist/local/store/memory/adapter.js.map +1 -1
  331. package/dist/local/store/node/adapter.d.ts +74 -130
  332. package/dist/local/store/node/adapter.d.ts.map +1 -1
  333. package/dist/local/store/node/adapter.js +83 -727
  334. package/dist/local/store/node/adapter.js.map +1 -1
  335. package/dist/local/store/node/index.d.ts +8 -6
  336. package/dist/local/store/node/index.d.ts.map +1 -1
  337. package/dist/local/store/node/index.js +3 -7
  338. package/dist/local/store/node/index.js.map +1 -1
  339. package/dist/local/store/node/maintenance.d.ts +5 -0
  340. package/dist/local/store/node/maintenance.d.ts.map +1 -0
  341. package/dist/local/store/node/maintenance.js +7 -0
  342. package/dist/local/store/node/maintenance.js.map +1 -0
  343. package/dist/local/store/node/owner-lock.d.ts +26 -0
  344. package/dist/local/store/node/owner-lock.d.ts.map +1 -0
  345. package/dist/local/store/node/owner-lock.js +88 -0
  346. package/dist/local/store/node/owner-lock.js.map +1 -0
  347. package/dist/local/store/react-native/adapter.d.ts +63 -274
  348. package/dist/local/store/react-native/adapter.d.ts.map +1 -1
  349. package/dist/local/store/react-native/adapter.js +80 -1406
  350. package/dist/local/store/react-native/adapter.js.map +1 -1
  351. package/dist/local/store/react-native/index.d.ts +7 -19
  352. package/dist/local/store/react-native/index.d.ts.map +1 -1
  353. package/dist/local/store/react-native/index.js +2 -7
  354. package/dist/local/store/react-native/index.js.map +1 -1
  355. package/dist/local/store/react-native/maintenance.d.ts +5 -0
  356. package/dist/local/store/react-native/maintenance.d.ts.map +1 -0
  357. package/dist/local/store/react-native/maintenance.js +7 -0
  358. package/dist/local/store/react-native/maintenance.js.map +1 -0
  359. package/dist/local/store/sqlite/better-sqlite3-multiple-ciphers-driver.d.ts +38 -0
  360. package/dist/local/store/sqlite/better-sqlite3-multiple-ciphers-driver.d.ts.map +1 -0
  361. package/dist/local/store/sqlite/better-sqlite3-multiple-ciphers-driver.js +196 -0
  362. package/dist/local/store/sqlite/better-sqlite3-multiple-ciphers-driver.js.map +1 -0
  363. package/dist/local/store/sqlite/database.d.ts +20 -0
  364. package/dist/local/store/sqlite/database.d.ts.map +1 -0
  365. package/dist/local/store/sqlite/database.js +41 -0
  366. package/dist/local/store/sqlite/database.js.map +1 -0
  367. package/dist/local/store/sqlite/driver.d.ts +138 -0
  368. package/dist/local/store/sqlite/driver.d.ts.map +1 -0
  369. package/dist/local/store/sqlite/driver.js +10 -0
  370. package/dist/local/store/sqlite/driver.js.map +1 -0
  371. package/dist/local/store/sqlite/encryption.d.ts +61 -0
  372. package/dist/local/store/sqlite/encryption.d.ts.map +1 -0
  373. package/dist/local/store/sqlite/encryption.js +98 -0
  374. package/dist/local/store/sqlite/encryption.js.map +1 -0
  375. package/dist/local/store/sqlite/errors.d.ts +70 -0
  376. package/dist/local/store/sqlite/errors.d.ts.map +1 -0
  377. package/dist/local/store/sqlite/errors.js +101 -0
  378. package/dist/local/store/sqlite/errors.js.map +1 -0
  379. package/dist/local/store/sqlite/executor.d.ts +22 -0
  380. package/dist/local/store/sqlite/executor.d.ts.map +1 -0
  381. package/dist/local/store/sqlite/executor.js +129 -0
  382. package/dist/local/store/sqlite/executor.js.map +1 -0
  383. package/dist/local/store/sqlite/index.d.ts +20 -0
  384. package/dist/local/store/sqlite/index.d.ts.map +1 -0
  385. package/dist/local/store/sqlite/index.js +18 -0
  386. package/dist/local/store/sqlite/index.js.map +1 -0
  387. package/dist/local/store/sqlite/key-storage/account.d.ts +45 -0
  388. package/dist/local/store/sqlite/key-storage/account.d.ts.map +1 -0
  389. package/dist/local/store/sqlite/key-storage/account.js +125 -0
  390. package/dist/local/store/sqlite/key-storage/account.js.map +1 -0
  391. package/dist/local/store/sqlite/key-storage/contact-identities.d.ts +19 -0
  392. package/dist/local/store/sqlite/key-storage/contact-identities.d.ts.map +1 -0
  393. package/dist/local/store/sqlite/key-storage/contact-identities.js +85 -0
  394. package/dist/local/store/sqlite/key-storage/contact-identities.js.map +1 -0
  395. package/dist/local/store/sqlite/key-storage/context.d.ts +19 -0
  396. package/dist/local/store/sqlite/key-storage/context.d.ts.map +1 -0
  397. package/dist/local/store/sqlite/key-storage/context.js +18 -0
  398. package/dist/local/store/sqlite/key-storage/context.js.map +1 -0
  399. package/dist/local/store/sqlite/key-storage/identity-keys.d.ts +18 -0
  400. package/dist/local/store/sqlite/key-storage/identity-keys.d.ts.map +1 -0
  401. package/dist/local/store/sqlite/key-storage/identity-keys.js +88 -0
  402. package/dist/local/store/sqlite/key-storage/identity-keys.js.map +1 -0
  403. package/dist/local/store/sqlite/key-storage/index.d.ts +108 -0
  404. package/dist/local/store/sqlite/key-storage/index.d.ts.map +1 -0
  405. package/dist/local/store/sqlite/key-storage/index.js +241 -0
  406. package/dist/local/store/sqlite/key-storage/index.js.map +1 -0
  407. package/dist/local/store/sqlite/key-storage/message-records.d.ts +41 -0
  408. package/dist/local/store/sqlite/key-storage/message-records.d.ts.map +1 -0
  409. package/dist/local/store/sqlite/key-storage/message-records.js +133 -0
  410. package/dist/local/store/sqlite/key-storage/message-records.js.map +1 -0
  411. package/dist/local/store/sqlite/key-storage/metadata.d.ts +16 -0
  412. package/dist/local/store/sqlite/key-storage/metadata.d.ts.map +1 -0
  413. package/dist/local/store/sqlite/key-storage/metadata.js +53 -0
  414. package/dist/local/store/sqlite/key-storage/metadata.js.map +1 -0
  415. package/dist/local/store/sqlite/key-storage/one-time-prekeys.d.ts +36 -0
  416. package/dist/local/store/sqlite/key-storage/one-time-prekeys.d.ts.map +1 -0
  417. package/dist/local/store/sqlite/key-storage/one-time-prekeys.js +129 -0
  418. package/dist/local/store/sqlite/key-storage/one-time-prekeys.js.map +1 -0
  419. package/dist/local/store/sqlite/key-storage/session-trust.d.ts +10 -0
  420. package/dist/local/store/sqlite/key-storage/session-trust.d.ts.map +1 -0
  421. package/dist/local/store/sqlite/key-storage/session-trust.js +88 -0
  422. package/dist/local/store/sqlite/key-storage/session-trust.js.map +1 -0
  423. package/dist/local/store/sqlite/key-storage/sessions.d.ts +50 -0
  424. package/dist/local/store/sqlite/key-storage/sessions.d.ts.map +1 -0
  425. package/dist/local/store/sqlite/key-storage/sessions.js +209 -0
  426. package/dist/local/store/sqlite/key-storage/sessions.js.map +1 -0
  427. package/dist/local/store/sqlite/key-storage/signed-prekeys.d.ts +69 -0
  428. package/dist/local/store/sqlite/key-storage/signed-prekeys.d.ts.map +1 -0
  429. package/dist/local/store/sqlite/key-storage/signed-prekeys.js +219 -0
  430. package/dist/local/store/sqlite/key-storage/signed-prekeys.js.map +1 -0
  431. package/dist/local/store/sqlite/maintenance.d.ts +7 -0
  432. package/dist/local/store/sqlite/maintenance.d.ts.map +1 -0
  433. package/dist/local/store/sqlite/maintenance.js +32 -0
  434. package/dist/local/store/sqlite/maintenance.js.map +1 -0
  435. package/dist/local/store/sqlite/migrations.d.ts +31 -0
  436. package/dist/local/store/sqlite/migrations.d.ts.map +1 -0
  437. package/dist/local/store/sqlite/migrations.js +232 -0
  438. package/dist/local/store/sqlite/migrations.js.map +1 -0
  439. package/dist/local/store/{expo → sqlite}/models/ec-one-time-prekey.d.ts +17 -22
  440. package/dist/local/store/sqlite/models/ec-one-time-prekey.d.ts.map +1 -0
  441. package/dist/local/store/{expo → sqlite}/models/ec-one-time-prekey.js +61 -99
  442. package/dist/local/store/sqlite/models/ec-one-time-prekey.js.map +1 -0
  443. package/dist/local/store/{expo → sqlite}/models/ec-signed-prekey.d.ts +22 -25
  444. package/dist/local/store/sqlite/models/ec-signed-prekey.d.ts.map +1 -0
  445. package/dist/local/store/{expo → sqlite}/models/ec-signed-prekey.js +82 -128
  446. package/dist/local/store/sqlite/models/ec-signed-prekey.js.map +1 -0
  447. package/dist/local/store/sqlite/models/identity-key-id.d.ts.map +1 -0
  448. package/dist/local/store/sqlite/models/identity-key-id.js.map +1 -0
  449. package/dist/local/store/{expo → sqlite}/models/index.d.ts +5 -5
  450. package/dist/local/store/sqlite/models/index.d.ts.map +1 -0
  451. package/dist/local/store/{expo → sqlite}/models/index.js +12 -5
  452. package/dist/local/store/sqlite/models/index.js.map +1 -0
  453. package/dist/local/store/{expo → sqlite}/models/kyber-one-time-prekey.d.ts +17 -20
  454. package/dist/local/store/sqlite/models/kyber-one-time-prekey.d.ts.map +1 -0
  455. package/dist/local/store/{expo → sqlite}/models/kyber-one-time-prekey.js +65 -105
  456. package/dist/local/store/sqlite/models/kyber-one-time-prekey.js.map +1 -0
  457. package/dist/local/store/{expo → sqlite}/models/kyber-prekey-used.d.ts +3 -3
  458. package/dist/local/store/sqlite/models/kyber-prekey-used.d.ts.map +1 -0
  459. package/dist/local/store/{expo → sqlite}/models/kyber-prekey-used.js +13 -25
  460. package/dist/local/store/sqlite/models/kyber-prekey-used.js.map +1 -0
  461. package/dist/local/store/{expo → sqlite}/models/kyber-prekey.d.ts +16 -19
  462. package/dist/local/store/sqlite/models/kyber-prekey.d.ts.map +1 -0
  463. package/dist/local/store/{expo → sqlite}/models/kyber-prekey.js +67 -111
  464. package/dist/local/store/sqlite/models/kyber-prekey.js.map +1 -0
  465. package/dist/local/store/sqlite/models/local-identity.d.ts +51 -0
  466. package/dist/local/store/sqlite/models/local-identity.d.ts.map +1 -0
  467. package/dist/local/store/sqlite/models/local-identity.js +150 -0
  468. package/dist/local/store/sqlite/models/local-identity.js.map +1 -0
  469. package/dist/local/store/{expo → sqlite}/models/message-record.d.ts +15 -44
  470. package/dist/local/store/sqlite/models/message-record.d.ts.map +1 -0
  471. package/dist/local/store/{expo → sqlite}/models/message-record.js +43 -109
  472. package/dist/local/store/sqlite/models/message-record.js.map +1 -0
  473. package/dist/local/store/sqlite/models/recipient-identity.d.ts +21 -0
  474. package/dist/local/store/sqlite/models/recipient-identity.d.ts.map +1 -0
  475. package/dist/local/store/sqlite/models/recipient-identity.js +59 -0
  476. package/dist/local/store/sqlite/models/recipient-identity.js.map +1 -0
  477. package/dist/local/store/sqlite/models/replaced-prekeys.d.ts +23 -0
  478. package/dist/local/store/sqlite/models/replaced-prekeys.d.ts.map +1 -0
  479. package/dist/local/store/sqlite/models/replaced-prekeys.js +42 -0
  480. package/dist/local/store/sqlite/models/replaced-prekeys.js.map +1 -0
  481. package/dist/local/store/{expo → sqlite}/models/sender-key.d.ts +22 -23
  482. package/dist/local/store/sqlite/models/sender-key.d.ts.map +1 -0
  483. package/dist/local/store/{expo → sqlite}/models/sender-key.js +66 -94
  484. package/dist/local/store/sqlite/models/sender-key.js.map +1 -0
  485. package/dist/local/store/sqlite/models/sesame-user-record.d.ts +32 -0
  486. package/dist/local/store/sqlite/models/sesame-user-record.d.ts.map +1 -0
  487. package/dist/local/store/sqlite/models/sesame-user-record.js +78 -0
  488. package/dist/local/store/sqlite/models/sesame-user-record.js.map +1 -0
  489. package/dist/local/store/{expo → sqlite}/models/session.d.ts +24 -20
  490. package/dist/local/store/sqlite/models/session.d.ts.map +1 -0
  491. package/dist/local/store/{expo → sqlite}/models/session.js +54 -72
  492. package/dist/local/store/sqlite/models/session.js.map +1 -0
  493. package/dist/local/store/sqlite/models/skipped-sender-key.d.ts +24 -0
  494. package/dist/local/store/sqlite/models/skipped-sender-key.d.ts.map +1 -0
  495. package/dist/local/store/sqlite/models/skipped-sender-key.js +62 -0
  496. package/dist/local/store/sqlite/models/skipped-sender-key.js.map +1 -0
  497. package/dist/local/store/sqlite/op-sqlite-driver.d.ts +14 -0
  498. package/dist/local/store/sqlite/op-sqlite-driver.d.ts.map +1 -0
  499. package/dist/local/store/sqlite/op-sqlite-driver.js +180 -0
  500. package/dist/local/store/sqlite/op-sqlite-driver.js.map +1 -0
  501. package/dist/local/store/sqlite/open-store.d.ts +83 -0
  502. package/dist/local/store/sqlite/open-store.d.ts.map +1 -0
  503. package/dist/local/store/sqlite/open-store.js +177 -0
  504. package/dist/local/store/sqlite/open-store.js.map +1 -0
  505. package/dist/local/store/sqlite/schema.d.ts +102 -0
  506. package/dist/local/store/sqlite/schema.d.ts.map +1 -0
  507. package/dist/local/store/sqlite/schema.js +61 -0
  508. package/dist/local/store/sqlite/schema.js.map +1 -0
  509. package/dist/local/store/sqlite/store.d.ts +199 -0
  510. package/dist/local/store/sqlite/store.d.ts.map +1 -0
  511. package/dist/local/store/sqlite/store.js +494 -0
  512. package/dist/local/store/sqlite/store.js.map +1 -0
  513. package/dist/local/store/sqlite/web/driver.d.ts +50 -0
  514. package/dist/local/store/sqlite/web/driver.d.ts.map +1 -0
  515. package/dist/local/store/sqlite/web/driver.js +171 -0
  516. package/dist/local/store/sqlite/web/driver.js.map +1 -0
  517. package/dist/local/store/sqlite/web/protocol.d.ts +80 -0
  518. package/dist/local/store/sqlite/web/protocol.d.ts.map +1 -0
  519. package/dist/local/store/sqlite/web/protocol.js +13 -0
  520. package/dist/local/store/sqlite/web/protocol.js.map +1 -0
  521. package/dist/local/store/sqlite/web/sqlite3mc/sqlite3.mjs +14526 -0
  522. package/dist/local/store/sqlite/web/sqlite3mc/sqlite3.wasm +0 -0
  523. package/dist/local/store/sqlite/web/worker.d.ts +39 -0
  524. package/dist/local/store/sqlite/web/worker.d.ts.map +1 -0
  525. package/dist/local/store/sqlite/web/worker.js +646 -0
  526. package/dist/local/store/sqlite/web/worker.js.map +1 -0
  527. package/dist/local/store/web/adapter.d.ts +5 -14
  528. package/dist/local/store/web/adapter.d.ts.map +1 -1
  529. package/dist/local/store/web/adapter.js +119 -106
  530. package/dist/local/store/web/adapter.js.map +1 -1
  531. package/dist/local/store/web/device-record.d.ts +23 -0
  532. package/dist/local/store/web/device-record.d.ts.map +1 -0
  533. package/dist/local/store/web/device-record.js +31 -0
  534. package/dist/local/store/web/device-record.js.map +1 -0
  535. package/dist/local/store/web-sqlite/adapter.d.ts +101 -0
  536. package/dist/local/store/web-sqlite/adapter.d.ts.map +1 -0
  537. package/dist/local/store/web-sqlite/adapter.js +154 -0
  538. package/dist/local/store/web-sqlite/adapter.js.map +1 -0
  539. package/dist/local/store/web-sqlite/index.d.ts +14 -0
  540. package/dist/local/store/web-sqlite/index.d.ts.map +1 -0
  541. package/dist/local/store/web-sqlite/index.js +3 -0
  542. package/dist/local/store/web-sqlite/index.js.map +1 -0
  543. package/dist/local/store/web-sqlite/maintenance.d.ts +5 -0
  544. package/dist/local/store/web-sqlite/maintenance.d.ts.map +1 -0
  545. package/dist/local/store/web-sqlite/maintenance.js +7 -0
  546. package/dist/local/store/web-sqlite/maintenance.js.map +1 -0
  547. package/dist/local/store/web-sqlite/store-locks.d.ts +33 -0
  548. package/dist/local/store/web-sqlite/store-locks.d.ts.map +1 -0
  549. package/dist/local/store/web-sqlite/store-locks.js +60 -0
  550. package/dist/local/store/web-sqlite/store-locks.js.map +1 -0
  551. package/dist/local/vault/electron-safe-storage.d.ts +45 -0
  552. package/dist/local/vault/electron-safe-storage.d.ts.map +1 -0
  553. package/dist/local/vault/electron-safe-storage.js +212 -0
  554. package/dist/local/vault/electron-safe-storage.js.map +1 -0
  555. package/dist/local/vault/index.d.ts +4 -2
  556. package/dist/local/vault/index.d.ts.map +1 -1
  557. package/dist/local/vault/indexed-db.d.ts +37 -0
  558. package/dist/local/vault/indexed-db.d.ts.map +1 -0
  559. package/dist/local/vault/indexed-db.js +102 -0
  560. package/dist/local/vault/indexed-db.js.map +1 -0
  561. package/dist/local/vault/react-native-keychain.d.ts +12 -0
  562. package/dist/local/vault/react-native-keychain.d.ts.map +1 -0
  563. package/dist/local/vault/react-native-keychain.js +71 -0
  564. package/dist/local/vault/react-native-keychain.js.map +1 -0
  565. package/dist/local/vault/require.d.ts +10 -0
  566. package/dist/local/vault/require.d.ts.map +1 -0
  567. package/dist/local/vault/require.js +16 -0
  568. package/dist/local/vault/require.js.map +1 -0
  569. package/dist/logger.d.ts.map +1 -1
  570. package/dist/logger.js +2 -1
  571. package/dist/logger.js.map +1 -1
  572. package/dist/media/index.d.ts.map +1 -1
  573. package/dist/media/index.js +2 -1
  574. package/dist/media/index.js.map +1 -1
  575. package/dist/profile/contact-state.d.ts.map +1 -1
  576. package/dist/profile/contact-state.js +2 -4
  577. package/dist/profile/contact-state.js.map +1 -1
  578. package/dist/profile/index.d.ts +0 -1
  579. package/dist/profile/index.d.ts.map +1 -1
  580. package/dist/profile/index.js +0 -2
  581. package/dist/profile/index.js.map +1 -1
  582. package/dist/profile/profile-key.d.ts +16 -11
  583. package/dist/profile/profile-key.d.ts.map +1 -1
  584. package/dist/profile/profile-key.js +29 -29
  585. package/dist/profile/profile-key.js.map +1 -1
  586. package/dist/profile/update-service.d.ts +6 -0
  587. package/dist/profile/update-service.d.ts.map +1 -1
  588. package/dist/profile/update-service.js +3 -1
  589. package/dist/profile/update-service.js.map +1 -1
  590. package/dist/remote/object-store/validation.d.ts.map +1 -1
  591. package/dist/remote/object-store/validation.js +2 -1
  592. package/dist/remote/object-store/validation.js.map +1 -1
  593. package/dist/remote/relay/memory/adapter.d.ts +2 -3
  594. package/dist/remote/relay/memory/adapter.d.ts.map +1 -1
  595. package/dist/remote/relay/memory/adapter.js +22 -30
  596. package/dist/remote/relay/memory/adapter.js.map +1 -1
  597. package/dist/remote/relay/memory/failures.d.ts.map +1 -1
  598. package/dist/remote/relay/memory/failures.js +2 -1
  599. package/dist/remote/relay/memory/failures.js.map +1 -1
  600. package/dist/remote/relay/memory/group-server.d.ts +5 -1
  601. package/dist/remote/relay/memory/group-server.d.ts.map +1 -1
  602. package/dist/remote/relay/memory/group-server.js +11 -1
  603. package/dist/remote/relay/memory/group-server.js.map +1 -1
  604. package/dist/safety/url.d.ts.map +1 -1
  605. package/dist/safety/url.js +21 -26
  606. package/dist/safety/url.js.map +1 -1
  607. package/dist/types/api.d.ts +15 -2
  608. package/dist/types/api.d.ts.map +1 -1
  609. package/dist/types/errors.d.ts +97 -1
  610. package/dist/types/errors.d.ts.map +1 -1
  611. package/dist/types/errors.js +105 -1
  612. package/dist/types/errors.js.map +1 -1
  613. package/dist/types/session.d.ts.map +1 -1
  614. package/dist/types/session.js +2 -1
  615. package/dist/types/session.js.map +1 -1
  616. package/dist/utils/retry.d.ts +2 -0
  617. package/dist/utils/retry.d.ts.map +1 -1
  618. package/dist/utils/retry.js +4 -2
  619. package/dist/utils/retry.js.map +1 -1
  620. package/docs/ASSURANCE.md +84 -11
  621. package/docs/CLIENT_COMPOSITION.md +1 -2
  622. package/docs/DEVIATIONS.md +1 -1
  623. package/docs/ERROR_HANDLING.md +7 -1
  624. package/docs/GETTING_STARTED.md +1 -2
  625. package/docs/PACKAGE_SURFACE.md +32 -12
  626. package/docs/RECIPES.md +1 -2
  627. package/examples/browser/index.html +1 -1
  628. package/local/store/README.md +142 -42
  629. package/local/store/expo/README.md +67 -47
  630. package/local/store/key-value/README.md +278 -0
  631. package/local/store/node/README.md +206 -46
  632. package/local/store/react-native/README.md +120 -61
  633. package/local/store/web/README.md +14 -0
  634. package/local/store/web-sqlite/README.md +210 -0
  635. package/local/vault/README.md +115 -2
  636. package/package.json +42 -23
  637. package/profile/README.md +9 -11
  638. package/remote/README.md +1 -2
  639. package/dist/local/store/expo/database-key.d.ts +0 -142
  640. package/dist/local/store/expo/database-key.d.ts.map +0 -1
  641. package/dist/local/store/expo/database-key.js +0 -312
  642. package/dist/local/store/expo/database-key.js.map +0 -1
  643. package/dist/local/store/expo/db.d.ts +0 -95
  644. package/dist/local/store/expo/db.d.ts.map +0 -1
  645. package/dist/local/store/expo/db.js +0 -147
  646. package/dist/local/store/expo/db.js.map +0 -1
  647. package/dist/local/store/expo/key-storage.d.ts +0 -429
  648. package/dist/local/store/expo/key-storage.d.ts.map +0 -1
  649. package/dist/local/store/expo/key-storage.js +0 -1361
  650. package/dist/local/store/expo/key-storage.js.map +0 -1
  651. package/dist/local/store/expo/models/ec-one-time-prekey.d.ts.map +0 -1
  652. package/dist/local/store/expo/models/ec-one-time-prekey.js.map +0 -1
  653. package/dist/local/store/expo/models/ec-signed-prekey.d.ts.map +0 -1
  654. package/dist/local/store/expo/models/ec-signed-prekey.js.map +0 -1
  655. package/dist/local/store/expo/models/identity-key-id.d.ts.map +0 -1
  656. package/dist/local/store/expo/models/identity-key-id.js.map +0 -1
  657. package/dist/local/store/expo/models/index.d.ts.map +0 -1
  658. package/dist/local/store/expo/models/index.js.map +0 -1
  659. package/dist/local/store/expo/models/kyber-one-time-prekey.d.ts.map +0 -1
  660. package/dist/local/store/expo/models/kyber-one-time-prekey.js.map +0 -1
  661. package/dist/local/store/expo/models/kyber-prekey-used.d.ts.map +0 -1
  662. package/dist/local/store/expo/models/kyber-prekey-used.js.map +0 -1
  663. package/dist/local/store/expo/models/kyber-prekey.d.ts.map +0 -1
  664. package/dist/local/store/expo/models/kyber-prekey.js.map +0 -1
  665. package/dist/local/store/expo/models/local-identity.d.ts +0 -52
  666. package/dist/local/store/expo/models/local-identity.d.ts.map +0 -1
  667. package/dist/local/store/expo/models/local-identity.js +0 -166
  668. package/dist/local/store/expo/models/local-identity.js.map +0 -1
  669. package/dist/local/store/expo/models/message-record.d.ts.map +0 -1
  670. package/dist/local/store/expo/models/message-record.js.map +0 -1
  671. package/dist/local/store/expo/models/recipient-identity.d.ts +0 -21
  672. package/dist/local/store/expo/models/recipient-identity.d.ts.map +0 -1
  673. package/dist/local/store/expo/models/recipient-identity.js +0 -66
  674. package/dist/local/store/expo/models/recipient-identity.js.map +0 -1
  675. package/dist/local/store/expo/models/replaced-prekey-utils.d.ts +0 -33
  676. package/dist/local/store/expo/models/replaced-prekey-utils.d.ts.map +0 -1
  677. package/dist/local/store/expo/models/replaced-prekey-utils.js +0 -54
  678. package/dist/local/store/expo/models/replaced-prekey-utils.js.map +0 -1
  679. package/dist/local/store/expo/models/sender-key.d.ts.map +0 -1
  680. package/dist/local/store/expo/models/sender-key.js.map +0 -1
  681. package/dist/local/store/expo/models/session.d.ts.map +0 -1
  682. package/dist/local/store/expo/models/session.js.map +0 -1
  683. package/dist/local/store/expo/schema.d.ts +0 -1917
  684. package/dist/local/store/expo/schema.d.ts.map +0 -1
  685. package/dist/local/store/expo/schema.js +0 -197
  686. package/dist/local/store/expo/schema.js.map +0 -1
  687. package/dist/local/store/node/database-encryption.d.ts +0 -109
  688. package/dist/local/store/node/database-encryption.d.ts.map +0 -1
  689. package/dist/local/store/node/database-encryption.js +0 -202
  690. package/dist/local/store/node/database-encryption.js.map +0 -1
  691. package/dist/local/store/node/database-file-commit.d.ts +0 -8
  692. package/dist/local/store/node/database-file-commit.d.ts.map +0 -1
  693. package/dist/local/store/node/database-file-commit.js +0 -62
  694. package/dist/local/store/node/database-file-commit.js.map +0 -1
  695. package/dist/local/store/node/database-key.d.ts +0 -129
  696. package/dist/local/store/node/database-key.d.ts.map +0 -1
  697. package/dist/local/store/node/database-key.js +0 -293
  698. package/dist/local/store/node/database-key.js.map +0 -1
  699. package/dist/local/store/node/database-lock.d.ts +0 -8
  700. package/dist/local/store/node/database-lock.d.ts.map +0 -1
  701. package/dist/local/store/node/database-lock.js +0 -44
  702. package/dist/local/store/node/database-lock.js.map +0 -1
  703. package/dist/local/store/node/database.d.ts +0 -226
  704. package/dist/local/store/node/database.d.ts.map +0 -1
  705. package/dist/local/store/node/database.js +0 -813
  706. package/dist/local/store/node/database.js.map +0 -1
  707. package/dist/local/store/react-native/backend-conformance.d.ts.map +0 -1
  708. package/dist/local/store/react-native/backend-conformance.js.map +0 -1
  709. package/dist/local/store/react-native/reference-backend.d.ts +0 -43
  710. package/dist/local/store/react-native/reference-backend.d.ts.map +0 -1
  711. package/dist/local/store/react-native/reference-backend.js +0 -178
  712. package/dist/local/store/react-native/reference-backend.js.map +0 -1
  713. package/dist/local/store/react-native/storage.d.ts.map +0 -1
  714. package/dist/local/store/react-native/storage.js.map +0 -1
  715. package/dist/profile/storage.d.ts +0 -61
  716. package/dist/profile/storage.d.ts.map +0 -1
  717. package/dist/profile/storage.js +0 -145
  718. package/dist/profile/storage.js.map +0 -1
  719. /package/dist/local/store/{react-native → key-value}/storage.js +0 -0
  720. /package/dist/local/store/{expo → sqlite}/models/identity-key-id.d.ts +0 -0
  721. /package/dist/local/store/{expo → sqlite}/models/identity-key-id.js +0 -0
@@ -0,0 +1,180 @@
1
+ import { isSQLCipher, open } from '@op-engineering/op-sqlite';
2
+ import { bytesToHex } from '../../../encoding/hex.js';
3
+ import { SqliteEncryptionUnavailableError } from './errors.js';
4
+ const BINDING = 'op-sqlite';
5
+ const KEY_BYTES = 32;
6
+ /**
7
+ * SQLite's message for `SQLITE_CANTOPEN`. op-sqlite reports no result code
8
+ * (op-sqlite#462), so the driver reads the message text, as the core does.
9
+ */
10
+ const CANT_OPEN = 'unable to open database file';
11
+ function messageOf(error) {
12
+ const message = error?.message;
13
+ return typeof message === 'string' ? message : String(error);
14
+ }
15
+ /**
16
+ * op-sqlite reads every INTEGER as a double, TEXT as a string, and a BLOB as
17
+ * an `ArrayBuffer`. Every SDK column is TEXT or INTEGER.
18
+ */
19
+ function toValue(column, value) {
20
+ if (value === null || typeof value === 'string' || typeof value === 'number')
21
+ return value;
22
+ if (typeof value === 'boolean')
23
+ return Number(value);
24
+ throw new TypeError(`SQLite column ${column} returned a value that is not TEXT, INTEGER, or NULL.`);
25
+ }
26
+ function toRow(row) {
27
+ const values = {};
28
+ for (const [column, value] of Object.entries(row)) {
29
+ values[column] = toValue(column, value);
30
+ }
31
+ return values;
32
+ }
33
+ class OpSqliteConnection {
34
+ #database;
35
+ constructor(database) {
36
+ this.#database = database;
37
+ }
38
+ /**
39
+ * `execute` is the only statement call. op-sqlite's `transaction` and
40
+ * `executeBatch` queue only against each other, so they would not keep the
41
+ * core's order.
42
+ */
43
+ async execute(sql, params = []) {
44
+ const result = await this.#database.execute(sql, [...params]);
45
+ // `rowsAffected` is sqlite3_changes() after the statement ran to
46
+ // completion, so a statement with RETURNING counts its rows too.
47
+ return { rows: result.rows.map(toRow), changes: result.rowsAffected };
48
+ }
49
+ /**
50
+ * SQLCipher answers `PRAGMA cipher_version` on every connection, with or
51
+ * without a key. `PRAGMA cipher_provider` returns a row only when the
52
+ * connection has a codec, so the probe asks it first.
53
+ */
54
+ async probeCipher() {
55
+ const provider = await this.execute('PRAGMA cipher_provider');
56
+ if (provider.rows.length === 0)
57
+ return null;
58
+ const { rows } = await this.execute('PRAGMA cipher_version');
59
+ const version = rows[0]?.cipher_version;
60
+ return typeof version === 'string' && version !== '' ? version : null;
61
+ }
62
+ /**
63
+ * op-sqlite's `close` interrupts the connection first, so SQLite does not
64
+ * checkpoint at close and the WAL stays. The checkpoint is best effort: the
65
+ * connection always closes, and a failure path keeps its own error.
66
+ */
67
+ async close() {
68
+ try {
69
+ await this.#database.execute('PRAGMA wal_checkpoint(TRUNCATE)');
70
+ }
71
+ catch {
72
+ // The WAL stays, and the next open reads it.
73
+ }
74
+ finally {
75
+ this.#database.close();
76
+ }
77
+ }
78
+ }
79
+ /** The SQLCipher raw-key form: SQLCipher uses the bytes with no key derivation. */
80
+ function rawKey(key) {
81
+ if (key.length !== KEY_BYTES) {
82
+ throw new Error(`The SQLCipher raw key must be ${KEY_BYTES} bytes.`);
83
+ }
84
+ // A build without SQLCipher ignores `encryptionKey` and writes plaintext,
85
+ // so the driver refuses the key before `open` creates the file.
86
+ if (!isSQLCipher())
87
+ throw new SqliteEncryptionUnavailableError(BINDING);
88
+ return `x'${bytesToHex(key)}'`;
89
+ }
90
+ /**
91
+ * Open `file` with the op-sqlite `failOnCreate` flag, or return `null` when
92
+ * the file does not exist. SQLite opens the file without reading a page, so
93
+ * this works on a file that the connection has no key for.
94
+ */
95
+ function openExisting(file) {
96
+ try {
97
+ return open({ name: file, failOnCreate: true });
98
+ }
99
+ catch (error) {
100
+ if (messageOf(error).includes(CANT_OPEN))
101
+ return null;
102
+ throw error;
103
+ }
104
+ }
105
+ /**
106
+ * Open the file on one connection that the store keeps until `close`.
107
+ *
108
+ * op-sqlite applies the key with `sqlite3_key_v2` inside `open`, before any
109
+ * statement. SQLCipher accepts a wrong key there, and a wrong key, a missing
110
+ * key on an encrypted file, and a key on a plaintext file all fail at the
111
+ * first read with `file is not a database`. The verifying read therefore runs
112
+ * inside `open`, before any setting that touches the file.
113
+ *
114
+ * `synchronous=FULL` syncs the WAL at each commit. With `NORMAL`, a power loss
115
+ * can roll back ratchet or prekey state.
116
+ */
117
+ async function openDatabase(file, key) {
118
+ const options = key === null ? { name: file } : { name: file, encryptionKey: rawKey(key) };
119
+ let database;
120
+ try {
121
+ database = open(options);
122
+ }
123
+ catch (error) {
124
+ throw new Error(`${BINDING} could not open the database: ${messageOf(error)}`, {
125
+ cause: error,
126
+ });
127
+ }
128
+ try {
129
+ await database.execute('SELECT count(*) FROM sqlite_master');
130
+ const { rows } = await database.execute('PRAGMA journal_mode=WAL');
131
+ const journalMode = rows[0]?.journal_mode;
132
+ if (journalMode !== 'wal') {
133
+ throw new Error(`SQLite kept journal mode ${String(journalMode)} instead of wal.`);
134
+ }
135
+ await database.execute('PRAGMA synchronous=FULL');
136
+ return database;
137
+ }
138
+ catch (error) {
139
+ database.close();
140
+ throw new Error(`${BINDING} could not open the database: ${messageOf(error)}`, {
141
+ cause: error,
142
+ });
143
+ }
144
+ }
145
+ /**
146
+ * The `SqliteDriver` for bare React Native, over `@op-engineering/op-sqlite`.
147
+ *
148
+ * `file` is the op-sqlite database name in the op-sqlite default location. A
149
+ * keyed file is in the SQLCipher format of the op-sqlite SQLCipher build, with
150
+ * the raw key `x'<64 hex>'`. Each open makes one op-sqlite connection, and
151
+ * every statement of the store runs on it.
152
+ *
153
+ * op-sqlite has no file API. `exists` and `remove` open each file with
154
+ * `failOnCreate`, and `remove` deletes it with the op-sqlite `delete`.
155
+ */
156
+ export function createOpSqliteDriver() {
157
+ return {
158
+ name: BINDING,
159
+ // The op-sqlite default location is fixed for the app.
160
+ identify: (file) => file,
161
+ async exists(file) {
162
+ const database = openExisting(file);
163
+ if (database === null)
164
+ return false;
165
+ database.close();
166
+ return true;
167
+ },
168
+ async open(file, key) {
169
+ return new OpSqliteConnection(await openDatabase(file, key));
170
+ },
171
+ async remove(file) {
172
+ // The sidecars go first, so an interrupted remove never leaves an old
173
+ // journal or WAL for a new database with the same name to find.
174
+ for (const name of [`${file}-wal`, `${file}-shm`, `${file}-journal`, file]) {
175
+ openExisting(name)?.delete();
176
+ }
177
+ },
178
+ };
179
+ }
180
+ //# sourceMappingURL=op-sqlite-driver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"op-sqlite-driver.js","sourceRoot":"","sources":["../../../../local/store/sqlite/op-sqlite-driver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,IAAI,EAAwB,MAAM,2BAA2B,CAAC;AAEpF,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAQnD,OAAO,EAAE,gCAAgC,EAAE,MAAM,UAAU,CAAC;AAE5D,MAAM,OAAO,GAAG,WAAW,CAAC;AAC5B,MAAM,SAAS,GAAG,EAAE,CAAC;AAErB;;;GAGG;AACH,MAAM,SAAS,GAAG,8BAA8B,CAAC;AAEjD,SAAS,SAAS,CAAC,KAAc;IAC/B,MAAM,OAAO,GAAI,KAAsC,EAAE,OAAO,CAAC;IACjE,OAAO,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC/D,CAAC;AAED;;;GAGG;AACH,SAAS,OAAO,CAAC,MAAc,EAAE,KAAa;IAC5C,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC3F,IAAI,OAAO,KAAK,KAAK,SAAS;QAAE,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;IACrD,MAAM,IAAI,SAAS,CAAC,iBAAiB,MAAM,uDAAuD,CAAC,CAAC;AACtG,CAAC;AAED,SAAS,KAAK,CAAC,GAA2B;IACxC,MAAM,MAAM,GAAgC,EAAE,CAAC;IAC/C,KAAK,MAAM,CAAC,MAAM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,IAAI,EAAE,GAAG;YAClB,OAAO,IAAI,kBAAkB,CAAC,MAAM,YAAY,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC;QAC/D,CAAC;QAED,KAAK,CAAC,MAAM,CAAC,IAAI;YACf,sEAAsE;YACtE,gEAAgE;YAChE,KAAK,MAAM,IAAI,IAAI,CAAC,GAAG,IAAI,MAAM,EAAE,GAAG,IAAI,MAAM,EAAE,GAAG,IAAI,UAAU,EAAE,IAAI,CAAC,EAAE,CAAC;gBAC3E,YAAY,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;YAC/B,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,83 @@
1
+ /**
2
+ * Open the database of an SDK-owned SQLite store, and hold the custody of its
3
+ * key.
4
+ *
5
+ * Each platform entry is a driver plus a vault on {@link openSqliteStore} and
6
+ * {@link resetSqliteStore}. The driver maps the name to a file, and
7
+ * `driver.identify(name)` names the database that the file is. That identity
8
+ * keys the vault slot of the key and the one-at-a-time open below.
9
+ *
10
+ * An encrypted store has one 32-byte key in one slot of the secret vault. The
11
+ * key lives only in the vault, never in the file beside the data it encrypts.
12
+ * The vault write comes before the driver creates the file, so a file never
13
+ * exists without its key. A file that exists while the vault holds no key is
14
+ * a lost key: opening reports it and changes nothing, because a new key
15
+ * cannot read the old file. The exception is a file that the core recorded as
16
+ * plaintext: opening reports a setting mismatch, as the other direction does.
17
+ * Only an explicit reset deletes the file and makes a new key. A store with
18
+ * `encryptionAtRest: false` has no key, and its open and reset do not touch
19
+ * the vault.
20
+ *
21
+ * In one process, the open and the reset of a database run one at a time, and
22
+ * a database has at most one open store. Two first opens therefore cannot write
23
+ * two different keys, and a reset or the driver's `exists` never runs on a
24
+ * file under a live connection. This does not cover other processes: an
25
+ * entry whose files other processes can open holds its own cross-process lock
26
+ * over each call.
27
+ */
28
+ import type { SignalProtocolLocalSecretVault } from '../../../types/api.js';
29
+ import type { SqliteDriver } from './driver.js';
30
+ import { type SqliteOpenOptions } from './encryption.js';
31
+ import type { SqliteRootExecutor } from './executor.js';
32
+ /** The options of {@link openSqliteStore} and {@link resetSqliteStore}. */
33
+ export interface SqliteStoreOpenOptions extends SqliteOpenOptions {
34
+ readonly driver: SqliteDriver;
35
+ /**
36
+ * The database name. The driver maps it to a file and to the identity that
37
+ * names the vault slot of the key. Letters, digits, `.`, `_`, and `-` only.
38
+ */
39
+ readonly name: string;
40
+ /** The vault that holds the database key. */
41
+ readonly vault: SignalProtocolLocalSecretVault;
42
+ }
43
+ /**
44
+ * The vault slot that holds the key of the database `identity`, the value of
45
+ * `driver.identify(name)`.
46
+ */
47
+ export declare function sqliteDatabaseKeySlot(identity: string): string;
48
+ /**
49
+ * Reject a name that is not safe as a file name on every platform, with the
50
+ * error of {@link openSqliteStore}.
51
+ */
52
+ export declare function assertSqliteStoreName(name: string, operation: 'open' | 'reset'): void;
53
+ /**
54
+ * Open the database of the store `name`. The open applies the SDK
55
+ * migrations. On an encrypted store, the key comes from the vault. The key,
56
+ * then the file, are created only when the file does not exist.
57
+ *
58
+ * `close()` on the result closes the database and releases the name.
59
+ *
60
+ * @throws EncryptionError with `INVALID_STATE` when the name is not valid or
61
+ * its database already has an open store in this process, or when a newer
62
+ * SDK wrote the file.
63
+ * @throws EncryptionError with `LOCAL_STORE_KEY_LOST` when the file exists
64
+ * and the vault holds no key for it.
65
+ * @throws EncryptionError with `KEY_STORAGE_ERROR` when the vault fails or
66
+ * holds a key of the wrong size, or when the file was created with the
67
+ * other `encryptionAtRest` setting (`SqliteKeyMismatchError`).
68
+ */
69
+ export declare function openSqliteStore(options: SqliteStoreOpenOptions): Promise<SqliteRootExecutor>;
70
+ /**
71
+ * Delete the database of the store `name`, then create a new key, then open a
72
+ * new, empty database.
73
+ *
74
+ * The order is the crash contract. A process that stops after the deletion
75
+ * and before the vault write leaves no file and the old key or none, and
76
+ * {@link openSqliteStore} opens that state as a new store. The other order
77
+ * would leave the old file under a key that no longer exists.
78
+ *
79
+ * @throws EncryptionError with `INVALID_STATE` when the name is not valid or
80
+ * its database already has an open store in this process.
81
+ */
82
+ export declare function resetSqliteStore(options: SqliteStoreOpenOptions): Promise<SqliteRootExecutor>;
83
+ //# sourceMappingURL=open-store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"open-store.d.ts","sourceRoot":"","sources":["../../../../local/store/sqlite/open-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAGH,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,oBAAoB,CAAC;AAEzE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,EAA6B,KAAK,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEjF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AASrD,2EAA2E;AAC3E,MAAM,WAAW,sBAAuB,SAAQ,iBAAiB;IAC/D,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B;;;OAGG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,6CAA6C;IAC7C,QAAQ,CAAC,KAAK,EAAE,8BAA8B,CAAC;CAChD;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAE9D;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,GAAG,IAAI,CAQrF;AAQD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAuB5F;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAU7F"}
@@ -0,0 +1,177 @@
1
+ /**
2
+ * Open the database of an SDK-owned SQLite store, and hold the custody of its
3
+ * key.
4
+ *
5
+ * Each platform entry is a driver plus a vault on {@link openSqliteStore} and
6
+ * {@link resetSqliteStore}. The driver maps the name to a file, and
7
+ * `driver.identify(name)` names the database that the file is. That identity
8
+ * keys the vault slot of the key and the one-at-a-time open below.
9
+ *
10
+ * An encrypted store has one 32-byte key in one slot of the secret vault. The
11
+ * key lives only in the vault, never in the file beside the data it encrypts.
12
+ * The vault write comes before the driver creates the file, so a file never
13
+ * exists without its key. A file that exists while the vault holds no key is
14
+ * a lost key: opening reports it and changes nothing, because a new key
15
+ * cannot read the old file. The exception is a file that the core recorded as
16
+ * plaintext: opening reports a setting mismatch, as the other direction does.
17
+ * Only an explicit reset deletes the file and makes a new key. A store with
18
+ * `encryptionAtRest: false` has no key, and its open and reset do not touch
19
+ * the vault.
20
+ *
21
+ * In one process, the open and the reset of a database run one at a time, and
22
+ * a database has at most one open store. Two first opens therefore cannot write
23
+ * two different keys, and a reset or the driver's `exists` never runs on a
24
+ * file under a live connection. This does not cover other processes: an
25
+ * entry whose files other processes can open holds its own cross-process lock
26
+ * over each call.
27
+ */
28
+ import { generateRandomBytes } from '../../../internal/crypto/random.js';
29
+ import { EncryptionError, EncryptionErrorCode } from '../../../types/errors.js';
30
+ import { isPlaintextSqliteDatabase } from './encryption.js';
31
+ import { SqliteKeyMismatchError } from './errors.js';
32
+ import { openMigratedSqliteDatabase } from './migrations.js';
33
+ /** SQLCipher raw key size. */
34
+ const DATABASE_KEY_SIZE = 32;
35
+ /** A name that is safe as a file name and as a vault slot on every platform. */
36
+ const STORE_NAME = /^[A-Za-z0-9._-]+$/;
37
+ /**
38
+ * The vault slot that holds the key of the database `identity`, the value of
39
+ * `driver.identify(name)`.
40
+ */
41
+ export function sqliteDatabaseKeySlot(identity) {
42
+ return `signal_protocol_sqlite_key.${identity}`;
43
+ }
44
+ /**
45
+ * Reject a name that is not safe as a file name on every platform, with the
46
+ * error of {@link openSqliteStore}.
47
+ */
48
+ export function assertSqliteStoreName(name, operation) {
49
+ if (STORE_NAME.test(name))
50
+ return;
51
+ throw new EncryptionError(`The SQLite store name ${JSON.stringify(name)} may contain only letters, digits, ` +
52
+ '".", "_", and "-".', EncryptionErrorCode.INVALID_STATE, { operation });
53
+ }
54
+ /** The tail of the queued opens and resets of each database identity. */
55
+ const pending = new Map();
56
+ /** The database identities that have an open store in this process. */
57
+ const held = new Set();
58
+ /**
59
+ * Open the database of the store `name`. The open applies the SDK
60
+ * migrations. On an encrypted store, the key comes from the vault. The key,
61
+ * then the file, are created only when the file does not exist.
62
+ *
63
+ * `close()` on the result closes the database and releases the name.
64
+ *
65
+ * @throws EncryptionError with `INVALID_STATE` when the name is not valid or
66
+ * its database already has an open store in this process, or when a newer
67
+ * SDK wrote the file.
68
+ * @throws EncryptionError with `LOCAL_STORE_KEY_LOST` when the file exists
69
+ * and the vault holds no key for it.
70
+ * @throws EncryptionError with `KEY_STORAGE_ERROR` when the vault fails or
71
+ * holds a key of the wrong size, or when the file was created with the
72
+ * other `encryptionAtRest` setting (`SqliteKeyMismatchError`).
73
+ */
74
+ export function openSqliteStore(options) {
75
+ return oneAtATime(options, 'open', async () => {
76
+ const { driver, name, vault } = options;
77
+ if (options.encryptionAtRest === false) {
78
+ return openMigratedSqliteDatabase(driver, name, null, options);
79
+ }
80
+ const slot = sqliteDatabaseKeySlot(driver.identify(name));
81
+ const storedKey = await readDatabaseKey(vault, slot);
82
+ if (storedKey)
83
+ return openMigratedSqliteDatabase(driver, name, storedKey, options);
84
+ if (await driver.exists(name)) {
85
+ if (await isPlaintextSqliteDatabase(driver, name)) {
86
+ throw new SqliteKeyMismatchError(driver.name);
87
+ }
88
+ throw new EncryptionError(`The ${driver.name} database ${name} exists, but the secret vault holds no key for it. ` +
89
+ 'Restore the vault entry, or reset the store to delete the database.', EncryptionErrorCode.LOCAL_STORE_KEY_LOST, { operation: 'open' });
90
+ }
91
+ return openMigratedSqliteDatabase(driver, name, await replaceDatabaseKey(vault, slot), options);
92
+ });
93
+ }
94
+ /**
95
+ * Delete the database of the store `name`, then create a new key, then open a
96
+ * new, empty database.
97
+ *
98
+ * The order is the crash contract. A process that stops after the deletion
99
+ * and before the vault write leaves no file and the old key or none, and
100
+ * {@link openSqliteStore} opens that state as a new store. The other order
101
+ * would leave the old file under a key that no longer exists.
102
+ *
103
+ * @throws EncryptionError with `INVALID_STATE` when the name is not valid or
104
+ * its database already has an open store in this process.
105
+ */
106
+ export function resetSqliteStore(options) {
107
+ return oneAtATime(options, 'reset', async () => {
108
+ const { driver, name, vault } = options;
109
+ await driver.remove(name);
110
+ const key = options.encryptionAtRest === false
111
+ ? null
112
+ : await replaceDatabaseKey(vault, sqliteDatabaseKeySlot(driver.identify(name)));
113
+ return openMigratedSqliteDatabase(driver, name, key, options);
114
+ });
115
+ }
116
+ /**
117
+ * Run `task` after every earlier open and reset of the database, and refuse
118
+ * it while the database has an open store. The database stays held until the
119
+ * returned executor closes.
120
+ */
121
+ function oneAtATime({ driver, name }, operation, task) {
122
+ try {
123
+ assertSqliteStoreName(name, operation);
124
+ }
125
+ catch (error) {
126
+ return Promise.reject(error);
127
+ }
128
+ const identity = driver.identify(name);
129
+ const run = async () => {
130
+ if (held.has(identity)) {
131
+ throw new EncryptionError(`The SQLite store ${name} is already open in this process. Close it first.`, EncryptionErrorCode.INVALID_STATE, { operation });
132
+ }
133
+ const db = await task();
134
+ held.add(identity);
135
+ let closing = null;
136
+ return {
137
+ ...db,
138
+ close() {
139
+ closing ??= db.close().finally(() => held.delete(identity));
140
+ return closing;
141
+ },
142
+ };
143
+ };
144
+ const result = (pending.get(identity) ?? Promise.resolve()).then(run);
145
+ const tail = result.catch(() => undefined);
146
+ pending.set(identity, tail);
147
+ void tail.then(() => {
148
+ if (pending.get(identity) === tail)
149
+ pending.delete(identity);
150
+ });
151
+ return result;
152
+ }
153
+ async function readDatabaseKey(vault, slot) {
154
+ let key;
155
+ try {
156
+ key = await vault.getSecret(slot);
157
+ }
158
+ catch (error) {
159
+ throw new EncryptionError('Failed to read the database key from the secret vault', EncryptionErrorCode.KEY_STORAGE_ERROR, { operation: 'open', originalError: error });
160
+ }
161
+ if (key && key.length !== DATABASE_KEY_SIZE) {
162
+ throw new EncryptionError(`The secret vault holds a database key of ${key.length} bytes; expected ${DATABASE_KEY_SIZE}`, EncryptionErrorCode.KEY_STORAGE_ERROR, { operation: 'open' });
163
+ }
164
+ return key;
165
+ }
166
+ /** Create a new database key and write it to the vault, over any old key. */
167
+ async function replaceDatabaseKey(vault, slot) {
168
+ const key = await generateRandomBytes(DATABASE_KEY_SIZE);
169
+ try {
170
+ await vault.setSecret(slot, key);
171
+ }
172
+ catch (error) {
173
+ throw new EncryptionError('Failed to write the database key to the secret vault', EncryptionErrorCode.KEY_STORAGE_ERROR, { operation: 'open', originalError: error });
174
+ }
175
+ return key;
176
+ }
177
+ //# sourceMappingURL=open-store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"open-store.js","sourceRoot":"","sources":["../../../../local/store/sqlite/open-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAEtE,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE7E,OAAO,EAAE,yBAAyB,EAA0B,MAAM,cAAc,CAAC;AACjF,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAElD,OAAO,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAC;AAE1D,8BAA8B;AAC9B,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAE7B,gFAAgF;AAChF,MAAM,UAAU,GAAG,mBAAmB,CAAC;AAcvC;;;GAGG;AACH,MAAM,UAAU,qBAAqB,CAAC,QAAgB;IACpD,OAAO,8BAA8B,QAAQ,EAAE,CAAC;AAClD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,qBAAqB,CAAC,IAAY,EAAE,SAA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AAC;IACpC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,eAAe,CACvB,uDAAuD,EACvD,mBAAmB,CAAC,iBAAiB,EACrC,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,EAAE,KAAc,EAAE,CACrD,CAAC;IACJ,CAAC;IACD,IAAI,GAAG,IAAI,GAAG,CAAC,MAAM,KAAK,iBAAiB,EAAE,CAAC;QAC5C,MAAM,IAAI,eAAe,CACvB,4CAA4C,GAAG,CAAC,MAAM,oBAAoB,iBAAiB,EAAE,EAC7F,mBAAmB,CAAC,iBAAiB,EACrC,EAAE,SAAS,EAAE,MAAM,EAAE,CACtB,CAAC;IACJ,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,6EAA6E;AAC7E,KAAK,UAAU,kBAAkB,CAC/B,KAAqC,EACrC,IAAY;IAEZ,MAAM,GAAG,GAAG,MAAM,mBAAmB,CAAC,iBAAiB,CAAC,CAAC;IACzD,IAAI,CAAC;QACH,MAAM,KAAK,CAAC,SAAS,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IACnC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,eAAe,CACvB,sDAAsD,EACtD,mBAAmB,CAAC,iBAAiB,EACrC,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,EAAE,KAAc,EAAE,CACrD,CAAC;IACJ,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -0,0 +1,102 @@
1
+ /**
2
+ * The SDK tables, as the shared core reads them.
3
+ *
4
+ * The migrations in `./migrations.ts` create these tables. The row types
5
+ * name each column in camelCase, and the `*_COLUMNS` lists select a full row
6
+ * with those aliases.
7
+ */
8
+ /**
9
+ * Every SDK table, children before parents, so one DELETE per table in this
10
+ * order empties the store. Tables that the application adds to the same
11
+ * database are not listed and are never touched.
12
+ */
13
+ export declare const SQLITE_STORE_TABLES: readonly ['identity_keys', 'recipient_identities', 'ec_signed_prekeys', 'ec_one_time_prekeys', 'kyber_prekey_used', 'kyber_prekeys', 'kyber_one_time_prekeys', 'sessions', 'sesame_user_records', 'sender_keys', 'skipped_sender_keys', 'message_records', 'metadata', 'profile_keys', 'group_master_keys', 'group_state_cache', 'auth_credential_cache'];
14
+ export type IdentityKeyRow = {
15
+ id: string;
16
+ identityType: string;
17
+ publicKey: string;
18
+ dhPublicKey: string | null;
19
+ dhPrivateKey: string | null;
20
+ signingPublicKey: string | null;
21
+ signingPrivateKey: string | null;
22
+ createdAt: number;
23
+ updatedAt: number;
24
+ };
25
+ export declare const IDENTITY_KEY_COLUMNS = "id, identity_type AS identityType, public_key AS publicKey,\n dh_public_key AS dhPublicKey,\n dh_private_key AS dhPrivateKey, signing_public_key AS signingPublicKey,\n signing_private_key AS signingPrivateKey, created_at AS createdAt,\n updated_at AS updatedAt";
26
+ export type EcSignedPreKeyRow = {
27
+ id: number;
28
+ identityType: string;
29
+ prekeyId: number;
30
+ publicKey: string;
31
+ privateKey: string;
32
+ signature: string;
33
+ timestamp: number;
34
+ createdAt: number;
35
+ replacedAt: number | null;
36
+ };
37
+ export declare const EC_SIGNED_PREKEY_COLUMNS = "id, identity_type AS identityType,\n prekey_id AS prekeyId, public_key AS publicKey, private_key AS privateKey,\n signature, timestamp, created_at AS createdAt, replaced_at AS replacedAt";
38
+ export type EcOneTimePreKeyRow = {
39
+ id: number;
40
+ identityType: string;
41
+ prekeyId: number;
42
+ publicKey: string;
43
+ privateKey: string;
44
+ createdAt: number;
45
+ replacedAt: number | null;
46
+ };
47
+ export declare const EC_ONE_TIME_PREKEY_COLUMNS = "id, identity_type AS identityType,\n prekey_id AS prekeyId, public_key AS publicKey, private_key AS privateKey,\n created_at AS createdAt, replaced_at AS replacedAt";
48
+ export type KyberPreKeyRow = {
49
+ id: number;
50
+ instanceId: string;
51
+ identityType: string;
52
+ prekeyId: number;
53
+ publicKey: string;
54
+ privateKey: string;
55
+ signature: string | null;
56
+ timestamp: number;
57
+ createdAt: number;
58
+ replacedAt: number | null;
59
+ };
60
+ export declare const KYBER_PREKEY_COLUMNS = "id, instance_id AS instanceId,\n identity_type AS identityType, prekey_id AS prekeyId, public_key AS publicKey,\n private_key AS privateKey, signature, timestamp, created_at AS createdAt,\n replaced_at AS replacedAt";
61
+ export type KyberOneTimePreKeyRow = {
62
+ id: number;
63
+ identityType: string;
64
+ prekeyId: number;
65
+ publicKey: string;
66
+ privateKey: string;
67
+ signature: string;
68
+ timestamp: number;
69
+ createdAt: number;
70
+ replacedAt: number | null;
71
+ };
72
+ export declare const KYBER_ONE_TIME_PREKEY_COLUMNS = "id, identity_type AS identityType,\n prekey_id AS prekeyId, public_key AS publicKey, private_key AS privateKey,\n signature, timestamp, created_at AS createdAt, replaced_at AS replacedAt";
73
+ export type SessionRow = {
74
+ sessionId: string;
75
+ identityType: string;
76
+ record: string;
77
+ createdAt: number;
78
+ updatedAt: number;
79
+ };
80
+ export declare const SESSION_COLUMNS = "session_id AS sessionId, identity_type AS identityType,\n record, created_at AS createdAt, updated_at AS updatedAt";
81
+ export type SenderKeyRow = {
82
+ groupId: string;
83
+ senderId: string;
84
+ deviceId: number;
85
+ record: string;
86
+ createdAt: number;
87
+ updatedAt: number;
88
+ };
89
+ export declare const SENDER_KEY_COLUMNS = "group_id AS groupId, sender_id AS senderId,\n device_id AS deviceId, record, created_at AS createdAt, updated_at AS updatedAt";
90
+ export type MessageRecordRow = {
91
+ sessionId: string;
92
+ timestamp: number;
93
+ recipientUserId: string;
94
+ recipientDeviceId: number;
95
+ plaintext: string;
96
+ createdAt: number;
97
+ sessionStateId: string;
98
+ };
99
+ export declare const MESSAGE_RECORD_COLUMNS = "session_id AS sessionId, timestamp,\n recipient_user_id AS recipientUserId, recipient_device_id AS recipientDeviceId,\n plaintext, created_at AS createdAt, session_state_id AS sessionStateId";
100
+ /** `?, ?, ?` for an `IN (...)` list of `count` values. */
101
+ export declare function placeholders(count: number): string;
102
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 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AAe,wHAC+B,CAAC;AAE5D,MAAM,MAAM,YAAY,GAAG;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,eAAO,MAAM,kBAAkB,mIACmD,CAAC;AAEnF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;IACxB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,eAAO,MAAM,sBAAsB,qMAEsC,CAAC;AAE1E,0DAA0D;AAC1D,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAElD"}
@@ -0,0 +1,61 @@
1
+ /**
2
+ * The SDK tables, as the shared core reads them.
3
+ *
4
+ * The migrations in `./migrations.ts` create these tables. The row types
5
+ * name each column in camelCase, and the `*_COLUMNS` lists select a full row
6
+ * with those aliases.
7
+ */
8
+ /**
9
+ * Every SDK table, children before parents, so one DELETE per table in this
10
+ * order empties the store. Tables that the application adds to the same
11
+ * database are not listed and are never touched.
12
+ */
13
+ export const SQLITE_STORE_TABLES = [
14
+ 'identity_keys',
15
+ 'recipient_identities',
16
+ 'ec_signed_prekeys',
17
+ 'ec_one_time_prekeys',
18
+ 'kyber_prekey_used',
19
+ 'kyber_prekeys',
20
+ 'kyber_one_time_prekeys',
21
+ 'sessions',
22
+ 'sesame_user_records',
23
+ 'sender_keys',
24
+ 'skipped_sender_keys',
25
+ 'message_records',
26
+ 'metadata',
27
+ 'profile_keys',
28
+ 'group_master_keys',
29
+ 'group_state_cache',
30
+ 'auth_credential_cache',
31
+ ];
32
+ export const IDENTITY_KEY_COLUMNS = `id, identity_type AS identityType, public_key AS publicKey,
33
+ dh_public_key AS dhPublicKey,
34
+ dh_private_key AS dhPrivateKey, signing_public_key AS signingPublicKey,
35
+ signing_private_key AS signingPrivateKey, created_at AS createdAt,
36
+ updated_at AS updatedAt`;
37
+ export const EC_SIGNED_PREKEY_COLUMNS = `id, identity_type AS identityType,
38
+ prekey_id AS prekeyId, public_key AS publicKey, private_key AS privateKey,
39
+ signature, timestamp, created_at AS createdAt, replaced_at AS replacedAt`;
40
+ export const EC_ONE_TIME_PREKEY_COLUMNS = `id, identity_type AS identityType,
41
+ prekey_id AS prekeyId, public_key AS publicKey, private_key AS privateKey,
42
+ created_at AS createdAt, replaced_at AS replacedAt`;
43
+ export const KYBER_PREKEY_COLUMNS = `id, instance_id AS instanceId,
44
+ identity_type AS identityType, prekey_id AS prekeyId, public_key AS publicKey,
45
+ private_key AS privateKey, signature, timestamp, created_at AS createdAt,
46
+ replaced_at AS replacedAt`;
47
+ export const KYBER_ONE_TIME_PREKEY_COLUMNS = `id, identity_type AS identityType,
48
+ prekey_id AS prekeyId, public_key AS publicKey, private_key AS privateKey,
49
+ signature, timestamp, created_at AS createdAt, replaced_at AS replacedAt`;
50
+ export const SESSION_COLUMNS = `session_id AS sessionId, identity_type AS identityType,
51
+ record, created_at AS createdAt, updated_at AS updatedAt`;
52
+ export const SENDER_KEY_COLUMNS = `group_id AS groupId, sender_id AS senderId,
53
+ device_id AS deviceId, record, created_at AS createdAt, updated_at AS updatedAt`;
54
+ export const MESSAGE_RECORD_COLUMNS = `session_id AS sessionId, timestamp,
55
+ recipient_user_id AS recipientUserId, recipient_device_id AS recipientDeviceId,
56
+ plaintext, created_at AS createdAt, session_state_id AS sessionStateId`;
57
+ /** `?, ?, ?` for an `IN (...)` list of `count` values. */
58
+ export function placeholders(count) {
59
+ return Array.from({ length: count }, () => '?').join(', ');
60
+ }
61
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../../local/store/sqlite/schema.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,eAAe;IACf,sBAAsB;IACtB,mBAAmB;IACnB,qBAAqB;IACrB,mBAAmB;IACnB,eAAe;IACf,wBAAwB;IACxB,UAAU;IACV,qBAAqB;IACrB,aAAa;IACb,qBAAqB;IACrB,iBAAiB;IACjB,UAAU;IACV,cAAc;IACd,mBAAmB;IACnB,mBAAmB;IACnB,uBAAuB;CACf,CAAC;AAcX,MAAM,CAAC,MAAM,oBAAoB,GAAG;;;;0BAIV,CAAC;AAc3B,MAAM,CAAC,MAAM,wBAAwB,GAAG;;2EAEmC,CAAC;AAY5E,MAAM,CAAC,MAAM,0BAA0B,GAAG;;qDAEW,CAAC;AAetD,MAAM,CAAC,MAAM,oBAAoB,GAAG;;;4BAGR,CAAC;AAc7B,MAAM,CAAC,MAAM,6BAA6B,GAAG;;2EAE8B,CAAC;AAU5E,MAAM,CAAC,MAAM,eAAe,GAAG;2DAC4B,CAAC;AAW5D,MAAM,CAAC,MAAM,kBAAkB,GAAG;kFACgD,CAAC;AAYnF,MAAM,CAAC,MAAM,sBAAsB,GAAG;;yEAEmC,CAAC;AAE1E,0DAA0D;AAC1D,MAAM,UAAU,YAAY,CAAC,KAAa;IACxC,OAAO,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC7D,CAAC"}