@needmoretruth/nmts-cli 0.17.2 → 0.34.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 (419) hide show
  1. package/AGENTS.md +124 -516
  2. package/CHANGELOG.md +98 -0
  3. package/README.ko.md +374 -467
  4. package/README.md +384 -465
  5. package/dist/account-proof.d.ts +29 -0
  6. package/dist/account-proof.js +6 -6
  7. package/dist/account.d.ts +18 -0
  8. package/dist/account.js +5 -5
  9. package/dist/agent-host.d.ts +71 -0
  10. package/dist/agent-host.js +169 -0
  11. package/dist/api-advice.d.ts +2 -0
  12. package/dist/api-advice.js +210 -0
  13. package/dist/api-key.d.ts +79 -0
  14. package/dist/api-key.js +7 -7
  15. package/dist/api-refusal.d.ts +14 -0
  16. package/dist/api-refusal.js +8 -0
  17. package/dist/api.d.ts +114 -0
  18. package/dist/api.js +59 -162
  19. package/dist/args.d.ts +160 -0
  20. package/dist/args.js +118 -30
  21. package/dist/artifact-about.d.ts +49 -0
  22. package/dist/autonomy.d.ts +39 -0
  23. package/dist/autonomy.js +110 -32
  24. package/dist/code-access.d.ts +29 -0
  25. package/dist/code-access.js +3 -3
  26. package/dist/code-vault.d.ts +38 -0
  27. package/dist/code-vault.js +8 -8
  28. package/dist/collision.d.ts +67 -0
  29. package/dist/collision.js +1 -1
  30. package/dist/commands/accept-terms.d.ts +11 -0
  31. package/dist/commands/accept-terms.js +106 -0
  32. package/dist/commands/balance.d.ts +7 -0
  33. package/dist/commands/balance.js +54 -1
  34. package/dist/commands/create-code-file.d.ts +24 -0
  35. package/dist/commands/create-code-file.js +93 -0
  36. package/dist/commands/create-link.d.ts +10 -0
  37. package/dist/commands/create-link.js +232 -0
  38. package/dist/commands/create.d.ts +20 -0
  39. package/dist/commands/create.js +43 -102
  40. package/dist/commands/credits.d.ts +9 -0
  41. package/dist/commands/credits.js +110 -0
  42. package/dist/commands/delete-account.d.ts +11 -0
  43. package/dist/commands/delete-account.js +63 -0
  44. package/dist/commands/deposit.d.ts +7 -0
  45. package/dist/commands/deposit.js +85 -0
  46. package/dist/commands/devices.d.ts +12 -0
  47. package/dist/commands/devices.js +144 -0
  48. package/dist/commands/documents.d.ts +35 -0
  49. package/dist/commands/documents.js +212 -0
  50. package/dist/commands/env.d.ts +5 -0
  51. package/dist/commands/env.js +10 -2
  52. package/dist/commands/erase.d.ts +13 -0
  53. package/dist/commands/erase.js +193 -0
  54. package/dist/commands/expiring.d.ts +19 -0
  55. package/dist/commands/extend.d.ts +33 -0
  56. package/dist/commands/extend.js +54 -15
  57. package/dist/commands/get.d.ts +18 -0
  58. package/dist/commands/key-manage.d.ts +11 -0
  59. package/dist/commands/key-manage.js +162 -0
  60. package/dist/commands/key.d.ts +28 -0
  61. package/dist/commands/key.js +249 -0
  62. package/dist/commands/kit.d.ts +11 -0
  63. package/dist/commands/kit.js +7 -7
  64. package/dist/commands/listfile.d.ts +13 -0
  65. package/dist/commands/listfile.js +12 -5
  66. package/dist/commands/login.d.ts +18 -0
  67. package/dist/commands/login.js +19 -19
  68. package/dist/commands/logout.d.ts +1 -0
  69. package/dist/commands/logout.js +1 -1
  70. package/dist/commands/losses.d.ts +12 -0
  71. package/dist/commands/losses.js +180 -0
  72. package/dist/commands/ls.d.ts +23 -0
  73. package/dist/commands/marks-dispatch.d.ts +2 -0
  74. package/dist/commands/marks-dispatch.js +51 -0
  75. package/dist/commands/marks.d.ts +46 -0
  76. package/dist/commands/marks.js +80 -0
  77. package/dist/commands/mcp.d.ts +24 -0
  78. package/dist/commands/mcp.js +70 -5
  79. package/dist/commands/mode.d.ts +8 -0
  80. package/dist/commands/mode.js +60 -24
  81. package/dist/commands/on-collision.d.ts +6 -0
  82. package/dist/commands/organise.d.ts +46 -0
  83. package/dist/commands/padding.d.ts +7 -0
  84. package/dist/commands/padding.js +114 -0
  85. package/dist/commands/public-code.d.ts +9 -0
  86. package/dist/commands/public-code.js +8 -8
  87. package/dist/commands/pull.d.ts +27 -0
  88. package/dist/commands/push-wallet.d.ts +19 -0
  89. package/dist/commands/push-wallet.js +69 -0
  90. package/dist/commands/push.d.ts +47 -0
  91. package/dist/commands/push.js +37 -7
  92. package/dist/commands/put-wallet.d.ts +77 -0
  93. package/dist/commands/put-wallet.js +316 -0
  94. package/dist/commands/put.d.ts +56 -0
  95. package/dist/commands/put.js +53 -6
  96. package/dist/commands/rebuild.d.ts +18 -0
  97. package/dist/commands/rebuild.js +108 -10
  98. package/dist/commands/receive.d.ts +24 -0
  99. package/dist/commands/recovery-dispatch.d.ts +2 -0
  100. package/dist/commands/recovery-dispatch.js +34 -0
  101. package/dist/commands/recovery-list.d.ts +11 -0
  102. package/dist/commands/recovery-list.js +6 -6
  103. package/dist/commands/recovery.d.ts +25 -0
  104. package/dist/commands/recovery.js +2 -2
  105. package/dist/commands/rollback.d.ts +9 -0
  106. package/dist/commands/rollback.js +118 -0
  107. package/dist/commands/s3.d.ts +23 -0
  108. package/dist/commands/s3.js +6 -6
  109. package/dist/commands/settings.d.ts +5 -0
  110. package/dist/commands/settings.js +21 -6
  111. package/dist/commands/share-dispatch.d.ts +2 -0
  112. package/dist/commands/share-dispatch.js +46 -0
  113. package/dist/commands/share.d.ts +14 -0
  114. package/dist/commands/share.js +13 -3
  115. package/dist/commands/shares-sent.d.ts +18 -0
  116. package/dist/commands/shares-sent.js +95 -0
  117. package/dist/commands/support.d.ts +24 -0
  118. package/dist/commands/support.js +321 -0
  119. package/dist/commands/sweep.d.ts +11 -0
  120. package/dist/commands/tip.d.ts +11 -0
  121. package/dist/commands/tip.js +86 -0
  122. package/dist/commands/trash.d.ts +17 -0
  123. package/dist/commands/trash.js +1 -1
  124. package/dist/commands/trial.d.ts +7 -0
  125. package/dist/commands/trial.js +16 -18
  126. package/dist/commands/unlock.d.ts +16 -0
  127. package/dist/commands/unlock.js +159 -0
  128. package/dist/commands/update.d.ts +42 -0
  129. package/dist/commands/update.js +1 -1
  130. package/dist/commands/usage.d.ts +8 -0
  131. package/dist/commands/verify.d.ts +18 -0
  132. package/dist/commands/verify.js +10 -6
  133. package/dist/commands/wallet-activity.d.ts +26 -0
  134. package/dist/commands/wallet-activity.js +117 -0
  135. package/dist/commands/wallet-donate.d.ts +26 -0
  136. package/dist/commands/wallet-donate.js +163 -0
  137. package/dist/commands/wallet-hall.d.ts +35 -0
  138. package/dist/commands/wallet-hall.js +214 -0
  139. package/dist/commands/wallet-send.d.ts +22 -0
  140. package/dist/commands/wallet-send.js +153 -0
  141. package/dist/commands/wallet-storage-ops.d.ts +24 -0
  142. package/dist/commands/wallet-storage-ops.js +215 -0
  143. package/dist/commands/wallet-storage.d.ts +18 -0
  144. package/dist/commands/wallet-storage.js +95 -0
  145. package/dist/commands/wallet-swap.d.ts +32 -0
  146. package/dist/commands/wallet-swap.js +287 -0
  147. package/dist/commands/wallet.d.ts +36 -0
  148. package/dist/commands/wallet.js +57 -15
  149. package/dist/commands/whoami.d.ts +10 -0
  150. package/dist/commands/whoami.js +24 -6
  151. package/dist/consent.d.ts +140 -0
  152. package/dist/consent.js +89 -30
  153. package/dist/credentials.d.ts +146 -0
  154. package/dist/credentials.js +10 -10
  155. package/dist/crypto-surface.d.ts +197 -0
  156. package/dist/crypto.d.ts +81 -0
  157. package/dist/crypto.js +13 -0
  158. package/dist/deposit.d.ts +25 -0
  159. package/dist/deposit.js +78 -0
  160. package/dist/download-part.d.ts +40 -0
  161. package/dist/download-sink.d.ts +76 -0
  162. package/dist/download.d.ts +79 -0
  163. package/dist/download.js +3 -3
  164. package/dist/drive-paths.d.ts +73 -0
  165. package/dist/environment.d.ts +62 -0
  166. package/dist/environment.js +29 -9
  167. package/dist/errors.d.ts +22 -0
  168. package/dist/errors.js +3 -3
  169. package/dist/exit.d.ts +44 -0
  170. package/dist/expiry.d.ts +58 -0
  171. package/dist/extend-budget.d.ts +35 -0
  172. package/dist/extend-budget.js +81 -0
  173. package/dist/extend-chain.d.ts +43 -0
  174. package/dist/extend-chain.js +40 -3
  175. package/dist/extend-plan.d.ts +148 -0
  176. package/dist/extend-plan.js +1 -1
  177. package/dist/gate.d.ts +18 -0
  178. package/dist/gate.js +100 -0
  179. package/dist/guards.d.ts +2 -0
  180. package/dist/help.d.ts +20 -0
  181. package/dist/help.js +199 -33
  182. package/dist/human-check.d.ts +23 -0
  183. package/dist/index.d.ts +42 -0
  184. package/dist/index.js +49 -0
  185. package/dist/item-trash.d.ts +1 -0
  186. package/dist/kit-file.d.ts +56 -0
  187. package/dist/kit-file.js +10 -10
  188. package/dist/list-file.d.ts +88 -0
  189. package/dist/list-file.js +90 -7
  190. package/dist/list-view-find.d.ts +15 -0
  191. package/dist/list-view-order.d.ts +32 -0
  192. package/dist/main.d.ts +12 -0
  193. package/dist/main.js +112 -113
  194. package/dist/manifest-chunk-cache.d.ts +14 -0
  195. package/dist/manifest-chunk-cache.js +103 -0
  196. package/dist/manifest-chunk-flow.d.ts +81 -0
  197. package/dist/manifest-chunk-flow.js +307 -0
  198. package/dist/manifest-create.d.ts +23 -0
  199. package/dist/manifest-create.js +26 -30
  200. package/dist/manifest-write.d.ts +161 -0
  201. package/dist/manifest-write.js +42 -33
  202. package/dist/manifest.d.ts +82 -0
  203. package/dist/manifest.js +69 -21
  204. package/dist/mark-render.d.ts +26 -0
  205. package/dist/mcp-args.d.ts +17 -0
  206. package/dist/mcp-ask.d.ts +43 -0
  207. package/dist/mcp-ask.js +100 -0
  208. package/dist/mcp-tools/context.d.ts +46 -0
  209. package/dist/mcp-tools/credits.d.ts +3 -0
  210. package/dist/mcp-tools/credits.js +61 -0
  211. package/dist/mcp-tools/files.d.ts +3 -0
  212. package/dist/mcp-tools/files.js +34 -0
  213. package/dist/mcp-tools/organise.d.ts +3 -0
  214. package/dist/mcp-tools/organise.js +82 -2
  215. package/dist/mcp-tools/reads.d.ts +3 -0
  216. package/dist/mcp-tools/reads.js +132 -4
  217. package/dist/mcp-tools/share.d.ts +3 -0
  218. package/dist/mcp-tools/share.js +26 -7
  219. package/dist/mcp-tools/support.d.ts +3 -0
  220. package/dist/mcp-tools/support.js +140 -0
  221. package/dist/mcp-tools/tiers.d.ts +31 -0
  222. package/dist/mcp-tools/tiers.js +147 -0
  223. package/dist/mcp.d.ts +80 -0
  224. package/dist/mcp.js +110 -9
  225. package/dist/net-retry.d.ts +38 -0
  226. package/dist/network.d.ts +10 -0
  227. package/dist/notice.d.ts +7 -0
  228. package/dist/notice.js +7 -7
  229. package/dist/product.d.ts +29 -0
  230. package/dist/product.js +1 -1
  231. package/dist/progress.d.ts +37 -0
  232. package/dist/prompt.d.ts +31 -0
  233. package/dist/prompt.js +1 -1
  234. package/dist/rebuild-key-check.d.ts +26 -0
  235. package/dist/rebuild-key-check.js +90 -0
  236. package/dist/rebuild.d.ts +87 -0
  237. package/dist/rebuild.js +26 -4
  238. package/dist/recovery-assemble.d.ts +40 -0
  239. package/dist/recovery-assemble.js +1 -1
  240. package/dist/recovery-build.d.ts +40 -0
  241. package/dist/recovery-map-file.d.ts +53 -0
  242. package/dist/recovery-map-file.js +4 -4
  243. package/dist/recovery-map.d.ts +197 -0
  244. package/dist/recovery-release.d.ts +104 -0
  245. package/dist/recovery-seq.d.ts +10 -0
  246. package/dist/recovery-source.d.ts +50 -0
  247. package/dist/redact.d.ts +70 -0
  248. package/dist/redact.js +212 -0
  249. package/dist/registration.d.ts +30 -0
  250. package/dist/registration.js +5 -5
  251. package/dist/risk.d.ts +380 -0
  252. package/dist/risk.js +206 -0
  253. package/dist/run-log.d.ts +78 -0
  254. package/dist/run-log.js +301 -0
  255. package/dist/s3/listing.d.ts +47 -0
  256. package/dist/s3/multipart.d.ts +21 -0
  257. package/dist/s3/response-sink.d.ts +8 -0
  258. package/dist/s3/same-file.d.ts +54 -0
  259. package/dist/s3/server.d.ts +58 -0
  260. package/dist/s3/server.js +2 -2
  261. package/dist/s3/sigv4.d.ts +46 -0
  262. package/dist/s3/sigv4.js +1 -1
  263. package/dist/s3/staging.d.ts +10 -0
  264. package/dist/s3/xml.d.ts +28 -0
  265. package/dist/safe-path.d.ts +41 -0
  266. package/dist/seal.d.ts +120 -0
  267. package/dist/secret-reader.d.ts +28 -0
  268. package/dist/server.d.ts +9 -0
  269. package/dist/session.d.ts +32 -0
  270. package/dist/session.js +1 -1
  271. package/dist/setup-questions.d.ts +7 -0
  272. package/dist/share.d.ts +108 -0
  273. package/dist/share.js +1 -1
  274. package/dist/shared/lib/crypto/size-padding.d.ts +55 -0
  275. package/dist/shared/lib/crypto/size-padding.js +5 -0
  276. package/dist/shared/lib/drive/manifest-chunks.d.ts +95 -0
  277. package/dist/shared/lib/drive/manifest-chunks.js +252 -0
  278. package/dist/shared/lib/drive/manifest-codec.d.ts +214 -0
  279. package/dist/shared/lib/drive/manifest-codec.js +7 -7
  280. package/dist/shared/lib/drive/manifest-index.d.ts +98 -0
  281. package/dist/shared/lib/drive/manifest-ops.d.ts +167 -0
  282. package/dist/shared/lib/drive/manifest-ops.js +9 -4
  283. package/dist/shared/lib/drive/manifest-pack.d.ts +65 -0
  284. package/dist/shared/lib/drive/manifest-pack.js +287 -0
  285. package/dist/shared/lib/drive/manifest-settings.d.ts +113 -0
  286. package/dist/shared/lib/drive/manifest-settings.js +87 -6
  287. package/dist/shared/lib/drive/name-conflict.d.ts +76 -0
  288. package/dist/shared/lib/drive/rebuild-verify.d.ts +73 -0
  289. package/dist/shared/lib/drive/rebuild-verify.js +112 -0
  290. package/dist/shared/lib/drive/unique-name.d.ts +9 -0
  291. package/dist/shared/lib/drive/zstd.d.ts +27 -0
  292. package/dist/shared/lib/drive/zstd.js +74 -0
  293. package/dist/shared/lib/extend/epochs.d.ts +205 -0
  294. package/dist/shared/lib/net/retry-budget.d.ts +79 -0
  295. package/dist/shared/lib/share/shared-file-info.d.ts +21 -0
  296. package/dist/shared/lib/storage-control/chain.d.ts +57 -0
  297. package/dist/shared/lib/storage-control/chain.js +82 -0
  298. package/dist/shared/lib/storage-control/plan.d.ts +40 -0
  299. package/dist/shared/lib/storage-control/plan.js +72 -0
  300. package/dist/shared/lib/storage-control/reuse.d.ts +72 -0
  301. package/dist/shared/lib/storage-control/reuse.js +95 -0
  302. package/dist/shared/lib/storage-network.d.ts +25 -0
  303. package/dist/shared/lib/upload/part-plan.d.ts +24 -0
  304. package/dist/shared/lib/wallet/activity.d.ts +138 -0
  305. package/dist/shared/lib/wallet/activity.js +208 -0
  306. package/dist/shared/lib/wallet/send-rules.d.ts +68 -0
  307. package/dist/shared/lib/wallet/send-rules.js +116 -0
  308. package/dist/shared/lib/wallet/swap-rules.d.ts +115 -0
  309. package/dist/shared/lib/wallet/swap-rules.js +199 -0
  310. package/dist/shared/lib/wallet/tip.d.ts +14 -0
  311. package/dist/shared/lib/wallet/tip.js +34 -0
  312. package/dist/shared/lib/wallet/venue-ids.d.ts +23 -0
  313. package/dist/shared/lib/wallet/venue-ids.js +53 -0
  314. package/dist/standing-tip.d.ts +24 -0
  315. package/dist/standing-tip.js +52 -0
  316. package/dist/stdout.d.ts +38 -0
  317. package/dist/storage-control-chain.d.ts +38 -0
  318. package/dist/storage-control-chain.js +78 -0
  319. package/dist/sui-rpc.d.ts +15 -0
  320. package/dist/sui-rpc.js +59 -0
  321. package/dist/support-attach.d.ts +24 -0
  322. package/dist/support-attach.js +72 -0
  323. package/dist/support-copy.d.ts +42 -0
  324. package/dist/support-copy.js +109 -0
  325. package/dist/support-wire.d.ts +49 -0
  326. package/dist/support-wire.js +194 -0
  327. package/dist/trash-sweep.d.ts +55 -0
  328. package/dist/units.d.ts +2 -0
  329. package/dist/update-check.d.ts +50 -0
  330. package/dist/update-source.d.ts +63 -0
  331. package/dist/upload-api.d.ts +3 -0
  332. package/dist/upload-file.d.ts +97 -0
  333. package/dist/upload-file.js +3 -2
  334. package/dist/upload-price.d.ts +50 -0
  335. package/dist/upload-steps.d.ts +26 -0
  336. package/dist/upload-steps.js +29 -9
  337. package/dist/upload-store.d.ts +182 -0
  338. package/dist/upload-wallet-chain.d.ts +54 -0
  339. package/dist/upload-wallet-chain.js +203 -0
  340. package/dist/upload-wallet-plan.d.ts +128 -0
  341. package/dist/upload-wallet-plan.js +184 -0
  342. package/dist/upload-wallet.d.ts +24 -0
  343. package/dist/upload-wallet.js +208 -0
  344. package/dist/upload-wire.d.ts +244 -0
  345. package/dist/upload.d.ts +18 -0
  346. package/dist/upload.js +10 -0
  347. package/dist/usage-report.d.ts +35 -0
  348. package/dist/wallet-activity-chain.d.ts +5 -0
  349. package/dist/wallet-activity-chain.js +31 -0
  350. package/dist/wallet-chain.d.ts +19 -0
  351. package/dist/wallet-chain.js +2 -2
  352. package/dist/wallet-grant.d.ts +50 -0
  353. package/dist/wallet-grant.js +218 -0
  354. package/dist/wallet-send-chain.d.ts +24 -0
  355. package/dist/wallet-send-chain.js +49 -0
  356. package/dist/wallet-sign.d.ts +133 -0
  357. package/dist/wallet-sign.js +317 -0
  358. package/dist/wallet-storage-chain.d.ts +3 -0
  359. package/dist/wallet-storage-chain.js +20 -0
  360. package/dist/wallet-swap-chain.d.ts +52 -0
  361. package/dist/wallet-swap-chain.js +186 -0
  362. package/dist/wallet-swap-quote.d.ts +22 -0
  363. package/dist/wallet-swap-quote.js +126 -0
  364. package/dist/wallet.d.ts +135 -0
  365. package/dist/wallet.js +5 -5
  366. package/dist/walrus-write.d.ts +56 -0
  367. package/dist/walrus-write.js +5 -4
  368. package/dist/walrus.d.ts +86 -0
  369. package/dist/walrus.js +48 -10
  370. package/dist/zstd-node.d.ts +11 -0
  371. package/dist/zstd-node.js +71 -0
  372. package/docs/commands/accept-terms.md +15 -0
  373. package/docs/commands/create.md +17 -0
  374. package/docs/commands/credits.md +34 -0
  375. package/docs/commands/delete-account.md +14 -0
  376. package/docs/commands/deposit.md +27 -0
  377. package/docs/commands/devices.md +9 -0
  378. package/docs/commands/documents.md +10 -0
  379. package/docs/commands/env.md +21 -0
  380. package/docs/commands/extend.md +27 -0
  381. package/docs/commands/folders.md +10 -0
  382. package/docs/commands/get.md +14 -0
  383. package/docs/commands/key.md +14 -0
  384. package/docs/commands/login.md +23 -0
  385. package/docs/commands/logout.md +11 -0
  386. package/docs/commands/losses.md +13 -0
  387. package/docs/commands/ls.md +16 -0
  388. package/docs/commands/marks.md +9 -0
  389. package/docs/commands/mcp.md +33 -0
  390. package/docs/commands/mode.md +29 -0
  391. package/docs/commands/on-collision.md +13 -0
  392. package/docs/commands/padding.md +13 -0
  393. package/docs/commands/public-code.md +9 -0
  394. package/docs/commands/pull.md +9 -0
  395. package/docs/commands/push.md +12 -0
  396. package/docs/commands/put.md +36 -0
  397. package/docs/commands/rebuild.md +13 -0
  398. package/docs/commands/recovery.md +18 -0
  399. package/docs/commands/s3.md +17 -0
  400. package/docs/commands/share.md +15 -0
  401. package/docs/commands/support.md +16 -0
  402. package/docs/commands/tip.md +21 -0
  403. package/docs/commands/trash.md +25 -0
  404. package/docs/commands/trial.md +12 -0
  405. package/docs/commands/unlock.md +25 -0
  406. package/docs/commands/update.md +14 -0
  407. package/docs/commands/usage.md +14 -0
  408. package/docs/commands/verify.md +18 -0
  409. package/docs/commands/wallet.md +67 -0
  410. package/docs/commands/whoami.md +12 -0
  411. package/package.json +67 -8
  412. package/server.json +28 -0
  413. package/vendor/nmts-crypto/nmts_crypto_wasm.d.ts +23 -2
  414. package/vendor/nmts-crypto/nmts_crypto_wasm.js +44 -2
  415. package/vendor/nmts-crypto/nmts_crypto_wasm_bg.wasm +0 -0
  416. package/vendor/nmts-crypto/nmts_crypto_wasm_bg.wasm.d.ts +1 -0
  417. package/vendor/nmts-crypto/package.json +1 -1
  418. package/dist/commands/consent.js +0 -77
  419. package/dist/extend-sign.js +0 -130
@@ -0,0 +1,28 @@
1
+ /** The five characters XML cannot carry raw. */
2
+ export declare function escapeXml(value: string): string;
3
+ export declare function errorXml(code: string, message: string, resource: string): string;
4
+ export declare function listBucketsXml(bucket: string, createdAt: string): string;
5
+ export declare function initiateUploadXml(bucket: string, key: string, uploadId: string): string;
6
+ export declare function completeUploadXml(bucket: string, key: string, etag: string): string;
7
+ export interface ObjectRow {
8
+ readonly key: string;
9
+ readonly lastModified: string;
10
+ readonly etag: string;
11
+ readonly size: number;
12
+ }
13
+ export interface ListingXml {
14
+ readonly bucket: string;
15
+ readonly prefix: string;
16
+ readonly delimiter: string;
17
+ readonly maxKeys: number;
18
+ /** Version 2 of the listing call names its cursor differently and counts what it returned. */
19
+ readonly v2: boolean;
20
+ readonly contents: readonly ObjectRow[];
21
+ readonly commonPrefixes: readonly string[];
22
+ readonly truncated: boolean;
23
+ /** The cursor a client sends back to continue, when there is more. */
24
+ readonly next: string | null;
25
+ /** What the client asked to be url-encoded, or null when it asked for nothing. */
26
+ readonly encodingType: string | null;
27
+ }
28
+ export declare function listObjectsXml(listing: ListingXml): string;
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Resolve where one fetched file goes, refusing anything that leaves the chosen directory.
3
+ *
4
+ * ⛔ It takes only the LAST segment of the account path. A file called `../../etc/passwd` in
5
+ * somebody's drive is a legal name for a file; it must not become a path on this disk. The
6
+ * containment check that follows is belt as well as braces — `basename` already strips the
7
+ * separators, and the check catches the day some platform disagrees about what a separator is.
8
+ *
9
+ * ⛔ IT IS ALSO WHAT KEEPS `-` FROM MEANING stdout ON THIS SERVER. `get` reads an `out` of exactly
10
+ * `-` as "hand the file to whatever is reading stdout", and here that reader is the client's
11
+ * protocol connection. Every answer this function gives has been through `resolve`, so it is
12
+ * always an absolute path and never the bare `-`: a model asking for a file named `-` gets a
13
+ * file named `-` inside the chosen directory, and the streaming branch is unreachable from
14
+ * this server rather than merely unused by it.
15
+ */
16
+ export declare function destinationFor(outDir: string, accountPath: string): string;
17
+ /**
18
+ * Windows keeps a handful of names for devices, and writing to one succeeds while storing nothing.
19
+ *
20
+ * ⛔ THE FAILURE IS SILENT, WHICH IS WHY IT IS WORTH CODE. A drive holding a file called `NUL`
21
+ * pulled onto Windows opens the null device: every byte is accepted, nothing is kept, and the
22
+ * tool says it wrote the file. A name containing a colon is worse than silent — it writes an
23
+ * alternate data stream on a DIFFERENT file, where nothing lists it. And a name ending in a dot
24
+ * or a space is not the name it looks like: Win32 strips those before opening, so two files can
25
+ * quietly become one.
26
+ *
27
+ * ⚠ The check is per PLATFORM, not universal. `NUL` is an ordinary, legal file name on Linux and
28
+ * macOS, and refusing it there would take a file away from somebody who can hold it perfectly
29
+ * well. The platform is a parameter so a test on any machine can ask the Windows question.
30
+ *
31
+ * Returns the reason it cannot be written, or null when it can.
32
+ */
33
+ export declare function unwritableOn(name: string, platform: NodeJS.Platform): string | null;
34
+ /**
35
+ * Refuse a name that this platform cannot hold, saying what to do about it.
36
+ *
37
+ * ⛔ A REFUSAL, NOT A RENAME. Renaming quietly would hand somebody a file under a name they did not
38
+ * choose and cannot predict, and the one thing worse than not getting a file is thinking you got
39
+ * it. The person can rename it in the drive, or name it themselves on the way out.
40
+ */
41
+ export declare function refuseUnwritableName(name: string, platform?: NodeJS.Platform): void;
package/dist/seal.d.ts ADDED
@@ -0,0 +1,120 @@
1
+ import type { CryptoGlue } from "./crypto.ts";
2
+ /**
3
+ * How much of a file goes into ONE part, unless the caller says otherwise.
4
+ *
5
+ * ⛔ IT IS A MEMORY BOUND, NOT A PRODUCT LIMIT. Sealing holds a part's ciphertext, and the storage
6
+ * network's erasure coding then expands it about fivefold while it computes the blob id — so a
7
+ * part costs several times its own size in memory before a single byte is sent. The file itself
8
+ * is never held: it is read a slice at a time.
9
+ *
10
+ * ⚠ THIS NUMBER USED TO BE THE WHOLE FILE'S CEILING, and keeping it as the part size is deliberate.
11
+ * It means growing past one part cannot make an upload that worked yesterday run out of memory
12
+ * today — the most memory this tool asks for is the same as it always was.
13
+ *
14
+ * Bigger parts mean fewer reservations, and every reservation counts against the account's daily
15
+ * spending allowance; smaller parts mean less memory and a shorter piece of work to lose when
16
+ * something goes wrong. `put --part-size` is how somebody picks a different trade.
17
+ */
18
+ export declare const DEFAULT_PART_BYTES: number;
19
+ /**
20
+ * What NCF-3 adds to a part's plaintext: a fixed header, and one tag per chunk.
21
+ *
22
+ * ⛔ NOT MEASURED, BECAUSE THE ONE CALLER NEEDS IT BEFORE SEALING: the price is quoted, and
23
+ * `--dry-run` answers, without a very large file ever being read. A test seals real plaintexts
24
+ * with the real engine and compares, so this is held against the format rather than against a
25
+ * copy of these numbers.
26
+ */
27
+ export declare const NCF3_SHAPE: {
28
+ readonly headerLen: 72;
29
+ readonly tagLen: 16;
30
+ readonly chunkSize: number;
31
+ };
32
+ /** How many bytes one sealed part of this plaintext length occupies. */
33
+ export declare function sealedLenFor(plaintextLen: number): number;
34
+ /**
35
+ * The plaintext length a sealed part of this size was sealed FROM.
36
+ *
37
+ * ⛔ WHY THE INVERSE EXISTS. The server is told what a part OCCUPIES and nothing about the file
38
+ * behind it, and it is the only number it can serve back. A recovery list records the length
39
+ * the stored stream DECLARES, because that is what a reader checks the fetched header against —
40
+ * so somewhere the one number has to become the other, and this is that place. It sits beside
41
+ * the forward arithmetic rather than in a module of its own so that the two can never be
42
+ * changed apart.
43
+ *
44
+ * ⛔ IT REFUSES RATHER THAN ROUNDS. Every reachable sealed length has exactly one plaintext length
45
+ * behind it, and the lengths between them are not reachable at all — a stream of n chunks ends
46
+ * where the next one's first tag would begin. The one caller that matters is the recovery
47
+ * list's own integrity check, where a lenient answer would be the failure it exists to catch.
48
+ *
49
+ * ⚠ RESTATED FROM `web/src/lib/crypto/sealed-size.ts::plaintextLenFromSealed`, which this package
50
+ * cannot import (zero imports across the two trees). Only the SEARCH is restated: each candidate
51
+ * is confirmed with `chunkCount` from the shared byte-for-byte copy, so the formula itself still
52
+ * lives in one file.
53
+ */
54
+ export declare function plaintextLenFromSealed(sealedLen: number): number;
55
+ /** Everything an upload needs about one file, and nothing that identifies it. */
56
+ export interface SealedFile {
57
+ /** The complete NCF-3 stream — header, chunks, end mark. These are the bytes that get stored. */
58
+ sealed: Uint8Array;
59
+ /** The file's own key wrapped under the account's data key (base64url envelope). */
60
+ dekWrapped: string;
61
+ /** SHA-256 of the plaintext, sealed under the account's data key (base64url envelope). */
62
+ contentHashCt: string;
63
+ /** Plaintext length — what the file list records, and what a reader reassembles to. */
64
+ plaintextLen: number;
65
+ /** Sealed length — what the server is told, what storage is bought for, what credits count. */
66
+ sealedLen: number;
67
+ }
68
+ /** The three secrets a file carries, made once and reused by every one of its parts. */
69
+ export interface FileSecrets {
70
+ /**
71
+ * The file's own key, raw.
72
+ *
73
+ * ⛔ THE CALLER WIPES IT. Every part of a file is sealed under this one key, so it has to outlive
74
+ * the first part — which means nothing here can wipe it, and the loop that uses it must.
75
+ */
76
+ dek: Uint8Array;
77
+ /** The same key wrapped under the account's data key (base64url envelope). */
78
+ dekWrapped: string;
79
+ /** The plaintext's SHA-256, sealed under the account's data key (base64url envelope). */
80
+ contentHashCt: string;
81
+ }
82
+ /**
83
+ * Make a file's key and seal the hash of its contents.
84
+ *
85
+ * ⛔ THE HASH IS OF THE PLAINTEXT, AND IT IS SEALED RATHER THAN STORED BARE. A bare content hash
86
+ * identifies the file itself: it is the same number for everyone who holds that file, and it is
87
+ * matchable against published hash sets. Sealed, it is checkable only by the account that wrote
88
+ * it — which is the only party that needs to check it.
89
+ *
90
+ * `contentDigest` is the SHA-256 of the whole plaintext, which the caller computes while reading
91
+ * the file. Passing it in rather than the file is what lets this work for a file too large to hold.
92
+ */
93
+ export declare function fileSecrets(crypt: CryptoGlue, dataKey: Uint8Array, contentDigest: Uint8Array): FileSecrets;
94
+ /**
95
+ * Seal ONE part of a file, reading its plaintext as it goes.
96
+ *
97
+ * ⛔ A FRESH SESSION, AND THEREFORE A FRESH NONCE, EVERY TIME. The format requires each part to be
98
+ * its own stream under its own nonce prefix; the engine allocates one inside the session and
99
+ * there is no way from here to reuse one. That is the property that makes a re-sealed part a
100
+ * DIFFERENT blob — which is exactly why a resumed upload pushes the bytes it wrote down rather
101
+ * than sealing again.
102
+ *
103
+ * ⛔ THE DECLARED LENGTH IS CHECKED AGAINST WHAT ARRIVES. The engine refuses to finish a stream
104
+ * that was fed too little; too much is caught here. A part whose header declares a length its
105
+ * bytes do not match is a file that reassembles wrong, and the reader would not find out until
106
+ * the download.
107
+ */
108
+ export declare function sealPart(crypt: CryptoGlue, dek: Uint8Array, chunks: AsyncIterable<Uint8Array>, placement: {
109
+ index: number;
110
+ total: number;
111
+ plaintextLen: number;
112
+ }): Promise<Uint8Array>;
113
+ /**
114
+ * Seal a whole file held in memory, as one part.
115
+ *
116
+ * ⛔ THE DATA KEY IS BORROWED, NOT KEPT. The caller derived it and the caller wipes it; this
117
+ * function does not hold a reference past its own return. The file key it makes IS wiped here,
118
+ * because nothing outside needs it — the wrapped copy is what travels.
119
+ */
120
+ export declare function sealFile(crypt: CryptoGlue, dataKey: Uint8Array, plaintext: Uint8Array): Promise<SealedFile>;
@@ -0,0 +1,28 @@
1
+ export type SecretStep = {
2
+ kind: "more";
3
+ } | {
4
+ kind: "done";
5
+ value: string;
6
+ } | {
7
+ kind: "cancelled";
8
+ };
9
+ /**
10
+ * Accumulates typed bytes into a secret.
11
+ *
12
+ * ⛔ `wipe()` is separate from `take()` on purpose: the caller reads the value and only then
13
+ * clears the buffer. Doing both in one step is what produced the NUL-run defect this file
14
+ * exists to make impossible.
15
+ */
16
+ export declare class SecretReader {
17
+ #private;
18
+ /** Bytes that arrived after the answer ended, for the prompt that comes next. */
19
+ takeLeftover(): Uint8Array;
20
+ /** Feed one chunk. Returns what the caller should do next. */
21
+ push(chunk: Uint8Array): SecretStep;
22
+ /** The value typed so far, with surrounding spaces removed. Clears the buffer. */
23
+ take(): string;
24
+ /** Drop the bytes without reading them. */
25
+ wipe(): void;
26
+ /** How many bytes are held. For tests; never printed. */
27
+ get length(): number;
28
+ }
@@ -0,0 +1,9 @@
1
+ export declare const DEFAULT_SERVER = "https://nmts.me";
2
+ export declare const SERVER_ENV_VAR = "NMTS_SERVER";
3
+ /**
4
+ * Resolve the server for this run: an explicit argument, then the environment, then the default.
5
+ *
6
+ * ⛔ Refuses anything that is not http(s). A credential is sent to whatever this returns, so a
7
+ * typo that lands on another scheme must stop here rather than somewhere further in.
8
+ */
9
+ export declare function resolveServer(explicit?: string | undefined): string;
@@ -0,0 +1,32 @@
1
+ import { type CredentialSource } from "./credentials.ts";
2
+ export interface Session {
3
+ /** The NMTS key. ⛔ Held for the command's own work and never written anywhere. */
4
+ code: string;
5
+ /**
6
+ * Where this machine got that code from.
7
+ *
8
+ * ⛔ CARRIED BECAUSE ONE THING A COMMAND DOES WITH THE CODE STILL NEEDS AN AGREEMENT. Sending
9
+ * the account proof (`account-proof.ts`) is that thing, and the agreement it asks for —
10
+ * `plain-env` — is about WHERE the code came from, not what is being done with it. A session
11
+ * that dropped this would leave the deciding module unable to tell a sealed stored code from
12
+ * an environment variable, and its only options would be to ask always or to ask never.
13
+ */
14
+ source: CredentialSource;
15
+ apiKey: string;
16
+ server: string;
17
+ network: string;
18
+ accountId: string;
19
+ }
20
+ /**
21
+ * The API key, or the one refusal for not having one.
22
+ *
23
+ * ⛔ IT IS ITS OWN FUNCTION BECAUSE ONE COMMAND NEEDS THE KEY AND NOT THE CODE. `verify` asks the
24
+ * server about the account and opens no file, so making it resolve an NMTS key would refuse
25
+ * a run over a credential it never uses — and wording that refusal a second time is exactly how
26
+ * two texts for one problem start.
27
+ */
28
+ export declare function requireApiKey(): string;
29
+ export declare function openSession(options: {
30
+ server?: string | undefined;
31
+ network?: string | undefined;
32
+ }): Promise<Session>;
package/dist/session.js CHANGED
@@ -15,7 +15,7 @@ import { resolveServer } from "./server.js";
15
15
  * The API key, or the one refusal for not having one.
16
16
  *
17
17
  * ⛔ IT IS ITS OWN FUNCTION BECAUSE ONE COMMAND NEEDS THE KEY AND NOT THE CODE. `verify` asks the
18
- * server about the account and opens no file, so making it resolve an account code would refuse
18
+ * server about the account and opens no file, so making it resolve an NMTS key would refuse
19
19
  * a run over a credential it never uses — and wording that refusal a second time is exactly how
20
20
  * two texts for one problem start.
21
21
  */
@@ -0,0 +1,7 @@
1
+ /**
2
+ * The one question setup asks about uploads.
3
+ *
4
+ * ⛔ CALL THIS OUTSIDE `holdTerminal`. Inside it the terminal is in raw mode, where a line prompt
5
+ * never sees a line.
6
+ */
7
+ export declare function askAboutCollisions(say: (line: string) => void): Promise<void>;
@@ -0,0 +1,108 @@
1
+ import { type CryptoGlue } from "./crypto.ts";
2
+ /**
3
+ * This account's sharing secrets, and the identity other people encrypt to.
4
+ *
5
+ * ⛔ THE CALLER WIPES IT. Three of these are secrets sliced out of the account's derivation, and
6
+ * they open every share this account has ever received. `wipe()` on every path out, including
7
+ * failures.
8
+ */
9
+ export interface ShareKeys {
10
+ /** Key-agreement seed. */
11
+ kemSeed: Uint8Array;
12
+ /** Proves this account SENT a share. */
13
+ authSecret: Uint8Array;
14
+ /** Signs the published identity. */
15
+ sigSeed: Uint8Array;
16
+ /** This account's 16-byte public code, in its wire form. */
17
+ address: Uint8Array;
18
+ /** The published identity bundle other people encrypt to. */
19
+ identity: Uint8Array;
20
+ /** The address in the form a person reads and types. */
21
+ display: string;
22
+ wipe(): void;
23
+ }
24
+ /** Derive everything sharing needs from an NMTS key. */
25
+ export declare function shareKeysOf(crypt: CryptoGlue, code: string): ShareKeys;
26
+ /** The three sealed fields a share carries, base64url, exactly as they go to the server. */
27
+ export interface SharePayload {
28
+ dek_share_ct: string;
29
+ name_share_ct: string;
30
+ content_hash_share_ct: string;
31
+ }
32
+ /**
33
+ * Seal one file for one recipient.
34
+ *
35
+ * `recipientIdentity` is checked against `recipientAddress` inside the engine before anything is
36
+ * encrypted to it — length, fingerprint, self-signature and key decoding — which is why both are
37
+ * arguments and why there is no form of this that takes the identity alone. A tool that fetched an
38
+ * identity and wrapped to it without naming the address it asked for would hand a readable key to
39
+ * whoever answered.
40
+ */
41
+ export declare function sealShare(crypt: CryptoGlue, input: {
42
+ keys: ShareKeys;
43
+ recipientIdentity: Uint8Array;
44
+ recipientAddress: Uint8Array;
45
+ /** The file's own key, already unwrapped from the account's sealed list. */
46
+ dek: Uint8Array;
47
+ /** The file's id, exactly as it will be posted. */
48
+ itemId: string;
49
+ /** The name the recipient sees, and the file's real plaintext length. */
50
+ name: string;
51
+ size: number;
52
+ /** The file's whole-plaintext digest, opened from the account's own sealed copy. */
53
+ digest: Uint8Array;
54
+ }): SharePayload;
55
+ /** One row of what somebody shared with this account, as the server describes it. */
56
+ export interface ReceivedRow {
57
+ id: string;
58
+ item_id: string;
59
+ /** Bytes on the storage network — NOT the file's length. The sealed document has that. */
60
+ size: number;
61
+ sender_public_key?: string;
62
+ dek_share_ct: string;
63
+ name_share_ct: string;
64
+ content_hash_share_ct: string;
65
+ created_at: string;
66
+ }
67
+ /** What a received share turns into once opened, or why it could not be. */
68
+ export interface OpenedShare {
69
+ id: string;
70
+ itemId: string;
71
+ createdAt: string;
72
+ /** The file's name as the sender sealed it, or null when the row would not open. */
73
+ name: string | null;
74
+ /** The file's real plaintext length, when the sender recorded one. */
75
+ size: number | null;
76
+ /** The sender's address, in readable form — only ever set when the open SUCCEEDED. */
77
+ sender: string | null;
78
+ /** The file's own key. Present only when it opened; the caller wipes it. */
79
+ dek: Uint8Array | null;
80
+ /** The sealed digest, carried through so a download can check the bytes. */
81
+ digestCt: string;
82
+ /** Why it did not open, for a row that must still be listed. */
83
+ problem: string | null;
84
+ }
85
+ /**
86
+ * Open one received share.
87
+ *
88
+ * ⛔ A ROW THAT WILL NOT OPEN IS STILL RETURNED. Dropping it would tell the account it was sent
89
+ * less than it was, and the honest answer to "this one will not open" is to say so on its own
90
+ * line — not to leave a gap somebody has no way to notice.
91
+ */
92
+ export declare function openReceived(crypt: CryptoGlue, keys: ShareKeys, row: ReceivedRow): OpenedShare;
93
+ /** The digest a recipient checks the downloaded bytes against. */
94
+ export declare function openSharedDigest(crypt: CryptoGlue, dek: Uint8Array, digestCt: string): Uint8Array | null;
95
+ /**
96
+ * Turn what a person typed into the 16 bytes behind a public code.
97
+ *
98
+ * ⛔ A TYPO FAILS HERE, NOT AS A LOOKUP. Sending a mistyped address to the server would ask it a
99
+ * question about somebody who might exist, and the answer is not ours to collect.
100
+ */
101
+ export declare function addressFromTyped(crypt: CryptoGlue, typed: string): Uint8Array;
102
+ /**
103
+ * Check that an identity the server handed back is the one that was asked for.
104
+ *
105
+ * The engine checks this again inside the wrap, and this exists so the refusal says WHICH thing
106
+ * was wrong rather than failing inside a sealing step.
107
+ */
108
+ export declare function identityMatches(crypt: CryptoGlue, identity: Uint8Array, address: Uint8Array): boolean;
package/dist/share.js CHANGED
@@ -24,7 +24,7 @@ const encoder = new TextEncoder();
24
24
  const ENVELOPE_LEN = 1240;
25
25
  const DIGEST_ENVELOPE_LEN = 104;
26
26
  const IDENTITY_LEN = 4989;
27
- /** Derive everything sharing needs from an account code. */
27
+ /** Derive everything sharing needs from an NMTS key. */
28
28
  export function shareKeysOf(crypt, code) {
29
29
  const derived = crypt.kdf_derive(crypt.account_code_parse(code));
30
30
  const slice = (range) => derived.slice(range[0], range[1]);
@@ -0,0 +1,55 @@
1
+ /**
2
+ * How coarsely a stored length is rounded up.
3
+ *
4
+ * `"none"` does not round at all: the sealed length IS the real one, so the stored stream states
5
+ * the file's exact size. It is a choice somebody makes with what it costs them written beside it
6
+ * (2026-09-06) — never a default, and never what an unrecognised spelling falls back to.
7
+ */
8
+ export type PaddingRule = "padme" | "pow2" | "none";
9
+ /**
10
+ * Padmé: round up to a multiple of 2^(E−S), where E = floor(log2 L) and S = floor(log2 E)+1.
11
+ *
12
+ * About 32 possible lengths per doubling, for roughly 1% more storage. Lengths below 4 are
13
+ * returned unchanged — the step there would be a single byte, which hides nothing.
14
+ */
15
+ export declare function padmeLen(len: number): number;
16
+ /** The next power of two at or above `len`: one possible length per doubling. Below 2, unchanged. */
17
+ export declare function pow2Len(len: number): number;
18
+ /** What sealing costs: a fixed header, plus one authentication tag per chunk. */
19
+ export interface SealingShape {
20
+ headerLen: number;
21
+ tagLen: number;
22
+ chunkSize: number;
23
+ }
24
+ /** Chunks a stream of this plaintext length splits into. Empty is one chunk, not zero. */
25
+ export declare function chunkCount(plaintextLen: number, shape: SealingShape): number;
26
+ /** How many bytes one sealed stream of this plaintext length occupies. */
27
+ export declare function sealedLenFor(plaintextLen: number, shape: SealingShape): number;
28
+ /**
29
+ * The largest plaintext length whose sealed stream still fits inside bytes already paid for.
30
+ *
31
+ * Storage for a file of its own is charged in whole units, so every byte between the real sealed
32
+ * length and the next unit boundary has already been bought. Filling them is the one padding that
33
+ * costs nothing at all, which is why it applies before any rule and whichever rule was chosen.
34
+ *
35
+ * `unitBytes` is the billing unit. Pass 0 when the bytes are not billed that way — a file sharing a
36
+ * stored object with others is billed alongside them, and there is no free room to claim.
37
+ */
38
+ export declare function freeCeiling(len: number, unitBytes: number, shape: SealingShape): number;
39
+ /**
40
+ * The plaintext length to seal a final part from. Never smaller than `len`.
41
+ *
42
+ * ⛔ FINAL PART ONLY — see the module note.
43
+ */
44
+ export declare function paddedPlaintextLen(len: number, rule: PaddingRule, options: {
45
+ unitBytes: number;
46
+ shape: SealingShape;
47
+ }): number;
48
+ /**
49
+ * Each part's REAL contributed length, from the file's real size and what each stored stream
50
+ * declares. The read side of the same contract, and the only place that arithmetic is written.
51
+ *
52
+ * Throws rather than repairing. Numbers that do not reconcile would hand back a file with bytes
53
+ * missing or padding in the middle of it, and neither announces itself afterwards.
54
+ */
55
+ export declare function keepLengths(size: number, streamLens: readonly number[]): number[];
@@ -84,6 +84,11 @@ export function paddedPlaintextLen(len, rule, options) {
84
84
  if (!Number.isSafeInteger(len) || len < 0) {
85
85
  throw new RangeError(`padded length needs a non-negative safe integer, got ${len}`);
86
86
  }
87
+ // ⛔ `none` RETURNS THE LENGTH ITSELF, THE FREE FLOOR INCLUDED. Filling out bytes already paid
88
+ // for costs nothing, but it still rounds — and a person who asked to store their exact size
89
+ // and got the next billing boundary instead was told one thing and given another.
90
+ if (rule === "none")
91
+ return len;
87
92
  const byRule = rule === "pow2" ? pow2Len(len) : padmeLen(len);
88
93
  return Math.max(len, byRule, freeCeiling(len, options.unitBytes, options.shape));
89
94
  }
@@ -0,0 +1,95 @@
1
+ import { manifestFingerprint, type AccountSettings, type Manifest, type ManifestEntry } from "./manifest-codec.ts";
2
+ /**
3
+ * Envelope AAD for ONE CHUNK of the chunked file list (NCF-3 §2, §6.3). Its own label, distinct
4
+ * from `AAD_FILE_LIST`, so a chunk can never be presented as an index or an index as a chunk —
5
+ * the server holds both as opaque bytes of the same shape.
6
+ */
7
+ export declare const AAD_FILE_LIST_CHUNK = "nmts/v3/file-list-chunk";
8
+ /** The version an index and its chunks carry. Version 1 is the single blob `manifest-codec` reads. */
9
+ export declare const FILE_LIST_VERSION_CHUNKED = 2;
10
+ /** Compression flag 0x02 — zstd (NCF-3 §6.3.4). 0x00 and 0x01 are `manifest-codec`'s. */
11
+ export declare const FLAG_ZSTD = 2;
12
+ /**
13
+ * The plaintext bound for ONE CHUNK (NCF-3 §6.3.3).
14
+ *
15
+ * On the PLAINTEXT and not on the sealed size, so a writer can decide where to close a chunk
16
+ * before it compresses or seals anything: 3,900,000 bytes plus the flag byte plus the 72-byte
17
+ * envelope is under the server's 4 MiB ceiling by construction, and a compressed chunk is smaller
18
+ * still. The unused remainder is left unused — an entry is never split across two chunks.
19
+ */
20
+ export declare const CHUNK_PLAIN_MAX = 3900000;
21
+ /**
22
+ * The plaintext bound for the INDEX.
23
+ *
24
+ * The index sits where the single blob sat, so it inherits that ceiling (16 MiB sealed · §8.291).
25
+ * It holds one ~110-byte row per chunk plus the account settings, so nothing an account can do
26
+ * brings it near this; the number exists so a reader has a bound to check a compressed frame
27
+ * against instead of trusting what the frame claims about itself.
28
+ */
29
+ export declare const INDEX_PLAIN_MAX = 15000000;
30
+ /** One row of the index: a chunk's name and the range of entries it holds. */
31
+ export interface ManifestChunkRef {
32
+ /** base64url SHA-256 of THIS CHUNK's transport string — its name and its pin. */
33
+ h: string;
34
+ /** How many entries it holds. */
35
+ n: number;
36
+ /** Placement key of its first entry (`manifest-pack.ts`). */
37
+ f: string;
38
+ /** Placement key of its last entry. */
39
+ l: string;
40
+ }
41
+ /** The index — everything version 1 kept except the entries themselves (NCF-3 §6.3.1). */
42
+ export interface ManifestIndexV2 {
43
+ v: typeof FILE_LIST_VERSION_CHUNKED;
44
+ /** The store version this index was sealed at, as §6.1. */
45
+ seq: number;
46
+ /** base64url SHA-256 of the parent INDEX's transport string; absent at version 1. */
47
+ p?: string;
48
+ /** Account-level settings, moved here from beside the entries. */
49
+ settings?: AccountSettings;
50
+ /** In placement order. Empty for an account with no items. */
51
+ chunks: readonly ManifestChunkRef[];
52
+ }
53
+ /** One chunk (NCF-3 §6.3.2). Immutable: an edit produces a new chunk with a new hash. */
54
+ export interface ManifestChunkDoc {
55
+ v: typeof FILE_LIST_VERSION_CHUNKED;
56
+ /**
57
+ * The index version this chunk was written FOR — not the current one. A chunk untouched for a
58
+ * hundred saves still says the version that made it, and that is correct: the index is what says
59
+ * which chunks make up version 141.
60
+ */
61
+ seq: number;
62
+ /** Entries exactly as version 1 carried them, in placement order. */
63
+ items: readonly ManifestEntry[];
64
+ }
65
+ /** What a sealed file-list blob turned out to be. The reader decides by `v`, never by guessing. */
66
+ export type FileListDocument = {
67
+ v: 1;
68
+ manifest: Manifest;
69
+ } | {
70
+ v: typeof FILE_LIST_VERSION_CHUNKED;
71
+ index: ManifestIndexV2;
72
+ };
73
+ /**
74
+ * A chunk's name. The SAME function the parent link uses, deliberately: both commit to the
75
+ * base64url transport string rather than the bytes it encodes, because the string is what travels
76
+ * and the encoding is canonical (fixed alphabet, no padding, one string per byte sequence).
77
+ */
78
+ export declare const chunkFingerprint: typeof manifestFingerprint;
79
+ /** The index → the plaintext to seal under `AAD_FILE_LIST`. */
80
+ export declare function encodeIndex(index: ManifestIndexV2): Promise<Uint8Array>;
81
+ /** Sealed plaintext → the index. Throws `ManifestFormatError` on anything it cannot read. */
82
+ export declare function decodeIndex(body: Uint8Array): Promise<ManifestIndexV2>;
83
+ /** A chunk → the plaintext to seal under `AAD_FILE_LIST_CHUNK`. */
84
+ export declare function encodeChunk(doc: ManifestChunkDoc): Promise<Uint8Array>;
85
+ /** Sealed chunk plaintext → its entries. */
86
+ export declare function decodeChunk(body: Uint8Array): Promise<ManifestChunkDoc>;
87
+ /**
88
+ * The reader's one door: sealed plaintext → whichever version it turned out to be.
89
+ *
90
+ * ⚠ A version-1 body is inflated twice — once here to read `v`, once by `decodeManifest`. That is
91
+ * deliberate rather than a duplicate validator: version 1's rules live in one place and stay
92
+ * there. The cost is bounded and self-extinguishing, because the first save after a version-1 load
93
+ * converts the account (§6.3.6) and no later read takes this branch.
94
+ */
95
+ export declare function decodeFileList(body: Uint8Array): Promise<FileListDocument>;