@drakkar.software/octobot-client 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (306) hide show
  1. package/README.md +140 -0
  2. package/dist/client/adapters/accounts.d.ts +66 -0
  3. package/dist/client/adapters/accounts.d.ts.map +1 -0
  4. package/dist/client/adapters/accounts.js +214 -0
  5. package/dist/client/adapters/accounts.js.map +1 -0
  6. package/dist/client/adapters/actionHandle.d.ts +29 -0
  7. package/dist/client/adapters/actionHandle.d.ts.map +1 -0
  8. package/dist/client/adapters/actionHandle.js +34 -0
  9. package/dist/client/adapters/actionHandle.js.map +1 -0
  10. package/dist/client/adapters/automations.d.ts +31 -0
  11. package/dist/client/adapters/automations.d.ts.map +1 -0
  12. package/dist/client/adapters/automations.js +79 -0
  13. package/dist/client/adapters/automations.js.map +1 -0
  14. package/dist/client/adapters/documents.d.ts +55 -0
  15. package/dist/client/adapters/documents.d.ts.map +1 -0
  16. package/dist/client/adapters/documents.js +66 -0
  17. package/dist/client/adapters/documents.js.map +1 -0
  18. package/dist/client/adapters/nodeApi.d.ts +25 -0
  19. package/dist/client/adapters/nodeApi.d.ts.map +1 -0
  20. package/dist/client/adapters/nodeApi.js +81 -0
  21. package/dist/client/adapters/nodeApi.js.map +1 -0
  22. package/dist/client/adapters/settings.d.ts +16 -0
  23. package/dist/client/adapters/settings.d.ts.map +1 -0
  24. package/dist/client/adapters/settings.js +43 -0
  25. package/dist/client/adapters/settings.js.map +1 -0
  26. package/dist/client/adapters/strategies.d.ts +17 -0
  27. package/dist/client/adapters/strategies.d.ts.map +1 -0
  28. package/dist/client/adapters/strategies.js +75 -0
  29. package/dist/client/adapters/strategies.js.map +1 -0
  30. package/dist/client/connect/connect.d.ts +40 -0
  31. package/dist/client/connect/connect.d.ts.map +1 -0
  32. package/dist/client/connect/connect.js +133 -0
  33. package/dist/client/connect/connect.js.map +1 -0
  34. package/dist/client/connect/readOnly.d.ts +97 -0
  35. package/dist/client/connect/readOnly.d.ts.map +1 -0
  36. package/dist/client/connect/readOnly.js +167 -0
  37. package/dist/client/connect/readOnly.js.map +1 -0
  38. package/dist/client/core/errors.d.ts +80 -0
  39. package/dist/client/core/errors.d.ts.map +1 -0
  40. package/dist/client/core/errors.js +154 -0
  41. package/dist/client/core/errors.js.map +1 -0
  42. package/dist/client/core/options.d.ts +44 -0
  43. package/dist/client/core/options.d.ts.map +1 -0
  44. package/dist/client/core/options.js +2 -0
  45. package/dist/client/core/options.js.map +1 -0
  46. package/dist/client/core/session.d.ts +90 -0
  47. package/dist/client/core/session.d.ts.map +1 -0
  48. package/dist/client/core/session.js +72 -0
  49. package/dist/client/core/session.js.map +1 -0
  50. package/dist/client/core/views.d.ts +40 -0
  51. package/dist/client/core/views.d.ts.map +1 -0
  52. package/dist/client/core/views.js +32 -0
  53. package/dist/client/core/views.js.map +1 -0
  54. package/dist/client/index.d.ts +16 -0
  55. package/dist/client/index.d.ts.map +1 -0
  56. package/dist/client/index.js +9 -0
  57. package/dist/client/index.js.map +1 -0
  58. package/dist/client/mirror/collections.d.ts +125 -0
  59. package/dist/client/mirror/collections.d.ts.map +1 -0
  60. package/dist/client/mirror/collections.js +118 -0
  61. package/dist/client/mirror/collections.js.map +1 -0
  62. package/dist/client/mirror/index.d.ts +4 -0
  63. package/dist/client/mirror/index.d.ts.map +1 -0
  64. package/dist/client/mirror/index.js +4 -0
  65. package/dist/client/mirror/index.js.map +1 -0
  66. package/dist/client/mirror/writer.d.ts +39 -0
  67. package/dist/client/mirror/writer.d.ts.map +1 -0
  68. package/dist/client/mirror/writer.js +50 -0
  69. package/dist/client/mirror/writer.js.map +1 -0
  70. package/dist/client/pairing/mirrorGrant.d.ts +91 -0
  71. package/dist/client/pairing/mirrorGrant.d.ts.map +1 -0
  72. package/dist/client/pairing/mirrorGrant.js +99 -0
  73. package/dist/client/pairing/mirrorGrant.js.map +1 -0
  74. package/dist/client/pairing/mirrorReader.d.ts +99 -0
  75. package/dist/client/pairing/mirrorReader.d.ts.map +1 -0
  76. package/dist/client/pairing/mirrorReader.js +117 -0
  77. package/dist/client/pairing/mirrorReader.js.map +1 -0
  78. package/dist/client/pairing/pairingGrantExchange.d.ts +135 -0
  79. package/dist/client/pairing/pairingGrantExchange.d.ts.map +1 -0
  80. package/dist/client/pairing/pairingGrantExchange.js +186 -0
  81. package/dist/client/pairing/pairingGrantExchange.js.map +1 -0
  82. package/dist/client/pairing/pairingRequest.d.ts +82 -0
  83. package/dist/client/pairing/pairingRequest.d.ts.map +1 -0
  84. package/dist/client/pairing/pairingRequest.js +120 -0
  85. package/dist/client/pairing/pairingRequest.js.map +1 -0
  86. package/dist/client/strategy.d.ts +36 -0
  87. package/dist/client/strategy.d.ts.map +1 -0
  88. package/dist/client/strategy.js +26 -0
  89. package/dist/client/strategy.js.map +1 -0
  90. package/dist/collections/index.d.ts +3 -0
  91. package/dist/collections/index.d.ts.map +1 -0
  92. package/dist/collections/index.js +3 -0
  93. package/dist/collections/index.js.map +1 -0
  94. package/dist/collections/nodeCollections.d.ts +57 -0
  95. package/dist/collections/nodeCollections.d.ts.map +1 -0
  96. package/dist/collections/nodeCollections.js +40 -0
  97. package/dist/collections/nodeCollections.js.map +1 -0
  98. package/dist/collections/paths.d.ts +7 -0
  99. package/dist/collections/paths.d.ts.map +1 -0
  100. package/dist/collections/paths.js +13 -0
  101. package/dist/collections/paths.js.map +1 -0
  102. package/dist/crypto/collectionKeys.d.ts +28 -0
  103. package/dist/crypto/collectionKeys.d.ts.map +1 -0
  104. package/dist/crypto/collectionKeys.js +53 -0
  105. package/dist/crypto/collectionKeys.js.map +1 -0
  106. package/dist/crypto/hkdf.d.ts +14 -0
  107. package/dist/crypto/hkdf.d.ts.map +1 -0
  108. package/dist/crypto/hkdf.js +19 -0
  109. package/dist/crypto/hkdf.js.map +1 -0
  110. package/dist/crypto/index.d.ts +5 -0
  111. package/dist/crypto/index.d.ts.map +1 -0
  112. package/dist/crypto/index.js +5 -0
  113. package/dist/crypto/index.js.map +1 -0
  114. package/dist/crypto/secretEncryptor.d.ts +20 -0
  115. package/dist/crypto/secretEncryptor.d.ts.map +1 -0
  116. package/dist/crypto/secretEncryptor.js +82 -0
  117. package/dist/crypto/secretEncryptor.js.map +1 -0
  118. package/dist/crypto/wireConstants.d.ts +14 -0
  119. package/dist/crypto/wireConstants.d.ts.map +1 -0
  120. package/dist/crypto/wireConstants.js +17 -0
  121. package/dist/crypto/wireConstants.js.map +1 -0
  122. package/dist/identity/address.d.ts +3 -0
  123. package/dist/identity/address.d.ts.map +1 -0
  124. package/dist/identity/address.js +17 -0
  125. package/dist/identity/address.js.map +1 -0
  126. package/dist/identity/bip39-wordlist.d.ts +2 -0
  127. package/dist/identity/bip39-wordlist.d.ts.map +1 -0
  128. package/dist/identity/bip39-wordlist.js +2051 -0
  129. package/dist/identity/bip39-wordlist.js.map +1 -0
  130. package/dist/identity/capProvider.d.ts +45 -0
  131. package/dist/identity/capProvider.d.ts.map +1 -0
  132. package/dist/identity/capProvider.js +80 -0
  133. package/dist/identity/capProvider.js.map +1 -0
  134. package/dist/identity/derivationSchemes.d.ts +25 -0
  135. package/dist/identity/derivationSchemes.d.ts.map +1 -0
  136. package/dist/identity/derivationSchemes.js +34 -0
  137. package/dist/identity/derivationSchemes.js.map +1 -0
  138. package/dist/identity/evm.d.ts +8 -0
  139. package/dist/identity/evm.d.ts.map +1 -0
  140. package/dist/identity/evm.js +78 -0
  141. package/dist/identity/evm.js.map +1 -0
  142. package/dist/identity/index.d.ts +10 -0
  143. package/dist/identity/index.d.ts.map +1 -0
  144. package/dist/identity/index.js +10 -0
  145. package/dist/identity/index.js.map +1 -0
  146. package/dist/identity/keys.d.ts +17 -0
  147. package/dist/identity/keys.d.ts.map +1 -0
  148. package/dist/identity/keys.js +36 -0
  149. package/dist/identity/keys.js.map +1 -0
  150. package/dist/identity/mnemonic.d.ts +4 -0
  151. package/dist/identity/mnemonic.d.ts.map +1 -0
  152. package/dist/identity/mnemonic.js +93 -0
  153. package/dist/identity/mnemonic.js.map +1 -0
  154. package/dist/identity/pairing.d.ts +45 -0
  155. package/dist/identity/pairing.d.ts.map +1 -0
  156. package/dist/identity/pairing.js +91 -0
  157. package/dist/identity/pairing.js.map +1 -0
  158. package/dist/identity/pairingRequest.d.ts +99 -0
  159. package/dist/identity/pairingRequest.d.ts.map +1 -0
  160. package/dist/identity/pairingRequest.js +217 -0
  161. package/dist/identity/pairingRequest.js.map +1 -0
  162. package/dist/identity/secret.d.ts +32 -0
  163. package/dist/identity/secret.d.ts.map +1 -0
  164. package/dist/identity/secret.js +54 -0
  165. package/dist/identity/secret.js.map +1 -0
  166. package/dist/index.d.ts +9 -0
  167. package/dist/index.d.ts.map +1 -0
  168. package/dist/index.js +18 -0
  169. package/dist/index.js.map +1 -0
  170. package/dist/internal/bytes.d.ts +11 -0
  171. package/dist/internal/bytes.d.ts.map +1 -0
  172. package/dist/internal/bytes.js +38 -0
  173. package/dist/internal/bytes.js.map +1 -0
  174. package/dist/node-api/dexPair.d.ts +24 -0
  175. package/dist/node-api/dexPair.d.ts.map +1 -0
  176. package/dist/node-api/dexPair.js +39 -0
  177. package/dist/node-api/dexPair.js.map +1 -0
  178. package/dist/node-api/dsl.d.ts +10 -0
  179. package/dist/node-api/dsl.d.ts.map +1 -0
  180. package/dist/node-api/dsl.js +7 -0
  181. package/dist/node-api/dsl.js.map +1 -0
  182. package/dist/node-api/exchanges.d.ts +49 -0
  183. package/dist/node-api/exchanges.d.ts.map +1 -0
  184. package/dist/node-api/exchanges.js +32 -0
  185. package/dist/node-api/exchanges.js.map +1 -0
  186. package/dist/node-api/index.d.ts +12 -0
  187. package/dist/node-api/index.d.ts.map +1 -0
  188. package/dist/node-api/index.js +12 -0
  189. package/dist/node-api/index.js.map +1 -0
  190. package/dist/node-api/marketMaking.d.ts +39 -0
  191. package/dist/node-api/marketMaking.d.ts.map +1 -0
  192. package/dist/node-api/marketMaking.js +44 -0
  193. package/dist/node-api/marketMaking.js.map +1 -0
  194. package/dist/node-api/octobots.d.ts +14 -0
  195. package/dist/node-api/octobots.d.ts.map +1 -0
  196. package/dist/node-api/octobots.js +16 -0
  197. package/dist/node-api/octobots.js.map +1 -0
  198. package/dist/node-api/orderBookPreview.d.ts +11 -0
  199. package/dist/node-api/orderBookPreview.d.ts.map +1 -0
  200. package/dist/node-api/orderBookPreview.js +7 -0
  201. package/dist/node-api/orderBookPreview.js.map +1 -0
  202. package/dist/node-api/pairing.d.ts +39 -0
  203. package/dist/node-api/pairing.d.ts.map +1 -0
  204. package/dist/node-api/pairing.js +61 -0
  205. package/dist/node-api/pairing.js.map +1 -0
  206. package/dist/node-api/pairs.d.ts +32 -0
  207. package/dist/node-api/pairs.d.ts.map +1 -0
  208. package/dist/node-api/pairs.js +72 -0
  209. package/dist/node-api/pairs.js.map +1 -0
  210. package/dist/node-api/requiredFunds.d.ts +11 -0
  211. package/dist/node-api/requiredFunds.d.ts.map +1 -0
  212. package/dist/node-api/requiredFunds.js +7 -0
  213. package/dist/node-api/requiredFunds.js.map +1 -0
  214. package/dist/node-api/setup.d.ts +25 -0
  215. package/dist/node-api/setup.d.ts.map +1 -0
  216. package/dist/node-api/setup.js +13 -0
  217. package/dist/node-api/setup.js.map +1 -0
  218. package/dist/node-api/wallet.d.ts +55 -0
  219. package/dist/node-api/wallet.d.ts.map +1 -0
  220. package/dist/node-api/wallet.js +87 -0
  221. package/dist/node-api/wallet.js.map +1 -0
  222. package/dist/protocol/actions.d.ts +40 -0
  223. package/dist/protocol/actions.d.ts.map +1 -0
  224. package/dist/protocol/actions.js +118 -0
  225. package/dist/protocol/actions.js.map +1 -0
  226. package/dist/protocol/documents.d.ts +25 -0
  227. package/dist/protocol/documents.d.ts.map +1 -0
  228. package/dist/protocol/documents.js +2 -0
  229. package/dist/protocol/documents.js.map +1 -0
  230. package/dist/protocol/index.d.ts +10 -0
  231. package/dist/protocol/index.d.ts.map +1 -0
  232. package/dist/protocol/index.js +12 -0
  233. package/dist/protocol/index.js.map +1 -0
  234. package/dist/protocol/orchestration/createAutomation.d.ts +61 -0
  235. package/dist/protocol/orchestration/createAutomation.d.ts.map +1 -0
  236. package/dist/protocol/orchestration/createAutomation.js +71 -0
  237. package/dist/protocol/orchestration/createAutomation.js.map +1 -0
  238. package/dist/protocol/poll.d.ts +4 -0
  239. package/dist/protocol/poll.d.ts.map +1 -0
  240. package/dist/protocol/poll.js +4 -0
  241. package/dist/protocol/poll.js.map +1 -0
  242. package/dist/protocol/proposal.d.ts +36 -0
  243. package/dist/protocol/proposal.d.ts.map +1 -0
  244. package/dist/protocol/proposal.js +39 -0
  245. package/dist/protocol/proposal.js.map +1 -0
  246. package/dist/protocol/state.d.ts +87 -0
  247. package/dist/protocol/state.d.ts.map +1 -0
  248. package/dist/protocol/state.js +303 -0
  249. package/dist/protocol/state.js.map +1 -0
  250. package/dist/protocol/strategy/build.d.ts +44 -0
  251. package/dist/protocol/strategy/build.d.ts.map +1 -0
  252. package/dist/protocol/strategy/build.js +50 -0
  253. package/dist/protocol/strategy/build.js.map +1 -0
  254. package/dist/protocol/strategy/builders.d.ts +252 -0
  255. package/dist/protocol/strategy/builders.d.ts.map +1 -0
  256. package/dist/protocol/strategy/builders.js +382 -0
  257. package/dist/protocol/strategy/builders.js.map +1 -0
  258. package/dist/protocol/strategy/index.d.ts +5 -0
  259. package/dist/protocol/strategy/index.d.ts.map +1 -0
  260. package/dist/protocol/strategy/index.js +4 -0
  261. package/dist/protocol/strategy/index.js.map +1 -0
  262. package/dist/protocol/strategy/kinds.d.ts +2 -0
  263. package/dist/protocol/strategy/kinds.d.ts.map +1 -0
  264. package/dist/protocol/strategy/kinds.js +2 -0
  265. package/dist/protocol/strategy/kinds.js.map +1 -0
  266. package/dist/protocol/strategy/patch.d.ts +59 -0
  267. package/dist/protocol/strategy/patch.d.ts.map +1 -0
  268. package/dist/protocol/strategy/patch.js +253 -0
  269. package/dist/protocol/strategy/patch.js.map +1 -0
  270. package/dist/protocol/symbols.d.ts +8 -0
  271. package/dist/protocol/symbols.d.ts.map +1 -0
  272. package/dist/protocol/symbols.js +11 -0
  273. package/dist/protocol/symbols.js.map +1 -0
  274. package/dist/transport/constants.d.ts +8 -0
  275. package/dist/transport/constants.d.ts.map +1 -0
  276. package/dist/transport/constants.js +8 -0
  277. package/dist/transport/constants.js.map +1 -0
  278. package/dist/transport/documents.d.ts +27 -0
  279. package/dist/transport/documents.d.ts.map +1 -0
  280. package/dist/transport/documents.js +34 -0
  281. package/dist/transport/documents.js.map +1 -0
  282. package/dist/transport/index.d.ts +8 -0
  283. package/dist/transport/index.d.ts.map +1 -0
  284. package/dist/transport/index.js +8 -0
  285. package/dist/transport/index.js.map +1 -0
  286. package/dist/transport/probe.d.ts +44 -0
  287. package/dist/transport/probe.d.ts.map +1 -0
  288. package/dist/transport/probe.js +121 -0
  289. package/dist/transport/probe.js.map +1 -0
  290. package/dist/transport/rendezvous.d.ts +116 -0
  291. package/dist/transport/rendezvous.d.ts.map +1 -0
  292. package/dist/transport/rendezvous.js +139 -0
  293. package/dist/transport/rendezvous.js.map +1 -0
  294. package/dist/transport/rest.d.ts +35 -0
  295. package/dist/transport/rest.d.ts.map +1 -0
  296. package/dist/transport/rest.js +58 -0
  297. package/dist/transport/rest.js.map +1 -0
  298. package/dist/transport/syncClient.d.ts +14 -0
  299. package/dist/transport/syncClient.d.ts.map +1 -0
  300. package/dist/transport/syncClient.js +30 -0
  301. package/dist/transport/syncClient.js.map +1 -0
  302. package/dist/transport/urls.d.ts +35 -0
  303. package/dist/transport/urls.d.ts.map +1 -0
  304. package/dist/transport/urls.js +126 -0
  305. package/dist/transport/urls.js.map +1 -0
  306. package/package.json +55 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paths.js","sourceRoot":"","sources":["../../src/collections/paths.ts"],"names":[],"mappings":"AAAA;;yEAEyE;AACzE,MAAM,UAAU,kBAAkB,CAAC,WAAmB,EAAE,MAA8B;IACpF,OAAO,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,CAClC,CAAC,IAAI,EAAE,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,GAAG,GAAG,EAAE,kBAAkB,CAAC,KAAK,CAAC,CAAC,EAC9E,WAAW,CACZ,CAAA;AACH,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,WAAmB,EAAE,MAA8B;IAC1E,OAAO,SAAS,kBAAkB,CAAC,WAAW,EAAE,MAAM,CAAC,EAAE,CAAA;AAC3D,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,WAAmB,EAAE,MAA8B;IAC1E,OAAO,SAAS,kBAAkB,CAAC,WAAW,EAAE,MAAM,CAAC,EAAE,CAAA;AAC3D,CAAC"}
@@ -0,0 +1,28 @@
1
+ import { type NodeCollectionKey } from '../collections/nodeCollections.js';
2
+ /**
3
+ * Derive one base64-encoded, per-collection AES-256 key for each of
4
+ * `collections`, from the wallet's derived encryption secret. Each key is
5
+ * `HKDF-SHA256(secret, STARFISH_ENCRYPTION_SALT, collection.encryptionInfo)`
6
+ * — the exact same derivation `createSecretEncryptor` performs internally,
7
+ * just stopped one step early (raw bytes instead of an imported `CryptoKey`)
8
+ * so the bytes can travel in a read-only pairing payload.
9
+ *
10
+ * One-way and collection-independent by construction: HKDF cannot be
11
+ * inverted to recover `secret`, and a key derived for one `info` string
12
+ * reveals nothing about a key derived for a different one — so a payload
13
+ * carrying `{userData, accounts}` keys grants exactly those two collections,
14
+ * never the wallet secret itself and never `settings`/`strategies`/
15
+ * `accountTrading`, even though every collection's key is a deterministic
16
+ * function of the same underlying secret.
17
+ *
18
+ * Returns a `Partial` record deliberately: a grant covers a subset of
19
+ * collections, never all of them, and TypeScript should not let a caller
20
+ * assume every key is present.
21
+ */
22
+ export declare function deriveCollectionKeys(secret: string, collections: readonly NodeCollectionKey[]): Partial<Record<NodeCollectionKey, string>>;
23
+ /** Decode one collection's base64 key back to raw bytes, for
24
+ * `createRawKeyEncryptor`. Throws on malformed base64 or a length other
25
+ * than 32 bytes (AES-256) — a corrupt or truncated grant should fail loudly
26
+ * at import time, not produce silent garbage ciphertext later. */
27
+ export declare function decodeCollectionKey(base64Key: string): Uint8Array<ArrayBuffer>;
28
+ //# sourceMappingURL=collectionKeys.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collectionKeys.d.ts","sourceRoot":"","sources":["../../src/crypto/collectionKeys.ts"],"names":[],"mappings":"AAGA,OAAO,EAAoB,KAAK,iBAAiB,EAAE,MAAM,mCAAmC,CAAA;AAU5F;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,SAAS,iBAAiB,EAAE,GACxC,OAAO,CAAC,MAAM,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAAC,CAS5C;AAED;;;mEAGmE;AACnE,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,GAAG,UAAU,CAAC,WAAW,CAAC,CAM9E"}
@@ -0,0 +1,53 @@
1
+ import { deriveAesKeyBytes } from './hkdf.js';
2
+ import { STARFISH_ENCRYPTION_SALT } from './wireConstants.js';
3
+ import { toBase64, fromBase64 } from '../internal/bytes.js';
4
+ import { NODE_COLLECTIONS } from '../collections/nodeCollections.js';
5
+ /** `"0x"`-strip, matching `secretEncryptor.ts`'s `normalizeSecret` — HKDF
6
+ * treats its secret as an opaque byte string, so the prefixed and
7
+ * unprefixed forms of the same key derive completely different bytes, and
8
+ * the node always HKDFs the stripped form. */
9
+ function normalizeSecret(secret) {
10
+ return secret.startsWith('0x') ? secret.slice(2) : secret;
11
+ }
12
+ /**
13
+ * Derive one base64-encoded, per-collection AES-256 key for each of
14
+ * `collections`, from the wallet's derived encryption secret. Each key is
15
+ * `HKDF-SHA256(secret, STARFISH_ENCRYPTION_SALT, collection.encryptionInfo)`
16
+ * — the exact same derivation `createSecretEncryptor` performs internally,
17
+ * just stopped one step early (raw bytes instead of an imported `CryptoKey`)
18
+ * so the bytes can travel in a read-only pairing payload.
19
+ *
20
+ * One-way and collection-independent by construction: HKDF cannot be
21
+ * inverted to recover `secret`, and a key derived for one `info` string
22
+ * reveals nothing about a key derived for a different one — so a payload
23
+ * carrying `{userData, accounts}` keys grants exactly those two collections,
24
+ * never the wallet secret itself and never `settings`/`strategies`/
25
+ * `accountTrading`, even though every collection's key is a deterministic
26
+ * function of the same underlying secret.
27
+ *
28
+ * Returns a `Partial` record deliberately: a grant covers a subset of
29
+ * collections, never all of them, and TypeScript should not let a caller
30
+ * assume every key is present.
31
+ */
32
+ export function deriveCollectionKeys(secret, collections) {
33
+ const normalized = normalizeSecret(secret);
34
+ const keys = {};
35
+ for (const collection of collections) {
36
+ const info = NODE_COLLECTIONS[collection].encryptionInfo;
37
+ const bytes = deriveAesKeyBytes(normalized, STARFISH_ENCRYPTION_SALT, info);
38
+ keys[collection] = toBase64(bytes);
39
+ }
40
+ return keys;
41
+ }
42
+ /** Decode one collection's base64 key back to raw bytes, for
43
+ * `createRawKeyEncryptor`. Throws on malformed base64 or a length other
44
+ * than 32 bytes (AES-256) — a corrupt or truncated grant should fail loudly
45
+ * at import time, not produce silent garbage ciphertext later. */
46
+ export function decodeCollectionKey(base64Key) {
47
+ const bytes = fromBase64(base64Key);
48
+ if (bytes.length !== 32) {
49
+ throw new Error(`invalid collection key: expected 32 bytes, got ${bytes.length}`);
50
+ }
51
+ return bytes;
52
+ }
53
+ //# sourceMappingURL=collectionKeys.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collectionKeys.js","sourceRoot":"","sources":["../../src/crypto/collectionKeys.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAC7C,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAA;AAC7D,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAC3D,OAAO,EAAE,gBAAgB,EAA0B,MAAM,mCAAmC,CAAA;AAE5F;;;+CAG+C;AAC/C,SAAS,eAAe,CAAC,MAAc;IACrC,OAAO,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAA;AAC3D,CAAC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,oBAAoB,CAClC,MAAc,EACd,WAAyC;IAEzC,MAAM,UAAU,GAAG,eAAe,CAAC,MAAM,CAAC,CAAA;IAC1C,MAAM,IAAI,GAA+C,EAAE,CAAA;IAC3D,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE,CAAC;QACrC,MAAM,IAAI,GAAG,gBAAgB,CAAC,UAAU,CAAC,CAAC,cAAc,CAAA;QACxD,MAAM,KAAK,GAAG,iBAAiB,CAAC,UAAU,EAAE,wBAAwB,EAAE,IAAI,CAAC,CAAA;QAC3E,IAAI,CAAC,UAAU,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAA;IACpC,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC;AAED;;;mEAGmE;AACnE,MAAM,UAAU,mBAAmB,CAAC,SAAiB;IACnD,MAAM,KAAK,GAAG,UAAU,CAAC,SAAS,CAAC,CAAA;IACnC,IAAI,KAAK,CAAC,MAAM,KAAK,EAAE,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CAAC,kDAAkD,KAAK,CAAC,MAAM,EAAE,CAAC,CAAA;IACnF,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Derive a raw 32-byte AES-256 key via HKDF-SHA256 over UTF-8(secret) with
3
+ * UTF-8(salt) / UTF-8(info) — the same algorithm `@drakkar.software/
4
+ * starfish-protocol`'s `deriveAesKeyBytes` uses (verified byte-for-byte
5
+ * identical against its WebCrypto implementation for a fixed vector).
6
+ *
7
+ * Reimplemented locally because `deriveAesKeyBytes` is not reachable from
8
+ * that package's public entry point: only `deriveKey`, `IV_BYTES`,
9
+ * `ENCRYPTED_KEY` are re-exported from `./crypto.js`, and there is no
10
+ * `./crypto` subpath in its `exports` map. `@noble/hashes` is already a
11
+ * direct dependency of this package.
12
+ */
13
+ export declare function deriveAesKeyBytes(secret: string, salt: string, info: string): Uint8Array;
14
+ //# sourceMappingURL=hkdf.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hkdf.d.ts","sourceRoot":"","sources":["../../src/crypto/hkdf.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,UAAU,CAExF"}
@@ -0,0 +1,19 @@
1
+ import { sha256 } from '@noble/hashes/sha2.js';
2
+ import { hkdf } from '@noble/hashes/hkdf.js';
3
+ import { utf8ToBytes } from '@noble/hashes/utils.js';
4
+ /**
5
+ * Derive a raw 32-byte AES-256 key via HKDF-SHA256 over UTF-8(secret) with
6
+ * UTF-8(salt) / UTF-8(info) — the same algorithm `@drakkar.software/
7
+ * starfish-protocol`'s `deriveAesKeyBytes` uses (verified byte-for-byte
8
+ * identical against its WebCrypto implementation for a fixed vector).
9
+ *
10
+ * Reimplemented locally because `deriveAesKeyBytes` is not reachable from
11
+ * that package's public entry point: only `deriveKey`, `IV_BYTES`,
12
+ * `ENCRYPTED_KEY` are re-exported from `./crypto.js`, and there is no
13
+ * `./crypto` subpath in its `exports` map. `@noble/hashes` is already a
14
+ * direct dependency of this package.
15
+ */
16
+ export function deriveAesKeyBytes(secret, salt, info) {
17
+ return hkdf(sha256, utf8ToBytes(secret), utf8ToBytes(salt), utf8ToBytes(info), 32);
18
+ }
19
+ //# sourceMappingURL=hkdf.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hkdf.js","sourceRoot":"","sources":["../../src/crypto/hkdf.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAA;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAEpD;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAAc,EAAE,IAAY,EAAE,IAAY;IAC1E,OAAO,IAAI,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC,IAAI,CAAC,EAAE,WAAW,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAA;AACpF,CAAC"}
@@ -0,0 +1,5 @@
1
+ export { createSecretEncryptor, createRawKeyEncryptor } from './secretEncryptor.js';
2
+ export { deriveCollectionKeys, decodeCollectionKey } from './collectionKeys.js';
3
+ export { deriveAesKeyBytes } from './hkdf.js';
4
+ export { SYNC_MOUNT_PATH, SYNC_NAMESPACE, SYNC_FETCH_TIMEOUT_MS, DEFAULT_PROBE_TIMEOUT_MS, STARFISH_ENCRYPTION_SALT, } from './wireConstants.js';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/crypto/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAA;AACnF,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAC/E,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAC7C,OAAO,EACL,eAAe,EACf,cAAc,EACd,qBAAqB,EACrB,wBAAwB,EACxB,wBAAwB,GACzB,MAAM,oBAAoB,CAAA"}
@@ -0,0 +1,5 @@
1
+ export { createSecretEncryptor, createRawKeyEncryptor } from './secretEncryptor.js';
2
+ export { deriveCollectionKeys, decodeCollectionKey } from './collectionKeys.js';
3
+ export { deriveAesKeyBytes } from './hkdf.js';
4
+ export { SYNC_MOUNT_PATH, SYNC_NAMESPACE, SYNC_FETCH_TIMEOUT_MS, DEFAULT_PROBE_TIMEOUT_MS, STARFISH_ENCRYPTION_SALT, } from './wireConstants.js';
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/crypto/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAA;AACnF,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAC/E,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAC7C,OAAO,EACL,eAAe,EACf,cAAc,EACd,qBAAqB,EACrB,wBAAwB,EACxB,wBAAwB,GACzB,MAAM,oBAAoB,CAAA"}
@@ -0,0 +1,20 @@
1
+ import type { Encryptor } from '@drakkar.software/starfish-protocol';
2
+ /**
3
+ * Build a symmetric Encryptor keyed by HKDF-SHA256(secret, salt, info) → AES-256-GCM.
4
+ *
5
+ * Mirrors octobot_sync/crypto.py SecretEncryptor. The {iv, data} envelope is
6
+ * compatible with Python's encrypt_bytes_to_blob_dict / decrypt_blob_dict_to_bytes.
7
+ *
8
+ * The key is derived once and cached in the returned Encryptor instance.
9
+ */
10
+ export declare function createSecretEncryptor(secret: string, salt: string, info: string): Encryptor;
11
+ /**
12
+ * Build an Encryptor from an already-derived raw AES-256 key (32 bytes),
13
+ * imported as a non-extractable AES-GCM `CryptoKey` — no HKDF step. Used for
14
+ * the read-only pairing path, where the payload carries a precomputed
15
+ * per-collection subkey (see `crypto/collectionKeys.ts`) instead of the
16
+ * wallet secret, so the recipient can decrypt exactly the granted
17
+ * collections and nothing else, and can never re-derive any other key.
18
+ */
19
+ export declare function createRawKeyEncryptor(keyBytes: Uint8Array<ArrayBuffer>): Encryptor;
20
+ //# sourceMappingURL=secretEncryptor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"secretEncryptor.d.ts","sourceRoot":"","sources":["../../src/crypto/secretEncryptor.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qCAAqC,CAAA;AAmEpE;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,GACX,SAAS,CAEX;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,UAAU,CAAC,WAAW,CAAC,GAAG,SAAS,CASlF"}
@@ -0,0 +1,82 @@
1
+ import { deriveKey } from '@drakkar.software/starfish-protocol';
2
+ import { toBase64, fromBase64 } from '../internal/bytes.js';
3
+ // Envelope keys — must match octobot_sync/constants.py BLOB_IV_KEY / BLOB_DATA_KEY.
4
+ const BLOB_IV_KEY = 'iv';
5
+ const BLOB_DATA_KEY = 'data';
6
+ // 96-bit IV for AES-256-GCM — matches Python's IV_BYTES = 12.
7
+ const IV_BYTES = 12;
8
+ /** The node stores wallet private keys with the `0x` prefix stripped
9
+ * (`community_wallet.py`: `private_key=private_key.removeprefix("0x")`) and
10
+ * HKDFs that stripped string directly (`octobot_sync/crypto.py`). HKDF
11
+ * treats its secret as an opaque byte string, not parsed hex, so `"0x1234"`
12
+ * and `"1234"` derive completely different keys despite representing the
13
+ * same private key numerically. Every caller here must agree with the node
14
+ * on the stripped form, so normalize once, centrally, rather than trusting
15
+ * each call site to strip before calling in. */
16
+ function normalizeSecret(secret) {
17
+ return secret.startsWith('0x') ? secret.slice(2) : secret;
18
+ }
19
+ /** Build an `Encryptor` from an already-resolved (or resolving) AES-256-GCM
20
+ * `CryptoKey`. Shared by `createSecretEncryptor` (derives the key from a
21
+ * wallet secret) and `createRawKeyEncryptor` (imports an already-derived
22
+ * key directly — the read-only pairing path, where the payload carries a
23
+ * precomputed per-collection subkey rather than the wallet secret itself). */
24
+ function buildAesGcmEncryptor(keyPromise) {
25
+ return {
26
+ async encrypt(data) {
27
+ const key = await keyPromise;
28
+ const ivBuf = new ArrayBuffer(IV_BYTES);
29
+ globalThis.crypto.getRandomValues(new Uint8Array(ivBuf));
30
+ const iv = new Uint8Array(ivBuf);
31
+ const plaintext = new TextEncoder().encode(JSON.stringify(data));
32
+ const ciphertext = new Uint8Array(await globalThis.crypto.subtle.encrypt({ name: 'AES-GCM', iv }, key, plaintext));
33
+ return {
34
+ [BLOB_IV_KEY]: toBase64(iv),
35
+ [BLOB_DATA_KEY]: toBase64(ciphertext),
36
+ };
37
+ },
38
+ async decrypt(wrapper) {
39
+ // Server wraps the {iv,data} blob as a JSON string inside StoredDocument.data.
40
+ // Parse it when needed so both current (string) and future (object) server formats work.
41
+ const blob = typeof wrapper === 'string'
42
+ ? JSON.parse(wrapper)
43
+ : wrapper;
44
+ // A collection that has never been pushed for this identity pulls back
45
+ // as the STRING "null" (the same opaque-string convention every real
46
+ // blob uses, just carrying the JSON literal `null` instead of a real
47
+ // {iv,data} envelope) — parsing it above yields the JS value `null`,
48
+ // not an object. Nothing to decrypt yet.
49
+ if (blob == null)
50
+ return {};
51
+ const key = await keyPromise;
52
+ const iv = fromBase64(blob[BLOB_IV_KEY]);
53
+ const ciphertext = fromBase64(blob[BLOB_DATA_KEY]);
54
+ const plaintext = new Uint8Array(await globalThis.crypto.subtle.decrypt({ name: 'AES-GCM', iv }, key, ciphertext));
55
+ return JSON.parse(new TextDecoder().decode(plaintext));
56
+ },
57
+ };
58
+ }
59
+ /**
60
+ * Build a symmetric Encryptor keyed by HKDF-SHA256(secret, salt, info) → AES-256-GCM.
61
+ *
62
+ * Mirrors octobot_sync/crypto.py SecretEncryptor. The {iv, data} envelope is
63
+ * compatible with Python's encrypt_bytes_to_blob_dict / decrypt_blob_dict_to_bytes.
64
+ *
65
+ * The key is derived once and cached in the returned Encryptor instance.
66
+ */
67
+ export function createSecretEncryptor(secret, salt, info) {
68
+ return buildAesGcmEncryptor(deriveKey(normalizeSecret(secret), salt, info));
69
+ }
70
+ /**
71
+ * Build an Encryptor from an already-derived raw AES-256 key (32 bytes),
72
+ * imported as a non-extractable AES-GCM `CryptoKey` — no HKDF step. Used for
73
+ * the read-only pairing path, where the payload carries a precomputed
74
+ * per-collection subkey (see `crypto/collectionKeys.ts`) instead of the
75
+ * wallet secret, so the recipient can decrypt exactly the granted
76
+ * collections and nothing else, and can never re-derive any other key.
77
+ */
78
+ export function createRawKeyEncryptor(keyBytes) {
79
+ const keyPromise = globalThis.crypto.subtle.importKey('raw', keyBytes, { name: 'AES-GCM' }, false, ['encrypt', 'decrypt']);
80
+ return buildAesGcmEncryptor(keyPromise);
81
+ }
82
+ //# sourceMappingURL=secretEncryptor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"secretEncryptor.js","sourceRoot":"","sources":["../../src/crypto/secretEncryptor.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,14 @@
1
+ /** The server mounts the sync sub-app at this path. The Starfish client
2
+ * receives this as the baseUrl suffix and handles /v1/{namespace}/... internally. */
3
+ export declare const SYNC_MOUNT_PATH = "sync";
4
+ export declare const SYNC_NAMESPACE = "octobot";
5
+ /** Per-request timeout on sync clients. Bounds a merging pull's write-gating
6
+ * window when the target node is offline (raw fetch would hang for the OS
7
+ * TCP timeout, 60s+). Documents are small JSON — 10s is ample for push too. */
8
+ export declare const SYNC_FETCH_TIMEOUT_MS = 10000;
9
+ export declare const DEFAULT_PROBE_TIMEOUT_MS = 4000;
10
+ /** HKDF salt for identity-encryption key derivation.
11
+ * @see packages/sync/octobot_sync/constants.py — HKDF_SALT_STRING
12
+ * @remarks Changing this breaks decryption of every existing document. */
13
+ export declare const STARFISH_ENCRYPTION_SALT = "octobot-starfish-identity-v1";
14
+ //# sourceMappingURL=wireConstants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wireConstants.d.ts","sourceRoot":"","sources":["../../src/crypto/wireConstants.ts"],"names":[],"mappings":"AAIA;sFACsF;AACtF,eAAO,MAAM,eAAe,SAAS,CAAA;AACrC,eAAO,MAAM,cAAc,YAAY,CAAA;AAEvC;;gFAEgF;AAChF,eAAO,MAAM,qBAAqB,QAAS,CAAA;AAC3C,eAAO,MAAM,wBAAwB,OAAO,CAAA;AAE5C;;2EAE2E;AAC3E,eAAO,MAAM,wBAAwB,iCAAiC,CAAA"}
@@ -0,0 +1,17 @@
1
+ // Literal strings and numbers shared with the node's Python implementation.
2
+ // A change on either side breaks sync SILENTLY — see tests/wireContract.test.ts
3
+ // and https://docs.octobot.cloud/client-sdk/wire-contract for the full inventory.
4
+ /** The server mounts the sync sub-app at this path. The Starfish client
5
+ * receives this as the baseUrl suffix and handles /v1/{namespace}/... internally. */
6
+ export const SYNC_MOUNT_PATH = 'sync';
7
+ export const SYNC_NAMESPACE = 'octobot';
8
+ /** Per-request timeout on sync clients. Bounds a merging pull's write-gating
9
+ * window when the target node is offline (raw fetch would hang for the OS
10
+ * TCP timeout, 60s+). Documents are small JSON — 10s is ample for push too. */
11
+ export const SYNC_FETCH_TIMEOUT_MS = 10_000;
12
+ export const DEFAULT_PROBE_TIMEOUT_MS = 4000;
13
+ /** HKDF salt for identity-encryption key derivation.
14
+ * @see packages/sync/octobot_sync/constants.py — HKDF_SALT_STRING
15
+ * @remarks Changing this breaks decryption of every existing document. */
16
+ export const STARFISH_ENCRYPTION_SALT = 'octobot-starfish-identity-v1';
17
+ //# sourceMappingURL=wireConstants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wireConstants.js","sourceRoot":"","sources":["../../src/crypto/wireConstants.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,gFAAgF;AAChF,kFAAkF;AAElF;sFACsF;AACtF,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAA;AACrC,MAAM,CAAC,MAAM,cAAc,GAAG,SAAS,CAAA;AAEvC;;gFAEgF;AAChF,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAA;AAC3C,MAAM,CAAC,MAAM,wBAAwB,GAAG,IAAI,CAAA;AAE5C;;2EAE2E;AAC3E,MAAM,CAAC,MAAM,wBAAwB,GAAG,8BAA8B,CAAA"}
@@ -0,0 +1,3 @@
1
+ /** EIP-55 checksummed EVM address derived from a secp256k1 private key. */
2
+ export declare function deriveEvmAddress(privateKey: Uint8Array): string;
3
+ //# sourceMappingURL=address.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"address.d.ts","sourceRoot":"","sources":["../../src/identity/address.ts"],"names":[],"mappings":"AAaA,2EAA2E;AAC3E,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,UAAU,GAAG,MAAM,CAI/D"}
@@ -0,0 +1,17 @@
1
+ import { secp256k1 } from '@noble/curves/secp256k1.js';
2
+ import { keccak_256 } from '@noble/hashes/sha3.js';
3
+ import { toHex } from '../internal/bytes.js';
4
+ // EIP-55 checksum-casing and EVM address derivation. Previously duplicated
5
+ // verbatim across auth/cap-provider.ts and auth/auth-core.ts in
6
+ // @drakkar.software/octobot-sdk — consolidated here.
7
+ function eip55Address(lower) {
8
+ const hash = toHex(keccak_256(new TextEncoder().encode(lower)));
9
+ return '0x' + Array.from(lower, (c, i) => (parseInt(hash[i], 16) >= 8 ? c.toUpperCase() : c)).join('');
10
+ }
11
+ /** EIP-55 checksummed EVM address derived from a secp256k1 private key. */
12
+ export function deriveEvmAddress(privateKey) {
13
+ const pubkey = secp256k1.getPublicKey(privateKey, false); // 65-byte uncompressed
14
+ const hash = keccak_256(pubkey.slice(1)); // keccak256 of 64-byte (x, y)
15
+ return eip55Address(toHex(hash.slice(12))); // last 20 bytes → checksummed address
16
+ }
17
+ //# sourceMappingURL=address.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"address.js","sourceRoot":"","sources":["../../src/identity/address.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAA;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAClD,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAA;AAE5C,2EAA2E;AAC3E,gEAAgE;AAChE,qDAAqD;AAErD,SAAS,YAAY,CAAC,KAAa;IACjC,MAAM,IAAI,GAAG,KAAK,CAAC,UAAU,CAAC,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;IAC/D,OAAO,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;AACxG,CAAC;AAED,2EAA2E;AAC3E,MAAM,UAAU,gBAAgB,CAAC,UAAsB;IACrD,MAAM,MAAM,GAAG,SAAS,CAAC,YAAY,CAAC,UAAU,EAAE,KAAK,CAAC,CAAA,CAAC,uBAAuB;IAChF,MAAM,IAAI,GAAG,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA,CAAiB,8BAA8B;IACvF,OAAO,YAAY,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA,CAAe,sCAAsC;AACjG,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const BIP39_WORDLIST: readonly string[];
2
+ //# sourceMappingURL=bip39-wordlist.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bip39-wordlist.d.ts","sourceRoot":"","sources":["../../src/identity/bip39-wordlist.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,EAAE,SAAS,MAAM,EAigElC,CAAA"}