@open-e2ee/signal-protocol-sdk 0.1.0-alpha.1

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 (1594) hide show
  1. package/ADAPTERS.md +195 -0
  2. package/ARCHITECTURE.md +206 -0
  3. package/CHANGELOG.md +13 -0
  4. package/LICENSE +661 -0
  5. package/NOTICE +27 -0
  6. package/README.md +152 -0
  7. package/SECURITY.md +125 -0
  8. package/THIRD_PARTY_NOTICES.md +31 -0
  9. package/TROUBLESHOOTING.md +203 -0
  10. package/blocking/README.md +42 -0
  11. package/client/README.md +169 -0
  12. package/device/README.md +166 -0
  13. package/dist/blocking/index.d.ts +4 -0
  14. package/dist/blocking/index.d.ts.map +1 -0
  15. package/dist/blocking/index.js +2 -0
  16. package/dist/blocking/index.js.map +1 -0
  17. package/dist/blocking/manager.d.ts +27 -0
  18. package/dist/blocking/manager.d.ts.map +1 -0
  19. package/dist/blocking/manager.js +61 -0
  20. package/dist/blocking/manager.js.map +1 -0
  21. package/dist/blocking/types.d.ts +43 -0
  22. package/dist/blocking/types.d.ts.map +1 -0
  23. package/dist/blocking/types.js +9 -0
  24. package/dist/blocking/types.js.map +1 -0
  25. package/dist/client/client.d.ts +1281 -0
  26. package/dist/client/client.d.ts.map +1 -0
  27. package/dist/client/client.js +2296 -0
  28. package/dist/client/client.js.map +1 -0
  29. package/dist/client/compose.d.ts +105 -0
  30. package/dist/client/compose.d.ts.map +1 -0
  31. package/dist/client/compose.js +41 -0
  32. package/dist/client/compose.js.map +1 -0
  33. package/dist/client/config.d.ts +707 -0
  34. package/dist/client/config.d.ts.map +1 -0
  35. package/dist/client/config.js +19 -0
  36. package/dist/client/config.js.map +1 -0
  37. package/dist/client/constants.d.ts +48 -0
  38. package/dist/client/constants.d.ts.map +1 -0
  39. package/dist/client/constants.js +40 -0
  40. package/dist/client/constants.js.map +1 -0
  41. package/dist/client/content-adapter.d.ts +106 -0
  42. package/dist/client/content-adapter.d.ts.map +1 -0
  43. package/dist/client/content-adapter.js +423 -0
  44. package/dist/client/content-adapter.js.map +1 -0
  45. package/dist/client/dual-store.d.ts +70 -0
  46. package/dist/client/dual-store.d.ts.map +1 -0
  47. package/dist/client/dual-store.js +123 -0
  48. package/dist/client/dual-store.js.map +1 -0
  49. package/dist/client/endorsement-manager.d.ts +143 -0
  50. package/dist/client/endorsement-manager.d.ts.map +1 -0
  51. package/dist/client/endorsement-manager.js +259 -0
  52. package/dist/client/endorsement-manager.js.map +1 -0
  53. package/dist/client/event-hooks.d.ts +330 -0
  54. package/dist/client/event-hooks.d.ts.map +1 -0
  55. package/dist/client/event-hooks.js +59 -0
  56. package/dist/client/event-hooks.js.map +1 -0
  57. package/dist/client/files.d.ts +73 -0
  58. package/dist/client/files.d.ts.map +1 -0
  59. package/dist/client/files.js +192 -0
  60. package/dist/client/files.js.map +1 -0
  61. package/dist/client/groups.d.ts +204 -0
  62. package/dist/client/groups.d.ts.map +1 -0
  63. package/dist/client/groups.js +340 -0
  64. package/dist/client/groups.js.map +1 -0
  65. package/dist/client/headless.d.ts +99 -0
  66. package/dist/client/headless.d.ts.map +1 -0
  67. package/dist/client/headless.js +163 -0
  68. package/dist/client/headless.js.map +1 -0
  69. package/dist/client/index.d.ts +33 -0
  70. package/dist/client/index.d.ts.map +1 -0
  71. package/dist/client/index.js +7 -0
  72. package/dist/client/index.js.map +1 -0
  73. package/dist/client/key-rotation-core.d.ts +167 -0
  74. package/dist/client/key-rotation-core.d.ts.map +1 -0
  75. package/dist/client/key-rotation-core.js +459 -0
  76. package/dist/client/key-rotation-core.js.map +1 -0
  77. package/dist/client/key-rotation.d.ts +45 -0
  78. package/dist/client/key-rotation.d.ts.map +1 -0
  79. package/dist/client/key-rotation.js +174 -0
  80. package/dist/client/key-rotation.js.map +1 -0
  81. package/dist/client/media.d.ts +173 -0
  82. package/dist/client/media.d.ts.map +1 -0
  83. package/dist/client/media.js +476 -0
  84. package/dist/client/media.js.map +1 -0
  85. package/dist/client/messages.d.ts +131 -0
  86. package/dist/client/messages.d.ts.map +1 -0
  87. package/dist/client/messages.js +546 -0
  88. package/dist/client/messages.js.map +1 -0
  89. package/dist/client/multi-device.d.ts +73 -0
  90. package/dist/client/multi-device.d.ts.map +1 -0
  91. package/dist/client/multi-device.js +104 -0
  92. package/dist/client/multi-device.js.map +1 -0
  93. package/dist/client/prekeys.d.ts +133 -0
  94. package/dist/client/prekeys.d.ts.map +1 -0
  95. package/dist/client/prekeys.js +608 -0
  96. package/dist/client/prekeys.js.map +1 -0
  97. package/dist/client/relay-subscription.d.ts +83 -0
  98. package/dist/client/relay-subscription.d.ts.map +1 -0
  99. package/dist/client/relay-subscription.js +353 -0
  100. package/dist/client/relay-subscription.js.map +1 -0
  101. package/dist/client/retry-utils.d.ts +42 -0
  102. package/dist/client/retry-utils.d.ts.map +1 -0
  103. package/dist/client/retry-utils.js +107 -0
  104. package/dist/client/retry-utils.js.map +1 -0
  105. package/dist/client/retry.d.ts +121 -0
  106. package/dist/client/retry.d.ts.map +1 -0
  107. package/dist/client/retry.js +499 -0
  108. package/dist/client/retry.js.map +1 -0
  109. package/dist/client/sealed-sender-ops.d.ts +61 -0
  110. package/dist/client/sealed-sender-ops.d.ts.map +1 -0
  111. package/dist/client/sealed-sender-ops.js +173 -0
  112. package/dist/client/sealed-sender-ops.js.map +1 -0
  113. package/dist/client/sessions.d.ts +108 -0
  114. package/dist/client/sessions.d.ts.map +1 -0
  115. package/dist/client/sessions.js +367 -0
  116. package/dist/client/sessions.js.map +1 -0
  117. package/dist/client/signal-service-cipher.d.ts +331 -0
  118. package/dist/client/signal-service-cipher.d.ts.map +1 -0
  119. package/dist/client/signal-service-cipher.js +1506 -0
  120. package/dist/client/signal-service-cipher.js.map +1 -0
  121. package/dist/client/state.d.ts +147 -0
  122. package/dist/client/state.d.ts.map +1 -0
  123. package/dist/client/state.js +226 -0
  124. package/dist/client/state.js.map +1 -0
  125. package/dist/client/types.d.ts +423 -0
  126. package/dist/client/types.d.ts.map +1 -0
  127. package/dist/client/types.js +42 -0
  128. package/dist/client/types.js.map +1 -0
  129. package/dist/device/connection.d.ts +46 -0
  130. package/dist/device/connection.d.ts.map +1 -0
  131. package/dist/device/connection.js +239 -0
  132. package/dist/device/connection.js.map +1 -0
  133. package/dist/device/constants.d.ts +69 -0
  134. package/dist/device/constants.d.ts.map +1 -0
  135. package/dist/device/constants.js +64 -0
  136. package/dist/device/constants.js.map +1 -0
  137. package/dist/device/device-id.d.ts +45 -0
  138. package/dist/device/device-id.d.ts.map +1 -0
  139. package/dist/device/device-id.js +87 -0
  140. package/dist/device/device-id.js.map +1 -0
  141. package/dist/device/device-name-crypto.d.ts +39 -0
  142. package/dist/device/device-name-crypto.d.ts.map +1 -0
  143. package/dist/device/device-name-crypto.js +165 -0
  144. package/dist/device/device-name-crypto.js.map +1 -0
  145. package/dist/device/index.d.ts +31 -0
  146. package/dist/device/index.d.ts.map +1 -0
  147. package/dist/device/index.js +35 -0
  148. package/dist/device/index.js.map +1 -0
  149. package/dist/device/lifecycle/index.d.ts +25 -0
  150. package/dist/device/lifecycle/index.d.ts.map +1 -0
  151. package/dist/device/lifecycle/index.js +3 -0
  152. package/dist/device/lifecycle/index.js.map +1 -0
  153. package/dist/device/lifecycle/manager.d.ts +273 -0
  154. package/dist/device/lifecycle/manager.d.ts.map +1 -0
  155. package/dist/device/lifecycle/manager.js +1229 -0
  156. package/dist/device/lifecycle/manager.js.map +1 -0
  157. package/dist/device/lifecycle/types.d.ts +372 -0
  158. package/dist/device/lifecycle/types.d.ts.map +1 -0
  159. package/dist/device/lifecycle/types.js +10 -0
  160. package/dist/device/lifecycle/types.js.map +1 -0
  161. package/dist/device/lifecycle/utils.d.ts +37 -0
  162. package/dist/device/lifecycle/utils.d.ts.map +1 -0
  163. package/dist/device/lifecycle/utils.js +79 -0
  164. package/dist/device/lifecycle/utils.js.map +1 -0
  165. package/dist/device/provisioning.d.ts +249 -0
  166. package/dist/device/provisioning.d.ts.map +1 -0
  167. package/dist/device/provisioning.js +439 -0
  168. package/dist/device/provisioning.js.map +1 -0
  169. package/dist/device/transfer.d.ts +231 -0
  170. package/dist/device/transfer.d.ts.map +1 -0
  171. package/dist/device/transfer.js +628 -0
  172. package/dist/device/transfer.js.map +1 -0
  173. package/dist/device/types.d.ts +275 -0
  174. package/dist/device/types.d.ts.map +1 -0
  175. package/dist/device/types.js +42 -0
  176. package/dist/device/types.js.map +1 -0
  177. package/dist/encoding/base64.d.ts +14 -0
  178. package/dist/encoding/base64.d.ts.map +1 -0
  179. package/dist/encoding/base64.js +2 -0
  180. package/dist/encoding/base64.js.map +1 -0
  181. package/dist/encoding/hex.d.ts +14 -0
  182. package/dist/encoding/hex.d.ts.map +1 -0
  183. package/dist/encoding/hex.js +2 -0
  184. package/dist/encoding/hex.js.map +1 -0
  185. package/dist/encoding/index.d.ts +17 -0
  186. package/dist/encoding/index.d.ts.map +1 -0
  187. package/dist/encoding/index.js +3 -0
  188. package/dist/encoding/index.js.map +1 -0
  189. package/dist/files/index.d.ts +16 -0
  190. package/dist/files/index.d.ts.map +1 -0
  191. package/dist/files/index.js +15 -0
  192. package/dist/files/index.js.map +1 -0
  193. package/dist/groups/index.d.ts +12 -0
  194. package/dist/groups/index.d.ts.map +1 -0
  195. package/dist/groups/index.js +9 -0
  196. package/dist/groups/index.js.map +1 -0
  197. package/dist/hooks/index.d.ts +20 -0
  198. package/dist/hooks/index.d.ts.map +1 -0
  199. package/dist/hooks/index.js +6 -0
  200. package/dist/hooks/index.js.map +1 -0
  201. package/dist/hooks/use-connection-presence.d.ts +68 -0
  202. package/dist/hooks/use-connection-presence.d.ts.map +1 -0
  203. package/dist/hooks/use-connection-presence.js +300 -0
  204. package/dist/hooks/use-connection-presence.js.map +1 -0
  205. package/dist/hooks/use-group-membership.d.ts +66 -0
  206. package/dist/hooks/use-group-membership.d.ts.map +1 -0
  207. package/dist/hooks/use-group-membership.js +156 -0
  208. package/dist/hooks/use-group-membership.js.map +1 -0
  209. package/dist/hooks/use-key-rotation.d.ts +119 -0
  210. package/dist/hooks/use-key-rotation.d.ts.map +1 -0
  211. package/dist/hooks/use-key-rotation.js +198 -0
  212. package/dist/hooks/use-key-rotation.js.map +1 -0
  213. package/dist/hooks/use-session-health.d.ts +51 -0
  214. package/dist/hooks/use-session-health.d.ts.map +1 -0
  215. package/dist/hooks/use-session-health.js +59 -0
  216. package/dist/hooks/use-session-health.js.map +1 -0
  217. package/dist/hooks/use-single-flight.d.ts +29 -0
  218. package/dist/hooks/use-single-flight.d.ts.map +1 -0
  219. package/dist/hooks/use-single-flight.js +59 -0
  220. package/dist/hooks/use-single-flight.js.map +1 -0
  221. package/dist/index.d.ts +203 -0
  222. package/dist/index.d.ts.map +1 -0
  223. package/dist/index.js +169 -0
  224. package/dist/index.js.map +1 -0
  225. package/dist/internal/crypto/ec/ed25519.d.ts +78 -0
  226. package/dist/internal/crypto/ec/ed25519.d.ts.map +1 -0
  227. package/dist/internal/crypto/ec/ed25519.js +108 -0
  228. package/dist/internal/crypto/ec/ed25519.js.map +1 -0
  229. package/dist/internal/crypto/ec/index.d.ts +5 -0
  230. package/dist/internal/crypto/ec/index.d.ts.map +1 -0
  231. package/dist/internal/crypto/ec/index.js +4 -0
  232. package/dist/internal/crypto/ec/index.js.map +1 -0
  233. package/dist/internal/crypto/ec/x25519-validation.d.ts +70 -0
  234. package/dist/internal/crypto/ec/x25519-validation.d.ts.map +1 -0
  235. package/dist/internal/crypto/ec/x25519-validation.js +137 -0
  236. package/dist/internal/crypto/ec/x25519-validation.js.map +1 -0
  237. package/dist/internal/crypto/ec/x25519.d.ts +91 -0
  238. package/dist/internal/crypto/ec/x25519.d.ts.map +1 -0
  239. package/dist/internal/crypto/ec/x25519.js +124 -0
  240. package/dist/internal/crypto/ec/x25519.js.map +1 -0
  241. package/dist/internal/crypto/hash/index.d.ts +4 -0
  242. package/dist/internal/crypto/hash/index.d.ts.map +1 -0
  243. package/dist/internal/crypto/hash/index.js +3 -0
  244. package/dist/internal/crypto/hash/index.js.map +1 -0
  245. package/dist/internal/crypto/hash/sha256.d.ts +24 -0
  246. package/dist/internal/crypto/hash/sha256.d.ts.map +1 -0
  247. package/dist/internal/crypto/hash/sha256.js +23 -0
  248. package/dist/internal/crypto/hash/sha256.js.map +1 -0
  249. package/dist/internal/crypto/hash/sha512.d.ts +16 -0
  250. package/dist/internal/crypto/hash/sha512.d.ts.map +1 -0
  251. package/dist/internal/crypto/hash/sha512.js +27 -0
  252. package/dist/internal/crypto/hash/sha512.js.map +1 -0
  253. package/dist/internal/crypto/index.d.ts +60 -0
  254. package/dist/internal/crypto/index.d.ts.map +1 -0
  255. package/dist/internal/crypto/index.js +107 -0
  256. package/dist/internal/crypto/index.js.map +1 -0
  257. package/dist/internal/crypto/kdf/hkdf.d.ts +300 -0
  258. package/dist/internal/crypto/kdf/hkdf.d.ts.map +1 -0
  259. package/dist/internal/crypto/kdf/hkdf.js +452 -0
  260. package/dist/internal/crypto/kdf/hkdf.js.map +1 -0
  261. package/dist/internal/crypto/kdf/index.d.ts +4 -0
  262. package/dist/internal/crypto/kdf/index.d.ts.map +1 -0
  263. package/dist/internal/crypto/kdf/index.js +3 -0
  264. package/dist/internal/crypto/kdf/index.js.map +1 -0
  265. package/dist/internal/crypto/kdf/pbkdf2.d.ts +42 -0
  266. package/dist/internal/crypto/kdf/pbkdf2.d.ts.map +1 -0
  267. package/dist/internal/crypto/kdf/pbkdf2.js +44 -0
  268. package/dist/internal/crypto/kdf/pbkdf2.js.map +1 -0
  269. package/dist/internal/crypto/key-prefix.d.ts +82 -0
  270. package/dist/internal/crypto/key-prefix.d.ts.map +1 -0
  271. package/dist/internal/crypto/key-prefix.js +116 -0
  272. package/dist/internal/crypto/key-prefix.js.map +1 -0
  273. package/dist/internal/crypto/pq/index.d.ts +3 -0
  274. package/dist/internal/crypto/pq/index.d.ts.map +1 -0
  275. package/dist/internal/crypto/pq/index.js +2 -0
  276. package/dist/internal/crypto/pq/index.js.map +1 -0
  277. package/dist/internal/crypto/pq/kyber.d.ts +232 -0
  278. package/dist/internal/crypto/pq/kyber.d.ts.map +1 -0
  279. package/dist/internal/crypto/pq/kyber.js +317 -0
  280. package/dist/internal/crypto/pq/kyber.js.map +1 -0
  281. package/dist/internal/crypto/random.d.ts +22 -0
  282. package/dist/internal/crypto/random.d.ts.map +1 -0
  283. package/dist/internal/crypto/random.js +45 -0
  284. package/dist/internal/crypto/random.js.map +1 -0
  285. package/dist/internal/crypto/symmetric/aes-ctr.d.ts +73 -0
  286. package/dist/internal/crypto/symmetric/aes-ctr.d.ts.map +1 -0
  287. package/dist/internal/crypto/symmetric/aes-ctr.js +98 -0
  288. package/dist/internal/crypto/symmetric/aes-ctr.js.map +1 -0
  289. package/dist/internal/crypto/symmetric/aes-gcm-siv.d.ts +77 -0
  290. package/dist/internal/crypto/symmetric/aes-gcm-siv.d.ts.map +1 -0
  291. package/dist/internal/crypto/symmetric/aes-gcm-siv.js +111 -0
  292. package/dist/internal/crypto/symmetric/aes-gcm-siv.js.map +1 -0
  293. package/dist/internal/crypto/symmetric/aes.d.ts +211 -0
  294. package/dist/internal/crypto/symmetric/aes.d.ts.map +1 -0
  295. package/dist/internal/crypto/symmetric/aes.js +386 -0
  296. package/dist/internal/crypto/symmetric/aes.js.map +1 -0
  297. package/dist/internal/crypto/symmetric/hmac.d.ts +32 -0
  298. package/dist/internal/crypto/symmetric/hmac.d.ts.map +1 -0
  299. package/dist/internal/crypto/symmetric/hmac.js +20 -0
  300. package/dist/internal/crypto/symmetric/hmac.js.map +1 -0
  301. package/dist/internal/crypto/symmetric/index.d.ts +9 -0
  302. package/dist/internal/crypto/symmetric/index.d.ts.map +1 -0
  303. package/dist/internal/crypto/symmetric/index.js +8 -0
  304. package/dist/internal/crypto/symmetric/index.js.map +1 -0
  305. package/dist/internal/crypto/symmetric/mac.d.ts +154 -0
  306. package/dist/internal/crypto/symmetric/mac.d.ts.map +1 -0
  307. package/dist/internal/crypto/symmetric/mac.js +292 -0
  308. package/dist/internal/crypto/symmetric/mac.js.map +1 -0
  309. package/dist/internal/crypto/symmetric/padding.d.ts +55 -0
  310. package/dist/internal/crypto/symmetric/padding.d.ts.map +1 -0
  311. package/dist/internal/crypto/symmetric/padding.js +90 -0
  312. package/dist/internal/crypto/symmetric/padding.js.map +1 -0
  313. package/dist/internal/crypto/symmetric/streaming-aead.d.ts +89 -0
  314. package/dist/internal/crypto/symmetric/streaming-aead.d.ts.map +1 -0
  315. package/dist/internal/crypto/symmetric/streaming-aead.js +253 -0
  316. package/dist/internal/crypto/symmetric/streaming-aead.js.map +1 -0
  317. package/dist/internal/crypto/utils.d.ts +119 -0
  318. package/dist/internal/crypto/utils.d.ts.map +1 -0
  319. package/dist/internal/crypto/utils.js +366 -0
  320. package/dist/internal/crypto/utils.js.map +1 -0
  321. package/dist/internal/crypto/validation.d.ts +45 -0
  322. package/dist/internal/crypto/validation.d.ts.map +1 -0
  323. package/dist/internal/crypto/validation.js +37 -0
  324. package/dist/internal/crypto/validation.js.map +1 -0
  325. package/dist/internal/encoding/index.d.ts +2 -0
  326. package/dist/internal/encoding/index.d.ts.map +1 -0
  327. package/dist/internal/encoding/index.js +2 -0
  328. package/dist/internal/encoding/index.js.map +1 -0
  329. package/dist/internal/encoding/proto/envelope.d.ts +120 -0
  330. package/dist/internal/encoding/proto/envelope.d.ts.map +1 -0
  331. package/dist/internal/encoding/proto/envelope.js +160 -0
  332. package/dist/internal/encoding/proto/envelope.js.map +1 -0
  333. package/dist/internal/encoding/proto/index.d.ts +25 -0
  334. package/dist/internal/encoding/proto/index.d.ts.map +1 -0
  335. package/dist/internal/encoding/proto/index.js +30 -0
  336. package/dist/internal/encoding/proto/index.js.map +1 -0
  337. package/dist/internal/encoding/proto/pq-ratchet-serialize.d.ts +118 -0
  338. package/dist/internal/encoding/proto/pq-ratchet-serialize.d.ts.map +1 -0
  339. package/dist/internal/encoding/proto/pq-ratchet-serialize.js +383 -0
  340. package/dist/internal/encoding/proto/pq-ratchet-serialize.js.map +1 -0
  341. package/dist/internal/encoding/proto/primitives.d.ts +98 -0
  342. package/dist/internal/encoding/proto/primitives.d.ts.map +1 -0
  343. package/dist/internal/encoding/proto/primitives.js +179 -0
  344. package/dist/internal/encoding/proto/primitives.js.map +1 -0
  345. package/dist/internal/encoding/proto/sender-key-message.d.ts +147 -0
  346. package/dist/internal/encoding/proto/sender-key-message.d.ts.map +1 -0
  347. package/dist/internal/encoding/proto/sender-key-message.js +220 -0
  348. package/dist/internal/encoding/proto/sender-key-message.js.map +1 -0
  349. package/dist/internal/encoding/proto/signal-message.d.ts +174 -0
  350. package/dist/internal/encoding/proto/signal-message.d.ts.map +1 -0
  351. package/dist/internal/encoding/proto/signal-message.js +372 -0
  352. package/dist/internal/encoding/proto/signal-message.js.map +1 -0
  353. package/dist/internal/groups/group-id.d.ts +74 -0
  354. package/dist/internal/groups/group-id.d.ts.map +1 -0
  355. package/dist/internal/groups/group-id.js +63 -0
  356. package/dist/internal/groups/group-id.js.map +1 -0
  357. package/dist/internal/groups/index.d.ts +15 -0
  358. package/dist/internal/groups/index.d.ts.map +1 -0
  359. package/dist/internal/groups/index.js +2 -0
  360. package/dist/internal/groups/index.js.map +1 -0
  361. package/dist/internal/groups-v2/access-control.d.ts +101 -0
  362. package/dist/internal/groups-v2/access-control.d.ts.map +1 -0
  363. package/dist/internal/groups-v2/access-control.js +184 -0
  364. package/dist/internal/groups-v2/access-control.js.map +1 -0
  365. package/dist/internal/groups-v2/change-actions.d.ts +35 -0
  366. package/dist/internal/groups-v2/change-actions.d.ts.map +1 -0
  367. package/dist/internal/groups-v2/change-actions.js +358 -0
  368. package/dist/internal/groups-v2/change-actions.js.map +1 -0
  369. package/dist/internal/groups-v2/encrypted-state.d.ts +121 -0
  370. package/dist/internal/groups-v2/encrypted-state.d.ts.map +1 -0
  371. package/dist/internal/groups-v2/encrypted-state.js +455 -0
  372. package/dist/internal/groups-v2/encrypted-state.js.map +1 -0
  373. package/dist/internal/groups-v2/index.d.ts +14 -0
  374. package/dist/internal/groups-v2/index.d.ts.map +1 -0
  375. package/dist/internal/groups-v2/index.js +11 -0
  376. package/dist/internal/groups-v2/index.js.map +1 -0
  377. package/dist/internal/groups-v2/invite-link.d.ts +55 -0
  378. package/dist/internal/groups-v2/invite-link.d.ts.map +1 -0
  379. package/dist/internal/groups-v2/invite-link.js +111 -0
  380. package/dist/internal/groups-v2/invite-link.js.map +1 -0
  381. package/dist/internal/groups-v2/manager.d.ts +351 -0
  382. package/dist/internal/groups-v2/manager.d.ts.map +1 -0
  383. package/dist/internal/groups-v2/manager.js +1093 -0
  384. package/dist/internal/groups-v2/manager.js.map +1 -0
  385. package/dist/internal/groups-v2/types.d.ts +371 -0
  386. package/dist/internal/groups-v2/types.d.ts.map +1 -0
  387. package/dist/internal/groups-v2/types.js +61 -0
  388. package/dist/internal/groups-v2/types.js.map +1 -0
  389. package/dist/internal/manager/index.d.ts +16 -0
  390. package/dist/internal/manager/index.d.ts.map +1 -0
  391. package/dist/internal/manager/index.js +2 -0
  392. package/dist/internal/manager/index.js.map +1 -0
  393. package/dist/internal/manager/manager.d.ts +378 -0
  394. package/dist/internal/manager/manager.d.ts.map +1 -0
  395. package/dist/internal/manager/manager.js +1079 -0
  396. package/dist/internal/manager/manager.js.map +1 -0
  397. package/dist/internal/protocol/double-ratchet/chains.d.ts +135 -0
  398. package/dist/internal/protocol/double-ratchet/chains.d.ts.map +1 -0
  399. package/dist/internal/protocol/double-ratchet/chains.js +417 -0
  400. package/dist/internal/protocol/double-ratchet/chains.js.map +1 -0
  401. package/dist/internal/protocol/double-ratchet/index.d.ts +20 -0
  402. package/dist/internal/protocol/double-ratchet/index.d.ts.map +1 -0
  403. package/dist/internal/protocol/double-ratchet/index.js +21 -0
  404. package/dist/internal/protocol/double-ratchet/index.js.map +1 -0
  405. package/dist/internal/protocol/double-ratchet/ratchet.d.ts +231 -0
  406. package/dist/internal/protocol/double-ratchet/ratchet.d.ts.map +1 -0
  407. package/dist/internal/protocol/double-ratchet/ratchet.js +198 -0
  408. package/dist/internal/protocol/double-ratchet/ratchet.js.map +1 -0
  409. package/dist/internal/protocol/index.d.ts +24 -0
  410. package/dist/internal/protocol/index.d.ts.map +1 -0
  411. package/dist/internal/protocol/index.js +9 -0
  412. package/dist/internal/protocol/index.js.map +1 -0
  413. package/dist/internal/protocol/pqxdh/index.d.ts +19 -0
  414. package/dist/internal/protocol/pqxdh/index.d.ts.map +1 -0
  415. package/dist/internal/protocol/pqxdh/index.js +16 -0
  416. package/dist/internal/protocol/pqxdh/index.js.map +1 -0
  417. package/dist/internal/protocol/pqxdh/pqxdh.d.ts +141 -0
  418. package/dist/internal/protocol/pqxdh/pqxdh.d.ts.map +1 -0
  419. package/dist/internal/protocol/pqxdh/pqxdh.js +399 -0
  420. package/dist/internal/protocol/pqxdh/pqxdh.js.map +1 -0
  421. package/dist/internal/protocol/sealed-sender/certificate.d.ts +94 -0
  422. package/dist/internal/protocol/sealed-sender/certificate.d.ts.map +1 -0
  423. package/dist/internal/protocol/sealed-sender/certificate.js +254 -0
  424. package/dist/internal/protocol/sealed-sender/certificate.js.map +1 -0
  425. package/dist/internal/protocol/sealed-sender/decryption-v2.d.ts +46 -0
  426. package/dist/internal/protocol/sealed-sender/decryption-v2.d.ts.map +1 -0
  427. package/dist/internal/protocol/sealed-sender/decryption-v2.js +184 -0
  428. package/dist/internal/protocol/sealed-sender/decryption-v2.js.map +1 -0
  429. package/dist/internal/protocol/sealed-sender/decryption.d.ts +59 -0
  430. package/dist/internal/protocol/sealed-sender/decryption.d.ts.map +1 -0
  431. package/dist/internal/protocol/sealed-sender/decryption.js +268 -0
  432. package/dist/internal/protocol/sealed-sender/decryption.js.map +1 -0
  433. package/dist/internal/protocol/sealed-sender/delivery-token.d.ts +48 -0
  434. package/dist/internal/protocol/sealed-sender/delivery-token.d.ts.map +1 -0
  435. package/dist/internal/protocol/sealed-sender/delivery-token.js +71 -0
  436. package/dist/internal/protocol/sealed-sender/delivery-token.js.map +1 -0
  437. package/dist/internal/protocol/sealed-sender/encryption-v2.d.ts +56 -0
  438. package/dist/internal/protocol/sealed-sender/encryption-v2.d.ts.map +1 -0
  439. package/dist/internal/protocol/sealed-sender/encryption-v2.js +169 -0
  440. package/dist/internal/protocol/sealed-sender/encryption-v2.js.map +1 -0
  441. package/dist/internal/protocol/sealed-sender/encryption.d.ts +66 -0
  442. package/dist/internal/protocol/sealed-sender/encryption.d.ts.map +1 -0
  443. package/dist/internal/protocol/sealed-sender/encryption.js +174 -0
  444. package/dist/internal/protocol/sealed-sender/encryption.js.map +1 -0
  445. package/dist/internal/protocol/sealed-sender/index.d.ts +23 -0
  446. package/dist/internal/protocol/sealed-sender/index.d.ts.map +1 -0
  447. package/dist/internal/protocol/sealed-sender/index.js +61 -0
  448. package/dist/internal/protocol/sealed-sender/index.js.map +1 -0
  449. package/dist/internal/protocol/sealed-sender/proto/index.d.ts +129 -0
  450. package/dist/internal/protocol/sealed-sender/proto/index.d.ts.map +1 -0
  451. package/dist/internal/protocol/sealed-sender/proto/index.js +267 -0
  452. package/dist/internal/protocol/sealed-sender/proto/index.js.map +1 -0
  453. package/dist/internal/protocol/sealed-sender/types.d.ts +461 -0
  454. package/dist/internal/protocol/sealed-sender/types.d.ts.map +1 -0
  455. package/dist/internal/protocol/sealed-sender/types.js +99 -0
  456. package/dist/internal/protocol/sealed-sender/types.js.map +1 -0
  457. package/dist/internal/protocol/sealed-sender/v2-binary.d.ts +124 -0
  458. package/dist/internal/protocol/sealed-sender/v2-binary.d.ts.map +1 -0
  459. package/dist/internal/protocol/sealed-sender/v2-binary.js +295 -0
  460. package/dist/internal/protocol/sealed-sender/v2-binary.js.map +1 -0
  461. package/dist/internal/protocol/sealed-sender/v2-helpers.d.ts +107 -0
  462. package/dist/internal/protocol/sealed-sender/v2-helpers.d.ts.map +1 -0
  463. package/dist/internal/protocol/sealed-sender/v2-helpers.js +185 -0
  464. package/dist/internal/protocol/sealed-sender/v2-helpers.js.map +1 -0
  465. package/dist/internal/protocol/sender-keys/index.d.ts +11 -0
  466. package/dist/internal/protocol/sender-keys/index.d.ts.map +1 -0
  467. package/dist/internal/protocol/sender-keys/index.js +2 -0
  468. package/dist/internal/protocol/sender-keys/index.js.map +1 -0
  469. package/dist/internal/protocol/sender-keys/manager.d.ts +298 -0
  470. package/dist/internal/protocol/sender-keys/manager.d.ts.map +1 -0
  471. package/dist/internal/protocol/sender-keys/manager.js +839 -0
  472. package/dist/internal/protocol/sender-keys/manager.js.map +1 -0
  473. package/dist/internal/protocol/spqr/braid-serialize.d.ts +128 -0
  474. package/dist/internal/protocol/spqr/braid-serialize.d.ts.map +1 -0
  475. package/dist/internal/protocol/spqr/braid-serialize.js +373 -0
  476. package/dist/internal/protocol/spqr/braid-serialize.js.map +1 -0
  477. package/dist/internal/protocol/spqr/braid.d.ts +164 -0
  478. package/dist/internal/protocol/spqr/braid.d.ts.map +1 -0
  479. package/dist/internal/protocol/spqr/braid.js +305 -0
  480. package/dist/internal/protocol/spqr/braid.js.map +1 -0
  481. package/dist/internal/protocol/spqr/index.d.ts +161 -0
  482. package/dist/internal/protocol/spqr/index.d.ts.map +1 -0
  483. package/dist/internal/protocol/spqr/index.js +115 -0
  484. package/dist/internal/protocol/spqr/index.js.map +1 -0
  485. package/dist/internal/protocol/spqr/message.d.ts +237 -0
  486. package/dist/internal/protocol/spqr/message.d.ts.map +1 -0
  487. package/dist/internal/protocol/spqr/message.js +298 -0
  488. package/dist/internal/protocol/spqr/message.js.map +1 -0
  489. package/dist/internal/protocol/spqr/ml-kem-braid/authenticator.d.ts +174 -0
  490. package/dist/internal/protocol/spqr/ml-kem-braid/authenticator.d.ts.map +1 -0
  491. package/dist/internal/protocol/spqr/ml-kem-braid/authenticator.js +248 -0
  492. package/dist/internal/protocol/spqr/ml-kem-braid/authenticator.js.map +1 -0
  493. package/dist/internal/protocol/spqr/ml-kem-braid/chunk-domain.d.ts +29 -0
  494. package/dist/internal/protocol/spqr/ml-kem-braid/chunk-domain.d.ts.map +1 -0
  495. package/dist/internal/protocol/spqr/ml-kem-braid/chunk-domain.js +43 -0
  496. package/dist/internal/protocol/spqr/ml-kem-braid/chunk-domain.js.map +1 -0
  497. package/dist/internal/protocol/spqr/ml-kem-braid/errors.d.ts +170 -0
  498. package/dist/internal/protocol/spqr/ml-kem-braid/errors.d.ts.map +1 -0
  499. package/dist/internal/protocol/spqr/ml-kem-braid/errors.js +249 -0
  500. package/dist/internal/protocol/spqr/ml-kem-braid/errors.js.map +1 -0
  501. package/dist/internal/protocol/spqr/ml-kem-braid/incremental-kem.d.ts +84 -0
  502. package/dist/internal/protocol/spqr/ml-kem-braid/incremental-kem.d.ts.map +1 -0
  503. package/dist/internal/protocol/spqr/ml-kem-braid/incremental-kem.js +138 -0
  504. package/dist/internal/protocol/spqr/ml-kem-braid/incremental-kem.js.map +1 -0
  505. package/dist/internal/protocol/spqr/ml-kem-braid/index.d.ts +45 -0
  506. package/dist/internal/protocol/spqr/ml-kem-braid/index.d.ts.map +1 -0
  507. package/dist/internal/protocol/spqr/ml-kem-braid/index.js +94 -0
  508. package/dist/internal/protocol/spqr/ml-kem-braid/index.js.map +1 -0
  509. package/dist/internal/protocol/spqr/ml-kem-braid/kdf.d.ts +52 -0
  510. package/dist/internal/protocol/spqr/ml-kem-braid/kdf.d.ts.map +1 -0
  511. package/dist/internal/protocol/spqr/ml-kem-braid/kdf.js +121 -0
  512. package/dist/internal/protocol/spqr/ml-kem-braid/kdf.js.map +1 -0
  513. package/dist/internal/protocol/spqr/ml-kem-braid/noble-pq/arithmetic.d.ts +12 -0
  514. package/dist/internal/protocol/spqr/ml-kem-braid/noble-pq/arithmetic.d.ts.map +1 -0
  515. package/dist/internal/protocol/spqr/ml-kem-braid/noble-pq/arithmetic.js +15 -0
  516. package/dist/internal/protocol/spqr/ml-kem-braid/noble-pq/arithmetic.js.map +1 -0
  517. package/dist/internal/protocol/spqr/ml-kem-braid/noble-pq/index.d.ts +136 -0
  518. package/dist/internal/protocol/spqr/ml-kem-braid/noble-pq/index.d.ts.map +1 -0
  519. package/dist/internal/protocol/spqr/ml-kem-braid/noble-pq/index.js +796 -0
  520. package/dist/internal/protocol/spqr/ml-kem-braid/noble-pq/index.js.map +1 -0
  521. package/dist/internal/protocol/spqr/ml-kem-braid/rs/codec.d.ts +454 -0
  522. package/dist/internal/protocol/spqr/ml-kem-braid/rs/codec.d.ts.map +1 -0
  523. package/dist/internal/protocol/spqr/ml-kem-braid/rs/codec.js +790 -0
  524. package/dist/internal/protocol/spqr/ml-kem-braid/rs/codec.js.map +1 -0
  525. package/dist/internal/protocol/spqr/ml-kem-braid/rs/galois/field.d.ts +108 -0
  526. package/dist/internal/protocol/spqr/ml-kem-braid/rs/galois/field.d.ts.map +1 -0
  527. package/dist/internal/protocol/spqr/ml-kem-braid/rs/galois/field.js +125 -0
  528. package/dist/internal/protocol/spqr/ml-kem-braid/rs/galois/field.js.map +1 -0
  529. package/dist/internal/protocol/spqr/ml-kem-braid/rs/galois/index.d.ts +12 -0
  530. package/dist/internal/protocol/spqr/ml-kem-braid/rs/galois/index.d.ts.map +1 -0
  531. package/dist/internal/protocol/spqr/ml-kem-braid/rs/galois/index.js +5 -0
  532. package/dist/internal/protocol/spqr/ml-kem-braid/rs/galois/index.js.map +1 -0
  533. package/dist/internal/protocol/spqr/ml-kem-braid/rs/galois/tables-16.d.ts +28 -0
  534. package/dist/internal/protocol/spqr/ml-kem-braid/rs/galois/tables-16.d.ts.map +1 -0
  535. package/dist/internal/protocol/spqr/ml-kem-braid/rs/galois/tables-16.js +13953 -0
  536. package/dist/internal/protocol/spqr/ml-kem-braid/rs/galois/tables-16.js.map +1 -0
  537. package/dist/internal/protocol/spqr/ml-kem-braid/rs/index.d.ts +40 -0
  538. package/dist/internal/protocol/spqr/ml-kem-braid/rs/index.d.ts.map +1 -0
  539. package/dist/internal/protocol/spqr/ml-kem-braid/rs/index.js +52 -0
  540. package/dist/internal/protocol/spqr/ml-kem-braid/rs/index.js.map +1 -0
  541. package/dist/internal/protocol/spqr/ml-kem-braid/rs/lagrange.d.ts +151 -0
  542. package/dist/internal/protocol/spqr/ml-kem-braid/rs/lagrange.d.ts.map +1 -0
  543. package/dist/internal/protocol/spqr/ml-kem-braid/rs/lagrange.js +297 -0
  544. package/dist/internal/protocol/spqr/ml-kem-braid/rs/lagrange.js.map +1 -0
  545. package/dist/internal/protocol/spqr/ml-kem-braid/rs/polynomial.d.ts +97 -0
  546. package/dist/internal/protocol/spqr/ml-kem-braid/rs/polynomial.d.ts.map +1 -0
  547. package/dist/internal/protocol/spqr/ml-kem-braid/rs/polynomial.js +201 -0
  548. package/dist/internal/protocol/spqr/ml-kem-braid/rs/polynomial.js.map +1 -0
  549. package/dist/internal/protocol/spqr/ml-kem-braid/serialize.d.ts +249 -0
  550. package/dist/internal/protocol/spqr/ml-kem-braid/serialize.d.ts.map +1 -0
  551. package/dist/internal/protocol/spqr/ml-kem-braid/serialize.js +731 -0
  552. package/dist/internal/protocol/spqr/ml-kem-braid/serialize.js.map +1 -0
  553. package/dist/internal/protocol/spqr/ml-kem-braid/state-machine.d.ts +127 -0
  554. package/dist/internal/protocol/spqr/ml-kem-braid/state-machine.d.ts.map +1 -0
  555. package/dist/internal/protocol/spqr/ml-kem-braid/state-machine.js +894 -0
  556. package/dist/internal/protocol/spqr/ml-kem-braid/state-machine.js.map +1 -0
  557. package/dist/internal/protocol/spqr/ml-kem-braid/types.d.ts +387 -0
  558. package/dist/internal/protocol/spqr/ml-kem-braid/types.d.ts.map +1 -0
  559. package/dist/internal/protocol/spqr/ml-kem-braid/types.js +121 -0
  560. package/dist/internal/protocol/spqr/ml-kem-braid/types.js.map +1 -0
  561. package/dist/internal/protocol/spqr/serialize.d.ts +149 -0
  562. package/dist/internal/protocol/spqr/serialize.d.ts.map +1 -0
  563. package/dist/internal/protocol/spqr/serialize.js +370 -0
  564. package/dist/internal/protocol/spqr/serialize.js.map +1 -0
  565. package/dist/internal/protocol/spqr/spqr.d.ts +486 -0
  566. package/dist/internal/protocol/spqr/spqr.d.ts.map +1 -0
  567. package/dist/internal/protocol/spqr/spqr.js +1031 -0
  568. package/dist/internal/protocol/spqr/spqr.js.map +1 -0
  569. package/dist/internal/protocol/spqr/validate.d.ts +35 -0
  570. package/dist/internal/protocol/spqr/validate.d.ts.map +1 -0
  571. package/dist/internal/protocol/spqr/validate.js +62 -0
  572. package/dist/internal/protocol/spqr/validate.js.map +1 -0
  573. package/dist/internal/protocol/triple-ratchet/index.d.ts +21 -0
  574. package/dist/internal/protocol/triple-ratchet/index.d.ts.map +1 -0
  575. package/dist/internal/protocol/triple-ratchet/index.js +19 -0
  576. package/dist/internal/protocol/triple-ratchet/index.js.map +1 -0
  577. package/dist/internal/protocol/triple-ratchet/ratchet.d.ts +233 -0
  578. package/dist/internal/protocol/triple-ratchet/ratchet.d.ts.map +1 -0
  579. package/dist/internal/protocol/triple-ratchet/ratchet.js +254 -0
  580. package/dist/internal/protocol/triple-ratchet/ratchet.js.map +1 -0
  581. package/dist/internal/protocol/username/generate.d.ts +9 -0
  582. package/dist/internal/protocol/username/generate.d.ts.map +1 -0
  583. package/dist/internal/protocol/username/generate.js +16 -0
  584. package/dist/internal/protocol/username/generate.js.map +1 -0
  585. package/dist/internal/protocol/username/hash.d.ts +74 -0
  586. package/dist/internal/protocol/username/hash.d.ts.map +1 -0
  587. package/dist/internal/protocol/username/hash.js +228 -0
  588. package/dist/internal/protocol/username/hash.js.map +1 -0
  589. package/dist/internal/protocol/username/link.d.ts +50 -0
  590. package/dist/internal/protocol/username/link.d.ts.map +1 -0
  591. package/dist/internal/protocol/username/link.js +187 -0
  592. package/dist/internal/protocol/username/link.js.map +1 -0
  593. package/dist/internal/protocol/username/proof.d.ts +34 -0
  594. package/dist/internal/protocol/username/proof.d.ts.map +1 -0
  595. package/dist/internal/protocol/username/proof.js +83 -0
  596. package/dist/internal/protocol/username/proof.js.map +1 -0
  597. package/dist/internal/protocol/version.d.ts +184 -0
  598. package/dist/internal/protocol/version.d.ts.map +1 -0
  599. package/dist/internal/protocol/version.js +163 -0
  600. package/dist/internal/protocol/version.js.map +1 -0
  601. package/dist/internal/protocol/x3dh/index.d.ts +15 -0
  602. package/dist/internal/protocol/x3dh/index.d.ts.map +1 -0
  603. package/dist/internal/protocol/x3dh/index.js +13 -0
  604. package/dist/internal/protocol/x3dh/index.js.map +1 -0
  605. package/dist/internal/protocol/x3dh/x3dh.d.ts +131 -0
  606. package/dist/internal/protocol/x3dh/x3dh.d.ts.map +1 -0
  607. package/dist/internal/protocol/x3dh/x3dh.js +261 -0
  608. package/dist/internal/protocol/x3dh/x3dh.js.map +1 -0
  609. package/dist/internal/protocol/zk/credentials/attributes.d.ts +157 -0
  610. package/dist/internal/protocol/zk/credentials/attributes.d.ts.map +1 -0
  611. package/dist/internal/protocol/zk/credentials/attributes.js +177 -0
  612. package/dist/internal/protocol/zk/credentials/attributes.js.map +1 -0
  613. package/dist/internal/protocol/zk/credentials/credentials.d.ts +129 -0
  614. package/dist/internal/protocol/zk/credentials/credentials.d.ts.map +1 -0
  615. package/dist/internal/protocol/zk/credentials/credentials.js +204 -0
  616. package/dist/internal/protocol/zk/credentials/credentials.js.map +1 -0
  617. package/dist/internal/protocol/zk/credentials/endorsements.d.ts +235 -0
  618. package/dist/internal/protocol/zk/credentials/endorsements.d.ts.map +1 -0
  619. package/dist/internal/protocol/zk/credentials/endorsements.js +520 -0
  620. package/dist/internal/protocol/zk/credentials/endorsements.js.map +1 -0
  621. package/dist/internal/protocol/zk/credentials/index.d.ts +14 -0
  622. package/dist/internal/protocol/zk/credentials/index.d.ts.map +1 -0
  623. package/dist/internal/protocol/zk/credentials/index.js +6 -0
  624. package/dist/internal/protocol/zk/credentials/index.js.map +1 -0
  625. package/dist/internal/protocol/zk/credentials/issuance.d.ts +135 -0
  626. package/dist/internal/protocol/zk/credentials/issuance.d.ts.map +1 -0
  627. package/dist/internal/protocol/zk/credentials/issuance.js +338 -0
  628. package/dist/internal/protocol/zk/credentials/issuance.js.map +1 -0
  629. package/dist/internal/protocol/zk/credentials/presentation.d.ts +160 -0
  630. package/dist/internal/protocol/zk/credentials/presentation.d.ts.map +1 -0
  631. package/dist/internal/protocol/zk/credentials/presentation.js +447 -0
  632. package/dist/internal/protocol/zk/credentials/presentation.js.map +1 -0
  633. package/dist/internal/protocol/zk/groups/auth-credential.d.ts +191 -0
  634. package/dist/internal/protocol/zk/groups/auth-credential.d.ts.map +1 -0
  635. package/dist/internal/protocol/zk/groups/auth-credential.js +377 -0
  636. package/dist/internal/protocol/zk/groups/auth-credential.js.map +1 -0
  637. package/dist/internal/protocol/zk/groups/client-zk-group-cipher.d.ts +73 -0
  638. package/dist/internal/protocol/zk/groups/client-zk-group-cipher.d.ts.map +1 -0
  639. package/dist/internal/protocol/zk/groups/client-zk-group-cipher.js +140 -0
  640. package/dist/internal/protocol/zk/groups/client-zk-group-cipher.js.map +1 -0
  641. package/dist/internal/protocol/zk/groups/group-params.d.ts +93 -0
  642. package/dist/internal/protocol/zk/groups/group-params.d.ts.map +1 -0
  643. package/dist/internal/protocol/zk/groups/group-params.js +184 -0
  644. package/dist/internal/protocol/zk/groups/group-params.js.map +1 -0
  645. package/dist/internal/protocol/zk/groups/group-send-endorsement.d.ts +245 -0
  646. package/dist/internal/protocol/zk/groups/group-send-endorsement.d.ts.map +1 -0
  647. package/dist/internal/protocol/zk/groups/group-send-endorsement.js +404 -0
  648. package/dist/internal/protocol/zk/groups/group-send-endorsement.js.map +1 -0
  649. package/dist/internal/protocol/zk/groups/index.d.ts +19 -0
  650. package/dist/internal/protocol/zk/groups/index.d.ts.map +1 -0
  651. package/dist/internal/protocol/zk/groups/index.js +12 -0
  652. package/dist/internal/protocol/zk/groups/index.js.map +1 -0
  653. package/dist/internal/protocol/zk/groups/lizard.d.ts +51 -0
  654. package/dist/internal/protocol/zk/groups/lizard.d.ts.map +1 -0
  655. package/dist/internal/protocol/zk/groups/lizard.js +478 -0
  656. package/dist/internal/protocol/zk/groups/lizard.js.map +1 -0
  657. package/dist/internal/protocol/zk/groups/profile-key-commitment.d.ts +35 -0
  658. package/dist/internal/protocol/zk/groups/profile-key-commitment.d.ts.map +1 -0
  659. package/dist/internal/protocol/zk/groups/profile-key-commitment.js +99 -0
  660. package/dist/internal/protocol/zk/groups/profile-key-commitment.js.map +1 -0
  661. package/dist/internal/protocol/zk/groups/profile-key-credential.d.ts +195 -0
  662. package/dist/internal/protocol/zk/groups/profile-key-credential.d.ts.map +1 -0
  663. package/dist/internal/protocol/zk/groups/profile-key-credential.js +370 -0
  664. package/dist/internal/protocol/zk/groups/profile-key-credential.js.map +1 -0
  665. package/dist/internal/protocol/zk/groups/profile-key-encryption.d.ts +45 -0
  666. package/dist/internal/protocol/zk/groups/profile-key-encryption.d.ts.map +1 -0
  667. package/dist/internal/protocol/zk/groups/profile-key-encryption.js +125 -0
  668. package/dist/internal/protocol/zk/groups/profile-key-encryption.js.map +1 -0
  669. package/dist/internal/protocol/zk/groups/profile-key-struct.d.ts +33 -0
  670. package/dist/internal/protocol/zk/groups/profile-key-struct.d.ts.map +1 -0
  671. package/dist/internal/protocol/zk/groups/profile-key-struct.js +62 -0
  672. package/dist/internal/protocol/zk/groups/profile-key-struct.js.map +1 -0
  673. package/dist/internal/protocol/zk/groups/profile-key-version.d.ts +17 -0
  674. package/dist/internal/protocol/zk/groups/profile-key-version.d.ts.map +1 -0
  675. package/dist/internal/protocol/zk/groups/profile-key-version.js +33 -0
  676. package/dist/internal/protocol/zk/groups/profile-key-version.js.map +1 -0
  677. package/dist/internal/protocol/zk/groups/server-params.d.ts +114 -0
  678. package/dist/internal/protocol/zk/groups/server-params.d.ts.map +1 -0
  679. package/dist/internal/protocol/zk/groups/server-params.js +146 -0
  680. package/dist/internal/protocol/zk/groups/server-params.js.map +1 -0
  681. package/dist/internal/protocol/zk/groups/uid-encryption.d.ts +41 -0
  682. package/dist/internal/protocol/zk/groups/uid-encryption.d.ts.map +1 -0
  683. package/dist/internal/protocol/zk/groups/uid-encryption.js +113 -0
  684. package/dist/internal/protocol/zk/groups/uid-encryption.js.map +1 -0
  685. package/dist/internal/protocol/zk/groups/uid-struct.d.ts +48 -0
  686. package/dist/internal/protocol/zk/groups/uid-struct.d.ts.map +1 -0
  687. package/dist/internal/protocol/zk/groups/uid-struct.js +77 -0
  688. package/dist/internal/protocol/zk/groups/uid-struct.js.map +1 -0
  689. package/dist/internal/protocol/zk/proofs/args.d.ts +33 -0
  690. package/dist/internal/protocol/zk/proofs/args.d.ts.map +1 -0
  691. package/dist/internal/protocol/zk/proofs/args.js +43 -0
  692. package/dist/internal/protocol/zk/proofs/args.js.map +1 -0
  693. package/dist/internal/protocol/zk/proofs/index.d.ts +13 -0
  694. package/dist/internal/protocol/zk/proofs/index.d.ts.map +1 -0
  695. package/dist/internal/protocol/zk/proofs/index.js +7 -0
  696. package/dist/internal/protocol/zk/proofs/index.js.map +1 -0
  697. package/dist/internal/protocol/zk/proofs/proof.d.ts +30 -0
  698. package/dist/internal/protocol/zk/proofs/proof.d.ts.map +1 -0
  699. package/dist/internal/protocol/zk/proofs/proof.js +48 -0
  700. package/dist/internal/protocol/zk/proofs/proof.js.map +1 -0
  701. package/dist/internal/protocol/zk/proofs/sho-sha256.d.ts +34 -0
  702. package/dist/internal/protocol/zk/proofs/sho-sha256.d.ts.map +1 -0
  703. package/dist/internal/protocol/zk/proofs/sho-sha256.js +138 -0
  704. package/dist/internal/protocol/zk/proofs/sho-sha256.js.map +1 -0
  705. package/dist/internal/protocol/zk/proofs/sho.d.ts +120 -0
  706. package/dist/internal/protocol/zk/proofs/sho.d.ts.map +1 -0
  707. package/dist/internal/protocol/zk/proofs/sho.js +221 -0
  708. package/dist/internal/protocol/zk/proofs/sho.js.map +1 -0
  709. package/dist/internal/protocol/zk/proofs/sign.d.ts +29 -0
  710. package/dist/internal/protocol/zk/proofs/sign.d.ts.map +1 -0
  711. package/dist/internal/protocol/zk/proofs/sign.js +34 -0
  712. package/dist/internal/protocol/zk/proofs/sign.js.map +1 -0
  713. package/dist/internal/protocol/zk/proofs/statement.d.ts +103 -0
  714. package/dist/internal/protocol/zk/proofs/statement.d.ts.map +1 -0
  715. package/dist/internal/protocol/zk/proofs/statement.js +282 -0
  716. package/dist/internal/protocol/zk/proofs/statement.js.map +1 -0
  717. package/dist/internal/sesame/device-registry.d.ts +208 -0
  718. package/dist/internal/sesame/device-registry.d.ts.map +1 -0
  719. package/dist/internal/sesame/device-registry.js +431 -0
  720. package/dist/internal/sesame/device-registry.js.map +1 -0
  721. package/dist/internal/sesame/index.d.ts +31 -0
  722. package/dist/internal/sesame/index.d.ts.map +1 -0
  723. package/dist/internal/sesame/index.js +40 -0
  724. package/dist/internal/sesame/index.js.map +1 -0
  725. package/dist/internal/sesame/manager.d.ts +351 -0
  726. package/dist/internal/sesame/manager.d.ts.map +1 -0
  727. package/dist/internal/sesame/manager.js +1760 -0
  728. package/dist/internal/sesame/manager.js.map +1 -0
  729. package/dist/internal/sesame/types.d.ts +840 -0
  730. package/dist/internal/sesame/types.d.ts.map +1 -0
  731. package/dist/internal/sesame/types.js +290 -0
  732. package/dist/internal/sesame/types.js.map +1 -0
  733. package/dist/internal/sesame/validation.d.ts +72 -0
  734. package/dist/internal/sesame/validation.d.ts.map +1 -0
  735. package/dist/internal/sesame/validation.js +136 -0
  736. package/dist/internal/sesame/validation.js.map +1 -0
  737. package/dist/internal/session/builder.d.ts +94 -0
  738. package/dist/internal/session/builder.d.ts.map +1 -0
  739. package/dist/internal/session/builder.js +266 -0
  740. package/dist/internal/session/builder.js.map +1 -0
  741. package/dist/internal/session/cipher.d.ts +256 -0
  742. package/dist/internal/session/cipher.d.ts.map +1 -0
  743. package/dist/internal/session/cipher.js +1222 -0
  744. package/dist/internal/session/cipher.js.map +1 -0
  745. package/dist/internal/session/decryption.d.ts +37 -0
  746. package/dist/internal/session/decryption.d.ts.map +1 -0
  747. package/dist/internal/session/decryption.js +256 -0
  748. package/dist/internal/session/decryption.js.map +1 -0
  749. package/dist/internal/session/factory.d.ts +161 -0
  750. package/dist/internal/session/factory.d.ts.map +1 -0
  751. package/dist/internal/session/factory.js +211 -0
  752. package/dist/internal/session/factory.js.map +1 -0
  753. package/dist/internal/session/handshake.d.ts +72 -0
  754. package/dist/internal/session/handshake.d.ts.map +1 -0
  755. package/dist/internal/session/handshake.js +343 -0
  756. package/dist/internal/session/handshake.js.map +1 -0
  757. package/dist/internal/session/identity-binding.d.ts +5 -0
  758. package/dist/internal/session/identity-binding.d.ts.map +1 -0
  759. package/dist/internal/session/identity-binding.js +15 -0
  760. package/dist/internal/session/identity-binding.js.map +1 -0
  761. package/dist/internal/session/index.d.ts +73 -0
  762. package/dist/internal/session/index.d.ts.map +1 -0
  763. package/dist/internal/session/index.js +75 -0
  764. package/dist/internal/session/index.js.map +1 -0
  765. package/dist/internal/session/keys.d.ts +220 -0
  766. package/dist/internal/session/keys.d.ts.map +1 -0
  767. package/dist/internal/session/keys.js +78 -0
  768. package/dist/internal/session/keys.js.map +1 -0
  769. package/dist/internal/session/ratchet.d.ts +97 -0
  770. package/dist/internal/session/ratchet.d.ts.map +1 -0
  771. package/dist/internal/session/ratchet.js +187 -0
  772. package/dist/internal/session/ratchet.js.map +1 -0
  773. package/dist/internal/session/session-resolver.d.ts +138 -0
  774. package/dist/internal/session/session-resolver.d.ts.map +1 -0
  775. package/dist/internal/session/session-resolver.js +190 -0
  776. package/dist/internal/session/session-resolver.js.map +1 -0
  777. package/dist/internal/session/state.d.ts +278 -0
  778. package/dist/internal/session/state.d.ts.map +1 -0
  779. package/dist/internal/session/state.js +167 -0
  780. package/dist/internal/session/state.js.map +1 -0
  781. package/dist/internal/session/types.d.ts +192 -0
  782. package/dist/internal/session/types.d.ts.map +1 -0
  783. package/dist/internal/session/types.js +16 -0
  784. package/dist/internal/session/types.js.map +1 -0
  785. package/dist/internal/session/validation.d.ts +145 -0
  786. package/dist/internal/session/validation.d.ts.map +1 -0
  787. package/dist/internal/session/validation.js +340 -0
  788. package/dist/internal/session/validation.js.map +1 -0
  789. package/dist/keys/branded.d.ts +85 -0
  790. package/dist/keys/branded.d.ts.map +1 -0
  791. package/dist/keys/branded.js +26 -0
  792. package/dist/keys/branded.js.map +1 -0
  793. package/dist/keys/generation.d.ts +101 -0
  794. package/dist/keys/generation.d.ts.map +1 -0
  795. package/dist/keys/generation.js +181 -0
  796. package/dist/keys/generation.js.map +1 -0
  797. package/dist/keys/identity.d.ts +27 -0
  798. package/dist/keys/identity.d.ts.map +1 -0
  799. package/dist/keys/identity.js +200 -0
  800. package/dist/keys/identity.js.map +1 -0
  801. package/dist/keys/index.d.ts +24 -0
  802. package/dist/keys/index.d.ts.map +1 -0
  803. package/dist/keys/index.js +22 -0
  804. package/dist/keys/index.js.map +1 -0
  805. package/dist/keys/prekey-signature.d.ts +13 -0
  806. package/dist/keys/prekey-signature.d.ts.map +1 -0
  807. package/dist/keys/prekey-signature.js +46 -0
  808. package/dist/keys/prekey-signature.js.map +1 -0
  809. package/dist/keys/types.d.ts +255 -0
  810. package/dist/keys/types.d.ts.map +1 -0
  811. package/dist/keys/types.js +11 -0
  812. package/dist/keys/types.js.map +1 -0
  813. package/dist/layers.d.ts +228 -0
  814. package/dist/layers.d.ts.map +1 -0
  815. package/dist/layers.js +328 -0
  816. package/dist/layers.js.map +1 -0
  817. package/dist/local/store/expo/adapter.d.ts +243 -0
  818. package/dist/local/store/expo/adapter.d.ts.map +1 -0
  819. package/dist/local/store/expo/adapter.js +619 -0
  820. package/dist/local/store/expo/adapter.js.map +1 -0
  821. package/dist/local/store/expo/database-key.d.ts +142 -0
  822. package/dist/local/store/expo/database-key.d.ts.map +1 -0
  823. package/dist/local/store/expo/database-key.js +312 -0
  824. package/dist/local/store/expo/database-key.js.map +1 -0
  825. package/dist/local/store/expo/db.d.ts +92 -0
  826. package/dist/local/store/expo/db.d.ts.map +1 -0
  827. package/dist/local/store/expo/db.js +142 -0
  828. package/dist/local/store/expo/db.js.map +1 -0
  829. package/dist/local/store/expo/index.d.ts +22 -0
  830. package/dist/local/store/expo/index.d.ts.map +1 -0
  831. package/dist/local/store/expo/index.js +10 -0
  832. package/dist/local/store/expo/index.js.map +1 -0
  833. package/dist/local/store/expo/key-storage.d.ts +422 -0
  834. package/dist/local/store/expo/key-storage.d.ts.map +1 -0
  835. package/dist/local/store/expo/key-storage.js +1292 -0
  836. package/dist/local/store/expo/key-storage.js.map +1 -0
  837. package/dist/local/store/expo/maintenance.d.ts +4 -0
  838. package/dist/local/store/expo/maintenance.d.ts.map +1 -0
  839. package/dist/local/store/expo/maintenance.js +36 -0
  840. package/dist/local/store/expo/maintenance.js.map +1 -0
  841. package/dist/local/store/expo/models/ec-one-time-prekey.d.ts +155 -0
  842. package/dist/local/store/expo/models/ec-one-time-prekey.d.ts.map +1 -0
  843. package/dist/local/store/expo/models/ec-one-time-prekey.js +309 -0
  844. package/dist/local/store/expo/models/ec-one-time-prekey.js.map +1 -0
  845. package/dist/local/store/expo/models/ec-signed-prekey.d.ts +189 -0
  846. package/dist/local/store/expo/models/ec-signed-prekey.d.ts.map +1 -0
  847. package/dist/local/store/expo/models/ec-signed-prekey.js +359 -0
  848. package/dist/local/store/expo/models/ec-signed-prekey.js.map +1 -0
  849. package/dist/local/store/expo/models/identity-key-id.d.ts +9 -0
  850. package/dist/local/store/expo/models/identity-key-id.d.ts.map +1 -0
  851. package/dist/local/store/expo/models/identity-key-id.js +10 -0
  852. package/dist/local/store/expo/models/identity-key-id.js.map +1 -0
  853. package/dist/local/store/expo/models/index.d.ts +20 -0
  854. package/dist/local/store/expo/models/index.d.ts.map +1 -0
  855. package/dist/local/store/expo/models/index.js +80 -0
  856. package/dist/local/store/expo/models/index.js.map +1 -0
  857. package/dist/local/store/expo/models/kyber-one-time-prekey.d.ts +183 -0
  858. package/dist/local/store/expo/models/kyber-one-time-prekey.d.ts.map +1 -0
  859. package/dist/local/store/expo/models/kyber-one-time-prekey.js +353 -0
  860. package/dist/local/store/expo/models/kyber-one-time-prekey.js.map +1 -0
  861. package/dist/local/store/expo/models/kyber-prekey-used.d.ts +37 -0
  862. package/dist/local/store/expo/models/kyber-prekey-used.d.ts.map +1 -0
  863. package/dist/local/store/expo/models/kyber-prekey-used.js +59 -0
  864. package/dist/local/store/expo/models/kyber-prekey-used.js.map +1 -0
  865. package/dist/local/store/expo/models/kyber-prekey.d.ts +172 -0
  866. package/dist/local/store/expo/models/kyber-prekey.d.ts.map +1 -0
  867. package/dist/local/store/expo/models/kyber-prekey.js +314 -0
  868. package/dist/local/store/expo/models/kyber-prekey.js.map +1 -0
  869. package/dist/local/store/expo/models/local-identity.d.ts +52 -0
  870. package/dist/local/store/expo/models/local-identity.d.ts.map +1 -0
  871. package/dist/local/store/expo/models/local-identity.js +166 -0
  872. package/dist/local/store/expo/models/local-identity.js.map +1 -0
  873. package/dist/local/store/expo/models/message-record.d.ts +198 -0
  874. package/dist/local/store/expo/models/message-record.d.ts.map +1 -0
  875. package/dist/local/store/expo/models/message-record.js +298 -0
  876. package/dist/local/store/expo/models/message-record.js.map +1 -0
  877. package/dist/local/store/expo/models/recipient-identity.d.ts +21 -0
  878. package/dist/local/store/expo/models/recipient-identity.d.ts.map +1 -0
  879. package/dist/local/store/expo/models/recipient-identity.js +66 -0
  880. package/dist/local/store/expo/models/recipient-identity.js.map +1 -0
  881. package/dist/local/store/expo/models/replaced-prekey-utils.d.ts +33 -0
  882. package/dist/local/store/expo/models/replaced-prekey-utils.d.ts.map +1 -0
  883. package/dist/local/store/expo/models/replaced-prekey-utils.js +54 -0
  884. package/dist/local/store/expo/models/replaced-prekey-utils.js.map +1 -0
  885. package/dist/local/store/expo/models/sender-key.d.ts +210 -0
  886. package/dist/local/store/expo/models/sender-key.d.ts.map +1 -0
  887. package/dist/local/store/expo/models/sender-key.js +379 -0
  888. package/dist/local/store/expo/models/sender-key.js.map +1 -0
  889. package/dist/local/store/expo/models/session.d.ts +175 -0
  890. package/dist/local/store/expo/models/session.d.ts.map +1 -0
  891. package/dist/local/store/expo/models/session.js +496 -0
  892. package/dist/local/store/expo/models/session.js.map +1 -0
  893. package/dist/local/store/expo/schema.d.ts +1734 -0
  894. package/dist/local/store/expo/schema.d.ts.map +1 -0
  895. package/dist/local/store/expo/schema.js +155 -0
  896. package/dist/local/store/expo/schema.js.map +1 -0
  897. package/dist/local/store/expo/secure-store-options.d.ts +10 -0
  898. package/dist/local/store/expo/secure-store-options.d.ts.map +1 -0
  899. package/dist/local/store/expo/secure-store-options.js +5 -0
  900. package/dist/local/store/expo/secure-store-options.js.map +1 -0
  901. package/dist/local/store/index.d.ts +41 -0
  902. package/dist/local/store/index.d.ts.map +1 -0
  903. package/dist/local/store/index.js +34 -0
  904. package/dist/local/store/index.js.map +1 -0
  905. package/dist/local/store/mock/adapter.d.ts +185 -0
  906. package/dist/local/store/mock/adapter.d.ts.map +1 -0
  907. package/dist/local/store/mock/adapter.js +875 -0
  908. package/dist/local/store/mock/adapter.js.map +1 -0
  909. package/dist/local/store/mock/index.d.ts +10 -0
  910. package/dist/local/store/mock/index.d.ts.map +1 -0
  911. package/dist/local/store/mock/index.js +6 -0
  912. package/dist/local/store/mock/index.js.map +1 -0
  913. package/dist/local/store/node/adapter.d.ts +85 -0
  914. package/dist/local/store/node/adapter.d.ts.map +1 -0
  915. package/dist/local/store/node/adapter.js +274 -0
  916. package/dist/local/store/node/adapter.js.map +1 -0
  917. package/dist/local/store/node/database-encryption.d.ts +109 -0
  918. package/dist/local/store/node/database-encryption.d.ts.map +1 -0
  919. package/dist/local/store/node/database-encryption.js +202 -0
  920. package/dist/local/store/node/database-encryption.js.map +1 -0
  921. package/dist/local/store/node/database-key.d.ts +124 -0
  922. package/dist/local/store/node/database-key.d.ts.map +1 -0
  923. package/dist/local/store/node/database-key.js +264 -0
  924. package/dist/local/store/node/database-key.js.map +1 -0
  925. package/dist/local/store/node/database.d.ts +156 -0
  926. package/dist/local/store/node/database.d.ts.map +1 -0
  927. package/dist/local/store/node/database.js +630 -0
  928. package/dist/local/store/node/database.js.map +1 -0
  929. package/dist/local/store/node/index.d.ts +11 -0
  930. package/dist/local/store/node/index.d.ts.map +1 -0
  931. package/dist/local/store/node/index.js +8 -0
  932. package/dist/local/store/node/index.js.map +1 -0
  933. package/dist/local/store/react-native/adapter.d.ts +240 -0
  934. package/dist/local/store/react-native/adapter.d.ts.map +1 -0
  935. package/dist/local/store/react-native/adapter.js +1108 -0
  936. package/dist/local/store/react-native/adapter.js.map +1 -0
  937. package/dist/local/store/react-native/index.d.ts +19 -0
  938. package/dist/local/store/react-native/index.d.ts.map +1 -0
  939. package/dist/local/store/react-native/index.js +6 -0
  940. package/dist/local/store/react-native/index.js.map +1 -0
  941. package/dist/local/store/react-native/storage.d.ts +39 -0
  942. package/dist/local/store/react-native/storage.d.ts.map +1 -0
  943. package/dist/local/store/react-native/storage.js +2 -0
  944. package/dist/local/store/react-native/storage.js.map +1 -0
  945. package/dist/local/store/session-codec.d.ts +5 -0
  946. package/dist/local/store/session-codec.d.ts.map +1 -0
  947. package/dist/local/store/session-codec.js +42 -0
  948. package/dist/local/store/session-codec.js.map +1 -0
  949. package/dist/local/store/web/adapter.d.ts +190 -0
  950. package/dist/local/store/web/adapter.d.ts.map +1 -0
  951. package/dist/local/store/web/adapter.js +1188 -0
  952. package/dist/local/store/web/adapter.js.map +1 -0
  953. package/dist/local/store/web/index.d.ts +11 -0
  954. package/dist/local/store/web/index.d.ts.map +1 -0
  955. package/dist/local/store/web/index.js +8 -0
  956. package/dist/local/store/web/index.js.map +1 -0
  957. package/dist/local/vault/expo-secure-store.d.ts +10 -0
  958. package/dist/local/vault/expo-secure-store.d.ts.map +1 -0
  959. package/dist/local/vault/expo-secure-store.js +23 -0
  960. package/dist/local/vault/expo-secure-store.js.map +1 -0
  961. package/dist/local/vault/index.d.ts +7 -0
  962. package/dist/local/vault/index.d.ts.map +1 -0
  963. package/dist/local/vault/index.js +2 -0
  964. package/dist/local/vault/index.js.map +1 -0
  965. package/dist/logger.d.ts +18 -0
  966. package/dist/logger.d.ts.map +1 -0
  967. package/dist/logger.js +71 -0
  968. package/dist/logger.js.map +1 -0
  969. package/dist/media/index.d.ts +524 -0
  970. package/dist/media/index.d.ts.map +1 -0
  971. package/dist/media/index.js +2053 -0
  972. package/dist/media/index.js.map +1 -0
  973. package/dist/profile/cipher.d.ts +125 -0
  974. package/dist/profile/cipher.d.ts.map +1 -0
  975. package/dist/profile/cipher.js +197 -0
  976. package/dist/profile/cipher.js.map +1 -0
  977. package/dist/profile/contact-state.d.ts +33 -0
  978. package/dist/profile/contact-state.d.ts.map +1 -0
  979. package/dist/profile/contact-state.js +77 -0
  980. package/dist/profile/contact-state.js.map +1 -0
  981. package/dist/profile/crypto.d.ts +65 -0
  982. package/dist/profile/crypto.d.ts.map +1 -0
  983. package/dist/profile/crypto.js +93 -0
  984. package/dist/profile/crypto.js.map +1 -0
  985. package/dist/profile/index.d.ts +26 -0
  986. package/dist/profile/index.d.ts.map +1 -0
  987. package/dist/profile/index.js +30 -0
  988. package/dist/profile/index.js.map +1 -0
  989. package/dist/profile/profile-key.d.ts +102 -0
  990. package/dist/profile/profile-key.d.ts.map +1 -0
  991. package/dist/profile/profile-key.js +229 -0
  992. package/dist/profile/profile-key.js.map +1 -0
  993. package/dist/profile/storage.d.ts +61 -0
  994. package/dist/profile/storage.d.ts.map +1 -0
  995. package/dist/profile/storage.js +145 -0
  996. package/dist/profile/storage.js.map +1 -0
  997. package/dist/profile/update-service.d.ts +53 -0
  998. package/dist/profile/update-service.d.ts.map +1 -0
  999. package/dist/profile/update-service.js +67 -0
  1000. package/dist/profile/update-service.js.map +1 -0
  1001. package/dist/remote/object-store/convex-r2/index.d.ts +11 -0
  1002. package/dist/remote/object-store/convex-r2/index.d.ts.map +1 -0
  1003. package/dist/remote/object-store/convex-r2/index.js +13 -0
  1004. package/dist/remote/object-store/convex-r2/index.js.map +1 -0
  1005. package/dist/remote/object-store/convex-r2/server/index.d.ts +2 -0
  1006. package/dist/remote/object-store/convex-r2/server/index.d.ts.map +1 -0
  1007. package/dist/remote/object-store/convex-r2/server/index.js +2 -0
  1008. package/dist/remote/object-store/convex-r2/server/index.js.map +1 -0
  1009. package/dist/remote/object-store/convex-r2/server.d.ts +126 -0
  1010. package/dist/remote/object-store/convex-r2/server.d.ts.map +1 -0
  1011. package/dist/remote/object-store/convex-r2/server.js +232 -0
  1012. package/dist/remote/object-store/convex-r2/server.js.map +1 -0
  1013. package/dist/remote/object-store/convex-r2/storage.d.ts +47 -0
  1014. package/dist/remote/object-store/convex-r2/storage.d.ts.map +1 -0
  1015. package/dist/remote/object-store/convex-r2/storage.js +55 -0
  1016. package/dist/remote/object-store/convex-r2/storage.js.map +1 -0
  1017. package/dist/remote/object-store/index.d.ts +8 -0
  1018. package/dist/remote/object-store/index.d.ts.map +1 -0
  1019. package/dist/remote/object-store/index.js +2 -0
  1020. package/dist/remote/object-store/index.js.map +1 -0
  1021. package/dist/remote/object-store/s3/index.d.ts +8 -0
  1022. package/dist/remote/object-store/s3/index.d.ts.map +1 -0
  1023. package/dist/remote/object-store/s3/index.js +10 -0
  1024. package/dist/remote/object-store/s3/index.js.map +1 -0
  1025. package/dist/remote/object-store/s3/storage.d.ts +44 -0
  1026. package/dist/remote/object-store/s3/storage.d.ts.map +1 -0
  1027. package/dist/remote/object-store/s3/storage.js +41 -0
  1028. package/dist/remote/object-store/s3/storage.js.map +1 -0
  1029. package/dist/remote/object-store/types.d.ts +80 -0
  1030. package/dist/remote/object-store/types.d.ts.map +1 -0
  1031. package/dist/remote/object-store/types.js +2 -0
  1032. package/dist/remote/object-store/types.js.map +1 -0
  1033. package/dist/remote/object-store/validation.d.ts +6 -0
  1034. package/dist/remote/object-store/validation.d.ts.map +1 -0
  1035. package/dist/remote/object-store/validation.js +93 -0
  1036. package/dist/remote/object-store/validation.js.map +1 -0
  1037. package/dist/remote/relay/convex/group-server.d.ts +118 -0
  1038. package/dist/remote/relay/convex/group-server.d.ts.map +1 -0
  1039. package/dist/remote/relay/convex/group-server.js +150 -0
  1040. package/dist/remote/relay/convex/group-server.js.map +1 -0
  1041. package/dist/remote/relay/convex/index.d.ts +39 -0
  1042. package/dist/remote/relay/convex/index.d.ts.map +1 -0
  1043. package/dist/remote/relay/convex/index.js +36 -0
  1044. package/dist/remote/relay/convex/index.js.map +1 -0
  1045. package/dist/remote/relay/convex/relay.d.ts +339 -0
  1046. package/dist/remote/relay/convex/relay.d.ts.map +1 -0
  1047. package/dist/remote/relay/convex/relay.js +1086 -0
  1048. package/dist/remote/relay/convex/relay.js.map +1 -0
  1049. package/dist/remote/relay/convex/types.d.ts +111 -0
  1050. package/dist/remote/relay/convex/types.d.ts.map +1 -0
  1051. package/dist/remote/relay/convex/types.js +19 -0
  1052. package/dist/remote/relay/convex/types.js.map +1 -0
  1053. package/dist/remote/relay/index.d.ts +34 -0
  1054. package/dist/remote/relay/index.d.ts.map +1 -0
  1055. package/dist/remote/relay/index.js +28 -0
  1056. package/dist/remote/relay/index.js.map +1 -0
  1057. package/dist/remote/relay/mock/adapter.d.ts +237 -0
  1058. package/dist/remote/relay/mock/adapter.d.ts.map +1 -0
  1059. package/dist/remote/relay/mock/adapter.js +939 -0
  1060. package/dist/remote/relay/mock/adapter.js.map +1 -0
  1061. package/dist/remote/relay/mock/index.d.ts +10 -0
  1062. package/dist/remote/relay/mock/index.d.ts.map +1 -0
  1063. package/dist/remote/relay/mock/index.js +6 -0
  1064. package/dist/remote/relay/mock/index.js.map +1 -0
  1065. package/dist/remote/relay/types.d.ts +756 -0
  1066. package/dist/remote/relay/types.d.ts.map +1 -0
  1067. package/dist/remote/relay/types.js +11 -0
  1068. package/dist/remote/relay/types.js.map +1 -0
  1069. package/dist/safety/core.d.ts +108 -0
  1070. package/dist/safety/core.d.ts.map +1 -0
  1071. package/dist/safety/core.js +299 -0
  1072. package/dist/safety/core.js.map +1 -0
  1073. package/dist/safety/fingerprint.d.ts +277 -0
  1074. package/dist/safety/fingerprint.d.ts.map +1 -0
  1075. package/dist/safety/fingerprint.js +339 -0
  1076. package/dist/safety/fingerprint.js.map +1 -0
  1077. package/dist/safety/index.d.ts +141 -0
  1078. package/dist/safety/index.d.ts.map +1 -0
  1079. package/dist/safety/index.js +230 -0
  1080. package/dist/safety/index.js.map +1 -0
  1081. package/dist/safety/protobuf.d.ts +34 -0
  1082. package/dist/safety/protobuf.d.ts.map +1 -0
  1083. package/dist/safety/protobuf.js +142 -0
  1084. package/dist/safety/protobuf.js.map +1 -0
  1085. package/dist/safety/url.d.ts +133 -0
  1086. package/dist/safety/url.d.ts.map +1 -0
  1087. package/dist/safety/url.js +242 -0
  1088. package/dist/safety/url.js.map +1 -0
  1089. package/dist/sealed-sender/index.d.ts +7 -0
  1090. package/dist/sealed-sender/index.d.ts.map +1 -0
  1091. package/dist/sealed-sender/index.js +6 -0
  1092. package/dist/sealed-sender/index.js.map +1 -0
  1093. package/dist/server-clock.d.ts +10 -0
  1094. package/dist/server-clock.d.ts.map +1 -0
  1095. package/dist/server-clock.js +27 -0
  1096. package/dist/server-clock.js.map +1 -0
  1097. package/dist/types/address.d.ts +171 -0
  1098. package/dist/types/address.d.ts.map +1 -0
  1099. package/dist/types/address.js +241 -0
  1100. package/dist/types/address.js.map +1 -0
  1101. package/dist/types/api.d.ts +1222 -0
  1102. package/dist/types/api.d.ts.map +1 -0
  1103. package/dist/types/api.js +5 -0
  1104. package/dist/types/api.js.map +1 -0
  1105. package/dist/types/errors.d.ts +772 -0
  1106. package/dist/types/errors.d.ts.map +1 -0
  1107. package/dist/types/errors.js +937 -0
  1108. package/dist/types/errors.js.map +1 -0
  1109. package/dist/types/index.d.ts +20 -0
  1110. package/dist/types/index.d.ts.map +1 -0
  1111. package/dist/types/index.js +33 -0
  1112. package/dist/types/index.js.map +1 -0
  1113. package/dist/types/messages.d.ts +257 -0
  1114. package/dist/types/messages.d.ts.map +1 -0
  1115. package/dist/types/messages.js +96 -0
  1116. package/dist/types/messages.js.map +1 -0
  1117. package/dist/types/protocol-config.d.ts +337 -0
  1118. package/dist/types/protocol-config.d.ts.map +1 -0
  1119. package/dist/types/protocol-config.js +178 -0
  1120. package/dist/types/protocol-config.js.map +1 -0
  1121. package/dist/types/protocol-constants.d.ts +122 -0
  1122. package/dist/types/protocol-constants.d.ts.map +1 -0
  1123. package/dist/types/protocol-constants.js +115 -0
  1124. package/dist/types/protocol-constants.js.map +1 -0
  1125. package/dist/types/session.d.ts +721 -0
  1126. package/dist/types/session.d.ts.map +1 -0
  1127. package/dist/types/session.js +340 -0
  1128. package/dist/types/session.js.map +1 -0
  1129. package/dist/types/trust.d.ts +168 -0
  1130. package/dist/types/trust.d.ts.map +1 -0
  1131. package/dist/types/trust.js +84 -0
  1132. package/dist/types/trust.js.map +1 -0
  1133. package/dist/types/utils.d.ts +93 -0
  1134. package/dist/types/utils.d.ts.map +1 -0
  1135. package/dist/types/utils.js +89 -0
  1136. package/dist/types/utils.js.map +1 -0
  1137. package/dist/username/index.d.ts +12 -0
  1138. package/dist/username/index.d.ts.map +1 -0
  1139. package/dist/username/index.js +11 -0
  1140. package/dist/username/index.js.map +1 -0
  1141. package/dist/username/link.d.ts +52 -0
  1142. package/dist/username/link.d.ts.map +1 -0
  1143. package/dist/username/link.js +87 -0
  1144. package/dist/username/link.js.map +1 -0
  1145. package/dist/utils/binary-transfer.d.ts +18 -0
  1146. package/dist/utils/binary-transfer.d.ts.map +1 -0
  1147. package/dist/utils/binary-transfer.js +27 -0
  1148. package/dist/utils/binary-transfer.js.map +1 -0
  1149. package/dist/utils/errors.d.ts +9 -0
  1150. package/dist/utils/errors.d.ts.map +1 -0
  1151. package/dist/utils/errors.js +15 -0
  1152. package/dist/utils/errors.js.map +1 -0
  1153. package/dist/utils/retry.d.ts +59 -0
  1154. package/dist/utils/retry.d.ts.map +1 -0
  1155. package/dist/utils/retry.js +136 -0
  1156. package/dist/utils/retry.js.map +1 -0
  1157. package/dist/versions.d.ts +62 -0
  1158. package/dist/versions.d.ts.map +1 -0
  1159. package/dist/versions.js +78 -0
  1160. package/dist/versions.js.map +1 -0
  1161. package/dist/zk/credentials.d.ts +10 -0
  1162. package/dist/zk/credentials.d.ts.map +1 -0
  1163. package/dist/zk/credentials.js +9 -0
  1164. package/dist/zk/credentials.js.map +1 -0
  1165. package/dist/zk/groups.d.ts +12 -0
  1166. package/dist/zk/groups.d.ts.map +1 -0
  1167. package/dist/zk/groups.js +11 -0
  1168. package/dist/zk/groups.js.map +1 -0
  1169. package/docs/ASSURANCE.md +102 -0
  1170. package/docs/CLIENT_COMPOSITION.md +189 -0
  1171. package/docs/DOCUMENTATION_STANDARDS.md +107 -0
  1172. package/docs/E2EE.md +35 -0
  1173. package/docs/ERROR_HANDLING.md +396 -0
  1174. package/docs/GETTING_STARTED.md +714 -0
  1175. package/docs/INTERFACES.md +187 -0
  1176. package/docs/PACKAGE_SURFACE.md +235 -0
  1177. package/docs/PROTOCOL_POLICY.md +109 -0
  1178. package/docs/RECIPES.md +389 -0
  1179. package/docs/SECURITY.md +199 -0
  1180. package/docs/api/README.md +471 -0
  1181. package/docs/api/classes/EncryptionError.md +112 -0
  1182. package/docs/api/classes/EndorsementManager.md +307 -0
  1183. package/docs/api/classes/SealedSenderAuthError.md +127 -0
  1184. package/docs/api/classes/ServerDerivedKeyPair.md +68 -0
  1185. package/docs/api/classes/ServerDerivedPublicKey.md +33 -0
  1186. package/docs/api/classes/ServerRootKeyPair.md +94 -0
  1187. package/docs/api/classes/ServerRootPublicKey.md +72 -0
  1188. package/docs/api/classes/SignalBlockingManager.md +106 -0
  1189. package/docs/api/classes/SignalProtocolClient.md +2651 -0
  1190. package/docs/api/classes/VerificationFailure.md +25 -0
  1191. package/docs/api/enumerations/ContentHint.md +63 -0
  1192. package/docs/api/enumerations/EncryptionErrorCode.md +488 -0
  1193. package/docs/api/enumerations/IdentityKeyChange.md +65 -0
  1194. package/docs/api/enumerations/MessageType.md +29 -0
  1195. package/docs/api/enumerations/TrustDirection.md +33 -0
  1196. package/docs/api/enumerations/TypingAction.md +31 -0
  1197. package/docs/api/functions/createDefaultSignalContentAdapter.md +13 -0
  1198. package/docs/api/functions/createDefaultSignalLogger.md +36 -0
  1199. package/docs/api/functions/createGroupId.md +32 -0
  1200. package/docs/api/functions/createSignalProtocolClient.md +36 -0
  1201. package/docs/api/functions/createSignalProtocolClientConfig.md +24 -0
  1202. package/docs/api/functions/extractGroupId.md +32 -0
  1203. package/docs/api/functions/formatVersion.md +25 -0
  1204. package/docs/api/functions/isCompatible.md +31 -0
  1205. package/docs/api/functions/isGroupId.md +37 -0
  1206. package/docs/api/functions/isSealedSenderAuthError.md +25 -0
  1207. package/docs/api/functions/parseVersion.md +29 -0
  1208. package/docs/api/functions/resolveSPQRLimits.md +21 -0
  1209. package/docs/api/functions/resolveSignalLogger.md +42 -0
  1210. package/docs/api/interfaces/AccountIdentityProvisioning.md +43 -0
  1211. package/docs/api/interfaces/AccountIdentityRotation.md +69 -0
  1212. package/docs/api/interfaces/AttachmentTransferOptions.md +49 -0
  1213. package/docs/api/interfaces/BlockedRecipientEntry.md +25 -0
  1214. package/docs/api/interfaces/BlockedRecipientsSyncInput.md +27 -0
  1215. package/docs/api/interfaces/ConfigurationSyncInput.md +19 -0
  1216. package/docs/api/interfaces/CredentialPublicKey.md +25 -0
  1217. package/docs/api/interfaces/DataMessageInput.md +21 -0
  1218. package/docs/api/interfaces/DecryptedEnvelope.md +95 -0
  1219. package/docs/api/interfaces/DecryptedGroup.md +86 -0
  1220. package/docs/api/interfaces/DeviceInfo.md +79 -0
  1221. package/docs/api/interfaces/DeviceRecord.md +87 -0
  1222. package/docs/api/interfaces/DeviceRegistration.md +27 -0
  1223. package/docs/api/interfaces/DoubleRatchetConfig.md +36 -0
  1224. package/docs/api/interfaces/EcOneTimePreKey.md +27 -0
  1225. package/docs/api/interfaces/EcSignedPreKey.md +39 -0
  1226. package/docs/api/interfaces/EcSignedPreKeyUpload.md +50 -0
  1227. package/docs/api/interfaces/EncryptionErrorContext.md +51 -0
  1228. package/docs/api/interfaces/Envelope.md +154 -0
  1229. package/docs/api/interfaces/ForceKeyResetResult.md +37 -0
  1230. package/docs/api/interfaces/GroupAuthorization.md +23 -0
  1231. package/docs/api/interfaces/GroupChangeEntry.md +42 -0
  1232. package/docs/api/interfaces/GroupMemberDevice.md +26 -0
  1233. package/docs/api/interfaces/IEcOneTimePreKeyStore.md +86 -0
  1234. package/docs/api/interfaces/IEcSignedPreKeyStore.md +132 -0
  1235. package/docs/api/interfaces/IGroupServer.md +120 -0
  1236. package/docs/api/interfaces/IGroupStateStore.md +128 -0
  1237. package/docs/api/interfaces/IIdentityKeyStore.md +312 -0
  1238. package/docs/api/interfaces/IKemPreKeyStore.md +144 -0
  1239. package/docs/api/interfaces/IKyberLastResortPreKeyStore.md +111 -0
  1240. package/docs/api/interfaces/ILogger.md +117 -0
  1241. package/docs/api/interfaces/IProtocolStore.md +1033 -0
  1242. package/docs/api/interfaces/ISenderKeyStore.md +417 -0
  1243. package/docs/api/interfaces/ISesameStore.md +249 -0
  1244. package/docs/api/interfaces/ISessionStore.md +178 -0
  1245. package/docs/api/interfaces/ISignalLocalSecretVault.md +71 -0
  1246. package/docs/api/interfaces/ISignalLocalStore.md +2053 -0
  1247. package/docs/api/interfaces/ISignalProtocolClient.md +1183 -0
  1248. package/docs/api/interfaces/ISignalProtocolManager.md +272 -0
  1249. package/docs/api/interfaces/ISignalRelayServer.md +1329 -0
  1250. package/docs/api/interfaces/IdentityKeyPair.md +49 -0
  1251. package/docs/api/interfaces/IncomingEnvelope.md +91 -0
  1252. package/docs/api/interfaces/InspectedSignalContent.md +43 -0
  1253. package/docs/api/interfaces/KDFChain.md +31 -0
  1254. package/docs/api/interfaces/KemLastResortPreKeyUpload.md +50 -0
  1255. package/docs/api/interfaces/KeyPair.md +23 -0
  1256. package/docs/api/interfaces/KyberPreKey.md +42 -0
  1257. package/docs/api/interfaces/MLKEMBraidAgentState.md +191 -0
  1258. package/docs/api/interfaces/MLKEMBraidMessage.md +49 -0
  1259. package/docs/api/interfaces/MediaAttachmentDeleteSyncInput.md +31 -0
  1260. package/docs/api/interfaces/MessageHeader.md +49 -0
  1261. package/docs/api/interfaces/MessageRecord.md +86 -0
  1262. package/docs/api/interfaces/ParsedReceiptContent.md +19 -0
  1263. package/docs/api/interfaces/ParsedTypingContent.md +19 -0
  1264. package/docs/api/interfaces/PreKeyMaintenanceStore.md +87 -0
  1265. package/docs/api/interfaces/PreKeyMessage.md +159 -0
  1266. package/docs/api/interfaces/PreKeyStatusResult.md +21 -0
  1267. package/docs/api/interfaces/PreKeyUpload.md +42 -0
  1268. package/docs/api/interfaces/ProcessEnvelopeOptions.md +72 -0
  1269. package/docs/api/interfaces/ProtocolAddress.md +38 -0
  1270. package/docs/api/interfaces/ProtocolStrategyConfig.md +91 -0
  1271. package/docs/api/interfaces/RatchetMessage.md +96 -0
  1272. package/docs/api/interfaces/ReadSyncEntryInput.md +19 -0
  1273. package/docs/api/interfaces/ReceiverChain.md +43 -0
  1274. package/docs/api/interfaces/RecipientUsernameSyncInput.md +31 -0
  1275. package/docs/api/interfaces/RelayPreKeyBundle.md +254 -0
  1276. package/docs/api/interfaces/RemoteObjectDownload.md +33 -0
  1277. package/docs/api/interfaces/RemoteObjectUpload.md +49 -0
  1278. package/docs/api/interfaces/ResolvedSPQRInfoStrings.md +27 -0
  1279. package/docs/api/interfaces/ResolvedSPQRLimits.md +37 -0
  1280. package/docs/api/interfaces/RetryRequest.md +80 -0
  1281. package/docs/api/interfaces/SCKAState.md +65 -0
  1282. package/docs/api/interfaces/SPQRLimits.md +40 -0
  1283. package/docs/api/interfaces/SPQRState.md +191 -0
  1284. package/docs/api/interfaces/SafetyNumber.md +60 -0
  1285. package/docs/api/interfaces/SafetyNumberConfirmation.md +46 -0
  1286. package/docs/api/interfaces/SealedSenderConfig.md +70 -0
  1287. package/docs/api/interfaces/SendOptions.md +191 -0
  1288. package/docs/api/interfaces/SendResult.md +93 -0
  1289. package/docs/api/interfaces/SenderKeyDistributionMessage.md +43 -0
  1290. package/docs/api/interfaces/SenderKeyState.md +76 -0
  1291. package/docs/api/interfaces/SenderKeysConfig.md +65 -0
  1292. package/docs/api/interfaces/SentSyncTranscriptInput.md +31 -0
  1293. package/docs/api/interfaces/ServiceId.md +19 -0
  1294. package/docs/api/interfaces/SesameMessage.md +84 -0
  1295. package/docs/api/interfaces/SesameStats.md +57 -0
  1296. package/docs/api/interfaces/SessionHealthResult.md +120 -0
  1297. package/docs/api/interfaces/SessionRecord.md +80 -0
  1298. package/docs/api/interfaces/SessionRecordMetadata.md +109 -0
  1299. package/docs/api/interfaces/SessionState.md +368 -0
  1300. package/docs/api/interfaces/SessionTrustCommit.md +58 -0
  1301. package/docs/api/interfaces/SignalBlockingHooks.md +44 -0
  1302. package/docs/api/interfaces/SignalBlockingManagerOptions.md +31 -0
  1303. package/docs/api/interfaces/SignalBlockingMirror.md +30 -0
  1304. package/docs/api/interfaces/SignalBlockingStore.md +83 -0
  1305. package/docs/api/interfaces/SignalContentAdapter.md +325 -0
  1306. package/docs/api/interfaces/SignalProtocolClientAdapterConfig.md +44 -0
  1307. package/docs/api/interfaces/SignalProtocolClientCompositionOptions.md +693 -0
  1308. package/docs/api/interfaces/SignalProtocolClientConfig.md +839 -0
  1309. package/docs/api/interfaces/SignalProtocolClientDeleteLocalAttachmentInput.md +25 -0
  1310. package/docs/api/interfaces/SignalProtocolClientHooks.md +506 -0
  1311. package/docs/api/interfaces/SignalProtocolClientIdentityConfig.md +35 -0
  1312. package/docs/api/interfaces/SignalProtocolClientLoadLocalAttachmentInput.md +187 -0
  1313. package/docs/api/interfaces/SignalProtocolClientLoadedLocalAttachment.md +19 -0
  1314. package/docs/api/interfaces/SignalProtocolClientMedia.md +83 -0
  1315. package/docs/api/interfaces/SignalProtocolClientMediaCompletedResult.md +25 -0
  1316. package/docs/api/interfaces/SignalProtocolClientMediaConfig.md +157 -0
  1317. package/docs/api/interfaces/SignalProtocolClientMediaDownloadCompletedResult.md +37 -0
  1318. package/docs/api/interfaces/SignalProtocolClientMediaDownloadNotNeededResult.md +25 -0
  1319. package/docs/api/interfaces/SignalProtocolClientMediaFailedResult.md +19 -0
  1320. package/docs/api/interfaces/SignalProtocolClientMediaOperationOptions.md +53 -0
  1321. package/docs/api/interfaces/SignalProtocolClientMediaPendingResult.md +19 -0
  1322. package/docs/api/interfaces/SignalProtocolClientMediaProcessResult.md +43 -0
  1323. package/docs/api/interfaces/SignalProtocolClientMediaSkippedResult.md +25 -0
  1324. package/docs/api/interfaces/SignalProtocolClientMediaUploadCompletedResult.md +31 -0
  1325. package/docs/api/interfaces/SignalProtocolClientProcessPendingMediaOptions.md +87 -0
  1326. package/docs/api/interfaces/SignalProtocolClientSaveDownloadedAttachmentInput.md +25 -0
  1327. package/docs/api/interfaces/SignalProtocolClientSaveUploadedAttachmentInput.md +25 -0
  1328. package/docs/api/interfaces/SignalProtocolClientSyncDeleteInput.md +19 -0
  1329. package/docs/api/interfaces/SignalProtocolConfig.md +50 -0
  1330. package/docs/api/interfaces/SignalRemoteObjectStore.md +88 -0
  1331. package/docs/api/interfaces/SkippedSenderMessageKey.md +26 -0
  1332. package/docs/api/interfaces/TaskNotificationAckSyncInput.md +31 -0
  1333. package/docs/api/interfaces/TripleRatchetState.md +64 -0
  1334. package/docs/api/interfaces/UserRecord.md +71 -0
  1335. package/docs/api/interfaces/UsernameStateSyncInput.md +19 -0
  1336. package/docs/api/interfaces/VerificationStateSyncInput.md +31 -0
  1337. package/docs/api/interfaces/VersionNegotiationState.md +84 -0
  1338. package/docs/api/interfaces/ViewOnceOpenSyncInput.md +19 -0
  1339. package/docs/api/namespaces/ProtocolAddress/README.md +33 -0
  1340. package/docs/api/namespaces/ProtocolAddress/functions/create.md +41 -0
  1341. package/docs/api/namespaces/ProtocolAddress/functions/equals.md +39 -0
  1342. package/docs/api/namespaces/ProtocolAddress/functions/fromStorageKey.md +36 -0
  1343. package/docs/api/namespaces/ProtocolAddress/functions/isUser.md +39 -0
  1344. package/docs/api/namespaces/ProtocolAddress/functions/isValid.md +34 -0
  1345. package/docs/api/namespaces/ProtocolAddress/functions/parse.md +41 -0
  1346. package/docs/api/namespaces/ProtocolAddress/functions/toStorageKey.md +38 -0
  1347. package/docs/api/namespaces/ProtocolAddress/functions/toString.md +34 -0
  1348. package/docs/api/namespaces/SessionRecord/README.md +30 -0
  1349. package/docs/api/namespaces/SessionRecord/functions/archiveCurrent.md +40 -0
  1350. package/docs/api/namespaces/SessionRecord/functions/archiveCurrentState.md +34 -0
  1351. package/docs/api/namespaces/SessionRecord/functions/create.md +25 -0
  1352. package/docs/api/namespaces/SessionRecord/functions/deserialize.md +29 -0
  1353. package/docs/api/namespaces/SessionRecord/functions/findSession.md +34 -0
  1354. package/docs/api/namespaces/SessionRecord/functions/getAllSessions.md +25 -0
  1355. package/docs/api/namespaces/SessionRecord/functions/getArchivedCount.md +25 -0
  1356. package/docs/api/namespaces/SessionRecord/functions/hasCurrentSession.md +25 -0
  1357. package/docs/api/namespaces/SessionRecord/functions/hasUsableSenderChain.md +36 -0
  1358. package/docs/api/namespaces/SessionRecord/functions/promoteSession.md +34 -0
  1359. package/docs/api/namespaces/SessionRecord/functions/serialize.md +28 -0
  1360. package/docs/api/namespaces/SessionRecord/variables/MAX_ARCHIVED_SESSIONS.md +14 -0
  1361. package/docs/api/namespaces/SessionState/README.md +15 -0
  1362. package/docs/api/namespaces/SessionState/functions/getSessionId.md +32 -0
  1363. package/docs/api/namespaces/blocking/README.md +43 -0
  1364. package/docs/api/namespaces/encoding/README.md +33 -0
  1365. package/docs/api/namespaces/encoding/functions/base64ToUrlSafe.md +28 -0
  1366. package/docs/api/namespaces/encoding/functions/bytesToBase64.md +21 -0
  1367. package/docs/api/namespaces/encoding/functions/bytesToString.md +21 -0
  1368. package/docs/api/namespaces/encoding/functions/bytesToUrlSafeBase64.md +33 -0
  1369. package/docs/api/namespaces/encoding/functions/concatBytes.md +21 -0
  1370. package/docs/api/namespaces/encoding/functions/stringToBytes.md +21 -0
  1371. package/docs/api/namespaces/encoding/functions/urlSafeToBase64.md +27 -0
  1372. package/docs/api/namespaces/keys/README.md +126 -0
  1373. package/docs/api/namespaces/keys/functions/acceptContactIdentityRotation.md +33 -0
  1374. package/docs/api/namespaces/keys/functions/assertIdentityCommitment.md +25 -0
  1375. package/docs/api/namespaces/keys/functions/compositeIdentitiesEqual.md +23 -0
  1376. package/docs/api/namespaces/keys/functions/createCompositeIdentityV1.md +19 -0
  1377. package/docs/api/namespaces/keys/functions/createPreKeySignatureContext.md +31 -0
  1378. package/docs/api/namespaces/keys/functions/createUnverifiedContactIdentityRecord.md +23 -0
  1379. package/docs/api/namespaces/keys/functions/decodeCompositeIdentityV1.md +19 -0
  1380. package/docs/api/namespaces/keys/functions/deriveIdentityCommitment.md +19 -0
  1381. package/docs/api/namespaces/keys/functions/encodeCompositeIdentityV1.md +19 -0
  1382. package/docs/api/namespaces/keys/functions/evaluateContactIdentityCandidate.md +27 -0
  1383. package/docs/api/namespaces/keys/functions/generateEcOneTimePreKeys.md +37 -0
  1384. package/docs/api/namespaces/keys/functions/generateEcSignedPreKey.md +39 -0
  1385. package/docs/api/namespaces/keys/functions/generateEcSignedPreKeyId.md +21 -0
  1386. package/docs/api/namespaces/keys/functions/generateIdentityKeyPair.md +24 -0
  1387. package/docs/api/namespaces/keys/functions/generateKemOneTimePreKeys.md +47 -0
  1388. package/docs/api/namespaces/keys/functions/generateKyberLastResortPreKey.md +37 -0
  1389. package/docs/api/namespaces/keys/functions/generateRegistrationId.md +13 -0
  1390. package/docs/api/namespaces/keys/functions/signMlKem1024PreKey.md +29 -0
  1391. package/docs/api/namespaces/keys/functions/signPreKey.md +31 -0
  1392. package/docs/api/namespaces/keys/functions/validateContactIdentityRecord.md +19 -0
  1393. package/docs/api/namespaces/keys/functions/verifyContactIdentityRecord.md +31 -0
  1394. package/docs/api/namespaces/keys/functions/verifyMlKem1024PreKey.md +33 -0
  1395. package/docs/api/namespaces/keys/functions/verifyPreKeySignature.md +35 -0
  1396. package/docs/api/namespaces/keys/interfaces/CompositeIdentityV1.md +33 -0
  1397. package/docs/api/namespaces/keys/interfaces/ContactIdentityRecord.md +53 -0
  1398. package/docs/api/namespaces/keys/interfaces/KemOneTimePreKey.md +43 -0
  1399. package/docs/api/namespaces/keys/type-aliases/IdentityCandidateStatus.md +9 -0
  1400. package/docs/api/namespaces/keys/type-aliases/IdentityTrustState.md +9 -0
  1401. package/docs/api/namespaces/keys/type-aliases/IdentityType.md +9 -0
  1402. package/docs/api/namespaces/keys/variables/COMPOSITE_IDENTITY_V1_ED25519_TAG.md +9 -0
  1403. package/docs/api/namespaces/keys/variables/COMPOSITE_IDENTITY_V1_LENGTH.md +9 -0
  1404. package/docs/api/namespaces/keys/variables/COMPOSITE_IDENTITY_V1_VERSION.md +9 -0
  1405. package/docs/api/namespaces/keys/variables/COMPOSITE_IDENTITY_V1_X25519_TAG.md +9 -0
  1406. package/docs/api/namespaces/keys/variables/IDENTITY_COMMITMENT_V1_DOMAIN.md +9 -0
  1407. package/docs/api/namespaces/keys/variables/PREKEY_ALGORITHM_ML_KEM_1024.md +9 -0
  1408. package/docs/api/namespaces/keys/variables/PREKEY_ALGORITHM_X25519.md +9 -0
  1409. package/docs/api/namespaces/keys/variables/PREKEY_SIGNATURE_V1_DOMAIN.md +9 -0
  1410. package/docs/api/namespaces/media/README.md +105 -0
  1411. package/docs/api/namespaces/media/classes/MediaAttachmentError.md +57 -0
  1412. package/docs/api/namespaces/media/functions/createByteRangeMediaAttachmentTransfer.md +19 -0
  1413. package/docs/api/namespaces/media/functions/createMediaAttachmentDeliveryId.md +29 -0
  1414. package/docs/api/namespaces/media/functions/createMediaAttachmentId.md +19 -0
  1415. package/docs/api/namespaces/media/functions/createMediaAttachmentMessage.md +25 -0
  1416. package/docs/api/namespaces/media/functions/createMediaAttachmentPointer.md +19 -0
  1417. package/docs/api/namespaces/media/functions/createTusMediaAttachmentTransfer.md +19 -0
  1418. package/docs/api/namespaces/media/functions/deleteMediaAttachment.md +23 -0
  1419. package/docs/api/namespaces/media/functions/executeMediaAttachmentJob.md +23 -0
  1420. package/docs/api/namespaces/media/functions/isMediaAttachmentFlagSet.md +19 -0
  1421. package/docs/api/namespaces/media/functions/parseMediaAttachmentMessage.md +19 -0
  1422. package/docs/api/namespaces/media/functions/planMediaAttachmentCleanup.md +23 -0
  1423. package/docs/api/namespaces/media/functions/planMediaAttachmentCleanupJobs.md +19 -0
  1424. package/docs/api/namespaces/media/functions/planMediaAttachmentDeleteSync.md +19 -0
  1425. package/docs/api/namespaces/media/functions/planMediaAttachmentDownloadJob.md +19 -0
  1426. package/docs/api/namespaces/media/functions/planMediaAttachmentOpen.md +19 -0
  1427. package/docs/api/namespaces/media/functions/planMediaAttachmentProcessing.md +19 -0
  1428. package/docs/api/namespaces/media/functions/planMediaAttachmentUploadJob.md +19 -0
  1429. package/docs/api/namespaces/media/functions/prepareMediaAttachmentUpload.md +30 -0
  1430. package/docs/api/namespaces/media/functions/resolveMediaAttachment.md +30 -0
  1431. package/docs/api/namespaces/media/functions/serializeMediaAttachmentMessage.md +25 -0
  1432. package/docs/api/namespaces/media/functions/validateMediaAttachmentPolicy.md +23 -0
  1433. package/docs/api/namespaces/media/interfaces/ByteRangeMediaAttachmentPartialStore.md +68 -0
  1434. package/docs/api/namespaces/media/interfaces/ByteRangeMediaAttachmentTransferOptions.md +91 -0
  1435. package/docs/api/namespaces/media/interfaces/DeleteMediaAttachmentOptions.md +25 -0
  1436. package/docs/api/namespaces/media/interfaces/DeleteMediaAttachmentResult.md +19 -0
  1437. package/docs/api/namespaces/media/interfaces/ExecuteMediaAttachmentJobOptions.md +157 -0
  1438. package/docs/api/namespaces/media/interfaces/MediaAttachmentBackgroundJob.md +85 -0
  1439. package/docs/api/namespaces/media/interfaces/MediaAttachmentCleanupPlan.md +37 -0
  1440. package/docs/api/namespaces/media/interfaces/MediaAttachmentJobExecutionResult.md +55 -0
  1441. package/docs/api/namespaces/media/interfaces/MediaAttachmentMessage.md +31 -0
  1442. package/docs/api/namespaces/media/interfaces/MediaAttachmentOpenDecision.md +31 -0
  1443. package/docs/api/namespaces/media/interfaces/MediaAttachmentPointer.md +133 -0
  1444. package/docs/api/namespaces/media/interfaces/MediaAttachmentPolicy.md +67 -0
  1445. package/docs/api/namespaces/media/interfaces/MediaAttachmentProcessingPlan.md +73 -0
  1446. package/docs/api/namespaces/media/interfaces/MediaAttachmentProgress.md +69 -0
  1447. package/docs/api/namespaces/media/interfaces/MediaAttachmentResumeState.md +37 -0
  1448. package/docs/api/namespaces/media/interfaces/MediaAttachmentRetryOptions.md +31 -0
  1449. package/docs/api/namespaces/media/interfaces/MediaAttachmentTransfer.md +51 -0
  1450. package/docs/api/namespaces/media/interfaces/MediaAttachmentTransferCheckpoint.md +69 -0
  1451. package/docs/api/namespaces/media/interfaces/MediaAttachmentTransferOptions.md +67 -0
  1452. package/docs/api/namespaces/media/interfaces/MediaAttachmentUploadJobData.md +19 -0
  1453. package/docs/api/namespaces/media/interfaces/MediaAttachmentUploadResponse.md +25 -0
  1454. package/docs/api/namespaces/media/interfaces/PlanMediaAttachmentCleanupJobsInput.md +61 -0
  1455. package/docs/api/namespaces/media/interfaces/PlanMediaAttachmentDeleteSyncInput.md +25 -0
  1456. package/docs/api/namespaces/media/interfaces/PlanMediaAttachmentDownloadJobInput.md +161 -0
  1457. package/docs/api/namespaces/media/interfaces/PlanMediaAttachmentOpenInput.md +25 -0
  1458. package/docs/api/namespaces/media/interfaces/PlanMediaAttachmentProcessingInput.md +83 -0
  1459. package/docs/api/namespaces/media/interfaces/PlanMediaAttachmentUploadJobInput.md +147 -0
  1460. package/docs/api/namespaces/media/interfaces/PrepareMediaAttachmentUploadOptions.md +144 -0
  1461. package/docs/api/namespaces/media/interfaces/ResolveMediaAttachmentOptions.md +55 -0
  1462. package/docs/api/namespaces/media/interfaces/ResolvedMediaAttachment.md +109 -0
  1463. package/docs/api/namespaces/media/interfaces/TusMediaAttachmentTransferOptions.md +85 -0
  1464. package/docs/api/namespaces/media/type-aliases/CreateMediaAttachmentPointerInput.md +15 -0
  1465. package/docs/api/namespaces/media/type-aliases/MediaAttachmentCheckpointCallback.md +19 -0
  1466. package/docs/api/namespaces/media/type-aliases/MediaAttachmentCleanupReason.md +9 -0
  1467. package/docs/api/namespaces/media/type-aliases/MediaAttachmentErrorCode.md +9 -0
  1468. package/docs/api/namespaces/media/type-aliases/MediaAttachmentFlag.md +9 -0
  1469. package/docs/api/namespaces/media/type-aliases/MediaAttachmentJobExecutionStatus.md +9 -0
  1470. package/docs/api/namespaces/media/type-aliases/MediaAttachmentJobOperation.md +9 -0
  1471. package/docs/api/namespaces/media/type-aliases/MediaAttachmentJobPriority.md +9 -0
  1472. package/docs/api/namespaces/media/type-aliases/MediaAttachmentJobSkipReason.md +9 -0
  1473. package/docs/api/namespaces/media/type-aliases/MediaAttachmentJobSource.md +9 -0
  1474. package/docs/api/namespaces/media/type-aliases/MediaAttachmentKnownIds.md +9 -0
  1475. package/docs/api/namespaces/media/type-aliases/MediaAttachmentMessageType.md +9 -0
  1476. package/docs/api/namespaces/media/type-aliases/MediaAttachmentProgressCallback.md +19 -0
  1477. package/docs/api/namespaces/media/variables/MEDIA_ATTACHMENT_POLICY_DEFAULTS.md +47 -0
  1478. package/docs/api/namespaces/media/variables/MEDIA_ATTACHMENT_POLICY_PRESETS.md +95 -0
  1479. package/docs/api/namespaces/media/variables/MediaAttachmentCleanupReason.md +27 -0
  1480. package/docs/api/namespaces/media/variables/MediaAttachmentErrorCode.md +75 -0
  1481. package/docs/api/namespaces/media/variables/MediaAttachmentFlag.md +23 -0
  1482. package/docs/api/namespaces/media/variables/MediaAttachmentJobExecutionStatus.md +19 -0
  1483. package/docs/api/namespaces/media/variables/MediaAttachmentJobOperation.md +31 -0
  1484. package/docs/api/namespaces/media/variables/MediaAttachmentJobPriority.md +23 -0
  1485. package/docs/api/namespaces/media/variables/MediaAttachmentJobSource.md +51 -0
  1486. package/docs/api/namespaces/media/variables/MediaAttachmentMessageType.md +15 -0
  1487. package/docs/api/namespaces/media/variables/downloadMediaAttachment.md +30 -0
  1488. package/docs/api/namespaces/safety/README.md +61 -0
  1489. package/docs/api/namespaces/safety/classes/DisplayableFingerprint.md +108 -0
  1490. package/docs/api/namespaces/safety/classes/Fingerprint.md +104 -0
  1491. package/docs/api/namespaces/safety/classes/ScannableFingerprint.md +209 -0
  1492. package/docs/api/namespaces/safety/functions/base64ToBytes.md +21 -0
  1493. package/docs/api/namespaces/safety/functions/clearFingerprintCache.md +15 -0
  1494. package/docs/api/namespaces/safety/functions/compareSafetyNumbers.md +25 -0
  1495. package/docs/api/namespaces/safety/functions/createFingerprintData.md +60 -0
  1496. package/docs/api/namespaces/safety/functions/extractQrData.md +34 -0
  1497. package/docs/api/namespaces/safety/functions/generateCompositeSafetyNumber.md +39 -0
  1498. package/docs/api/namespaces/safety/functions/generateEmojiFingerprint.md +24 -0
  1499. package/docs/api/namespaces/safety/functions/generateSingleKeyReferenceSafetyNumber.md +51 -0
  1500. package/docs/api/namespaces/safety/functions/generateVerifySchemeUrl.md +32 -0
  1501. package/docs/api/namespaces/safety/functions/generateVerifyUrl.md +49 -0
  1502. package/docs/api/namespaces/safety/functions/isValidSafetyNumber.md +21 -0
  1503. package/docs/api/namespaces/safety/functions/isVerifyUrl.md +45 -0
  1504. package/docs/api/namespaces/safety/functions/parseVerifyUrl.md +31 -0
  1505. package/docs/api/namespaces/safety/interfaces/FingerprintData.md +52 -0
  1506. package/docs/api/namespaces/safety/interfaces/SafetyNumber.md +49 -0
  1507. package/docs/api/namespaces/safety/interfaces/VerifyLinkConfig.md +28 -0
  1508. package/docs/api/namespaces/safety/interfaces/VerifyUrlParams.md +49 -0
  1509. package/docs/api/namespaces/safety/type-aliases/CompareResult.md +21 -0
  1510. package/docs/api/namespaces/safety/variables/DEFAULT_VERIFY_LINK_CONFIG.md +12 -0
  1511. package/docs/api/namespaces/safety/variables/FINGERPRINT_ITERATIONS.md +12 -0
  1512. package/docs/api/namespaces/safety/variables/FINGERPRINT_VERSION.md +12 -0
  1513. package/docs/api/namespaces/safety/variables/VERIFY_BASE_URL.md +11 -0
  1514. package/docs/api/namespaces/safety/variables/VERIFY_SCHEME_URL.md +11 -0
  1515. package/docs/api/type-aliases/Base64.md +20 -0
  1516. package/docs/api/type-aliases/BraidPolicy.md +11 -0
  1517. package/docs/api/type-aliases/Bytes.md +20 -0
  1518. package/docs/api/type-aliases/Ciphertext.md +21 -0
  1519. package/docs/api/type-aliases/DeviceType.md +11 -0
  1520. package/docs/api/type-aliases/DownloadedAttachment.md +11 -0
  1521. package/docs/api/type-aliases/GroupId.md +27 -0
  1522. package/docs/api/type-aliases/Hex.md +20 -0
  1523. package/docs/api/type-aliases/HookName.md +11 -0
  1524. package/docs/api/type-aliases/PostQuantumPolicy.md +11 -0
  1525. package/docs/api/type-aliases/PreparedAttachmentUpload.md +14 -0
  1526. package/docs/api/type-aliases/PrivateKey.md +22 -0
  1527. package/docs/api/type-aliases/ProgressCallback.md +45 -0
  1528. package/docs/api/type-aliases/PublicKey.md +22 -0
  1529. package/docs/api/type-aliases/RemoteObjectCompleteUploadRequest.md +19 -0
  1530. package/docs/api/type-aliases/RemoteObjectDeleteRequest.md +19 -0
  1531. package/docs/api/type-aliases/RemoteObjectDownloadRequest.md +19 -0
  1532. package/docs/api/type-aliases/RemoteObjectUploadRequest.md +42 -0
  1533. package/docs/api/type-aliases/SCKAMode.md +11 -0
  1534. package/docs/api/type-aliases/SealedSenderAuth.md +15 -0
  1535. package/docs/api/type-aliases/SignalProtocolClientMediaCleanupInput.md +9 -0
  1536. package/docs/api/type-aliases/SignalProtocolClientMediaCleanupResult.md +9 -0
  1537. package/docs/api/type-aliases/SignalProtocolClientMediaDownloadInput.md +9 -0
  1538. package/docs/api/type-aliases/SignalProtocolClientMediaDownloadResult.md +9 -0
  1539. package/docs/api/type-aliases/SignalProtocolClientMediaOperationResult.md +9 -0
  1540. package/docs/api/type-aliases/SignalProtocolClientMediaUploadInput.md +9 -0
  1541. package/docs/api/type-aliases/SignalProtocolClientMediaUploadResult.md +9 -0
  1542. package/docs/api/type-aliases/Signature.md +21 -0
  1543. package/docs/api/type-aliases/Unsubscribe.md +15 -0
  1544. package/docs/api/variables/BraidPolicy.md +21 -0
  1545. package/docs/api/variables/DEFAULT_DEVICE_ID.md +12 -0
  1546. package/docs/api/variables/DOUBLE_RATCHET_SPEC.md +11 -0
  1547. package/docs/api/variables/GROUP_V2_PREFIX.md +11 -0
  1548. package/docs/api/variables/KEY_REFRESH_INTERVAL_MS_DEFAULT.md +11 -0
  1549. package/docs/api/variables/MAX_MESSAGE_KEYS.md +14 -0
  1550. package/docs/api/variables/MAX_PREKEY_AGE_MS_DEFAULT.md +11 -0
  1551. package/docs/api/variables/MAX_RECEIVER_CHAINS.md +14 -0
  1552. package/docs/api/variables/MAX_REGISTRATION_ID.md +16 -0
  1553. package/docs/api/variables/MAX_SKIP.md +11 -0
  1554. package/docs/api/variables/MESSAGE_FORMAT.md +11 -0
  1555. package/docs/api/variables/MIN_REGISTRATION_ID.md +16 -0
  1556. package/docs/api/variables/ML_KEM_BRAID_SPEC.md +11 -0
  1557. package/docs/api/variables/ONE_TIME_PREKEY_BATCH_SIZE.md +21 -0
  1558. package/docs/api/variables/PQXDH_SPEC.md +11 -0
  1559. package/docs/api/variables/PostQuantumPolicy.md +21 -0
  1560. package/docs/api/variables/SENDER_KEY_FORMAT.md +11 -0
  1561. package/docs/api/variables/SENDER_KEY_SPEC.md +11 -0
  1562. package/docs/api/variables/SESAME_SPEC.md +11 -0
  1563. package/docs/api/variables/SESSION_FORMAT.md +11 -0
  1564. package/docs/api/variables/SPQR_LIMITS_DEFAULTS.md +11 -0
  1565. package/docs/api/variables/X3DH_SPEC.md +9 -0
  1566. package/docs/api/variables/defaultSignalLogger.md +32 -0
  1567. package/encoding/README.md +32 -0
  1568. package/files/README.md +37 -0
  1569. package/groups/README.md +42 -0
  1570. package/hooks/README.md +40 -0
  1571. package/keys/README.md +121 -0
  1572. package/local/store/README.md +120 -0
  1573. package/local/store/expo/README.md +73 -0
  1574. package/local/store/mock/README.md +27 -0
  1575. package/local/store/node/README.md +35 -0
  1576. package/local/store/react-native/README.md +39 -0
  1577. package/local/store/web/README.md +65 -0
  1578. package/local/vault/README.md +32 -0
  1579. package/media/README.md +73 -0
  1580. package/package.json +436 -0
  1581. package/profile/README.md +44 -0
  1582. package/remote/README.md +219 -0
  1583. package/remote/object-store/README.md +45 -0
  1584. package/remote/object-store/convex-r2/README.md +85 -0
  1585. package/remote/object-store/s3/README.md +35 -0
  1586. package/remote/relay/README.md +38 -0
  1587. package/remote/relay/convex/README.md +54 -0
  1588. package/remote/relay/mock/README.md +32 -0
  1589. package/safety/README.md +42 -0
  1590. package/sealed-sender/README.md +32 -0
  1591. package/types/README.md +36 -0
  1592. package/username/README.md +37 -0
  1593. package/utils/README.md +37 -0
  1594. package/zk/README.md +36 -0
@@ -0,0 +1,1506 @@
1
+ /**
2
+ * SignalServiceCipher - Cipher coordination for Signal Protocol
3
+ *
4
+ * @layer 1 - API
5
+ *
6
+ * Public coordination surface:
7
+ * - `decrypt(envelope)` → DecryptedEnvelope
8
+ * - `encrypt(recipientId, content)` → SendResult
9
+ *
10
+ * Separates cipher coordination (encrypt/decrypt routing) from lifecycle
11
+ * management (sessions, keys, hooks, subscriptions) in SignalProtocolClient.
12
+ *
13
+ * @see https://signal.org/docs/specifications/sesame/
14
+ */
15
+ import AsyncLock from 'async-lock';
16
+ import { EncryptionError, EncryptionErrorCode } from '../types/index.js';
17
+ import { SealedSenderAuthError } from '../types/errors.js';
18
+ import { base64ToBytes } from '../internal/crypto/index.js';
19
+ import { recordServerClockSample } from '../server-clock.js';
20
+ import { ProtocolAddress } from '../types/address.js';
21
+ import { defaultSignalLogger } from '../logger.js';
22
+ import { isGroupId, extractGroupId } from '../internal/groups/index.js';
23
+ import { createDefaultSignalContentAdapter, } from './content-adapter.js';
24
+ import * as CryptoUtils from '../internal/crypto/index.js';
25
+ import { withRetry } from '../utils/retry.js';
26
+ import { prepareMediaAttachmentUpload, serializeMediaAttachmentMessage } from '../media/index.js';
27
+ import { UnidentifiedAccessMode, } from '../profile/contact-state.js';
28
+ export function sortEnvelopesForDecryption(envelopes) {
29
+ return [...envelopes].sort((a, b) => {
30
+ // Treat undefined messageType as non-prekey (ciphertext comes after prekey_bundle)
31
+ const aIsPreKey = a.messageType === 'prekey_bundle' ? 0 : 1;
32
+ const bIsPreKey = b.messageType === 'prekey_bundle' ? 0 : 1;
33
+ return aIsPreKey - bIsPreKey;
34
+ });
35
+ }
36
+ /**
37
+ * Detect actual message type from ciphertext for envelope metadata
38
+ *
39
+ * PreKeyMessages (first messages) should have messageType: 'prekey_bundle'
40
+ * Regular ratchet messages should have messageType: 'ciphertext'
41
+ *
42
+ * @param ciphertext - The encrypted message content (string or Uint8Array)
43
+ * @returns 'prekey_bundle' for PreKeyMessages, 'ciphertext' for regular messages
44
+ */
45
+ function getEnvelopeMessageType(ciphertext) {
46
+ const text = typeof ciphertext === 'string' ? ciphertext : new TextDecoder().decode(ciphertext);
47
+ // Binary protobuf format: base64 decode, check first protobuf tag
48
+ try {
49
+ const bytes = CryptoUtils.base64ToBytes(text);
50
+ if (bytes.length >= 2) {
51
+ const firstTag = bytes[1];
52
+ // PreKeySignalMessage: first tag is 0x08 (field 1 uint32) or 0x12 (field 2 bytes)
53
+ if (firstTag === 0x08 || firstTag === 0x12) {
54
+ return 'prekey_bundle';
55
+ }
56
+ }
57
+ }
58
+ catch {
59
+ // Not valid base64 binary
60
+ }
61
+ return 'ciphertext';
62
+ }
63
+ /**
64
+ * Detect if an error is a stale session error from the server
65
+ *
66
+ * The relay returns STALE_DEVICE when a PreKeyMessage uses an outdated
67
+ * registration ID.
68
+ *
69
+ * This SDK validates registration IDs at the relay boundary. Stale-prekey
70
+ * detection remains client-side through authentication failure and retry.
71
+ *
72
+ * @param error - The error to check
73
+ * @returns True if error indicates stale session requiring bundle refresh
74
+ */
75
+ function isStaleSessionError(error) {
76
+ if (error && typeof error === 'object' && 'data' in error) {
77
+ const data = error.data;
78
+ if (data && typeof data === 'object' && 'code' in data) {
79
+ const code = data.code;
80
+ return code === 'STALE_DEVICE';
81
+ }
82
+ }
83
+ return false;
84
+ }
85
+ /**
86
+ * Detect 409 mismatched devices error from V2 multi-recipient send.
87
+ *
88
+ * Server returns this when the device list in the request doesn't match
89
+ * the recipient's current device list (device added/removed since last check).
90
+ * Our Convex server throws errors with 'MISMATCHED_DEVICES' in the message.
91
+ *
92
+ */
93
+ function isMismatchedDevicesError(message) {
94
+ return message.includes('MISMATCHED_DEVICES');
95
+ }
96
+ /**
97
+ * Detect 410 stale sessions error from V2 multi-recipient send.
98
+ *
99
+ * Server returns this when registration IDs in the request don't match
100
+ * (device was reinstalled). Sessions need to be archived and re-established.
101
+ * Our Convex server throws errors with 'STALE_DEVICE' in the message.
102
+ *
103
+ */
104
+ function isStaleSessionV2Error(message) {
105
+ return message.includes('STALE_DEVICE');
106
+ }
107
+ /**
108
+ * SignalServiceCipher - Routes encryption and decryption to appropriate ciphers
109
+ *
110
+ * Handles:
111
+ * - Pairwise messages via SESAME/Double Ratchet
112
+ * - Group messages via Sender Keys
113
+ * - Binary content with two-layer encryption (AES-GCM + Signal Protocol)
114
+ *
115
+ * @example
116
+ * ```typescript
117
+ * // Created by SignalProtocolClient - not instantiated directly
118
+ * const cipher = new SignalServiceCipher(userId, deviceId, sesameManager, ...);
119
+ *
120
+ * // Decrypt incoming envelope
121
+ * const decrypted = await cipher.decrypt(envelope);
122
+ *
123
+ * // Encrypt outgoing message
124
+ * const result = await cipher.encrypt('bob', 'Hello!');
125
+ * ```
126
+ */
127
+ export class SignalServiceCipher {
128
+ userId;
129
+ deviceId;
130
+ sesameManager;
131
+ senderKeyManager;
132
+ storage;
133
+ relay;
134
+ remoteObjectStore;
135
+ contentAdapter;
136
+ logger;
137
+ lock = new AsyncLock();
138
+ sessionEstablisher;
139
+ staleSessionRefresher;
140
+ sealedSenderProvider;
141
+ contactProfileStateStore;
142
+ endorsementManager;
143
+ endorsementRefresher;
144
+ groupSecretParamsProvider;
145
+ constructor(userId, deviceId, sesameManager, senderKeyManager, storage, relay, remoteObjectStore, contentAdapter, logger = defaultSignalLogger) {
146
+ this.userId = userId;
147
+ this.deviceId = deviceId;
148
+ this.sesameManager = sesameManager;
149
+ this.senderKeyManager = senderKeyManager;
150
+ this.storage = storage;
151
+ this.relay = relay;
152
+ this.remoteObjectStore = remoteObjectStore;
153
+ this.contentAdapter = contentAdapter;
154
+ this.logger = logger;
155
+ }
156
+ getResolvedContentAdapter() {
157
+ return this.contentAdapter ?? createDefaultSignalContentAdapter();
158
+ }
159
+ getDirectConversationId(recipientUserId) {
160
+ const sortedIds = [this.userId, recipientUserId].sort();
161
+ return `dm:${sortedIds[0]}_${sortedIds[1]}`;
162
+ }
163
+ buildSentSyncTranscript(conversationId, plaintextBytes, timestamp, recipientUserId) {
164
+ return this.getResolvedContentAdapter().serializeSentTranscript({
165
+ conversationId,
166
+ serializedContent: plaintextBytes,
167
+ timestamp,
168
+ recipientUserId,
169
+ });
170
+ }
171
+ encodeLosslessPlaintext(plaintextBytes) {
172
+ const text = new TextDecoder().decode(plaintextBytes);
173
+ const roundTrip = new TextEncoder().encode(text);
174
+ if (roundTrip.length === plaintextBytes.length &&
175
+ roundTrip.every((byte, index) => byte === plaintextBytes[index])) {
176
+ return text;
177
+ }
178
+ return CryptoUtils.bytesToBase64(plaintextBytes);
179
+ }
180
+ async uploadSyncMessages(syncMessages) {
181
+ if (!this.relay || syncMessages.length === 0) {
182
+ return;
183
+ }
184
+ for (const syncMsg of syncMessages) {
185
+ await this.relay.send({
186
+ targetUserId: syncMsg.recipientUserId,
187
+ targetDeviceId: syncMsg.recipientDeviceId,
188
+ senderUserId: this.userId,
189
+ senderDeviceId: this.deviceId,
190
+ ciphertext: typeof syncMsg.ciphertext === 'string'
191
+ ? syncMsg.ciphertext
192
+ : CryptoUtils.bytesToBase64(syncMsg.ciphertext),
193
+ messageType: getEnvelopeMessageType(syncMsg.ciphertext),
194
+ timestamp: syncMsg.timestamp,
195
+ });
196
+ }
197
+ }
198
+ async sendSyncTranscriptToLocalOtherDevices(conversationId, plaintextBytes, timestamp, recipientUserId) {
199
+ const transcriptBytes = this.buildSentSyncTranscript(conversationId, plaintextBytes, timestamp, recipientUserId);
200
+ await this.sendSyncPayloadToLocalOtherDevices(transcriptBytes, timestamp);
201
+ }
202
+ async sendSyncPayloadToLocalOtherDevices(payloadBytes, timestamp) {
203
+ if (!this.relay) {
204
+ return;
205
+ }
206
+ const syncMessages = await this.sesameManager.sendToLocalOtherDevices(payloadBytes, {
207
+ clientTimestamp: timestamp,
208
+ includeSyncMessages: false,
209
+ });
210
+ await this.uploadSyncMessages(syncMessages);
211
+ }
212
+ async sendReadSyncToLocalOtherDevices(entries) {
213
+ if (entries.length === 0) {
214
+ return;
215
+ }
216
+ const timestamp = Date.now();
217
+ const payloadBytes = this.getResolvedContentAdapter().serializeReadSync(entries);
218
+ await this.sendSyncPayloadToLocalOtherDevices(payloadBytes, timestamp);
219
+ }
220
+ async sendViewOnceOpenSyncToLocalOtherDevices(entry) {
221
+ const timestamp = Date.now();
222
+ const payloadBytes = this.getResolvedContentAdapter().serializeViewOnceOpenSync(entry);
223
+ await this.sendSyncPayloadToLocalOtherDevices(payloadBytes, timestamp);
224
+ }
225
+ async sendMediaAttachmentDeleteSyncToLocalOtherDevices(entry) {
226
+ const payloadBytes = this.getResolvedContentAdapter().serializeMediaAttachmentDeleteSync(entry);
227
+ await this.sendSyncPayloadToLocalOtherDevices(payloadBytes, entry.deletedAt);
228
+ }
229
+ async sendConfigurationSyncToLocalOtherDevices(configuration) {
230
+ const timestamp = Date.now();
231
+ const payloadBytes = this.getResolvedContentAdapter().serializeConfigurationSync(configuration);
232
+ await this.sendSyncPayloadToLocalOtherDevices(payloadBytes, timestamp);
233
+ }
234
+ async sendUsernameStateSyncToLocalOtherDevices(usernameState) {
235
+ const timestamp = Date.now();
236
+ const payloadBytes = this.getResolvedContentAdapter().serializeUsernameStateSync(usernameState);
237
+ await this.sendSyncPayloadToLocalOtherDevices(payloadBytes, timestamp);
238
+ }
239
+ async sendRecipientUsernameSyncToLocalOtherDevices(recipientUsername) {
240
+ const payloadBytes = this.getResolvedContentAdapter().serializeRecipientUsernameSync(recipientUsername);
241
+ await this.sendSyncPayloadToLocalOtherDevices(payloadBytes, recipientUsername.learnedAt);
242
+ }
243
+ async sendVerificationStateSyncToLocalOtherDevices(verificationState) {
244
+ const payloadBytes = this.getResolvedContentAdapter().serializeVerificationStateSync(verificationState);
245
+ await this.sendSyncPayloadToLocalOtherDevices(payloadBytes, verificationState.changedAt);
246
+ }
247
+ async sendTaskNotificationAckSyncToLocalOtherDevices(ack) {
248
+ const payloadBytes = this.getResolvedContentAdapter().serializeTaskNotificationAckSync(ack);
249
+ await this.sendSyncPayloadToLocalOtherDevices(payloadBytes, ack.acknowledgedAt);
250
+ }
251
+ async sendBlockedRecipientsSyncToLocalOtherDevices(blocked) {
252
+ const payloadBytes = this.getResolvedContentAdapter().serializeBlockedRecipientsSync(blocked);
253
+ await this.sendSyncPayloadToLocalOtherDevices(payloadBytes, blocked.syncedAt);
254
+ }
255
+ /**
256
+ * Set the session establisher callback
257
+ * Called by SignalProtocolClient after construction to inject session establishment logic
258
+ */
259
+ setSessionEstablisher(establisher) {
260
+ this.sessionEstablisher = establisher;
261
+ }
262
+ /**
263
+ * Set the stale session refresher callback
264
+ * Called by SignalProtocolClient after construction to inject session refresh logic
265
+ *
266
+ * Used when server returns STALE_DEVICE errors (device reinstalled).
267
+ */
268
+ setStaleSessionRefresher(refresher) {
269
+ this.staleSessionRefresher = refresher;
270
+ }
271
+ /**
272
+ * Set the sealed sender provider callback
273
+ * Called by SignalProtocolClient after construction to inject sealed sender support.
274
+ *
275
+ * Provides the sender certificate and identity key needed for sealing messages.
276
+ */
277
+ setSealedSenderProvider(provider) {
278
+ this.sealedSenderProvider = provider;
279
+ }
280
+ setContactProfileStateStore(store) {
281
+ this.contactProfileStateStore = store;
282
+ }
283
+ /**
284
+ * Set the endorsement manager for group send endorsement-based auth.
285
+ *
286
+ * When set, group messages will prefer endorsement tokens over UAK-based
287
+ * sealed sender. This avoids needing the recipient's profile key for
288
+ * group messages and provides stronger group membership verification.
289
+ *
290
+ */
291
+ setEndorsementManager(manager) {
292
+ this.endorsementManager = manager;
293
+ }
294
+ /**
295
+ * Set the endorsement refresher callback.
296
+ *
297
+ * Called before V2 multi-recipient sends when endorsements are missing or
298
+ * expiring soon. The implementation fetches endorsements from the server
299
+ * and caches them via EndorsementManager.
300
+ *
301
+ */
302
+ setEndorsementRefresher(refresher) {
303
+ this.endorsementRefresher = refresher;
304
+ }
305
+ /**
306
+ * Set the group secret params provider callback.
307
+ *
308
+ * Required for endorsement-based sealed sender in groups. The provider
309
+ * looks up GroupSecretParams from the local database for a given group ID.
310
+ *
311
+ * @param provider - Async callback returning GroupSecretParams or null
312
+ */
313
+ setGroupSecretParamsProvider(provider) {
314
+ this.groupSecretParamsProvider = provider;
315
+ }
316
+ // ============================================================================
317
+ // Public API
318
+ // ============================================================================
319
+ /**
320
+ * Decrypt incoming envelope - routes to appropriate cipher
321
+ *
322
+ * Routes based on envelope type:
323
+ * - ciphertext + groupId → Group cipher (Sender Keys)
324
+ * - otherwise → Pairwise cipher (SESAME/Double Ratchet)
325
+ *
326
+ * @param envelope - Encrypted envelope from relay
327
+ * @returns Decrypted envelope ready for ContentManager
328
+ * @throws {EncryptionError} DECRYPTION_FAILED if decryption fails
329
+ *
330
+ * @see https://signal.org/docs/specifications/sesame/
331
+ */
332
+ async decrypt(envelope, sealedSenderConfig) {
333
+ // Handle sealed sender (unidentified_sender) envelopes by unsealing first
334
+ if (envelope.messageType === 'unidentified_sender') {
335
+ if (!sealedSenderConfig || sealedSenderConfig.trustRoots.length === 0) {
336
+ throw new EncryptionError('Received sealed sender message but no trust roots configured', EncryptionErrorCode.INVALID_CIPHERTEXT, { messageType: envelope.messageType });
337
+ }
338
+ const { unsealMessage, reconstructEnvelope } = await import('./sealed-sender-ops.js');
339
+ // Get recipient's X25519 identity private key for unsealing
340
+ const identityKeyPair = await this.storage.getIdentityKey();
341
+ if (!identityKeyPair) {
342
+ throw new EncryptionError('No identity key pair for sealed sender decryption', EncryptionErrorCode.DECRYPTION_FAILED);
343
+ }
344
+ // Convert branded Base64 private key to Uint8Array for sealed sender
345
+ const recipientPrivateKeyBytes = base64ToBytes(identityKeyPair.dhKey.privateKey);
346
+ const ciphertextStr = typeof envelope.ciphertext === 'string'
347
+ ? envelope.ciphertext
348
+ : CryptoUtils.bytesToBase64(envelope.ciphertext);
349
+ const unsealed = await unsealMessage(ciphertextStr, recipientPrivateKeyBytes, this.userId, this.deviceId, sealedSenderConfig, this.logger);
350
+ // Reconstruct envelope with revealed sender identity
351
+ const innerEnvelope = reconstructEnvelope(envelope, unsealed);
352
+ // Recursively decrypt the inner message (now a standard ciphertext)
353
+ return this.decrypt(innerEnvelope);
354
+ }
355
+ // Validate message type before processing
356
+ // Server only sends the 5 envelope types; client-to-client types (typing_indicator,
357
+ // delivery_receipt, sender_key_distribution) are encrypted Content inside ciphertext.
358
+ const validMessageTypes = [
359
+ 'prekey_bundle',
360
+ 'ciphertext',
361
+ 'plaintext_content',
362
+ 'server_delivery_receipt',
363
+ 'unidentified_sender',
364
+ ];
365
+ if (!validMessageTypes.includes(envelope.messageType)) {
366
+ throw new EncryptionError(`Unknown message type: ${envelope.messageType}`, EncryptionErrorCode.INVALID_CIPHERTEXT, { messageType: envelope.messageType, senderId: envelope.senderUserId });
367
+ }
368
+ const lockKey = `decrypt:${envelope.senderUserId}:${envelope.senderDeviceId}`;
369
+ return this.lock.acquire(lockKey, async () => {
370
+ this.logger.debug('Handling incoming envelope', {
371
+ category: 'E2EE',
372
+ data: {
373
+ envelopeId: envelope.id,
374
+ senderId: envelope.senderUserId,
375
+ senderDeviceId: envelope.senderDeviceId,
376
+ messageType: envelope.messageType,
377
+ groupId: envelope.groupId,
378
+ },
379
+ });
380
+ let plaintext;
381
+ // Route to appropriate decryption based on context
382
+ // Group messages arrive as 'ciphertext' with groupId set (the server doesn't
383
+ // distinguish group vs pairwise — both are ciphertext envelopes)
384
+ if (envelope.groupId && envelope.messageType === 'ciphertext') {
385
+ // Group message encrypted with Sender Keys
386
+ plaintext = await this.decryptGroup(envelope);
387
+ }
388
+ else {
389
+ // Pairwise message - use SESAME for session convergence
390
+ const sesameMessage = this.toSesameMessage(envelope);
391
+ plaintext = await this.decryptPairwise(sesameMessage);
392
+ }
393
+ // Create decrypted envelope for hook
394
+ const receivedAt = Date.now();
395
+ const inspectedContent = this.getResolvedContentAdapter().inspectContent(plaintext);
396
+ // For DMs, compute canonical conversation ID: dm:${sorted(user1, user2)}
397
+ // Groups use their group ID directly. Sent sync transcripts override this
398
+ // with the transcript's destination conversation.
399
+ const conversationId = inspectedContent?.conversationId ||
400
+ envelope.groupId ||
401
+ this.getDirectConversationId(envelope.senderUserId);
402
+ // Extract client timestamp from decrypted content
403
+ // Text messages: dataMessage.timestamp, Attachments: timestamp at top level
404
+ let clientTimestamp = receivedAt;
405
+ let hasContentTimestamp = false;
406
+ const contentTimestamp = inspectedContent?.timestamp;
407
+ if (typeof contentTimestamp === 'number') {
408
+ clientTimestamp = contentTimestamp;
409
+ hasContentTimestamp = true;
410
+ }
411
+ // Replay attack prevention
412
+ // Validate envelope.timestamp matches content timestamp after decryption
413
+ if (envelope.timestamp !== undefined && hasContentTimestamp) {
414
+ if (envelope.timestamp !== clientTimestamp) {
415
+ throw new EncryptionError(`Timestamp mismatch: envelope=${envelope.timestamp}, content=${clientTimestamp}. Potential replay attack.`, EncryptionErrorCode.REPLAY_DETECTED);
416
+ }
417
+ }
418
+ recordServerClockSample(envelope.serverTimestamp, receivedAt);
419
+ const decryptedEnvelope = {
420
+ messageId: envelope.id || `${envelope.senderUserId}-${receivedAt}`,
421
+ sessionId: ProtocolAddress.toString(ProtocolAddress.create(envelope.senderUserId, envelope.senderDeviceId)),
422
+ senderId: envelope.senderUserId,
423
+ senderDeviceId: envelope.senderDeviceId,
424
+ conversationId,
425
+ content: plaintext,
426
+ timestamp: clientTimestamp, // Use client timestamp for receipt matching
427
+ serverTimestamp: envelope.serverTimestamp,
428
+ receivedAt,
429
+ isGroup: !!envelope.groupId,
430
+ messageType: envelope.messageType,
431
+ };
432
+ return decryptedEnvelope;
433
+ });
434
+ }
435
+ /**
436
+ * Encrypt outgoing message - routes based on recipient type
437
+ *
438
+ * Routes based on recipientId:
439
+ * - Group ID (prefixed) → encryptToGroup (Sender Keys)
440
+ * - Binary content with mimeType → encryptBlob (two-layer encryption)
441
+ * - User ID → encryptToUser (SESAME)
442
+ *
443
+ * @param recipientId - User ID or group ID (groups use Signal V2 prefix)
444
+ * @param content - Uint8Array bytes to encrypt and send
445
+ * @param options - Optional send options (mimeType for binary content, etc.)
446
+ * @returns SendResult with messageId, timestamp, and device count
447
+ *
448
+ * @see https://signal.org/docs/specifications/sesame/
449
+ */
450
+ async encrypt(recipientId, content, options) {
451
+ const lockKey = `encrypt:${recipientId}`;
452
+ return this.lock.acquire(lockKey, async () => {
453
+ // 1. Route binary file data (Uint8Array with isBinary flag) to blob encryption
454
+ if (options?.isBinary) {
455
+ return this.encryptBinaryAttachment(recipientId, content, options);
456
+ }
457
+ // 2. Detect recipient type (group vs user)
458
+ if (isGroupId(recipientId)) {
459
+ return this.encryptToGroup(recipientId, content, options);
460
+ }
461
+ // 3. Send to user (existing SESAME path)
462
+ return this.encryptToUser(recipientId, content, options);
463
+ });
464
+ }
465
+ /**
466
+ * Encrypt and upload attachment data without sending a standalone message.
467
+ */
468
+ async uploadAttachment(data, options) {
469
+ const lockKey = `attachment-upload:${options.mimeType}`;
470
+ return this.lock.acquire(lockKey, async () => this.prepareAttachmentUpload(data, options));
471
+ }
472
+ // ============================================================================
473
+ // PRIVATE - Decryption
474
+ // ============================================================================
475
+ /**
476
+ * Convert Envelope to SesameMessage for SESAME receive path
477
+ */
478
+ toSesameMessage(envelope) {
479
+ // SessionID format is "userId:deviceId" (from ProtocolAddress.toString())
480
+ const sessionId = `${envelope.senderUserId}:${envelope.senderDeviceId}`;
481
+ return {
482
+ senderUserId: envelope.senderUserId,
483
+ senderDeviceId: envelope.senderDeviceId,
484
+ recipientUserId: this.userId, // We are the recipient
485
+ recipientDeviceId: this.deviceId,
486
+ sessionId,
487
+ // Ciphertext is base64-encoded on relay, convert back to Uint8Array
488
+ // SESAME will deserialize it back to Ciphertext (branded base64 string) internally
489
+ ciphertext: typeof envelope.ciphertext === 'string'
490
+ ? base64ToBytes(envelope.ciphertext)
491
+ : envelope.ciphertext,
492
+ isInitiating: envelope.messageType === 'prekey_bundle',
493
+ initHeader: null, // Extracted from ciphertext by SESAME
494
+ timestamp: envelope.timestamp,
495
+ };
496
+ }
497
+ /**
498
+ * Decrypt a pairwise message via SESAME
499
+ *
500
+ * Public for use by SignalProtocolClient.receive() which takes raw SesameMessage.
501
+ *
502
+ * @throws {EncryptionError} DECRYPTION_FAILED if decryption fails
503
+ */
504
+ async decryptPairwise(sesameMessage) {
505
+ try {
506
+ const plaintextBytes = await this.sesameManager.receive(sesameMessage);
507
+ const plaintext = this.encodeLosslessPlaintext(plaintextBytes);
508
+ this.logger.debug('Message received and decrypted', {
509
+ category: 'E2EE',
510
+ data: {
511
+ senderUserId: sesameMessage.senderUserId,
512
+ senderDeviceId: sesameMessage.senderDeviceId,
513
+ },
514
+ });
515
+ return plaintext;
516
+ }
517
+ catch (error) {
518
+ // Preserve EncryptionError for client-layer handling (e.g., PREKEY_NOT_FOUND triggers key rotation)
519
+ if (error instanceof EncryptionError) {
520
+ throw error;
521
+ }
522
+ throw new EncryptionError('Failed to decrypt message', EncryptionErrorCode.DECRYPTION_FAILED, {
523
+ originalError: error,
524
+ senderUserId: sesameMessage.senderUserId,
525
+ });
526
+ }
527
+ }
528
+ /**
529
+ * Decrypt a group message via Sender Keys
530
+ *
531
+ * @throws {EncryptionError} DECRYPTION_FAILED if decryption fails
532
+ */
533
+ async decryptGroup(envelope) {
534
+ // Get the framed SenderKeyMessage bytes
535
+ let framedBytes;
536
+ if (typeof envelope.ciphertext === 'string') {
537
+ // Base64-encoded framed SenderKeyMessage
538
+ framedBytes = CryptoUtils.base64ToBytes(envelope.ciphertext);
539
+ }
540
+ else {
541
+ framedBytes = envelope.ciphertext;
542
+ }
543
+ try {
544
+ const plaintext = await this.senderKeyManager.decryptGroupMessage(envelope.groupId, envelope.senderUserId, envelope.senderDeviceId, framedBytes);
545
+ this.logger.debug('Decrypted group message', {
546
+ category: 'E2EE',
547
+ data: {
548
+ groupId: envelope.groupId,
549
+ senderId: envelope.senderUserId,
550
+ },
551
+ });
552
+ return plaintext;
553
+ }
554
+ catch (error) {
555
+ const err = error;
556
+ if (err.message?.includes('SENDER_KEY_NOT_FOUND')) {
557
+ throw new EncryptionError(`No sender key from ${envelope.senderUserId} for group ${envelope.groupId} - request key distribution`, EncryptionErrorCode.SESSION_NOT_FOUND, { originalError: err });
558
+ }
559
+ if (err.message?.includes('INVALID_SIGNATURE')) {
560
+ throw new EncryptionError(`Invalid signature on group message from ${envelope.senderUserId}`, EncryptionErrorCode.DECRYPTION_FAILED, { originalError: err });
561
+ }
562
+ if (err.message?.includes('MESSAGE_TOO_OLD')) {
563
+ throw new EncryptionError('Cannot decrypt old group message (forward secrecy)', EncryptionErrorCode.DECRYPTION_FAILED, { originalError: err });
564
+ }
565
+ throw new EncryptionError(`Failed to decrypt group message from ${envelope.senderUserId}`, EncryptionErrorCode.DECRYPTION_FAILED, { originalError: err });
566
+ }
567
+ }
568
+ // ============================================================================
569
+ // PRIVATE - Encryption
570
+ // ============================================================================
571
+ /**
572
+ * Ensure sessions exist with a recipient user
573
+ *
574
+ * Checks if any session exists with the recipient. If not, uses the session
575
+ * establisher callback to fetch prekey bundles and create sessions.
576
+ *
577
+ * @throws {EncryptionError} SESSION_NOT_FOUND if sessions cannot be established
578
+ */
579
+ async ensureSessionsForUser(recipientUserId) {
580
+ // Check if we have any session with this user via SESAME UserRecord
581
+ const userRecord = await this.sesameManager.getUserRecord(recipientUserId);
582
+ if (userRecord && userRecord.devices.size > 0) {
583
+ // Check if at least one device has an active session
584
+ const hasActiveSession = Array.from(userRecord.devices.values()).some((device) => device.session?.currentSession !== null);
585
+ if (hasActiveSession) {
586
+ return; // Sessions exist, nothing to do
587
+ }
588
+ }
589
+ // No sessions exist - need to establish them
590
+ this.logger.debug('No session exists, auto-establishing', {
591
+ category: 'E2EE',
592
+ data: { recipientUserId, hasUserRecord: !!userRecord },
593
+ });
594
+ if (!this.sessionEstablisher) {
595
+ throw new EncryptionError(`No session with ${recipientUserId} and auto-establishment not configured`, EncryptionErrorCode.SESSION_NOT_FOUND, { recipientUserId });
596
+ }
597
+ if (!this.relay) {
598
+ throw new EncryptionError('Cannot auto-establish session: relay server not configured', EncryptionErrorCode.INITIALIZATION_FAILED, { recipientUserId });
599
+ }
600
+ try {
601
+ // Use retry logic for transient network failures
602
+ const result = await withRetry(() => this.sessionEstablisher(recipientUserId), {
603
+ operationName: 'establishSession',
604
+ maxRetries: 2,
605
+ baseDelay: 500,
606
+ });
607
+ if (result.establishedDevices.length === 0) {
608
+ throw new EncryptionError(`Recipient ${recipientUserId} has no available prekey bundles - they may not have registered encryption keys`, EncryptionErrorCode.RECIPIENT_NOT_REGISTERED, { recipientUserId, failedDevices: result.failedDevices });
609
+ }
610
+ this.logger.info('Auto-established sessions', {
611
+ category: 'E2EE',
612
+ data: {
613
+ recipientUserId,
614
+ establishedDevices: result.establishedDevices,
615
+ failedDevices: result.failedDevices,
616
+ },
617
+ });
618
+ }
619
+ catch (error) {
620
+ // Re-throw EncryptionErrors, wrap others
621
+ if (error instanceof EncryptionError) {
622
+ throw error;
623
+ }
624
+ // Check for rate limiting
625
+ const errorMessage = error.message?.toLowerCase() || '';
626
+ if (errorMessage.includes('rate limit')) {
627
+ throw new EncryptionError(`Rate limited while establishing session with ${recipientUserId}`, EncryptionErrorCode.PREKEY_FETCH_RATE_LIMITED, { originalError: error, recipientUserId });
628
+ }
629
+ throw new EncryptionError(`Failed to establish session with ${recipientUserId} after retries`, EncryptionErrorCode.SESSION_ESTABLISHMENT_FAILED, { originalError: error, recipientUserId });
630
+ }
631
+ }
632
+ /**
633
+ * Encrypt to a single user (all their devices) via SESAME
634
+ */
635
+ async encryptToUser(recipientUserId, plaintextBytes, options) {
636
+ // Auto-establish sessions if needed (lazy session creation)
637
+ await this.ensureSessionsForUser(recipientUserId);
638
+ // SESAME multi-device encryption: encrypt for all recipient devices
639
+ let batch;
640
+ try {
641
+ const clientTimestamp = options?.timestamp ?? Date.now();
642
+ const syncPlaintext = this.buildSentSyncTranscript(this.getDirectConversationId(recipientUserId), plaintextBytes, clientTimestamp, recipientUserId);
643
+ batch = await this.sesameManager.send(recipientUserId, plaintextBytes, {
644
+ clientTimestamp,
645
+ syncPlaintext,
646
+ });
647
+ }
648
+ catch (error) {
649
+ // Preserve EncryptionError codes
650
+ if (error instanceof EncryptionError) {
651
+ throw error;
652
+ }
653
+ throw new EncryptionError('Failed to encrypt message for user', EncryptionErrorCode.ENCRYPTION_FAILED, { originalError: error, recipientUserId });
654
+ }
655
+ this.logger.debug('Message encrypted for user devices', {
656
+ category: 'E2EE',
657
+ data: {
658
+ recipientUserId,
659
+ deviceCount: batch.deviceMessages.length,
660
+ syncCount: batch.syncMessages.length,
661
+ },
662
+ });
663
+ // Upload messages to relay server if configured
664
+ let messageId = `local-${Date.now()}`;
665
+ let timestamp = Date.now(); // Fallback if no relay
666
+ if (this.relay) {
667
+ // Resolve sealed sender context once per send (avoid re-fetching per device)
668
+ const sealedSender = await this.resolveSealedSenderContext(recipientUserId);
669
+ // Send to each recipient device with stale session handling
670
+ for (const msg of batch.deviceMessages) {
671
+ const messageType = getEnvelopeMessageType(msg.ciphertext);
672
+ const ciphertextBase64 = typeof msg.ciphertext === 'string'
673
+ ? msg.ciphertext
674
+ : CryptoUtils.bytesToBase64(msg.ciphertext);
675
+ // For PreKeyMessages, get session metadata for server-side validation
676
+ // Signal only validates registrationId server-side (device reinstall detection)
677
+ // Stale prekey detection is handled client-side via MAC failure + retry
678
+ let recipientRegistrationId;
679
+ if (messageType === 'prekey_bundle') {
680
+ const session = await this.sesameManager.getSession(msg.recipientUserId, msg.recipientDeviceId);
681
+ if (session?.currentSession) {
682
+ recipientRegistrationId = session.currentSession.remoteRegistrationId;
683
+ }
684
+ }
685
+ try {
686
+ const result = await this.sendToDevice(msg, ciphertextBase64, messageType, recipientRegistrationId, sealedSender, options?.contentHint, options?.clientMessageId);
687
+ // Use first envelope ID and serverTimestamp as the canonical values
688
+ if (messageId.startsWith('local-')) {
689
+ messageId = result.messageId;
690
+ timestamp = result.serverTimestamp;
691
+ }
692
+ }
693
+ catch (error) {
694
+ // Recover from a relay stale-device response.
695
+ if (isStaleSessionError(error) && this.staleSessionRefresher) {
696
+ const staleData = error.data;
697
+ this.logger.info('Server detected stale session, refreshing', {
698
+ category: 'E2EE',
699
+ data: {
700
+ code: staleData.code,
701
+ reason: staleData.reason,
702
+ recipientUserId: msg.recipientUserId,
703
+ recipientDeviceId: msg.recipientDeviceId,
704
+ },
705
+ });
706
+ // Refresh the stale session (archive + fetch fresh bundle + re-establish)
707
+ const refreshed = await this.staleSessionRefresher(msg.recipientUserId, msg.recipientDeviceId);
708
+ if (refreshed) {
709
+ // Re-encrypt and retry with fresh session
710
+ const freshBatch = await this.sesameManager.send(recipientUserId, plaintextBytes, {
711
+ clientTimestamp: options?.timestamp,
712
+ });
713
+ const freshMsg = freshBatch.deviceMessages.find((m) => m.recipientUserId === msg.recipientUserId &&
714
+ m.recipientDeviceId === msg.recipientDeviceId);
715
+ if (freshMsg) {
716
+ const freshCiphertext = typeof freshMsg.ciphertext === 'string'
717
+ ? freshMsg.ciphertext
718
+ : CryptoUtils.bytesToBase64(freshMsg.ciphertext);
719
+ // Get fresh session metadata
720
+ const freshSession = await this.sesameManager.getSession(msg.recipientUserId, msg.recipientDeviceId);
721
+ const retryResult = await this.sendToDevice(freshMsg, freshCiphertext, getEnvelopeMessageType(freshMsg.ciphertext), freshSession?.currentSession?.remoteRegistrationId, sealedSender, options?.contentHint, options?.clientMessageId);
722
+ if (messageId.startsWith('local-')) {
723
+ messageId = retryResult.messageId;
724
+ timestamp = retryResult.serverTimestamp;
725
+ }
726
+ this.logger.info('Successfully sent after stale session refresh', {
727
+ category: 'E2EE',
728
+ data: {
729
+ recipientUserId: msg.recipientUserId,
730
+ recipientDeviceId: msg.recipientDeviceId,
731
+ },
732
+ });
733
+ continue; // Successfully sent after refresh
734
+ }
735
+ }
736
+ // If refresh failed or no message for device, throw original error
737
+ throw new EncryptionError(`Failed to refresh stale session: ${staleData.reason}`, EncryptionErrorCode.SESSION_ESTABLISHMENT_FAILED, {
738
+ originalError: error,
739
+ recipientUserId: msg.recipientUserId,
740
+ });
741
+ }
742
+ // Re-throw non-stale errors
743
+ throw error;
744
+ }
745
+ }
746
+ await this.uploadSyncMessages(batch.syncMessages);
747
+ }
748
+ return {
749
+ messageId,
750
+ timestamp,
751
+ recipientDeviceCount: batch.deviceMessages.length,
752
+ };
753
+ }
754
+ /**
755
+ * Resolve sealed sender context for a recipient.
756
+ *
757
+ * Authorization priority:
758
+ * 1. GroupSend endorsement token (for group messages when endorsementManager is set)
759
+ * 2. Per-contact mode-based UAK (existing path)
760
+ *
761
+ * Mode-aware selection for priority 2:
762
+ *
763
+ * | Mode | Behavior |
764
+ * |--------------|----------------------------------------------------------------|
765
+ * | DISABLED | Return null immediately (skip sealed sender) |
766
+ * | UNRESTRICTED | Use zeroed 16-byte key (no profile key needed) |
767
+ * | ENABLED | Derive UAK from profile key; return null if no profile key |
768
+ * | UNKNOWN | Use derived UAK if profile key available, else use zeroed key |
769
+ *
770
+ * Returns null if sealed sender is not enabled or recipient identity is not known.
771
+ * Pre-fetches the sender certificate and identity keys so they can be reused
772
+ * across all device messages in a send batch.
773
+ *
774
+ * @param recipientUserId - User ID of the message recipient
775
+ * @param groupId - Optional group ID; when provided, endorsement-based auth is attempted first
776
+ *
777
+ */
778
+ async resolveSealedSenderContext(recipientUserId, groupId) {
779
+ if (!this.sealedSenderProvider || !this.relay?.sendUnidentified) {
780
+ return null;
781
+ }
782
+ try {
783
+ // Priority 1: GroupSend endorsement (preferred for groups)
784
+ // No profile key needed — endorsement tokens prove group membership via ZK credential
785
+ if (groupId && this.endorsementManager) {
786
+ try {
787
+ // Resolve group secret params for endorsement token generation
788
+ const groupSecretParams = this.groupSecretParamsProvider
789
+ ? await this.groupSecretParamsProvider(groupId)
790
+ : null;
791
+ const endorsementToken = await this.endorsementManager.getTokenForRecipient(groupId, recipientUserId, groupSecretParams ?? undefined);
792
+ if (endorsementToken) {
793
+ const { senderCertificateBase64, senderIdentityPrivate, config } = await this.sealedSenderProvider();
794
+ const recipientAddress = ProtocolAddress.create(recipientUserId, 1);
795
+ const recipientIdentityRecord = await this.storage.getContactIdentity(recipientAddress);
796
+ if (recipientIdentityRecord) {
797
+ const recipientIdentityPublic = base64ToBytes(recipientIdentityRecord.identity.x25519PublicKey);
798
+ return {
799
+ senderCertificateBase64,
800
+ senderIdentityPrivate,
801
+ recipientIdentityPublic,
802
+ config,
803
+ auth: {
804
+ type: 'groupSendToken',
805
+ groupSendToken: endorsementToken.token,
806
+ },
807
+ };
808
+ }
809
+ }
810
+ }
811
+ catch (endorsementError) {
812
+ // Endorsement lookup failed — fall through to UAK path
813
+ this.logger.debug('Endorsement lookup failed, trying UAK', {
814
+ category: 'E2EE',
815
+ data: {
816
+ recipientUserId,
817
+ groupId,
818
+ error: endorsementError.message,
819
+ },
820
+ });
821
+ }
822
+ }
823
+ // Priority 2: Per-contact mode-based UAK (existing path)
824
+ // Check mode first — DISABLED skips sealed sender entirely
825
+ const contactStateStore = this.contactProfileStateStore;
826
+ if (!contactStateStore) {
827
+ this.logger.debug('No contact profile state store configured, using identified delivery', {
828
+ category: 'E2EE',
829
+ data: { recipientUserId, groupId },
830
+ });
831
+ return null;
832
+ }
833
+ const mode = await contactStateStore.getUnidentifiedAccessMode(recipientUserId);
834
+ if (mode === UnidentifiedAccessMode.DISABLED) {
835
+ this.logger.debug('Sealed sender disabled for recipient, using identified delivery', {
836
+ category: 'E2EE',
837
+ data: { recipientUserId, mode },
838
+ });
839
+ return null;
840
+ }
841
+ // Resolve access key based on mode
842
+ const { deriveAccessKey } = await import('../internal/protocol/sealed-sender/delivery-token.js');
843
+ const { bytesToBase64 } = await import('../internal/crypto/index.js');
844
+ let auth;
845
+ switch (mode) {
846
+ case UnidentifiedAccessMode.UNRESTRICTED: {
847
+ // Anyone can send sealed sender — use zeroed 16-byte key
848
+ const zeroedKey = new Uint8Array(16);
849
+ auth = {
850
+ type: 'accessKey',
851
+ unidentifiedAccessKey: bytesToBase64(zeroedKey),
852
+ };
853
+ break;
854
+ }
855
+ case UnidentifiedAccessMode.ENABLED: {
856
+ // Must derive from profile key — fail if unavailable
857
+ const recipientProfileKey = await contactStateStore.getContactProfileKey(recipientUserId);
858
+ if (!recipientProfileKey) {
859
+ this.logger.debug('No profile key for ENABLED recipient, using identified delivery', {
860
+ category: 'E2EE',
861
+ data: { recipientUserId },
862
+ });
863
+ return null;
864
+ }
865
+ const accessKey = await deriveAccessKey(recipientProfileKey);
866
+ auth = {
867
+ type: 'accessKey',
868
+ unidentifiedAccessKey: bytesToBase64(accessKey),
869
+ };
870
+ break;
871
+ }
872
+ case UnidentifiedAccessMode.UNKNOWN:
873
+ default: {
874
+ // Best effort: use derived key if available, else zeroed key
875
+ const recipientProfileKey = await contactStateStore.getContactProfileKey(recipientUserId);
876
+ if (recipientProfileKey) {
877
+ const accessKey = await deriveAccessKey(recipientProfileKey);
878
+ auth = {
879
+ type: 'accessKey',
880
+ unidentifiedAccessKey: bytesToBase64(accessKey),
881
+ };
882
+ }
883
+ else {
884
+ const zeroedKey = new Uint8Array(16);
885
+ auth = {
886
+ type: 'accessKey',
887
+ unidentifiedAccessKey: bytesToBase64(zeroedKey),
888
+ };
889
+ }
890
+ break;
891
+ }
892
+ }
893
+ // Get sender certificate and identity keys
894
+ const { senderCertificateBase64, senderIdentityPrivate, config } = await this.sealedSenderProvider();
895
+ // Get recipient's identity public key (needed for sealed sender DH)
896
+ const recipientAddress = ProtocolAddress.create(recipientUserId, 1);
897
+ const recipientIdentityRecord = await this.storage.getContactIdentity(recipientAddress);
898
+ if (!recipientIdentityRecord) {
899
+ // No identity key on file - fall back to identified delivery
900
+ this.logger.debug('No identity key for recipient, using identified delivery', {
901
+ category: 'E2EE',
902
+ data: { recipientUserId },
903
+ });
904
+ return null;
905
+ }
906
+ const recipientIdentityPublic = base64ToBytes(recipientIdentityRecord.identity.x25519PublicKey);
907
+ return {
908
+ senderCertificateBase64,
909
+ senderIdentityPrivate,
910
+ recipientIdentityPublic,
911
+ config,
912
+ auth,
913
+ };
914
+ }
915
+ catch (error) {
916
+ // Sealed sender is best-effort; fall back to identified delivery on failure
917
+ this.logger.warn('Failed to resolve sealed sender context, using identified delivery', {
918
+ category: 'E2EE',
919
+ data: { recipientUserId, error: error.message },
920
+ });
921
+ return null;
922
+ }
923
+ }
924
+ /**
925
+ * Send a single ciphertext to a device, optionally wrapping with sealed sender.
926
+ *
927
+ * When sealed sender context is available:
928
+ * 1. Wraps the ciphertext with seal() to hide sender identity
929
+ * 2. Uses relay.sendUnidentified() for anonymous delivery
930
+ *
931
+ * On sealed sender auth failure, transitions the recipient's
932
+ * UnidentifiedAccessMode before falling back to identified delivery:
933
+ *
934
+ * | Current Mode | -> New Mode | Rationale |
935
+ * |----------------|-------------|----------------------------------|
936
+ * | UNRESTRICTED | UNKNOWN | Might have wrong info, re-verify |
937
+ * | ENABLED | DISABLED | Key definitely wrong |
938
+ * | UNKNOWN | DISABLED | Confirmed doesn't work |
939
+ *
940
+ */
941
+ async sendToDevice(msg, ciphertextBase64, messageType, recipientRegistrationId, sealedSender, contentHint, clientMessageId) {
942
+ const effectiveClientMessageId = msg.clientMessageId ?? clientMessageId;
943
+ // Sealed sender path: wrap with seal() and use anonymous delivery
944
+ if (sealedSender && this.relay.sendUnidentified) {
945
+ const { sealMessage } = await import('./sealed-sender-ops.js');
946
+ const sealedCiphertext = await sealMessage(ciphertextBase64, sealedSender.senderCertificateBase64, sealedSender.senderIdentityPrivate, sealedSender.recipientIdentityPublic, sealedSender.config, this.logger);
947
+ try {
948
+ return await this.relay.sendUnidentified({
949
+ targetUserId: msg.recipientUserId,
950
+ targetDeviceId: msg.recipientDeviceId,
951
+ senderUserId: '', // Hidden from server
952
+ senderDeviceId: 0,
953
+ ciphertext: sealedCiphertext,
954
+ messageType: 'unidentified_sender',
955
+ groupId: msg.groupId,
956
+ timestamp: msg.timestamp,
957
+ clientMessageId: effectiveClientMessageId,
958
+ contentHint,
959
+ }, sealedSender.auth);
960
+ }
961
+ catch (error) {
962
+ // Fall back to identified delivery only for sealed-sender authorization
963
+ // failures. Other failures retain their original error semantics.
964
+ if (error instanceof SealedSenderAuthError) {
965
+ // Restrict the cached mode after authorization fails.
966
+ try {
967
+ if (this.contactProfileStateStore) {
968
+ const currentMode = await this.contactProfileStateStore.getUnidentifiedAccessMode(msg.recipientUserId);
969
+ let newMode;
970
+ switch (currentMode) {
971
+ case UnidentifiedAccessMode.UNRESTRICTED:
972
+ newMode = UnidentifiedAccessMode.UNKNOWN;
973
+ break;
974
+ case UnidentifiedAccessMode.ENABLED:
975
+ case UnidentifiedAccessMode.UNKNOWN:
976
+ default:
977
+ newMode = UnidentifiedAccessMode.DISABLED;
978
+ break;
979
+ }
980
+ await this.contactProfileStateStore.updateUnidentifiedAccessMode(msg.recipientUserId, newMode);
981
+ this.logger.info('Sealed sender auth failed, transitioned mode and falling back to identified delivery', {
982
+ category: 'E2EE',
983
+ data: {
984
+ recipientUserId: msg.recipientUserId,
985
+ previousMode: currentMode,
986
+ newMode,
987
+ },
988
+ });
989
+ }
990
+ else {
991
+ this.logger.debug('No contact profile state store configured after sealed sender failure', {
992
+ category: 'E2EE',
993
+ data: { recipientUserId: msg.recipientUserId },
994
+ });
995
+ }
996
+ }
997
+ catch (modeError) {
998
+ // Non-fatal: mode transition failure shouldn't block message delivery
999
+ this.logger.warn('Failed to update unidentified access mode after auth failure', {
1000
+ category: 'E2EE',
1001
+ data: {
1002
+ recipientUserId: msg.recipientUserId,
1003
+ error: modeError.message,
1004
+ },
1005
+ });
1006
+ }
1007
+ // Fall through to identified path below
1008
+ }
1009
+ else {
1010
+ throw error;
1011
+ }
1012
+ }
1013
+ }
1014
+ // Identified sender path: standard relay send
1015
+ return this.relay.send({
1016
+ targetUserId: msg.recipientUserId,
1017
+ targetDeviceId: msg.recipientDeviceId,
1018
+ senderUserId: this.userId,
1019
+ senderDeviceId: this.deviceId,
1020
+ ciphertext: ciphertextBase64,
1021
+ messageType,
1022
+ groupId: msg.groupId,
1023
+ timestamp: msg.timestamp,
1024
+ clientMessageId: effectiveClientMessageId,
1025
+ recipientRegistrationId,
1026
+ contentHint,
1027
+ });
1028
+ }
1029
+ /**
1030
+ * Attempt V2 multi-recipient sealed sender send.
1031
+ * Returns null if unavailable — caller falls back to V1.
1032
+ *
1033
+ * Recovery behavior:
1034
+ * - 409 (mismatched devices): refresh device lists, rebuild recipient list, retry once
1035
+ * - 410 (stale sessions): archive stale sessions, retry once
1036
+ * - Other errors: return null for full V1 fallback
1037
+ *
1038
+ */
1039
+ async tryMultiRecipientSend(groupId, otherMembers, encryptedMessageJson, sendTimestamp, clientMessageId) {
1040
+ // Guard checks — return null to trigger V1 fallback
1041
+ if (!this.sealedSenderProvider)
1042
+ return null;
1043
+ if (!this.relay?.sendMultiRecipientUnidentified)
1044
+ return null;
1045
+ if (otherMembers.length < 2)
1046
+ return null;
1047
+ // outer recovery state flags — prevent infinite retry loops
1048
+ //
1049
+ let hasRetriedDevices = false;
1050
+ let hasRetriedSessions = false;
1051
+ let currentMembers = otherMembers;
1052
+ const attemptV2Send = async () => {
1053
+ // Get sender keys (certificate + identity)
1054
+ const senderKeys = await this.sealedSenderProvider();
1055
+ const { base64ToBytes: b64ToBytes, bytesToBase64: bytesToB64 } = await import('../internal/crypto/index.js');
1056
+ // Gather recipient identity keys (per unique userId)
1057
+ const identityByUser = new Map();
1058
+ const uniqueUserIds = [...new Set(currentMembers.map((m) => m.userId))];
1059
+ for (const userId of uniqueUserIds) {
1060
+ const address = ProtocolAddress.create(userId, 1);
1061
+ const identityRecord = await this.storage.getContactIdentity(address);
1062
+ if (identityRecord) {
1063
+ identityByUser.set(userId, b64ToBytes(identityRecord.identity.x25519PublicKey));
1064
+ }
1065
+ }
1066
+ // Split V2-eligible vs V1-fallback
1067
+ const v2Members = [];
1068
+ const v1FallbackMembers = [];
1069
+ for (const member of currentMembers) {
1070
+ if (identityByUser.has(member.userId)) {
1071
+ v2Members.push(member);
1072
+ }
1073
+ else {
1074
+ v1FallbackMembers.push(member);
1075
+ }
1076
+ }
1077
+ // Need at least 2 V2-eligible unique users
1078
+ const v2UniqueUsers = new Set(v2Members.map((m) => m.userId));
1079
+ if (v2UniqueUsers.size < 2)
1080
+ return null;
1081
+ // Build V2 recipients with registration IDs from session state
1082
+ const v2Recipients = [];
1083
+ for (const member of v2Members) {
1084
+ const session = await this.storage.getSessionRecord(ProtocolAddress.create(member.userId, member.deviceId));
1085
+ let registrationId = 0;
1086
+ if (session?.currentSession) {
1087
+ registrationId = session.currentSession.remoteRegistrationId;
1088
+ }
1089
+ v2Recipients.push({
1090
+ serviceId: member.userId,
1091
+ deviceId: member.deviceId,
1092
+ registrationId,
1093
+ identityPublic: identityByUser.get(member.userId),
1094
+ });
1095
+ }
1096
+ // Call sealMultiRecipient()
1097
+ const { sealMultiRecipient } = await import('../internal/protocol/sealed-sender/index.js');
1098
+ const { deserializeSenderCertificate } = await import('../internal/protocol/sealed-sender/index.js');
1099
+ // Parse sender certificate
1100
+ const certBytes = b64ToBytes(senderKeys.senderCertificateBase64);
1101
+ const senderCertificate = deserializeSenderCertificate(certBytes);
1102
+ // Convert encryptedMessageJson to bytes for the seal
1103
+ const signalProtocolMessage = new TextEncoder().encode(encryptedMessageJson);
1104
+ // Group ID as bytes
1105
+ const groupIdBytes = new TextEncoder().encode(groupId);
1106
+ const sealResult = await sealMultiRecipient({
1107
+ senderCertificate,
1108
+ senderIdentityPrivate: senderKeys.senderIdentityPrivate,
1109
+ senderIdentityPublic: senderKeys.senderIdentityPublic,
1110
+ recipients: v2Recipients,
1111
+ signalProtocolMessage,
1112
+ groupId: groupIdBytes,
1113
+ });
1114
+ // Serialize to binary
1115
+ const { serializeSentMessage } = await import('../internal/protocol/sealed-sender/v2-binary.js');
1116
+ // Group recipients by serviceId for the binary format
1117
+ const recipientsByUser = new Map();
1118
+ for (const entry of sealResult.recipients) {
1119
+ const existing = recipientsByUser.get(entry.serviceId);
1120
+ if (existing) {
1121
+ existing.devices.push({
1122
+ deviceId: entry.deviceId,
1123
+ registrationId: entry.registrationId,
1124
+ });
1125
+ }
1126
+ else {
1127
+ recipientsByUser.set(entry.serviceId, {
1128
+ serviceId: entry.serviceId,
1129
+ devices: [
1130
+ {
1131
+ deviceId: entry.deviceId,
1132
+ registrationId: entry.registrationId,
1133
+ },
1134
+ ],
1135
+ encryptedMessageKey: b64ToBytes(entry.encryptedMessageKey),
1136
+ authenticationTag: b64ToBytes(entry.authenticationTag),
1137
+ });
1138
+ }
1139
+ }
1140
+ const binaryBlob = serializeSentMessage(Array.from(recipientsByUser.values()), [], // No excluded recipients for now
1141
+ b64ToBytes(sealResult.ephemeralPublic), b64ToBytes(sealResult.messageCiphertext));
1142
+ const sentMessageBase64 = bytesToB64(binaryBlob);
1143
+ // Get combined auth token
1144
+ if (!this.endorsementManager)
1145
+ return null;
1146
+ const groupSecretParams = this.groupSecretParamsProvider
1147
+ ? await this.groupSecretParamsProvider(groupId)
1148
+ : null;
1149
+ const v2UserIds = [...v2UniqueUsers];
1150
+ // Pre-send endorsement refresh
1151
+ const { needsRefresh, reason } = await this.endorsementManager.shouldRefreshEndorsements(groupId, v2UserIds);
1152
+ if (needsRefresh && this.endorsementRefresher) {
1153
+ try {
1154
+ await this.endorsementRefresher(groupId, v2UserIds);
1155
+ this.logger.debug('Refreshed endorsements before V2 send', {
1156
+ category: 'E2EE',
1157
+ data: { groupId, reason },
1158
+ });
1159
+ }
1160
+ catch (refreshErr) {
1161
+ this.logger.debug('Pre-send endorsement refresh failed, will attempt V1 fallback', {
1162
+ category: 'E2EE',
1163
+ data: { groupId, error: refreshErr.message },
1164
+ });
1165
+ }
1166
+ }
1167
+ const combinedToken = await this.endorsementManager.getCombinedToken(groupId, v2UserIds, groupSecretParams ?? undefined);
1168
+ if (!combinedToken)
1169
+ return null;
1170
+ const auth = {
1171
+ type: 'groupSendToken',
1172
+ groupSendToken: combinedToken.token,
1173
+ };
1174
+ // Send via relay
1175
+ const recipientUserIds = Array.from(recipientsByUser.keys());
1176
+ const result = await this.relay.sendMultiRecipientUnidentified(sentMessageBase64, auth, sendTimestamp, groupId, recipientUserIds, clientMessageId);
1177
+ // Send to V1 fallback members via per-device fanout
1178
+ if (v1FallbackMembers.length > 0) {
1179
+ const sealedSenderByUser = new Map();
1180
+ const fallbackUserIds = [...new Set(v1FallbackMembers.map((m) => m.userId))];
1181
+ for (const userId of fallbackUserIds) {
1182
+ sealedSenderByUser.set(userId, await this.resolveSealedSenderContext(userId, groupId));
1183
+ }
1184
+ for (const member of v1FallbackMembers) {
1185
+ const sealedSender = sealedSenderByUser.get(member.userId) ?? null;
1186
+ await this.sendToDevice({
1187
+ recipientUserId: member.userId,
1188
+ recipientDeviceId: member.deviceId,
1189
+ timestamp: sendTimestamp,
1190
+ groupId,
1191
+ }, encryptedMessageJson, 'ciphertext', undefined, sealedSender, undefined, clientMessageId);
1192
+ }
1193
+ }
1194
+ return {
1195
+ messageId: result.messageId,
1196
+ serverTimestamp: result.serverTimestamp,
1197
+ };
1198
+ };
1199
+ try {
1200
+ return await attemptV2Send();
1201
+ }
1202
+ catch (error) {
1203
+ const errorMessage = error.message ?? '';
1204
+ // 409: Mismatched devices — refresh device lists and retry once
1205
+ // the application send pipeline
1206
+ if (!hasRetriedDevices && isMismatchedDevicesError(errorMessage)) {
1207
+ hasRetriedDevices = true;
1208
+ this.logger.info('V2 send got mismatched devices (409), refreshing and retrying', {
1209
+ category: 'E2EE',
1210
+ data: { groupId },
1211
+ });
1212
+ try {
1213
+ // Refresh device lists for all affected users
1214
+ const uniqueUserIds = [...new Set(currentMembers.map((m) => m.userId))];
1215
+ const refreshedDevices = await Promise.all(uniqueUserIds.map((uid) => this.relay.getActiveDevices(uid)));
1216
+ currentMembers = refreshedDevices.flat().filter((m) => m.userId !== this.userId);
1217
+ return await attemptV2Send();
1218
+ }
1219
+ catch (retryError) {
1220
+ this.logger.debug('V2 retry after device refresh failed, falling back to V1', {
1221
+ category: 'E2EE',
1222
+ data: { groupId, error: retryError.message },
1223
+ });
1224
+ return null;
1225
+ }
1226
+ }
1227
+ // 410: Stale sessions — archive and retry once
1228
+ // the application send pipeline
1229
+ if (!hasRetriedSessions && isStaleSessionV2Error(errorMessage)) {
1230
+ hasRetriedSessions = true;
1231
+ this.logger.info('V2 send got stale sessions (410), archiving and retrying', {
1232
+ category: 'E2EE',
1233
+ data: { groupId },
1234
+ });
1235
+ try {
1236
+ // Archive stale sessions for all affected devices and re-establish
1237
+ if (this.staleSessionRefresher) {
1238
+ for (const member of currentMembers) {
1239
+ await this.staleSessionRefresher(member.userId, member.deviceId).catch(() => {
1240
+ // Non-fatal: some devices might not have stale sessions
1241
+ });
1242
+ }
1243
+ }
1244
+ return await attemptV2Send();
1245
+ }
1246
+ catch (retryError) {
1247
+ this.logger.debug('V2 retry after session refresh failed, falling back to V1', {
1248
+ category: 'E2EE',
1249
+ data: { groupId, error: retryError.message },
1250
+ });
1251
+ return null;
1252
+ }
1253
+ }
1254
+ // All other errors: V1 fallback
1255
+ this.logger.debug('V2 multi-recipient send failed, falling back to V1', {
1256
+ category: 'E2EE',
1257
+ data: { groupId, error: errorMessage },
1258
+ });
1259
+ return null;
1260
+ }
1261
+ }
1262
+ /**
1263
+ * V1 per-device sealed sender fanout (legacy path, used as fallback).
1264
+ */
1265
+ async perDeviceFanoutSend(groupId, otherMembers, encryptedMessageJson, sendTimestamp, clientMessageId) {
1266
+ // Pre-send endorsement freshness check (non-blocking, log only)
1267
+ // Actual refresh is handled at orchestration layer (group-service.ts)
1268
+ if (this.endorsementManager) {
1269
+ const uniqueUserIds = [...new Set(otherMembers.map((m) => m.userId))];
1270
+ const { needsRefresh, reason } = await this.endorsementManager.shouldRefreshEndorsements(groupId, uniqueUserIds);
1271
+ if (needsRefresh) {
1272
+ this.logger.debug('Group endorsements need refresh before send', {
1273
+ category: 'E2EE',
1274
+ data: { groupId, reason },
1275
+ });
1276
+ }
1277
+ }
1278
+ // Resolve sealed sender context per unique recipient (not per device)
1279
+ // Identity keys and endorsement tokens are per-user, shared across devices
1280
+ const sealedSenderByUser = new Map();
1281
+ const uniqueRecipientIds = [...new Set(otherMembers.map((m) => m.userId))];
1282
+ for (const userId of uniqueRecipientIds) {
1283
+ sealedSenderByUser.set(userId, await this.resolveSealedSenderContext(userId, groupId));
1284
+ }
1285
+ // Send to each member device (sendToDevice handles seal + fallback)
1286
+ let firstResult;
1287
+ for (const member of otherMembers) {
1288
+ const sealedSender = sealedSenderByUser.get(member.userId) ?? null;
1289
+ const result = await this.sendToDevice({
1290
+ recipientUserId: member.userId,
1291
+ recipientDeviceId: member.deviceId,
1292
+ timestamp: sendTimestamp,
1293
+ groupId,
1294
+ }, encryptedMessageJson, 'ciphertext', undefined, sealedSender, undefined, clientMessageId);
1295
+ if (!firstResult)
1296
+ firstResult = result;
1297
+ }
1298
+ return firstResult;
1299
+ }
1300
+ /**
1301
+ * Encrypt to a group via Sender Keys (O(1) encryption)
1302
+ *
1303
+ * Prefers V2 multi-recipient sealed sender when available, falls back to
1304
+ * V1 per-device fanout.
1305
+ */
1306
+ async encryptToGroup(groupId, plaintextBytes, options) {
1307
+ // Extract actual group ID from prefixed format
1308
+ const actualGroupId = extractGroupId(groupId);
1309
+ // Require sender key to exist - caller (SignalProtocolClient.createGroupSenderKey) must create it first
1310
+ // This ensures proper sender key distribution to group members before sending
1311
+ const existingKey = await this.storage.getSenderKey(actualGroupId, this.userId, this.deviceId);
1312
+ if (!existingKey) {
1313
+ throw new EncryptionError(`No sender key for group ${actualGroupId}. Call createGroupSenderKey() first to create and distribute the key.`, EncryptionErrorCode.SESSION_NOT_FOUND, {
1314
+ groupId: actualGroupId,
1315
+ userId: this.userId,
1316
+ deviceId: this.deviceId,
1317
+ });
1318
+ }
1319
+ // Encrypt with sender key (O(1) - single encryption for all members)
1320
+ // Auto-rotate on SENDER_KEY_EXPIRED
1321
+ let encrypted;
1322
+ try {
1323
+ encrypted = await this.senderKeyManager.encryptGroupMessage(actualGroupId, this.userId, this.deviceId, plaintextBytes);
1324
+ }
1325
+ catch (error) {
1326
+ if (error instanceof EncryptionError &&
1327
+ error.code === EncryptionErrorCode.SENDER_KEY_EXPIRED) {
1328
+ this.logger.info('Sender key expired, auto-rotating', {
1329
+ category: 'E2EE',
1330
+ data: { groupId: actualGroupId },
1331
+ });
1332
+ // Rotate sender key (generates new key material + increments generation)
1333
+ const { distributionMessage } = await this.senderKeyManager.rotateSenderKey(actualGroupId, this.userId, this.deviceId);
1334
+ // Redistribute new sender key to all group members via relay
1335
+ if (this.relay) {
1336
+ const members = options?.groupMemberUserIds?.length
1337
+ ? (await Promise.all(options.groupMemberUserIds.map((uid) => this.relay.getActiveDevices(uid)))).flat()
1338
+ : await this.relay.getGroupMembers(actualGroupId);
1339
+ const otherMembers = members.filter((m) => m.userId !== this.userId);
1340
+ for (const member of otherMembers) {
1341
+ // Send SKDM via pairwise session (same as initial distribution)
1342
+ await this.ensureSessionsForUser(member.userId);
1343
+ // Serialize SKDM as ProtoContentData with senderKeyDistributionMessage field
1344
+ // The string field contains JSON-encoded {groupId, ...distributionMessage}
1345
+ const skdmBytes = this.contentAdapter
1346
+ ? this.contentAdapter.serializeSenderKeyDistributionBytes(actualGroupId, distributionMessage)
1347
+ : new TextEncoder().encode(JSON.stringify({
1348
+ senderKeyDistributionMessage: JSON.stringify({
1349
+ groupId: actualGroupId,
1350
+ ...distributionMessage,
1351
+ }),
1352
+ }));
1353
+ const batch = await this.sesameManager.send(member.userId, skdmBytes, {});
1354
+ for (const msg of batch.deviceMessages) {
1355
+ const ciphertextBase64 = typeof msg.ciphertext === 'string'
1356
+ ? msg.ciphertext
1357
+ : CryptoUtils.bytesToBase64(msg.ciphertext);
1358
+ await this.relay.send({
1359
+ targetUserId: msg.recipientUserId,
1360
+ targetDeviceId: msg.recipientDeviceId,
1361
+ senderUserId: this.userId,
1362
+ senderDeviceId: this.deviceId,
1363
+ ciphertext: ciphertextBase64,
1364
+ messageType: getEnvelopeMessageType(msg.ciphertext),
1365
+ groupId: actualGroupId,
1366
+ timestamp: msg.timestamp,
1367
+ });
1368
+ }
1369
+ }
1370
+ }
1371
+ // Retry encryption with the new key (once — no infinite loop)
1372
+ encrypted = await this.senderKeyManager.encryptGroupMessage(actualGroupId, this.userId, this.deviceId, plaintextBytes);
1373
+ }
1374
+ else {
1375
+ throw error;
1376
+ }
1377
+ }
1378
+ // Send encrypted message via relay
1379
+ let messageId = `local-${Date.now()}`;
1380
+ let timestamp = Date.now(); // Fallback if no relay
1381
+ let recipientDeviceCount = 0;
1382
+ if (this.relay) {
1383
+ // Resolve group members → devices. Prefer caller-provided member list
1384
+ // (local-first: membership lives in SQLite, not on server).
1385
+ // Falls back to relay.getGroupMembers() for in-memory adapters.
1386
+ let members;
1387
+ if (options?.groupMemberUserIds?.length) {
1388
+ const deviceResults = await Promise.all(options.groupMemberUserIds.map((userId) => this.relay.getActiveDevices(userId)));
1389
+ members = deviceResults.flat();
1390
+ }
1391
+ else {
1392
+ members = await this.relay.getGroupMembers(actualGroupId);
1393
+ }
1394
+ // Framed SenderKeyMessage bytes → base64 for transport
1395
+ const encryptedMessageJson = CryptoUtils.bytesToBase64(encrypted);
1396
+ const sendTimestamp = options?.timestamp ?? Date.now();
1397
+ // Filter to other members (skip self — the application send pipeline)
1398
+ const otherMembers = members.filter((m) => m.userId !== this.userId);
1399
+ recipientDeviceCount = otherMembers.length;
1400
+ // Try V2 multi-recipient first
1401
+ const v2Result = await this.tryMultiRecipientSend(actualGroupId, otherMembers, encryptedMessageJson, sendTimestamp, options?.clientMessageId);
1402
+ if (v2Result) {
1403
+ messageId = v2Result.messageId;
1404
+ timestamp = v2Result.serverTimestamp;
1405
+ this.logger.debug('Group message sent via V2 multi-recipient', {
1406
+ category: 'E2EE',
1407
+ data: { groupId: actualGroupId, recipientDeviceCount, messageId },
1408
+ });
1409
+ }
1410
+ else {
1411
+ // V1 fallback
1412
+ const v1Result = await this.perDeviceFanoutSend(actualGroupId, otherMembers, encryptedMessageJson, sendTimestamp, options?.clientMessageId);
1413
+ if (v1Result) {
1414
+ messageId = v1Result.messageId;
1415
+ timestamp = v1Result.serverTimestamp;
1416
+ }
1417
+ else {
1418
+ messageId = `group-${actualGroupId}-${timestamp}`;
1419
+ }
1420
+ this.logger.debug('Group message sent via V1 per-device fanout', {
1421
+ category: 'E2EE',
1422
+ data: { groupId: actualGroupId, recipientDeviceCount, messageId },
1423
+ });
1424
+ }
1425
+ await this.sendSyncTranscriptToLocalOtherDevices(actualGroupId, plaintextBytes, sendTimestamp);
1426
+ }
1427
+ return {
1428
+ messageId,
1429
+ timestamp,
1430
+ recipientDeviceCount,
1431
+ groupId: actualGroupId,
1432
+ };
1433
+ }
1434
+ /**
1435
+ * Encrypt binary attachment with two-layer encryption
1436
+ *
1437
+ * Layer 1: AES-GCM-HKDF Streaming encrypts the file (Tink format)
1438
+ * Layer 2: Signal Protocol encrypts the AES key + metadata
1439
+ *
1440
+ * Uses streaming AEAD for:
1441
+ * - Per-chunk integrity verification
1442
+ * - Streaming decryption (video playback while downloading)
1443
+ * - Truncation detection via last-segment flag
1444
+ *
1445
+ * @param recipientId - User or group ID to send to
1446
+ * @param data - Binary file data as Uint8Array (use expo-file-system File.bytes())
1447
+ * @param options - Send options including mimeType, blurHash, dimensions
1448
+ *
1449
+ * @see https://developers.google.com/tink/streaming-aead/aes_gcm_hkdf_streaming
1450
+ */
1451
+ async encryptBinaryAttachment(recipientId, data, options) {
1452
+ if (!this.relay) {
1453
+ throw new EncryptionError('Relay server not configured. Cannot send attachments without server connection.', EncryptionErrorCode.INITIALIZATION_FAILED);
1454
+ }
1455
+ const uploaded = await this.prepareAttachmentUpload(data, options);
1456
+ const attachmentPayload = serializeMediaAttachmentMessage({
1457
+ attachment: uploaded,
1458
+ timestamp: options?.timestamp ?? Date.now(),
1459
+ });
1460
+ const attachmentBytes = new TextEncoder().encode(attachmentPayload);
1461
+ let result;
1462
+ if (isGroupId(recipientId)) {
1463
+ result = await this.encryptToGroup(recipientId, attachmentBytes, options);
1464
+ }
1465
+ else {
1466
+ result = await this.encryptToUser(recipientId, attachmentBytes, options);
1467
+ }
1468
+ return {
1469
+ ...result,
1470
+ storageId: uploaded.storageId,
1471
+ aesKey: uploaded.key,
1472
+ segmentSize: uploaded.segmentSize,
1473
+ digest: uploaded.digest,
1474
+ contentType: uploaded.contentType,
1475
+ };
1476
+ }
1477
+ async prepareAttachmentUpload(data, options) {
1478
+ if (!this.remoteObjectStore) {
1479
+ throw new EncryptionError('Remote object storage not configured. Provide remoteObjectStore in SignalProtocolClient.create() config.', EncryptionErrorCode.INITIALIZATION_FAILED);
1480
+ }
1481
+ return prepareMediaAttachmentUpload(data, {
1482
+ remoteObjectStore: this.remoteObjectStore,
1483
+ transfer: options?.attachment?.transfer,
1484
+ retry: options?.attachment?.retry,
1485
+ policy: options?.attachment?.policy,
1486
+ signal: options?.attachment?.signal,
1487
+ onProgress: options?.attachment?.onProgress,
1488
+ onCheckpoint: options?.attachment?.onCheckpoint,
1489
+ resume: options?.attachment?.resume,
1490
+ contentType: options?.mimeType || 'application/octet-stream',
1491
+ blurHash: options?.blurHash,
1492
+ thumbnail: options?.thumbnail,
1493
+ width: options?.width,
1494
+ height: options?.height,
1495
+ durationMs: options?.durationMs,
1496
+ waveform: options?.waveform,
1497
+ fileName: options?.fileName,
1498
+ caption: options?.caption,
1499
+ isViewOnce: options?.isViewOnce,
1500
+ flags: options?.flags,
1501
+ clientUuid: options?.clientUuid,
1502
+ cdnNumber: options?.cdnNumber,
1503
+ });
1504
+ }
1505
+ }
1506
+ //# sourceMappingURL=signal-service-cipher.js.map