@gjsify/crypto 0.4.35 → 0.4.36
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.
- package/lib/esm/browser/cipher.js +1 -0
- package/lib/esm/browser/hash.js +1 -0
- package/lib/esm/browser/hmac.js +1 -0
- package/lib/esm/browser/kdf.js +1 -0
- package/lib/esm/browser/random.js +1 -0
- package/lib/esm/browser/sign.js +1 -0
- package/lib/esm/browser/stubs.js +1 -0
- package/lib/esm/browser.js +1 -0
- package/lib/esm/index.js +1 -1
- package/lib/types/browser/cipher.d.ts +48 -0
- package/lib/types/browser/hash.d.ts +22 -0
- package/lib/types/browser/hmac.d.ts +16 -0
- package/lib/types/browser/kdf.d.ts +15 -0
- package/lib/types/browser/random.d.ts +12 -0
- package/lib/types/browser/sign.d.ts +35 -0
- package/lib/types/browser/stubs.d.ts +36 -0
- package/lib/types/browser.d.ts +93 -0
- package/package.json +52 -10
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"../_virtual/_rolldown/runtime.js";import{Buffer as e}from"node:buffer";function parseCipherName(e){let t=e.toLowerCase().replace(/_/g,`-`).match(/^aes-(128|192|256)-(cbc|ctr|gcm)$/);if(!t){let t=Error(`Unsupported cipher in browser builds: ${e}. Supported: aes-{128,192,256}-{cbc,ctr,gcm}.`);throw t.code=`ENOTSUP_CIPHER`,t}let n=Number(t[1]),r=t[2];return{webMode:`AES-${r.toUpperCase()}`,keyBits:n,aesMode:`aes-${r}`}}function getWebSubtle(){if(globalThis.crypto===void 0||globalThis.crypto.subtle===void 0)throw Error(`WebCrypto SubtleCrypto is unavailable in this environment`);return globalThis.crypto.subtle}function toBytes(t){return typeof t==`string`?e.from(t,`utf8`):t instanceof Uint8Array?t:e.from(t)}function syncUnsupportedError(){let e=Error(`Synchronous Cipher.final() / Decipher.final() is not supported in browser builds. Use finalAsync() (returns Promise<Buffer>) or await crypto.subtle.encrypt/decrypt directly.`);return e.code=`ENOTSUP_SYNC_CIPHER`,e}var CipherBase=class{_parsed;_key;_iv;_chunks=[];_aad=null;_authTag=null;_finalized=!1;constructor(e,t,n){if(this._parsed=parseCipherName(e),t.byteLength*8!==this._parsed.keyBits)throw RangeError(`Invalid key length: got ${t.byteLength*8} bits, expected ${this._parsed.keyBits}.`);this._key=t,this._iv=n}update(t,n){if(this._finalized)throw Error(`Cipher already finalised`);let r=typeof t==`string`?e.from(t,n??`utf8`):toBytes(t);return this._chunks.push(r),e.alloc(0)}setAAD(t){if(this._parsed.aesMode!==`aes-gcm`)throw Error(`setAAD() is only valid for AES-GCM`);return this._aad=t instanceof Uint8Array?t:e.from(t),this}final(e){throw syncUnsupportedError()}_allBytes(){if(this._chunks.length===0)return new Uint8Array;if(this._chunks.length===1)return this._chunks[0];let e=this._chunks.reduce((e,t)=>e+t.byteLength,0),t=new Uint8Array(e),n=0;for(let e of this._chunks)t.set(e,n),n+=e.byteLength;return t}_algorithmParams(){switch(this._parsed.aesMode){case`aes-cbc`:return{name:`AES-CBC`,iv:this._iv};case`aes-ctr`:return{name:`AES-CTR`,counter:this._iv,length:64};case`aes-gcm`:return{name:`AES-GCM`,iv:this._iv,...this._aad?{additionalData:this._aad}:{}}}}},Cipher=class extends CipherBase{async finalAsync(t){if(this._finalized)throw Error(`Cipher already finalised`);this._finalized=!0;let n=getWebSubtle(),r=await n.importKey(`raw`,this._key,this._parsed.webMode,!1,[`encrypt`]),i=await n.encrypt(this._algorithmParams(),r,this._allBytes()),a=e.from(i);return this._parsed.aesMode===`aes-gcm`&&(this._authTag=a.subarray(a.byteLength-16)),t?a.toString(t):a}getAuthTag(){if(this._parsed.aesMode!==`aes-gcm`)throw Error(`getAuthTag() is only valid for AES-GCM`);if(!this._authTag)throw Error(`getAuthTag() called before finalAsync()`);return e.from(this._authTag)}},Decipher=class extends CipherBase{setAuthTag(t){if(this._parsed.aesMode!==`aes-gcm`)throw Error(`setAuthTag() is only valid for AES-GCM`);return this._authTag=t instanceof Uint8Array?t:e.from(t),this}async finalAsync(t){if(this._finalized)throw Error(`Cipher already finalised`);this._finalized=!0;let n=getWebSubtle(),r=await n.importKey(`raw`,this._key,this._parsed.webMode,!1,[`decrypt`]),i=this._allBytes();if(this._parsed.aesMode===`aes-gcm`){if(!this._authTag)throw Error(`GCM decrypt requires setAuthTag() before finalAsync()`);let e=new Uint8Array(i.byteLength+this._authTag.byteLength);e.set(i,0),e.set(this._authTag,i.byteLength),i=e}let a=await n.decrypt(this._algorithmParams(),r,i),o=e.from(a);return t?o.toString(t):o}};function createCipheriv(e,t,n){return new Cipher(e,toBytes(t),toBytes(n))}function createDecipheriv(e,t,n){return new Decipher(e,toBytes(t),toBytes(n))}function createCipher(e,t){let n=Error(`createCipher() is deprecated and not supported in browser builds. Use createCipheriv() with an explicit IV.`);throw n.code=`ENOTSUP_LEGACY_CIPHER`,n}function createDecipher(e,t){let n=Error(`createDecipher() is deprecated and not supported in browser builds. Use createDecipheriv() with an explicit IV.`);throw n.code=`ENOTSUP_LEGACY_CIPHER`,n}function getCiphers(){return[`aes-128-cbc`,`aes-192-cbc`,`aes-256-cbc`,`aes-128-ctr`,`aes-192-ctr`,`aes-256-ctr`,`aes-128-gcm`,`aes-192-gcm`,`aes-256-gcm`]}export{Cipher,Decipher,createCipher,createCipheriv,createDecipher,createDecipheriv,getCiphers};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"../_virtual/_rolldown/runtime.js";import{Buffer as e}from"node:buffer";const t={sha1:`SHA-1`,sha256:`SHA-256`,sha384:`SHA-384`,sha512:`SHA-512`};function normalizeAlgorithm(e){return e.toLowerCase().replace(/-/g,``)}function getWebSubtle(){if(globalThis.crypto===void 0||globalThis.crypto.subtle===void 0)throw Error(`WebCrypto SubtleCrypto is unavailable in this environment`);return globalThis.crypto.subtle}function makeSyncUnsupportedError(e){let t=Error(`Synchronous digest is not supported in browser builds (algorithm: ${e}). Call hash.digestAsync(encoding) or await crypto.subtle.digest() instead.`);return t.code=`ENOTSUP_SYNC_DIGEST`,t}var n=class Hash{_algorithm;_webAlgo;_chunks=[];_totalLen=0;_finalized=!1;constructor(e){let n=normalizeAlgorithm(e),r=t[n];if(!r){let t=Error(`Unknown or unsupported message digest: ${e}`);throw t.code=`ERR_CRYPTO_HASH_UNKNOWN`,t}this._algorithm=n,this._webAlgo=r}update(t,n){if(this._finalized)throw Error(`Digest already called`);let r;return r=typeof t==`string`?e.from(t,n??`utf8`):t instanceof Uint8Array?t:e.from(t),this._chunks.push(r),this._totalLen+=r.byteLength,this}async digestAsync(t){if(this._finalized)throw Error(`Digest already called`);this._finalized=!0;let n=getWebSubtle(),r=this._concat(),i=await n.digest(this._webAlgo,r),a=e.from(i);return t?a.toString(t):a}digest(e){throw makeSyncUnsupportedError(this._algorithm)}copy(){if(this._finalized)throw Error(`Digest already called`);let e=new Hash(this._algorithm);return e._chunks=[...this._chunks],e._totalLen=this._totalLen,e}_concat(){if(this._chunks.length===1)return this._chunks[0];let e=new Uint8Array(this._totalLen),t=0;for(let n of this._chunks)e.set(n,t),t+=n.byteLength;return e}};function createHash(e){return new n(e)}function getHashes(){return Object.keys(t)}async function hash(e,t,r){return new n(e).update(t).digestAsync(r)}export{n as Hash,createHash,getHashes,hash};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"../_virtual/_rolldown/runtime.js";import{Buffer as e}from"node:buffer";const t={sha1:`SHA-1`,sha256:`SHA-256`,sha384:`SHA-384`,sha512:`SHA-512`};function normalizeAlgorithm(e){return e.toLowerCase().replace(/-/g,``)}function getWebSubtle(){if(globalThis.crypto===void 0||globalThis.crypto.subtle===void 0)throw Error(`WebCrypto SubtleCrypto is unavailable in this environment`);return globalThis.crypto.subtle}function makeSyncUnsupportedError(e){let t=Error(`Synchronous Hmac digest is not supported in browser builds (algorithm: ${e}). Call hmac.digestAsync(encoding) or await crypto.subtle.sign('HMAC', …) instead.`);return t.code=`ENOTSUP_SYNC_DIGEST`,t}var Hmac=class{_algorithm;_webAlgo;_keyBytes;_chunks=[];_totalLen=0;_finalized=!1;constructor(n,r){let i=normalizeAlgorithm(n),a=t[i];if(!a){let e=Error(`Unknown or unsupported message digest: ${n}`);throw e.code=`ERR_CRYPTO_HASH_UNKNOWN`,e}this._algorithm=i,this._webAlgo=a,typeof r==`string`?this._keyBytes=e.from(r,`utf8`):this._keyBytes=r instanceof Uint8Array?r:e.from(r)}update(t,n){if(this._finalized)throw Error(`Digest already called`);let r;return r=typeof t==`string`?e.from(t,n??`utf8`):t instanceof Uint8Array?t:e.from(t),this._chunks.push(r),this._totalLen+=r.byteLength,this}async digestAsync(t){if(this._finalized)throw Error(`Digest already called`);this._finalized=!0;let n=getWebSubtle(),r=await n.importKey(`raw`,this._keyBytes,{name:`HMAC`,hash:this._webAlgo},!1,[`sign`]),i=await n.sign(`HMAC`,r,this._concat()),a=e.from(i);return t?a.toString(t):a}digest(e){throw makeSyncUnsupportedError(this._algorithm)}_concat(){if(this._chunks.length===0)return new Uint8Array;if(this._chunks.length===1)return this._chunks[0];let e=new Uint8Array(this._totalLen),t=0;for(let n of this._chunks)e.set(n,t),t+=n.byteLength;return e}};function createHmac(e,t){return new Hmac(e,t)}export{Hmac,createHmac};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"../_virtual/_rolldown/runtime.js";import{Buffer as e}from"node:buffer";const t={sha1:`SHA-1`,sha256:`SHA-256`,sha384:`SHA-384`,sha512:`SHA-512`};function normalizeAlgorithm(e){return e.toLowerCase().replace(/-/g,``)}function getWebSubtle(){if(globalThis.crypto===void 0||globalThis.crypto.subtle===void 0)throw Error(`WebCrypto SubtleCrypto is unavailable in this environment`);return globalThis.crypto.subtle}function toBytes(t){return typeof t==`string`?e.from(t,`utf8`):t instanceof Uint8Array?t:e.from(t)}function resolveWebAlgo(e){let n=t[normalizeAlgorithm(e)];if(!n)throw Error(`Unsupported PBKDF2/HKDF digest: ${e}`);return n}function pbkdf2(t,n,r,i,a,o){let s,c;typeof a==`function`?(s=`sha1`,c=a):(s=a,c=o);let l=resolveWebAlgo(s),u=toBytes(t),d=toBytes(n),f=getWebSubtle();f.importKey(`raw`,u,{name:`PBKDF2`},!1,[`deriveBits`]).then(e=>f.deriveBits({name:`PBKDF2`,salt:d,iterations:r,hash:l},e,i*8)).then(t=>c(null,e.from(t))).catch(t=>c(t,e.alloc(0)))}function pbkdf2Sync(e,t,n,r,i){let a=Error(`Synchronous pbkdf2Sync is not supported in browser builds. Use pbkdf2() with a callback, or await crypto.subtle.deriveBits({name:"PBKDF2", …}) directly.`);throw a.code=`ENOTSUP_SYNC_KDF`,a}function hkdf(e,t,n,r,i,a){let o=resolveWebAlgo(e),s=getWebSubtle();s.importKey(`raw`,toBytes(t),{name:`HKDF`},!1,[`deriveBits`]).then(e=>s.deriveBits({name:`HKDF`,hash:o,salt:toBytes(n),info:toBytes(r)},e,i*8)).then(e=>a(null,e)).catch(e=>a(e,new ArrayBuffer(0)))}function hkdfSync(e,t,n,r,i){let a=Error(`Synchronous hkdfSync is not supported in browser builds. Use hkdf() with a callback, or await crypto.subtle.deriveBits({name:"HKDF", …}) directly.`);throw a.code=`ENOTSUP_SYNC_KDF`,a}function scrypt(t,n,r,i,a){let o=Error(`scrypt is not supported in browser builds — WebCrypto does not provide a scrypt primitive.`);o.code=`ENOTSUP_NO_WEBCRYPTO_PRIMITIVE`;let s=typeof i==`function`?i:a;if(s){s(o,e.alloc(0));return}throw o}function scryptSync(e,t,n,r){let i=Error(`scryptSync is not supported in browser builds — WebCrypto does not provide a scrypt primitive.`);throw i.code=`ENOTSUP_NO_WEBCRYPTO_PRIMITIVE`,i}export{hkdf,hkdfSync,pbkdf2,pbkdf2Sync,scrypt,scryptSync};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"../_virtual/_rolldown/runtime.js";import{Buffer as e}from"node:buffer";const t=65536;function getWebCrypto(){if(globalThis.crypto===void 0||typeof globalThis.crypto.getRandomValues!=`function`)throw Error(`WebCrypto getRandomValues is unavailable in this environment`);return globalThis.crypto}function fillRandom(e){let n=getWebCrypto();for(let r=0;r<e.length;r+=t){let i=Math.min(e.length-r,t),a=new Uint8Array(e.buffer,e.byteOffset+r,i);n.getRandomValues(a)}}function randomBytes(t,n){if(typeof t!=`number`||t<0||!Number.isInteger(t))throw TypeError(`The "size" argument must be a non-negative integer. Received ${t}`);try{let r=e.alloc(t);if(t>0&&fillRandom(new Uint8Array(r.buffer,r.byteOffset,r.byteLength)),n){n(null,r);return}return r}catch(t){if(n){n(t,e.alloc(0));return}throw t}}function randomFillSync(e,t=0,n){let r=n??e.length-t;if(t<0||t>e.length)throw RangeError(`The value of "offset" is out of range. Received ${t}`);if(r<0||t+r>e.length)throw RangeError(`The value of "size" is out of range. Received ${r}`);return r>0&&fillRandom(new Uint8Array(e.buffer,e.byteOffset+t,r)),e}function randomFill(e,t,n,r){let i,a,o;typeof t==`function`?(o=t,i=0,a=e.length):typeof n==`function`?(o=n,i=t,a=e.length-t):(o=r,i=t,a=n);try{randomFillSync(e,i,a),o(null,e)}catch(t){o(t,e)}}function randomUUID(){let e=getWebCrypto();if(typeof e.randomUUID==`function`)return e.randomUUID();let t=new Uint8Array(16);fillRandom(t),t[6]=t[6]&15|64,t[8]=t[8]&63|128;let n=Array.from(t,e=>e.toString(16).padStart(2,`0`)).join(``);return`${n.slice(0,8)}-${n.slice(8,12)}-${n.slice(12,16)}-${n.slice(16,20)}-${n.slice(20)}`}function randomInt(e,t,n){let r,i,a;if(typeof t==`function`?(a=t,i=e,r=0):typeof t==`number`?(r=e,i=t,a=n):(i=e,r=0,a=n),!Number.isInteger(r))throw TypeError(`The "min" argument must be a safe integer. Received ${r}`);if(!Number.isInteger(i))throw TypeError(`The "max" argument must be a safe integer. Received ${i}`);if(r>=i)throw RangeError(`The value of "min" must be less than "max". Received min: ${r}, max: ${i}`);let o=i-r,s=new Uint32Array(1);fillRandom(new Uint8Array(s.buffer));let c=r+s[0]%o;if(a){a(null,c);return}return c}export{randomBytes,randomFill,randomFillSync,randomInt,randomUUID};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"../_virtual/_rolldown/runtime.js";import{Buffer as e}from"node:buffer";const t={sha1:`SHA-1`,sha256:`SHA-256`,sha384:`SHA-384`,sha512:`SHA-512`};function normalizeHash(e){let n=t[e.toLowerCase().replace(/-/g,``)];if(!n)throw Error(`Unsupported digest in browser builds: ${e}`);return n}function getWebSubtle(){if(globalThis.crypto===void 0||globalThis.crypto.subtle===void 0)throw Error(`WebCrypto SubtleCrypto is unavailable in this environment`);return globalThis.crypto.subtle}function syncUnsupportedError(){let e=Error(`Synchronous Sign.sign() / Verify.verify() is not supported in browser builds. Use signAsync(cryptoKey) / verifyAsync(cryptoKey, signature) with a pre-imported CryptoKey.`);return e.code=`ENOTSUP_SYNC_SIGN`,e}var SignBase=class{_algorithm;_webAlgo;_chunks=[];_finalized=!1;constructor(e){this._algorithm=e.toLowerCase(),this._webAlgo=normalizeHash(e)}update(t,n){if(this._finalized)throw Error(`Sign/Verify already finalised`);let r=typeof t==`string`?e.from(t,n??`utf8`):t instanceof Uint8Array?t:e.from(t);return this._chunks.push(r),this}_allBytes(){if(this._chunks.length===0)return new Uint8Array;if(this._chunks.length===1)return this._chunks[0];let e=this._chunks.reduce((e,t)=>e+t.byteLength,0),t=new Uint8Array(e),n=0;for(let e of this._chunks)t.set(e,n),n+=e.byteLength;return t}},Sign=class extends SignBase{sign(e,t){throw syncUnsupportedError()}async signAsync(t,n){if(this._finalized)throw Error(`Sign already finalised`);this._finalized=!0;let r=getWebSubtle(),i=t.algorithm.name,a;a=i===`ECDSA`?{name:`ECDSA`,hash:this._webAlgo}:i===`RSA-PSS`?{name:`RSA-PSS`,saltLength:32}:i;let o=await r.sign(a,t,this._allBytes()),s=e.from(o);return n?s.toString(n):s}},Verify=class extends SignBase{verify(e,t,n){throw syncUnsupportedError()}async verifyAsync(e,t){if(this._finalized)throw Error(`Verify already finalised`);this._finalized=!0;let n=getWebSubtle(),r=e.algorithm.name,i;return i=r===`ECDSA`?{name:`ECDSA`,hash:this._webAlgo}:r===`RSA-PSS`?{name:`RSA-PSS`,saltLength:32}:r,n.verify(i,e,t,this._allBytes())}};function createSign(e){return new Sign(e)}function createVerify(e){return new Verify(e)}async function sign(t,n,r){let i=getWebSubtle(),a=r.algorithm.name,o;return o=a===`ECDSA`?{name:`ECDSA`,hash:t?normalizeHash(t):`SHA-256`}:a===`RSA-PSS`?{name:`RSA-PSS`,saltLength:32}:a,e.from(await i.sign(o,r,n))}async function verify(e,t,n,r){let i=getWebSubtle(),a=n.algorithm.name,o;return o=a===`ECDSA`?{name:`ECDSA`,hash:e?normalizeHash(e):`SHA-256`}:a===`RSA-PSS`?{name:`RSA-PSS`,saltLength:32}:a,i.verify(o,n,r,t)}export{Sign,Verify,createSign,createVerify,sign,verify};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"../_virtual/_rolldown/runtime.js";function notSupported(e,t){let n=`${e} is not supported in browser builds.${t?` `+t:``}`,r=Error(n);throw r.code=`ENOTSUP`,r}function createDiffieHellman(...e){return notSupported(`createDiffieHellman`,`WebCrypto does not expose classic DH. Use crypto.subtle.deriveBits({name:"ECDH",…}) instead.`)}function getDiffieHellman(e){return notSupported(`getDiffieHellman`)}var DiffieHellman=class{constructor(){notSupported(`DiffieHellman`)}},DiffieHellmanGroup=class{constructor(){notSupported(`DiffieHellmanGroup`)}};function createDiffieHellmanGroup(e){return notSupported(`createDiffieHellmanGroup`)}function createECDH(e){return notSupported(`createECDH`,`Use crypto.subtle.generateKey({name:"ECDH",namedCurve:…}) + subtle.deriveBits instead.`)}function getCurves(){return[`prime256v1`,`secp256r1`,`secp384r1`,`secp521r1`]}function ecdsaSign(){return notSupported(`ecdsaSign`,`Use createSign("sha256").update(…).signAsync(cryptoKey).`)}function ecdsaVerify(){return notSupported(`ecdsaVerify`,`Use createVerify("sha256").update(…).verifyAsync(cryptoKey, signature).`)}function publicEncrypt(e,t){return notSupported(`publicEncrypt`,`Use crypto.subtle.encrypt({name:"RSA-OAEP",…}, cryptoKey, plaintext).`)}function privateDecrypt(e,t){return notSupported(`privateDecrypt`,`Use crypto.subtle.decrypt({name:"RSA-OAEP",…}, cryptoKey, ciphertext).`)}function privateEncrypt(e,t){return notSupported(`privateEncrypt`,`No WebCrypto equivalent — used by legacy JWT libraries only.`)}function publicDecrypt(e,t){return notSupported(`publicDecrypt`,`No WebCrypto equivalent — used by legacy JWT libraries only.`)}function rsaPssSign(){return notSupported(`rsaPssSign`,`Use createSign(digest).signAsync(rsaPssCryptoKey).`)}function rsaPssVerify(){return notSupported(`rsaPssVerify`,`Use createVerify(digest).verifyAsync(rsaPssCryptoKey, signature).`)}function rsaOaepEncrypt(){return notSupported(`rsaOaepEncrypt`,`Use crypto.subtle.encrypt({name:"RSA-OAEP",…}, cryptoKey, plaintext).`)}function rsaOaepDecrypt(){return notSupported(`rsaOaepDecrypt`,`Use crypto.subtle.decrypt({name:"RSA-OAEP",…}, cryptoKey, ciphertext).`)}function mgf1(){return notSupported(`mgf1`,`WebCrypto does not expose MGF1 directly — it is internal to RSA-OAEP/PSS.`)}var KeyObject=class{constructor(){notSupported(`KeyObject`,`Use crypto.subtle.importKey / exportKey to obtain a CryptoKey instead.`)}static from(){return notSupported(`KeyObject.from`)}};function createSecretKey(e){return notSupported(`createSecretKey`,`Use crypto.subtle.importKey("raw", key, …).`)}function createPublicKey(e){return notSupported(`createPublicKey`,`Use crypto.subtle.importKey("spki" | "jwk", …).`)}function createPrivateKey(e){return notSupported(`createPrivateKey`,`Use crypto.subtle.importKey("pkcs8" | "jwk", …).`)}function generateKeyPair(...e){return notSupported(`generateKeyPair`,`Use crypto.subtle.generateKey({name:…, …}, true, [usages]).`)}function generateKeyPairSync(...e){return notSupported(`generateKeyPairSync`,`No sync key-pair gen in WebCrypto. Use crypto.subtle.generateKey (async).`)}function generateKey(...e){return notSupported(`generateKey`,`Use crypto.subtle.generateKey for symmetric keys.`)}var X509Certificate=class{constructor(){notSupported(`X509Certificate`,`WebCrypto does not expose X.509 parsing. Use a third-party library or the platform certificate APIs.`)}};export{DiffieHellman,DiffieHellmanGroup,KeyObject,X509Certificate,createDiffieHellman,createDiffieHellmanGroup,createECDH,createPrivateKey,createPublicKey,createSecretKey,ecdsaSign,ecdsaVerify,generateKey,generateKeyPair,generateKeyPairSync,getCurves,getDiffieHellman,mgf1,privateDecrypt,privateEncrypt,publicDecrypt,publicEncrypt,rsaOaepDecrypt,rsaOaepEncrypt,rsaPssSign,rsaPssVerify};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{constants as e}from"./constants.js";import{randomBytes as t,randomFill as n,randomFillSync as r,randomInt as i,randomUUID as a}from"./browser/random.js";import{Hash as o,createHash as s,getHashes as c,hash as l}from"./browser/hash.js";import{Hmac as u,createHmac as d}from"./browser/hmac.js";import{hkdf as f,hkdfSync as p,pbkdf2 as m,pbkdf2Sync as h,scrypt as g,scryptSync as _}from"./browser/kdf.js";import{Cipher as v,Decipher as y,createCipher as b,createCipheriv as x,createDecipher as S,createDecipheriv as C,getCiphers as w}from"./browser/cipher.js";import{Sign as T,Verify as E,createSign as D,createVerify as O,sign as k,verify as A}from"./browser/sign.js";import{DiffieHellman as j,DiffieHellmanGroup as M,KeyObject as N,X509Certificate as P,createDiffieHellman as F,createDiffieHellmanGroup as I,createECDH as L,createPrivateKey as R,createPublicKey as z,createSecretKey as B,ecdsaSign as V,ecdsaVerify as H,generateKey as U,generateKeyPair as W,generateKeyPairSync as G,getCurves as K,getDiffieHellman as q,mgf1 as J,privateDecrypt as Y,privateEncrypt as X,publicDecrypt as Z,publicEncrypt as Q,rsaOaepDecrypt as $,rsaOaepEncrypt as ee,rsaPssSign as te,rsaPssVerify as ne}from"./browser/stubs.js";import{timingSafeEqual as re}from"./timing-safe-equal.js";const ie=globalThis.crypto,ae=globalThis.crypto.subtle;var oe={webcrypto:ie,subtle:ae,constants:e,randomBytes:t,randomFill:n,randomFillSync:r,randomUUID:a,randomInt:i,Hash:o,createHash:s,getHashes:c,hash:l,Hmac:u,createHmac:d,pbkdf2:m,pbkdf2Sync:h,hkdf:f,hkdfSync:p,scrypt:g,scryptSync:_,Cipher:v,Decipher:y,createCipher:b,createCipheriv:x,createDecipher:S,createDecipheriv:C,getCiphers:w,Sign:T,Verify:E,createSign:D,createVerify:O,sign:k,verify:A,createDiffieHellman:F,getDiffieHellman:q,DiffieHellman:j,DiffieHellmanGroup:M,createDiffieHellmanGroup:I,createECDH:L,getCurves:K,ecdsaSign:V,ecdsaVerify:H,publicEncrypt:Q,privateDecrypt:Y,privateEncrypt:X,publicDecrypt:Z,rsaPssSign:te,rsaPssVerify:ne,rsaOaepEncrypt:ee,rsaOaepDecrypt:$,mgf1:J,KeyObject:N,createSecretKey:B,createPublicKey:z,createPrivateKey:R,generateKeyPair:W,generateKeyPairSync:G,generateKey:U,X509Certificate:P,timingSafeEqual:re};export{v as Cipher,y as Decipher,j as DiffieHellman,M as DiffieHellmanGroup,o as Hash,u as Hmac,N as KeyObject,T as Sign,E as Verify,P as X509Certificate,e as constants,b as createCipher,x as createCipheriv,S as createDecipher,C as createDecipheriv,F as createDiffieHellman,I as createDiffieHellmanGroup,L as createECDH,s as createHash,d as createHmac,R as createPrivateKey,z as createPublicKey,B as createSecretKey,D as createSign,O as createVerify,oe as default,V as ecdsaSign,H as ecdsaVerify,U as generateKey,W as generateKeyPair,G as generateKeyPairSync,w as getCiphers,K as getCurves,q as getDiffieHellman,c as getHashes,l as hash,f as hkdf,p as hkdfSync,J as mgf1,m as pbkdf2,h as pbkdf2Sync,Y as privateDecrypt,X as privateEncrypt,Z as publicDecrypt,Q as publicEncrypt,t as randomBytes,n as randomFill,r as randomFillSync,i as randomInt,a as randomUUID,$ as rsaOaepDecrypt,ee as rsaOaepEncrypt,te as rsaPssSign,ne as rsaPssVerify,g as scrypt,_ as scryptSync,k as sign,ae as subtle,re as timingSafeEqual,A as verify,ie as webcrypto};
|
package/lib/esm/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./_virtual/_rolldown/runtime.js";import{
|
|
1
|
+
import"./_virtual/_rolldown/runtime.js";import{constants as e}from"./constants.js";import{timingSafeEqual as t}from"./timing-safe-equal.js";import{createCipher as n,createCipheriv as r,createDecipher as i,createDecipheriv as a,getCiphers as o}from"./cipher.js";import{randomBytes as s,randomFill as c,randomFillSync as l,randomInt as u,randomUUID as d}from"./random.js";import{DiffieHellman as f,DiffieHellmanGroup as p,createDiffieHellman as m,createDiffieHellmanGroup as h,getDiffieHellman as g}from"./dh.js";import{createECDH as _,getCurves as v}from"./ecdh.js";import{Hash as y,getHashes as b,hash as x}from"./hash.js";import{Hmac as S}from"./hmac.js";import{ecdsaSign as C,ecdsaVerify as w}from"./ecdsa.js";import{hkdf as T,hkdfSync as E}from"./hkdf.js";import{pbkdf2 as D,pbkdf2Sync as O}from"./pbkdf2.js";import{scrypt as k,scryptSync as A}from"./scrypt.js";import{Sign as j,Verify as M,createSign as N,createVerify as P}from"./sign.js";import{privateDecrypt as F,privateEncrypt as I,publicDecrypt as L,publicEncrypt as R}from"./public-encrypt.js";import{mgf1 as z}from"./mgf1.js";import{rsaPssSign as B,rsaPssVerify as V}from"./rsa-pss.js";import{rsaOaepDecrypt as H,rsaOaepEncrypt as U}from"./rsa-oaep.js";import{KeyObject as W,createPrivateKey as G,createPublicKey as K,createSecretKey as q}from"./key-object.js";import{X509Certificate as J}from"./x509.js";function createHash(e){return new y(e)}function createHmac(e,t){return new S(e,t)}var Y={Hash:y,getHashes:b,hash:x,Hmac:S,randomBytes:s,randomFill:c,randomFillSync:l,randomUUID:d,randomInt:u,timingSafeEqual:t,constants:e,pbkdf2:D,pbkdf2Sync:O,hkdf:T,hkdfSync:E,scrypt:k,scryptSync:A,createHash,createHmac,createCipher:n,createCipheriv:r,createDecipher:i,createDecipheriv:a,getCiphers:o,Sign:j,Verify:M,createSign:N,createVerify:P,createDiffieHellman:m,getDiffieHellman:g,DiffieHellman:f,DiffieHellmanGroup:p,createDiffieHellmanGroup:h,createECDH:_,getCurves:v,ecdsaSign:C,ecdsaVerify:w,publicEncrypt:R,privateDecrypt:F,privateEncrypt:I,publicDecrypt:L,rsaPssSign:B,rsaPssVerify:V,rsaOaepEncrypt:U,rsaOaepDecrypt:H,mgf1:z,KeyObject:W,createSecretKey:q,createPublicKey:K,createPrivateKey:G,X509Certificate:J};export{f as DiffieHellman,p as DiffieHellmanGroup,y as Hash,S as Hmac,W as KeyObject,j as Sign,M as Verify,J as X509Certificate,e as constants,n as createCipher,r as createCipheriv,i as createDecipher,a as createDecipheriv,m as createDiffieHellman,h as createDiffieHellmanGroup,_ as createECDH,createHash,createHmac,G as createPrivateKey,K as createPublicKey,q as createSecretKey,N as createSign,P as createVerify,Y as default,C as ecdsaSign,w as ecdsaVerify,o as getCiphers,v as getCurves,g as getDiffieHellman,b as getHashes,x as hash,T as hkdf,E as hkdfSync,z as mgf1,D as pbkdf2,O as pbkdf2Sync,F as privateDecrypt,I as privateEncrypt,L as publicDecrypt,R as publicEncrypt,s as randomBytes,c as randomFill,l as randomFillSync,u as randomInt,d as randomUUID,H as rsaOaepDecrypt,U as rsaOaepEncrypt,B as rsaPssSign,V as rsaPssVerify,k as scrypt,A as scryptSync,t as timingSafeEqual};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Buffer } from 'node:buffer';
|
|
2
|
+
type AesMode = 'aes-cbc' | 'aes-ctr' | 'aes-gcm';
|
|
3
|
+
interface ParsedCipherName {
|
|
4
|
+
/** WebCrypto AlgorithmIdentifier mode prefix, e.g. "AES-CBC". */
|
|
5
|
+
webMode: 'AES-CBC' | 'AES-CTR' | 'AES-GCM';
|
|
6
|
+
/** Key bit-length: 128/192/256. */
|
|
7
|
+
keyBits: 128 | 192 | 256;
|
|
8
|
+
/** Short mode tag used internally. */
|
|
9
|
+
aesMode: AesMode;
|
|
10
|
+
}
|
|
11
|
+
declare abstract class CipherBase {
|
|
12
|
+
protected _parsed: ParsedCipherName;
|
|
13
|
+
protected _key: Uint8Array;
|
|
14
|
+
protected _iv: Uint8Array;
|
|
15
|
+
protected _chunks: Uint8Array[];
|
|
16
|
+
protected _aad: Uint8Array | null;
|
|
17
|
+
protected _authTag: Uint8Array | null;
|
|
18
|
+
protected _finalized: boolean;
|
|
19
|
+
constructor(name: string, key: Uint8Array, iv: Uint8Array);
|
|
20
|
+
update(data: string | Buffer | Uint8Array, inputEncoding?: BufferEncoding): Buffer;
|
|
21
|
+
setAAD(buffer: Buffer | Uint8Array): this;
|
|
22
|
+
/** Sync final — throws ENOTSUP_SYNC_CIPHER. */
|
|
23
|
+
final(_outputEncoding?: BufferEncoding): Buffer | string;
|
|
24
|
+
protected _allBytes(): Uint8Array;
|
|
25
|
+
protected _algorithmParams(): AesCbcParams | AesCtrParams | AesGcmParams;
|
|
26
|
+
}
|
|
27
|
+
export declare class Cipher extends CipherBase {
|
|
28
|
+
/** Async final — preferred entry. Returns ciphertext (incl. GCM tag appended). */
|
|
29
|
+
finalAsync(outputEncoding?: BufferEncoding): Promise<Buffer | string>;
|
|
30
|
+
/** GCM auth tag — only valid after `finalAsync()`. */
|
|
31
|
+
getAuthTag(): Buffer;
|
|
32
|
+
}
|
|
33
|
+
export declare class Decipher extends CipherBase {
|
|
34
|
+
setAuthTag(buffer: Buffer | Uint8Array): this;
|
|
35
|
+
/** Async final — preferred entry. Returns plaintext. */
|
|
36
|
+
finalAsync(outputEncoding?: BufferEncoding): Promise<Buffer | string>;
|
|
37
|
+
}
|
|
38
|
+
export declare function createCipheriv(algorithm: string, key: Buffer | Uint8Array | string, iv: Buffer | Uint8Array | string): Cipher;
|
|
39
|
+
export declare function createDecipheriv(algorithm: string, key: Buffer | Uint8Array | string, iv: Buffer | Uint8Array | string): Decipher;
|
|
40
|
+
/**
|
|
41
|
+
* Legacy `createCipher(algorithm, password)` — deprecated in Node and unsafe;
|
|
42
|
+
* not supported in browser builds because it requires a sync PBKDF1
|
|
43
|
+
* key-derivation that WebCrypto cannot reproduce.
|
|
44
|
+
*/
|
|
45
|
+
export declare function createCipher(_algorithm: string, _password: string | Buffer | Uint8Array): never;
|
|
46
|
+
export declare function createDecipher(_algorithm: string, _password: string | Buffer | Uint8Array): never;
|
|
47
|
+
export declare function getCiphers(): string[];
|
|
48
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Buffer } from 'node:buffer';
|
|
2
|
+
/** Hash class backed by WebCrypto `subtle.digest`. */
|
|
3
|
+
export declare class Hash {
|
|
4
|
+
private _algorithm;
|
|
5
|
+
private _webAlgo;
|
|
6
|
+
private _chunks;
|
|
7
|
+
private _totalLen;
|
|
8
|
+
private _finalized;
|
|
9
|
+
constructor(algorithm: string);
|
|
10
|
+
update(data: string | Buffer | Uint8Array, inputEncoding?: BufferEncoding): this;
|
|
11
|
+
/** Async digest — preferred entry in browser builds. */
|
|
12
|
+
digestAsync(encoding?: BufferEncoding): Promise<Buffer | string>;
|
|
13
|
+
/** Sync digest — throws ENOTSUP_SYNC_DIGEST in browser builds. */
|
|
14
|
+
digest(_encoding?: BufferEncoding): Buffer | string;
|
|
15
|
+
/** Snapshot copy — `_chunks` are reused (Uint8Array views are read-only here). */
|
|
16
|
+
copy(): Hash;
|
|
17
|
+
private _concat;
|
|
18
|
+
}
|
|
19
|
+
export declare function createHash(algorithm: string): Hash;
|
|
20
|
+
export declare function getHashes(): string[];
|
|
21
|
+
/** Convenience: one-shot hash (Node 21+). Async — use await. */
|
|
22
|
+
export declare function hash(algorithm: string, data: string | Buffer | Uint8Array, encoding?: BufferEncoding): Promise<Buffer | string>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Buffer } from 'node:buffer';
|
|
2
|
+
/** Hmac class backed by WebCrypto `subtle.importKey` + `subtle.sign('HMAC')`. */
|
|
3
|
+
export declare class Hmac {
|
|
4
|
+
private _algorithm;
|
|
5
|
+
private _webAlgo;
|
|
6
|
+
private _keyBytes;
|
|
7
|
+
private _chunks;
|
|
8
|
+
private _totalLen;
|
|
9
|
+
private _finalized;
|
|
10
|
+
constructor(algorithm: string, key: string | Buffer | Uint8Array);
|
|
11
|
+
update(data: string | Buffer | Uint8Array, inputEncoding?: BufferEncoding): this;
|
|
12
|
+
digestAsync(encoding?: BufferEncoding): Promise<Buffer | string>;
|
|
13
|
+
digest(_encoding?: BufferEncoding): Buffer | string;
|
|
14
|
+
private _concat;
|
|
15
|
+
}
|
|
16
|
+
export declare function createHmac(algorithm: string, key: string | Buffer | Uint8Array): Hmac;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Buffer } from 'node:buffer';
|
|
2
|
+
type Pbkdf2Callback = (err: Error | null, derivedKey: Buffer) => void;
|
|
3
|
+
/** PBKDF2 — async via `subtle.deriveBits`. */
|
|
4
|
+
export declare function pbkdf2(password: string | Buffer | Uint8Array, salt: string | Buffer | Uint8Array, iterations: number, keylen: number, digest: string, callback?: Pbkdf2Callback): void;
|
|
5
|
+
/** Synchronous PBKDF2 — throws ENOTSUP_SYNC_KDF in browser builds. */
|
|
6
|
+
export declare function pbkdf2Sync(_password: string | Buffer | Uint8Array, _salt: string | Buffer | Uint8Array, _iterations: number, _keylen: number, _digest?: string): Buffer;
|
|
7
|
+
type HkdfCallback = (err: Error | null, derivedKey: ArrayBuffer) => void;
|
|
8
|
+
/** HKDF — async via `subtle.deriveBits`. */
|
|
9
|
+
export declare function hkdf(digest: string, ikm: string | Buffer | Uint8Array, salt: string | Buffer | Uint8Array, info: string | Buffer | Uint8Array, keylen: number, callback: HkdfCallback): void;
|
|
10
|
+
/** Synchronous HKDF — throws ENOTSUP_SYNC_KDF in browser builds. */
|
|
11
|
+
export declare function hkdfSync(_digest: string, _ikm: string | Buffer | Uint8Array, _salt: string | Buffer | Uint8Array, _info: string | Buffer | Uint8Array, _keylen: number): ArrayBuffer;
|
|
12
|
+
/** Scrypt is not in WebCrypto. */
|
|
13
|
+
export declare function scrypt(_password: string | Buffer | Uint8Array, _salt: string | Buffer | Uint8Array, _keylen: number, _optionsOrCallback: unknown, callback?: (err: Error | null, derivedKey: Buffer) => void): void;
|
|
14
|
+
export declare function scryptSync(_password: string | Buffer | Uint8Array, _salt: string | Buffer | Uint8Array, _keylen: number, _options?: unknown): Buffer;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Buffer } from 'node:buffer';
|
|
2
|
+
/** Generate cryptographically strong pseudo-random data. */
|
|
3
|
+
export declare function randomBytes(size: number): Buffer;
|
|
4
|
+
export declare function randomBytes(size: number, callback: (err: Error | null, buf: Buffer) => void): void;
|
|
5
|
+
/** Fill a buffer with cryptographically strong pseudo-random data (synchronous). */
|
|
6
|
+
export declare function randomFillSync(buffer: Buffer | Uint8Array, offset?: number, size?: number): Buffer | Uint8Array;
|
|
7
|
+
/** Fill a buffer with cryptographically strong pseudo-random data (async). */
|
|
8
|
+
export declare function randomFill(buffer: Buffer | Uint8Array, offset: number | ((err: Error | null, buf: Buffer | Uint8Array) => void), size?: number | ((err: Error | null, buf: Buffer | Uint8Array) => void), callback?: (err: Error | null, buf: Buffer | Uint8Array) => void): void;
|
|
9
|
+
/** Generate a random UUID v4 string — uses native `crypto.randomUUID` when present. */
|
|
10
|
+
export declare function randomUUID(): string;
|
|
11
|
+
/** Generate a random integer between min (inclusive) and max (exclusive). */
|
|
12
|
+
export declare function randomInt(min: number, max?: number | ((err: Error | null, value: number) => void), callback?: (err: Error | null, value: number) => void): number | void;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Buffer } from 'node:buffer';
|
|
2
|
+
declare abstract class SignBase {
|
|
3
|
+
protected _algorithm: string;
|
|
4
|
+
protected _webAlgo: string;
|
|
5
|
+
protected _chunks: Uint8Array[];
|
|
6
|
+
protected _finalized: boolean;
|
|
7
|
+
constructor(algorithm: string);
|
|
8
|
+
update(data: string | Buffer | Uint8Array, inputEncoding?: BufferEncoding): this;
|
|
9
|
+
protected _allBytes(): Uint8Array;
|
|
10
|
+
}
|
|
11
|
+
export declare class Sign extends SignBase {
|
|
12
|
+
/** Sync sign — throws ENOTSUP_SYNC_SIGN. */
|
|
13
|
+
sign(_privateKey: unknown, _outputFormat?: BufferEncoding): Buffer | string;
|
|
14
|
+
/**
|
|
15
|
+
* Async sign — accepts a pre-imported `CryptoKey` (use `subtle.importKey`).
|
|
16
|
+
* Algorithm depends on the digest used in `createSign(digest)`:
|
|
17
|
+
* - RSASSA-PKCS1-v1_5 if the key was imported as such
|
|
18
|
+
* - ECDSA if the key is EC
|
|
19
|
+
* - RSA-PSS if the key was imported with PSS metadata
|
|
20
|
+
* Caller is responsible for matching the key algorithm; this wrapper
|
|
21
|
+
* defaults to the `key.algorithm.name` reported by the CryptoKey.
|
|
22
|
+
*/
|
|
23
|
+
signAsync(privateKey: CryptoKey, outputEncoding?: BufferEncoding): Promise<Buffer | string>;
|
|
24
|
+
}
|
|
25
|
+
export declare class Verify extends SignBase {
|
|
26
|
+
/** Sync verify — throws ENOTSUP_SYNC_SIGN. */
|
|
27
|
+
verify(_publicKey: unknown, _signature: string | Buffer | Uint8Array, _signatureFormat?: BufferEncoding): boolean;
|
|
28
|
+
verifyAsync(publicKey: CryptoKey, signature: Buffer | Uint8Array): Promise<boolean>;
|
|
29
|
+
}
|
|
30
|
+
export declare function createSign(algorithm: string): Sign;
|
|
31
|
+
export declare function createVerify(algorithm: string): Verify;
|
|
32
|
+
/** One-shot sign — Node 15+ API. Async only in browser builds. */
|
|
33
|
+
export declare function sign(algorithm: string | null | undefined, data: Buffer | Uint8Array, key: CryptoKey): Promise<Buffer>;
|
|
34
|
+
export declare function verify(algorithm: string | null | undefined, data: Buffer | Uint8Array, key: CryptoKey, signature: Buffer | Uint8Array): Promise<boolean>;
|
|
35
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Buffer } from 'node:buffer';
|
|
2
|
+
export declare function createDiffieHellman(..._args: unknown[]): never;
|
|
3
|
+
export declare function getDiffieHellman(_groupName: string): never;
|
|
4
|
+
export declare class DiffieHellman {
|
|
5
|
+
constructor();
|
|
6
|
+
}
|
|
7
|
+
export declare class DiffieHellmanGroup {
|
|
8
|
+
constructor();
|
|
9
|
+
}
|
|
10
|
+
export declare function createDiffieHellmanGroup(_groupName: string): never;
|
|
11
|
+
export declare function createECDH(_curveName: string): never;
|
|
12
|
+
export declare function getCurves(): string[];
|
|
13
|
+
export declare function ecdsaSign(): never;
|
|
14
|
+
export declare function ecdsaVerify(): never;
|
|
15
|
+
export declare function publicEncrypt(_keyLike: unknown, _data: Buffer | Uint8Array): never;
|
|
16
|
+
export declare function privateDecrypt(_keyLike: unknown, _data: Buffer | Uint8Array): never;
|
|
17
|
+
export declare function privateEncrypt(_keyLike: unknown, _data: Buffer | Uint8Array): never;
|
|
18
|
+
export declare function publicDecrypt(_keyLike: unknown, _data: Buffer | Uint8Array): never;
|
|
19
|
+
export declare function rsaPssSign(): never;
|
|
20
|
+
export declare function rsaPssVerify(): never;
|
|
21
|
+
export declare function rsaOaepEncrypt(): never;
|
|
22
|
+
export declare function rsaOaepDecrypt(): never;
|
|
23
|
+
export declare function mgf1(): never;
|
|
24
|
+
export declare class KeyObject {
|
|
25
|
+
constructor();
|
|
26
|
+
static from(): never;
|
|
27
|
+
}
|
|
28
|
+
export declare function createSecretKey(_key: Buffer | Uint8Array): never;
|
|
29
|
+
export declare function createPublicKey(_keyLike: unknown): never;
|
|
30
|
+
export declare function createPrivateKey(_keyLike: unknown): never;
|
|
31
|
+
export declare function generateKeyPair(..._args: unknown[]): never;
|
|
32
|
+
export declare function generateKeyPairSync(..._args: unknown[]): never;
|
|
33
|
+
export declare function generateKey(..._args: unknown[]): never;
|
|
34
|
+
export declare class X509Certificate {
|
|
35
|
+
constructor();
|
|
36
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { Buffer } from 'node:buffer';
|
|
2
|
+
export declare const webcrypto: Crypto;
|
|
3
|
+
export declare const subtle: SubtleCrypto;
|
|
4
|
+
export { constants } from './constants.js';
|
|
5
|
+
export { randomBytes, randomFill, randomFillSync, randomUUID, randomInt } from './browser/random.js';
|
|
6
|
+
export { Hash, createHash, getHashes, hash } from './browser/hash.js';
|
|
7
|
+
export { Hmac, createHmac } from './browser/hmac.js';
|
|
8
|
+
export { pbkdf2, pbkdf2Sync, hkdf, hkdfSync, scrypt, scryptSync } from './browser/kdf.js';
|
|
9
|
+
export { Cipher, Decipher, createCipher, createCipheriv, createDecipher, createDecipheriv, getCiphers, } from './browser/cipher.js';
|
|
10
|
+
export { Sign, Verify, createSign, createVerify, sign, verify } from './browser/sign.js';
|
|
11
|
+
export { createDiffieHellman, getDiffieHellman, DiffieHellman, DiffieHellmanGroup, createDiffieHellmanGroup, createECDH, getCurves, ecdsaSign, ecdsaVerify, publicEncrypt, privateDecrypt, privateEncrypt, publicDecrypt, rsaPssSign, rsaPssVerify, rsaOaepEncrypt, rsaOaepDecrypt, mgf1, KeyObject, createSecretKey, createPublicKey, createPrivateKey, generateKeyPair, generateKeyPairSync, generateKey, X509Certificate, } from './browser/stubs.js';
|
|
12
|
+
export { timingSafeEqual } from './timing-safe-equal.js';
|
|
13
|
+
import { randomBytes, randomFill, randomFillSync, randomUUID, randomInt } from './browser/random.js';
|
|
14
|
+
import { Hash, createHash, getHashes, hash } from './browser/hash.js';
|
|
15
|
+
import { Hmac, createHmac } from './browser/hmac.js';
|
|
16
|
+
import { pbkdf2, pbkdf2Sync, hkdf, hkdfSync, scrypt, scryptSync } from './browser/kdf.js';
|
|
17
|
+
import { Cipher, Decipher, createCipher, createCipheriv, createDecipher, createDecipheriv, getCiphers } from './browser/cipher.js';
|
|
18
|
+
import { Sign, Verify, createSign, createVerify, sign, verify } from './browser/sign.js';
|
|
19
|
+
import { createDiffieHellman, getDiffieHellman, DiffieHellman, DiffieHellmanGroup, createDiffieHellmanGroup, createECDH, getCurves, ecdsaSign, ecdsaVerify, publicEncrypt, privateDecrypt, privateEncrypt, publicDecrypt, rsaPssSign, rsaPssVerify, rsaOaepEncrypt, rsaOaepDecrypt, mgf1, KeyObject, createSecretKey, createPublicKey, createPrivateKey, generateKeyPair, generateKeyPairSync, generateKey, X509Certificate } from './browser/stubs.js';
|
|
20
|
+
import { timingSafeEqual } from './timing-safe-equal.js';
|
|
21
|
+
export type { Buffer };
|
|
22
|
+
declare const _default: {
|
|
23
|
+
webcrypto: Crypto;
|
|
24
|
+
subtle: SubtleCrypto;
|
|
25
|
+
constants: {
|
|
26
|
+
readonly RSA_PKCS1_PADDING: 1;
|
|
27
|
+
readonly RSA_NO_PADDING: 3;
|
|
28
|
+
readonly RSA_PKCS1_OAEP_PADDING: 4;
|
|
29
|
+
readonly RSA_PKCS1_PSS_PADDING: 6;
|
|
30
|
+
readonly DH_CHECK_P_NOT_SAFE_PRIME: 2;
|
|
31
|
+
readonly DH_CHECK_P_NOT_PRIME: 1;
|
|
32
|
+
readonly DH_UNABLE_TO_CHECK_GENERATOR: 4;
|
|
33
|
+
readonly DH_NOT_SUITABLE_GENERATOR: 8;
|
|
34
|
+
};
|
|
35
|
+
randomBytes: typeof randomBytes;
|
|
36
|
+
randomFill: typeof randomFill;
|
|
37
|
+
randomFillSync: typeof randomFillSync;
|
|
38
|
+
randomUUID: typeof randomUUID;
|
|
39
|
+
randomInt: typeof randomInt;
|
|
40
|
+
Hash: typeof Hash;
|
|
41
|
+
createHash: typeof createHash;
|
|
42
|
+
getHashes: typeof getHashes;
|
|
43
|
+
hash: typeof hash;
|
|
44
|
+
Hmac: typeof Hmac;
|
|
45
|
+
createHmac: typeof createHmac;
|
|
46
|
+
pbkdf2: typeof pbkdf2;
|
|
47
|
+
pbkdf2Sync: typeof pbkdf2Sync;
|
|
48
|
+
hkdf: typeof hkdf;
|
|
49
|
+
hkdfSync: typeof hkdfSync;
|
|
50
|
+
scrypt: typeof scrypt;
|
|
51
|
+
scryptSync: typeof scryptSync;
|
|
52
|
+
Cipher: typeof Cipher;
|
|
53
|
+
Decipher: typeof Decipher;
|
|
54
|
+
createCipher: typeof createCipher;
|
|
55
|
+
createCipheriv: typeof createCipheriv;
|
|
56
|
+
createDecipher: typeof createDecipher;
|
|
57
|
+
createDecipheriv: typeof createDecipheriv;
|
|
58
|
+
getCiphers: typeof getCiphers;
|
|
59
|
+
Sign: typeof Sign;
|
|
60
|
+
Verify: typeof Verify;
|
|
61
|
+
createSign: typeof createSign;
|
|
62
|
+
createVerify: typeof createVerify;
|
|
63
|
+
sign: typeof sign;
|
|
64
|
+
verify: typeof verify;
|
|
65
|
+
createDiffieHellman: typeof createDiffieHellman;
|
|
66
|
+
getDiffieHellman: typeof getDiffieHellman;
|
|
67
|
+
DiffieHellman: typeof DiffieHellman;
|
|
68
|
+
DiffieHellmanGroup: typeof DiffieHellmanGroup;
|
|
69
|
+
createDiffieHellmanGroup: typeof createDiffieHellmanGroup;
|
|
70
|
+
createECDH: typeof createECDH;
|
|
71
|
+
getCurves: typeof getCurves;
|
|
72
|
+
ecdsaSign: typeof ecdsaSign;
|
|
73
|
+
ecdsaVerify: typeof ecdsaVerify;
|
|
74
|
+
publicEncrypt: typeof publicEncrypt;
|
|
75
|
+
privateDecrypt: typeof privateDecrypt;
|
|
76
|
+
privateEncrypt: typeof privateEncrypt;
|
|
77
|
+
publicDecrypt: typeof publicDecrypt;
|
|
78
|
+
rsaPssSign: typeof rsaPssSign;
|
|
79
|
+
rsaPssVerify: typeof rsaPssVerify;
|
|
80
|
+
rsaOaepEncrypt: typeof rsaOaepEncrypt;
|
|
81
|
+
rsaOaepDecrypt: typeof rsaOaepDecrypt;
|
|
82
|
+
mgf1: typeof mgf1;
|
|
83
|
+
KeyObject: typeof KeyObject;
|
|
84
|
+
createSecretKey: typeof createSecretKey;
|
|
85
|
+
createPublicKey: typeof createPublicKey;
|
|
86
|
+
createPrivateKey: typeof createPrivateKey;
|
|
87
|
+
generateKeyPair: typeof generateKeyPair;
|
|
88
|
+
generateKeyPairSync: typeof generateKeyPairSync;
|
|
89
|
+
generateKey: typeof generateKey;
|
|
90
|
+
X509Certificate: typeof X509Certificate;
|
|
91
|
+
timingSafeEqual: typeof timingSafeEqual;
|
|
92
|
+
};
|
|
93
|
+
export default _default;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gjsify/crypto",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.36",
|
|
4
4
|
"description": "Node.js crypto module for Gjs",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "lib/esm/index.js",
|
|
@@ -9,6 +9,38 @@
|
|
|
9
9
|
".": {
|
|
10
10
|
"types": "./lib/types/index.d.ts",
|
|
11
11
|
"default": "./lib/esm/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./browser": {
|
|
14
|
+
"types": "./lib/types/browser.d.ts",
|
|
15
|
+
"default": "./lib/esm/browser.js"
|
|
16
|
+
},
|
|
17
|
+
"./browser/hash": {
|
|
18
|
+
"types": "./lib/types/browser/hash.d.ts",
|
|
19
|
+
"default": "./lib/esm/browser/hash.js"
|
|
20
|
+
},
|
|
21
|
+
"./browser/hmac": {
|
|
22
|
+
"types": "./lib/types/browser/hmac.d.ts",
|
|
23
|
+
"default": "./lib/esm/browser/hmac.js"
|
|
24
|
+
},
|
|
25
|
+
"./browser/random": {
|
|
26
|
+
"types": "./lib/types/browser/random.d.ts",
|
|
27
|
+
"default": "./lib/esm/browser/random.js"
|
|
28
|
+
},
|
|
29
|
+
"./browser/kdf": {
|
|
30
|
+
"types": "./lib/types/browser/kdf.d.ts",
|
|
31
|
+
"default": "./lib/esm/browser/kdf.js"
|
|
32
|
+
},
|
|
33
|
+
"./browser/cipher": {
|
|
34
|
+
"types": "./lib/types/browser/cipher.d.ts",
|
|
35
|
+
"default": "./lib/esm/browser/cipher.js"
|
|
36
|
+
},
|
|
37
|
+
"./browser/sign": {
|
|
38
|
+
"types": "./lib/types/browser/sign.d.ts",
|
|
39
|
+
"default": "./lib/esm/browser/sign.js"
|
|
40
|
+
},
|
|
41
|
+
"./browser/stubs": {
|
|
42
|
+
"types": "./lib/types/browser/stubs.d.ts",
|
|
43
|
+
"default": "./lib/esm/browser/stubs.js"
|
|
12
44
|
}
|
|
13
45
|
},
|
|
14
46
|
"files": [
|
|
@@ -33,23 +65,33 @@
|
|
|
33
65
|
"crypto"
|
|
34
66
|
],
|
|
35
67
|
"devDependencies": {
|
|
36
|
-
"@gjsify/cli": "^0.4.
|
|
37
|
-
"@gjsify/unit": "^0.4.
|
|
68
|
+
"@gjsify/cli": "^0.4.36",
|
|
69
|
+
"@gjsify/unit": "^0.4.36",
|
|
38
70
|
"@types/diffie-hellman": "^5.0.3",
|
|
39
71
|
"@types/node": "^25.9.1",
|
|
40
|
-
"typescript": "^
|
|
72
|
+
"typescript": "^5.9.3"
|
|
41
73
|
},
|
|
42
74
|
"dependencies": {
|
|
43
|
-
"@girs/glib-2.0": "2.88.0-4.0.
|
|
44
|
-
"@gjsify/buffer": "^0.4.
|
|
45
|
-
"@gjsify/stream": "^0.4.
|
|
46
|
-
"@gjsify/utils": "^0.4.
|
|
75
|
+
"@girs/glib-2.0": "2.88.0-4.0.4",
|
|
76
|
+
"@gjsify/buffer": "^0.4.36",
|
|
77
|
+
"@gjsify/stream": "^0.4.36",
|
|
78
|
+
"@gjsify/utils": "^0.4.36"
|
|
47
79
|
},
|
|
48
80
|
"gjsify": {
|
|
49
81
|
"runtimes": {
|
|
50
82
|
"gjs": "polyfill",
|
|
51
83
|
"node": "none",
|
|
52
|
-
"browser": "
|
|
84
|
+
"browser": "partial"
|
|
53
85
|
}
|
|
54
|
-
}
|
|
86
|
+
},
|
|
87
|
+
"license": "MIT",
|
|
88
|
+
"repository": {
|
|
89
|
+
"type": "git",
|
|
90
|
+
"url": "git+https://github.com/gjsify/gjsify.git",
|
|
91
|
+
"directory": "packages/node/crypto"
|
|
92
|
+
},
|
|
93
|
+
"bugs": {
|
|
94
|
+
"url": "https://github.com/gjsify/gjsify/issues"
|
|
95
|
+
},
|
|
96
|
+
"homepage": "https://github.com/gjsify/gjsify/tree/main/packages/node/crypto#readme"
|
|
55
97
|
}
|