@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
@@ -1 +0,0 @@
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};