@dstorage-tech/dstorage-sdk 0.0.4 → 0.0.5

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 (55) hide show
  1. package/README.md +2 -0
  2. package/dist/browser.mjs +9 -8
  3. package/dist/index.js +8 -3
  4. package/dist/index.mjs +8 -3
  5. package/package.json +2 -1
  6. package/dist/KeypairEncryptionAdapter-AE75YC4W-AOWNSH2M.mjs +0 -9
  7. package/dist/KeypairEncryptionAdapter-AE75YC4W-BAVHRNNJ.mjs +0 -1
  8. package/dist/KeypairEncryptionAdapter-AE75YC4W-BEYO4RUO.mjs +0 -1
  9. package/dist/KeypairEncryptionAdapter-AE75YC4W-VAOH6AAL.mjs +0 -9
  10. package/dist/KeypairEncryptionAdapter-XUKCLRFU-6ERIZN2M.mjs +0 -1
  11. package/dist/MnemonicEncryptionAdapter-J6IE5OKA-6DFVUVD6.mjs +0 -1
  12. package/dist/MnemonicEncryptionAdapter-J6IE5OKA-O5AJPX42.mjs +0 -1
  13. package/dist/MnemonicEncryptionAdapter-J6IE5OKA-SI6TBLTQ.mjs +0 -9
  14. package/dist/MnemonicEncryptionAdapter-J6IE5OKA-WEPFOTSJ.mjs +0 -9
  15. package/dist/MnemonicEncryptionAdapter-RCHUETBP-ELAMJMMO.mjs +0 -1
  16. package/dist/PasswordEncryptionAdapter-CWOXUGR4-2YZ64B4A.mjs +0 -1
  17. package/dist/PasswordEncryptionAdapter-CWOXUGR4-DCEGC2NX.mjs +0 -1
  18. package/dist/PasswordEncryptionAdapter-CWOXUGR4-QEGGYPFJ.mjs +0 -13
  19. package/dist/PasswordEncryptionAdapter-CWOXUGR4-ZYUBUYUI.mjs +0 -13
  20. package/dist/PasswordEncryptionAdapter-ECHND672-XVBPHPPT.mjs +0 -1
  21. package/dist/chunk-4YMF57VY.mjs +0 -1
  22. package/dist/chunk-5MZ7FPPY.mjs +0 -1
  23. package/dist/chunk-5P4EW2YL.mjs +0 -1
  24. package/dist/chunk-5RW7SGA7.mjs +0 -1
  25. package/dist/chunk-62RSKZ6T.mjs +0 -118
  26. package/dist/chunk-BBJCQFWP.mjs +0 -275
  27. package/dist/chunk-EYF3263P.mjs +0 -2049
  28. package/dist/chunk-GUYENY5N.mjs +0 -1
  29. package/dist/chunk-L5QD6GHB.mjs +0 -101
  30. package/dist/chunk-PKHRAYFD.mjs +0 -1
  31. package/dist/chunk-PLAOCKSS.mjs +0 -101
  32. package/dist/chunk-QKA2DCR6.mjs +0 -118
  33. package/dist/chunk-RPSRFFXN.mjs +0 -275
  34. package/dist/chunk-TESUOXRJ.mjs +0 -1
  35. package/dist/chunk-TMLXCRJU.mjs +0 -1
  36. package/dist/chunk-TNRKN4LB.mjs +0 -1
  37. package/dist/chunk-TSZ37JDY.mjs +0 -2596
  38. package/dist/chunk-U3MS6KMF.mjs +0 -1
  39. package/dist/chunk-UBALMYIY.mjs +0 -2049
  40. package/dist/chunk-UOOF4V2Y.mjs +0 -1
  41. package/dist/chunk-Z2TH6U4C.mjs +0 -3
  42. package/dist/chunk-ZEPZ4QDD.mjs +0 -1
  43. package/dist/chunk-ZGUY5EIR.mjs +0 -1
  44. package/dist/contract-api-AO4RGPLT-4HRCMSCE.mjs +0 -279
  45. package/dist/contract-api-AO4RGPLT-ADH6ZDKC.mjs +0 -279
  46. package/dist/contract-api-AO4RGPLT-PAMIPEI3.mjs +0 -1
  47. package/dist/contract-api-AO4RGPLT-W3RSVP5A.mjs +0 -1
  48. package/dist/contract-api-AO4RGPLT-WENYDV6I.mjs +0 -1
  49. package/dist/contract-api-TJ7JPHZA-ZWP3EH7D.mjs +0 -279
  50. package/dist/dataregistry-simulator-E6RTGGWT-QGCYR3VF.mjs +0 -1
  51. package/dist/dist-655VYUPJ.mjs +0 -1
  52. package/dist/dist-MEZZWKP4.mjs +0 -1
  53. package/dist/dist-UD4WRMYJ.mjs +0 -65
  54. package/dist/esm5-AGBDHMNS.mjs +0 -1
  55. package/dist/in-memory-private-state-NGOP37V7-XFJFNFCQ.mjs +0 -1
package/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # dStorage SDK
2
2
 
3
+ > ⚠️ **Active development (v0.0.x)**: APIs may still change. It's safe to follow the guides, but hold off on production use for now.
4
+
3
5
  > Privacy-first data layer for dApps — client-side encryption + decentralised storage + on-chain coordination in a single SDK.
4
6
 
5
7
  For teams building privacy-sensitive dApps (health, identity, finance, and enterprise workflows) that need strong client-side confidentiality without operating plaintext data infrastructure.
package/dist/browser.mjs CHANGED
@@ -133,9 +133,10 @@ function isStorePartialError(err) {
133
133
  // package.json
134
134
  var package_default = {
135
135
  name: "@dstorage-tech/dstorage-sdk",
136
- version: "0.0.4",
136
+ version: "0.0.5",
137
137
  description: "Privacy-first decentralized storage SDK with pluggable adapters",
138
138
  license: "MIT",
139
+ homepage: "https://dstorage.pro",
139
140
  keywords: [
140
141
  "dstorage",
141
142
  "privacy",
@@ -2553,7 +2554,7 @@ var DStorage = class {
2553
2554
  }
2554
2555
  };
2555
2556
 
2556
- // ../storage/dist/chunk-URI7FNOW.mjs
2557
+ // ../storage/dist/browser.mjs
2557
2558
  var StorageErrorCode = {
2558
2559
  // adapters/mock.ts (15000–15049)
2559
2560
  MOCK_AUTH_TOKEN_REQUIRED: 15001,
@@ -2594,8 +2595,6 @@ var StorageErrorCode = {
2594
2595
  ARWEAVE_BUNDLER_NO_TX_ID_RETURNED: 15413,
2595
2596
  ARWEAVE_BUNDLER_UPLOAD_FAILED: 15414
2596
2597
  };
2597
-
2598
- // ../storage/dist/chunk-BIT7XMIA.mjs
2599
2598
  var memoryStore = /* @__PURE__ */ new Map();
2600
2599
  function bytesToBase64url2(bytes) {
2601
2600
  let binary = "";
@@ -2753,8 +2752,6 @@ var MockStorageAdapter = class {
2753
2752
  );
2754
2753
  }
2755
2754
  };
2756
-
2757
- // ../storage/dist/index.mjs
2758
2755
  var CONTENT_HASH_TAG2 = "X-Content-Hash";
2759
2756
  async function assertContentHash(id, bytes, storedHash, adapter) {
2760
2757
  const actual = await computeBlake3Hex(bytes);
@@ -3063,6 +3060,10 @@ The transaction may still be processed eventually \u2014 track it at:
3063
3060
  function sleep(ms) {
3064
3061
  return new Promise((resolve) => setTimeout(resolve, ms));
3065
3062
  }
3063
+ async function getTurboFactory() {
3064
+ const { TurboFactory } = await import("@ardrive/turbo-sdk/web");
3065
+ return TurboFactory;
3066
+ }
3066
3067
  var ARWEAVE_GATEWAY_URL = "https://turbo-gateway.com";
3067
3068
  var ArweaveBundlerStorageAdapter = class _ArweaveBundlerStorageAdapter {
3068
3069
  constructor(config = {}) {
@@ -3188,7 +3189,7 @@ Check: https://viewblock.io/arweave/tx/${id}`
3188
3189
  }
3189
3190
  // ── estimateCost ───────────────────────────────────────────────────────────────
3190
3191
  async estimateCost(dataSizeBytes) {
3191
- const { TurboFactory } = await import("@ardrive/turbo-sdk");
3192
+ const TurboFactory = await getTurboFactory();
3192
3193
  const turbo = TurboFactory.unauthenticated();
3193
3194
  let costs;
3194
3195
  try {
@@ -3299,7 +3300,7 @@ Check: https://viewblock.io/arweave/tx/${id}`
3299
3300
  "dStorage/arweave-bundler",
3300
3301
  `Uploading ${dataItemBuffer.byteLength}-byte signed data item to bundler\u2026`
3301
3302
  );
3302
- const { TurboFactory } = await import("@ardrive/turbo-sdk");
3303
+ const TurboFactory = await getTurboFactory();
3303
3304
  const turbo = TurboFactory.unauthenticated();
3304
3305
  try {
3305
3306
  const result = await turbo.uploadSignedDataItem({
package/dist/index.js CHANGED
@@ -14569,9 +14569,10 @@ function isStorePartialError(err) {
14569
14569
  // package.json
14570
14570
  var package_default = {
14571
14571
  name: "@dstorage-tech/dstorage-sdk",
14572
- version: "0.0.4",
14572
+ version: "0.0.5",
14573
14573
  description: "Privacy-first decentralized storage SDK with pluggable adapters",
14574
14574
  license: "MIT",
14575
+ homepage: "https://dstorage.pro",
14575
14576
  keywords: [
14576
14577
  "dstorage",
14577
14578
  "privacy",
@@ -17519,6 +17520,10 @@ The transaction may still be processed eventually \u2014 track it at:
17519
17520
  function sleep(ms) {
17520
17521
  return new Promise((resolve) => setTimeout(resolve, ms));
17521
17522
  }
17523
+ async function getTurboFactory() {
17524
+ const { TurboFactory } = await import("@ardrive/turbo-sdk/node");
17525
+ return TurboFactory;
17526
+ }
17522
17527
  var ARWEAVE_GATEWAY_URL = "https://turbo-gateway.com";
17523
17528
  var ArweaveBundlerStorageAdapter = class _ArweaveBundlerStorageAdapter {
17524
17529
  constructor(config = {}) {
@@ -17644,7 +17649,7 @@ Check: https://viewblock.io/arweave/tx/${id}`
17644
17649
  }
17645
17650
  // ── estimateCost ───────────────────────────────────────────────────────────────
17646
17651
  async estimateCost(dataSizeBytes) {
17647
- const { TurboFactory } = await import("@ardrive/turbo-sdk");
17652
+ const TurboFactory = await getTurboFactory();
17648
17653
  const turbo = TurboFactory.unauthenticated();
17649
17654
  let costs;
17650
17655
  try {
@@ -17755,7 +17760,7 @@ Check: https://viewblock.io/arweave/tx/${id}`
17755
17760
  "dStorage/arweave-bundler",
17756
17761
  `Uploading ${dataItemBuffer.byteLength}-byte signed data item to bundler\u2026`
17757
17762
  );
17758
- const { TurboFactory } = await import("@ardrive/turbo-sdk");
17763
+ const TurboFactory = await getTurboFactory();
17759
17764
  const turbo = TurboFactory.unauthenticated();
17760
17765
  try {
17761
17766
  const result = await turbo.uploadSignedDataItem({
package/dist/index.mjs CHANGED
@@ -134,9 +134,10 @@ function isStorePartialError(err) {
134
134
  // package.json
135
135
  var package_default = {
136
136
  name: "@dstorage-tech/dstorage-sdk",
137
- version: "0.0.4",
137
+ version: "0.0.5",
138
138
  description: "Privacy-first decentralized storage SDK with pluggable adapters",
139
139
  license: "MIT",
140
+ homepage: "https://dstorage.pro",
140
141
  keywords: [
141
142
  "dstorage",
142
143
  "privacy",
@@ -3064,6 +3065,10 @@ The transaction may still be processed eventually \u2014 track it at:
3064
3065
  function sleep(ms) {
3065
3066
  return new Promise((resolve) => setTimeout(resolve, ms));
3066
3067
  }
3068
+ async function getTurboFactory() {
3069
+ const { TurboFactory } = await import("@ardrive/turbo-sdk/node");
3070
+ return TurboFactory;
3071
+ }
3067
3072
  var ARWEAVE_GATEWAY_URL = "https://turbo-gateway.com";
3068
3073
  var ArweaveBundlerStorageAdapter = class _ArweaveBundlerStorageAdapter {
3069
3074
  constructor(config = {}) {
@@ -3189,7 +3194,7 @@ Check: https://viewblock.io/arweave/tx/${id}`
3189
3194
  }
3190
3195
  // ── estimateCost ───────────────────────────────────────────────────────────────
3191
3196
  async estimateCost(dataSizeBytes) {
3192
- const { TurboFactory } = await import("@ardrive/turbo-sdk");
3197
+ const TurboFactory = await getTurboFactory();
3193
3198
  const turbo = TurboFactory.unauthenticated();
3194
3199
  let costs;
3195
3200
  try {
@@ -3300,7 +3305,7 @@ Check: https://viewblock.io/arweave/tx/${id}`
3300
3305
  "dStorage/arweave-bundler",
3301
3306
  `Uploading ${dataItemBuffer.byteLength}-byte signed data item to bundler\u2026`
3302
3307
  );
3303
- const { TurboFactory } = await import("@ardrive/turbo-sdk");
3308
+ const TurboFactory = await getTurboFactory();
3304
3309
  const turbo = TurboFactory.unauthenticated();
3305
3310
  try {
3306
3311
  const result = await turbo.uploadSignedDataItem({
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "@dstorage-tech/dstorage-sdk",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "description": "Privacy-first decentralized storage SDK with pluggable adapters",
5
5
  "license": "MIT",
6
+ "homepage": "https://dstorage.pro",
6
7
  "keywords": [
7
8
  "dstorage",
8
9
  "privacy",
@@ -1,9 +0,0 @@
1
- import {
2
- KeypairEncryptionAdapter
3
- } from "./chunk-62RSKZ6T.mjs";
4
- import "./chunk-O37NHERH.mjs";
5
- import "./chunk-TSZ37JDY.mjs";
6
- import "./chunk-UJCSKKID.mjs";
7
- export {
8
- KeypairEncryptionAdapter
9
- };
@@ -1 +0,0 @@
1
- import{a as r}from"./chunk-UOOF4V2Y.mjs";import"./chunk-PKHRAYFD.mjs";import"./chunk-UBALMYIY.mjs";export{r as KeypairEncryptionAdapter};
@@ -1 +0,0 @@
1
- import{a as r}from"./chunk-ZEPZ4QDD.mjs";import"./chunk-PKHRAYFD.mjs";import"./chunk-EYF3263P.mjs";export{r as KeypairEncryptionAdapter};
@@ -1,9 +0,0 @@
1
- import {
2
- KeypairEncryptionAdapter
3
- } from "./chunk-QKA2DCR6.mjs";
4
- import "./chunk-O37NHERH.mjs";
5
- import "./chunk-BWLEAAFW.mjs";
6
- import "./chunk-UJCSKKID.mjs";
7
- export {
8
- KeypairEncryptionAdapter
9
- };
@@ -1 +0,0 @@
1
- import{a as r}from"./chunk-TESUOXRJ.mjs";import"./chunk-PKHRAYFD.mjs";import"./chunk-EYF3263P.mjs";export{r as KeypairEncryptionAdapter};
@@ -1 +0,0 @@
1
- import{a as o}from"./chunk-5RW7SGA7.mjs";import"./chunk-PKHRAYFD.mjs";import"./chunk-UBALMYIY.mjs";export{o as MnemonicEncryptionAdapter};
@@ -1 +0,0 @@
1
- import{a as o}from"./chunk-5MZ7FPPY.mjs";import"./chunk-PKHRAYFD.mjs";import"./chunk-EYF3263P.mjs";export{o as MnemonicEncryptionAdapter};
@@ -1,9 +0,0 @@
1
- import {
2
- MnemonicEncryptionAdapter
3
- } from "./chunk-PLAOCKSS.mjs";
4
- import "./chunk-O37NHERH.mjs";
5
- import "./chunk-BWLEAAFW.mjs";
6
- import "./chunk-UJCSKKID.mjs";
7
- export {
8
- MnemonicEncryptionAdapter
9
- };
@@ -1,9 +0,0 @@
1
- import {
2
- MnemonicEncryptionAdapter
3
- } from "./chunk-L5QD6GHB.mjs";
4
- import "./chunk-O37NHERH.mjs";
5
- import "./chunk-TSZ37JDY.mjs";
6
- import "./chunk-UJCSKKID.mjs";
7
- export {
8
- MnemonicEncryptionAdapter
9
- };
@@ -1 +0,0 @@
1
- import{a as o}from"./chunk-5P4EW2YL.mjs";import"./chunk-PKHRAYFD.mjs";import"./chunk-EYF3263P.mjs";export{o as MnemonicEncryptionAdapter};
@@ -1 +0,0 @@
1
- import{a as r,b as o,c as t}from"./chunk-TMLXCRJU.mjs";import"./chunk-PKHRAYFD.mjs";import"./chunk-EYF3263P.mjs";export{r as KDF_PRESETS,o as PasswordEncryptionAdapter,t as generatePqsPassword};
@@ -1 +0,0 @@
1
- import{a as r,b as o,c as t}from"./chunk-U3MS6KMF.mjs";import"./chunk-PKHRAYFD.mjs";import"./chunk-UBALMYIY.mjs";export{r as KDF_PRESETS,o as PasswordEncryptionAdapter,t as generatePqsPassword};
@@ -1,13 +0,0 @@
1
- import {
2
- KDF_PRESETS,
3
- PasswordEncryptionAdapter,
4
- generatePqsPassword
5
- } from "./chunk-RPSRFFXN.mjs";
6
- import "./chunk-O37NHERH.mjs";
7
- import "./chunk-TSZ37JDY.mjs";
8
- import "./chunk-UJCSKKID.mjs";
9
- export {
10
- KDF_PRESETS,
11
- PasswordEncryptionAdapter,
12
- generatePqsPassword
13
- };
@@ -1,13 +0,0 @@
1
- import {
2
- KDF_PRESETS,
3
- PasswordEncryptionAdapter,
4
- generatePqsPassword
5
- } from "./chunk-BBJCQFWP.mjs";
6
- import "./chunk-O37NHERH.mjs";
7
- import "./chunk-BWLEAAFW.mjs";
8
- import "./chunk-UJCSKKID.mjs";
9
- export {
10
- KDF_PRESETS,
11
- PasswordEncryptionAdapter,
12
- generatePqsPassword
13
- };
@@ -1 +0,0 @@
1
- import{a as r,b as o,c as t}from"./chunk-GUYENY5N.mjs";import"./chunk-PKHRAYFD.mjs";import"./chunk-EYF3263P.mjs";export{r as KDF_PRESETS,o as PasswordEncryptionAdapter,t as generatePqsPassword};
@@ -1 +0,0 @@
1
- var _={MOCK_REF_NOT_FOUND:11001,MOCK_REF_NOT_FOUND_REMOVE:11002,MOCK_REF_NOT_FOUND_UPDATE:11003,MOCK_OWNER_SECRET_REQUIRED:11004,MOCK_OWNER_SECRET_MISMATCH:11005,GATEWAY_WRITE_FAILED:11201,GATEWAY_WRITE_HTTP_ERROR:11202,GATEWAY_UPDATE_FAILED:11203,GATEWAY_UPDATE_HTTP_ERROR:11204,GATEWAY_READ_FAILED:11205,GATEWAY_READ_HTTP_ERROR:11206,GATEWAY_READ_INVALID_JSON:11207,GATEWAY_READ_INVALID_SHAPE:11208,GATEWAY_LIST_FAILED:11209,GATEWAY_LIST_HTTP_ERROR:11210,GATEWAY_LIST_INVALID_JSON:11211,GATEWAY_LIST_NOT_ARRAY:11212,GATEWAY_REMOVE_FAILED:11213,GATEWAY_REMOVE_HTTP_ERROR:11214,CONTRACT_UNSUPPORTED_VERSION:11401,CONTRACT_CIRCUIT_RESULT_MISSING:11402,MIDNIGHT_NETWORK_REQUIRED:11501,MIDNIGHT_WALLET_PROVIDER_REQUIRED:11502,MIDNIGHT_PRIVATE_STATE_PASSWORD_REQUIRED:11503,MIDNIGHT_ZK_ARTIFACTS_PATH_EMPTY:11504,MIDNIGHT_ZK_CONFIG_BASE_URL_EMPTY:11505,MIDNIGHT_UNSUPPORTED_NETWORK:11506,MIDNIGHT_AUTH_TOKEN_REQUIRED:11507,MIDNIGHT_ZK_CONFIG_BASE_URL_REQUIRED:11508,MIDNIGHT_ZK_ARTIFACTS_PATH_REQUIRED:11509,MIDNIGHT_ZK_ARTIFACTS_PATH_NOT_FOUND:11510,MIDNIGHT_CONNECTOR_NOT_INITIALIZED:11511,MIDNIGHT_COIN_PUBLIC_KEY_MISSING:11512,MIDNIGHT_ENC_PUBLIC_KEY_MISSING:11513,MIDNIGHT_INDEXER_HTTP_NOT_SET:11514,MIDNIGHT_INDEXER_WS_NOT_SET:11515,MIDNIGHT_PROOF_SERVER_NOT_SET:11516,MIDNIGHT_NOT_INITIALIZED:11517,MIDNIGHT_INVALID_CONTRACT_ADDRESS:11518,MIDNIGHT_REF_NOT_FOUND:11519,MIDNIGHT_KEYENVELOPE_REQUIRED:11520,MIDNIGHT_OWNER_SECRET_REQUIRED_WRITE:11521,MIDNIGHT_OWNER_SECRET_REQUIRED_REMOVE:11522,MIDNIGHT_OWNER_SECRET_REQUIRED_UPDATE:11523,MIDNIGHT_WALLET_NOT_FOUND:11524,MIDNIGHT_NO_WALLETS_FOUND:11525,MIDNIGHT_WALLET_CONNECT_FAILED:11526,MIDNIGHT_NO_ADDRESSES:11527,MIDNIGHT_EXTRACT_ADDRESSES_FAILED:11528,MIDNIGHT_GET_ADDRESSES_NOT_INITIALIZED:11529,MIDNIGHT_GET_BALANCES_NOT_INITIALIZED:11530};export{_ as a};
@@ -1 +0,0 @@
1
- import{a as c}from"./chunk-PKHRAYFD.mjs";import{a as n,f as s,q as o,r as m,s as l}from"./chunk-EYF3263P.mjs";var u=class{constructor(r){if(this.name="mnemonic",r.mnemonic!==void 0){let e=r.mnemonic.trim().split(/\s+/).length;if(e<24)throw new n(c.MNEMONIC_TOO_SHORT,`[dStorage] MnemonicEncryptionAdapter: a 24-word BIP-39 mnemonic is required (${e} word${e===1?"":"s"} provided). Shorter mnemonics provide insufficient entropy for post-quantum-safe key derivation \u2014 a 12-word mnemonic gives only 64-bit PQ security (below NIST's 128-bit minimum). Use a 24-word mnemonic or pass a 64-byte seedHex instead.`)}let t=new s(r);this.kekMaterialPromise=t.getSeed().then(e=>globalThis.crypto.subtle.importKey("raw",Uint8Array.from(e),"HKDF",!1,["deriveBits"]).then(i=>(e.fill(0),i),i=>{throw e.fill(0),i}))}async wrapDek(r){let t=await this.kekMaterialPromise,e=await o(t);try{return{algorithm:"xchacha20poly1305-v1",kekDerivation:"hkdf-sha256-v1",wrappedDek:await m(r,e)}}finally{e.fill(0)}}async unwrapDek({wrappedDek:r}){let t=await this.kekMaterialPromise,e=await o(t);try{return l(r,e)}finally{e.fill(0)}}async intoKeypairEncryptionAdapter(r,t){let{KeypairEncryptionAdapter:e}=await import("./KeypairEncryptionAdapter-AE75YC4W-BEYO4RUO.mjs"),{mlkemGenerateKeypairFromSeed:i}=await import("./dist-MEZZWKP4.mjs"),p=await this.kekMaterialPromise,y=await globalThis.crypto.subtle.deriveBits({name:"HKDF",hash:"SHA-256",salt:new Uint8Array(32),info:new TextEncoder().encode("dstorage:mlkem-seed:v1")},p,512),a=new Uint8Array(y);try{let{pk:k,sk:d}=i(a,t);return e.fromKeypair(k,d,r,t)}finally{a.fill(0)}}};export{u as a};
@@ -1 +0,0 @@
1
- import{a as c}from"./chunk-PKHRAYFD.mjs";import{a as n,f as s,q as o,r as m,s as l}from"./chunk-EYF3263P.mjs";var u=class{constructor(r){if(this.name="mnemonic",r.mnemonic!==void 0){let e=r.mnemonic.trim().split(/\s+/).length;if(e<24)throw new n(c.MNEMONIC_TOO_SHORT,`[dStorage] MnemonicEncryptionAdapter: a 24-word BIP-39 mnemonic is required (${e} word${e===1?"":"s"} provided). Shorter mnemonics provide insufficient entropy for post-quantum-safe key derivation \u2014 a 12-word mnemonic gives only 64-bit PQ security (below NIST's 128-bit minimum). Use a 24-word mnemonic or pass a 64-byte seedHex instead.`)}let t=new s(r);this.kekMaterialPromise=t.getSeed().then(e=>globalThis.crypto.subtle.importKey("raw",Uint8Array.from(e),"HKDF",!1,["deriveBits"]).then(i=>(e.fill(0),i),i=>{throw e.fill(0),i}))}async wrapDek(r){let t=await this.kekMaterialPromise,e=await o(t);try{return{algorithm:"xchacha20poly1305-v1",kekDerivation:"hkdf-sha256-v1",wrappedDek:await m(r,e)}}finally{e.fill(0)}}async unwrapDek({wrappedDek:r}){let t=await this.kekMaterialPromise,e=await o(t);try{return l(r,e)}finally{e.fill(0)}}async intoKeypairEncryptionAdapter(r,t){let{KeypairEncryptionAdapter:e}=await import("./KeypairEncryptionAdapter-XUKCLRFU-6ERIZN2M.mjs"),{mlkemGenerateKeypairFromSeed:i}=await import("./dist-MEZZWKP4.mjs"),p=await this.kekMaterialPromise,y=await globalThis.crypto.subtle.deriveBits({name:"HKDF",hash:"SHA-256",salt:new Uint8Array(32),info:new TextEncoder().encode("dstorage:mlkem-seed:v1")},p,512),a=new Uint8Array(y);try{let{pk:k,sk:d}=i(a,t);return e.fromKeypair(k,d,r,t)}finally{a.fill(0)}}};export{u as a};
@@ -1 +0,0 @@
1
- import{a as c}from"./chunk-PKHRAYFD.mjs";import{a as n,f as s,q as o,r as m,s as l}from"./chunk-UBALMYIY.mjs";var u=class{constructor(r){if(this.name="mnemonic",r.mnemonic!==void 0){let e=r.mnemonic.trim().split(/\s+/).length;if(e<24)throw new n(c.MNEMONIC_TOO_SHORT,`[dStorage] MnemonicEncryptionAdapter: a 24-word BIP-39 mnemonic is required (${e} word${e===1?"":"s"} provided). Shorter mnemonics provide insufficient entropy for post-quantum-safe key derivation \u2014 a 12-word mnemonic gives only 64-bit PQ security (below NIST's 128-bit minimum). Use a 24-word mnemonic or pass a 64-byte seedHex instead.`)}let t=new s(r);this.kekMaterialPromise=t.getSeed().then(e=>globalThis.crypto.subtle.importKey("raw",Uint8Array.from(e),"HKDF",!1,["deriveBits"]).then(i=>(e.fill(0),i),i=>{throw e.fill(0),i}))}async wrapDek(r){let t=await this.kekMaterialPromise,e=await o(t);try{return{algorithm:"xchacha20poly1305-v1",kekDerivation:"hkdf-sha256-v1",wrappedDek:await m(r,e)}}finally{e.fill(0)}}async unwrapDek({wrappedDek:r}){let t=await this.kekMaterialPromise,e=await o(t);try{return l(r,e)}finally{e.fill(0)}}async intoKeypairEncryptionAdapter(r,t){let{KeypairEncryptionAdapter:e}=await import("./KeypairEncryptionAdapter-AE75YC4W-BAVHRNNJ.mjs"),{mlkemGenerateKeypairFromSeed:i}=await import("./dist-655VYUPJ.mjs"),p=await this.kekMaterialPromise,y=await globalThis.crypto.subtle.deriveBits({name:"HKDF",hash:"SHA-256",salt:new Uint8Array(32),info:new TextEncoder().encode("dstorage:mlkem-seed:v1")},p,512),a=new Uint8Array(y);try{let{pk:k,sk:d}=i(a,t);return e.fromKeypair(k,d,r,t)}finally{a.fill(0)}}};export{u as a};
@@ -1,118 +0,0 @@
1
- import {
2
- EncryptionErrorCode
3
- } from "./chunk-O37NHERH.mjs";
4
- import {
5
- DStorageError,
6
- mlkemGenerateKeypair,
7
- mlkemUnwrapDek,
8
- mlkemWrapDek
9
- } from "./chunk-TSZ37JDY.mjs";
10
-
11
- // ../encryption/dist/chunk-55C752ON.mjs
12
- var KeypairEncryptionAdapter = class _KeypairEncryptionAdapter {
13
- constructor(pk, sk, context, variant) {
14
- this.publicKey = pk;
15
- this.secretKey = sk;
16
- this.context = context;
17
- this.variant = variant;
18
- this.name = variant;
19
- }
20
- /**
21
- * Upload-only adapter — holds only the Public Key.
22
- * wrapDek() works normally; unwrapDek() throws (no SK available).
23
- */
24
- static fromPublicKey(pk, context, variant = "mlkem768") {
25
- return new _KeypairEncryptionAdapter(pk, void 0, context, variant);
26
- }
27
- /**
28
- * Full adapter — holds both Public Key and Secret Key.
29
- * Both wrapDek() and unwrapDek() work.
30
- */
31
- static fromKeypair(pk, sk, context, variant = "mlkem768") {
32
- return new _KeypairEncryptionAdapter(pk, sk, context, variant);
33
- }
34
- /**
35
- * Generate a fresh random ML-KEM keypair.
36
- *
37
- * Returns the adapter (with both PK+SK) plus the raw keys so the caller
38
- * can persist the secret key and share the public key separately.
39
- *
40
- * @param variant Default: "mlkem768".
41
- */
42
- static generateKeypair(context, variant = "mlkem768") {
43
- const { pk, sk } = mlkemGenerateKeypair(variant);
44
- return {
45
- adapter: new _KeypairEncryptionAdapter(pk, sk, context, variant),
46
- publicKey: pk,
47
- secretKey: sk
48
- };
49
- }
50
- /**
51
- * Deterministically derive a ML-KEM keypair from a BIP-39 mnemonic phrase or hex seed.
52
- *
53
- * Delegates to MnemonicEncryptionAdapter.intoKeypairEncryptionAdapter() so all
54
- * mnemonic/seed handling lives in a single place.
55
- *
56
- * Same inputs + variant always produce the same keypair.
57
- *
58
- * Note: 32-byte seedHex (64 hex characters) is not supported — use a mnemonic
59
- * or a 64-byte seedHex (128 hex characters) instead.
60
- *
61
- * @param input { mnemonic } or { seedHex } (64-byte hex, 128 chars)
62
- * @param variant Default: "mlkem768"
63
- */
64
- static async fromMnemonic(input, context, variant = "mlkem768") {
65
- const { MnemonicEncryptionAdapter } = await import("./MnemonicEncryptionAdapter-J6IE5OKA-WEPFOTSJ.mjs");
66
- const ms = new MnemonicEncryptionAdapter(input);
67
- return ms.intoKeypairEncryptionAdapter(context, variant);
68
- }
69
- /**
70
- * Deterministically derive a ML-KEM keypair from a password and salt.
71
- *
72
- * Delegates to PasswordEncryptionAdapter.intoKeypairEncryptionAdapter() so all
73
- * password handling (scrypt params, entropy validation, 64-byte seed derivation)
74
- * lives in a single place.
75
- *
76
- * Same password + salt + variant always produces the same keypair.
77
- *
78
- * @param password User password (validated for entropy)
79
- * @param salt Domain salt — must not be empty
80
- * @param variant Default: "mlkem768"
81
- * @param params Optional custom scrypt params
82
- */
83
- static async fromPassword(password, salt, context, variant = "mlkem768", params) {
84
- const { PasswordEncryptionAdapter } = await import("./PasswordEncryptionAdapter-CWOXUGR4-QEGGYPFJ.mjs");
85
- const ps = new PasswordEncryptionAdapter({
86
- password,
87
- salt,
88
- ...params ? { params } : {}
89
- });
90
- return ps.intoKeypairEncryptionAdapter(context, variant);
91
- }
92
- /**
93
- * Zero the Secret Key bytes and mark this adapter as read-only.
94
- * Call when the adapter is no longer needed to minimise the window
95
- * during which raw ML-KEM key material sits in GC-reachable memory.
96
- * After destroy(), unwrapDek() will throw.
97
- */
98
- destroy() {
99
- this.secretKey?.fill(0);
100
- this.secretKey = void 0;
101
- }
102
- async wrapDek(dek) {
103
- return mlkemWrapDek(dek, this.publicKey, this.context, this.variant);
104
- }
105
- async unwrapDek(data) {
106
- if (!this.secretKey) {
107
- throw new DStorageError(
108
- EncryptionErrorCode.KEYPAIR_MISSING_SECRET_KEY,
109
- `[dStorage] KeypairEncryptionAdapter(${this.variant}): cannot unwrapDek \u2014 no Secret Key is available. Use fromKeypair() or fromPassword() to create an adapter with a SK.`
110
- );
111
- }
112
- return mlkemUnwrapDek(data, this.secretKey, this.context);
113
- }
114
- };
115
-
116
- export {
117
- KeypairEncryptionAdapter
118
- };