@dstorage-tech/dstorage-sdk 0.0.4

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 (106) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +530 -0
  3. package/dist/KeypairEncryptionAdapter-AE75YC4W-AOWNSH2M.mjs +9 -0
  4. package/dist/KeypairEncryptionAdapter-AE75YC4W-BAVHRNNJ.mjs +1 -0
  5. package/dist/KeypairEncryptionAdapter-AE75YC4W-BEYO4RUO.mjs +1 -0
  6. package/dist/KeypairEncryptionAdapter-AE75YC4W-VAOH6AAL.mjs +9 -0
  7. package/dist/KeypairEncryptionAdapter-XUKCLRFU-6ERIZN2M.mjs +1 -0
  8. package/dist/KeypairEncryptionAdapter-XUKCLRFU-AYDAZ2TZ.mjs +9 -0
  9. package/dist/KeypairEncryptionAdapter-XUKCLRFU-ERPYK5S4.mjs +8 -0
  10. package/dist/MnemonicEncryptionAdapter-J6IE5OKA-6DFVUVD6.mjs +1 -0
  11. package/dist/MnemonicEncryptionAdapter-J6IE5OKA-O5AJPX42.mjs +1 -0
  12. package/dist/MnemonicEncryptionAdapter-J6IE5OKA-SI6TBLTQ.mjs +9 -0
  13. package/dist/MnemonicEncryptionAdapter-J6IE5OKA-WEPFOTSJ.mjs +9 -0
  14. package/dist/MnemonicEncryptionAdapter-RCHUETBP-DZPBGQG6.mjs +8 -0
  15. package/dist/MnemonicEncryptionAdapter-RCHUETBP-ELAMJMMO.mjs +1 -0
  16. package/dist/MnemonicEncryptionAdapter-RCHUETBP-M7NHGSHO.mjs +9 -0
  17. package/dist/PasswordEncryptionAdapter-CWOXUGR4-2YZ64B4A.mjs +1 -0
  18. package/dist/PasswordEncryptionAdapter-CWOXUGR4-DCEGC2NX.mjs +1 -0
  19. package/dist/PasswordEncryptionAdapter-CWOXUGR4-QEGGYPFJ.mjs +13 -0
  20. package/dist/PasswordEncryptionAdapter-CWOXUGR4-ZYUBUYUI.mjs +13 -0
  21. package/dist/PasswordEncryptionAdapter-ECHND672-3DEFO6FP.mjs +13 -0
  22. package/dist/PasswordEncryptionAdapter-ECHND672-MUTHAMZY.mjs +12 -0
  23. package/dist/PasswordEncryptionAdapter-ECHND672-XVBPHPPT.mjs +1 -0
  24. package/dist/browser.d.mts +2418 -0
  25. package/dist/browser.mjs +5175 -0
  26. package/dist/chunk-25I6ZXUC.mjs +9403 -0
  27. package/dist/chunk-4X5K43JF.mjs +62 -0
  28. package/dist/chunk-4YMF57VY.mjs +1 -0
  29. package/dist/chunk-5MZ7FPPY.mjs +1 -0
  30. package/dist/chunk-5P4EW2YL.mjs +1 -0
  31. package/dist/chunk-5QOKJEH3.mjs +8 -0
  32. package/dist/chunk-5RW7SGA7.mjs +1 -0
  33. package/dist/chunk-62RSKZ6T.mjs +118 -0
  34. package/dist/chunk-6IAQVMSM.mjs +102 -0
  35. package/dist/chunk-BBJCQFWP.mjs +275 -0
  36. package/dist/chunk-BWLEAAFW.mjs +2599 -0
  37. package/dist/chunk-EYF3263P.mjs +2049 -0
  38. package/dist/chunk-FJ7LSZOW.mjs +5537 -0
  39. package/dist/chunk-GUYENY5N.mjs +1 -0
  40. package/dist/chunk-HDD6SUU4.mjs +276 -0
  41. package/dist/chunk-JMPRZK5D.mjs +62 -0
  42. package/dist/chunk-L5QD6GHB.mjs +101 -0
  43. package/dist/chunk-O37NHERH.mjs +17 -0
  44. package/dist/chunk-OLGVVM5Y.mjs +102 -0
  45. package/dist/chunk-PKHRAYFD.mjs +1 -0
  46. package/dist/chunk-PLAOCKSS.mjs +101 -0
  47. package/dist/chunk-QKA2DCR6.mjs +118 -0
  48. package/dist/chunk-RPSRFFXN.mjs +275 -0
  49. package/dist/chunk-TESUOXRJ.mjs +1 -0
  50. package/dist/chunk-TMLXCRJU.mjs +1 -0
  51. package/dist/chunk-TNRKN4LB.mjs +1 -0
  52. package/dist/chunk-TSZ37JDY.mjs +2596 -0
  53. package/dist/chunk-U3MS6KMF.mjs +1 -0
  54. package/dist/chunk-UBALMYIY.mjs +2049 -0
  55. package/dist/chunk-UDYXMII2.mjs +121 -0
  56. package/dist/chunk-UJCSKKID.mjs +30 -0
  57. package/dist/chunk-UOOF4V2Y.mjs +1 -0
  58. package/dist/chunk-VDZ7F7MP.mjs +1329 -0
  59. package/dist/chunk-X4LEBNK6.mjs +276 -0
  60. package/dist/chunk-Z2TH6U4C.mjs +3 -0
  61. package/dist/chunk-Z6DUAI5B.mjs +121 -0
  62. package/dist/chunk-ZEPZ4QDD.mjs +1 -0
  63. package/dist/chunk-ZGUY5EIR.mjs +1 -0
  64. package/dist/cjs-RMZ3L2IO.mjs +5 -0
  65. package/dist/contract-api-AO4RGPLT-4HRCMSCE.mjs +279 -0
  66. package/dist/contract-api-AO4RGPLT-ADH6ZDKC.mjs +279 -0
  67. package/dist/contract-api-AO4RGPLT-ENC72WCG.mjs +280 -0
  68. package/dist/contract-api-AO4RGPLT-PAMIPEI3.mjs +1 -0
  69. package/dist/contract-api-AO4RGPLT-W3RSVP5A.mjs +1 -0
  70. package/dist/contract-api-AO4RGPLT-WENYDV6I.mjs +1 -0
  71. package/dist/contract-api-TJ7JPHZA-6FUBJ6DS.mjs +279 -0
  72. package/dist/contract-api-TJ7JPHZA-ZWP3EH7D.mjs +279 -0
  73. package/dist/contracts/dataregistry/managed/keys/removeReference.prover +0 -0
  74. package/dist/contracts/dataregistry/managed/keys/removeReference.verifier +0 -0
  75. package/dist/contracts/dataregistry/managed/keys/storeReference.prover +0 -0
  76. package/dist/contracts/dataregistry/managed/keys/storeReference.verifier +0 -0
  77. package/dist/contracts/dataregistry/managed/keys/updateReference.prover +0 -0
  78. package/dist/contracts/dataregistry/managed/keys/updateReference.verifier +0 -0
  79. package/dist/contracts/dataregistry/managed/zkir/removeReference.bzkir +0 -0
  80. package/dist/contracts/dataregistry/managed/zkir/removeReference.zkir +138 -0
  81. package/dist/contracts/dataregistry/managed/zkir/storeReference.bzkir +0 -0
  82. package/dist/contracts/dataregistry/managed/zkir/storeReference.zkir +158 -0
  83. package/dist/contracts/dataregistry/managed/zkir/updateReference.bzkir +0 -0
  84. package/dist/contracts/dataregistry/managed/zkir/updateReference.zkir +190 -0
  85. package/dist/dataregistry-simulator-E6RTGGWT-5YEGBW7P.mjs +108 -0
  86. package/dist/dataregistry-simulator-E6RTGGWT-DJS4MHBD.mjs +109 -0
  87. package/dist/dataregistry-simulator-E6RTGGWT-QGCYR3VF.mjs +1 -0
  88. package/dist/dist-655VYUPJ.mjs +1 -0
  89. package/dist/dist-INTAFXQ7.mjs +65 -0
  90. package/dist/dist-MEZZWKP4.mjs +1 -0
  91. package/dist/dist-MOLWJ4Y7.mjs +64 -0
  92. package/dist/dist-UD4WRMYJ.mjs +65 -0
  93. package/dist/errors.d.mts +117 -0
  94. package/dist/errors.d.ts +117 -0
  95. package/dist/errors.js +2308 -0
  96. package/dist/errors.mjs +2278 -0
  97. package/dist/esm5-AGBDHMNS.mjs +1 -0
  98. package/dist/esm5-GFOBLUFI.mjs +350 -0
  99. package/dist/in-memory-private-state-NGOP37V7-DXWZE42Q.mjs +48 -0
  100. package/dist/in-memory-private-state-NGOP37V7-QXT3RUEH.mjs +49 -0
  101. package/dist/in-memory-private-state-NGOP37V7-XFJFNFCQ.mjs +1 -0
  102. package/dist/index.d.mts +2843 -0
  103. package/dist/index.d.ts +2843 -0
  104. package/dist/index.js +19639 -0
  105. package/dist/index.mjs +5177 -0
  106. package/package.json +87 -0
@@ -0,0 +1 @@
1
+ import{a as n}from"./chunk-PKHRAYFD.mjs";import{a as i,q as p,r as w,s as h}from"./chunk-UBALMYIY.mjs";import{scrypt as S}from"@noble/hashes/scrypt.js";var d={v1:{N:131072,r:8,p:1},"v1-lite":{N:65536,r:8,p:1}},N=class m{constructor(t){this.name="password",O(t.password,t.minPasswordLength??12,t.minEntropyBits??60,t.additionalValidators),this.salt=P(t.salt);let r=A(t.preset,t.params);this.N=r.N,this.r=r.r,this.p=r.p;let a=new TextEncoder().encode(t.password),s=S(a,this.salt,{N:this.N,r:this.r,p:this.p,dkLen:64});this.kekMaterialPromise=globalThis.crypto.subtle.importKey("raw",s,"HKDF",!1,["deriveBits"]).then(o=>(s.fill(0),o),o=>{throw s.fill(0),o})}static fromKdfParams(t){if(t.kdf!=="scrypt")throw new i(n.PASSWORD_UNSUPPORTED_KDF,`[dStorage] PasswordEncryptionAdapter.fromKdfParams: unsupported kdf "${t.kdf}". Only "scrypt" is supported.`);return new m({password:t.password,salt:t.salt,params:{N:t.N,r:t.r,p:t.p},...t.minPasswordLength!==void 0&&{minPasswordLength:t.minPasswordLength},...t.minEntropyBits!==void 0&&{minEntropyBits:t.minEntropyBits},...t.additionalValidators!==void 0&&{additionalValidators:t.additionalValidators}})}getKdfParams(){return{kdf:"scrypt",N:this.N,r:this.r,p:this.p}}async wrapDek(t){let r=await this.kekMaterialPromise,a=await p(r);try{return{algorithm:"xchacha20poly1305-v1",kekDerivation:"hkdf-sha256-v1",wrappedDek:await w(t,a)}}finally{a.fill(0)}}async unwrapDek({wrappedDek:t}){let r=await this.kekMaterialPromise,a=await p(r);try{return h(t,a)}finally{a.fill(0)}}async intoKeypairEncryptionAdapter(t,r){let{KeypairEncryptionAdapter:a}=await import("./KeypairEncryptionAdapter-AE75YC4W-BAVHRNNJ.mjs"),{mlkemGenerateKeypairFromSeed:s}=await import("./dist-655VYUPJ.mjs"),o=await this.kekMaterialPromise,l=await globalThis.crypto.subtle.deriveBits({name:"HKDF",hash:"SHA-256",salt:new Uint8Array(32),info:new TextEncoder().encode("dstorage:mlkem-seed:v1")},o,512),c=new Uint8Array(l);try{let{pk:u,sk:k}=s(c,r);return a.fromKeypair(u,k,t,r)}finally{c.fill(0)}}};function P(e){let t=typeof e=="string"?new TextEncoder().encode(e):e;if(t.length===0)throw new i(n.PASSWORD_EMPTY_SALT,'[dStorage] PasswordEncryptionAdapter: salt must not be empty. Provide an app-specific domain label, e.g. "myapp:v1:alice@example.com".');return t}function A(e,t){if(e!==void 0){if(!(e in d))throw new i(n.PASSWORD_UNKNOWN_PRESET,`[dStorage] PasswordEncryptionAdapter: unknown preset "${e}". Valid presets: ${Object.keys(d).join(", ")}.`);return d[e]}return{N:t?.N??d.v1.N,r:t?.r??d.v1.r,p:t?.p??d.v1.p}}function E(e){let t=0;return/[a-z]/.test(e)&&(t+=26),/[A-Z]/.test(e)&&(t+=26),/[0-9]/.test(e)&&(t+=10),/[^a-zA-Z0-9]/.test(e)&&(t+=32),t===0?0:Math.log2(t)*e.length}function y(e,t=5){for(let r=0;r<=e.length-t;r++){let a=!0,s=!0;for(let o=1;o<t;o++){let l=e.charCodeAt(r+o)-e.charCodeAt(r+o-1);if(l!==1&&(a=!1),l!==-1&&(s=!1),!a&&!s)break}if(a||s)return!0}return!1}var v=["qwertyuiop","asdfghjkl","zxcvbnm","1234567890"];function f(e,t=5){let r=e.toLowerCase();for(let a of v)for(let s=0;s<=a.length-t;s++){let o=a.slice(s,s+t),l=o.split("").reverse().join("");if(r.includes(o)||r.includes(l))return!0}return!1}function _(){for(;;){let e=globalThis.crypto.getRandomValues(new Uint8Array(32)),r=btoa(Array.from(e,a=>String.fromCharCode(a)).join("")).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"");if(new Set(r).size>=3&&!y(r)&&!f(r))return r}}function O(e,t,r,a){if(e.length<t)throw new i(n.PASSWORD_TOO_SHORT,`[dStorage] Password too short: ${e.length} character(s) (minimum ${t}). Use a longer passphrase.`);if(new Set(e).size<3)throw new i(n.PASSWORD_TOO_FEW_DISTINCT,"[dStorage] Password is too weak: too few distinct characters.");if(y(e))throw new i(n.PASSWORD_SEQUENTIAL_RUN,"[dStorage] Password is too weak: contains a sequential character run (e.g. abcde, 12345).");if(f(e))throw new i(n.PASSWORD_KEYBOARD_WALK,"[dStorage] Password is too weak: contains a keyboard-row pattern (e.g. qwerty, asdfg).");let s=E(e);if(s<r)throw new i(n.PASSWORD_ENTROPY_TOO_LOW,`[dStorage] Password entropy too low: ~${Math.round(s)} bits (minimum ${r} bits). Use a longer password with a mix of uppercase, lowercase, digits, and symbols.`);if(a)for(let o of a)o(e)}export{d as a,N as b,_ as c};