@openclaw/nostr 2026.5.20-beta.2 → 2026.5.22
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/node_modules/@noble/ciphers/LICENSE +22 -0
- package/node_modules/@noble/ciphers/README.md +608 -0
- package/node_modules/@noble/ciphers/_arx.d.ts +81 -0
- package/node_modules/@noble/ciphers/_arx.d.ts.map +1 -0
- package/node_modules/@noble/ciphers/_arx.js +258 -0
- package/node_modules/@noble/ciphers/_arx.js.map +1 -0
- package/node_modules/@noble/ciphers/_poly1305.d.ts +48 -0
- package/node_modules/@noble/ciphers/_poly1305.d.ts.map +1 -0
- package/node_modules/@noble/ciphers/_poly1305.js +319 -0
- package/node_modules/@noble/ciphers/_poly1305.js.map +1 -0
- package/node_modules/@noble/ciphers/_polyval.d.ts +62 -0
- package/node_modules/@noble/ciphers/_polyval.d.ts.map +1 -0
- package/node_modules/@noble/ciphers/_polyval.js +231 -0
- package/node_modules/@noble/ciphers/_polyval.js.map +1 -0
- package/node_modules/@noble/ciphers/aes.d.ts +231 -0
- package/node_modules/@noble/ciphers/aes.d.ts.map +1 -0
- package/node_modules/@noble/ciphers/aes.js +1281 -0
- package/node_modules/@noble/ciphers/aes.js.map +1 -0
- package/node_modules/@noble/ciphers/chacha.d.ts +75 -0
- package/node_modules/@noble/ciphers/chacha.d.ts.map +1 -0
- package/node_modules/@noble/ciphers/chacha.js +385 -0
- package/node_modules/@noble/ciphers/chacha.js.map +1 -0
- package/node_modules/@noble/ciphers/ff1.d.ts +9 -0
- package/node_modules/@noble/ciphers/ff1.d.ts.map +1 -0
- package/node_modules/@noble/ciphers/ff1.js +160 -0
- package/node_modules/@noble/ciphers/ff1.js.map +1 -0
- package/node_modules/@noble/ciphers/index.d.ts +2 -0
- package/node_modules/@noble/ciphers/index.d.ts.map +1 -0
- package/node_modules/@noble/ciphers/index.js +27 -0
- package/node_modules/@noble/ciphers/index.js.map +1 -0
- package/node_modules/@noble/ciphers/package.json +81 -0
- package/node_modules/@noble/ciphers/salsa.d.ts +30 -0
- package/node_modules/@noble/ciphers/salsa.d.ts.map +1 -0
- package/node_modules/@noble/ciphers/salsa.js +260 -0
- package/node_modules/@noble/ciphers/salsa.js.map +1 -0
- package/node_modules/@noble/ciphers/src/_arx.ts +338 -0
- package/node_modules/@noble/ciphers/src/_poly1305.ts +360 -0
- package/node_modules/@noble/ciphers/src/_polyval.ts +272 -0
- package/node_modules/@noble/ciphers/src/aes.ts +1439 -0
- package/node_modules/@noble/ciphers/src/chacha.ts +367 -0
- package/node_modules/@noble/ciphers/src/ff1.ts +162 -0
- package/node_modules/@noble/ciphers/src/index.ts +25 -0
- package/node_modules/@noble/ciphers/src/salsa.ts +255 -0
- package/node_modules/@noble/ciphers/src/utils.ts +497 -0
- package/node_modules/@noble/ciphers/src/webcrypto.ts +125 -0
- package/node_modules/@noble/ciphers/utils.d.ts +171 -0
- package/node_modules/@noble/ciphers/utils.d.ts.map +1 -0
- package/node_modules/@noble/ciphers/utils.js +343 -0
- package/node_modules/@noble/ciphers/utils.js.map +1 -0
- package/node_modules/@noble/ciphers/webcrypto.d.ts +30 -0
- package/node_modules/@noble/ciphers/webcrypto.d.ts.map +1 -0
- package/node_modules/@noble/ciphers/webcrypto.js +99 -0
- package/node_modules/@noble/ciphers/webcrypto.js.map +1 -0
- package/node_modules/@noble/curves/LICENSE +21 -0
- package/node_modules/@noble/curves/README.md +1037 -0
- package/node_modules/@noble/curves/abstract/bls.d.ts +128 -0
- package/node_modules/@noble/curves/abstract/bls.d.ts.map +1 -0
- package/node_modules/@noble/curves/abstract/bls.js +372 -0
- package/node_modules/@noble/curves/abstract/bls.js.map +1 -0
- package/node_modules/@noble/curves/abstract/curve.d.ts +195 -0
- package/node_modules/@noble/curves/abstract/curve.d.ts.map +1 -0
- package/node_modules/@noble/curves/abstract/curve.js +457 -0
- package/node_modules/@noble/curves/abstract/curve.js.map +1 -0
- package/node_modules/@noble/curves/abstract/edwards.d.ts +184 -0
- package/node_modules/@noble/curves/abstract/edwards.d.ts.map +1 -0
- package/node_modules/@noble/curves/abstract/edwards.js +558 -0
- package/node_modules/@noble/curves/abstract/edwards.js.map +1 -0
- package/node_modules/@noble/curves/abstract/fft.d.ts +127 -0
- package/node_modules/@noble/curves/abstract/fft.d.ts.map +1 -0
- package/node_modules/@noble/curves/abstract/fft.js +426 -0
- package/node_modules/@noble/curves/abstract/fft.js.map +1 -0
- package/node_modules/@noble/curves/abstract/hash-to-curve.d.ts +90 -0
- package/node_modules/@noble/curves/abstract/hash-to-curve.d.ts.map +1 -0
- package/node_modules/@noble/curves/abstract/hash-to-curve.js +207 -0
- package/node_modules/@noble/curves/abstract/hash-to-curve.js.map +1 -0
- package/node_modules/@noble/curves/abstract/modular.d.ts +159 -0
- package/node_modules/@noble/curves/abstract/modular.d.ts.map +1 -0
- package/node_modules/@noble/curves/abstract/modular.js +555 -0
- package/node_modules/@noble/curves/abstract/modular.js.map +1 -0
- package/node_modules/@noble/curves/abstract/montgomery.d.ts +25 -0
- package/node_modules/@noble/curves/abstract/montgomery.d.ts.map +1 -0
- package/node_modules/@noble/curves/abstract/montgomery.js +153 -0
- package/node_modules/@noble/curves/abstract/montgomery.js.map +1 -0
- package/node_modules/@noble/curves/abstract/oprf.d.ts +282 -0
- package/node_modules/@noble/curves/abstract/oprf.d.ts.map +1 -0
- package/node_modules/@noble/curves/abstract/oprf.js +297 -0
- package/node_modules/@noble/curves/abstract/oprf.js.map +1 -0
- package/node_modules/@noble/curves/abstract/poseidon.d.ts +68 -0
- package/node_modules/@noble/curves/abstract/poseidon.d.ts.map +1 -0
- package/node_modules/@noble/curves/abstract/poseidon.js +300 -0
- package/node_modules/@noble/curves/abstract/poseidon.js.map +1 -0
- package/node_modules/@noble/curves/abstract/tower.d.ts +95 -0
- package/node_modules/@noble/curves/abstract/tower.d.ts.map +1 -0
- package/node_modules/@noble/curves/abstract/tower.js +742 -0
- package/node_modules/@noble/curves/abstract/tower.js.map +1 -0
- package/node_modules/@noble/curves/abstract/weierstrass.d.ts +325 -0
- package/node_modules/@noble/curves/abstract/weierstrass.d.ts.map +1 -0
- package/node_modules/@noble/curves/abstract/weierstrass.js +1222 -0
- package/node_modules/@noble/curves/abstract/weierstrass.js.map +1 -0
- package/node_modules/@noble/curves/bls12-381.d.ts +10 -0
- package/node_modules/@noble/curves/bls12-381.d.ts.map +1 -0
- package/node_modules/@noble/curves/bls12-381.js +688 -0
- package/node_modules/@noble/curves/bls12-381.js.map +1 -0
- package/node_modules/@noble/curves/bn254.d.ts +66 -0
- package/node_modules/@noble/curves/bn254.d.ts.map +1 -0
- package/node_modules/@noble/curves/bn254.js +190 -0
- package/node_modules/@noble/curves/bn254.js.map +1 -0
- package/node_modules/@noble/curves/ed25519.d.ts +101 -0
- package/node_modules/@noble/curves/ed25519.d.ts.map +1 -0
- package/node_modules/@noble/curves/ed25519.js +462 -0
- package/node_modules/@noble/curves/ed25519.js.map +1 -0
- package/node_modules/@noble/curves/ed448.d.ts +91 -0
- package/node_modules/@noble/curves/ed448.d.ts.map +1 -0
- package/node_modules/@noble/curves/ed448.js +442 -0
- package/node_modules/@noble/curves/ed448.js.map +1 -0
- package/node_modules/@noble/curves/index.d.ts +2 -0
- package/node_modules/@noble/curves/index.d.ts.map +1 -0
- package/node_modules/@noble/curves/index.js +33 -0
- package/node_modules/@noble/curves/index.js.map +1 -0
- package/node_modules/@noble/curves/misc.d.ts +15 -0
- package/node_modules/@noble/curves/misc.d.ts.map +1 -0
- package/node_modules/@noble/curves/misc.js +103 -0
- package/node_modules/@noble/curves/misc.js.map +1 -0
- package/node_modules/@noble/curves/nist.d.ts +36 -0
- package/node_modules/@noble/curves/nist.d.ts.map +1 -0
- package/node_modules/@noble/curves/nist.js +146 -0
- package/node_modules/@noble/curves/nist.js.map +1 -0
- package/node_modules/@noble/curves/package.json +98 -0
- package/node_modules/@noble/curves/secp256k1.d.ts +76 -0
- package/node_modules/@noble/curves/secp256k1.d.ts.map +1 -0
- package/node_modules/@noble/curves/secp256k1.js +283 -0
- package/node_modules/@noble/curves/secp256k1.js.map +1 -0
- package/node_modules/@noble/curves/src/abstract/bls.ts +604 -0
- package/node_modules/@noble/curves/src/abstract/curve.ts +633 -0
- package/node_modules/@noble/curves/src/abstract/edwards.ts +789 -0
- package/node_modules/@noble/curves/src/abstract/fft.ts +521 -0
- package/node_modules/@noble/curves/src/abstract/hash-to-curve.ts +292 -0
- package/node_modules/@noble/curves/src/abstract/modular.ts +621 -0
- package/node_modules/@noble/curves/src/abstract/montgomery.ts +187 -0
- package/node_modules/@noble/curves/src/abstract/oprf.ts +600 -0
- package/node_modules/@noble/curves/src/abstract/poseidon.ts +333 -0
- package/node_modules/@noble/curves/src/abstract/tower.ts +864 -0
- package/node_modules/@noble/curves/src/abstract/weierstrass.ts +1562 -0
- package/node_modules/@noble/curves/src/bls12-381.ts +775 -0
- package/node_modules/@noble/curves/src/bn254.ts +219 -0
- package/node_modules/@noble/curves/src/ed25519.ts +533 -0
- package/node_modules/@noble/curves/src/ed448.ts +525 -0
- package/node_modules/@noble/curves/src/index.ts +31 -0
- package/node_modules/@noble/curves/src/misc.ts +140 -0
- package/node_modules/@noble/curves/src/nist.ts +204 -0
- package/node_modules/@noble/curves/src/secp256k1.ts +327 -0
- package/node_modules/@noble/curves/src/utils.ts +306 -0
- package/node_modules/@noble/curves/src/webcrypto.ts +403 -0
- package/node_modules/@noble/curves/utils.d.ts +103 -0
- package/node_modules/@noble/curves/utils.d.ts.map +1 -0
- package/node_modules/@noble/curves/utils.js +241 -0
- package/node_modules/@noble/curves/utils.js.map +1 -0
- package/node_modules/@noble/curves/webcrypto.d.ts +99 -0
- package/node_modules/@noble/curves/webcrypto.d.ts.map +1 -0
- package/node_modules/@noble/curves/webcrypto.js +256 -0
- package/node_modules/@noble/curves/webcrypto.js.map +1 -0
- package/node_modules/@noble/hashes/LICENSE +21 -0
- package/node_modules/@noble/hashes/README.md +575 -0
- package/node_modules/@noble/hashes/_blake.d.ts +14 -0
- package/node_modules/@noble/hashes/_blake.d.ts.map +1 -0
- package/node_modules/@noble/hashes/_blake.js +45 -0
- package/node_modules/@noble/hashes/_blake.js.map +1 -0
- package/node_modules/@noble/hashes/_md.d.ts +49 -0
- package/node_modules/@noble/hashes/_md.d.ts.map +1 -0
- package/node_modules/@noble/hashes/_md.js +147 -0
- package/node_modules/@noble/hashes/_md.js.map +1 -0
- package/node_modules/@noble/hashes/_u64.d.ts +55 -0
- package/node_modules/@noble/hashes/_u64.d.ts.map +1 -0
- package/node_modules/@noble/hashes/_u64.js +67 -0
- package/node_modules/@noble/hashes/_u64.js.map +1 -0
- package/node_modules/@noble/hashes/argon2.d.ts +32 -0
- package/node_modules/@noble/hashes/argon2.d.ts.map +1 -0
- package/node_modules/@noble/hashes/argon2.js +391 -0
- package/node_modules/@noble/hashes/argon2.js.map +1 -0
- package/node_modules/@noble/hashes/blake1.d.ts +110 -0
- package/node_modules/@noble/hashes/blake1.d.ts.map +1 -0
- package/node_modules/@noble/hashes/blake1.js +485 -0
- package/node_modules/@noble/hashes/blake1.js.map +1 -0
- package/node_modules/@noble/hashes/blake2.d.ts +120 -0
- package/node_modules/@noble/hashes/blake2.d.ts.map +1 -0
- package/node_modules/@noble/hashes/blake2.js +417 -0
- package/node_modules/@noble/hashes/blake2.js.map +1 -0
- package/node_modules/@noble/hashes/blake3.d.ts +54 -0
- package/node_modules/@noble/hashes/blake3.d.ts.map +1 -0
- package/node_modules/@noble/hashes/blake3.js +255 -0
- package/node_modules/@noble/hashes/blake3.js.map +1 -0
- package/node_modules/@noble/hashes/eskdf.d.ts +50 -0
- package/node_modules/@noble/hashes/eskdf.d.ts.map +1 -0
- package/node_modules/@noble/hashes/eskdf.js +161 -0
- package/node_modules/@noble/hashes/eskdf.js.map +1 -0
- package/node_modules/@noble/hashes/hkdf.d.ts +36 -0
- package/node_modules/@noble/hashes/hkdf.d.ts.map +1 -0
- package/node_modules/@noble/hashes/hkdf.js +84 -0
- package/node_modules/@noble/hashes/hkdf.js.map +1 -0
- package/node_modules/@noble/hashes/hmac.d.ts +36 -0
- package/node_modules/@noble/hashes/hmac.d.ts.map +1 -0
- package/node_modules/@noble/hashes/hmac.js +90 -0
- package/node_modules/@noble/hashes/hmac.js.map +1 -0
- package/node_modules/@noble/hashes/index.d.ts +2 -0
- package/node_modules/@noble/hashes/index.d.ts.map +1 -0
- package/node_modules/@noble/hashes/index.js +34 -0
- package/node_modules/@noble/hashes/index.js.map +1 -0
- package/node_modules/@noble/hashes/legacy.d.ts +71 -0
- package/node_modules/@noble/hashes/legacy.d.ts.map +1 -0
- package/node_modules/@noble/hashes/legacy.js +281 -0
- package/node_modules/@noble/hashes/legacy.js.map +1 -0
- package/node_modules/@noble/hashes/package.json +93 -0
- package/node_modules/@noble/hashes/pbkdf2.d.ts +29 -0
- package/node_modules/@noble/hashes/pbkdf2.d.ts.map +1 -0
- package/node_modules/@noble/hashes/pbkdf2.js +97 -0
- package/node_modules/@noble/hashes/pbkdf2.js.map +1 -0
- package/node_modules/@noble/hashes/scrypt.d.ts +33 -0
- package/node_modules/@noble/hashes/scrypt.d.ts.map +1 -0
- package/node_modules/@noble/hashes/scrypt.js +216 -0
- package/node_modules/@noble/hashes/scrypt.js.map +1 -0
- package/node_modules/@noble/hashes/sha2.d.ts +199 -0
- package/node_modules/@noble/hashes/sha2.d.ts.map +1 -0
- package/node_modules/@noble/hashes/sha2.js +397 -0
- package/node_modules/@noble/hashes/sha2.js.map +1 -0
- package/node_modules/@noble/hashes/sha3-addons.d.ts +149 -0
- package/node_modules/@noble/hashes/sha3-addons.d.ts.map +1 -0
- package/node_modules/@noble/hashes/sha3-addons.js +420 -0
- package/node_modules/@noble/hashes/sha3-addons.js.map +1 -0
- package/node_modules/@noble/hashes/sha3.d.ts +58 -0
- package/node_modules/@noble/hashes/sha3.d.ts.map +1 -0
- package/node_modules/@noble/hashes/sha3.js +254 -0
- package/node_modules/@noble/hashes/sha3.js.map +1 -0
- package/node_modules/@noble/hashes/src/_blake.ts +50 -0
- package/node_modules/@noble/hashes/src/_md.ts +156 -0
- package/node_modules/@noble/hashes/src/_u64.ts +91 -0
- package/node_modules/@noble/hashes/src/argon2.ts +493 -0
- package/node_modules/@noble/hashes/src/blake1.ts +536 -0
- package/node_modules/@noble/hashes/src/blake2.ts +489 -0
- package/node_modules/@noble/hashes/src/blake3.ts +275 -0
- package/node_modules/@noble/hashes/src/eskdf.ts +188 -0
- package/node_modules/@noble/hashes/src/hkdf.ts +94 -0
- package/node_modules/@noble/hashes/src/hmac.ts +94 -0
- package/node_modules/@noble/hashes/src/index.ts +32 -0
- package/node_modules/@noble/hashes/src/legacy.ts +293 -0
- package/node_modules/@noble/hashes/src/pbkdf2.ts +129 -0
- package/node_modules/@noble/hashes/src/scrypt.ts +249 -0
- package/node_modules/@noble/hashes/src/sha2.ts +469 -0
- package/node_modules/@noble/hashes/src/sha3-addons.ts +530 -0
- package/node_modules/@noble/hashes/src/sha3.ts +295 -0
- package/node_modules/@noble/hashes/src/utils.ts +338 -0
- package/node_modules/@noble/hashes/src/webcrypto.ts +168 -0
- package/node_modules/@noble/hashes/utils.d.ts +130 -0
- package/node_modules/@noble/hashes/utils.d.ts.map +1 -0
- package/node_modules/@noble/hashes/utils.js +242 -0
- package/node_modules/@noble/hashes/utils.js.map +1 -0
- package/node_modules/@noble/hashes/webcrypto.d.ts +62 -0
- package/node_modules/@noble/hashes/webcrypto.d.ts.map +1 -0
- package/node_modules/@noble/hashes/webcrypto.js +126 -0
- package/node_modules/@noble/hashes/webcrypto.js.map +1 -0
- package/node_modules/@scure/base/LICENSE +21 -0
- package/node_modules/@scure/base/README.md +226 -0
- package/node_modules/@scure/base/index.d.ts +294 -0
- package/node_modules/@scure/base/index.d.ts.map +1 -0
- package/node_modules/@scure/base/index.js +704 -0
- package/node_modules/@scure/base/index.js.map +1 -0
- package/node_modules/@scure/base/index.ts +857 -0
- package/node_modules/@scure/base/package.json +58 -0
- package/node_modules/@scure/bip32/LICENSE +21 -0
- package/node_modules/@scure/bip32/README.md +158 -0
- package/node_modules/@scure/bip32/index.d.ts +60 -0
- package/node_modules/@scure/bip32/index.d.ts.map +1 -0
- package/node_modules/@scure/bip32/index.js +283 -0
- package/node_modules/@scure/bip32/index.js.map +1 -0
- package/node_modules/@scure/bip32/index.ts +317 -0
- package/node_modules/@scure/bip32/package.json +57 -0
- package/node_modules/@scure/bip39/LICENSE +21 -0
- package/node_modules/@scure/bip39/README.md +134 -0
- package/node_modules/@scure/bip39/index.d.ts +75 -0
- package/node_modules/@scure/bip39/index.js +149 -0
- package/node_modules/@scure/bip39/package.json +70 -0
- package/node_modules/@scure/bip39/src/index.ts +161 -0
- package/node_modules/@scure/bip39/wordlists/czech.d.ts +1 -0
- package/node_modules/@scure/bip39/wordlists/czech.js +2048 -0
- package/node_modules/@scure/bip39/wordlists/english.d.ts +1 -0
- package/node_modules/@scure/bip39/wordlists/english.js +2048 -0
- package/node_modules/@scure/bip39/wordlists/french.d.ts +1 -0
- package/node_modules/@scure/bip39/wordlists/french.js +2048 -0
- package/node_modules/@scure/bip39/wordlists/italian.d.ts +1 -0
- package/node_modules/@scure/bip39/wordlists/italian.js +2048 -0
- package/node_modules/@scure/bip39/wordlists/japanese.d.ts +1 -0
- package/node_modules/@scure/bip39/wordlists/japanese.js +2048 -0
- package/node_modules/@scure/bip39/wordlists/korean.d.ts +1 -0
- package/node_modules/@scure/bip39/wordlists/korean.js +2048 -0
- package/node_modules/@scure/bip39/wordlists/portuguese.d.ts +1 -0
- package/node_modules/@scure/bip39/wordlists/portuguese.js +2048 -0
- package/node_modules/@scure/bip39/wordlists/simplified-chinese.d.ts +1 -0
- package/node_modules/@scure/bip39/wordlists/simplified-chinese.js +2048 -0
- package/node_modules/@scure/bip39/wordlists/spanish.d.ts +1 -0
- package/node_modules/@scure/bip39/wordlists/spanish.js +2048 -0
- package/node_modules/@scure/bip39/wordlists/traditional-chinese.d.ts +1 -0
- package/node_modules/@scure/bip39/wordlists/traditional-chinese.js +2048 -0
- package/node_modules/nostr-tools/LICENSE +24 -0
- package/node_modules/nostr-tools/README.md +454 -0
- package/node_modules/nostr-tools/lib/cjs/abstract-pool.js +889 -0
- package/node_modules/nostr-tools/lib/cjs/abstract-pool.js.map +7 -0
- package/node_modules/nostr-tools/lib/cjs/abstract-relay.js +596 -0
- package/node_modules/nostr-tools/lib/cjs/abstract-relay.js.map +7 -0
- package/node_modules/nostr-tools/lib/cjs/core.js +63 -0
- package/node_modules/nostr-tools/lib/cjs/core.js.map +7 -0
- package/node_modules/nostr-tools/lib/cjs/fakejson.js +66 -0
- package/node_modules/nostr-tools/lib/cjs/fakejson.js.map +7 -0
- package/node_modules/nostr-tools/lib/cjs/filter.js +111 -0
- package/node_modules/nostr-tools/lib/cjs/filter.js.map +7 -0
- package/node_modules/nostr-tools/lib/cjs/index.js +3666 -0
- package/node_modules/nostr-tools/lib/cjs/index.js.map +7 -0
- package/node_modules/nostr-tools/lib/cjs/kinds.js +273 -0
- package/node_modules/nostr-tools/lib/cjs/kinds.js.map +7 -0
- package/node_modules/nostr-tools/lib/cjs/nip04.js +61 -0
- package/node_modules/nostr-tools/lib/cjs/nip04.js.map +7 -0
- package/node_modules/nostr-tools/lib/cjs/nip05.js +76 -0
- package/node_modules/nostr-tools/lib/cjs/nip05.js.map +7 -0
- package/node_modules/nostr-tools/lib/cjs/nip06.js +82 -0
- package/node_modules/nostr-tools/lib/cjs/nip06.js.map +7 -0
- package/node_modules/nostr-tools/lib/cjs/nip07.js +18 -0
- package/node_modules/nostr-tools/lib/cjs/nip07.js.map +7 -0
- package/node_modules/nostr-tools/lib/cjs/nip10.js +124 -0
- package/node_modules/nostr-tools/lib/cjs/nip10.js.map +7 -0
- package/node_modules/nostr-tools/lib/cjs/nip11.js +39 -0
- package/node_modules/nostr-tools/lib/cjs/nip11.js.map +7 -0
- package/node_modules/nostr-tools/lib/cjs/nip13.js +83 -0
- package/node_modules/nostr-tools/lib/cjs/nip13.js.map +7 -0
- package/node_modules/nostr-tools/lib/cjs/nip17.js +343 -0
- package/node_modules/nostr-tools/lib/cjs/nip17.js.map +7 -0
- package/node_modules/nostr-tools/lib/cjs/nip18.js +188 -0
- package/node_modules/nostr-tools/lib/cjs/nip18.js.map +7 -0
- package/node_modules/nostr-tools/lib/cjs/nip19.js +217 -0
- package/node_modules/nostr-tools/lib/cjs/nip19.js.map +7 -0
- package/node_modules/nostr-tools/lib/cjs/nip21.js +140 -0
- package/node_modules/nostr-tools/lib/cjs/nip21.js.map +7 -0
- package/node_modules/nostr-tools/lib/cjs/nip22.js +154 -0
- package/node_modules/nostr-tools/lib/cjs/nip22.js.map +7 -0
- package/node_modules/nostr-tools/lib/cjs/nip25.js +159 -0
- package/node_modules/nostr-tools/lib/cjs/nip25.js.map +7 -0
- package/node_modules/nostr-tools/lib/cjs/nip27.js +269 -0
- package/node_modules/nostr-tools/lib/cjs/nip27.js.map +7 -0
- package/node_modules/nostr-tools/lib/cjs/nip28.js +220 -0
- package/node_modules/nostr-tools/lib/cjs/nip28.js.map +7 -0
- package/node_modules/nostr-tools/lib/cjs/nip29.js +499 -0
- package/node_modules/nostr-tools/lib/cjs/nip29.js.map +7 -0
- package/node_modules/nostr-tools/lib/cjs/nip30.js +53 -0
- package/node_modules/nostr-tools/lib/cjs/nip30.js.map +7 -0
- package/node_modules/nostr-tools/lib/cjs/nip39.js +42 -0
- package/node_modules/nostr-tools/lib/cjs/nip39.js.map +7 -0
- package/node_modules/nostr-tools/lib/cjs/nip40.js +63 -0
- package/node_modules/nostr-tools/lib/cjs/nip40.js.map +7 -0
- package/node_modules/nostr-tools/lib/cjs/nip42.js +41 -0
- package/node_modules/nostr-tools/lib/cjs/nip42.js.map +7 -0
- package/node_modules/nostr-tools/lib/cjs/nip44.js +167 -0
- package/node_modules/nostr-tools/lib/cjs/nip44.js.map +7 -0
- package/node_modules/nostr-tools/lib/cjs/nip46.js +1455 -0
- package/node_modules/nostr-tools/lib/cjs/nip46.js.map +7 -0
- package/node_modules/nostr-tools/lib/cjs/nip47.js +168 -0
- package/node_modules/nostr-tools/lib/cjs/nip47.js.map +7 -0
- package/node_modules/nostr-tools/lib/cjs/nip49.js +77 -0
- package/node_modules/nostr-tools/lib/cjs/nip49.js.map +7 -0
- package/node_modules/nostr-tools/lib/cjs/nip54.js +35 -0
- package/node_modules/nostr-tools/lib/cjs/nip54.js.map +7 -0
- package/node_modules/nostr-tools/lib/cjs/nip55.js +103 -0
- package/node_modules/nostr-tools/lib/cjs/nip55.js.map +7 -0
- package/node_modules/nostr-tools/lib/cjs/nip57.js +274 -0
- package/node_modules/nostr-tools/lib/cjs/nip57.js.map +7 -0
- package/node_modules/nostr-tools/lib/cjs/nip58.js +117 -0
- package/node_modules/nostr-tools/lib/cjs/nip58.js.map +7 -0
- package/node_modules/nostr-tools/lib/cjs/nip59.js +320 -0
- package/node_modules/nostr-tools/lib/cjs/nip59.js.map +7 -0
- package/node_modules/nostr-tools/lib/cjs/nip75.js +70 -0
- package/node_modules/nostr-tools/lib/cjs/nip75.js.map +7 -0
- package/node_modules/nostr-tools/lib/cjs/nip77.js +519 -0
- package/node_modules/nostr-tools/lib/cjs/nip77.js.map +7 -0
- package/node_modules/nostr-tools/lib/cjs/nip94.js +142 -0
- package/node_modules/nostr-tools/lib/cjs/nip94.js.map +7 -0
- package/node_modules/nostr-tools/lib/cjs/nip98.js +230 -0
- package/node_modules/nostr-tools/lib/cjs/nip98.js.map +7 -0
- package/node_modules/nostr-tools/lib/cjs/nip99.js +153 -0
- package/node_modules/nostr-tools/lib/cjs/nip99.js.map +7 -0
- package/node_modules/nostr-tools/lib/cjs/nipb7.js +184 -0
- package/node_modules/nostr-tools/lib/cjs/nipb7.js.map +7 -0
- package/node_modules/nostr-tools/lib/cjs/package.json +1 -0
- package/node_modules/nostr-tools/lib/cjs/pool.js +989 -0
- package/node_modules/nostr-tools/lib/cjs/pool.js.map +7 -0
- package/node_modules/nostr-tools/lib/cjs/pure.js +130 -0
- package/node_modules/nostr-tools/lib/cjs/pure.js.map +7 -0
- package/node_modules/nostr-tools/lib/cjs/references.js +210 -0
- package/node_modules/nostr-tools/lib/cjs/references.js.map +7 -0
- package/node_modules/nostr-tools/lib/cjs/relay.js +704 -0
- package/node_modules/nostr-tools/lib/cjs/relay.js.map +7 -0
- package/node_modules/nostr-tools/lib/cjs/signer.js +130 -0
- package/node_modules/nostr-tools/lib/cjs/signer.js.map +7 -0
- package/node_modules/nostr-tools/lib/cjs/utils.js +150 -0
- package/node_modules/nostr-tools/lib/cjs/utils.js.map +7 -0
- package/node_modules/nostr-tools/lib/cjs/wasm.js +103 -0
- package/node_modules/nostr-tools/lib/cjs/wasm.js.map +7 -0
- package/node_modules/nostr-tools/lib/esm/abstract-pool.js +866 -0
- package/node_modules/nostr-tools/lib/esm/abstract-pool.js.map +7 -0
- package/node_modules/nostr-tools/lib/esm/abstract-relay.js +573 -0
- package/node_modules/nostr-tools/lib/esm/abstract-relay.js.map +7 -0
- package/node_modules/nostr-tools/lib/esm/core.js +42 -0
- package/node_modules/nostr-tools/lib/esm/core.js.map +7 -0
- package/node_modules/nostr-tools/lib/esm/fakejson.js +45 -0
- package/node_modules/nostr-tools/lib/esm/fakejson.js.map +7 -0
- package/node_modules/nostr-tools/lib/esm/filter.js +88 -0
- package/node_modules/nostr-tools/lib/esm/filter.js.map +7 -0
- package/node_modules/nostr-tools/lib/esm/index.js +3649 -0
- package/node_modules/nostr-tools/lib/esm/index.js.map +7 -0
- package/node_modules/nostr-tools/lib/esm/kinds.js +250 -0
- package/node_modules/nostr-tools/lib/esm/kinds.js.map +7 -0
- package/node_modules/nostr-tools/lib/esm/nip04.js +40 -0
- package/node_modules/nostr-tools/lib/esm/nip04.js.map +7 -0
- package/node_modules/nostr-tools/lib/esm/nip05.js +55 -0
- package/node_modules/nostr-tools/lib/esm/nip05.js.map +7 -0
- package/node_modules/nostr-tools/lib/esm/nip06.js +61 -0
- package/node_modules/nostr-tools/lib/esm/nip06.js.map +7 -0
- package/node_modules/nostr-tools/lib/esm/nip07.js +0 -0
- package/node_modules/nostr-tools/lib/esm/nip07.js.map +7 -0
- package/node_modules/nostr-tools/lib/esm/nip10.js +103 -0
- package/node_modules/nostr-tools/lib/esm/nip10.js.map +7 -0
- package/node_modules/nostr-tools/lib/esm/nip11.js +18 -0
- package/node_modules/nostr-tools/lib/esm/nip11.js.map +7 -0
- package/node_modules/nostr-tools/lib/esm/nip13.js +62 -0
- package/node_modules/nostr-tools/lib/esm/nip13.js.map +7 -0
- package/node_modules/nostr-tools/lib/esm/nip17.js +320 -0
- package/node_modules/nostr-tools/lib/esm/nip17.js.map +7 -0
- package/node_modules/nostr-tools/lib/esm/nip18.js +165 -0
- package/node_modules/nostr-tools/lib/esm/nip18.js.map +7 -0
- package/node_modules/nostr-tools/lib/esm/nip19.js +196 -0
- package/node_modules/nostr-tools/lib/esm/nip19.js.map +7 -0
- package/node_modules/nostr-tools/lib/esm/nip21.js +117 -0
- package/node_modules/nostr-tools/lib/esm/nip21.js.map +7 -0
- package/node_modules/nostr-tools/lib/esm/nip22.js +133 -0
- package/node_modules/nostr-tools/lib/esm/nip22.js.map +7 -0
- package/node_modules/nostr-tools/lib/esm/nip25.js +136 -0
- package/node_modules/nostr-tools/lib/esm/nip25.js.map +7 -0
- package/node_modules/nostr-tools/lib/esm/nip27.js +246 -0
- package/node_modules/nostr-tools/lib/esm/nip27.js.map +7 -0
- package/node_modules/nostr-tools/lib/esm/nip28.js +197 -0
- package/node_modules/nostr-tools/lib/esm/nip28.js.map +7 -0
- package/node_modules/nostr-tools/lib/esm/nip29.js +476 -0
- package/node_modules/nostr-tools/lib/esm/nip29.js.map +7 -0
- package/node_modules/nostr-tools/lib/esm/nip30.js +32 -0
- package/node_modules/nostr-tools/lib/esm/nip30.js.map +7 -0
- package/node_modules/nostr-tools/lib/esm/nip39.js +21 -0
- package/node_modules/nostr-tools/lib/esm/nip39.js.map +7 -0
- package/node_modules/nostr-tools/lib/esm/nip40.js +42 -0
- package/node_modules/nostr-tools/lib/esm/nip40.js.map +7 -0
- package/node_modules/nostr-tools/lib/esm/nip42.js +18 -0
- package/node_modules/nostr-tools/lib/esm/nip42.js.map +7 -0
- package/node_modules/nostr-tools/lib/esm/nip44.js +146 -0
- package/node_modules/nostr-tools/lib/esm/nip44.js.map +7 -0
- package/node_modules/nostr-tools/lib/esm/nip46.js +1432 -0
- package/node_modules/nostr-tools/lib/esm/nip46.js.map +7 -0
- package/node_modules/nostr-tools/lib/esm/nip47.js +145 -0
- package/node_modules/nostr-tools/lib/esm/nip47.js.map +7 -0
- package/node_modules/nostr-tools/lib/esm/nip49.js +56 -0
- package/node_modules/nostr-tools/lib/esm/nip49.js.map +7 -0
- package/node_modules/nostr-tools/lib/esm/nip54.js +14 -0
- package/node_modules/nostr-tools/lib/esm/nip54.js.map +7 -0
- package/node_modules/nostr-tools/lib/esm/nip55.js +82 -0
- package/node_modules/nostr-tools/lib/esm/nip55.js.map +7 -0
- package/node_modules/nostr-tools/lib/esm/nip57.js +253 -0
- package/node_modules/nostr-tools/lib/esm/nip57.js.map +7 -0
- package/node_modules/nostr-tools/lib/esm/nip58.js +94 -0
- package/node_modules/nostr-tools/lib/esm/nip58.js.map +7 -0
- package/node_modules/nostr-tools/lib/esm/nip59.js +297 -0
- package/node_modules/nostr-tools/lib/esm/nip59.js.map +7 -0
- package/node_modules/nostr-tools/lib/esm/nip75.js +47 -0
- package/node_modules/nostr-tools/lib/esm/nip75.js.map +7 -0
- package/node_modules/nostr-tools/lib/esm/nip77.js +498 -0
- package/node_modules/nostr-tools/lib/esm/nip77.js.map +7 -0
- package/node_modules/nostr-tools/lib/esm/nip94.js +119 -0
- package/node_modules/nostr-tools/lib/esm/nip94.js.map +7 -0
- package/node_modules/nostr-tools/lib/esm/nip98.js +209 -0
- package/node_modules/nostr-tools/lib/esm/nip98.js.map +7 -0
- package/node_modules/nostr-tools/lib/esm/nip99.js +130 -0
- package/node_modules/nostr-tools/lib/esm/nip99.js.map +7 -0
- package/node_modules/nostr-tools/lib/esm/nipb7.js +163 -0
- package/node_modules/nostr-tools/lib/esm/nipb7.js.map +7 -0
- package/node_modules/nostr-tools/lib/esm/pool.js +966 -0
- package/node_modules/nostr-tools/lib/esm/pool.js.map +7 -0
- package/node_modules/nostr-tools/lib/esm/pure.js +109 -0
- package/node_modules/nostr-tools/lib/esm/pure.js.map +7 -0
- package/node_modules/nostr-tools/lib/esm/references.js +187 -0
- package/node_modules/nostr-tools/lib/esm/references.js.map +7 -0
- package/node_modules/nostr-tools/lib/esm/relay.js +681 -0
- package/node_modules/nostr-tools/lib/esm/relay.js.map +7 -0
- package/node_modules/nostr-tools/lib/esm/signer.js +107 -0
- package/node_modules/nostr-tools/lib/esm/signer.js.map +7 -0
- package/node_modules/nostr-tools/lib/esm/utils.js +129 -0
- package/node_modules/nostr-tools/lib/esm/utils.js.map +7 -0
- package/node_modules/nostr-tools/lib/esm/wasm.js +82 -0
- package/node_modules/nostr-tools/lib/esm/wasm.js.map +7 -0
- package/node_modules/nostr-tools/lib/nostr.bundle.js +7336 -0
- package/node_modules/nostr-tools/lib/nostr.bundle.js.map +7 -0
- package/node_modules/nostr-tools/lib/types/abstract-pool.d.ts +60 -0
- package/node_modules/nostr-tools/lib/types/abstract-relay.d.ts +110 -0
- package/node_modules/nostr-tools/lib/types/benchmarks.d.ts +1 -0
- package/node_modules/nostr-tools/lib/types/core.d.ts +32 -0
- package/node_modules/nostr-tools/lib/types/core.test.d.ts +1 -0
- package/node_modules/nostr-tools/lib/types/fakejson.d.ts +6 -0
- package/node_modules/nostr-tools/lib/types/fakejson.test.d.ts +1 -0
- package/node_modules/nostr-tools/lib/types/filter.d.ts +19 -0
- package/node_modules/nostr-tools/lib/types/filter.test.d.ts +1 -0
- package/node_modules/nostr-tools/lib/types/helpers.d.ts +2 -0
- package/node_modules/nostr-tools/lib/types/index.d.ts +31 -0
- package/node_modules/nostr-tools/lib/types/kinds.d.ts +200 -0
- package/node_modules/nostr-tools/lib/types/kinds.test.d.ts +1 -0
- package/node_modules/nostr-tools/lib/types/nip04.d.ts +2 -0
- package/node_modules/nostr-tools/lib/types/nip04.test.d.ts +1 -0
- package/node_modules/nostr-tools/lib/types/nip05.d.ts +17 -0
- package/node_modules/nostr-tools/lib/types/nip05.test.d.ts +1 -0
- package/node_modules/nostr-tools/lib/types/nip06.d.ts +15 -0
- package/node_modules/nostr-tools/lib/types/nip06.test.d.ts +1 -0
- package/node_modules/nostr-tools/lib/types/nip07.d.ts +13 -0
- package/node_modules/nostr-tools/lib/types/nip10.d.ts +24 -0
- package/node_modules/nostr-tools/lib/types/nip10.test.d.ts +1 -0
- package/node_modules/nostr-tools/lib/types/nip11.d.ts +266 -0
- package/node_modules/nostr-tools/lib/types/nip11.test.d.ts +1 -0
- package/node_modules/nostr-tools/lib/types/nip13.d.ts +8 -0
- package/node_modules/nostr-tools/lib/types/nip13.test.d.ts +1 -0
- package/node_modules/nostr-tools/lib/types/nip17.d.ts +15 -0
- package/node_modules/nostr-tools/lib/types/nip17.test.d.ts +1 -0
- package/node_modules/nostr-tools/lib/types/nip18.d.ts +22 -0
- package/node_modules/nostr-tools/lib/types/nip18.test.d.ts +1 -0
- package/node_modules/nostr-tools/lib/types/nip19.d.ts +81 -0
- package/node_modules/nostr-tools/lib/types/nip19.test.d.ts +1 -0
- package/node_modules/nostr-tools/lib/types/nip21.d.ts +34 -0
- package/node_modules/nostr-tools/lib/types/nip21.test.d.ts +1 -0
- package/node_modules/nostr-tools/lib/types/nip22.d.ts +36 -0
- package/node_modules/nostr-tools/lib/types/nip22.test.d.ts +1 -0
- package/node_modules/nostr-tools/lib/types/nip25.d.ts +15 -0
- package/node_modules/nostr-tools/lib/types/nip25.test.d.ts +1 -0
- package/node_modules/nostr-tools/lib/types/nip27.d.ts +32 -0
- package/node_modules/nostr-tools/lib/types/nip27.test.d.ts +1 -0
- package/node_modules/nostr-tools/lib/types/nip28.d.ts +46 -0
- package/node_modules/nostr-tools/lib/types/nip28.test.d.ts +1 -0
- package/node_modules/nostr-tools/lib/types/nip29.d.ts +265 -0
- package/node_modules/nostr-tools/lib/types/nip30.d.ts +22 -0
- package/node_modules/nostr-tools/lib/types/nip30.test.d.ts +1 -0
- package/node_modules/nostr-tools/lib/types/nip39.d.ts +2 -0
- package/node_modules/nostr-tools/lib/types/nip39.test.d.ts +1 -0
- package/node_modules/nostr-tools/lib/types/nip40.d.ts +10 -0
- package/node_modules/nostr-tools/lib/types/nip40.test.d.ts +1 -0
- package/node_modules/nostr-tools/lib/types/nip42.d.ts +5 -0
- package/node_modules/nostr-tools/lib/types/nip42.test.d.ts +1 -0
- package/node_modules/nostr-tools/lib/types/nip44.d.ts +18 -0
- package/node_modules/nostr-tools/lib/types/nip44.test.d.ts +1 -0
- package/node_modules/nostr-tools/lib/types/nip46.d.ts +119 -0
- package/node_modules/nostr-tools/lib/types/nip47.d.ts +11 -0
- package/node_modules/nostr-tools/lib/types/nip47.test.d.ts +1 -0
- package/node_modules/nostr-tools/lib/types/nip49.d.ts +3 -0
- package/node_modules/nostr-tools/lib/types/nip49.test.d.ts +1 -0
- package/node_modules/nostr-tools/lib/types/nip54.d.ts +1 -0
- package/node_modules/nostr-tools/lib/types/nip54.test.d.ts +1 -0
- package/node_modules/nostr-tools/lib/types/nip55.d.ts +30 -0
- package/node_modules/nostr-tools/lib/types/nip55.test.d.ts +1 -0
- package/node_modules/nostr-tools/lib/types/nip57.d.ts +25 -0
- package/node_modules/nostr-tools/lib/types/nip57.test.d.ts +1 -0
- package/node_modules/nostr-tools/lib/types/nip58.d.ts +134 -0
- package/node_modules/nostr-tools/lib/types/nip58.test.d.ts +1 -0
- package/node_modules/nostr-tools/lib/types/nip59.d.ts +12 -0
- package/node_modules/nostr-tools/lib/types/nip59.test.d.ts +1 -0
- package/node_modules/nostr-tools/lib/types/nip75.d.ts +61 -0
- package/node_modules/nostr-tools/lib/types/nip75.test.d.ts +1 -0
- package/node_modules/nostr-tools/lib/types/nip77.d.ts +102 -0
- package/node_modules/nostr-tools/lib/types/nip77.test.d.ts +1 -0
- package/node_modules/nostr-tools/lib/types/nip94.d.ts +87 -0
- package/node_modules/nostr-tools/lib/types/nip94.test.d.ts +1 -0
- package/node_modules/nostr-tools/lib/types/nip98.d.ts +74 -0
- package/node_modules/nostr-tools/lib/types/nip98.test.d.ts +1 -0
- package/node_modules/nostr-tools/lib/types/nip99.d.ts +92 -0
- package/node_modules/nostr-tools/lib/types/nip99.test.d.ts +1 -0
- package/node_modules/nostr-tools/lib/types/nipb7.d.ts +23 -0
- package/node_modules/nostr-tools/lib/types/nipb7.test.d.ts +1 -0
- package/node_modules/nostr-tools/lib/types/pool.d.ts +6 -0
- package/node_modules/nostr-tools/lib/types/pool.test.d.ts +1 -0
- package/node_modules/nostr-tools/lib/types/pure.d.ts +8 -0
- package/node_modules/nostr-tools/lib/types/pure.test.d.ts +1 -0
- package/node_modules/nostr-tools/lib/types/references.d.ts +10 -0
- package/node_modules/nostr-tools/lib/types/references.test.d.ts +1 -0
- package/node_modules/nostr-tools/lib/types/relay.d.ts +11 -0
- package/node_modules/nostr-tools/lib/types/relay.test.d.ts +1 -0
- package/node_modules/nostr-tools/lib/types/signer.d.ts +11 -0
- package/node_modules/nostr-tools/lib/types/test-helpers.d.ts +14 -0
- package/node_modules/nostr-tools/lib/types/utils.d.ts +9 -0
- package/node_modules/nostr-tools/lib/types/utils.test.d.ts +1 -0
- package/node_modules/nostr-tools/lib/types/wasm.d.ts +8 -0
- package/node_modules/nostr-tools/package.json +330 -0
- package/node_modules/nostr-wasm/README.md +91 -0
- package/node_modules/nostr-wasm/dist/api/emsimp.d.ts +3 -0
- package/node_modules/nostr-wasm/dist/api/nostr.d.ts +45 -0
- package/node_modules/nostr-wasm/dist/api/secp256k1-types.d.ts +124 -0
- package/node_modules/nostr-wasm/dist/api/secp256k1.d.ts +41 -0
- package/node_modules/nostr-wasm/dist/api/types.d.ts +124 -0
- package/node_modules/nostr-wasm/dist/api/wasm-env.d.ts +3 -0
- package/node_modules/nostr-wasm/dist/gen/wasm.d.ts +27 -0
- package/node_modules/nostr-wasm/dist/generate.d.ts +1 -0
- package/node_modules/nostr-wasm/dist/gzipped.d.ts +3 -0
- package/node_modules/nostr-wasm/dist/gzipped.js +44 -0
- package/node_modules/nostr-wasm/dist/headless.d.ts +2 -0
- package/node_modules/nostr-wasm/dist/main.d.ts +3 -0
- package/node_modules/nostr-wasm/dist/main.js +9 -0
- package/node_modules/nostr-wasm/dist/nostr.js +248 -0
- package/node_modules/nostr-wasm/dist/secp256k1.js +230 -0
- package/node_modules/nostr-wasm/dist/types.d.ts +22 -0
- package/node_modules/nostr-wasm/package.json +37 -0
- package/node_modules/nostr-wasm/public/out/secp256k1.js +1 -0
- package/node_modules/nostr-wasm/public/out/secp256k1.wasm +0 -0
- package/node_modules/zod/LICENSE +21 -0
- package/node_modules/zod/README.md +191 -0
- package/node_modules/zod/index.cjs +33 -0
- package/node_modules/zod/index.d.cts +4 -0
- package/node_modules/zod/index.d.ts +4 -0
- package/node_modules/zod/index.js +4 -0
- package/node_modules/zod/locales/index.cjs +17 -0
- package/node_modules/zod/locales/index.d.cts +1 -0
- package/node_modules/zod/locales/index.d.ts +1 -0
- package/node_modules/zod/locales/index.js +1 -0
- package/node_modules/zod/locales/package.json +7 -0
- package/node_modules/zod/mini/index.cjs +32 -0
- package/node_modules/zod/mini/index.d.cts +3 -0
- package/node_modules/zod/mini/index.d.ts +3 -0
- package/node_modules/zod/mini/index.js +3 -0
- package/node_modules/zod/mini/package.json +7 -0
- package/node_modules/zod/package.json +135 -0
- package/node_modules/zod/src/index.ts +4 -0
- package/node_modules/zod/src/locales/index.ts +1 -0
- package/node_modules/zod/src/mini/index.ts +3 -0
- package/node_modules/zod/src/v3/ZodError.ts +330 -0
- package/node_modules/zod/src/v3/benchmarks/datetime.ts +58 -0
- package/node_modules/zod/src/v3/benchmarks/discriminatedUnion.ts +80 -0
- package/node_modules/zod/src/v3/benchmarks/index.ts +59 -0
- package/node_modules/zod/src/v3/benchmarks/ipv4.ts +57 -0
- package/node_modules/zod/src/v3/benchmarks/object.ts +69 -0
- package/node_modules/zod/src/v3/benchmarks/primitives.ts +162 -0
- package/node_modules/zod/src/v3/benchmarks/realworld.ts +63 -0
- package/node_modules/zod/src/v3/benchmarks/string.ts +55 -0
- package/node_modules/zod/src/v3/benchmarks/union.ts +80 -0
- package/node_modules/zod/src/v3/errors.ts +13 -0
- package/node_modules/zod/src/v3/external.ts +6 -0
- package/node_modules/zod/src/v3/helpers/enumUtil.ts +17 -0
- package/node_modules/zod/src/v3/helpers/errorUtil.ts +8 -0
- package/node_modules/zod/src/v3/helpers/parseUtil.ts +176 -0
- package/node_modules/zod/src/v3/helpers/partialUtil.ts +34 -0
- package/node_modules/zod/src/v3/helpers/typeAliases.ts +2 -0
- package/node_modules/zod/src/v3/helpers/util.ts +224 -0
- package/node_modules/zod/src/v3/index.ts +4 -0
- package/node_modules/zod/src/v3/locales/en.ts +124 -0
- package/node_modules/zod/src/v3/standard-schema.ts +113 -0
- package/node_modules/zod/src/v3/tests/Mocker.ts +54 -0
- package/node_modules/zod/src/v3/tests/all-errors.test.ts +157 -0
- package/node_modules/zod/src/v3/tests/anyunknown.test.ts +28 -0
- package/node_modules/zod/src/v3/tests/array.test.ts +71 -0
- package/node_modules/zod/src/v3/tests/async-parsing.test.ts +388 -0
- package/node_modules/zod/src/v3/tests/async-refinements.test.ts +46 -0
- package/node_modules/zod/src/v3/tests/base.test.ts +29 -0
- package/node_modules/zod/src/v3/tests/bigint.test.ts +55 -0
- package/node_modules/zod/src/v3/tests/branded.test.ts +53 -0
- package/node_modules/zod/src/v3/tests/catch.test.ts +220 -0
- package/node_modules/zod/src/v3/tests/coerce.test.ts +133 -0
- package/node_modules/zod/src/v3/tests/complex.test.ts +70 -0
- package/node_modules/zod/src/v3/tests/custom.test.ts +31 -0
- package/node_modules/zod/src/v3/tests/date.test.ts +32 -0
- package/node_modules/zod/src/v3/tests/deepmasking.test.ts +186 -0
- package/node_modules/zod/src/v3/tests/default.test.ts +112 -0
- package/node_modules/zod/src/v3/tests/description.test.ts +33 -0
- package/node_modules/zod/src/v3/tests/discriminated-unions.test.ts +315 -0
- package/node_modules/zod/src/v3/tests/enum.test.ts +80 -0
- package/node_modules/zod/src/v3/tests/error.test.ts +551 -0
- package/node_modules/zod/src/v3/tests/firstparty.test.ts +87 -0
- package/node_modules/zod/src/v3/tests/firstpartyschematypes.test.ts +21 -0
- package/node_modules/zod/src/v3/tests/function.test.ts +261 -0
- package/node_modules/zod/src/v3/tests/generics.test.ts +48 -0
- package/node_modules/zod/src/v3/tests/instanceof.test.ts +37 -0
- package/node_modules/zod/src/v3/tests/intersection.test.ts +110 -0
- package/node_modules/zod/src/v3/tests/language-server.source.ts +76 -0
- package/node_modules/zod/src/v3/tests/language-server.test.ts +207 -0
- package/node_modules/zod/src/v3/tests/literal.test.ts +36 -0
- package/node_modules/zod/src/v3/tests/map.test.ts +110 -0
- package/node_modules/zod/src/v3/tests/masking.test.ts +4 -0
- package/node_modules/zod/src/v3/tests/mocker.test.ts +19 -0
- package/node_modules/zod/src/v3/tests/nan.test.ts +24 -0
- package/node_modules/zod/src/v3/tests/nativeEnum.test.ts +87 -0
- package/node_modules/zod/src/v3/tests/nullable.test.ts +42 -0
- package/node_modules/zod/src/v3/tests/number.test.ts +176 -0
- package/node_modules/zod/src/v3/tests/object-augmentation.test.ts +29 -0
- package/node_modules/zod/src/v3/tests/object-in-es5-env.test.ts +29 -0
- package/node_modules/zod/src/v3/tests/object.test.ts +434 -0
- package/node_modules/zod/src/v3/tests/optional.test.ts +42 -0
- package/node_modules/zod/src/v3/tests/parseUtil.test.ts +23 -0
- package/node_modules/zod/src/v3/tests/parser.test.ts +41 -0
- package/node_modules/zod/src/v3/tests/partials.test.ts +243 -0
- package/node_modules/zod/src/v3/tests/pickomit.test.ts +111 -0
- package/node_modules/zod/src/v3/tests/pipeline.test.ts +29 -0
- package/node_modules/zod/src/v3/tests/preprocess.test.ts +186 -0
- package/node_modules/zod/src/v3/tests/primitive.test.ts +440 -0
- package/node_modules/zod/src/v3/tests/promise.test.ts +90 -0
- package/node_modules/zod/src/v3/tests/readonly.test.ts +194 -0
- package/node_modules/zod/src/v3/tests/record.test.ts +171 -0
- package/node_modules/zod/src/v3/tests/recursive.test.ts +197 -0
- package/node_modules/zod/src/v3/tests/refine.test.ts +313 -0
- package/node_modules/zod/src/v3/tests/safeparse.test.ts +27 -0
- package/node_modules/zod/src/v3/tests/set.test.ts +142 -0
- package/node_modules/zod/src/v3/tests/standard-schema.test.ts +83 -0
- package/node_modules/zod/src/v3/tests/string.test.ts +916 -0
- package/node_modules/zod/src/v3/tests/transformer.test.ts +233 -0
- package/node_modules/zod/src/v3/tests/tuple.test.ts +90 -0
- package/node_modules/zod/src/v3/tests/unions.test.ts +57 -0
- package/node_modules/zod/src/v3/tests/validations.test.ts +133 -0
- package/node_modules/zod/src/v3/tests/void.test.ts +15 -0
- package/node_modules/zod/src/v3/types.ts +5138 -0
- package/node_modules/zod/src/v4/classic/checks.ts +32 -0
- package/node_modules/zod/src/v4/classic/coerce.ts +27 -0
- package/node_modules/zod/src/v4/classic/compat.ts +70 -0
- package/node_modules/zod/src/v4/classic/errors.ts +82 -0
- package/node_modules/zod/src/v4/classic/external.ts +52 -0
- package/node_modules/zod/src/v4/classic/from-json-schema.ts +659 -0
- package/node_modules/zod/src/v4/classic/index.ts +5 -0
- package/node_modules/zod/src/v4/classic/iso.ts +90 -0
- package/node_modules/zod/src/v4/classic/parse.ts +82 -0
- package/node_modules/zod/src/v4/classic/schemas.ts +2672 -0
- package/node_modules/zod/src/v4/classic/tests/anyunknown.test.ts +26 -0
- package/node_modules/zod/src/v4/classic/tests/apply.test.ts +59 -0
- package/node_modules/zod/src/v4/classic/tests/array.test.ts +264 -0
- package/node_modules/zod/src/v4/classic/tests/assignability.test.ts +216 -0
- package/node_modules/zod/src/v4/classic/tests/async-parsing.test.ts +381 -0
- package/node_modules/zod/src/v4/classic/tests/async-refinements.test.ts +68 -0
- package/node_modules/zod/src/v4/classic/tests/base.test.ts +7 -0
- package/node_modules/zod/src/v4/classic/tests/bigint.test.ts +54 -0
- package/node_modules/zod/src/v4/classic/tests/brand.test.ts +106 -0
- package/node_modules/zod/src/v4/classic/tests/catch.test.ts +326 -0
- package/node_modules/zod/src/v4/classic/tests/coalesce.test.ts +20 -0
- package/node_modules/zod/src/v4/classic/tests/codec-examples.test.ts +573 -0
- package/node_modules/zod/src/v4/classic/tests/codec.test.ts +703 -0
- package/node_modules/zod/src/v4/classic/tests/coerce.test.ts +160 -0
- package/node_modules/zod/src/v4/classic/tests/continuability.test.ts +374 -0
- package/node_modules/zod/src/v4/classic/tests/custom.test.ts +40 -0
- package/node_modules/zod/src/v4/classic/tests/date.test.ts +62 -0
- package/node_modules/zod/src/v4/classic/tests/datetime.test.ts +302 -0
- package/node_modules/zod/src/v4/classic/tests/default.test.ts +409 -0
- package/node_modules/zod/src/v4/classic/tests/describe-meta-checks.test.ts +27 -0
- package/node_modules/zod/src/v4/classic/tests/description.test.ts +32 -0
- package/node_modules/zod/src/v4/classic/tests/detached-methods.test.ts +197 -0
- package/node_modules/zod/src/v4/classic/tests/discriminated-unions.test.ts +694 -0
- package/node_modules/zod/src/v4/classic/tests/enum.test.ts +285 -0
- package/node_modules/zod/src/v4/classic/tests/error-utils.test.ts +807 -0
- package/node_modules/zod/src/v4/classic/tests/error.test.ts +711 -0
- package/node_modules/zod/src/v4/classic/tests/file.test.ts +96 -0
- package/node_modules/zod/src/v4/classic/tests/firstparty.test.ts +179 -0
- package/node_modules/zod/src/v4/classic/tests/fix-json-issue.test.ts +26 -0
- package/node_modules/zod/src/v4/classic/tests/from-json-schema.test.ts +895 -0
- package/node_modules/zod/src/v4/classic/tests/function.test.ts +360 -0
- package/node_modules/zod/src/v4/classic/tests/generics.test.ts +72 -0
- package/node_modules/zod/src/v4/classic/tests/global-config.test.ts +39 -0
- package/node_modules/zod/src/v4/classic/tests/hash.test.ts +68 -0
- package/node_modules/zod/src/v4/classic/tests/index.test.ts +939 -0
- package/node_modules/zod/src/v4/classic/tests/instanceof.test.ts +60 -0
- package/node_modules/zod/src/v4/classic/tests/intersection.test.ts +198 -0
- package/node_modules/zod/src/v4/classic/tests/jitless-allows-eval.test.ts +46 -0
- package/node_modules/zod/src/v4/classic/tests/json.test.ts +109 -0
- package/node_modules/zod/src/v4/classic/tests/lazy.test.ts +227 -0
- package/node_modules/zod/src/v4/classic/tests/literal.test.ts +117 -0
- package/node_modules/zod/src/v4/classic/tests/locales_ka.test.ts +29 -0
- package/node_modules/zod/src/v4/classic/tests/locales_ro.test.ts +24 -0
- package/node_modules/zod/src/v4/classic/tests/map.test.ts +330 -0
- package/node_modules/zod/src/v4/classic/tests/nan.test.ts +21 -0
- package/node_modules/zod/src/v4/classic/tests/nested-refine.test.ts +168 -0
- package/node_modules/zod/src/v4/classic/tests/nonoptional.test.ts +101 -0
- package/node_modules/zod/src/v4/classic/tests/nullable.test.ts +22 -0
- package/node_modules/zod/src/v4/classic/tests/number.test.ts +325 -0
- package/node_modules/zod/src/v4/classic/tests/object.test.ts +717 -0
- package/node_modules/zod/src/v4/classic/tests/optional.test.ts +333 -0
- package/node_modules/zod/src/v4/classic/tests/partial.test.ts +450 -0
- package/node_modules/zod/src/v4/classic/tests/pickomit.test.ts +211 -0
- package/node_modules/zod/src/v4/classic/tests/pipe.test.ts +101 -0
- package/node_modules/zod/src/v4/classic/tests/prefault.test.ts +74 -0
- package/node_modules/zod/src/v4/classic/tests/preprocess-types.test.ts +26 -0
- package/node_modules/zod/src/v4/classic/tests/preprocess.test.ts +351 -0
- package/node_modules/zod/src/v4/classic/tests/primitive.test.ts +175 -0
- package/node_modules/zod/src/v4/classic/tests/promise.test.ts +81 -0
- package/node_modules/zod/src/v4/classic/tests/prototypes.test.ts +23 -0
- package/node_modules/zod/src/v4/classic/tests/readonly.test.ts +252 -0
- package/node_modules/zod/src/v4/classic/tests/record.test.ts +717 -0
- package/node_modules/zod/src/v4/classic/tests/recursive-types.test.ts +631 -0
- package/node_modules/zod/src/v4/classic/tests/refine.test.ts +633 -0
- package/node_modules/zod/src/v4/classic/tests/registries.test.ts +243 -0
- package/node_modules/zod/src/v4/classic/tests/set.test.ts +181 -0
- package/node_modules/zod/src/v4/classic/tests/standard-schema.test.ts +134 -0
- package/node_modules/zod/src/v4/classic/tests/string-formats.test.ts +125 -0
- package/node_modules/zod/src/v4/classic/tests/string.test.ts +1224 -0
- package/node_modules/zod/src/v4/classic/tests/stringbool.test.ts +106 -0
- package/node_modules/zod/src/v4/classic/tests/template-literal.test.ts +771 -0
- package/node_modules/zod/src/v4/classic/tests/to-json-schema-methods.test.ts +438 -0
- package/node_modules/zod/src/v4/classic/tests/to-json-schema.test.ts +3125 -0
- package/node_modules/zod/src/v4/classic/tests/transform.test.ts +378 -0
- package/node_modules/zod/src/v4/classic/tests/tuple.test.ts +496 -0
- package/node_modules/zod/src/v4/classic/tests/union.test.ts +273 -0
- package/node_modules/zod/src/v4/classic/tests/url.test.ts +13 -0
- package/node_modules/zod/src/v4/classic/tests/validations.test.ts +283 -0
- package/node_modules/zod/src/v4/classic/tests/void.test.ts +12 -0
- package/node_modules/zod/src/v4/core/api.ts +1823 -0
- package/node_modules/zod/src/v4/core/checks.ts +1293 -0
- package/node_modules/zod/src/v4/core/config.ts +15 -0
- package/node_modules/zod/src/v4/core/core.ts +153 -0
- package/node_modules/zod/src/v4/core/doc.ts +44 -0
- package/node_modules/zod/src/v4/core/errors.ts +455 -0
- package/node_modules/zod/src/v4/core/index.ts +16 -0
- package/node_modules/zod/src/v4/core/json-schema-generator.ts +126 -0
- package/node_modules/zod/src/v4/core/json-schema-processors.ts +666 -0
- package/node_modules/zod/src/v4/core/json-schema.ts +147 -0
- package/node_modules/zod/src/v4/core/parse.ts +195 -0
- package/node_modules/zod/src/v4/core/regexes.ts +190 -0
- package/node_modules/zod/src/v4/core/registries.ts +105 -0
- package/node_modules/zod/src/v4/core/schemas.ts +4730 -0
- package/node_modules/zod/src/v4/core/standard-schema.ts +159 -0
- package/node_modules/zod/src/v4/core/tests/extend.test.ts +59 -0
- package/node_modules/zod/src/v4/core/tests/index.test.ts +46 -0
- package/node_modules/zod/src/v4/core/tests/locales/be.test.ts +124 -0
- package/node_modules/zod/src/v4/core/tests/locales/el.test.ts +215 -0
- package/node_modules/zod/src/v4/core/tests/locales/en.test.ts +22 -0
- package/node_modules/zod/src/v4/core/tests/locales/es.test.ts +181 -0
- package/node_modules/zod/src/v4/core/tests/locales/fr.test.ts +72 -0
- package/node_modules/zod/src/v4/core/tests/locales/he.test.ts +379 -0
- package/node_modules/zod/src/v4/core/tests/locales/hr.test.ts +163 -0
- package/node_modules/zod/src/v4/core/tests/locales/nl.test.ts +46 -0
- package/node_modules/zod/src/v4/core/tests/locales/ru.test.ts +128 -0
- package/node_modules/zod/src/v4/core/tests/locales/tr.test.ts +69 -0
- package/node_modules/zod/src/v4/core/tests/locales/uz.test.ts +105 -0
- package/node_modules/zod/src/v4/core/tests/record-constructor.test.ts +125 -0
- package/node_modules/zod/src/v4/core/tests/recursive-tuples.test.ts +45 -0
- package/node_modules/zod/src/v4/core/to-json-schema.ts +622 -0
- package/node_modules/zod/src/v4/core/util.ts +983 -0
- package/node_modules/zod/src/v4/core/versions.ts +5 -0
- package/node_modules/zod/src/v4/core/zsf.ts +323 -0
- package/node_modules/zod/src/v4/index.ts +4 -0
- package/node_modules/zod/src/v4/locales/ar.ts +115 -0
- package/node_modules/zod/src/v4/locales/az.ts +111 -0
- package/node_modules/zod/src/v4/locales/be.ts +176 -0
- package/node_modules/zod/src/v4/locales/bg.ts +128 -0
- package/node_modules/zod/src/v4/locales/ca.ts +116 -0
- package/node_modules/zod/src/v4/locales/cs.ts +118 -0
- package/node_modules/zod/src/v4/locales/da.ts +123 -0
- package/node_modules/zod/src/v4/locales/de.ts +116 -0
- package/node_modules/zod/src/v4/locales/el.ts +121 -0
- package/node_modules/zod/src/v4/locales/en.ts +123 -0
- package/node_modules/zod/src/v4/locales/eo.ts +118 -0
- package/node_modules/zod/src/v4/locales/es.ts +141 -0
- package/node_modules/zod/src/v4/locales/fa.ts +126 -0
- package/node_modules/zod/src/v4/locales/fi.ts +121 -0
- package/node_modules/zod/src/v4/locales/fr-CA.ts +116 -0
- package/node_modules/zod/src/v4/locales/fr.ts +132 -0
- package/node_modules/zod/src/v4/locales/he.ts +246 -0
- package/node_modules/zod/src/v4/locales/hr.ts +131 -0
- package/node_modules/zod/src/v4/locales/hu.ts +117 -0
- package/node_modules/zod/src/v4/locales/hy.ts +164 -0
- package/node_modules/zod/src/v4/locales/id.ts +115 -0
- package/node_modules/zod/src/v4/locales/index.ts +52 -0
- package/node_modules/zod/src/v4/locales/is.ts +119 -0
- package/node_modules/zod/src/v4/locales/it.ts +116 -0
- package/node_modules/zod/src/v4/locales/ja.ts +114 -0
- package/node_modules/zod/src/v4/locales/ka.ts +123 -0
- package/node_modules/zod/src/v4/locales/kh.ts +7 -0
- package/node_modules/zod/src/v4/locales/km.ts +119 -0
- package/node_modules/zod/src/v4/locales/ko.ts +121 -0
- package/node_modules/zod/src/v4/locales/lt.ts +239 -0
- package/node_modules/zod/src/v4/locales/mk.ts +118 -0
- package/node_modules/zod/src/v4/locales/ms.ts +115 -0
- package/node_modules/zod/src/v4/locales/nl.ts +121 -0
- package/node_modules/zod/src/v4/locales/no.ts +116 -0
- package/node_modules/zod/src/v4/locales/ota.ts +117 -0
- package/node_modules/zod/src/v4/locales/pl.ts +118 -0
- package/node_modules/zod/src/v4/locales/ps.ts +126 -0
- package/node_modules/zod/src/v4/locales/pt.ts +116 -0
- package/node_modules/zod/src/v4/locales/ro.ts +129 -0
- package/node_modules/zod/src/v4/locales/ru.ts +176 -0
- package/node_modules/zod/src/v4/locales/sl.ts +118 -0
- package/node_modules/zod/src/v4/locales/sv.ts +119 -0
- package/node_modules/zod/src/v4/locales/ta.ts +118 -0
- package/node_modules/zod/src/v4/locales/th.ts +119 -0
- package/node_modules/zod/src/v4/locales/tr.ts +111 -0
- package/node_modules/zod/src/v4/locales/ua.ts +7 -0
- package/node_modules/zod/src/v4/locales/uk.ts +117 -0
- package/node_modules/zod/src/v4/locales/ur.ts +119 -0
- package/node_modules/zod/src/v4/locales/uz.ts +117 -0
- package/node_modules/zod/src/v4/locales/vi.ts +117 -0
- package/node_modules/zod/src/v4/locales/yo.ts +124 -0
- package/node_modules/zod/src/v4/locales/zh-CN.ts +116 -0
- package/node_modules/zod/src/v4/locales/zh-TW.ts +115 -0
- package/node_modules/zod/src/v4/mini/checks.ts +32 -0
- package/node_modules/zod/src/v4/mini/coerce.ts +27 -0
- package/node_modules/zod/src/v4/mini/external.ts +41 -0
- package/node_modules/zod/src/v4/mini/index.ts +3 -0
- package/node_modules/zod/src/v4/mini/iso.ts +66 -0
- package/node_modules/zod/src/v4/mini/parse.ts +14 -0
- package/node_modules/zod/src/v4/mini/schemas.ts +1947 -0
- package/node_modules/zod/src/v4/mini/tests/apply.test.ts +24 -0
- package/node_modules/zod/src/v4/mini/tests/assignability.test.ts +129 -0
- package/node_modules/zod/src/v4/mini/tests/brand.test.ts +94 -0
- package/node_modules/zod/src/v4/mini/tests/checks.test.ts +144 -0
- package/node_modules/zod/src/v4/mini/tests/codec.test.ts +548 -0
- package/node_modules/zod/src/v4/mini/tests/computed.test.ts +36 -0
- package/node_modules/zod/src/v4/mini/tests/error.test.ts +22 -0
- package/node_modules/zod/src/v4/mini/tests/functions.test.ts +5 -0
- package/node_modules/zod/src/v4/mini/tests/index.test.ts +993 -0
- package/node_modules/zod/src/v4/mini/tests/number.test.ts +95 -0
- package/node_modules/zod/src/v4/mini/tests/object.test.ts +227 -0
- package/node_modules/zod/src/v4/mini/tests/prototypes.test.ts +43 -0
- package/node_modules/zod/src/v4/mini/tests/recursive-types.test.ts +325 -0
- package/node_modules/zod/src/v4/mini/tests/standard-schema.test.ts +50 -0
- package/node_modules/zod/src/v4/mini/tests/string.test.ts +352 -0
- package/node_modules/zod/src/v4-mini/index.ts +3 -0
- package/node_modules/zod/v3/ZodError.cjs +138 -0
- package/node_modules/zod/v3/ZodError.d.cts +164 -0
- package/node_modules/zod/v3/ZodError.d.ts +164 -0
- package/node_modules/zod/v3/ZodError.js +133 -0
- package/node_modules/zod/v3/errors.cjs +17 -0
- package/node_modules/zod/v3/errors.d.cts +5 -0
- package/node_modules/zod/v3/errors.d.ts +5 -0
- package/node_modules/zod/v3/errors.js +9 -0
- package/node_modules/zod/v3/external.cjs +22 -0
- package/node_modules/zod/v3/external.d.cts +6 -0
- package/node_modules/zod/v3/external.d.ts +6 -0
- package/node_modules/zod/v3/external.js +6 -0
- package/node_modules/zod/v3/helpers/enumUtil.cjs +2 -0
- package/node_modules/zod/v3/helpers/enumUtil.d.cts +8 -0
- package/node_modules/zod/v3/helpers/enumUtil.d.ts +8 -0
- package/node_modules/zod/v3/helpers/enumUtil.js +1 -0
- package/node_modules/zod/v3/helpers/errorUtil.cjs +9 -0
- package/node_modules/zod/v3/helpers/errorUtil.d.cts +9 -0
- package/node_modules/zod/v3/helpers/errorUtil.d.ts +9 -0
- package/node_modules/zod/v3/helpers/errorUtil.js +6 -0
- package/node_modules/zod/v3/helpers/parseUtil.cjs +124 -0
- package/node_modules/zod/v3/helpers/parseUtil.d.cts +78 -0
- package/node_modules/zod/v3/helpers/parseUtil.d.ts +78 -0
- package/node_modules/zod/v3/helpers/parseUtil.js +109 -0
- package/node_modules/zod/v3/helpers/partialUtil.cjs +2 -0
- package/node_modules/zod/v3/helpers/partialUtil.d.cts +8 -0
- package/node_modules/zod/v3/helpers/partialUtil.d.ts +8 -0
- package/node_modules/zod/v3/helpers/partialUtil.js +1 -0
- package/node_modules/zod/v3/helpers/typeAliases.cjs +2 -0
- package/node_modules/zod/v3/helpers/typeAliases.d.cts +2 -0
- package/node_modules/zod/v3/helpers/typeAliases.d.ts +2 -0
- package/node_modules/zod/v3/helpers/typeAliases.js +1 -0
- package/node_modules/zod/v3/helpers/util.cjs +137 -0
- package/node_modules/zod/v3/helpers/util.d.cts +85 -0
- package/node_modules/zod/v3/helpers/util.d.ts +85 -0
- package/node_modules/zod/v3/helpers/util.js +133 -0
- package/node_modules/zod/v3/index.cjs +33 -0
- package/node_modules/zod/v3/index.d.cts +4 -0
- package/node_modules/zod/v3/index.d.ts +4 -0
- package/node_modules/zod/v3/index.js +4 -0
- package/node_modules/zod/v3/locales/en.cjs +112 -0
- package/node_modules/zod/v3/locales/en.d.cts +3 -0
- package/node_modules/zod/v3/locales/en.d.ts +3 -0
- package/node_modules/zod/v3/locales/en.js +109 -0
- package/node_modules/zod/v3/package.json +7 -0
- package/node_modules/zod/v3/standard-schema.cjs +2 -0
- package/node_modules/zod/v3/standard-schema.d.cts +102 -0
- package/node_modules/zod/v3/standard-schema.d.ts +102 -0
- package/node_modules/zod/v3/standard-schema.js +1 -0
- package/node_modules/zod/v3/types.cjs +3777 -0
- package/node_modules/zod/v3/types.d.cts +1034 -0
- package/node_modules/zod/v3/types.d.ts +1034 -0
- package/node_modules/zod/v3/types.js +3695 -0
- package/node_modules/zod/v4/classic/checks.cjs +33 -0
- package/node_modules/zod/v4/classic/checks.d.cts +1 -0
- package/node_modules/zod/v4/classic/checks.d.ts +1 -0
- package/node_modules/zod/v4/classic/checks.js +1 -0
- package/node_modules/zod/v4/classic/coerce.cjs +47 -0
- package/node_modules/zod/v4/classic/coerce.d.cts +17 -0
- package/node_modules/zod/v4/classic/coerce.d.ts +17 -0
- package/node_modules/zod/v4/classic/coerce.js +17 -0
- package/node_modules/zod/v4/classic/compat.cjs +61 -0
- package/node_modules/zod/v4/classic/compat.d.cts +50 -0
- package/node_modules/zod/v4/classic/compat.d.ts +50 -0
- package/node_modules/zod/v4/classic/compat.js +31 -0
- package/node_modules/zod/v4/classic/errors.cjs +74 -0
- package/node_modules/zod/v4/classic/errors.d.cts +30 -0
- package/node_modules/zod/v4/classic/errors.d.ts +30 -0
- package/node_modules/zod/v4/classic/errors.js +48 -0
- package/node_modules/zod/v4/classic/external.cjs +73 -0
- package/node_modules/zod/v4/classic/external.d.cts +16 -0
- package/node_modules/zod/v4/classic/external.d.ts +16 -0
- package/node_modules/zod/v4/classic/external.js +20 -0
- package/node_modules/zod/v4/classic/from-json-schema.cjs +625 -0
- package/node_modules/zod/v4/classic/from-json-schema.d.cts +12 -0
- package/node_modules/zod/v4/classic/from-json-schema.d.ts +12 -0
- package/node_modules/zod/v4/classic/from-json-schema.js +599 -0
- package/node_modules/zod/v4/classic/index.cjs +33 -0
- package/node_modules/zod/v4/classic/index.d.cts +4 -0
- package/node_modules/zod/v4/classic/index.d.ts +4 -0
- package/node_modules/zod/v4/classic/index.js +4 -0
- package/node_modules/zod/v4/classic/iso.cjs +60 -0
- package/node_modules/zod/v4/classic/iso.d.cts +22 -0
- package/node_modules/zod/v4/classic/iso.d.ts +22 -0
- package/node_modules/zod/v4/classic/iso.js +30 -0
- package/node_modules/zod/v4/classic/package.json +7 -0
- package/node_modules/zod/v4/classic/parse.cjs +41 -0
- package/node_modules/zod/v4/classic/parse.d.cts +31 -0
- package/node_modules/zod/v4/classic/parse.d.ts +31 -0
- package/node_modules/zod/v4/classic/parse.js +15 -0
- package/node_modules/zod/v4/classic/schemas.cjs +1511 -0
- package/node_modules/zod/v4/classic/schemas.d.cts +767 -0
- package/node_modules/zod/v4/classic/schemas.d.ts +767 -0
- package/node_modules/zod/v4/classic/schemas.js +1395 -0
- package/node_modules/zod/v4/core/api.cjs +1227 -0
- package/node_modules/zod/v4/core/api.d.cts +325 -0
- package/node_modules/zod/v4/core/api.d.ts +325 -0
- package/node_modules/zod/v4/core/api.js +1087 -0
- package/node_modules/zod/v4/core/checks.cjs +601 -0
- package/node_modules/zod/v4/core/checks.d.cts +278 -0
- package/node_modules/zod/v4/core/checks.d.ts +278 -0
- package/node_modules/zod/v4/core/checks.js +575 -0
- package/node_modules/zod/v4/core/core.cjs +85 -0
- package/node_modules/zod/v4/core/core.d.cts +70 -0
- package/node_modules/zod/v4/core/core.d.ts +70 -0
- package/node_modules/zod/v4/core/core.js +78 -0
- package/node_modules/zod/v4/core/doc.cjs +39 -0
- package/node_modules/zod/v4/core/doc.d.cts +14 -0
- package/node_modules/zod/v4/core/doc.d.ts +14 -0
- package/node_modules/zod/v4/core/doc.js +35 -0
- package/node_modules/zod/v4/core/errors.cjs +216 -0
- package/node_modules/zod/v4/core/errors.d.cts +221 -0
- package/node_modules/zod/v4/core/errors.d.ts +221 -0
- package/node_modules/zod/v4/core/errors.js +185 -0
- package/node_modules/zod/v4/core/index.cjs +47 -0
- package/node_modules/zod/v4/core/index.d.cts +16 -0
- package/node_modules/zod/v4/core/index.d.ts +16 -0
- package/node_modules/zod/v4/core/index.js +16 -0
- package/node_modules/zod/v4/core/json-schema-generator.cjs +99 -0
- package/node_modules/zod/v4/core/json-schema-generator.d.cts +65 -0
- package/node_modules/zod/v4/core/json-schema-generator.d.ts +65 -0
- package/node_modules/zod/v4/core/json-schema-generator.js +95 -0
- package/node_modules/zod/v4/core/json-schema-processors.cjs +644 -0
- package/node_modules/zod/v4/core/json-schema-processors.d.cts +49 -0
- package/node_modules/zod/v4/core/json-schema-processors.d.ts +49 -0
- package/node_modules/zod/v4/core/json-schema-processors.js +601 -0
- package/node_modules/zod/v4/core/json-schema.cjs +2 -0
- package/node_modules/zod/v4/core/json-schema.d.cts +88 -0
- package/node_modules/zod/v4/core/json-schema.d.ts +88 -0
- package/node_modules/zod/v4/core/json-schema.js +1 -0
- package/node_modules/zod/v4/core/package.json +7 -0
- package/node_modules/zod/v4/core/parse.cjs +131 -0
- package/node_modules/zod/v4/core/parse.d.cts +49 -0
- package/node_modules/zod/v4/core/parse.d.ts +49 -0
- package/node_modules/zod/v4/core/parse.js +93 -0
- package/node_modules/zod/v4/core/regexes.cjs +172 -0
- package/node_modules/zod/v4/core/regexes.d.cts +85 -0
- package/node_modules/zod/v4/core/regexes.d.ts +85 -0
- package/node_modules/zod/v4/core/regexes.js +139 -0
- package/node_modules/zod/v4/core/registries.cjs +56 -0
- package/node_modules/zod/v4/core/registries.d.cts +35 -0
- package/node_modules/zod/v4/core/registries.d.ts +35 -0
- package/node_modules/zod/v4/core/registries.js +51 -0
- package/node_modules/zod/v4/core/schemas.cjs +2270 -0
- package/node_modules/zod/v4/core/schemas.d.cts +1184 -0
- package/node_modules/zod/v4/core/schemas.d.ts +1184 -0
- package/node_modules/zod/v4/core/schemas.js +2239 -0
- package/node_modules/zod/v4/core/standard-schema.cjs +2 -0
- package/node_modules/zod/v4/core/standard-schema.d.cts +126 -0
- package/node_modules/zod/v4/core/standard-schema.d.ts +126 -0
- package/node_modules/zod/v4/core/standard-schema.js +1 -0
- package/node_modules/zod/v4/core/to-json-schema.cjs +457 -0
- package/node_modules/zod/v4/core/to-json-schema.d.cts +114 -0
- package/node_modules/zod/v4/core/to-json-schema.d.ts +114 -0
- package/node_modules/zod/v4/core/to-json-schema.js +448 -0
- package/node_modules/zod/v4/core/util.cjs +734 -0
- package/node_modules/zod/v4/core/util.d.cts +200 -0
- package/node_modules/zod/v4/core/util.d.ts +200 -0
- package/node_modules/zod/v4/core/util.js +674 -0
- package/node_modules/zod/v4/core/versions.cjs +8 -0
- package/node_modules/zod/v4/core/versions.d.cts +5 -0
- package/node_modules/zod/v4/core/versions.d.ts +5 -0
- package/node_modules/zod/v4/core/versions.js +5 -0
- package/node_modules/zod/v4/index.cjs +22 -0
- package/node_modules/zod/v4/index.d.cts +3 -0
- package/node_modules/zod/v4/index.d.ts +3 -0
- package/node_modules/zod/v4/index.js +3 -0
- package/node_modules/zod/v4/locales/ar.cjs +133 -0
- package/node_modules/zod/v4/locales/ar.d.cts +5 -0
- package/node_modules/zod/v4/locales/ar.d.ts +4 -0
- package/node_modules/zod/v4/locales/ar.js +106 -0
- package/node_modules/zod/v4/locales/az.cjs +132 -0
- package/node_modules/zod/v4/locales/az.d.cts +5 -0
- package/node_modules/zod/v4/locales/az.d.ts +4 -0
- package/node_modules/zod/v4/locales/az.js +105 -0
- package/node_modules/zod/v4/locales/be.cjs +183 -0
- package/node_modules/zod/v4/locales/be.d.cts +5 -0
- package/node_modules/zod/v4/locales/be.d.ts +4 -0
- package/node_modules/zod/v4/locales/be.js +156 -0
- package/node_modules/zod/v4/locales/bg.cjs +147 -0
- package/node_modules/zod/v4/locales/bg.d.cts +5 -0
- package/node_modules/zod/v4/locales/bg.d.ts +4 -0
- package/node_modules/zod/v4/locales/bg.js +120 -0
- package/node_modules/zod/v4/locales/ca.cjs +134 -0
- package/node_modules/zod/v4/locales/ca.d.cts +5 -0
- package/node_modules/zod/v4/locales/ca.d.ts +4 -0
- package/node_modules/zod/v4/locales/ca.js +107 -0
- package/node_modules/zod/v4/locales/cs.cjs +138 -0
- package/node_modules/zod/v4/locales/cs.d.cts +5 -0
- package/node_modules/zod/v4/locales/cs.d.ts +4 -0
- package/node_modules/zod/v4/locales/cs.js +111 -0
- package/node_modules/zod/v4/locales/da.cjs +142 -0
- package/node_modules/zod/v4/locales/da.d.cts +5 -0
- package/node_modules/zod/v4/locales/da.d.ts +4 -0
- package/node_modules/zod/v4/locales/da.js +115 -0
- package/node_modules/zod/v4/locales/de.cjs +135 -0
- package/node_modules/zod/v4/locales/de.d.cts +5 -0
- package/node_modules/zod/v4/locales/de.d.ts +4 -0
- package/node_modules/zod/v4/locales/de.js +108 -0
- package/node_modules/zod/v4/locales/el.cjs +136 -0
- package/node_modules/zod/v4/locales/el.d.cts +5 -0
- package/node_modules/zod/v4/locales/el.d.ts +4 -0
- package/node_modules/zod/v4/locales/el.js +109 -0
- package/node_modules/zod/v4/locales/en.cjs +140 -0
- package/node_modules/zod/v4/locales/en.d.cts +5 -0
- package/node_modules/zod/v4/locales/en.d.ts +4 -0
- package/node_modules/zod/v4/locales/en.js +113 -0
- package/node_modules/zod/v4/locales/eo.cjs +136 -0
- package/node_modules/zod/v4/locales/eo.d.cts +5 -0
- package/node_modules/zod/v4/locales/eo.d.ts +4 -0
- package/node_modules/zod/v4/locales/eo.js +109 -0
- package/node_modules/zod/v4/locales/es.cjs +159 -0
- package/node_modules/zod/v4/locales/es.d.cts +5 -0
- package/node_modules/zod/v4/locales/es.d.ts +4 -0
- package/node_modules/zod/v4/locales/es.js +132 -0
- package/node_modules/zod/v4/locales/fa.cjs +141 -0
- package/node_modules/zod/v4/locales/fa.d.cts +5 -0
- package/node_modules/zod/v4/locales/fa.d.ts +4 -0
- package/node_modules/zod/v4/locales/fa.js +114 -0
- package/node_modules/zod/v4/locales/fi.cjs +139 -0
- package/node_modules/zod/v4/locales/fi.d.cts +5 -0
- package/node_modules/zod/v4/locales/fi.d.ts +4 -0
- package/node_modules/zod/v4/locales/fi.js +112 -0
- package/node_modules/zod/v4/locales/fr-CA.cjs +134 -0
- package/node_modules/zod/v4/locales/fr-CA.d.cts +5 -0
- package/node_modules/zod/v4/locales/fr-CA.d.ts +4 -0
- package/node_modules/zod/v4/locales/fr-CA.js +107 -0
- package/node_modules/zod/v4/locales/fr.cjs +152 -0
- package/node_modules/zod/v4/locales/fr.d.cts +5 -0
- package/node_modules/zod/v4/locales/fr.d.ts +4 -0
- package/node_modules/zod/v4/locales/fr.js +125 -0
- package/node_modules/zod/v4/locales/he.cjs +241 -0
- package/node_modules/zod/v4/locales/he.d.cts +5 -0
- package/node_modules/zod/v4/locales/he.d.ts +4 -0
- package/node_modules/zod/v4/locales/he.js +214 -0
- package/node_modules/zod/v4/locales/hr.cjs +149 -0
- package/node_modules/zod/v4/locales/hr.d.cts +5 -0
- package/node_modules/zod/v4/locales/hr.d.ts +4 -0
- package/node_modules/zod/v4/locales/hr.js +122 -0
- package/node_modules/zod/v4/locales/hu.cjs +135 -0
- package/node_modules/zod/v4/locales/hu.d.cts +5 -0
- package/node_modules/zod/v4/locales/hu.d.ts +4 -0
- package/node_modules/zod/v4/locales/hu.js +108 -0
- package/node_modules/zod/v4/locales/hy.cjs +174 -0
- package/node_modules/zod/v4/locales/hy.d.cts +5 -0
- package/node_modules/zod/v4/locales/hy.d.ts +4 -0
- package/node_modules/zod/v4/locales/hy.js +147 -0
- package/node_modules/zod/v4/locales/id.cjs +133 -0
- package/node_modules/zod/v4/locales/id.d.cts +5 -0
- package/node_modules/zod/v4/locales/id.d.ts +4 -0
- package/node_modules/zod/v4/locales/id.js +106 -0
- package/node_modules/zod/v4/locales/index.cjs +111 -0
- package/node_modules/zod/v4/locales/index.d.cts +52 -0
- package/node_modules/zod/v4/locales/index.d.ts +52 -0
- package/node_modules/zod/v4/locales/index.js +52 -0
- package/node_modules/zod/v4/locales/is.cjs +136 -0
- package/node_modules/zod/v4/locales/is.d.cts +5 -0
- package/node_modules/zod/v4/locales/is.d.ts +4 -0
- package/node_modules/zod/v4/locales/is.js +109 -0
- package/node_modules/zod/v4/locales/it.cjs +135 -0
- package/node_modules/zod/v4/locales/it.d.cts +5 -0
- package/node_modules/zod/v4/locales/it.d.ts +4 -0
- package/node_modules/zod/v4/locales/it.js +108 -0
- package/node_modules/zod/v4/locales/ja.cjs +134 -0
- package/node_modules/zod/v4/locales/ja.d.cts +5 -0
- package/node_modules/zod/v4/locales/ja.d.ts +4 -0
- package/node_modules/zod/v4/locales/ja.js +107 -0
- package/node_modules/zod/v4/locales/ka.cjs +139 -0
- package/node_modules/zod/v4/locales/ka.d.cts +5 -0
- package/node_modules/zod/v4/locales/ka.d.ts +4 -0
- package/node_modules/zod/v4/locales/ka.js +112 -0
- package/node_modules/zod/v4/locales/kh.cjs +12 -0
- package/node_modules/zod/v4/locales/kh.d.cts +5 -0
- package/node_modules/zod/v4/locales/kh.d.ts +5 -0
- package/node_modules/zod/v4/locales/kh.js +5 -0
- package/node_modules/zod/v4/locales/km.cjs +137 -0
- package/node_modules/zod/v4/locales/km.d.cts +5 -0
- package/node_modules/zod/v4/locales/km.d.ts +4 -0
- package/node_modules/zod/v4/locales/km.js +110 -0
- package/node_modules/zod/v4/locales/ko.cjs +138 -0
- package/node_modules/zod/v4/locales/ko.d.cts +5 -0
- package/node_modules/zod/v4/locales/ko.d.ts +4 -0
- package/node_modules/zod/v4/locales/ko.js +111 -0
- package/node_modules/zod/v4/locales/lt.cjs +230 -0
- package/node_modules/zod/v4/locales/lt.d.cts +5 -0
- package/node_modules/zod/v4/locales/lt.d.ts +4 -0
- package/node_modules/zod/v4/locales/lt.js +203 -0
- package/node_modules/zod/v4/locales/mk.cjs +136 -0
- package/node_modules/zod/v4/locales/mk.d.cts +5 -0
- package/node_modules/zod/v4/locales/mk.d.ts +4 -0
- package/node_modules/zod/v4/locales/mk.js +109 -0
- package/node_modules/zod/v4/locales/ms.cjs +134 -0
- package/node_modules/zod/v4/locales/ms.d.cts +5 -0
- package/node_modules/zod/v4/locales/ms.d.ts +4 -0
- package/node_modules/zod/v4/locales/ms.js +107 -0
- package/node_modules/zod/v4/locales/nl.cjs +137 -0
- package/node_modules/zod/v4/locales/nl.d.cts +5 -0
- package/node_modules/zod/v4/locales/nl.d.ts +4 -0
- package/node_modules/zod/v4/locales/nl.js +110 -0
- package/node_modules/zod/v4/locales/no.cjs +135 -0
- package/node_modules/zod/v4/locales/no.d.cts +5 -0
- package/node_modules/zod/v4/locales/no.d.ts +4 -0
- package/node_modules/zod/v4/locales/no.js +108 -0
- package/node_modules/zod/v4/locales/ota.cjs +136 -0
- package/node_modules/zod/v4/locales/ota.d.cts +5 -0
- package/node_modules/zod/v4/locales/ota.d.ts +4 -0
- package/node_modules/zod/v4/locales/ota.js +109 -0
- package/node_modules/zod/v4/locales/package.json +7 -0
- package/node_modules/zod/v4/locales/pl.cjs +136 -0
- package/node_modules/zod/v4/locales/pl.d.cts +5 -0
- package/node_modules/zod/v4/locales/pl.d.ts +4 -0
- package/node_modules/zod/v4/locales/pl.js +109 -0
- package/node_modules/zod/v4/locales/ps.cjs +141 -0
- package/node_modules/zod/v4/locales/ps.d.cts +5 -0
- package/node_modules/zod/v4/locales/ps.d.ts +4 -0
- package/node_modules/zod/v4/locales/ps.js +114 -0
- package/node_modules/zod/v4/locales/pt.cjs +135 -0
- package/node_modules/zod/v4/locales/pt.d.cts +5 -0
- package/node_modules/zod/v4/locales/pt.d.ts +4 -0
- package/node_modules/zod/v4/locales/pt.js +108 -0
- package/node_modules/zod/v4/locales/ro.cjs +146 -0
- package/node_modules/zod/v4/locales/ro.d.cts +5 -0
- package/node_modules/zod/v4/locales/ro.d.ts +4 -0
- package/node_modules/zod/v4/locales/ro.js +119 -0
- package/node_modules/zod/v4/locales/ru.cjs +183 -0
- package/node_modules/zod/v4/locales/ru.d.cts +5 -0
- package/node_modules/zod/v4/locales/ru.d.ts +4 -0
- package/node_modules/zod/v4/locales/ru.js +156 -0
- package/node_modules/zod/v4/locales/sl.cjs +136 -0
- package/node_modules/zod/v4/locales/sl.d.cts +5 -0
- package/node_modules/zod/v4/locales/sl.d.ts +4 -0
- package/node_modules/zod/v4/locales/sl.js +109 -0
- package/node_modules/zod/v4/locales/sv.cjs +137 -0
- package/node_modules/zod/v4/locales/sv.d.cts +5 -0
- package/node_modules/zod/v4/locales/sv.d.ts +4 -0
- package/node_modules/zod/v4/locales/sv.js +110 -0
- package/node_modules/zod/v4/locales/ta.cjs +137 -0
- package/node_modules/zod/v4/locales/ta.d.cts +5 -0
- package/node_modules/zod/v4/locales/ta.d.ts +4 -0
- package/node_modules/zod/v4/locales/ta.js +110 -0
- package/node_modules/zod/v4/locales/th.cjs +137 -0
- package/node_modules/zod/v4/locales/th.d.cts +5 -0
- package/node_modules/zod/v4/locales/th.d.ts +4 -0
- package/node_modules/zod/v4/locales/th.js +110 -0
- package/node_modules/zod/v4/locales/tr.cjs +132 -0
- package/node_modules/zod/v4/locales/tr.d.cts +5 -0
- package/node_modules/zod/v4/locales/tr.d.ts +4 -0
- package/node_modules/zod/v4/locales/tr.js +105 -0
- package/node_modules/zod/v4/locales/ua.cjs +12 -0
- package/node_modules/zod/v4/locales/ua.d.cts +5 -0
- package/node_modules/zod/v4/locales/ua.d.ts +5 -0
- package/node_modules/zod/v4/locales/ua.js +5 -0
- package/node_modules/zod/v4/locales/uk.cjs +135 -0
- package/node_modules/zod/v4/locales/uk.d.cts +5 -0
- package/node_modules/zod/v4/locales/uk.d.ts +4 -0
- package/node_modules/zod/v4/locales/uk.js +108 -0
- package/node_modules/zod/v4/locales/ur.cjs +137 -0
- package/node_modules/zod/v4/locales/ur.d.cts +5 -0
- package/node_modules/zod/v4/locales/ur.d.ts +4 -0
- package/node_modules/zod/v4/locales/ur.js +110 -0
- package/node_modules/zod/v4/locales/uz.cjs +137 -0
- package/node_modules/zod/v4/locales/uz.d.cts +5 -0
- package/node_modules/zod/v4/locales/uz.d.ts +4 -0
- package/node_modules/zod/v4/locales/uz.js +110 -0
- package/node_modules/zod/v4/locales/vi.cjs +135 -0
- package/node_modules/zod/v4/locales/vi.d.cts +5 -0
- package/node_modules/zod/v4/locales/vi.d.ts +4 -0
- package/node_modules/zod/v4/locales/vi.js +108 -0
- package/node_modules/zod/v4/locales/yo.cjs +134 -0
- package/node_modules/zod/v4/locales/yo.d.cts +5 -0
- package/node_modules/zod/v4/locales/yo.d.ts +4 -0
- package/node_modules/zod/v4/locales/yo.js +107 -0
- package/node_modules/zod/v4/locales/zh-CN.cjs +136 -0
- package/node_modules/zod/v4/locales/zh-CN.d.cts +5 -0
- package/node_modules/zod/v4/locales/zh-CN.d.ts +4 -0
- package/node_modules/zod/v4/locales/zh-CN.js +109 -0
- package/node_modules/zod/v4/locales/zh-TW.cjs +134 -0
- package/node_modules/zod/v4/locales/zh-TW.d.cts +5 -0
- package/node_modules/zod/v4/locales/zh-TW.d.ts +4 -0
- package/node_modules/zod/v4/locales/zh-TW.js +107 -0
- package/node_modules/zod/v4/mini/checks.cjs +34 -0
- package/node_modules/zod/v4/mini/checks.d.cts +1 -0
- package/node_modules/zod/v4/mini/checks.d.ts +1 -0
- package/node_modules/zod/v4/mini/checks.js +1 -0
- package/node_modules/zod/v4/mini/coerce.cjs +52 -0
- package/node_modules/zod/v4/mini/coerce.d.cts +7 -0
- package/node_modules/zod/v4/mini/coerce.d.ts +7 -0
- package/node_modules/zod/v4/mini/coerce.js +22 -0
- package/node_modules/zod/v4/mini/external.cjs +63 -0
- package/node_modules/zod/v4/mini/external.d.cts +13 -0
- package/node_modules/zod/v4/mini/external.d.ts +13 -0
- package/node_modules/zod/v4/mini/external.js +14 -0
- package/node_modules/zod/v4/mini/index.cjs +32 -0
- package/node_modules/zod/v4/mini/index.d.cts +3 -0
- package/node_modules/zod/v4/mini/index.d.ts +3 -0
- package/node_modules/zod/v4/mini/index.js +3 -0
- package/node_modules/zod/v4/mini/iso.cjs +64 -0
- package/node_modules/zod/v4/mini/iso.d.cts +22 -0
- package/node_modules/zod/v4/mini/iso.d.ts +22 -0
- package/node_modules/zod/v4/mini/iso.js +34 -0
- package/node_modules/zod/v4/mini/package.json +7 -0
- package/node_modules/zod/v4/mini/parse.cjs +16 -0
- package/node_modules/zod/v4/mini/parse.d.cts +1 -0
- package/node_modules/zod/v4/mini/parse.d.ts +1 -0
- package/node_modules/zod/v4/mini/parse.js +1 -0
- package/node_modules/zod/v4/mini/schemas.cjs +1083 -0
- package/node_modules/zod/v4/mini/schemas.d.cts +445 -0
- package/node_modules/zod/v4/mini/schemas.d.ts +445 -0
- package/node_modules/zod/v4/mini/schemas.js +961 -0
- package/node_modules/zod/v4/package.json +7 -0
- package/node_modules/zod/v4-mini/index.cjs +32 -0
- package/node_modules/zod/v4-mini/index.d.cts +3 -0
- package/node_modules/zod/v4-mini/index.d.ts +3 -0
- package/node_modules/zod/v4-mini/index.js +3 -0
- package/node_modules/zod/v4-mini/package.json +7 -0
- package/npm-shrinkwrap.json +137 -0
- package/package.json +9 -8
|
@@ -0,0 +1,1439 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* [AES](https://en.wikipedia.org/wiki/Advanced_Encryption_Standard)
|
|
3
|
+
* a.k.a. Advanced Encryption Standard
|
|
4
|
+
* is a variant of Rijndael block cipher, standardized by NIST in 2001.
|
|
5
|
+
* We provide the fastest available pure JS implementation.
|
|
6
|
+
*
|
|
7
|
+
* `cipher = encrypt(block, key)`
|
|
8
|
+
*
|
|
9
|
+
* Data is split into 128-bit blocks. Encrypted in 10/12/14 rounds (128/192/256 bits). In every round:
|
|
10
|
+
* 1. **S-box**, table substitution
|
|
11
|
+
* 2. **Shift rows**, cyclic shift left of all rows of data array
|
|
12
|
+
* 3. **Mix columns**, multiplying every column by fixed polynomial
|
|
13
|
+
* 4. **Add round key**, round_key xor i-th column of array
|
|
14
|
+
*
|
|
15
|
+
* Check out [FIPS-197](https://csrc.nist.gov/files/pubs/fips/197/final/docs/fips-197.pdf),
|
|
16
|
+
* [NIST 800-38G](https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-38G.pdf)
|
|
17
|
+
* and [original proposal](https://csrc.nist.gov/csrc/media/projects/cryptographic-standards-and-guidelines/documents/aes-development/rijndael-ammended.pdf)
|
|
18
|
+
* @module
|
|
19
|
+
*/
|
|
20
|
+
import { ghash, polyval } from './_polyval.ts';
|
|
21
|
+
// prettier-ignore
|
|
22
|
+
import {
|
|
23
|
+
abytes, anumber, clean, complexOverlapBytes, concatBytes,
|
|
24
|
+
copyBytes, createView, equalBytes, getOutput, isAligned32, overlapBytes,
|
|
25
|
+
u32, u64Lengths, u8, wrapCipher,
|
|
26
|
+
type Cipher, type CipherWithOutput, type PRG, type Uint8ArrayBuffer
|
|
27
|
+
} from './utils.ts';
|
|
28
|
+
|
|
29
|
+
const BLOCK_SIZE = 16;
|
|
30
|
+
const BLOCK_SIZE32 = 4;
|
|
31
|
+
const EMPTY_BLOCK = /* @__PURE__ */ new Uint8Array(BLOCK_SIZE);
|
|
32
|
+
const ONE_BLOCK = /* @__PURE__ */ Uint8Array.from([
|
|
33
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
|
|
34
|
+
]);
|
|
35
|
+
const POLY = 0x11b; // 1 + x + x**3 + x**4 + x**8
|
|
36
|
+
|
|
37
|
+
function validateKeyLength(key: Uint8Array) {
|
|
38
|
+
if (![16, 24, 32].includes(key.length))
|
|
39
|
+
throw new Error('"aes key" expected Uint8Array of length 16/24/32, got length=' + key.length);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// TODO: remove multiplication, binary ops only
|
|
43
|
+
function mul2(n: number) {
|
|
44
|
+
return (n << 1) ^ (POLY & -(n >> 7));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function mul(a: number, b: number) {
|
|
48
|
+
let res = 0;
|
|
49
|
+
for (; b > 0; b >>= 1) {
|
|
50
|
+
// Montgomery ladder
|
|
51
|
+
res ^= a & -(b & 1); // if (b&1) res ^=a (but const-time).
|
|
52
|
+
a = mul2(a); // a = 2*a
|
|
53
|
+
}
|
|
54
|
+
return res;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Increments bigint with wrap around
|
|
58
|
+
// NOTE: we cannot use u32 here since it may overflow on carry!
|
|
59
|
+
const incBytes = (data: Uint8Array, isLE: boolean, carry: number = 1) => {
|
|
60
|
+
if (!Number.isSafeInteger(carry)) throw new Error('incBytes: wrong carry ' + carry);
|
|
61
|
+
abytes(data);
|
|
62
|
+
for (let i = 0; i < data.length; i++) {
|
|
63
|
+
const pos = !isLE ? data.length - 1 - i : i;
|
|
64
|
+
carry = (carry + (data[pos] & 0xff)) | 0;
|
|
65
|
+
data[pos] = carry & 0xff;
|
|
66
|
+
carry >>>= 8;
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
// AES S-box is generated using finite field inversion,
|
|
71
|
+
// an affine transform, and xor of a constant 0x63.
|
|
72
|
+
const sbox = /* @__PURE__ */ (() => {
|
|
73
|
+
const t = new Uint8Array(256);
|
|
74
|
+
for (let i = 0, x = 1; i < 256; i++, x ^= mul2(x)) t[i] = x;
|
|
75
|
+
const box = new Uint8Array(256);
|
|
76
|
+
box[0] = 0x63; // first elm
|
|
77
|
+
for (let i = 0; i < 255; i++) {
|
|
78
|
+
let x = t[255 - i];
|
|
79
|
+
x |= x << 8;
|
|
80
|
+
box[t[i]] = (x ^ (x >> 4) ^ (x >> 5) ^ (x >> 6) ^ (x >> 7) ^ 0x63) & 0xff;
|
|
81
|
+
}
|
|
82
|
+
clean(t);
|
|
83
|
+
return box;
|
|
84
|
+
})();
|
|
85
|
+
|
|
86
|
+
// Inverted S-box
|
|
87
|
+
const invSbox = /* @__PURE__ */ sbox.map((_, j) => sbox.indexOf(j));
|
|
88
|
+
|
|
89
|
+
// Rotate u32 by 8
|
|
90
|
+
const rotr32_8 = (n: number) => (n << 24) | (n >>> 8);
|
|
91
|
+
const rotl32_8 = (n: number) => (n << 8) | (n >>> 24);
|
|
92
|
+
// The byte swap operation for uint32 (LE<->BE)
|
|
93
|
+
const byteSwap = (word: number) =>
|
|
94
|
+
((word << 24) & 0xff000000) |
|
|
95
|
+
((word << 8) & 0xff0000) |
|
|
96
|
+
((word >>> 8) & 0xff00) |
|
|
97
|
+
((word >>> 24) & 0xff);
|
|
98
|
+
|
|
99
|
+
// T-table is optimization suggested in 5.2 of original proposal (missed from FIPS-197). Changes:
|
|
100
|
+
// - LE instead of BE
|
|
101
|
+
// - bigger tables: T0 and T1 are merged into T01 table and T2 & T3 into T23;
|
|
102
|
+
// so index is u16, instead of u8. This speeds up things, unexpectedly
|
|
103
|
+
function genTtable(sbox: Uint8Array, fn: (n: number) => number) {
|
|
104
|
+
if (sbox.length !== 256) throw new Error('Wrong sbox length');
|
|
105
|
+
const T0 = new Uint32Array(256).map((_, j) => fn(sbox[j]));
|
|
106
|
+
const T1 = T0.map(rotl32_8);
|
|
107
|
+
const T2 = T1.map(rotl32_8);
|
|
108
|
+
const T3 = T2.map(rotl32_8);
|
|
109
|
+
const T01 = new Uint32Array(256 * 256);
|
|
110
|
+
const T23 = new Uint32Array(256 * 256);
|
|
111
|
+
const sbox2 = new Uint16Array(256 * 256);
|
|
112
|
+
for (let i = 0; i < 256; i++) {
|
|
113
|
+
for (let j = 0; j < 256; j++) {
|
|
114
|
+
const idx = i * 256 + j;
|
|
115
|
+
T01[idx] = T0[i] ^ T1[j];
|
|
116
|
+
T23[idx] = T2[i] ^ T3[j];
|
|
117
|
+
sbox2[idx] = (sbox[i] << 8) | sbox[j];
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return { sbox, sbox2, T0, T1, T2, T3, T01, T23 };
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const tableEncoding = /* @__PURE__ */ genTtable(
|
|
124
|
+
sbox,
|
|
125
|
+
(s: number) => (mul(s, 3) << 24) | (s << 16) | (s << 8) | mul(s, 2)
|
|
126
|
+
);
|
|
127
|
+
const tableDecoding = /* @__PURE__ */ genTtable(
|
|
128
|
+
invSbox,
|
|
129
|
+
(s) => (mul(s, 11) << 24) | (mul(s, 13) << 16) | (mul(s, 9) << 8) | mul(s, 14)
|
|
130
|
+
);
|
|
131
|
+
|
|
132
|
+
const xPowers = /* @__PURE__ */ (() => {
|
|
133
|
+
const p = new Uint8Array(16);
|
|
134
|
+
for (let i = 0, x = 1; i < 16; i++, x = mul2(x)) p[i] = x;
|
|
135
|
+
return p;
|
|
136
|
+
})();
|
|
137
|
+
|
|
138
|
+
/** Key expansion used in CTR. */
|
|
139
|
+
function expandKeyLE(key: Uint8Array): Uint32Array {
|
|
140
|
+
abytes(key);
|
|
141
|
+
const len = key.length;
|
|
142
|
+
validateKeyLength(key);
|
|
143
|
+
const { sbox2 } = tableEncoding;
|
|
144
|
+
const toClean = [];
|
|
145
|
+
if (!isAligned32(key)) toClean.push((key = copyBytes(key)));
|
|
146
|
+
const k32 = u32(key);
|
|
147
|
+
const Nk = k32.length;
|
|
148
|
+
const subByte = (n: number) => applySbox(sbox2, n, n, n, n);
|
|
149
|
+
const xk = new Uint32Array(len + 28); // expanded key
|
|
150
|
+
xk.set(k32);
|
|
151
|
+
// 4.3.1 Key expansion
|
|
152
|
+
for (let i = Nk; i < xk.length; i++) {
|
|
153
|
+
let t = xk[i - 1];
|
|
154
|
+
if (i % Nk === 0) t = subByte(rotr32_8(t)) ^ xPowers[i / Nk - 1];
|
|
155
|
+
else if (Nk > 6 && i % Nk === 4) t = subByte(t);
|
|
156
|
+
xk[i] = xk[i - Nk] ^ t;
|
|
157
|
+
}
|
|
158
|
+
clean(...toClean);
|
|
159
|
+
return xk;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function expandKeyDecLE(key: Uint8Array): Uint32Array {
|
|
163
|
+
const encKey = expandKeyLE(key);
|
|
164
|
+
const xk = encKey.slice();
|
|
165
|
+
const Nk = encKey.length;
|
|
166
|
+
const { sbox2 } = tableEncoding;
|
|
167
|
+
const { T0, T1, T2, T3 } = tableDecoding;
|
|
168
|
+
// Inverse key by chunks of 4 (rounds)
|
|
169
|
+
for (let i = 0; i < Nk; i += 4) {
|
|
170
|
+
for (let j = 0; j < 4; j++) xk[i + j] = encKey[Nk - i - 4 + j];
|
|
171
|
+
}
|
|
172
|
+
clean(encKey);
|
|
173
|
+
// apply InvMixColumn except first & last round
|
|
174
|
+
for (let i = 4; i < Nk - 4; i++) {
|
|
175
|
+
const x = xk[i];
|
|
176
|
+
const w = applySbox(sbox2, x, x, x, x);
|
|
177
|
+
xk[i] = T0[w & 0xff] ^ T1[(w >>> 8) & 0xff] ^ T2[(w >>> 16) & 0xff] ^ T3[w >>> 24];
|
|
178
|
+
}
|
|
179
|
+
return xk;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// Apply tables
|
|
183
|
+
function apply0123(
|
|
184
|
+
T01: Uint32Array,
|
|
185
|
+
T23: Uint32Array,
|
|
186
|
+
s0: number,
|
|
187
|
+
s1: number,
|
|
188
|
+
s2: number,
|
|
189
|
+
s3: number
|
|
190
|
+
) {
|
|
191
|
+
return (
|
|
192
|
+
T01[((s0 << 8) & 0xff00) | ((s1 >>> 8) & 0xff)] ^
|
|
193
|
+
T23[((s2 >>> 8) & 0xff00) | ((s3 >>> 24) & 0xff)]
|
|
194
|
+
);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
function applySbox(sbox2: Uint16Array, s0: number, s1: number, s2: number, s3: number) {
|
|
198
|
+
return (
|
|
199
|
+
sbox2[(s0 & 0xff) | (s1 & 0xff00)] |
|
|
200
|
+
(sbox2[((s2 >>> 16) & 0xff) | ((s3 >>> 16) & 0xff00)] << 16)
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
function encrypt(
|
|
205
|
+
xk: Uint32Array,
|
|
206
|
+
s0: number,
|
|
207
|
+
s1: number,
|
|
208
|
+
s2: number,
|
|
209
|
+
s3: number
|
|
210
|
+
): { s0: number; s1: number; s2: number; s3: number } {
|
|
211
|
+
const { sbox2, T01, T23 } = tableEncoding;
|
|
212
|
+
let k = 0;
|
|
213
|
+
((s0 ^= xk[k++]), (s1 ^= xk[k++]), (s2 ^= xk[k++]), (s3 ^= xk[k++]));
|
|
214
|
+
const rounds = xk.length / 4 - 2;
|
|
215
|
+
for (let i = 0; i < rounds; i++) {
|
|
216
|
+
const t0 = xk[k++] ^ apply0123(T01, T23, s0, s1, s2, s3);
|
|
217
|
+
const t1 = xk[k++] ^ apply0123(T01, T23, s1, s2, s3, s0);
|
|
218
|
+
const t2 = xk[k++] ^ apply0123(T01, T23, s2, s3, s0, s1);
|
|
219
|
+
const t3 = xk[k++] ^ apply0123(T01, T23, s3, s0, s1, s2);
|
|
220
|
+
((s0 = t0), (s1 = t1), (s2 = t2), (s3 = t3));
|
|
221
|
+
}
|
|
222
|
+
// last round (without mixcolumns, so using SBOX2 table)
|
|
223
|
+
const t0 = xk[k++] ^ applySbox(sbox2, s0, s1, s2, s3);
|
|
224
|
+
const t1 = xk[k++] ^ applySbox(sbox2, s1, s2, s3, s0);
|
|
225
|
+
const t2 = xk[k++] ^ applySbox(sbox2, s2, s3, s0, s1);
|
|
226
|
+
const t3 = xk[k++] ^ applySbox(sbox2, s3, s0, s1, s2);
|
|
227
|
+
return { s0: t0, s1: t1, s2: t2, s3: t3 };
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
// Can't be merged with encrypt: arg positions for apply0123 / applySbox are different
|
|
231
|
+
function decrypt(
|
|
232
|
+
xk: Uint32Array,
|
|
233
|
+
s0: number,
|
|
234
|
+
s1: number,
|
|
235
|
+
s2: number,
|
|
236
|
+
s3: number
|
|
237
|
+
): {
|
|
238
|
+
s0: number;
|
|
239
|
+
s1: number;
|
|
240
|
+
s2: number;
|
|
241
|
+
s3: number;
|
|
242
|
+
} {
|
|
243
|
+
const { sbox2, T01, T23 } = tableDecoding;
|
|
244
|
+
let k = 0;
|
|
245
|
+
((s0 ^= xk[k++]), (s1 ^= xk[k++]), (s2 ^= xk[k++]), (s3 ^= xk[k++]));
|
|
246
|
+
const rounds = xk.length / 4 - 2;
|
|
247
|
+
for (let i = 0; i < rounds; i++) {
|
|
248
|
+
const t0 = xk[k++] ^ apply0123(T01, T23, s0, s3, s2, s1);
|
|
249
|
+
const t1 = xk[k++] ^ apply0123(T01, T23, s1, s0, s3, s2);
|
|
250
|
+
const t2 = xk[k++] ^ apply0123(T01, T23, s2, s1, s0, s3);
|
|
251
|
+
const t3 = xk[k++] ^ apply0123(T01, T23, s3, s2, s1, s0);
|
|
252
|
+
((s0 = t0), (s1 = t1), (s2 = t2), (s3 = t3));
|
|
253
|
+
}
|
|
254
|
+
// Last round
|
|
255
|
+
const t0: number = xk[k++] ^ applySbox(sbox2, s0, s3, s2, s1);
|
|
256
|
+
const t1: number = xk[k++] ^ applySbox(sbox2, s1, s0, s3, s2);
|
|
257
|
+
const t2: number = xk[k++] ^ applySbox(sbox2, s2, s1, s0, s3);
|
|
258
|
+
const t3: number = xk[k++] ^ applySbox(sbox2, s3, s2, s1, s0);
|
|
259
|
+
return { s0: t0, s1: t1, s2: t2, s3: t3 };
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
// TODO: investigate merging with ctr32
|
|
263
|
+
function ctrCounter(
|
|
264
|
+
xk: Uint32Array,
|
|
265
|
+
nonce: Uint8Array,
|
|
266
|
+
src: Uint8Array,
|
|
267
|
+
dst?: Uint8Array
|
|
268
|
+
): Uint8Array {
|
|
269
|
+
abytes(nonce, BLOCK_SIZE, 'nonce');
|
|
270
|
+
abytes(src);
|
|
271
|
+
const srcLen = src.length;
|
|
272
|
+
dst = getOutput(srcLen, dst);
|
|
273
|
+
complexOverlapBytes(src, dst);
|
|
274
|
+
const ctr = nonce;
|
|
275
|
+
const c32 = u32(ctr);
|
|
276
|
+
// Fill block (empty, ctr=0)
|
|
277
|
+
let { s0, s1, s2, s3 } = encrypt(xk, c32[0], c32[1], c32[2], c32[3]);
|
|
278
|
+
const src32 = u32(src);
|
|
279
|
+
const dst32 = u32(dst);
|
|
280
|
+
// process blocks
|
|
281
|
+
for (let i = 0; i + 4 <= src32.length; i += 4) {
|
|
282
|
+
dst32[i + 0] = src32[i + 0] ^ s0;
|
|
283
|
+
dst32[i + 1] = src32[i + 1] ^ s1;
|
|
284
|
+
dst32[i + 2] = src32[i + 2] ^ s2;
|
|
285
|
+
dst32[i + 3] = src32[i + 3] ^ s3;
|
|
286
|
+
incBytes(ctr, false, 1); // Full 128 bit counter with wrap around
|
|
287
|
+
({ s0, s1, s2, s3 } = encrypt(xk, c32[0], c32[1], c32[2], c32[3]));
|
|
288
|
+
}
|
|
289
|
+
// leftovers (less than block)
|
|
290
|
+
// It's possible to handle > u32 fast, but is it worth it?
|
|
291
|
+
const start = BLOCK_SIZE * Math.floor(src32.length / BLOCK_SIZE32);
|
|
292
|
+
if (start < srcLen) {
|
|
293
|
+
const b32 = new Uint32Array([s0, s1, s2, s3]);
|
|
294
|
+
const buf = u8(b32);
|
|
295
|
+
for (let i = start, pos = 0; i < srcLen; i++, pos++) dst[i] = src[i] ^ buf[pos];
|
|
296
|
+
clean(b32);
|
|
297
|
+
}
|
|
298
|
+
return dst;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
// AES CTR with overflowing 32 bit counter
|
|
302
|
+
// It's possible to do 32le significantly simpler (and probably faster) by using u32.
|
|
303
|
+
// But, we need both, and perf bottleneck is in ghash anyway.
|
|
304
|
+
function ctr32(
|
|
305
|
+
xk: Uint32Array,
|
|
306
|
+
isLE: boolean,
|
|
307
|
+
nonce: Uint8Array,
|
|
308
|
+
src: Uint8Array,
|
|
309
|
+
dst?: Uint8Array
|
|
310
|
+
): Uint8Array {
|
|
311
|
+
abytes(nonce, BLOCK_SIZE, 'nonce');
|
|
312
|
+
abytes(src);
|
|
313
|
+
dst = getOutput(src.length, dst);
|
|
314
|
+
const ctr = nonce; // write new value to nonce, so it can be re-used
|
|
315
|
+
const c32 = u32(ctr);
|
|
316
|
+
const view = createView(ctr);
|
|
317
|
+
const src32 = u32(src);
|
|
318
|
+
const dst32 = u32(dst);
|
|
319
|
+
const ctrPos = isLE ? 0 : 12;
|
|
320
|
+
const srcLen = src.length;
|
|
321
|
+
// Fill block (empty, ctr=0)
|
|
322
|
+
let ctrNum = view.getUint32(ctrPos, isLE); // read current counter value
|
|
323
|
+
let { s0, s1, s2, s3 } = encrypt(xk, c32[0], c32[1], c32[2], c32[3]);
|
|
324
|
+
// process blocks
|
|
325
|
+
for (let i = 0; i + 4 <= src32.length; i += 4) {
|
|
326
|
+
dst32[i + 0] = src32[i + 0] ^ s0;
|
|
327
|
+
dst32[i + 1] = src32[i + 1] ^ s1;
|
|
328
|
+
dst32[i + 2] = src32[i + 2] ^ s2;
|
|
329
|
+
dst32[i + 3] = src32[i + 3] ^ s3;
|
|
330
|
+
ctrNum = (ctrNum + 1) >>> 0; // u32 wrap
|
|
331
|
+
view.setUint32(ctrPos, ctrNum, isLE);
|
|
332
|
+
({ s0, s1, s2, s3 } = encrypt(xk, c32[0], c32[1], c32[2], c32[3]));
|
|
333
|
+
}
|
|
334
|
+
// leftovers (less than a block)
|
|
335
|
+
const start = BLOCK_SIZE * Math.floor(src32.length / BLOCK_SIZE32);
|
|
336
|
+
if (start < srcLen) {
|
|
337
|
+
const b32 = new Uint32Array([s0, s1, s2, s3]);
|
|
338
|
+
const buf = u8(b32);
|
|
339
|
+
for (let i = start, pos = 0; i < srcLen; i++, pos++) dst[i] = src[i] ^ buf[pos];
|
|
340
|
+
clean(b32);
|
|
341
|
+
}
|
|
342
|
+
return dst;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* **CTR** (Counter Mode): Turns a block cipher into a stream cipher using a counter and IV (nonce).
|
|
347
|
+
* Efficient and parallelizable. Requires a unique nonce per encryption. Unauthenticated: needs MAC.
|
|
348
|
+
*/
|
|
349
|
+
export const ctr: ((key: Uint8Array, nonce: Uint8Array) => CipherWithOutput) & {
|
|
350
|
+
blockSize: number;
|
|
351
|
+
nonceLength: number;
|
|
352
|
+
} = /* @__PURE__ */ wrapCipher(
|
|
353
|
+
{ blockSize: 16, nonceLength: 16 },
|
|
354
|
+
function aesctr(key: Uint8Array, nonce: Uint8Array): CipherWithOutput {
|
|
355
|
+
function processCtr(buf: Uint8Array, dst?: Uint8Array) {
|
|
356
|
+
abytes(buf);
|
|
357
|
+
if (dst !== undefined) {
|
|
358
|
+
abytes(dst);
|
|
359
|
+
if (!isAligned32(dst)) throw new Error('unaligned destination');
|
|
360
|
+
}
|
|
361
|
+
const xk = expandKeyLE(key);
|
|
362
|
+
const n = copyBytes(nonce); // align + avoid changing
|
|
363
|
+
const toClean = [xk, n];
|
|
364
|
+
if (!isAligned32(buf)) toClean.push((buf = copyBytes(buf)));
|
|
365
|
+
const out = ctrCounter(xk, n, buf, dst);
|
|
366
|
+
clean(...toClean);
|
|
367
|
+
return out;
|
|
368
|
+
}
|
|
369
|
+
return {
|
|
370
|
+
encrypt: (plaintext: Uint8Array, dst?: Uint8Array) => processCtr(plaintext, dst),
|
|
371
|
+
decrypt: (ciphertext: Uint8Array, dst?: Uint8Array) => processCtr(ciphertext, dst),
|
|
372
|
+
};
|
|
373
|
+
}
|
|
374
|
+
);
|
|
375
|
+
|
|
376
|
+
function validateBlockDecrypt(data: Uint8Array) {
|
|
377
|
+
abytes(data);
|
|
378
|
+
if (data.length % BLOCK_SIZE !== 0) {
|
|
379
|
+
throw new Error(
|
|
380
|
+
'aes-(cbc/ecb).decrypt ciphertext should consist of blocks with size ' + BLOCK_SIZE
|
|
381
|
+
);
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
function validateBlockEncrypt(plaintext: Uint8Array, pcks5: boolean, dst?: Uint8Array) {
|
|
386
|
+
abytes(plaintext);
|
|
387
|
+
let outLen = plaintext.length;
|
|
388
|
+
const remaining = outLen % BLOCK_SIZE;
|
|
389
|
+
if (!pcks5 && remaining !== 0)
|
|
390
|
+
throw new Error('aec/(cbc-ecb): unpadded plaintext with disabled padding');
|
|
391
|
+
if (!isAligned32(plaintext)) plaintext = copyBytes(plaintext);
|
|
392
|
+
const b = u32(plaintext);
|
|
393
|
+
if (pcks5) {
|
|
394
|
+
let left = BLOCK_SIZE - remaining;
|
|
395
|
+
if (!left) left = BLOCK_SIZE; // if no bytes left, create empty padding block
|
|
396
|
+
outLen = outLen + left;
|
|
397
|
+
}
|
|
398
|
+
dst = getOutput(outLen, dst);
|
|
399
|
+
complexOverlapBytes(plaintext, dst);
|
|
400
|
+
const o = u32(dst);
|
|
401
|
+
return { b, o, out: dst };
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
function validatePCKS(data: Uint8Array, pcks5: boolean) {
|
|
405
|
+
if (!pcks5) return data;
|
|
406
|
+
const len = data.length;
|
|
407
|
+
if (!len) throw new Error('aes/pcks5: empty ciphertext not allowed');
|
|
408
|
+
const lastByte = data[len - 1];
|
|
409
|
+
if (lastByte <= 0 || lastByte > 16) throw new Error('aes/pcks5: wrong padding');
|
|
410
|
+
const out = data.subarray(0, -lastByte);
|
|
411
|
+
for (let i = 0; i < lastByte; i++)
|
|
412
|
+
if (data[len - i - 1] !== lastByte) throw new Error('aes/pcks5: wrong padding');
|
|
413
|
+
return out;
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
function padPCKS(left: Uint8Array) {
|
|
417
|
+
const tmp = new Uint8Array(16);
|
|
418
|
+
const tmp32 = u32(tmp);
|
|
419
|
+
tmp.set(left);
|
|
420
|
+
const paddingByte = BLOCK_SIZE - left.length;
|
|
421
|
+
for (let i = BLOCK_SIZE - paddingByte; i < BLOCK_SIZE; i++) tmp[i] = paddingByte;
|
|
422
|
+
return tmp32;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
/** Options for ECB and CBC. */
|
|
426
|
+
export type BlockOpts = { disablePadding?: boolean };
|
|
427
|
+
|
|
428
|
+
/**
|
|
429
|
+
* **ECB** (Electronic Codebook): Deterministic encryption; identical plaintext blocks yield
|
|
430
|
+
* identical ciphertexts. Not secure due to pattern leakage.
|
|
431
|
+
* See [AES Penguin](https://words.filippo.io/the-ecb-penguin/).
|
|
432
|
+
*/
|
|
433
|
+
export const ecb: ((key: Uint8Array, opts?: BlockOpts) => CipherWithOutput) & {
|
|
434
|
+
blockSize: number;
|
|
435
|
+
} = /* @__PURE__ */ wrapCipher(
|
|
436
|
+
{ blockSize: 16 },
|
|
437
|
+
function aesecb(key: Uint8Array, opts: BlockOpts = {}): CipherWithOutput {
|
|
438
|
+
const pcks5 = !opts.disablePadding;
|
|
439
|
+
return {
|
|
440
|
+
encrypt(plaintext: Uint8Array, dst?: Uint8Array) {
|
|
441
|
+
const { b, o, out: _out } = validateBlockEncrypt(plaintext, pcks5, dst);
|
|
442
|
+
const xk = expandKeyLE(key);
|
|
443
|
+
let i = 0;
|
|
444
|
+
for (; i + 4 <= b.length; ) {
|
|
445
|
+
const { s0, s1, s2, s3 } = encrypt(xk, b[i + 0], b[i + 1], b[i + 2], b[i + 3]);
|
|
446
|
+
((o[i++] = s0), (o[i++] = s1), (o[i++] = s2), (o[i++] = s3));
|
|
447
|
+
}
|
|
448
|
+
if (pcks5) {
|
|
449
|
+
const tmp32 = padPCKS(plaintext.subarray(i * 4));
|
|
450
|
+
const { s0, s1, s2, s3 } = encrypt(xk, tmp32[0], tmp32[1], tmp32[2], tmp32[3]);
|
|
451
|
+
((o[i++] = s0), (o[i++] = s1), (o[i++] = s2), (o[i++] = s3));
|
|
452
|
+
}
|
|
453
|
+
clean(xk);
|
|
454
|
+
return _out;
|
|
455
|
+
},
|
|
456
|
+
decrypt(ciphertext: Uint8Array, dst?: Uint8Array) {
|
|
457
|
+
validateBlockDecrypt(ciphertext);
|
|
458
|
+
const xk = expandKeyDecLE(key);
|
|
459
|
+
dst = getOutput(ciphertext.length, dst);
|
|
460
|
+
const toClean: (Uint8Array | Uint32Array)[] = [xk];
|
|
461
|
+
if (!isAligned32(ciphertext)) toClean.push((ciphertext = copyBytes(ciphertext)));
|
|
462
|
+
complexOverlapBytes(ciphertext, dst);
|
|
463
|
+
const b = u32(ciphertext);
|
|
464
|
+
const o = u32(dst);
|
|
465
|
+
for (let i = 0; i + 4 <= b.length; ) {
|
|
466
|
+
const { s0, s1, s2, s3 } = decrypt(xk, b[i + 0], b[i + 1], b[i + 2], b[i + 3]);
|
|
467
|
+
((o[i++] = s0), (o[i++] = s1), (o[i++] = s2), (o[i++] = s3));
|
|
468
|
+
}
|
|
469
|
+
clean(...toClean);
|
|
470
|
+
return validatePCKS(dst, pcks5);
|
|
471
|
+
},
|
|
472
|
+
};
|
|
473
|
+
}
|
|
474
|
+
);
|
|
475
|
+
|
|
476
|
+
/**
|
|
477
|
+
* **CBC** (Cipher Block Chaining): Each plaintext block is XORed with the
|
|
478
|
+
* previous block of ciphertext before encryption.
|
|
479
|
+
* Hard to use: requires proper padding and an IV. Unauthenticated: needs MAC.
|
|
480
|
+
*/
|
|
481
|
+
export const cbc: ((key: Uint8Array, iv: Uint8Array, opts?: BlockOpts) => CipherWithOutput) & {
|
|
482
|
+
blockSize: number;
|
|
483
|
+
nonceLength: number;
|
|
484
|
+
} = /* @__PURE__ */ wrapCipher(
|
|
485
|
+
{ blockSize: 16, nonceLength: 16 },
|
|
486
|
+
function aescbc(key: Uint8Array, iv: Uint8Array, opts: BlockOpts = {}): CipherWithOutput {
|
|
487
|
+
const pcks5 = !opts.disablePadding;
|
|
488
|
+
return {
|
|
489
|
+
encrypt(plaintext: Uint8Array, dst?: Uint8Array) {
|
|
490
|
+
const xk = expandKeyLE(key);
|
|
491
|
+
const { b, o, out: _out } = validateBlockEncrypt(plaintext, pcks5, dst);
|
|
492
|
+
let _iv = iv;
|
|
493
|
+
const toClean: (Uint8Array | Uint32Array)[] = [xk];
|
|
494
|
+
if (!isAligned32(_iv)) toClean.push((_iv = copyBytes(_iv)));
|
|
495
|
+
const n32 = u32(_iv);
|
|
496
|
+
// prettier-ignore
|
|
497
|
+
let s0 = n32[0], s1 = n32[1], s2 = n32[2], s3 = n32[3];
|
|
498
|
+
let i = 0;
|
|
499
|
+
for (; i + 4 <= b.length; ) {
|
|
500
|
+
((s0 ^= b[i + 0]), (s1 ^= b[i + 1]), (s2 ^= b[i + 2]), (s3 ^= b[i + 3]));
|
|
501
|
+
({ s0, s1, s2, s3 } = encrypt(xk, s0, s1, s2, s3));
|
|
502
|
+
((o[i++] = s0), (o[i++] = s1), (o[i++] = s2), (o[i++] = s3));
|
|
503
|
+
}
|
|
504
|
+
if (pcks5) {
|
|
505
|
+
const tmp32 = padPCKS(plaintext.subarray(i * 4));
|
|
506
|
+
((s0 ^= tmp32[0]), (s1 ^= tmp32[1]), (s2 ^= tmp32[2]), (s3 ^= tmp32[3]));
|
|
507
|
+
({ s0, s1, s2, s3 } = encrypt(xk, s0, s1, s2, s3));
|
|
508
|
+
((o[i++] = s0), (o[i++] = s1), (o[i++] = s2), (o[i++] = s3));
|
|
509
|
+
}
|
|
510
|
+
clean(...toClean);
|
|
511
|
+
return _out;
|
|
512
|
+
},
|
|
513
|
+
decrypt(ciphertext: Uint8Array, dst?: Uint8Array) {
|
|
514
|
+
validateBlockDecrypt(ciphertext);
|
|
515
|
+
const xk = expandKeyDecLE(key);
|
|
516
|
+
let _iv = iv;
|
|
517
|
+
const toClean: (Uint8Array | Uint32Array)[] = [xk];
|
|
518
|
+
if (!isAligned32(_iv)) toClean.push((_iv = copyBytes(_iv)));
|
|
519
|
+
const n32 = u32(_iv);
|
|
520
|
+
dst = getOutput(ciphertext.length, dst);
|
|
521
|
+
if (!isAligned32(ciphertext)) toClean.push((ciphertext = copyBytes(ciphertext)));
|
|
522
|
+
complexOverlapBytes(ciphertext, dst);
|
|
523
|
+
const b = u32(ciphertext);
|
|
524
|
+
const o = u32(dst);
|
|
525
|
+
// prettier-ignore
|
|
526
|
+
let s0 = n32[0], s1 = n32[1], s2 = n32[2], s3 = n32[3];
|
|
527
|
+
for (let i = 0; i + 4 <= b.length; ) {
|
|
528
|
+
// prettier-ignore
|
|
529
|
+
const ps0 = s0, ps1 = s1, ps2 = s2, ps3 = s3;
|
|
530
|
+
((s0 = b[i + 0]), (s1 = b[i + 1]), (s2 = b[i + 2]), (s3 = b[i + 3]));
|
|
531
|
+
const { s0: o0, s1: o1, s2: o2, s3: o3 } = decrypt(xk, s0, s1, s2, s3);
|
|
532
|
+
((o[i++] = o0 ^ ps0), (o[i++] = o1 ^ ps1), (o[i++] = o2 ^ ps2), (o[i++] = o3 ^ ps3));
|
|
533
|
+
}
|
|
534
|
+
clean(...toClean);
|
|
535
|
+
return validatePCKS(dst, pcks5);
|
|
536
|
+
},
|
|
537
|
+
};
|
|
538
|
+
}
|
|
539
|
+
);
|
|
540
|
+
|
|
541
|
+
/**
|
|
542
|
+
* CFB: Cipher Feedback Mode. The input for the block cipher is the previous cipher output.
|
|
543
|
+
* Unauthenticated: needs MAC.
|
|
544
|
+
*/
|
|
545
|
+
export const cfb: ((key: Uint8Array, iv: Uint8Array) => CipherWithOutput) & {
|
|
546
|
+
blockSize: number;
|
|
547
|
+
nonceLength: number;
|
|
548
|
+
} = /* @__PURE__ */ wrapCipher(
|
|
549
|
+
{ blockSize: 16, nonceLength: 16 },
|
|
550
|
+
function aescfb(key: Uint8Array, iv: Uint8Array): CipherWithOutput {
|
|
551
|
+
function processCfb(src: Uint8Array, isEncrypt: boolean, dst?: Uint8Array) {
|
|
552
|
+
abytes(src);
|
|
553
|
+
const srcLen = src.length;
|
|
554
|
+
dst = getOutput(srcLen, dst);
|
|
555
|
+
if (overlapBytes(src, dst)) throw new Error('overlapping src and dst not supported.');
|
|
556
|
+
const xk = expandKeyLE(key);
|
|
557
|
+
let _iv = iv;
|
|
558
|
+
const toClean: (Uint8Array | Uint32Array)[] = [xk];
|
|
559
|
+
if (!isAligned32(_iv)) toClean.push((_iv = copyBytes(_iv)));
|
|
560
|
+
if (!isAligned32(src)) toClean.push((src = copyBytes(src)));
|
|
561
|
+
const src32 = u32(src);
|
|
562
|
+
const dst32 = u32(dst);
|
|
563
|
+
const next32 = isEncrypt ? dst32 : src32;
|
|
564
|
+
const n32 = u32(_iv);
|
|
565
|
+
// prettier-ignore
|
|
566
|
+
let s0 = n32[0], s1 = n32[1], s2 = n32[2], s3 = n32[3];
|
|
567
|
+
for (let i = 0; i + 4 <= src32.length; ) {
|
|
568
|
+
const { s0: e0, s1: e1, s2: e2, s3: e3 } = encrypt(xk, s0, s1, s2, s3);
|
|
569
|
+
dst32[i + 0] = src32[i + 0] ^ e0;
|
|
570
|
+
dst32[i + 1] = src32[i + 1] ^ e1;
|
|
571
|
+
dst32[i + 2] = src32[i + 2] ^ e2;
|
|
572
|
+
dst32[i + 3] = src32[i + 3] ^ e3;
|
|
573
|
+
((s0 = next32[i++]), (s1 = next32[i++]), (s2 = next32[i++]), (s3 = next32[i++]));
|
|
574
|
+
}
|
|
575
|
+
// leftovers (less than block)
|
|
576
|
+
const start = BLOCK_SIZE * Math.floor(src32.length / BLOCK_SIZE32);
|
|
577
|
+
if (start < srcLen) {
|
|
578
|
+
({ s0, s1, s2, s3 } = encrypt(xk, s0, s1, s2, s3));
|
|
579
|
+
const buf = u8(new Uint32Array([s0, s1, s2, s3]));
|
|
580
|
+
for (let i = start, pos = 0; i < srcLen; i++, pos++) dst[i] = src[i] ^ buf[pos];
|
|
581
|
+
clean(buf);
|
|
582
|
+
}
|
|
583
|
+
clean(...toClean);
|
|
584
|
+
return dst;
|
|
585
|
+
}
|
|
586
|
+
return {
|
|
587
|
+
encrypt: (plaintext: Uint8Array, dst?: Uint8Array) => processCfb(plaintext, true, dst),
|
|
588
|
+
decrypt: (ciphertext: Uint8Array, dst?: Uint8Array) => processCfb(ciphertext, false, dst),
|
|
589
|
+
};
|
|
590
|
+
}
|
|
591
|
+
);
|
|
592
|
+
|
|
593
|
+
// TODO: merge with chacha, however gcm has bitLen while chacha has byteLen
|
|
594
|
+
function computeTag(
|
|
595
|
+
fn: typeof ghash,
|
|
596
|
+
isLE: boolean,
|
|
597
|
+
key: Uint8Array,
|
|
598
|
+
data: Uint8Array,
|
|
599
|
+
AAD?: Uint8Array
|
|
600
|
+
) {
|
|
601
|
+
const aadLength = AAD ? AAD.length : 0;
|
|
602
|
+
const h = fn.create(key, data.length + aadLength);
|
|
603
|
+
if (AAD) h.update(AAD);
|
|
604
|
+
const num = u64Lengths(8 * data.length, 8 * aadLength, isLE);
|
|
605
|
+
h.update(data);
|
|
606
|
+
h.update(num);
|
|
607
|
+
const res = h.digest();
|
|
608
|
+
clean(num);
|
|
609
|
+
return res;
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
/**
|
|
613
|
+
* **GCM** (Galois/Counter Mode): Combines CTR mode with polynomial MAC. Efficient and widely used.
|
|
614
|
+
* Not perfect:
|
|
615
|
+
* a) conservative key wear-out is `2**32` (4B) msgs.
|
|
616
|
+
* b) key wear-out under random nonces is even smaller: `2**23` (8M) messages for `2**-50` chance.
|
|
617
|
+
* c) MAC can be forged: see Poly1305 documentation.
|
|
618
|
+
*/
|
|
619
|
+
export const gcm: ((key: Uint8Array, nonce: Uint8Array, AAD?: Uint8Array) => Cipher) & {
|
|
620
|
+
blockSize: number;
|
|
621
|
+
nonceLength: number;
|
|
622
|
+
tagLength: number;
|
|
623
|
+
varSizeNonce: true;
|
|
624
|
+
} = /* @__PURE__ */ wrapCipher(
|
|
625
|
+
{ blockSize: 16, nonceLength: 12, tagLength: 16, varSizeNonce: true },
|
|
626
|
+
function aesgcm(key: Uint8Array, nonce: Uint8Array, AAD?: Uint8Array): Cipher {
|
|
627
|
+
// NIST 800-38d doesn't enforce minimum nonce length.
|
|
628
|
+
// We enforce 8 bytes for compat with openssl.
|
|
629
|
+
// 12 bytes are recommended. More than 12 bytes would be converted into 12.
|
|
630
|
+
if (nonce.length < 8) throw new Error('aes/gcm: invalid nonce length');
|
|
631
|
+
const tagLength = 16;
|
|
632
|
+
function _computeTag(authKey: Uint8Array, tagMask: Uint8Array, data: Uint8Array) {
|
|
633
|
+
const tag = computeTag(ghash, false, authKey, data, AAD);
|
|
634
|
+
for (let i = 0; i < tagMask.length; i++) tag[i] ^= tagMask[i];
|
|
635
|
+
return tag;
|
|
636
|
+
}
|
|
637
|
+
function deriveKeys() {
|
|
638
|
+
const xk = expandKeyLE(key);
|
|
639
|
+
const authKey = EMPTY_BLOCK.slice();
|
|
640
|
+
const counter = EMPTY_BLOCK.slice();
|
|
641
|
+
ctr32(xk, false, counter, counter, authKey);
|
|
642
|
+
// NIST 800-38d, page 15: different behavior for 96-bit and non-96-bit nonces
|
|
643
|
+
if (nonce.length === 12) {
|
|
644
|
+
counter.set(nonce);
|
|
645
|
+
} else {
|
|
646
|
+
const nonceLen = EMPTY_BLOCK.slice();
|
|
647
|
+
const view = createView(nonceLen);
|
|
648
|
+
view.setBigUint64(8, BigInt(nonce.length * 8), false);
|
|
649
|
+
// ghash(nonce || u64be(0) || u64be(nonceLen*8))
|
|
650
|
+
const g = ghash.create(authKey).update(nonce).update(nonceLen);
|
|
651
|
+
g.digestInto(counter); // digestInto doesn't trigger '.destroy'
|
|
652
|
+
g.destroy();
|
|
653
|
+
}
|
|
654
|
+
const tagMask = ctr32(xk, false, counter, EMPTY_BLOCK);
|
|
655
|
+
return { xk, authKey, counter, tagMask };
|
|
656
|
+
}
|
|
657
|
+
return {
|
|
658
|
+
encrypt(plaintext: Uint8Array) {
|
|
659
|
+
const { xk, authKey, counter, tagMask } = deriveKeys();
|
|
660
|
+
const out = new Uint8Array(plaintext.length + tagLength);
|
|
661
|
+
const toClean: (Uint8Array | Uint32Array)[] = [xk, authKey, counter, tagMask];
|
|
662
|
+
if (!isAligned32(plaintext)) toClean.push((plaintext = copyBytes(plaintext)));
|
|
663
|
+
ctr32(xk, false, counter, plaintext, out.subarray(0, plaintext.length));
|
|
664
|
+
const tag = _computeTag(authKey, tagMask, out.subarray(0, out.length - tagLength));
|
|
665
|
+
toClean.push(tag);
|
|
666
|
+
out.set(tag, plaintext.length);
|
|
667
|
+
clean(...toClean);
|
|
668
|
+
return out;
|
|
669
|
+
},
|
|
670
|
+
decrypt(ciphertext: Uint8Array) {
|
|
671
|
+
const { xk, authKey, counter, tagMask } = deriveKeys();
|
|
672
|
+
const toClean: (Uint8Array | Uint32Array)[] = [xk, authKey, tagMask, counter];
|
|
673
|
+
if (!isAligned32(ciphertext)) toClean.push((ciphertext = copyBytes(ciphertext)));
|
|
674
|
+
const data = ciphertext.subarray(0, -tagLength);
|
|
675
|
+
const passedTag = ciphertext.subarray(-tagLength);
|
|
676
|
+
const tag = _computeTag(authKey, tagMask, data);
|
|
677
|
+
toClean.push(tag);
|
|
678
|
+
if (!equalBytes(tag, passedTag)) throw new Error('aes/gcm: invalid ghash tag');
|
|
679
|
+
const out = ctr32(xk, false, counter, data);
|
|
680
|
+
clean(...toClean);
|
|
681
|
+
return out;
|
|
682
|
+
},
|
|
683
|
+
};
|
|
684
|
+
}
|
|
685
|
+
);
|
|
686
|
+
|
|
687
|
+
const limit = (name: string, min: number, max: number) => (value: number) => {
|
|
688
|
+
if (!Number.isSafeInteger(value) || min > value || value > max) {
|
|
689
|
+
const minmax = '[' + min + '..' + max + ']';
|
|
690
|
+
throw new Error('' + name + ': expected value in range ' + minmax + ', got ' + value);
|
|
691
|
+
}
|
|
692
|
+
};
|
|
693
|
+
|
|
694
|
+
/**
|
|
695
|
+
* **SIV** (Synthetic IV): GCM with nonce-misuse resistance.
|
|
696
|
+
* Repeating nonces reveal only the fact plaintexts are identical.
|
|
697
|
+
* Also suffers from GCM issues: key wear-out limits & MAC forging.
|
|
698
|
+
* See [RFC 8452](https://www.rfc-editor.org/rfc/rfc8452).
|
|
699
|
+
*/
|
|
700
|
+
export const gcmsiv: ((key: Uint8Array, nonce: Uint8Array, AAD?: Uint8Array) => Cipher) & {
|
|
701
|
+
blockSize: number;
|
|
702
|
+
nonceLength: number;
|
|
703
|
+
tagLength: number;
|
|
704
|
+
varSizeNonce: true;
|
|
705
|
+
} = /* @__PURE__ */ wrapCipher(
|
|
706
|
+
{ blockSize: 16, nonceLength: 12, tagLength: 16, varSizeNonce: true },
|
|
707
|
+
function aessiv(key: Uint8Array, nonce: Uint8Array, AAD?: Uint8Array): Cipher {
|
|
708
|
+
const tagLength = 16;
|
|
709
|
+
// From RFC 8452: Section 6
|
|
710
|
+
const AAD_LIMIT = limit('AAD', 0, 2 ** 36);
|
|
711
|
+
const PLAIN_LIMIT = limit('plaintext', 0, 2 ** 36);
|
|
712
|
+
const NONCE_LIMIT = limit('nonce', 12, 12);
|
|
713
|
+
const CIPHER_LIMIT = limit('ciphertext', 16, 2 ** 36 + 16);
|
|
714
|
+
abytes(key);
|
|
715
|
+
validateKeyLength(key);
|
|
716
|
+
NONCE_LIMIT(nonce.length);
|
|
717
|
+
if (AAD !== undefined) AAD_LIMIT(AAD.length);
|
|
718
|
+
function deriveKeys() {
|
|
719
|
+
const xk = expandKeyLE(key);
|
|
720
|
+
const encKey = new Uint8Array(key.length);
|
|
721
|
+
const authKey = new Uint8Array(16);
|
|
722
|
+
const toClean: (Uint8Array | Uint32Array)[] = [xk, encKey];
|
|
723
|
+
let _nonce = nonce;
|
|
724
|
+
if (!isAligned32(_nonce)) toClean.push((_nonce = copyBytes(_nonce)));
|
|
725
|
+
const n32 = u32(_nonce);
|
|
726
|
+
// prettier-ignore
|
|
727
|
+
let s0 = 0, s1 = n32[0], s2 = n32[1], s3 = n32[2];
|
|
728
|
+
let counter = 0;
|
|
729
|
+
for (const derivedKey of [authKey, encKey].map(u32)) {
|
|
730
|
+
const d32 = u32(derivedKey);
|
|
731
|
+
for (let i = 0; i < d32.length; i += 2) {
|
|
732
|
+
// aes(u32le(0) || nonce)[:8] || aes(u32le(1) || nonce)[:8] ...
|
|
733
|
+
const { s0: o0, s1: o1 } = encrypt(xk, s0, s1, s2, s3);
|
|
734
|
+
d32[i + 0] = o0;
|
|
735
|
+
d32[i + 1] = o1;
|
|
736
|
+
s0 = ++counter; // increment counter inside state
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
const res = { authKey, encKey: expandKeyLE(encKey) };
|
|
740
|
+
// Cleanup
|
|
741
|
+
clean(...toClean);
|
|
742
|
+
return res;
|
|
743
|
+
}
|
|
744
|
+
function _computeTag(encKey: Uint32Array, authKey: Uint8Array, data: Uint8Array) {
|
|
745
|
+
const tag = computeTag(polyval, true, authKey, data, AAD);
|
|
746
|
+
// Compute the expected tag by XORing S_s and the nonce, clearing the
|
|
747
|
+
// most significant bit of the last byte and encrypting with the
|
|
748
|
+
// message-encryption key.
|
|
749
|
+
for (let i = 0; i < 12; i++) tag[i] ^= nonce[i];
|
|
750
|
+
tag[15] &= 0x7f; // Clear the highest bit
|
|
751
|
+
// encrypt tag as block
|
|
752
|
+
const t32 = u32(tag);
|
|
753
|
+
// prettier-ignore
|
|
754
|
+
let s0 = t32[0], s1 = t32[1], s2 = t32[2], s3 = t32[3];
|
|
755
|
+
({ s0, s1, s2, s3 } = encrypt(encKey, s0, s1, s2, s3));
|
|
756
|
+
((t32[0] = s0), (t32[1] = s1), (t32[2] = s2), (t32[3] = s3));
|
|
757
|
+
return tag;
|
|
758
|
+
}
|
|
759
|
+
// actual decrypt/encrypt of message.
|
|
760
|
+
function processSiv(encKey: Uint32Array, tag: Uint8Array, input: Uint8Array) {
|
|
761
|
+
let block = copyBytes(tag);
|
|
762
|
+
block[15] |= 0x80; // Force highest bit
|
|
763
|
+
const res = ctr32(encKey, true, block, input);
|
|
764
|
+
// Cleanup
|
|
765
|
+
clean(block);
|
|
766
|
+
return res;
|
|
767
|
+
}
|
|
768
|
+
return {
|
|
769
|
+
encrypt(plaintext: Uint8Array) {
|
|
770
|
+
PLAIN_LIMIT(plaintext.length);
|
|
771
|
+
const { encKey, authKey } = deriveKeys();
|
|
772
|
+
const tag = _computeTag(encKey, authKey, plaintext);
|
|
773
|
+
const toClean: (Uint8Array | Uint32Array)[] = [encKey, authKey, tag];
|
|
774
|
+
if (!isAligned32(plaintext)) toClean.push((plaintext = copyBytes(plaintext)));
|
|
775
|
+
const out = new Uint8Array(plaintext.length + tagLength);
|
|
776
|
+
out.set(tag, plaintext.length);
|
|
777
|
+
out.set(processSiv(encKey, tag, plaintext));
|
|
778
|
+
// Cleanup
|
|
779
|
+
clean(...toClean);
|
|
780
|
+
return out;
|
|
781
|
+
},
|
|
782
|
+
decrypt(ciphertext: Uint8Array) {
|
|
783
|
+
CIPHER_LIMIT(ciphertext.length);
|
|
784
|
+
const tag = ciphertext.subarray(-tagLength);
|
|
785
|
+
const { encKey, authKey } = deriveKeys();
|
|
786
|
+
const toClean: (Uint8Array | Uint32Array)[] = [encKey, authKey];
|
|
787
|
+
if (!isAligned32(ciphertext)) toClean.push((ciphertext = copyBytes(ciphertext)));
|
|
788
|
+
const plaintext = processSiv(encKey, tag, ciphertext.subarray(0, -tagLength));
|
|
789
|
+
const expectedTag = _computeTag(encKey, authKey, plaintext);
|
|
790
|
+
toClean.push(expectedTag);
|
|
791
|
+
if (!equalBytes(tag, expectedTag)) {
|
|
792
|
+
clean(...toClean);
|
|
793
|
+
throw new Error('invalid polyval tag');
|
|
794
|
+
}
|
|
795
|
+
// Cleanup
|
|
796
|
+
clean(...toClean);
|
|
797
|
+
return plaintext;
|
|
798
|
+
},
|
|
799
|
+
};
|
|
800
|
+
}
|
|
801
|
+
);
|
|
802
|
+
|
|
803
|
+
function isBytes32(a: unknown): a is Uint32Array {
|
|
804
|
+
return (
|
|
805
|
+
a instanceof Uint32Array || (ArrayBuffer.isView(a) && a.constructor.name === 'Uint32Array')
|
|
806
|
+
);
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
function encryptBlock(xk: Uint32Array, block: Uint8Array): Uint8Array {
|
|
810
|
+
abytes(block, 16, 'block');
|
|
811
|
+
if (!isBytes32(xk)) throw new Error('_encryptBlock accepts result of expandKeyLE');
|
|
812
|
+
const b32 = u32(block);
|
|
813
|
+
let { s0, s1, s2, s3 } = encrypt(xk, b32[0], b32[1], b32[2], b32[3]);
|
|
814
|
+
((b32[0] = s0), (b32[1] = s1), (b32[2] = s2), (b32[3] = s3));
|
|
815
|
+
return block;
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
function decryptBlock(xk: Uint32Array, block: Uint8Array): Uint8Array {
|
|
819
|
+
abytes(block, 16, 'block');
|
|
820
|
+
if (!isBytes32(xk)) throw new Error('_decryptBlock accepts result of expandKeyLE');
|
|
821
|
+
const b32 = u32(block);
|
|
822
|
+
let { s0, s1, s2, s3 } = decrypt(xk, b32[0], b32[1], b32[2], b32[3]);
|
|
823
|
+
((b32[0] = s0), (b32[1] = s1), (b32[2] = s2), (b32[3] = s3));
|
|
824
|
+
return block;
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
/**
|
|
828
|
+
* AES-W (base for AESKW/AESKWP).
|
|
829
|
+
* Specs: [SP800-38F](https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-38F.pdf),
|
|
830
|
+
* [RFC 3394](https://www.rfc-editor.org/rfc/rfc3394),
|
|
831
|
+
* [RFC 5649](https://www.rfc-editor.org/rfc/rfc5649).
|
|
832
|
+
*/
|
|
833
|
+
const AESW = {
|
|
834
|
+
/*
|
|
835
|
+
High-level pseudocode:
|
|
836
|
+
```
|
|
837
|
+
A: u64 = IV
|
|
838
|
+
out = []
|
|
839
|
+
for (let i=0, ctr = 0; i<6; i++) {
|
|
840
|
+
for (const chunk of chunks(plaintext, 8)) {
|
|
841
|
+
A ^= swapEndianess(ctr++)
|
|
842
|
+
[A, res] = chunks(encrypt(A || chunk), 8);
|
|
843
|
+
out ||= res
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
out = A || out
|
|
847
|
+
```
|
|
848
|
+
Decrypt is the same, but reversed.
|
|
849
|
+
*/
|
|
850
|
+
encrypt(kek: Uint8Array, out: Uint8Array) {
|
|
851
|
+
// Size is limited to 4GB, otherwise ctr will overflow and we'll need to switch to bigints.
|
|
852
|
+
// If you need it larger, open an issue.
|
|
853
|
+
if (out.length >= 2 ** 32) throw new Error('plaintext should be less than 4gb');
|
|
854
|
+
const xk = expandKeyLE(kek);
|
|
855
|
+
if (out.length === 16) encryptBlock(xk, out);
|
|
856
|
+
else {
|
|
857
|
+
const o32 = u32(out);
|
|
858
|
+
// prettier-ignore
|
|
859
|
+
let a0 = o32[0], a1 = o32[1]; // A
|
|
860
|
+
for (let j = 0, ctr = 1; j < 6; j++) {
|
|
861
|
+
for (let pos = 2; pos < o32.length; pos += 2, ctr++) {
|
|
862
|
+
const { s0, s1, s2, s3 } = encrypt(xk, a0, a1, o32[pos], o32[pos + 1]);
|
|
863
|
+
// A = MSB(64, B) ^ t where t = (n*j)+i
|
|
864
|
+
((a0 = s0), (a1 = s1 ^ byteSwap(ctr)), (o32[pos] = s2), (o32[pos + 1] = s3));
|
|
865
|
+
}
|
|
866
|
+
}
|
|
867
|
+
((o32[0] = a0), (o32[1] = a1)); // out = A || out
|
|
868
|
+
}
|
|
869
|
+
xk.fill(0);
|
|
870
|
+
},
|
|
871
|
+
decrypt(kek: Uint8Array, out: Uint8Array) {
|
|
872
|
+
if (out.length - 8 >= 2 ** 32) throw new Error('ciphertext should be less than 4gb');
|
|
873
|
+
const xk = expandKeyDecLE(kek);
|
|
874
|
+
const chunks = out.length / 8 - 1; // first chunk is IV
|
|
875
|
+
if (chunks === 1) decryptBlock(xk, out);
|
|
876
|
+
else {
|
|
877
|
+
const o32 = u32(out);
|
|
878
|
+
// prettier-ignore
|
|
879
|
+
let a0 = o32[0], a1 = o32[1]; // A
|
|
880
|
+
for (let j = 0, ctr = chunks * 6; j < 6; j++) {
|
|
881
|
+
for (let pos = chunks * 2; pos >= 1; pos -= 2, ctr--) {
|
|
882
|
+
a1 ^= byteSwap(ctr);
|
|
883
|
+
const { s0, s1, s2, s3 } = decrypt(xk, a0, a1, o32[pos], o32[pos + 1]);
|
|
884
|
+
((a0 = s0), (a1 = s1), (o32[pos] = s2), (o32[pos + 1] = s3));
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
((o32[0] = a0), (o32[1] = a1));
|
|
888
|
+
}
|
|
889
|
+
xk.fill(0);
|
|
890
|
+
},
|
|
891
|
+
};
|
|
892
|
+
|
|
893
|
+
const AESKW_IV = /* @__PURE__ */ new Uint8Array(8).fill(0xa6); // A6A6A6A6A6A6A6A6
|
|
894
|
+
|
|
895
|
+
/**
|
|
896
|
+
* AES-KW (key-wrap). Injects static IV into plaintext, adds counter, encrypts 6 times.
|
|
897
|
+
* Reduces block size from 16 to 8 bytes.
|
|
898
|
+
* For padded version, use aeskwp.
|
|
899
|
+
* [RFC 3394](https://www.rfc-editor.org/rfc/rfc3394/),
|
|
900
|
+
* [NIST.SP.800-38F](https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-38F.pdf).
|
|
901
|
+
*/
|
|
902
|
+
export const aeskw: ((kek: Uint8Array) => Cipher) & {
|
|
903
|
+
blockSize: number;
|
|
904
|
+
} = /* @__PURE__ */ wrapCipher(
|
|
905
|
+
{ blockSize: 8 },
|
|
906
|
+
(kek: Uint8Array): Cipher => ({
|
|
907
|
+
encrypt(plaintext: Uint8Array) {
|
|
908
|
+
if (!plaintext.length || plaintext.length % 8 !== 0)
|
|
909
|
+
throw new Error('invalid plaintext length');
|
|
910
|
+
if (plaintext.length === 8)
|
|
911
|
+
throw new Error('8-byte keys not allowed in AESKW, use AESKWP instead');
|
|
912
|
+
const out = concatBytes(AESKW_IV, plaintext);
|
|
913
|
+
AESW.encrypt(kek, out);
|
|
914
|
+
return out;
|
|
915
|
+
},
|
|
916
|
+
decrypt(ciphertext: Uint8Array) {
|
|
917
|
+
// ciphertext must be at least 24 bytes and a multiple of 8 bytes
|
|
918
|
+
// 24 because should have at least two block (1 iv + 2).
|
|
919
|
+
// Replace with 16 to enable '8-byte keys'
|
|
920
|
+
if (ciphertext.length % 8 !== 0 || ciphertext.length < 3 * 8)
|
|
921
|
+
throw new Error('invalid ciphertext length');
|
|
922
|
+
const out = copyBytes(ciphertext);
|
|
923
|
+
AESW.decrypt(kek, out);
|
|
924
|
+
if (!equalBytes(out.subarray(0, 8), AESKW_IV)) throw new Error('integrity check failed');
|
|
925
|
+
out.subarray(0, 8).fill(0); // ciphertext.subarray(0, 8) === IV, but we clean it anyway
|
|
926
|
+
return out.subarray(8);
|
|
927
|
+
},
|
|
928
|
+
})
|
|
929
|
+
);
|
|
930
|
+
|
|
931
|
+
/*
|
|
932
|
+
We don't support 8-byte keys. The rabbit hole:
|
|
933
|
+
|
|
934
|
+
- Wycheproof says: "NIST SP 800-38F does not define the wrapping of 8 byte keys.
|
|
935
|
+
RFC 3394 Section 2 on the other hand specifies that 8 byte keys are wrapped
|
|
936
|
+
by directly encrypting one block with AES."
|
|
937
|
+
- https://github.com/C2SP/wycheproof/blob/master/doc/key_wrap.md
|
|
938
|
+
- "RFC 3394 specifies in Section 2, that the input for the key wrap
|
|
939
|
+
algorithm must be at least two blocks and otherwise the constant
|
|
940
|
+
field and key are simply encrypted with ECB as a single block"
|
|
941
|
+
- What RFC 3394 actually says (in Section 2):
|
|
942
|
+
- "Before being wrapped, the key data is parsed into n blocks of 64 bits.
|
|
943
|
+
The only restriction the key wrap algorithm places on n is that n be
|
|
944
|
+
at least two"
|
|
945
|
+
- "For key data with length less than or equal to 64 bits, the constant
|
|
946
|
+
field used in this specification and the key data form a single
|
|
947
|
+
128-bit codebook input making this key wrap unnecessary."
|
|
948
|
+
- Which means "assert(n >= 2)" and "use something else for 8 byte keys"
|
|
949
|
+
- NIST SP800-38F actually prohibits 8-byte in "5.3.1 Mandatory Limits".
|
|
950
|
+
It states that plaintext for KW should be "2 to 2^54 -1 semiblocks".
|
|
951
|
+
- So, where does "directly encrypt single block with AES" come from?
|
|
952
|
+
- Not RFC 3394. Pseudocode of key wrap in 2.2 explicitly uses
|
|
953
|
+
loop of 6 for any code path
|
|
954
|
+
- There is a weird W3C spec:
|
|
955
|
+
https://www.w3.org/TR/2002/REC-xmlenc-core-20021210/Overview.html#kw-aes128
|
|
956
|
+
- This spec is outdated, as admitted by Wycheproof authors
|
|
957
|
+
- There is RFC 5649 for padded key wrap, which is padding construction on
|
|
958
|
+
top of AESKW. In '4.1.2' it says: "If the padded plaintext contains exactly
|
|
959
|
+
eight octets, then prepend the AIV as defined in Section 3 above to P[1] and
|
|
960
|
+
encrypt the resulting 128-bit block using AES in ECB mode [Modes] with key
|
|
961
|
+
K (the KEK). In this case, the output is two 64-bit blocks C[0] and C[1]:"
|
|
962
|
+
- Browser subtle crypto is actually crashes on wrapping keys less than 16 bytes:
|
|
963
|
+
`Error: error:1C8000E6:Provider routines::invalid input length] { opensslErrorStack: [ 'error:030000BD:digital envelope routines::update error' ]`
|
|
964
|
+
|
|
965
|
+
In the end, seems like a bug in Wycheproof.
|
|
966
|
+
The 8-byte check can be easily disabled inside of AES_W.
|
|
967
|
+
*/
|
|
968
|
+
|
|
969
|
+
const AESKWP_IV = 0xa65959a6; // single u32le value
|
|
970
|
+
|
|
971
|
+
/**
|
|
972
|
+
* AES-KW, but with padding and allows random keys.
|
|
973
|
+
* Second u32 of IV is used as counter for length.
|
|
974
|
+
* [RFC 5649](https://www.rfc-editor.org/rfc/rfc5649)
|
|
975
|
+
*/
|
|
976
|
+
export const aeskwp: ((kek: Uint8Array) => Cipher) & {
|
|
977
|
+
blockSize: number;
|
|
978
|
+
} = /* @__PURE__ */ wrapCipher(
|
|
979
|
+
{ blockSize: 8 },
|
|
980
|
+
(kek: Uint8Array): Cipher => ({
|
|
981
|
+
encrypt(plaintext: Uint8Array) {
|
|
982
|
+
if (!plaintext.length) throw new Error('invalid plaintext length');
|
|
983
|
+
const padded = Math.ceil(plaintext.length / 8) * 8;
|
|
984
|
+
const out = new Uint8Array(8 + padded);
|
|
985
|
+
out.set(plaintext, 8);
|
|
986
|
+
const out32 = u32(out);
|
|
987
|
+
out32[0] = AESKWP_IV;
|
|
988
|
+
out32[1] = byteSwap(plaintext.length);
|
|
989
|
+
AESW.encrypt(kek, out);
|
|
990
|
+
return out;
|
|
991
|
+
},
|
|
992
|
+
decrypt(ciphertext: Uint8Array) {
|
|
993
|
+
// 16 because should have at least one block
|
|
994
|
+
if (ciphertext.length < 16) throw new Error('invalid ciphertext length');
|
|
995
|
+
const out = copyBytes(ciphertext);
|
|
996
|
+
const o32 = u32(out);
|
|
997
|
+
AESW.decrypt(kek, out);
|
|
998
|
+
const len = byteSwap(o32[1]) >>> 0;
|
|
999
|
+
const padded = Math.ceil(len / 8) * 8;
|
|
1000
|
+
if (o32[0] !== AESKWP_IV || out.length - 8 !== padded)
|
|
1001
|
+
throw new Error('integrity check failed');
|
|
1002
|
+
for (let i = len; i < padded; i++)
|
|
1003
|
+
if (out[8 + i] !== 0) throw new Error('integrity check failed');
|
|
1004
|
+
out.subarray(0, 8).fill(0); // ciphertext.subarray(0, 8) === IV, but we clean it anyway
|
|
1005
|
+
return out.subarray(8, 8 + len);
|
|
1006
|
+
},
|
|
1007
|
+
})
|
|
1008
|
+
);
|
|
1009
|
+
|
|
1010
|
+
class _AesCtrDRBG implements PRG {
|
|
1011
|
+
readonly blockLen: number;
|
|
1012
|
+
private key: Uint8Array;
|
|
1013
|
+
private nonce: Uint8Array;
|
|
1014
|
+
private state: Uint8Array;
|
|
1015
|
+
private reseedCnt: number;
|
|
1016
|
+
constructor(keyLen: number, seed: Uint8Array, personalization?: Uint8Array) {
|
|
1017
|
+
this.blockLen = ctr.blockSize;
|
|
1018
|
+
const keyLenBytes = keyLen / 8;
|
|
1019
|
+
const nonceLen = 16;
|
|
1020
|
+
this.state = new Uint8Array(keyLenBytes + nonceLen);
|
|
1021
|
+
this.key = this.state.subarray(0, keyLenBytes);
|
|
1022
|
+
this.nonce = this.state.subarray(keyLenBytes, keyLenBytes + nonceLen);
|
|
1023
|
+
this.reseedCnt = 1;
|
|
1024
|
+
incBytes(this.nonce, false, 1);
|
|
1025
|
+
this.addEntropy(seed, personalization);
|
|
1026
|
+
}
|
|
1027
|
+
private update(data?: Uint8Array) {
|
|
1028
|
+
// cannot re-use state here, because we will wipe current key
|
|
1029
|
+
ctr(this.key, this.nonce).encrypt(new Uint8Array(this.state.length), this.state);
|
|
1030
|
+
if (data) {
|
|
1031
|
+
abytes(data);
|
|
1032
|
+
for (let i = 0; i < data.length; i++) this.state[i] ^= data[i];
|
|
1033
|
+
}
|
|
1034
|
+
incBytes(this.nonce, false, 1);
|
|
1035
|
+
}
|
|
1036
|
+
addEntropy(seed: Uint8Array, info?: Uint8Array): void {
|
|
1037
|
+
abytes(seed, this.state.length, 'seed');
|
|
1038
|
+
const _seed = seed.slice();
|
|
1039
|
+
if (info) {
|
|
1040
|
+
abytes(info);
|
|
1041
|
+
if (info.length > _seed.length) throw new Error('info length is too big');
|
|
1042
|
+
for (let i = 0; i < info.length; i++) _seed[i] ^= info[i];
|
|
1043
|
+
}
|
|
1044
|
+
this.update(_seed);
|
|
1045
|
+
_seed.fill(0);
|
|
1046
|
+
this.reseedCnt = 1;
|
|
1047
|
+
}
|
|
1048
|
+
randomBytes(len: number, info?: Uint8Array): Uint8Array {
|
|
1049
|
+
anumber(len);
|
|
1050
|
+
if (this.reseedCnt++ >= 2 ** 48) throw new Error('entropy exhausted');
|
|
1051
|
+
if (info) this.update(info);
|
|
1052
|
+
const res = new Uint8Array(len);
|
|
1053
|
+
ctr(this.key, this.nonce).encrypt(res, res);
|
|
1054
|
+
incBytes(this.nonce, false, Math.ceil(len / this.blockLen));
|
|
1055
|
+
this.update(info);
|
|
1056
|
+
return res;
|
|
1057
|
+
}
|
|
1058
|
+
clean(): void {
|
|
1059
|
+
this.state.fill(0);
|
|
1060
|
+
this.reseedCnt = 0;
|
|
1061
|
+
}
|
|
1062
|
+
}
|
|
1063
|
+
|
|
1064
|
+
export type AesCtrDrbg = (seed: Uint8Array, personalization?: Uint8Array) => _AesCtrDRBG;
|
|
1065
|
+
|
|
1066
|
+
const createAesDrbg: (keyLen: number) => AesCtrDrbg = (keyLen) => {
|
|
1067
|
+
return (seed, personalization = undefined) => new _AesCtrDRBG(keyLen, seed, personalization);
|
|
1068
|
+
};
|
|
1069
|
+
|
|
1070
|
+
/**
|
|
1071
|
+
* AES-CTR DRBG 128-bit - CSPRNG (cryptographically secure pseudorandom number generator).
|
|
1072
|
+
* It's best to limit usage to non-production, non-critical cases: for example, test-only.
|
|
1073
|
+
*/
|
|
1074
|
+
export const rngAesCtrDrbg128: AesCtrDrbg = /* @__PURE__ */ createAesDrbg(128);
|
|
1075
|
+
/**
|
|
1076
|
+
* AES-CTR DRBG 256-bit - CSPRNG (cryptographically secure pseudorandom number generator).
|
|
1077
|
+
* It's best to limit usage to non-production, non-critical cases: for example, test-only.
|
|
1078
|
+
*/
|
|
1079
|
+
export const rngAesCtrDrbg256: AesCtrDrbg = /* @__PURE__ */ createAesDrbg(256);
|
|
1080
|
+
|
|
1081
|
+
//#region CMAC
|
|
1082
|
+
|
|
1083
|
+
/**
|
|
1084
|
+
* Left-shift by one bit and conditionally XOR with 0x87:
|
|
1085
|
+
* ```
|
|
1086
|
+
* if MSB(L) is equal to 0
|
|
1087
|
+
* then K1 := L << 1;
|
|
1088
|
+
* else K1 := (L << 1) XOR const_Rb;
|
|
1089
|
+
* ```
|
|
1090
|
+
*
|
|
1091
|
+
* Specs: [RFC 4493, Section 2.3](https://www.rfc-editor.org/rfc/rfc4493.html#section-2.3),
|
|
1092
|
+
* [RFC 5297 Section 2.3](https://datatracker.ietf.org/doc/html/rfc5297.html#section-2.3)
|
|
1093
|
+
*
|
|
1094
|
+
* @returns modified `block` (for chaining)
|
|
1095
|
+
*/
|
|
1096
|
+
function dbl<T extends Uint8Array>(block: T): T {
|
|
1097
|
+
let carry = 0;
|
|
1098
|
+
|
|
1099
|
+
// Left shift by 1 bit
|
|
1100
|
+
for (let i = BLOCK_SIZE - 1; i >= 0; i--) {
|
|
1101
|
+
const newCarry = (block[i] & 0x80) >>> 7;
|
|
1102
|
+
block[i] = (block[i] << 1) | carry;
|
|
1103
|
+
carry = newCarry;
|
|
1104
|
+
}
|
|
1105
|
+
|
|
1106
|
+
// XOR with 0x87 if there was a carry from the most significant bit
|
|
1107
|
+
if (carry) {
|
|
1108
|
+
block[BLOCK_SIZE - 1] ^= 0x87;
|
|
1109
|
+
}
|
|
1110
|
+
|
|
1111
|
+
return block;
|
|
1112
|
+
}
|
|
1113
|
+
|
|
1114
|
+
/**
|
|
1115
|
+
* `a XOR b`, running in-site on `a`.
|
|
1116
|
+
* @param a left operand and output
|
|
1117
|
+
* @param b right operand
|
|
1118
|
+
* @returns `a` (for chaining)
|
|
1119
|
+
*/
|
|
1120
|
+
function xorBlock<T extends Uint8Array>(a: T, b: Uint8Array): T {
|
|
1121
|
+
if (a.length !== b.length) throw new Error('xorBlock: blocks must have same length');
|
|
1122
|
+
for (let i = 0; i < a.length; i++) {
|
|
1123
|
+
a[i] = a[i] ^ b[i];
|
|
1124
|
+
}
|
|
1125
|
+
return a;
|
|
1126
|
+
}
|
|
1127
|
+
|
|
1128
|
+
/**
|
|
1129
|
+
* xorend as defined in [RFC 5297 Section 2.1](https://datatracker.ietf.org/doc/html/rfc5297.html#section-2.1).
|
|
1130
|
+
*
|
|
1131
|
+
* ```
|
|
1132
|
+
* leftmost(A, len(A)-len(B)) || (rightmost(A, len(B)) xor B)
|
|
1133
|
+
* ```
|
|
1134
|
+
*/
|
|
1135
|
+
function xorend<T extends Uint8Array>(a: T, b: Uint8Array): T {
|
|
1136
|
+
if (b.length > a.length) {
|
|
1137
|
+
throw new Error('xorend: len(B) must be less than or equal to len(A)');
|
|
1138
|
+
}
|
|
1139
|
+
// keep leftmost part of `a` unchanged
|
|
1140
|
+
// and xor only the rightmost part:
|
|
1141
|
+
const offset = a.length - b.length;
|
|
1142
|
+
for (let i = 0; i < b.length; i++) {
|
|
1143
|
+
a[offset + i] = a[offset + i] ^ b[i];
|
|
1144
|
+
}
|
|
1145
|
+
return a;
|
|
1146
|
+
}
|
|
1147
|
+
|
|
1148
|
+
/**
|
|
1149
|
+
* Internal CMAC class.
|
|
1150
|
+
*/
|
|
1151
|
+
class _CMAC {
|
|
1152
|
+
private buffer: Uint8Array;
|
|
1153
|
+
private destroyed: boolean;
|
|
1154
|
+
private k1: Uint8Array;
|
|
1155
|
+
private k2: Uint8Array;
|
|
1156
|
+
private xk: Uint32Array;
|
|
1157
|
+
|
|
1158
|
+
constructor(key: Uint8Array) {
|
|
1159
|
+
abytes(key);
|
|
1160
|
+
validateKeyLength(key);
|
|
1161
|
+
this.xk = expandKeyLE(key);
|
|
1162
|
+
this.buffer = new Uint8Array(0);
|
|
1163
|
+
this.destroyed = false;
|
|
1164
|
+
// L = AES_encrypt(K, const_Zero)
|
|
1165
|
+
const L = new Uint8Array(BLOCK_SIZE);
|
|
1166
|
+
encryptBlock(this.xk, L);
|
|
1167
|
+
// Generate subkeys K1 and K2 from the main key according to
|
|
1168
|
+
// [RFC 4493, Section 2.3](https://www.rfc-editor.org/rfc/rfc4493.html#section-2.3)
|
|
1169
|
+
// K1
|
|
1170
|
+
this.k1 = dbl(L);
|
|
1171
|
+
this.k2 = dbl(new Uint8Array(this.k1));
|
|
1172
|
+
}
|
|
1173
|
+
|
|
1174
|
+
update(data: Uint8Array): _CMAC {
|
|
1175
|
+
const { destroyed, buffer } = this;
|
|
1176
|
+
if (destroyed) throw new Error('CMAC instance was destroyed');
|
|
1177
|
+
abytes(data);
|
|
1178
|
+
const newBuffer = new Uint8Array(buffer.length + data.length);
|
|
1179
|
+
newBuffer.set(buffer);
|
|
1180
|
+
newBuffer.set(data, buffer.length);
|
|
1181
|
+
this.buffer = newBuffer;
|
|
1182
|
+
return this;
|
|
1183
|
+
}
|
|
1184
|
+
|
|
1185
|
+
// see https://www.rfc-editor.org/rfc/rfc4493.html#section-2.4
|
|
1186
|
+
digest(): Uint8ArrayBuffer {
|
|
1187
|
+
if (this.destroyed) throw new Error('CMAC instance was destroyed');
|
|
1188
|
+
const { buffer } = this;
|
|
1189
|
+
const msgLen = buffer.length;
|
|
1190
|
+
|
|
1191
|
+
// Step 2:
|
|
1192
|
+
let n = Math.ceil(msgLen / BLOCK_SIZE); // n := ceil(len/const_Bsize);
|
|
1193
|
+
|
|
1194
|
+
// Step 3:
|
|
1195
|
+
let flag: boolean; // denoting if last block is complete or not
|
|
1196
|
+
if (n === 0) {
|
|
1197
|
+
n = 1;
|
|
1198
|
+
flag = false;
|
|
1199
|
+
} else {
|
|
1200
|
+
flag = msgLen % BLOCK_SIZE === 0; // if len mod const_Bsize is 0
|
|
1201
|
+
}
|
|
1202
|
+
|
|
1203
|
+
// Step 4:
|
|
1204
|
+
const lastBlockStart = (n - 1) * BLOCK_SIZE;
|
|
1205
|
+
const lastBlockData = buffer.subarray(lastBlockStart);
|
|
1206
|
+
let m_last: Uint8ArrayBuffer;
|
|
1207
|
+
if (flag) {
|
|
1208
|
+
// M_last := M_n XOR K1;
|
|
1209
|
+
m_last = xorBlock(new Uint8Array(lastBlockData), this.k1);
|
|
1210
|
+
} else {
|
|
1211
|
+
// M_last := padding(M_n) XOR K2;
|
|
1212
|
+
//
|
|
1213
|
+
// [...] padding(x) is the concatenation of x and a single '1',
|
|
1214
|
+
// followed by the minimum number of '0's, so that the total length is
|
|
1215
|
+
// equal to 128 bits.
|
|
1216
|
+
const padded = new Uint8Array(BLOCK_SIZE);
|
|
1217
|
+
padded.set(lastBlockData);
|
|
1218
|
+
padded[lastBlockData.length] = 0x80; // single '1' bit
|
|
1219
|
+
m_last = xorBlock(padded, this.k2);
|
|
1220
|
+
}
|
|
1221
|
+
|
|
1222
|
+
// Step 5:
|
|
1223
|
+
let x = new Uint8Array(BLOCK_SIZE); // X := const_Zero;
|
|
1224
|
+
|
|
1225
|
+
// Step 6:
|
|
1226
|
+
for (let i = 0; i < n - 1; i++) {
|
|
1227
|
+
const m_i = buffer.subarray(i * BLOCK_SIZE, (i + 1) * BLOCK_SIZE); // M_i
|
|
1228
|
+
xorBlock(x, m_i); // Y := X XOR M_i;
|
|
1229
|
+
encryptBlock(this.xk, x); // X := AES-128(K,Y);
|
|
1230
|
+
}
|
|
1231
|
+
|
|
1232
|
+
// Step 7:
|
|
1233
|
+
xorBlock(x, m_last); // Y := M_last XOR X;
|
|
1234
|
+
encryptBlock(this.xk, x); // T := AES-128(K,Y);
|
|
1235
|
+
|
|
1236
|
+
// cleanup:
|
|
1237
|
+
clean(m_last);
|
|
1238
|
+
|
|
1239
|
+
return x; // T
|
|
1240
|
+
}
|
|
1241
|
+
|
|
1242
|
+
destroy(): void {
|
|
1243
|
+
const { buffer, destroyed, xk, k1, k2 } = this;
|
|
1244
|
+
if (destroyed) return;
|
|
1245
|
+
this.destroyed = true;
|
|
1246
|
+
clean(buffer, xk, k1, k2);
|
|
1247
|
+
}
|
|
1248
|
+
}
|
|
1249
|
+
|
|
1250
|
+
/**
|
|
1251
|
+
* AES-CMAC (Cipher-based Message Authentication Code).
|
|
1252
|
+
* Specs: [RFC 4493](https://www.rfc-editor.org/rfc/rfc4493.html).
|
|
1253
|
+
*/
|
|
1254
|
+
export const cmac: {
|
|
1255
|
+
(key: Uint8Array, message: Uint8Array): Uint8Array;
|
|
1256
|
+
create(key: Uint8Array): _CMAC;
|
|
1257
|
+
} = (key: Uint8Array, message: Uint8Array): Uint8Array => new _CMAC(key).update(message).digest();
|
|
1258
|
+
cmac.create = (key: Uint8Array): _CMAC => new _CMAC(key);
|
|
1259
|
+
|
|
1260
|
+
/**
|
|
1261
|
+
* S2V (Synthetic Initialization Vector) function as described in [RFC 5297 Section 2.4](https://datatracker.ietf.org/doc/html/rfc5297.html#section-2.4).
|
|
1262
|
+
*
|
|
1263
|
+
* ```
|
|
1264
|
+
* S2V(K, S1, ..., Sn) {
|
|
1265
|
+
* if n = 0 then
|
|
1266
|
+
* return V = AES-CMAC(K, <one>)
|
|
1267
|
+
* fi
|
|
1268
|
+
* D = AES-CMAC(K, <zero>)
|
|
1269
|
+
* for i = 1 to n-1 do
|
|
1270
|
+
* D = dbl(D) xor AES-CMAC(K, Si)
|
|
1271
|
+
* done
|
|
1272
|
+
* if len(Sn) >= 128 then
|
|
1273
|
+
* T = Sn xorend D
|
|
1274
|
+
* else
|
|
1275
|
+
* T = dbl(D) xor pad(Sn)
|
|
1276
|
+
* fi
|
|
1277
|
+
* return V = AES-CMAC(K, T)
|
|
1278
|
+
* }
|
|
1279
|
+
* ```
|
|
1280
|
+
*
|
|
1281
|
+
* S2V takes a key and a vector of strings S1, S2, ..., Sn and returns a 128-bit string.
|
|
1282
|
+
* The S2V function is used to generate a synthetic IV for AES-SIV.
|
|
1283
|
+
*
|
|
1284
|
+
* @param key - AES key (128, 192, or 256 bits)
|
|
1285
|
+
* @param strings - Array of byte arrays to process
|
|
1286
|
+
* @returns 128-bit synthetic IV
|
|
1287
|
+
*/
|
|
1288
|
+
function s2v(key: Uint8Array, strings: Uint8Array[]): Uint8Array {
|
|
1289
|
+
validateKeyLength(key);
|
|
1290
|
+
const len = strings.length;
|
|
1291
|
+
if (len > 127) {
|
|
1292
|
+
// see https://datatracker.ietf.org/doc/html/rfc5297.html#section-7
|
|
1293
|
+
throw new Error('s2v: number of input strings must be less than or equal to 127');
|
|
1294
|
+
}
|
|
1295
|
+
|
|
1296
|
+
if (len === 0) return cmac(key, ONE_BLOCK);
|
|
1297
|
+
|
|
1298
|
+
// D = AES-CMAC(K, <zero>)
|
|
1299
|
+
let d = cmac(key, EMPTY_BLOCK);
|
|
1300
|
+
|
|
1301
|
+
// for i = 1 to n-1 do
|
|
1302
|
+
// D = dbl(D) xor AES-CMAC(K, Si)
|
|
1303
|
+
for (let i = 0; i < len - 1; i++) {
|
|
1304
|
+
dbl(d);
|
|
1305
|
+
const cmacResult = cmac(key, strings[i]);
|
|
1306
|
+
xorBlock(d, cmacResult);
|
|
1307
|
+
clean(cmacResult);
|
|
1308
|
+
}
|
|
1309
|
+
|
|
1310
|
+
const s_n = strings[len - 1];
|
|
1311
|
+
let t: Uint8Array;
|
|
1312
|
+
|
|
1313
|
+
// if len(Sn) >= 128 then
|
|
1314
|
+
if (s_n.byteLength >= BLOCK_SIZE) {
|
|
1315
|
+
// T = Sn xorend D
|
|
1316
|
+
t = xorend(Uint8Array.from(s_n), d);
|
|
1317
|
+
} else {
|
|
1318
|
+
// pad(Sn):
|
|
1319
|
+
const paddedSn = new Uint8Array(BLOCK_SIZE);
|
|
1320
|
+
paddedSn.set(s_n);
|
|
1321
|
+
paddedSn[s_n.length] = 0x80; // padding: 0x80 followed by zeros
|
|
1322
|
+
|
|
1323
|
+
// T = dbl(D) xor pad(Sn)
|
|
1324
|
+
t = xorBlock(dbl(d), paddedSn);
|
|
1325
|
+
clean(paddedSn);
|
|
1326
|
+
}
|
|
1327
|
+
|
|
1328
|
+
// V = AES-CMAC(K, T)
|
|
1329
|
+
const result = cmac(key, t);
|
|
1330
|
+
clean(d, t);
|
|
1331
|
+
return result;
|
|
1332
|
+
}
|
|
1333
|
+
|
|
1334
|
+
/** Use `gcmsiv` or `aessiv`. */
|
|
1335
|
+
export const siv: () => never = () => {
|
|
1336
|
+
throw new Error('"siv" from v1 is now "gcmsiv"');
|
|
1337
|
+
};
|
|
1338
|
+
|
|
1339
|
+
/**
|
|
1340
|
+
* **SIV**: Synthetic Initialization Vector (SIV) Authenticated Encryption
|
|
1341
|
+
* Nonce is derived from the plaintext and AAD using the S2V function.
|
|
1342
|
+
* See [RFC 5297](https://datatracker.ietf.org/doc/html/rfc5297.html).
|
|
1343
|
+
*/
|
|
1344
|
+
export const aessiv: ((key: Uint8Array, ...AAD: Uint8Array[]) => Cipher) & {
|
|
1345
|
+
blockSize: number;
|
|
1346
|
+
tagLength: number;
|
|
1347
|
+
} = /* @__PURE__ */ wrapCipher(
|
|
1348
|
+
{ blockSize: 16, tagLength: 16 },
|
|
1349
|
+
function aessiv(key: Uint8Array, ...AAD: Uint8Array[]): Cipher {
|
|
1350
|
+
// From RFC 5297: Section 6.1, 6.2, 6.3:
|
|
1351
|
+
const PLAIN_LIMIT = limit('plaintext', 0, 2 ** 132);
|
|
1352
|
+
const CIPHER_LIMIT = limit('ciphertext', 16, 2 ** 132 + 16);
|
|
1353
|
+
if (AAD.length > 126) {
|
|
1354
|
+
// see https://datatracker.ietf.org/doc/html/rfc5297.html#section-7
|
|
1355
|
+
throw new Error('"AAD" number of elements must be less than or equal to 126');
|
|
1356
|
+
}
|
|
1357
|
+
AAD.forEach((aad) => abytes(aad));
|
|
1358
|
+
abytes(key);
|
|
1359
|
+
if (![32, 48, 64].includes(key.length))
|
|
1360
|
+
throw new Error('"aes key" expected Uint8Array of length 32/48/64, got length=' + key.length);
|
|
1361
|
+
|
|
1362
|
+
// The key is split into equal halves, K1 = leftmost(K, len(K)/2) and
|
|
1363
|
+
// K2 = rightmost(K, len(K)/2). K1 is used for S2V and K2 is used for CTR.
|
|
1364
|
+
const k1 = key.subarray(0, key.length / 2);
|
|
1365
|
+
const k2 = key.subarray(key.length / 2);
|
|
1366
|
+
|
|
1367
|
+
return {
|
|
1368
|
+
// https://datatracker.ietf.org/doc/html/rfc5297.html#section-2.6
|
|
1369
|
+
encrypt(plaintext: Uint8Array) {
|
|
1370
|
+
PLAIN_LIMIT(plaintext.length);
|
|
1371
|
+
|
|
1372
|
+
const v = s2v(k1, [...AAD, plaintext]);
|
|
1373
|
+
|
|
1374
|
+
// clear out the 31st and 63rd (rightmost) bit:
|
|
1375
|
+
const q = Uint8Array.from(v);
|
|
1376
|
+
q[8] &= 0x7f;
|
|
1377
|
+
q[12] &= 0x7f;
|
|
1378
|
+
|
|
1379
|
+
// encrypt:
|
|
1380
|
+
const c = ctr(k2, q).encrypt(plaintext);
|
|
1381
|
+
|
|
1382
|
+
return concatBytes(v, c);
|
|
1383
|
+
},
|
|
1384
|
+
// https://datatracker.ietf.org/doc/html/rfc5297.html#section-2.7
|
|
1385
|
+
decrypt(ciphertext: Uint8Array) {
|
|
1386
|
+
CIPHER_LIMIT(ciphertext.length);
|
|
1387
|
+
const v = ciphertext.subarray(0, BLOCK_SIZE);
|
|
1388
|
+
const c = ciphertext.subarray(BLOCK_SIZE);
|
|
1389
|
+
|
|
1390
|
+
// clear out the 31st and 63rd (rightmost) bit:
|
|
1391
|
+
const q = Uint8Array.from(v);
|
|
1392
|
+
q[8] &= 0x7f;
|
|
1393
|
+
q[12] &= 0x7f;
|
|
1394
|
+
|
|
1395
|
+
// decrypt:
|
|
1396
|
+
const p = ctr(k2, q).decrypt(c);
|
|
1397
|
+
|
|
1398
|
+
// verify tag:
|
|
1399
|
+
const t = s2v(k1, [...AAD, p]);
|
|
1400
|
+
|
|
1401
|
+
if (equalBytes(t, v)) {
|
|
1402
|
+
return p;
|
|
1403
|
+
} else {
|
|
1404
|
+
throw new Error('invalid siv tag');
|
|
1405
|
+
}
|
|
1406
|
+
},
|
|
1407
|
+
};
|
|
1408
|
+
}
|
|
1409
|
+
);
|
|
1410
|
+
//#endregion
|
|
1411
|
+
|
|
1412
|
+
/** Unsafe low-level internal methods. May change at any time. */
|
|
1413
|
+
export const unsafe: {
|
|
1414
|
+
expandKeyLE: typeof expandKeyLE;
|
|
1415
|
+
expandKeyDecLE: typeof expandKeyDecLE;
|
|
1416
|
+
encrypt: typeof encrypt;
|
|
1417
|
+
decrypt: typeof decrypt;
|
|
1418
|
+
encryptBlock: typeof encryptBlock;
|
|
1419
|
+
decryptBlock: typeof decryptBlock;
|
|
1420
|
+
ctrCounter: typeof ctrCounter;
|
|
1421
|
+
ctr32: typeof ctr32;
|
|
1422
|
+
dbl: typeof dbl;
|
|
1423
|
+
xorBlock: typeof xorBlock;
|
|
1424
|
+
xorend: typeof xorend;
|
|
1425
|
+
s2v: typeof s2v;
|
|
1426
|
+
} = {
|
|
1427
|
+
expandKeyLE,
|
|
1428
|
+
expandKeyDecLE,
|
|
1429
|
+
encrypt,
|
|
1430
|
+
decrypt,
|
|
1431
|
+
encryptBlock,
|
|
1432
|
+
decryptBlock,
|
|
1433
|
+
ctrCounter,
|
|
1434
|
+
ctr32,
|
|
1435
|
+
dbl,
|
|
1436
|
+
xorBlock,
|
|
1437
|
+
xorend,
|
|
1438
|
+
s2v,
|
|
1439
|
+
};
|