validator0x 0.3.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/AGENTS.md +74 -65
  2. package/CHANGELOG.md +24 -2
  3. package/README.md +23 -10
  4. package/dist/bitcoin.cjs +1 -1
  5. package/dist/bitcoin.mjs +1 -1
  6. package/dist/cardano.cjs +1 -1
  7. package/dist/cardano.mjs +1 -1
  8. package/dist/cosmos.cjs +1 -1
  9. package/dist/cosmos.mjs +1 -1
  10. package/dist/dogecoin.cjs +1 -1
  11. package/dist/dogecoin.mjs +1 -1
  12. package/dist/ethereum.cjs +1 -1
  13. package/dist/ethereum.mjs +1 -1
  14. package/dist/evm.cjs +1 -1
  15. package/dist/evm.mjs +1 -1
  16. package/dist/formatters.cjs +1 -1
  17. package/dist/formatters.mjs +1 -1
  18. package/dist/index.cjs +1 -1
  19. package/dist/index.d.cts +0 -2
  20. package/dist/index.d.mts +0 -2
  21. package/dist/index.mjs +1 -1
  22. package/dist/index.umd.js +1 -1
  23. package/dist/litecoin.cjs +1 -1
  24. package/dist/litecoin.mjs +1 -1
  25. package/dist/move.cjs +1 -1
  26. package/dist/move.mjs +1 -1
  27. package/dist/near.cjs +1 -1
  28. package/dist/near.mjs +1 -1
  29. package/dist/ripple.cjs +1 -1
  30. package/dist/ripple.mjs +1 -1
  31. package/dist/shared/base-3sYui6r0.cjs +1 -0
  32. package/dist/shared/base-CZZTeLCP.mjs +1 -0
  33. package/dist/shared/base58-DV6hu8Kq.cjs +1 -0
  34. package/dist/shared/base58-DY9-Un67.mjs +1 -0
  35. package/dist/shared/base58check-BeCwnkGe.cjs +1 -0
  36. package/dist/shared/base58check-rMkz2cjy.mjs +1 -0
  37. package/dist/shared/bech32-Cu41-5bd.mjs +1 -0
  38. package/dist/shared/bech32-Dk6Pnay4.cjs +1 -0
  39. package/dist/shared/utxo-BrSxcH2x.mjs +1 -0
  40. package/dist/shared/utxo-DF5Lt3lY.cjs +1 -0
  41. package/dist/solana.cjs +1 -1
  42. package/dist/solana.mjs +1 -1
  43. package/dist/tron.cjs +1 -1
  44. package/dist/tron.mjs +1 -1
  45. package/package.json +9 -8
package/dist/evm.mjs CHANGED
@@ -1 +1 @@
1
- var e;!function(e){e.INVALID_FORMAT="INVALID_FORMAT",e.INVALID_CHECKSUM="INVALID_CHECKSUM",e.INVALID_LENGTH="INVALID_LENGTH",e.INVALID_CHARACTERS="INVALID_CHARACTERS",e.UNSUPPORTED_CHAIN="UNSUPPORTED_CHAIN",e.BURN_ADDRESS="BURN_ADDRESS",e.UNSAFE_INPUT="UNSAFE_INPUT",e.NETWORK_MISMATCH="NETWORK_MISMATCH"}(e||(e={}));class t{static sanitize(t){if(null==t)throw new Error(e.UNSAFE_INPUT);if("string"!=typeof t)throw new Error(e.UNSAFE_INPUT);if(t.length>256)throw new Error(e.UNSAFE_INPUT);if(/[^\x20-\x7E]/.test(t))throw new Error(e.UNSAFE_INPUT);return t.trim()}}class n{validate(n,r){try{const a=t.sanitize(n),s=this.validateImplementation(a,r),o=s.details?.network;return s.valid&&o&&(r?.network&&"auto"!==r.network&&r.network!==o||!1===r?.allowTestnet&&"testnet"===o)?{valid:!1,error:"Address network does not match the requested network",details:{...s.details,errorCode:e.NETWORK_MISMATCH}}:s}catch(t){const n=t instanceof Error?t.message:String(t);return n===e.UNSAFE_INPUT?{valid:!1,error:"Unsafe input detected",details:{errorCode:e.UNSAFE_INPUT}}:{valid:!1,error:n,details:{errorCode:e.INVALID_FORMAT}}}}format(e,t){return r(e,t)}}function r(e,n,r=4){const a=t.sanitize(e);if(!n?.shorten)return a;const s=n.shortenLength??r;if(!Number.isSafeInteger(s)||s<1)throw new RangeError("shortenLength must be a positive integer");const o=a.startsWith("0x")?2:0;return a.length<=2*s+o+3?a:`${a.slice(0,s+o)}...${a.slice(-s)}`}function a(e){return e.startsWith("0x")?e.slice(2):e}function s(e){return e.startsWith("0x")?e:`0x${e}`}const o=(1n<<64n)-1n,i=[0,1,62,28,27,36,44,6,55,20,3,10,43,25,39,41,45,15,21,8,18,2,61,56,14],l=[0x0000000000000001n,0x0000000000008082n,0x800000000000808an,0x8000000080008000n,0x000000000000808bn,0x0000000080000001n,0x8000000080008081n,0x8000000000008009n,0x000000000000008an,0x0000000000000088n,0x0000000080008009n,0x000000008000000an,0x000000008000808bn,0x800000000000008bn,0x8000000000008089n,0x8000000000008003n,0x8000000000008002n,0x8000000000000080n,0x000000000000800an,0x800000008000000an,0x8000000080008081n,0x8000000000008080n,0x0000000080000001n,0x8000000080008008n];function c(e,t){return(e<<BigInt(t)|e>>BigInt(64-t))&o}function d(e){const t=new Array(5),n=new Array(25);for(const r of l){for(let n=0;n<5;n++)t[n]=e[n]^e[n+5]^e[n+10]^e[n+15]^e[n+20];for(let n=0;n<5;n++){const r=t[(n+4)%5]^c(t[(n+1)%5],1);for(let t=0;t<5;t++)e[n+5*t]^=r}for(let t=0;t<5;t++)for(let r=0;r<5;r++)n[r+(2*t+3*r)%5*5]=c(e[t+5*r],i[t+5*r]);for(let t=0;t<5;t++)for(let r=0;r<5;r++)e[t+5*r]=n[t+5*r]^~n[(t+1)%5+5*r]&n[(t+2)%5+5*r];e[0]^=r}}class I extends n{validateImplementation(t,n){const r=a(t);if(40!==r.length)return{valid:!1,error:"Invalid length",details:{errorCode:e.INVALID_LENGTH}};if(!function(e){if("string"!=typeof e)return!1;const t=e.startsWith("0x")?e.slice(2):e;return/^[0-9a-fA-F]*$/.test(t)}(r))return{valid:!1,error:"Invalid hex characters",details:{errorCode:e.INVALID_CHARACTERS}};if(!n?.allowBurnAddress&&/^0+$/.test(r))return{valid:!1,error:"Burn address detected",details:{errorCode:e.BURN_ADDRESS}};const s=this.isChecksummed(r);return(n?.strict||r!==r.toLowerCase()&&r!==r.toUpperCase())&&!s?{valid:!1,error:"Invalid checksum",details:{errorCode:e.INVALID_CHECKSUM}}:{valid:!0,blockchain:"ethereum",details:{checksum:s}}}format(e,n){let a=s(t.sanitize(e));return n?.checksum&&(a=this.toChecksumAddress(a)),r(a,n)}isChecksummed(e){const t=a(e);return s(t)===this.toChecksumAddress(t)}toChecksumAddress(e){const t=a(e).toLowerCase();if(!/^[0-9a-f]{40}$/.test(t))throw new Error("Expected a 20-byte hexadecimal address");const n=function(e){const t=(new TextEncoder).encode(e),n=new Uint8Array(136*(Math.floor(t.length/136)+1));n.set(t),n[t.length]=1,n[n.length-1]|=128;const r=new Array(25).fill(0n);for(let e=0;e<n.length;e+=136){for(let t=0;t<136;t++)r[t>>3]^=BigInt(n[e+t])<<BigInt(8*(7&t));d(r)}let a="";for(let e=0;e<32;e++)a+=Number(r[e>>3]>>BigInt(8*(7&e))&255n).toString(16).padStart(2,"0");return a}(t);return"0x"+[...t].map((e,t)=>parseInt(n[t],16)>=8?e.toUpperCase():e).join("")}}class u extends I{validateImplementation(e,t){const n=super.validateImplementation(e,t);return n.valid&&(n.blockchain="bsc"),n}}class h extends I{validateImplementation(e,t){const n=super.validateImplementation(e,t);return n.valid&&(n.blockchain="avalanche"),n}}class m extends I{validateImplementation(e,t){const n=super.validateImplementation(e,t);return n.valid&&(n.blockchain="arbitrum"),n}}class A extends I{validateImplementation(e,t){const n=super.validateImplementation(e,t);return n.valid&&(n.blockchain="optimism"),n}}class x extends I{validateImplementation(e,t){const n=super.validateImplementation(e,t);return n.valid&&(n.blockchain="base"),n}}class N extends I{constructor(e="evm"){super(),this.chain=e}validateImplementation(e,t){const n=super.validateImplementation(e,t);return n.valid&&(n.blockchain=this.chain),n}}export{m as ArbitrumValidator,h as AvalancheValidator,x as BaseValidator,u as BscValidator,N as EvmValidator,A as OptimismValidator};
1
+ import{EthereumValidator as e}from"./ethereum.mjs";import{E as t}from"./shared/base-CZZTeLCP.mjs";class a extends e{validateImplementation(e,t){const a=super.validateImplementation(e,t);return a.valid&&(a.blockchain="bsc"),a}}class n extends e{validateImplementation(e,t){const a=super.validateImplementation(e,t);return a.valid&&(a.blockchain="avalanche"),a}}class i extends e{validateImplementation(e,t){const a=super.validateImplementation(e,t);return a.valid&&(a.blockchain="arbitrum"),a}}class l extends e{validateImplementation(e,t){const a=super.validateImplementation(e,t);return a.valid&&(a.blockchain="optimism"),a}}class s extends e{validateImplementation(e,t){const a=super.validateImplementation(e,t);return a.valid&&(a.blockchain="base"),a}}class r extends e{constructor(e="evm"){if(super(),this.chain=e,!t.includes(e))throw new RangeError(`Unsupported EVM chain: ${String(e)}`)}validateImplementation(e,t){const a=super.validateImplementation(e,t);return a.valid&&(a.blockchain=this.chain),a}}export{i as ArbitrumValidator,n as AvalancheValidator,s as BaseValidator,a as BscValidator,r as EvmValidator,l as OptimismValidator};
@@ -1 +1 @@
1
- "use strict";const e=Object.freeze(["ethereum","polygon","bsc","avalanche","arbitrum","optimism","base","evm","fantom","sonic","gnosis","celo","cronos","moonbeam","moonriver","zksync","linea","scroll","mantle","blast","opbnb","zora","worldchain"]);var t;!function(e){e.INVALID_FORMAT="INVALID_FORMAT",e.INVALID_CHECKSUM="INVALID_CHECKSUM",e.INVALID_LENGTH="INVALID_LENGTH",e.INVALID_CHARACTERS="INVALID_CHARACTERS",e.UNSUPPORTED_CHAIN="UNSUPPORTED_CHAIN",e.BURN_ADDRESS="BURN_ADDRESS",e.UNSAFE_INPUT="UNSAFE_INPUT",e.NETWORK_MISMATCH="NETWORK_MISMATCH"}(t||(t={}));class r{static sanitize(e){if(null==e)throw new Error(t.UNSAFE_INPUT);if("string"!=typeof e)throw new Error(t.UNSAFE_INPUT);if(e.length>256)throw new Error(t.UNSAFE_INPUT);if(/[^\x20-\x7E]/.test(e))throw new Error(t.UNSAFE_INPUT);return e.trim()}}class n{validate(e,n){try{const o=r.sanitize(e),s=this.validateImplementation(o,n),i=s.details?.network;return s.valid&&i&&(n?.network&&"auto"!==n.network&&n.network!==i||!1===n?.allowTestnet&&"testnet"===i)?{valid:!1,error:"Address network does not match the requested network",details:{...s.details,errorCode:t.NETWORK_MISMATCH}}:s}catch(e){const r=e instanceof Error?e.message:String(e);return r===t.UNSAFE_INPUT?{valid:!1,error:"Unsafe input detected",details:{errorCode:t.UNSAFE_INPUT}}:{valid:!1,error:r,details:{errorCode:t.INVALID_FORMAT}}}}format(e,t){return o(e,t)}}function o(e,t,n=4){const o=r.sanitize(e);if(!t?.shorten)return o;const s=t.shortenLength??n;if(!Number.isSafeInteger(s)||s<1)throw new RangeError("shortenLength must be a positive integer");const i=o.startsWith("0x")?2:0;return o.length<=2*s+i+3?o:`${o.slice(0,s+i)}...${o.slice(-s)}`}function s(e){return e.startsWith("0x")?e.slice(2):e}function i(e){return e.startsWith("0x")?e:`0x${e}`}const a=(1n<<64n)-1n,c=[0,1,62,28,27,36,44,6,55,20,3,10,43,25,39,41,45,15,21,8,18,2,61,56,14],l=[0x0000000000000001n,0x0000000000008082n,0x800000000000808an,0x8000000080008000n,0x000000000000808bn,0x0000000080000001n,0x8000000080008081n,0x8000000000008009n,0x000000000000008an,0x0000000000000088n,0x0000000080008009n,0x000000008000000an,0x000000008000808bn,0x800000000000008bn,0x8000000000008089n,0x8000000000008003n,0x8000000000008002n,0x8000000000000080n,0x000000000000800an,0x800000008000000an,0x8000000080008081n,0x8000000000008080n,0x0000000080000001n,0x8000000080008008n];function d(e,t){return(e<<BigInt(t)|e>>BigInt(64-t))&a}function u(e){const t=new Array(5),r=new Array(25);for(const n of l){for(let r=0;r<5;r++)t[r]=e[r]^e[r+5]^e[r+10]^e[r+15]^e[r+20];for(let r=0;r<5;r++){const n=t[(r+4)%5]^d(t[(r+1)%5],1);for(let t=0;t<5;t++)e[r+5*t]^=n}for(let t=0;t<5;t++)for(let n=0;n<5;n++)r[n+(2*t+3*n)%5*5]=d(e[t+5*n],c[t+5*n]);for(let t=0;t<5;t++)for(let n=0;n<5;n++)e[t+5*n]=r[t+5*n]^~r[(t+1)%5+5*n]&r[(t+2)%5+5*n];e[0]^=n}}class h extends n{validateImplementation(e,r){const n=s(e);if(40!==n.length)return{valid:!1,error:"Invalid length",details:{errorCode:t.INVALID_LENGTH}};if(!function(e){if("string"!=typeof e)return!1;const t=e.startsWith("0x")?e.slice(2):e;return/^[0-9a-fA-F]*$/.test(t)}(n))return{valid:!1,error:"Invalid hex characters",details:{errorCode:t.INVALID_CHARACTERS}};if(!r?.allowBurnAddress&&/^0+$/.test(n))return{valid:!1,error:"Burn address detected",details:{errorCode:t.BURN_ADDRESS}};const o=this.isChecksummed(n);return(r?.strict||n!==n.toLowerCase()&&n!==n.toUpperCase())&&!o?{valid:!1,error:"Invalid checksum",details:{errorCode:t.INVALID_CHECKSUM}}:{valid:!0,blockchain:"ethereum",details:{checksum:o}}}format(e,t){let n=i(r.sanitize(e));return t?.checksum&&(n=this.toChecksumAddress(n)),o(n,t)}isChecksummed(e){const t=s(e);return i(t)===this.toChecksumAddress(t)}toChecksumAddress(e){const t=s(e).toLowerCase();if(!/^[0-9a-f]{40}$/.test(t))throw new Error("Expected a 20-byte hexadecimal address");const r=function(e){const t=(new TextEncoder).encode(e),r=new Uint8Array(136*(Math.floor(t.length/136)+1));r.set(t),r[t.length]=1,r[r.length-1]|=128;const n=new Array(25).fill(0n);for(let e=0;e<r.length;e+=136){for(let t=0;t<136;t++)n[t>>3]^=BigInt(r[e+t])<<BigInt(8*(7&t));u(n)}let o="";for(let e=0;e<32;e++)o+=Number(n[e>>3]>>BigInt(8*(7&e))&255n).toString(16).padStart(2,"0");return o}(t);return"0x"+[...t].map((e,t)=>parseInt(r[t],16)>=8?e.toUpperCase():e).join("")}}exports.addChecksum=function(t,n){return e.includes(n)?(new h).format(t,{checksum:!0}):r.sanitize(t)},exports.normalizeAddress=function(t,n){const o=r.sanitize(t);return e.includes(n)||"sui"===n||"aptos"===n?o.toLowerCase():o},exports.shortenAddress=function(e,t=4){return o(e,{shorten:!0,shortenLength:t})};
1
+ "use strict";var e=require("./shared/base-3sYui6r0.cjs"),r=require("./ethereum.cjs");exports.addChecksum=function(t,s){return e.EVM_CHAINS.includes(s)?(new r.EthereumValidator).format(t,{checksum:!0}):e.InputSanitizer.sanitize(t)},exports.normalizeAddress=function(r,t){const s=e.InputSanitizer.sanitize(r);return e.EVM_CHAINS.includes(t)||"sui"===t||"aptos"===t?s.toLowerCase():s},exports.shortenAddress=function(r,t=4){return e.formatPlainAddress(r,{shorten:!0,shortenLength:t})};
@@ -1 +1 @@
1
- const e=Object.freeze(["ethereum","polygon","bsc","avalanche","arbitrum","optimism","base","evm","fantom","sonic","gnosis","celo","cronos","moonbeam","moonriver","zksync","linea","scroll","mantle","blast","opbnb","zora","worldchain"]);var t;!function(e){e.INVALID_FORMAT="INVALID_FORMAT",e.INVALID_CHECKSUM="INVALID_CHECKSUM",e.INVALID_LENGTH="INVALID_LENGTH",e.INVALID_CHARACTERS="INVALID_CHARACTERS",e.UNSUPPORTED_CHAIN="UNSUPPORTED_CHAIN",e.BURN_ADDRESS="BURN_ADDRESS",e.UNSAFE_INPUT="UNSAFE_INPUT",e.NETWORK_MISMATCH="NETWORK_MISMATCH"}(t||(t={}));class r{static sanitize(e){if(null==e)throw new Error(t.UNSAFE_INPUT);if("string"!=typeof e)throw new Error(t.UNSAFE_INPUT);if(e.length>256)throw new Error(t.UNSAFE_INPUT);if(/[^\x20-\x7E]/.test(e))throw new Error(t.UNSAFE_INPUT);return e.trim()}}class n{validate(e,n){try{const o=r.sanitize(e),s=this.validateImplementation(o,n),i=s.details?.network;return s.valid&&i&&(n?.network&&"auto"!==n.network&&n.network!==i||!1===n?.allowTestnet&&"testnet"===i)?{valid:!1,error:"Address network does not match the requested network",details:{...s.details,errorCode:t.NETWORK_MISMATCH}}:s}catch(e){const r=e instanceof Error?e.message:String(e);return r===t.UNSAFE_INPUT?{valid:!1,error:"Unsafe input detected",details:{errorCode:t.UNSAFE_INPUT}}:{valid:!1,error:r,details:{errorCode:t.INVALID_FORMAT}}}}format(e,t){return o(e,t)}}function o(e,t,n=4){const o=r.sanitize(e);if(!t?.shorten)return o;const s=t.shortenLength??n;if(!Number.isSafeInteger(s)||s<1)throw new RangeError("shortenLength must be a positive integer");const i=o.startsWith("0x")?2:0;return o.length<=2*s+i+3?o:`${o.slice(0,s+i)}...${o.slice(-s)}`}function s(e){return e.startsWith("0x")?e.slice(2):e}function i(e){return e.startsWith("0x")?e:`0x${e}`}const a=(1n<<64n)-1n,c=[0,1,62,28,27,36,44,6,55,20,3,10,43,25,39,41,45,15,21,8,18,2,61,56,14],l=[0x0000000000000001n,0x0000000000008082n,0x800000000000808an,0x8000000080008000n,0x000000000000808bn,0x0000000080000001n,0x8000000080008081n,0x8000000000008009n,0x000000000000008an,0x0000000000000088n,0x0000000080008009n,0x000000008000000an,0x000000008000808bn,0x800000000000008bn,0x8000000000008089n,0x8000000000008003n,0x8000000000008002n,0x8000000000000080n,0x000000000000800an,0x800000008000000an,0x8000000080008081n,0x8000000000008080n,0x0000000080000001n,0x8000000080008008n];function d(e,t){return(e<<BigInt(t)|e>>BigInt(64-t))&a}function u(e){const t=new Array(5),r=new Array(25);for(const n of l){for(let r=0;r<5;r++)t[r]=e[r]^e[r+5]^e[r+10]^e[r+15]^e[r+20];for(let r=0;r<5;r++){const n=t[(r+4)%5]^d(t[(r+1)%5],1);for(let t=0;t<5;t++)e[r+5*t]^=n}for(let t=0;t<5;t++)for(let n=0;n<5;n++)r[n+(2*t+3*n)%5*5]=d(e[t+5*n],c[t+5*n]);for(let t=0;t<5;t++)for(let n=0;n<5;n++)e[t+5*n]=r[t+5*n]^~r[(t+1)%5+5*n]&r[(t+2)%5+5*n];e[0]^=n}}class h extends n{validateImplementation(e,r){const n=s(e);if(40!==n.length)return{valid:!1,error:"Invalid length",details:{errorCode:t.INVALID_LENGTH}};if(!function(e){if("string"!=typeof e)return!1;const t=e.startsWith("0x")?e.slice(2):e;return/^[0-9a-fA-F]*$/.test(t)}(n))return{valid:!1,error:"Invalid hex characters",details:{errorCode:t.INVALID_CHARACTERS}};if(!r?.allowBurnAddress&&/^0+$/.test(n))return{valid:!1,error:"Burn address detected",details:{errorCode:t.BURN_ADDRESS}};const o=this.isChecksummed(n);return(r?.strict||n!==n.toLowerCase()&&n!==n.toUpperCase())&&!o?{valid:!1,error:"Invalid checksum",details:{errorCode:t.INVALID_CHECKSUM}}:{valid:!0,blockchain:"ethereum",details:{checksum:o}}}format(e,t){let n=i(r.sanitize(e));return t?.checksum&&(n=this.toChecksumAddress(n)),o(n,t)}isChecksummed(e){const t=s(e);return i(t)===this.toChecksumAddress(t)}toChecksumAddress(e){const t=s(e).toLowerCase();if(!/^[0-9a-f]{40}$/.test(t))throw new Error("Expected a 20-byte hexadecimal address");const r=function(e){const t=(new TextEncoder).encode(e),r=new Uint8Array(136*(Math.floor(t.length/136)+1));r.set(t),r[t.length]=1,r[r.length-1]|=128;const n=new Array(25).fill(0n);for(let e=0;e<r.length;e+=136){for(let t=0;t<136;t++)n[t>>3]^=BigInt(r[e+t])<<BigInt(8*(7&t));u(n)}let o="";for(let e=0;e<32;e++)o+=Number(n[e>>3]>>BigInt(8*(7&e))&255n).toString(16).padStart(2,"0");return o}(t);return"0x"+[...t].map((e,t)=>parseInt(r[t],16)>=8?e.toUpperCase():e).join("")}}function I(e,t=4){return o(e,{shorten:!0,shortenLength:t})}function f(t,n){const o=r.sanitize(t);return e.includes(n)||"sui"===n||"aptos"===n?o.toLowerCase():o}function A(t,n){return e.includes(n)?(new h).format(t,{checksum:!0}):r.sanitize(t)}export{A as addChecksum,f as normalizeAddress,I as shortenAddress};
1
+ import{E as e,I as t,f as n}from"./shared/base-CZZTeLCP.mjs";import{EthereumValidator as s}from"./ethereum.mjs";function r(e,t=4){return n(e,{shorten:!0,shortenLength:t})}function o(n,s){const r=t.sanitize(n);return e.includes(s)||"sui"===s||"aptos"===s?r.toLowerCase():r}function i(n,r){return e.includes(r)?(new s).format(n,{checksum:!0}):t.sanitize(n)}export{i as addChecksum,o as normalizeAddress,r as shortenAddress};
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";const t=Object.freeze(["ethereum","polygon","bsc","avalanche","arbitrum","optimism","base","evm","fantom","sonic","gnosis","celo","cronos","moonbeam","moonriver","zksync","linea","scroll","mantle","blast","opbnb","zora","worldchain"]),e=Object.freeze(["cosmos","osmosis","celestia","injective","sei"]);var r;exports.ValidationError=void 0,(r=exports.ValidationError||(exports.ValidationError={})).INVALID_FORMAT="INVALID_FORMAT",r.INVALID_CHECKSUM="INVALID_CHECKSUM",r.INVALID_LENGTH="INVALID_LENGTH",r.INVALID_CHARACTERS="INVALID_CHARACTERS",r.UNSUPPORTED_CHAIN="UNSUPPORTED_CHAIN",r.BURN_ADDRESS="BURN_ADDRESS",r.UNSAFE_INPUT="UNSAFE_INPUT",r.NETWORK_MISMATCH="NETWORK_MISMATCH";class n{static sanitize(t){if(null==t)throw new Error(exports.ValidationError.UNSAFE_INPUT);if("string"!=typeof t)throw new Error(exports.ValidationError.UNSAFE_INPUT);if(t.length>256)throw new Error(exports.ValidationError.UNSAFE_INPUT);if(/[^\x20-\x7E]/.test(t))throw new Error(exports.ValidationError.UNSAFE_INPUT);return t.trim()}}class o{validate(t,e){try{const r=n.sanitize(t),o=this.validateImplementation(r,e),i=o.details?.network;return o.valid&&i&&(e?.network&&"auto"!==e.network&&e.network!==i||!1===e?.allowTestnet&&"testnet"===i)?{valid:!1,error:"Address network does not match the requested network",details:{...o.details,errorCode:exports.ValidationError.NETWORK_MISMATCH}}:o}catch(t){const e=t instanceof Error?t.message:String(t);return e===exports.ValidationError.UNSAFE_INPUT?{valid:!1,error:"Unsafe input detected",details:{errorCode:exports.ValidationError.UNSAFE_INPUT}}:{valid:!1,error:e,details:{errorCode:exports.ValidationError.INVALID_FORMAT}}}}format(t,e){return i(t,e)}}function i(t,e,r=4){const o=n.sanitize(t);if(!e?.shorten)return o;const i=e.shortenLength??r;if(!Number.isSafeInteger(i)||i<1)throw new RangeError("shortenLength must be a positive integer");const a=o.startsWith("0x")?2:0;return o.length<=2*i+a+3?o:`${o.slice(0,i+a)}...${o.slice(-i)}`}function a(t){return t.startsWith("0x")?t.slice(2):t}function s(t){return t.startsWith("0x")?t:`0x${t}`}const l=(1n<<64n)-1n,c=[0,1,62,28,27,36,44,6,55,20,3,10,43,25,39,41,45,15,21,8,18,2,61,56,14],d=[0x0000000000000001n,0x0000000000008082n,0x800000000000808an,0x8000000080008000n,0x000000000000808bn,0x0000000080000001n,0x8000000080008081n,0x8000000000008009n,0x000000000000008an,0x0000000000000088n,0x0000000080008009n,0x000000008000000an,0x000000008000808bn,0x800000000000008bn,0x8000000000008089n,0x8000000000008003n,0x8000000000008002n,0x8000000000000080n,0x000000000000800an,0x800000008000000an,0x8000000080008081n,0x8000000000008080n,0x0000000080000001n,0x8000000080008008n];function h(t,e){return(t<<BigInt(e)|t>>BigInt(64-e))&l}function u(t){const e=new Array(5),r=new Array(25);for(const n of d){for(let r=0;r<5;r++)e[r]=t[r]^t[r+5]^t[r+10]^t[r+15]^t[r+20];for(let r=0;r<5;r++){const n=e[(r+4)%5]^h(e[(r+1)%5],1);for(let e=0;e<5;e++)t[r+5*e]^=n}for(let e=0;e<5;e++)for(let n=0;n<5;n++)r[n+(2*e+3*n)%5*5]=h(t[e+5*n],c[e+5*n]);for(let e=0;e<5;e++)for(let n=0;n<5;n++)t[e+5*n]=r[e+5*n]^~r[(e+1)%5+5*n]&r[(e+2)%5+5*n];t[0]^=n}}class f extends o{validateImplementation(t,e){const r=a(t);if(40!==r.length)return{valid:!1,error:"Invalid length",details:{errorCode:exports.ValidationError.INVALID_LENGTH}};if(!function(t){if("string"!=typeof t)return!1;const e=t.startsWith("0x")?t.slice(2):t;return/^[0-9a-fA-F]*$/.test(e)}(r))return{valid:!1,error:"Invalid hex characters",details:{errorCode:exports.ValidationError.INVALID_CHARACTERS}};if(!e?.allowBurnAddress&&/^0+$/.test(r))return{valid:!1,error:"Burn address detected",details:{errorCode:exports.ValidationError.BURN_ADDRESS}};const n=this.isChecksummed(r);return(e?.strict||r!==r.toLowerCase()&&r!==r.toUpperCase())&&!n?{valid:!1,error:"Invalid checksum",details:{errorCode:exports.ValidationError.INVALID_CHECKSUM}}:{valid:!0,blockchain:"ethereum",details:{checksum:n}}}format(t,e){let r=s(n.sanitize(t));return e?.checksum&&(r=this.toChecksumAddress(r)),i(r,e)}isChecksummed(t){const e=a(t);return s(e)===this.toChecksumAddress(e)}toChecksumAddress(t){const e=a(t).toLowerCase();if(!/^[0-9a-f]{40}$/.test(e))throw new Error("Expected a 20-byte hexadecimal address");const r=function(t){const e=(new TextEncoder).encode(t),r=new Uint8Array(136*(Math.floor(e.length/136)+1));r.set(e),r[e.length]=1,r[r.length-1]|=128;const n=new Array(25).fill(0n);for(let t=0;t<r.length;t+=136){for(let e=0;e<136;e++)n[e>>3]^=BigInt(r[t+e])<<BigInt(8*(7&e));u(n)}let o="";for(let t=0;t<32;t++)o+=Number(n[t>>3]>>BigInt(8*(7&t))&255n).toString(16).padStart(2,"0");return o}(e);return"0x"+[...e].map((t,e)=>parseInt(r[e],16)>=8?t.toUpperCase():t).join("")}}const p="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",m=p.charAt(0),v={};for(let t=0;t<58;t++)v[p.charAt(t)]=t;function x(t){if(0===t.length)return new Uint8Array(0);let e=0;for(;e<t.length&&t[e]===m;)e++;const r=e,n=[0];for(;e<t.length;e++){const r=t[e],o=v[r];if(void 0===o)throw new Error(`Invalid Base58 character: ${r}`);for(let t=0;t<n.length;t++)n[t]*=58;n[0]+=o;let i=0;for(let t=0;t<n.length;++t)n[t]+=i,i=n[t]>>8,n[t]&=255;for(;i;)n.push(255&i),i>>=8}const o=t.length===r?[]:n.reverse();return Uint8Array.from([...new Array(r).fill(0),...o])}class I extends o{validateImplementation(t){if(t.length<32||t.length>44)return{valid:!1,error:"Invalid length",details:{errorCode:exports.ValidationError.INVALID_LENGTH}};try{if(32!==x(t).length)return{valid:!1,error:"Invalid public key length",details:{errorCode:exports.ValidationError.INVALID_LENGTH}}}catch{return{valid:!1,error:"Invalid Base58 characters",details:{errorCode:exports.ValidationError.INVALID_FORMAT}}}return"11111111111111111111111111111111"===t?{valid:!0,blockchain:"solana",details:{format:"System Program"}}:{valid:!0,blockchain:"solana"}}}function g(t){const e=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],r=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],n=8*t.length,o=t.length,i=new Uint8Array(64-(o+8)%64+8);i[0]=128;const a=n,s=Math.floor(a/4294967296),l=a%4294967296,c=i.length;i[c-4]=l>>>24&255,i[c-3]=l>>>16&255,i[c-2]=l>>>8&255,i[c-1]=255&l,i[c-8]=s>>>24&255,i[c-7]=s>>>16&255,i[c-6]=s>>>8&255,i[c-5]=255&s;const d=new Uint8Array(o+i.length);d.set(t),d.set(i,o);const h=new Uint32Array(64);for(let t=0;t<d.length;t+=64){for(let e=0;e<16;e++)h[e]=d[t+4*e]<<24|d[t+4*e+1]<<16|d[t+4*e+2]<<8|d[t+4*e+3];for(let t=16;t<64;t++){const e=A(h[t-2],17)^A(h[t-2],19)^h[t-2]>>>10,r=A(h[t-15],7)^A(h[t-15],18)^h[t-15]>>>3;h[t]=e+h[t-7]+r+h[t-16]|0}let n=r[0],o=r[1],i=r[2],a=r[3],s=r[4],l=r[5],c=r[6],u=r[7];for(let t=0;t<64;t++){const r=u+(A(s,6)^A(s,11)^A(s,25))+(s&l^~s&c)+e[t]+h[t]|0,d=n&o^n&i^o&i;u=c,c=l,l=s,s=a+r|0,a=i,i=o,o=n,n=r+((A(n,2)^A(n,13)^A(n,22))+d|0)|0}r[0]=r[0]+n|0,r[1]=r[1]+o|0,r[2]=r[2]+i|0,r[3]=r[3]+a|0,r[4]=r[4]+s|0,r[5]=r[5]+l|0,r[6]=r[6]+c|0,r[7]=r[7]+u|0}const u=new Uint8Array(32);for(let t=0;t<8;t++)u[4*t]=r[t]>>>24&255,u[4*t+1]=r[t]>>>16&255,u[4*t+2]=r[t]>>>8&255,u[4*t+3]=255&r[t];return u}function A(t,e){return t>>>e|t<<32-e}function E(t){try{const e=x(t);if(e.length<5)return null;const r=e.slice(0,-4),n=g(g(r));return e.slice(-4).every((t,e)=>t===n[e])?r:null}catch{return null}}var w;!function(t){t.BECH32="bech32",t.BECH32M="bech32m"}(w||(w={}));const C=[996825010,642813549,513874426,1027748829,705979059];function V(t,e,r){const n=r===w.BECH32M?734539939:1;return function(t){let e=1;for(const r of t){const t=e>>25;e=(33554431&e)<<5^r;for(let r=0;r<5;r++)t>>r&1&&(e^=C[r])}return e}(function(t){const e=[];for(let r=0;r<t.length;r++)e.push(t.charCodeAt(r)>>5);e.push(0);for(let r=0;r<t.length;r++)e.push(31&t.charCodeAt(r));return e}(t).concat(e))===n}function N(t,e=90){if(t.length<8||t.length>e)return null;const r=t.toLowerCase();if(t!==r&&t!==t.toUpperCase())return null;const n=r.lastIndexOf("1");if(n<1||n+7>r.length)return null;const o=r.substring(0,n);if(/[^\x21-\x7E]/.test(o))return null;const i=[];for(let t=n+1;t<r.length;t++){const e="qpzry9x8gf2tvdw0s3jn54khce6mua7l".indexOf(r[t]);if(-1===e)return null;i.push(e)}return V(o,i,w.BECH32)?{hrp:o,data:i.slice(0,i.length-6),encoding:w.BECH32}:V(o,i,w.BECH32M)?{hrp:o,data:i.slice(0,i.length-6),encoding:w.BECH32M}:null}function k(t){let e=0,r=0;const n=[];for(const o of t){if(!Number.isInteger(o)||o<0||o>31)return null;e=65535&(e<<5|o),r+=5,r>=8&&(r-=8,n.push(e>>>r&255))}return r>=5||e<<8-r&255?null:Uint8Array.from(n)}class b extends o{constructor(t){super(),this.config=t}validateImplementation(t){const e=t.toLowerCase().split("1")[0];if(this.config.hrps&&Object.prototype.hasOwnProperty.call(this.config.hrps,e))return this.validateWitness(t,this.config.hrps[e]);if(t.length<26||t.length>35)return this.invalid("Invalid address length",exports.ValidationError.INVALID_LENGTH);const r=E(t);if(!r)return this.invalid("Invalid Base58Check address",exports.ValidationError.INVALID_CHECKSUM);if(21!==r.length)return this.invalid("Invalid payload length",exports.ValidationError.INVALID_LENGTH);const n=this.config.versions[r[0]];return n?{valid:!0,blockchain:this.config.chain,details:{format:"legacy",network:n,checksum:!0}}:this.invalid("Invalid address version")}validateWitness(t,e){const r=N(t);if(!r||0===r.data.length)return this.invalid("Invalid Bech32 encoding");const n=r.data[0],o=k(r.data.slice(1));if(n>16)return this.invalid("Invalid witness version");if(!o||o.length<2||o.length>40||0===n&&20!==o.length&&32!==o.length)return this.invalid("Invalid witness program or padding",exports.ValidationError.INVALID_LENGTH);const i=0===n?w.BECH32:w.BECH32M;if(r.encoding!==i)return this.invalid("Wrong checksum encoding for witness version",exports.ValidationError.INVALID_CHECKSUM);const a=0===n?"segwit":1===n&&32===o.length?"taproot":"future";return{valid:!0,blockchain:this.config.chain,details:{format:a,network:e,checksum:!0}}}invalid(t,e=exports.ValidationError.INVALID_FORMAT){return{valid:!1,error:t,details:{errorCode:e}}}}class L extends b{constructor(){super({chain:"bitcoin",versions:{0:"mainnet",5:"mainnet",111:"testnet",196:"testnet"},hrps:{bc:"mainnet",tb:"testnet"}})}}class T extends b{constructor(){super({chain:"litecoin",versions:{48:"mainnet",50:"mainnet",5:"mainnet",111:"testnet",58:"testnet",196:"testnet"},hrps:{ltc:"mainnet",tltc:"testnet"}})}}class _ extends b{constructor(){super({chain:"dogecoin",versions:{30:"mainnet",22:"mainnet",113:"testnet",196:"testnet"}})}}class y{constructor(t){this.data=t,this.offset=0}head(t){if(this.offset>=this.data.length)throw new Error("Truncated CBOR");const e=this.data[this.offset++];if(e>>>5!==t)throw new Error("Invalid CBOR type");const r=31&e;if(r<24)return r;if(r>26)throw new Error("Unsupported CBOR length");const n=1<<r-24;if(this.offset+n>this.data.length)throw new Error("Truncated CBOR");let o=0;for(let t=0;t<n;t++)o=256*o+this.data[this.offset++];return o}bytes(){const t=this.head(2);if(this.offset+t>this.data.length)throw new Error("Truncated bytes");const e=this.data.slice(this.offset,this.offset+t);return this.offset+=t,e}end(){if(this.offset!==this.data.length)throw new Error("Trailing CBOR data")}}class S extends o{validateImplementation(t){if(/^(addr|stake)(_test)?1/i.test(t))return this.validateShelley(t);try{const e=function(t){try{const e=new y(t);if(2!==e.head(4)||24!==e.head(6))return null;const r=e.bytes();if(e.head(0)!==function(t){let e=4294967295;for(const r of t){e^=r;for(let t=0;t<8;t++)e=e>>>1^(1&e?3988292384:0)}return(4294967295^e)>>>0}(r))return null;e.end();const n=new y(r);if(3!==n.head(4)||28!==n.bytes().length)return null;const o=n.head(5);if(o>r.length)return null;const i=new Set;let a="mainnet";for(let t=0;t<o;t++){const t=n.head(0);if(i.has(t)||t>255)return null;i.add(t);const e=n.bytes();if(1===t){const t=new y(e);if(28!==t.bytes().length)return null;t.end()}if(2===t){const t=new y(e);t.head(0),t.end(),a="testnet"}}const s=n.head(0);return 0!==s&&2!==s?null:(n.end(),a)}catch{return null}}(x(t));if(e)return{valid:!0,blockchain:"cardano",details:{format:"byron",network:e,checksum:!0}}}catch{}return this.invalid()}validateShelley(t){const e=N(t,256),r=e&&k(e.data);if(!e||e.encoding!==w.BECH32||!r?.length)return this.invalid();const n=r[0]>>>4,o=15&r[0];if(0!==o&&1!==o)return this.invalid();const i=14===n||15===n,a=(i?"stake":"addr")+(0===o?"_test":"");if(e.hrp!==a)return this.invalid();let s=!1;return n<=3?s=57===r.length:6===n||7===n||i?s=29===r.length:4!==n&&5!==n||(s=this.validPointer(r)),s?{valid:!0,blockchain:"cardano",details:{format:i?"stake":"shelley",network:1===o?"mainnet":"testnet",checksum:!0}}:this.invalid()}validPointer(t){let e=29;for(let r=0;r<3;r++){let r=0n;const n=e;do{if(e>=t.length||e-n>=10)return!1;r=r<<7n|BigInt(127&t[e])}while(128&t[e++]);if(e-n>1&&128===t[n]||r>0xffffffffffffffffn)return!1}return e===t.length}invalid(){return{valid:!1,error:"Invalid Cardano address structure, network, or checksum",details:{errorCode:exports.ValidationError.INVALID_FORMAT}}}format(t,e){return i(t,e,8)}}const U="rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz",D=U.charAt(0),R={};for(let t=0;t<58;t++)R[U.charAt(t)]=t;class H extends o{validateImplementation(t){if(!t.startsWith("r"))return{valid:!1,error:"Must start with r",details:{errorCode:exports.ValidationError.INVALID_FORMAT}};if(t.length<25||t.length>35)return{valid:!1,error:"Invalid length",details:{errorCode:exports.ValidationError.INVALID_LENGTH}};try{const e=function(t){if(0===t.length)return new Uint8Array(0);let e=0;for(;e<t.length&&t[e]===D;)e++;const r=e,n=[0];for(;e<t.length;e++){const r=t[e],o=R[r];if(void 0===o)throw new Error(`Invalid Ripple Base58 character: ${r}`);for(let t=0;t<n.length;t++)n[t]*=58;n[0]+=o;let i=0;for(let t=0;t<n.length;++t)n[t]+=i,i=n[t]>>8,n[t]&=255;for(;i;)n.push(255&i),i>>=8}let o=[];t.length!==r&&(o=n.reverse());for(let t=0;t<r;t++)o.unshift(0);return new Uint8Array(o)}(t);if(25!==e.length||0!==e[0])return{valid:!1,error:"Invalid decoded length",details:{errorCode:exports.ValidationError.INVALID_LENGTH}};const r=e.slice(0,21),n=e.slice(21),o=g(r),i=g(o);return i[0]!==n[0]||i[1]!==n[1]||i[2]!==n[2]||i[3]!==n[3]?{valid:!1,error:"Invalid checksum",details:{errorCode:exports.ValidationError.INVALID_CHECKSUM}}:{valid:!0,blockchain:"ripple"}}catch{return{valid:!1,error:"Invalid characters",details:{errorCode:exports.ValidationError.INVALID_CHARACTERS}}}}}class B extends f{constructor(t="evm"){super(),this.chain=t}validateImplementation(t,e){const r=super.validateImplementation(t,e);return r.valid&&(r.blockchain=this.chain),r}}class M extends o{validateImplementation(t){if(/^41[0-9a-fA-F]{40}$/.test(t))return{valid:!0,blockchain:"tron",details:{format:"hex",checksum:!1}};const e=34===t.length&&t.startsWith("T")?E(t):null;return e&&21===e.length&&65===e[0]?{valid:!0,blockchain:"tron",details:{format:"base58check",checksum:!0}}:{valid:!1,error:"Invalid TRON address",details:{errorCode:exports.ValidationError.INVALID_FORMAT}}}}const O={cosmos:"cosmos",osmosis:"osmo",celestia:"celestia",injective:"inj",sei:"sei"};class F extends o{constructor(t="cosmos"){super(),this.chain=t}validateImplementation(t){const e=N(t),r=e&&k(e.data),n="injective"===this.chain||"celestia"===this.chain?[20]:[20,32];return e&&e.hrp===O[this.chain]&&e.encoding===w.BECH32&&r&&n.includes(r.length)?{valid:!0,blockchain:this.chain,details:{format:"bech32",checksum:!0}}:{valid:!1,error:"Invalid account prefix, checksum, length, or padding",details:{errorCode:exports.ValidationError.INVALID_FORMAT}}}}class $ extends o{validateImplementation(t){return/^0x[0-9a-fA-F]{64}$/.test(t)?{valid:!0,blockchain:"sui",details:{format:"hex",checksum:!1}}:{valid:!1,error:"Expected 0x followed by 64 hex digits",details:{errorCode:exports.ValidationError.INVALID_FORMAT}}}}class P extends o{validateImplementation(t,e){const r=/^0x[0-9a-fA-F]{64}$/.test(t),n=/^0x[0-9a-f]$/.test(t),o=n||/^0x[0-9a-f]{64}$/.test(t)&&!/^0x0{63}[0-9a-f]$/.test(t);return(e?.strict?o:r||n)?{valid:!0,blockchain:"aptos",details:{format:"hex",checksum:!1}}:{valid:!1,error:"Invalid Aptos address (AIP-40)",details:{errorCode:exports.ValidationError.INVALID_FORMAT}}}format(t,e){if(!this.validate(t).valid)throw new Error("Invalid Aptos address");let r=t.trim().toLowerCase();return/^0x0{63}[0-9a-f]$/.test(r)&&(r="0x"+r.slice(-1)),i(r,e)}}class z extends o{validateImplementation(t){if(t.length<2||t.length>64||!/^[a-z0-9]+(?:[._-][a-z0-9]+)*$/.test(t))return{valid:!1,error:"Invalid NEAR account ID",details:{errorCode:exports.ValidationError.INVALID_FORMAT}};return{valid:!0,blockchain:"near",details:{format:/^[0-9a-f]{64}$/.test(t)||/^0x[0-9a-f]{40}$/.test(t)?"implicit":/^0s[0-9a-f]{40}$/.test(t)?"deterministic":/^0u[0-9a-hjkmnp-tv-z]{51}[0g]$/.test(t)?"universal":"named",checksum:!1}}}}const j=new Map;for(const e of t)j.set(e,"ethereum"===e?new f:new B(e));for(const t of e)j.set(t,new F(t));j.set("bitcoin",new L),j.set("litecoin",new T),j.set("dogecoin",new _),j.set("solana",new I),j.set("ripple",new H),j.set("cardano",new S),j.set("tron",new M),j.set("sui",new $),j.set("aptos",new P),j.set("near",new z);const W=Object.freeze([...j.keys()]);function G(t){const e=j.get(t);if(!e)throw new Error(`Unsupported blockchain: ${String(t)}`);return e}exports.AddressValidator=o,exports.AptosValidator=P,exports.ArbitrumValidator=class extends f{validateImplementation(t,e){const r=super.validateImplementation(t,e);return r.valid&&(r.blockchain="arbitrum"),r}},exports.AvalancheValidator=class extends f{validateImplementation(t,e){const r=super.validateImplementation(t,e);return r.valid&&(r.blockchain="avalanche"),r}},exports.BaseValidator=class extends f{validateImplementation(t,e){const r=super.validateImplementation(t,e);return r.valid&&(r.blockchain="base"),r}},exports.BitcoinValidator=L,exports.BscValidator=class extends f{validateImplementation(t,e){const r=super.validateImplementation(t,e);return r.valid&&(r.blockchain="bsc"),r}},exports.COSMOS_CHAINS=e,exports.CardanoValidator=S,exports.CosmosValidator=F,exports.DogecoinValidator=_,exports.EVM_CHAINS=t,exports.EthereumValidator=f,exports.EvmValidator=B,exports.LitecoinValidator=T,exports.NearValidator=z,exports.OptimismValidator=class extends f{validateImplementation(t,e){const r=super.validateImplementation(t,e);return r.valid&&(r.blockchain="optimism"),r}},exports.PolygonValidator=class extends f{validateImplementation(t,e){const r=super.validateImplementation(t,e);return r.valid&&(r.blockchain="polygon"),r}},exports.RippleValidator=H,exports.SUPPORTED_CHAINS=W,exports.SolanaValidator=I,exports.SuiValidator=$,exports.TronValidator=M,exports.addChecksum=function(e,r){return t.includes(r)?(new f).format(e,{checksum:!0}):n.sanitize(e)},exports.detectBlockchain=function(e,r){let o;try{o=n.sanitize(e)}catch{return null}if(!o)return null;const i=[];G("ethereum").validate(o,r).valid&&i.push(...t);for(const e of W)t.includes(e)||("near"!==e||/(\.near|\.testnet)$/.test(o)||/^[0-9a-f]{64}$/.test(o)||/^0[xs][0-9a-f]{40}$/.test(o)||/^0u[0-9a-hjkmnp-tv-z]{51}[0g]$/.test(o))&&G(e).validate(o,r).valid&&i.push(e);return 0===i.length?null:1===i.length?i[0]:i},exports.formatAddress=function(t,e,r){return G(e).format(t,r)},exports.isSupportedChain=function(t){return"string"==typeof t&&j.has(t)},exports.normalizeAddress=function(e,r){const o=n.sanitize(e);return t.includes(r)||"sui"===r||"aptos"===r?o.toLowerCase():o},exports.shortenAddress=function(t,e=4){return i(t,{shorten:!0,shortenLength:e})},exports.validateAddress=function(t,e,r){return G(e).validate(t,r)},exports.validateBatch=function(t,e,r){const n=G(e);return t.map(t=>n.validate(t,r))};
1
+ "use strict";var r=require("./ethereum.cjs"),e=require("./solana.cjs"),t=require("./bitcoin.cjs"),a=require("./litecoin.cjs"),o=require("./dogecoin.cjs"),i=require("./cardano.cjs"),s=require("./ripple.cjs"),n=require("./evm.cjs"),d=require("./shared/base-3sYui6r0.cjs"),l=require("./tron.cjs"),c=require("./cosmos.cjs"),p=require("./move.cjs"),u=require("./near.cjs"),V=require("./formatters.cjs");require("./shared/base58-DV6hu8Kq.cjs"),require("./shared/utxo-DF5Lt3lY.cjs"),require("./shared/base58check-BeCwnkGe.cjs"),require("./shared/bech32-Dk6Pnay4.cjs");class m extends r.EthereumValidator{validateImplementation(r,e){const t=super.validateImplementation(r,e);return t.valid&&(t.blockchain="polygon"),t}}const h=new Map;for(const e of d.EVM_CHAINS)h.set(e,"ethereum"===e?new r.EthereumValidator:new n.EvmValidator(e));for(const r of d.COSMOS_CHAINS)h.set(r,new c.CosmosValidator(r));h.set("bitcoin",new t.BitcoinValidator),h.set("litecoin",new a.LitecoinValidator),h.set("dogecoin",new o.DogecoinValidator),h.set("solana",new e.SolanaValidator),h.set("ripple",new s.RippleValidator),h.set("cardano",new i.CardanoValidator),h.set("tron",new l.TronValidator),h.set("sui",new p.SuiValidator),h.set("aptos",new p.AptosValidator),h.set("near",new u.NearValidator);const x=Object.freeze([...h.keys()]);function A(r){const e=h.get(r);if(!e)throw new Error(`Unsupported blockchain: ${String(r)}`);return e}const f=x.filter(r=>!d.EVM_CHAINS.includes(r));exports.EthereumValidator=r.EthereumValidator,exports.SolanaValidator=e.SolanaValidator,exports.BitcoinValidator=t.BitcoinValidator,exports.LitecoinValidator=a.LitecoinValidator,exports.DogecoinValidator=o.DogecoinValidator,exports.CardanoValidator=i.CardanoValidator,exports.RippleValidator=s.RippleValidator,exports.ArbitrumValidator=n.ArbitrumValidator,exports.AvalancheValidator=n.AvalancheValidator,exports.BaseValidator=n.BaseValidator,exports.BscValidator=n.BscValidator,exports.EvmValidator=n.EvmValidator,exports.OptimismValidator=n.OptimismValidator,exports.AddressValidator=d.AddressValidator,exports.COSMOS_CHAINS=d.COSMOS_CHAINS,exports.EVM_CHAINS=d.EVM_CHAINS,Object.defineProperty(exports,"ValidationError",{enumerable:!0,get:function(){return d.ValidationError}}),exports.TronValidator=l.TronValidator,exports.CosmosValidator=c.CosmosValidator,exports.AptosValidator=p.AptosValidator,exports.SuiValidator=p.SuiValidator,exports.NearValidator=u.NearValidator,exports.addChecksum=V.addChecksum,exports.normalizeAddress=V.normalizeAddress,exports.shortenAddress=V.shortenAddress,exports.PolygonValidator=m,exports.SUPPORTED_CHAINS=x,exports.detectBlockchain=function(r,e){d.assertValidationOptions(e);const t=d.InputSanitizer.trySanitize(r);if(!t)return null;const a=[];A("ethereum").validate(t,e).valid&&a.push(...d.EVM_CHAINS);for(const r of f){const o=A(r).validate(t,e);o.valid&&(("near"!==r||"named"!==o.details?.format||t.endsWith(".near")||t.endsWith(".testnet"))&&a.push(r))}return 0===a.length?null:1===a.length?a[0]:a},exports.formatAddress=function(r,e,t){return A(e).format(r,t)},exports.isSupportedChain=function(r){return"string"==typeof r&&h.has(r)},exports.validateAddress=function(r,e,t){return A(e).validate(r,t)},exports.validateBatch=function(r,e,t){const a=A(e);if(d.assertValidationOptions(t),!Array.isArray(r))return Array.from(r,r=>a.validate(r,t));const o=r.length,i=new Array(o);for(let e=0;e<o;e++){const o=Object.prototype.hasOwnProperty.call(r,e)?r[e]:void 0;i[e]=a.validate(o,t)}return i};
package/dist/index.d.cts CHANGED
@@ -50,8 +50,6 @@ declare abstract class AddressValidator {
50
50
  declare class EthereumValidator extends AddressValidator {
51
51
  protected validateImplementation(address: string, options?: ValidationOptions): ValidationResult;
52
52
  format(address: string, options?: FormatOptions): string;
53
- private isChecksummed;
54
- private toChecksumAddress;
55
53
  }
56
54
 
57
55
  declare class SolanaValidator extends AddressValidator {
package/dist/index.d.mts CHANGED
@@ -50,8 +50,6 @@ declare abstract class AddressValidator {
50
50
  declare class EthereumValidator extends AddressValidator {
51
51
  protected validateImplementation(address: string, options?: ValidationOptions): ValidationResult;
52
52
  format(address: string, options?: FormatOptions): string;
53
- private isChecksummed;
54
- private toChecksumAddress;
55
53
  }
56
54
 
57
55
  declare class SolanaValidator extends AddressValidator {
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- const t=Object.freeze(["ethereum","polygon","bsc","avalanche","arbitrum","optimism","base","evm","fantom","sonic","gnosis","celo","cronos","moonbeam","moonriver","zksync","linea","scroll","mantle","blast","opbnb","zora","worldchain"]),e=Object.freeze(["cosmos","osmosis","celestia","injective","sei"]);var n;!function(t){t.INVALID_FORMAT="INVALID_FORMAT",t.INVALID_CHECKSUM="INVALID_CHECKSUM",t.INVALID_LENGTH="INVALID_LENGTH",t.INVALID_CHARACTERS="INVALID_CHARACTERS",t.UNSUPPORTED_CHAIN="UNSUPPORTED_CHAIN",t.BURN_ADDRESS="BURN_ADDRESS",t.UNSAFE_INPUT="UNSAFE_INPUT",t.NETWORK_MISMATCH="NETWORK_MISMATCH"}(n||(n={}));class r{static sanitize(t){if(null==t)throw new Error(n.UNSAFE_INPUT);if("string"!=typeof t)throw new Error(n.UNSAFE_INPUT);if(t.length>256)throw new Error(n.UNSAFE_INPUT);if(/[^\x20-\x7E]/.test(t))throw new Error(n.UNSAFE_INPUT);return t.trim()}}class s{validate(t,e){try{const s=r.sanitize(t),i=this.validateImplementation(s,e),a=i.details?.network;return i.valid&&a&&(e?.network&&"auto"!==e.network&&e.network!==a||!1===e?.allowTestnet&&"testnet"===a)?{valid:!1,error:"Address network does not match the requested network",details:{...i.details,errorCode:n.NETWORK_MISMATCH}}:i}catch(t){const e=t instanceof Error?t.message:String(t);return e===n.UNSAFE_INPUT?{valid:!1,error:"Unsafe input detected",details:{errorCode:n.UNSAFE_INPUT}}:{valid:!1,error:e,details:{errorCode:n.INVALID_FORMAT}}}}format(t,e){return i(t,e)}}function i(t,e,n=4){const s=r.sanitize(t);if(!e?.shorten)return s;const i=e.shortenLength??n;if(!Number.isSafeInteger(i)||i<1)throw new RangeError("shortenLength must be a positive integer");const a=s.startsWith("0x")?2:0;return s.length<=2*i+a+3?s:`${s.slice(0,i+a)}...${s.slice(-i)}`}function a(t){return t.startsWith("0x")?t.slice(2):t}function o(t){return t.startsWith("0x")?t:`0x${t}`}const l=(1n<<64n)-1n,c=[0,1,62,28,27,36,44,6,55,20,3,10,43,25,39,41,45,15,21,8,18,2,61,56,14],d=[0x0000000000000001n,0x0000000000008082n,0x800000000000808an,0x8000000080008000n,0x000000000000808bn,0x0000000080000001n,0x8000000080008081n,0x8000000000008009n,0x000000000000008an,0x0000000000000088n,0x0000000080008009n,0x000000008000000an,0x000000008000808bn,0x800000000000008bn,0x8000000000008089n,0x8000000000008003n,0x8000000000008002n,0x8000000000000080n,0x000000000000800an,0x800000008000000an,0x8000000080008081n,0x8000000000008080n,0x0000000080000001n,0x8000000080008008n];function h(t,e){return(t<<BigInt(e)|t>>BigInt(64-e))&l}function u(t){const e=new Array(5),n=new Array(25);for(const r of d){for(let n=0;n<5;n++)e[n]=t[n]^t[n+5]^t[n+10]^t[n+15]^t[n+20];for(let n=0;n<5;n++){const r=e[(n+4)%5]^h(e[(n+1)%5],1);for(let e=0;e<5;e++)t[n+5*e]^=r}for(let e=0;e<5;e++)for(let r=0;r<5;r++)n[r+(2*e+3*r)%5*5]=h(t[e+5*r],c[e+5*r]);for(let e=0;e<5;e++)for(let r=0;r<5;r++)t[e+5*r]=n[e+5*r]^~n[(e+1)%5+5*r]&n[(e+2)%5+5*r];t[0]^=r}}class f extends s{validateImplementation(t,e){const r=a(t);if(40!==r.length)return{valid:!1,error:"Invalid length",details:{errorCode:n.INVALID_LENGTH}};if(!function(t){if("string"!=typeof t)return!1;const e=t.startsWith("0x")?t.slice(2):t;return/^[0-9a-fA-F]*$/.test(e)}(r))return{valid:!1,error:"Invalid hex characters",details:{errorCode:n.INVALID_CHARACTERS}};if(!e?.allowBurnAddress&&/^0+$/.test(r))return{valid:!1,error:"Burn address detected",details:{errorCode:n.BURN_ADDRESS}};const s=this.isChecksummed(r);return(e?.strict||r!==r.toLowerCase()&&r!==r.toUpperCase())&&!s?{valid:!1,error:"Invalid checksum",details:{errorCode:n.INVALID_CHECKSUM}}:{valid:!0,blockchain:"ethereum",details:{checksum:s}}}format(t,e){let n=o(r.sanitize(t));return e?.checksum&&(n=this.toChecksumAddress(n)),i(n,e)}isChecksummed(t){const e=a(t);return o(e)===this.toChecksumAddress(e)}toChecksumAddress(t){const e=a(t).toLowerCase();if(!/^[0-9a-f]{40}$/.test(e))throw new Error("Expected a 20-byte hexadecimal address");const n=function(t){const e=(new TextEncoder).encode(t),n=new Uint8Array(136*(Math.floor(e.length/136)+1));n.set(e),n[e.length]=1,n[n.length-1]|=128;const r=new Array(25).fill(0n);for(let t=0;t<n.length;t+=136){for(let e=0;e<136;e++)r[e>>3]^=BigInt(n[t+e])<<BigInt(8*(7&e));u(r)}let s="";for(let t=0;t<32;t++)s+=Number(r[t>>3]>>BigInt(8*(7&t))&255n).toString(16).padStart(2,"0");return s}(e);return"0x"+[...e].map((t,e)=>parseInt(n[e],16)>=8?t.toUpperCase():t).join("")}}const v="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",m=v.charAt(0),I={};for(let t=0;t<58;t++)I[v.charAt(t)]=t;function g(t){if(0===t.length)return new Uint8Array(0);let e=0;for(;e<t.length&&t[e]===m;)e++;const n=e,r=[0];for(;e<t.length;e++){const n=t[e],s=I[n];if(void 0===s)throw new Error(`Invalid Base58 character: ${n}`);for(let t=0;t<r.length;t++)r[t]*=58;r[0]+=s;let i=0;for(let t=0;t<r.length;++t)r[t]+=i,i=r[t]>>8,r[t]&=255;for(;i;)r.push(255&i),i>>=8}const s=t.length===n?[]:r.reverse();return Uint8Array.from([...new Array(n).fill(0),...s])}class p extends s{validateImplementation(t){if(t.length<32||t.length>44)return{valid:!1,error:"Invalid length",details:{errorCode:n.INVALID_LENGTH}};try{if(32!==g(t).length)return{valid:!1,error:"Invalid public key length",details:{errorCode:n.INVALID_LENGTH}}}catch{return{valid:!1,error:"Invalid Base58 characters",details:{errorCode:n.INVALID_FORMAT}}}return"11111111111111111111111111111111"===t?{valid:!0,blockchain:"solana",details:{format:"System Program"}}:{valid:!0,blockchain:"solana"}}}function A(t){const e=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],n=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],r=8*t.length,s=t.length,i=new Uint8Array(64-(s+8)%64+8);i[0]=128;const a=r,o=Math.floor(a/4294967296),l=a%4294967296,c=i.length;i[c-4]=l>>>24&255,i[c-3]=l>>>16&255,i[c-2]=l>>>8&255,i[c-1]=255&l,i[c-8]=o>>>24&255,i[c-7]=o>>>16&255,i[c-6]=o>>>8&255,i[c-5]=255&o;const d=new Uint8Array(s+i.length);d.set(t),d.set(i,s);const h=new Uint32Array(64);for(let t=0;t<d.length;t+=64){for(let e=0;e<16;e++)h[e]=d[t+4*e]<<24|d[t+4*e+1]<<16|d[t+4*e+2]<<8|d[t+4*e+3];for(let t=16;t<64;t++){const e=w(h[t-2],17)^w(h[t-2],19)^h[t-2]>>>10,n=w(h[t-15],7)^w(h[t-15],18)^h[t-15]>>>3;h[t]=e+h[t-7]+n+h[t-16]|0}let r=n[0],s=n[1],i=n[2],a=n[3],o=n[4],l=n[5],c=n[6],u=n[7];for(let t=0;t<64;t++){const n=u+(w(o,6)^w(o,11)^w(o,25))+(o&l^~o&c)+e[t]+h[t]|0,d=r&s^r&i^s&i;u=c,c=l,l=o,o=a+n|0,a=i,i=s,s=r,r=n+((w(r,2)^w(r,13)^w(r,22))+d|0)|0}n[0]=n[0]+r|0,n[1]=n[1]+s|0,n[2]=n[2]+i|0,n[3]=n[3]+a|0,n[4]=n[4]+o|0,n[5]=n[5]+l|0,n[6]=n[6]+c|0,n[7]=n[7]+u|0}const u=new Uint8Array(32);for(let t=0;t<8;t++)u[4*t]=n[t]>>>24&255,u[4*t+1]=n[t]>>>16&255,u[4*t+2]=n[t]>>>8&255,u[4*t+3]=255&n[t];return u}function w(t,e){return t>>>e|t<<32-e}function C(t){try{const e=g(t);if(e.length<5)return null;const n=e.slice(0,-4),r=A(A(n));return e.slice(-4).every((t,e)=>t===r[e])?n:null}catch{return null}}var x;!function(t){t.BECH32="bech32",t.BECH32M="bech32m"}(x||(x={}));const N=[996825010,642813549,513874426,1027748829,705979059];function E(t,e,n){const r=n===x.BECH32M?734539939:1;return function(t){let e=1;for(const n of t){const t=e>>25;e=(33554431&e)<<5^n;for(let n=0;n<5;n++)t>>n&1&&(e^=N[n])}return e}(function(t){const e=[];for(let n=0;n<t.length;n++)e.push(t.charCodeAt(n)>>5);e.push(0);for(let n=0;n<t.length;n++)e.push(31&t.charCodeAt(n));return e}(t).concat(e))===r}function k(t,e=90){if(t.length<8||t.length>e)return null;const n=t.toLowerCase();if(t!==n&&t!==t.toUpperCase())return null;const r=n.lastIndexOf("1");if(r<1||r+7>n.length)return null;const s=n.substring(0,r);if(/[^\x21-\x7E]/.test(s))return null;const i=[];for(let t=r+1;t<n.length;t++){const e="qpzry9x8gf2tvdw0s3jn54khce6mua7l".indexOf(n[t]);if(-1===e)return null;i.push(e)}return E(s,i,x.BECH32)?{hrp:s,data:i.slice(0,i.length-6),encoding:x.BECH32}:E(s,i,x.BECH32M)?{hrp:s,data:i.slice(0,i.length-6),encoding:x.BECH32M}:null}function b(t){let e=0,n=0;const r=[];for(const s of t){if(!Number.isInteger(s)||s<0||s>31)return null;e=65535&(e<<5|s),n+=5,n>=8&&(n-=8,r.push(e>>>n&255))}return n>=5||e<<8-n&255?null:Uint8Array.from(r)}class L extends s{constructor(t){super(),this.config=t}validateImplementation(t){const e=t.toLowerCase().split("1")[0];if(this.config.hrps&&Object.prototype.hasOwnProperty.call(this.config.hrps,e))return this.validateWitness(t,this.config.hrps[e]);if(t.length<26||t.length>35)return this.invalid("Invalid address length",n.INVALID_LENGTH);const r=C(t);if(!r)return this.invalid("Invalid Base58Check address",n.INVALID_CHECKSUM);if(21!==r.length)return this.invalid("Invalid payload length",n.INVALID_LENGTH);const s=this.config.versions[r[0]];return s?{valid:!0,blockchain:this.config.chain,details:{format:"legacy",network:s,checksum:!0}}:this.invalid("Invalid address version")}validateWitness(t,e){const r=k(t);if(!r||0===r.data.length)return this.invalid("Invalid Bech32 encoding");const s=r.data[0],i=b(r.data.slice(1));if(s>16)return this.invalid("Invalid witness version");if(!i||i.length<2||i.length>40||0===s&&20!==i.length&&32!==i.length)return this.invalid("Invalid witness program or padding",n.INVALID_LENGTH);const a=0===s?x.BECH32:x.BECH32M;if(r.encoding!==a)return this.invalid("Wrong checksum encoding for witness version",n.INVALID_CHECKSUM);const o=0===s?"segwit":1===s&&32===i.length?"taproot":"future";return{valid:!0,blockchain:this.config.chain,details:{format:o,network:e,checksum:!0}}}invalid(t,e=n.INVALID_FORMAT){return{valid:!1,error:t,details:{errorCode:e}}}}class T extends L{constructor(){super({chain:"bitcoin",versions:{0:"mainnet",5:"mainnet",111:"testnet",196:"testnet"},hrps:{bc:"mainnet",tb:"testnet"}})}}class y extends f{validateImplementation(t,e){const n=super.validateImplementation(t,e);return n.valid&&(n.blockchain="polygon"),n}}class _ extends L{constructor(){super({chain:"litecoin",versions:{48:"mainnet",50:"mainnet",5:"mainnet",111:"testnet",58:"testnet",196:"testnet"},hrps:{ltc:"mainnet",tltc:"testnet"}})}}class U extends L{constructor(){super({chain:"dogecoin",versions:{30:"mainnet",22:"mainnet",113:"testnet",196:"testnet"}})}}class D{constructor(t){this.data=t,this.offset=0}head(t){if(this.offset>=this.data.length)throw new Error("Truncated CBOR");const e=this.data[this.offset++];if(e>>>5!==t)throw new Error("Invalid CBOR type");const n=31&e;if(n<24)return n;if(n>26)throw new Error("Unsupported CBOR length");const r=1<<n-24;if(this.offset+r>this.data.length)throw new Error("Truncated CBOR");let s=0;for(let t=0;t<r;t++)s=256*s+this.data[this.offset++];return s}bytes(){const t=this.head(2);if(this.offset+t>this.data.length)throw new Error("Truncated bytes");const e=this.data.slice(this.offset,this.offset+t);return this.offset+=t,e}end(){if(this.offset!==this.data.length)throw new Error("Trailing CBOR data")}}class R extends s{validateImplementation(t){if(/^(addr|stake)(_test)?1/i.test(t))return this.validateShelley(t);try{const e=function(t){try{const e=new D(t);if(2!==e.head(4)||24!==e.head(6))return null;const n=e.bytes();if(e.head(0)!==function(t){let e=4294967295;for(const n of t){e^=n;for(let t=0;t<8;t++)e=e>>>1^(1&e?3988292384:0)}return(4294967295^e)>>>0}(n))return null;e.end();const r=new D(n);if(3!==r.head(4)||28!==r.bytes().length)return null;const s=r.head(5);if(s>n.length)return null;const i=new Set;let a="mainnet";for(let t=0;t<s;t++){const t=r.head(0);if(i.has(t)||t>255)return null;i.add(t);const e=r.bytes();if(1===t){const t=new D(e);if(28!==t.bytes().length)return null;t.end()}if(2===t){const t=new D(e);t.head(0),t.end(),a="testnet"}}const o=r.head(0);return 0!==o&&2!==o?null:(r.end(),a)}catch{return null}}(g(t));if(e)return{valid:!0,blockchain:"cardano",details:{format:"byron",network:e,checksum:!0}}}catch{}return this.invalid()}validateShelley(t){const e=k(t,256),n=e&&b(e.data);if(!e||e.encoding!==x.BECH32||!n?.length)return this.invalid();const r=n[0]>>>4,s=15&n[0];if(0!==s&&1!==s)return this.invalid();const i=14===r||15===r,a=(i?"stake":"addr")+(0===s?"_test":"");if(e.hrp!==a)return this.invalid();let o=!1;return r<=3?o=57===n.length:6===r||7===r||i?o=29===n.length:4!==r&&5!==r||(o=this.validPointer(n)),o?{valid:!0,blockchain:"cardano",details:{format:i?"stake":"shelley",network:1===s?"mainnet":"testnet",checksum:!0}}:this.invalid()}validPointer(t){let e=29;for(let n=0;n<3;n++){let n=0n;const r=e;do{if(e>=t.length||e-r>=10)return!1;n=n<<7n|BigInt(127&t[e])}while(128&t[e++]);if(e-r>1&&128===t[r]||n>0xffffffffffffffffn)return!1}return e===t.length}invalid(){return{valid:!1,error:"Invalid Cardano address structure, network, or checksum",details:{errorCode:n.INVALID_FORMAT}}}format(t,e){return i(t,e,8)}}const S="rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz",H=S.charAt(0),M={};for(let t=0;t<58;t++)M[S.charAt(t)]=t;class B extends s{validateImplementation(t){if(!t.startsWith("r"))return{valid:!1,error:"Must start with r",details:{errorCode:n.INVALID_FORMAT}};if(t.length<25||t.length>35)return{valid:!1,error:"Invalid length",details:{errorCode:n.INVALID_LENGTH}};try{const e=function(t){if(0===t.length)return new Uint8Array(0);let e=0;for(;e<t.length&&t[e]===H;)e++;const n=e,r=[0];for(;e<t.length;e++){const n=t[e],s=M[n];if(void 0===s)throw new Error(`Invalid Ripple Base58 character: ${n}`);for(let t=0;t<r.length;t++)r[t]*=58;r[0]+=s;let i=0;for(let t=0;t<r.length;++t)r[t]+=i,i=r[t]>>8,r[t]&=255;for(;i;)r.push(255&i),i>>=8}let s=[];t.length!==n&&(s=r.reverse());for(let t=0;t<n;t++)s.unshift(0);return new Uint8Array(s)}(t);if(25!==e.length||0!==e[0])return{valid:!1,error:"Invalid decoded length",details:{errorCode:n.INVALID_LENGTH}};const r=e.slice(0,21),s=e.slice(21),i=A(r),a=A(i);return a[0]!==s[0]||a[1]!==s[1]||a[2]!==s[2]||a[3]!==s[3]?{valid:!1,error:"Invalid checksum",details:{errorCode:n.INVALID_CHECKSUM}}:{valid:!0,blockchain:"ripple"}}catch{return{valid:!1,error:"Invalid characters",details:{errorCode:n.INVALID_CHARACTERS}}}}}class V extends f{validateImplementation(t,e){const n=super.validateImplementation(t,e);return n.valid&&(n.blockchain="bsc"),n}}class O extends f{validateImplementation(t,e){const n=super.validateImplementation(t,e);return n.valid&&(n.blockchain="avalanche"),n}}class F extends f{validateImplementation(t,e){const n=super.validateImplementation(t,e);return n.valid&&(n.blockchain="arbitrum"),n}}class $ extends f{validateImplementation(t,e){const n=super.validateImplementation(t,e);return n.valid&&(n.blockchain="optimism"),n}}class z extends f{validateImplementation(t,e){const n=super.validateImplementation(t,e);return n.valid&&(n.blockchain="base"),n}}class P extends f{constructor(t="evm"){super(),this.chain=t}validateImplementation(t,e){const n=super.validateImplementation(t,e);return n.valid&&(n.blockchain=this.chain),n}}class j extends s{validateImplementation(t){if(/^41[0-9a-fA-F]{40}$/.test(t))return{valid:!0,blockchain:"tron",details:{format:"hex",checksum:!1}};const e=34===t.length&&t.startsWith("T")?C(t):null;return e&&21===e.length&&65===e[0]?{valid:!0,blockchain:"tron",details:{format:"base58check",checksum:!0}}:{valid:!1,error:"Invalid TRON address",details:{errorCode:n.INVALID_FORMAT}}}}const W={cosmos:"cosmos",osmosis:"osmo",celestia:"celestia",injective:"inj",sei:"sei"};class G extends s{constructor(t="cosmos"){super(),this.chain=t}validateImplementation(t){const e=k(t),r=e&&b(e.data),s="injective"===this.chain||"celestia"===this.chain?[20]:[20,32];return e&&e.hrp===W[this.chain]&&e.encoding===x.BECH32&&r&&s.includes(r.length)?{valid:!0,blockchain:this.chain,details:{format:"bech32",checksum:!0}}:{valid:!1,error:"Invalid account prefix, checksum, length, or padding",details:{errorCode:n.INVALID_FORMAT}}}}class K extends s{validateImplementation(t){return/^0x[0-9a-fA-F]{64}$/.test(t)?{valid:!0,blockchain:"sui",details:{format:"hex",checksum:!1}}:{valid:!1,error:"Expected 0x followed by 64 hex digits",details:{errorCode:n.INVALID_FORMAT}}}}class q extends s{validateImplementation(t,e){const r=/^0x[0-9a-fA-F]{64}$/.test(t),s=/^0x[0-9a-f]$/.test(t),i=s||/^0x[0-9a-f]{64}$/.test(t)&&!/^0x0{63}[0-9a-f]$/.test(t);return(e?.strict?i:r||s)?{valid:!0,blockchain:"aptos",details:{format:"hex",checksum:!1}}:{valid:!1,error:"Invalid Aptos address (AIP-40)",details:{errorCode:n.INVALID_FORMAT}}}format(t,e){if(!this.validate(t).valid)throw new Error("Invalid Aptos address");let n=t.trim().toLowerCase();return/^0x0{63}[0-9a-f]$/.test(n)&&(n="0x"+n.slice(-1)),i(n,e)}}class J extends s{validateImplementation(t){if(t.length<2||t.length>64||!/^[a-z0-9]+(?:[._-][a-z0-9]+)*$/.test(t))return{valid:!1,error:"Invalid NEAR account ID",details:{errorCode:n.INVALID_FORMAT}};return{valid:!0,blockchain:"near",details:{format:/^[0-9a-f]{64}$/.test(t)||/^0x[0-9a-f]{40}$/.test(t)?"implicit":/^0s[0-9a-f]{40}$/.test(t)?"deterministic":/^0u[0-9a-hjkmnp-tv-z]{51}[0g]$/.test(t)?"universal":"named",checksum:!1}}}}const Q=new Map;for(const e of t)Q.set(e,"ethereum"===e?new f:new P(e));for(const t of e)Q.set(t,new G(t));Q.set("bitcoin",new T),Q.set("litecoin",new _),Q.set("dogecoin",new U),Q.set("solana",new p),Q.set("ripple",new B),Q.set("cardano",new R),Q.set("tron",new j),Q.set("sui",new K),Q.set("aptos",new q),Q.set("near",new J);const X=Object.freeze([...Q.keys()]);function Y(t){return"string"==typeof t&&Q.has(t)}function Z(t){const e=Q.get(t);if(!e)throw new Error(`Unsupported blockchain: ${String(t)}`);return e}function tt(e,n){let s;try{s=r.sanitize(e)}catch{return null}if(!s)return null;const i=[];Z("ethereum").validate(s,n).valid&&i.push(...t);for(const e of X)t.includes(e)||("near"!==e||/(\.near|\.testnet)$/.test(s)||/^[0-9a-f]{64}$/.test(s)||/^0[xs][0-9a-f]{40}$/.test(s)||/^0u[0-9a-hjkmnp-tv-z]{51}[0g]$/.test(s))&&Z(e).validate(s,n).valid&&i.push(e);return 0===i.length?null:1===i.length?i[0]:i}function et(t,e=4){return i(t,{shorten:!0,shortenLength:e})}function nt(e,n){const s=r.sanitize(e);return t.includes(n)||"sui"===n||"aptos"===n?s.toLowerCase():s}function rt(e,n){return t.includes(n)?(new f).format(e,{checksum:!0}):r.sanitize(e)}function st(t,e,n){return Z(e).validate(t,n)}function it(t,e,n){const r=Z(e);return t.map(t=>r.validate(t,n))}function at(t,e,n){return Z(e).format(t,n)}export{s as AddressValidator,q as AptosValidator,F as ArbitrumValidator,O as AvalancheValidator,z as BaseValidator,T as BitcoinValidator,V as BscValidator,e as COSMOS_CHAINS,R as CardanoValidator,G as CosmosValidator,U as DogecoinValidator,t as EVM_CHAINS,f as EthereumValidator,P as EvmValidator,_ as LitecoinValidator,J as NearValidator,$ as OptimismValidator,y as PolygonValidator,B as RippleValidator,X as SUPPORTED_CHAINS,p as SolanaValidator,K as SuiValidator,j as TronValidator,n as ValidationError,rt as addChecksum,tt as detectBlockchain,at as formatAddress,Y as isSupportedChain,nt as normalizeAddress,et as shortenAddress,st as validateAddress,it as validateBatch};
1
+ import{EthereumValidator as t}from"./ethereum.mjs";import{SolanaValidator as e}from"./solana.mjs";import{BitcoinValidator as r}from"./bitcoin.mjs";import{LitecoinValidator as o}from"./litecoin.mjs";import{DogecoinValidator as s}from"./dogecoin.mjs";import{CardanoValidator as n}from"./cardano.mjs";import{RippleValidator as a}from"./ripple.mjs";import{EvmValidator as i}from"./evm.mjs";export{ArbitrumValidator,AvalancheValidator,BaseValidator,BscValidator,OptimismValidator}from"./evm.mjs";import{E as m,C as c,a as l,I as d}from"./shared/base-CZZTeLCP.mjs";export{A as AddressValidator,V as ValidationError}from"./shared/base-CZZTeLCP.mjs";import{TronValidator as p}from"./tron.mjs";import{CosmosValidator as f}from"./cosmos.mjs";import{SuiValidator as u,AptosValidator as h}from"./move.mjs";import{NearValidator as j}from"./near.mjs";export{addChecksum,normalizeAddress,shortenAddress}from"./formatters.mjs";import"./shared/base58-DY9-Un67.mjs";import"./shared/utxo-BrSxcH2x.mjs";import"./shared/base58check-rMkz2cjy.mjs";import"./shared/bech32-Cu41-5bd.mjs";class w extends t{validateImplementation(t,e){const r=super.validateImplementation(t,e);return r.valid&&(r.blockchain="polygon"),r}}const v=new Map;for(const e of m)v.set(e,"ethereum"===e?new t:new i(e));for(const t of c)v.set(t,new f(t));v.set("bitcoin",new r),v.set("litecoin",new o),v.set("dogecoin",new s),v.set("solana",new e),v.set("ripple",new a),v.set("cardano",new n),v.set("tron",new p),v.set("sui",new u),v.set("aptos",new h),v.set("near",new j);const b=Object.freeze([...v.keys()]);function y(t){return"string"==typeof t&&v.has(t)}function g(t){const e=v.get(t);if(!e)throw new Error(`Unsupported blockchain: ${String(t)}`);return e}const x=b.filter(t=>!m.includes(t));function k(t,e){l(e);const r=d.trySanitize(t);if(!r)return null;const o=[];g("ethereum").validate(r,e).valid&&o.push(...m);for(const t of x){const s=g(t).validate(r,e);s.valid&&(("near"!==t||"named"!==s.details?.format||r.endsWith(".near")||r.endsWith(".testnet"))&&o.push(t))}return 0===o.length?null:1===o.length?o[0]:o}function O(t,e,r){return g(e).validate(t,r)}function z(t,e,r){const o=g(e);if(l(r),!Array.isArray(t))return Array.from(t,t=>o.validate(t,r));const s=t.length,n=new Array(s);for(let e=0;e<s;e++){const s=Object.prototype.hasOwnProperty.call(t,e)?t[e]:void 0;n[e]=o.validate(s,r)}return n}function E(t,e,r){return g(e).format(t,r)}export{h as AptosValidator,r as BitcoinValidator,c as COSMOS_CHAINS,n as CardanoValidator,f as CosmosValidator,s as DogecoinValidator,m as EVM_CHAINS,t as EthereumValidator,i as EvmValidator,o as LitecoinValidator,j as NearValidator,w as PolygonValidator,a as RippleValidator,b as SUPPORTED_CHAINS,e as SolanaValidator,u as SuiValidator,p as TronValidator,k as detectBlockchain,E as formatAddress,y as isSupportedChain,O as validateAddress,z as validateBatch};
package/dist/index.umd.js CHANGED
@@ -1 +1 @@
1
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).validator0x={})}(this,function(t){"use strict";const e=Object.freeze(["ethereum","polygon","bsc","avalanche","arbitrum","optimism","base","evm","fantom","sonic","gnosis","celo","cronos","moonbeam","moonriver","zksync","linea","scroll","mantle","blast","opbnb","zora","worldchain"]),n=Object.freeze(["cosmos","osmosis","celestia","injective","sei"]);var r;t.ValidationError=void 0,(r=t.ValidationError||(t.ValidationError={})).INVALID_FORMAT="INVALID_FORMAT",r.INVALID_CHECKSUM="INVALID_CHECKSUM",r.INVALID_LENGTH="INVALID_LENGTH",r.INVALID_CHARACTERS="INVALID_CHARACTERS",r.UNSUPPORTED_CHAIN="UNSUPPORTED_CHAIN",r.BURN_ADDRESS="BURN_ADDRESS",r.UNSAFE_INPUT="UNSAFE_INPUT",r.NETWORK_MISMATCH="NETWORK_MISMATCH";class i{static sanitize(e){if(null==e)throw new Error(t.ValidationError.UNSAFE_INPUT);if("string"!=typeof e)throw new Error(t.ValidationError.UNSAFE_INPUT);if(e.length>256)throw new Error(t.ValidationError.UNSAFE_INPUT);if(/[^\x20-\x7E]/.test(e))throw new Error(t.ValidationError.UNSAFE_INPUT);return e.trim()}}class a{validate(e,n){try{const r=i.sanitize(e),a=this.validateImplementation(r,n),o=a.details?.network;return a.valid&&o&&(n?.network&&"auto"!==n.network&&n.network!==o||!1===n?.allowTestnet&&"testnet"===o)?{valid:!1,error:"Address network does not match the requested network",details:{...a.details,errorCode:t.ValidationError.NETWORK_MISMATCH}}:a}catch(e){const n=e instanceof Error?e.message:String(e);return n===t.ValidationError.UNSAFE_INPUT?{valid:!1,error:"Unsafe input detected",details:{errorCode:t.ValidationError.UNSAFE_INPUT}}:{valid:!1,error:n,details:{errorCode:t.ValidationError.INVALID_FORMAT}}}}format(t,e){return o(t,e)}}function o(t,e,n=4){const r=i.sanitize(t);if(!e?.shorten)return r;const a=e.shortenLength??n;if(!Number.isSafeInteger(a)||a<1)throw new RangeError("shortenLength must be a positive integer");const o=r.startsWith("0x")?2:0;return r.length<=2*a+o+3?r:`${r.slice(0,a+o)}...${r.slice(-a)}`}function s(t){return t.startsWith("0x")?t.slice(2):t}function l(t){return t.startsWith("0x")?t:`0x${t}`}const c=(1n<<64n)-1n,d=[0,1,62,28,27,36,44,6,55,20,3,10,43,25,39,41,45,15,21,8,18,2,61,56,14],h=[0x0000000000000001n,0x0000000000008082n,0x800000000000808an,0x8000000080008000n,0x000000000000808bn,0x0000000080000001n,0x8000000080008081n,0x8000000000008009n,0x000000000000008an,0x0000000000000088n,0x0000000080008009n,0x000000008000000an,0x000000008000808bn,0x800000000000008bn,0x8000000000008089n,0x8000000000008003n,0x8000000000008002n,0x8000000000000080n,0x000000000000800an,0x800000008000000an,0x8000000080008081n,0x8000000000008080n,0x0000000080000001n,0x8000000080008008n];function u(t,e){return(t<<BigInt(e)|t>>BigInt(64-e))&c}function f(t){const e=new Array(5),n=new Array(25);for(const r of h){for(let n=0;n<5;n++)e[n]=t[n]^t[n+5]^t[n+10]^t[n+15]^t[n+20];for(let n=0;n<5;n++){const r=e[(n+4)%5]^u(e[(n+1)%5],1);for(let e=0;e<5;e++)t[n+5*e]^=r}for(let e=0;e<5;e++)for(let r=0;r<5;r++)n[r+(2*e+3*r)%5*5]=u(t[e+5*r],d[e+5*r]);for(let e=0;e<5;e++)for(let r=0;r<5;r++)t[e+5*r]=n[e+5*r]^~n[(e+1)%5+5*r]&n[(e+2)%5+5*r];t[0]^=r}}class m extends a{validateImplementation(e,n){const r=s(e);if(40!==r.length)return{valid:!1,error:"Invalid length",details:{errorCode:t.ValidationError.INVALID_LENGTH}};if(!function(t){if("string"!=typeof t)return!1;const e=t.startsWith("0x")?t.slice(2):t;return/^[0-9a-fA-F]*$/.test(e)}(r))return{valid:!1,error:"Invalid hex characters",details:{errorCode:t.ValidationError.INVALID_CHARACTERS}};if(!n?.allowBurnAddress&&/^0+$/.test(r))return{valid:!1,error:"Burn address detected",details:{errorCode:t.ValidationError.BURN_ADDRESS}};const i=this.isChecksummed(r);return(n?.strict||r!==r.toLowerCase()&&r!==r.toUpperCase())&&!i?{valid:!1,error:"Invalid checksum",details:{errorCode:t.ValidationError.INVALID_CHECKSUM}}:{valid:!0,blockchain:"ethereum",details:{checksum:i}}}format(t,e){let n=l(i.sanitize(t));return e?.checksum&&(n=this.toChecksumAddress(n)),o(n,e)}isChecksummed(t){const e=s(t);return l(e)===this.toChecksumAddress(e)}toChecksumAddress(t){const e=s(t).toLowerCase();if(!/^[0-9a-f]{40}$/.test(e))throw new Error("Expected a 20-byte hexadecimal address");const n=function(t){const e=(new TextEncoder).encode(t),n=new Uint8Array(136*(Math.floor(e.length/136)+1));n.set(e),n[e.length]=1,n[n.length-1]|=128;const r=new Array(25).fill(0n);for(let t=0;t<n.length;t+=136){for(let e=0;e<136;e++)r[e>>3]^=BigInt(n[t+e])<<BigInt(8*(7&e));f(r)}let i="";for(let t=0;t<32;t++)i+=Number(r[t>>3]>>BigInt(8*(7&t))&255n).toString(16).padStart(2,"0");return i}(e);return"0x"+[...e].map((t,e)=>parseInt(n[e],16)>=8?t.toUpperCase():t).join("")}}const v="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",I=v.charAt(0),g={};for(let t=0;t<58;t++)g[v.charAt(t)]=t;function p(t){if(0===t.length)return new Uint8Array(0);let e=0;for(;e<t.length&&t[e]===I;)e++;const n=e,r=[0];for(;e<t.length;e++){const n=t[e],i=g[n];if(void 0===i)throw new Error(`Invalid Base58 character: ${n}`);for(let t=0;t<r.length;t++)r[t]*=58;r[0]+=i;let a=0;for(let t=0;t<r.length;++t)r[t]+=a,a=r[t]>>8,r[t]&=255;for(;a;)r.push(255&a),a>>=8}const i=t.length===n?[]:r.reverse();return Uint8Array.from([...new Array(n).fill(0),...i])}class A extends a{validateImplementation(e){if(e.length<32||e.length>44)return{valid:!1,error:"Invalid length",details:{errorCode:t.ValidationError.INVALID_LENGTH}};try{if(32!==p(e).length)return{valid:!1,error:"Invalid public key length",details:{errorCode:t.ValidationError.INVALID_LENGTH}}}catch{return{valid:!1,error:"Invalid Base58 characters",details:{errorCode:t.ValidationError.INVALID_FORMAT}}}return"11111111111111111111111111111111"===e?{valid:!0,blockchain:"solana",details:{format:"System Program"}}:{valid:!0,blockchain:"solana"}}}function E(t){const e=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],n=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],r=8*t.length,i=t.length,a=new Uint8Array(64-(i+8)%64+8);a[0]=128;const o=r,s=Math.floor(o/4294967296),l=o%4294967296,c=a.length;a[c-4]=l>>>24&255,a[c-3]=l>>>16&255,a[c-2]=l>>>8&255,a[c-1]=255&l,a[c-8]=s>>>24&255,a[c-7]=s>>>16&255,a[c-6]=s>>>8&255,a[c-5]=255&s;const d=new Uint8Array(i+a.length);d.set(t),d.set(a,i);const h=new Uint32Array(64);for(let t=0;t<d.length;t+=64){for(let e=0;e<16;e++)h[e]=d[t+4*e]<<24|d[t+4*e+1]<<16|d[t+4*e+2]<<8|d[t+4*e+3];for(let t=16;t<64;t++){const e=w(h[t-2],17)^w(h[t-2],19)^h[t-2]>>>10,n=w(h[t-15],7)^w(h[t-15],18)^h[t-15]>>>3;h[t]=e+h[t-7]+n+h[t-16]|0}let r=n[0],i=n[1],a=n[2],o=n[3],s=n[4],l=n[5],c=n[6],u=n[7];for(let t=0;t<64;t++){const n=u+(w(s,6)^w(s,11)^w(s,25))+(s&l^~s&c)+e[t]+h[t]|0,d=r&i^r&a^i&a;u=c,c=l,l=s,s=o+n|0,o=a,a=i,i=r,r=n+((w(r,2)^w(r,13)^w(r,22))+d|0)|0}n[0]=n[0]+r|0,n[1]=n[1]+i|0,n[2]=n[2]+a|0,n[3]=n[3]+o|0,n[4]=n[4]+s|0,n[5]=n[5]+l|0,n[6]=n[6]+c|0,n[7]=n[7]+u|0}const u=new Uint8Array(32);for(let t=0;t<8;t++)u[4*t]=n[t]>>>24&255,u[4*t+1]=n[t]>>>16&255,u[4*t+2]=n[t]>>>8&255,u[4*t+3]=255&n[t];return u}function w(t,e){return t>>>e|t<<32-e}function C(t){try{const e=p(t);if(e.length<5)return null;const n=e.slice(0,-4),r=E(E(n));return e.slice(-4).every((t,e)=>t===r[e])?n:null}catch{return null}}var V;!function(t){t.BECH32="bech32",t.BECH32M="bech32m"}(V||(V={}));const x=[996825010,642813549,513874426,1027748829,705979059];function N(t,e,n){const r=n===V.BECH32M?734539939:1;return function(t){let e=1;for(const n of t){const t=e>>25;e=(33554431&e)<<5^n;for(let n=0;n<5;n++)t>>n&1&&(e^=x[n])}return e}(function(t){const e=[];for(let n=0;n<t.length;n++)e.push(t.charCodeAt(n)>>5);e.push(0);for(let n=0;n<t.length;n++)e.push(31&t.charCodeAt(n));return e}(t).concat(e))===r}function k(t,e=90){if(t.length<8||t.length>e)return null;const n=t.toLowerCase();if(t!==n&&t!==t.toUpperCase())return null;const r=n.lastIndexOf("1");if(r<1||r+7>n.length)return null;const i=n.substring(0,r);if(/[^\x21-\x7E]/.test(i))return null;const a=[];for(let t=r+1;t<n.length;t++){const e="qpzry9x8gf2tvdw0s3jn54khce6mua7l".indexOf(n[t]);if(-1===e)return null;a.push(e)}return N(i,a,V.BECH32)?{hrp:i,data:a.slice(0,a.length-6),encoding:V.BECH32}:N(i,a,V.BECH32M)?{hrp:i,data:a.slice(0,a.length-6),encoding:V.BECH32M}:null}function b(t){let e=0,n=0;const r=[];for(const i of t){if(!Number.isInteger(i)||i<0||i>31)return null;e=65535&(e<<5|i),n+=5,n>=8&&(n-=8,r.push(e>>>n&255))}return n>=5||e<<8-n&255?null:Uint8Array.from(r)}class y extends a{constructor(t){super(),this.config=t}validateImplementation(e){const n=e.toLowerCase().split("1")[0];if(this.config.hrps&&Object.prototype.hasOwnProperty.call(this.config.hrps,n))return this.validateWitness(e,this.config.hrps[n]);if(e.length<26||e.length>35)return this.invalid("Invalid address length",t.ValidationError.INVALID_LENGTH);const r=C(e);if(!r)return this.invalid("Invalid Base58Check address",t.ValidationError.INVALID_CHECKSUM);if(21!==r.length)return this.invalid("Invalid payload length",t.ValidationError.INVALID_LENGTH);const i=this.config.versions[r[0]];return i?{valid:!0,blockchain:this.config.chain,details:{format:"legacy",network:i,checksum:!0}}:this.invalid("Invalid address version")}validateWitness(e,n){const r=k(e);if(!r||0===r.data.length)return this.invalid("Invalid Bech32 encoding");const i=r.data[0],a=b(r.data.slice(1));if(i>16)return this.invalid("Invalid witness version");if(!a||a.length<2||a.length>40||0===i&&20!==a.length&&32!==a.length)return this.invalid("Invalid witness program or padding",t.ValidationError.INVALID_LENGTH);const o=0===i?V.BECH32:V.BECH32M;if(r.encoding!==o)return this.invalid("Wrong checksum encoding for witness version",t.ValidationError.INVALID_CHECKSUM);const s=0===i?"segwit":1===i&&32===a.length?"taproot":"future";return{valid:!0,blockchain:this.config.chain,details:{format:s,network:n,checksum:!0}}}invalid(e,n=t.ValidationError.INVALID_FORMAT){return{valid:!1,error:e,details:{errorCode:n}}}}class T extends y{constructor(){super({chain:"bitcoin",versions:{0:"mainnet",5:"mainnet",111:"testnet",196:"testnet"},hrps:{bc:"mainnet",tb:"testnet"}})}}class L extends y{constructor(){super({chain:"litecoin",versions:{48:"mainnet",50:"mainnet",5:"mainnet",111:"testnet",58:"testnet",196:"testnet"},hrps:{ltc:"mainnet",tltc:"testnet"}})}}class _ extends y{constructor(){super({chain:"dogecoin",versions:{30:"mainnet",22:"mainnet",113:"testnet",196:"testnet"}})}}class S{constructor(t){this.data=t,this.offset=0}head(t){if(this.offset>=this.data.length)throw new Error("Truncated CBOR");const e=this.data[this.offset++];if(e>>>5!==t)throw new Error("Invalid CBOR type");const n=31&e;if(n<24)return n;if(n>26)throw new Error("Unsupported CBOR length");const r=1<<n-24;if(this.offset+r>this.data.length)throw new Error("Truncated CBOR");let i=0;for(let t=0;t<r;t++)i=256*i+this.data[this.offset++];return i}bytes(){const t=this.head(2);if(this.offset+t>this.data.length)throw new Error("Truncated bytes");const e=this.data.slice(this.offset,this.offset+t);return this.offset+=t,e}end(){if(this.offset!==this.data.length)throw new Error("Trailing CBOR data")}}class U extends a{validateImplementation(t){if(/^(addr|stake)(_test)?1/i.test(t))return this.validateShelley(t);try{const e=function(t){try{const e=new S(t);if(2!==e.head(4)||24!==e.head(6))return null;const n=e.bytes();if(e.head(0)!==function(t){let e=4294967295;for(const n of t){e^=n;for(let t=0;t<8;t++)e=e>>>1^(1&e?3988292384:0)}return(4294967295^e)>>>0}(n))return null;e.end();const r=new S(n);if(3!==r.head(4)||28!==r.bytes().length)return null;const i=r.head(5);if(i>n.length)return null;const a=new Set;let o="mainnet";for(let t=0;t<i;t++){const t=r.head(0);if(a.has(t)||t>255)return null;a.add(t);const e=r.bytes();if(1===t){const t=new S(e);if(28!==t.bytes().length)return null;t.end()}if(2===t){const t=new S(e);t.head(0),t.end(),o="testnet"}}const s=r.head(0);return 0!==s&&2!==s?null:(r.end(),o)}catch{return null}}(p(t));if(e)return{valid:!0,blockchain:"cardano",details:{format:"byron",network:e,checksum:!0}}}catch{}return this.invalid()}validateShelley(t){const e=k(t,256),n=e&&b(e.data);if(!e||e.encoding!==V.BECH32||!n?.length)return this.invalid();const r=n[0]>>>4,i=15&n[0];if(0!==i&&1!==i)return this.invalid();const a=14===r||15===r,o=(a?"stake":"addr")+(0===i?"_test":"");if(e.hrp!==o)return this.invalid();let s=!1;return r<=3?s=57===n.length:6===r||7===r||a?s=29===n.length:4!==r&&5!==r||(s=this.validPointer(n)),s?{valid:!0,blockchain:"cardano",details:{format:a?"stake":"shelley",network:1===i?"mainnet":"testnet",checksum:!0}}:this.invalid()}validPointer(t){let e=29;for(let n=0;n<3;n++){let n=0n;const r=e;do{if(e>=t.length||e-r>=10)return!1;n=n<<7n|BigInt(127&t[e])}while(128&t[e++]);if(e-r>1&&128===t[r]||n>0xffffffffffffffffn)return!1}return e===t.length}invalid(){return{valid:!1,error:"Invalid Cardano address structure, network, or checksum",details:{errorCode:t.ValidationError.INVALID_FORMAT}}}format(t,e){return o(t,e,8)}}const D="rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz",R=D.charAt(0),H={};for(let t=0;t<58;t++)H[D.charAt(t)]=t;class B extends a{validateImplementation(e){if(!e.startsWith("r"))return{valid:!1,error:"Must start with r",details:{errorCode:t.ValidationError.INVALID_FORMAT}};if(e.length<25||e.length>35)return{valid:!1,error:"Invalid length",details:{errorCode:t.ValidationError.INVALID_LENGTH}};try{const n=function(t){if(0===t.length)return new Uint8Array(0);let e=0;for(;e<t.length&&t[e]===R;)e++;const n=e,r=[0];for(;e<t.length;e++){const n=t[e],i=H[n];if(void 0===i)throw new Error(`Invalid Ripple Base58 character: ${n}`);for(let t=0;t<r.length;t++)r[t]*=58;r[0]+=i;let a=0;for(let t=0;t<r.length;++t)r[t]+=a,a=r[t]>>8,r[t]&=255;for(;a;)r.push(255&a),a>>=8}let i=[];t.length!==n&&(i=r.reverse());for(let t=0;t<n;t++)i.unshift(0);return new Uint8Array(i)}(e);if(25!==n.length||0!==n[0])return{valid:!1,error:"Invalid decoded length",details:{errorCode:t.ValidationError.INVALID_LENGTH}};const r=n.slice(0,21),i=n.slice(21),a=E(r),o=E(a);return o[0]!==i[0]||o[1]!==i[1]||o[2]!==i[2]||o[3]!==i[3]?{valid:!1,error:"Invalid checksum",details:{errorCode:t.ValidationError.INVALID_CHECKSUM}}:{valid:!0,blockchain:"ripple"}}catch{return{valid:!1,error:"Invalid characters",details:{errorCode:t.ValidationError.INVALID_CHARACTERS}}}}}class M extends m{constructor(t="evm"){super(),this.chain=t}validateImplementation(t,e){const n=super.validateImplementation(t,e);return n.valid&&(n.blockchain=this.chain),n}}class O extends a{validateImplementation(e){if(/^41[0-9a-fA-F]{40}$/.test(e))return{valid:!0,blockchain:"tron",details:{format:"hex",checksum:!1}};const n=34===e.length&&e.startsWith("T")?C(e):null;return n&&21===n.length&&65===n[0]?{valid:!0,blockchain:"tron",details:{format:"base58check",checksum:!0}}:{valid:!1,error:"Invalid TRON address",details:{errorCode:t.ValidationError.INVALID_FORMAT}}}}const F={cosmos:"cosmos",osmosis:"osmo",celestia:"celestia",injective:"inj",sei:"sei"};class $ extends a{constructor(t="cosmos"){super(),this.chain=t}validateImplementation(e){const n=k(e),r=n&&b(n.data),i="injective"===this.chain||"celestia"===this.chain?[20]:[20,32];return n&&n.hrp===F[this.chain]&&n.encoding===V.BECH32&&r&&i.includes(r.length)?{valid:!0,blockchain:this.chain,details:{format:"bech32",checksum:!0}}:{valid:!1,error:"Invalid account prefix, checksum, length, or padding",details:{errorCode:t.ValidationError.INVALID_FORMAT}}}}class P extends a{validateImplementation(e){return/^0x[0-9a-fA-F]{64}$/.test(e)?{valid:!0,blockchain:"sui",details:{format:"hex",checksum:!1}}:{valid:!1,error:"Expected 0x followed by 64 hex digits",details:{errorCode:t.ValidationError.INVALID_FORMAT}}}}class z extends a{validateImplementation(e,n){const r=/^0x[0-9a-fA-F]{64}$/.test(e),i=/^0x[0-9a-f]$/.test(e),a=i||/^0x[0-9a-f]{64}$/.test(e)&&!/^0x0{63}[0-9a-f]$/.test(e);return(n?.strict?a:r||i)?{valid:!0,blockchain:"aptos",details:{format:"hex",checksum:!1}}:{valid:!1,error:"Invalid Aptos address (AIP-40)",details:{errorCode:t.ValidationError.INVALID_FORMAT}}}format(t,e){if(!this.validate(t).valid)throw new Error("Invalid Aptos address");let n=t.trim().toLowerCase();return/^0x0{63}[0-9a-f]$/.test(n)&&(n="0x"+n.slice(-1)),o(n,e)}}class j extends a{validateImplementation(e){if(e.length<2||e.length>64||!/^[a-z0-9]+(?:[._-][a-z0-9]+)*$/.test(e))return{valid:!1,error:"Invalid NEAR account ID",details:{errorCode:t.ValidationError.INVALID_FORMAT}};return{valid:!0,blockchain:"near",details:{format:/^[0-9a-f]{64}$/.test(e)||/^0x[0-9a-f]{40}$/.test(e)?"implicit":/^0s[0-9a-f]{40}$/.test(e)?"deterministic":/^0u[0-9a-hjkmnp-tv-z]{51}[0g]$/.test(e)?"universal":"named",checksum:!1}}}}const W=new Map;for(const t of e)W.set(t,"ethereum"===t?new m:new M(t));for(const t of n)W.set(t,new $(t));W.set("bitcoin",new T),W.set("litecoin",new L),W.set("dogecoin",new _),W.set("solana",new A),W.set("ripple",new B),W.set("cardano",new U),W.set("tron",new O),W.set("sui",new P),W.set("aptos",new z),W.set("near",new j);const G=Object.freeze([...W.keys()]);function K(t){const e=W.get(t);if(!e)throw new Error(`Unsupported blockchain: ${String(t)}`);return e}t.AddressValidator=a,t.AptosValidator=z,t.ArbitrumValidator=class extends m{validateImplementation(t,e){const n=super.validateImplementation(t,e);return n.valid&&(n.blockchain="arbitrum"),n}},t.AvalancheValidator=class extends m{validateImplementation(t,e){const n=super.validateImplementation(t,e);return n.valid&&(n.blockchain="avalanche"),n}},t.BaseValidator=class extends m{validateImplementation(t,e){const n=super.validateImplementation(t,e);return n.valid&&(n.blockchain="base"),n}},t.BitcoinValidator=T,t.BscValidator=class extends m{validateImplementation(t,e){const n=super.validateImplementation(t,e);return n.valid&&(n.blockchain="bsc"),n}},t.COSMOS_CHAINS=n,t.CardanoValidator=U,t.CosmosValidator=$,t.DogecoinValidator=_,t.EVM_CHAINS=e,t.EthereumValidator=m,t.EvmValidator=M,t.LitecoinValidator=L,t.NearValidator=j,t.OptimismValidator=class extends m{validateImplementation(t,e){const n=super.validateImplementation(t,e);return n.valid&&(n.blockchain="optimism"),n}},t.PolygonValidator=class extends m{validateImplementation(t,e){const n=super.validateImplementation(t,e);return n.valid&&(n.blockchain="polygon"),n}},t.RippleValidator=B,t.SUPPORTED_CHAINS=G,t.SolanaValidator=A,t.SuiValidator=P,t.TronValidator=O,t.addChecksum=function(t,n){return e.includes(n)?(new m).format(t,{checksum:!0}):i.sanitize(t)},t.detectBlockchain=function(t,n){let r;try{r=i.sanitize(t)}catch{return null}if(!r)return null;const a=[];K("ethereum").validate(r,n).valid&&a.push(...e);for(const t of G)e.includes(t)||("near"!==t||/(\.near|\.testnet)$/.test(r)||/^[0-9a-f]{64}$/.test(r)||/^0[xs][0-9a-f]{40}$/.test(r)||/^0u[0-9a-hjkmnp-tv-z]{51}[0g]$/.test(r))&&K(t).validate(r,n).valid&&a.push(t);return 0===a.length?null:1===a.length?a[0]:a},t.formatAddress=function(t,e,n){return K(e).format(t,n)},t.isSupportedChain=function(t){return"string"==typeof t&&W.has(t)},t.normalizeAddress=function(t,n){const r=i.sanitize(t);return e.includes(n)||"sui"===n||"aptos"===n?r.toLowerCase():r},t.shortenAddress=function(t,e=4){return o(t,{shorten:!0,shortenLength:e})},t.validateAddress=function(t,e,n){return K(e).validate(t,n)},t.validateBatch=function(t,e,n){const r=K(e);return t.map(t=>r.validate(t,n))}});
1
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).validator0x={})}(this,function(t){"use strict";const e=Object.freeze(["ethereum","polygon","bsc","avalanche","arbitrum","optimism","base","evm","fantom","sonic","gnosis","celo","cronos","moonbeam","moonriver","zksync","linea","scroll","mantle","blast","opbnb","zora","worldchain"]),r=Object.freeze(["cosmos","osmosis","celestia","injective","sei"]);var n;t.ValidationError=void 0,(n=t.ValidationError||(t.ValidationError={})).INVALID_FORMAT="INVALID_FORMAT",n.INVALID_CHECKSUM="INVALID_CHECKSUM",n.INVALID_LENGTH="INVALID_LENGTH",n.INVALID_CHARACTERS="INVALID_CHARACTERS",n.UNSUPPORTED_CHAIN="UNSUPPORTED_CHAIN",n.BURN_ADDRESS="BURN_ADDRESS",n.UNSAFE_INPUT="UNSAFE_INPUT",n.NETWORK_MISMATCH="NETWORK_MISMATCH";class i{static trySanitize(t){return"string"!=typeof t||t.length>256||/[^\x20-\x7E]/.test(t)?null:t.trim()}static sanitize(e){const r=i.trySanitize(e);if(null===r)throw new Error(t.ValidationError.UNSAFE_INPUT);return r}}function a(){return{valid:!1,error:"Unsafe input detected",details:{errorCode:t.ValidationError.UNSAFE_INPUT}}}function o(t){const e=t?.network;if(null!=e&&"mainnet"!==e&&"testnet"!==e&&"auto"!==e)throw new RangeError("Invalid network option (expected 'mainnet', 'testnet' or 'auto')")}class s{validate(e,r){o(r);try{const n=i.trySanitize(e);if(null===n)return a();const o=this.validateImplementation(n,r),s=o.details?.network;return o.valid&&s&&(r?.network&&"auto"!==r.network&&r.network!==s||!1===r?.allowTestnet&&"testnet"===s)?{valid:!1,error:"Address network does not match the requested network",details:{...o.details,errorCode:t.ValidationError.NETWORK_MISMATCH}}:o}catch(e){const r=e instanceof Error?e.message:String(e);return r===t.ValidationError.UNSAFE_INPUT?a():{valid:!1,error:r,details:{errorCode:t.ValidationError.INVALID_FORMAT}}}}format(t,e){return l(t,e)}}function l(t,e,r=4){const n=i.sanitize(t);if(!e?.shorten)return n;const a=e.shortenLength??r;if(!Number.isSafeInteger(a)||a<1)throw new RangeError("shortenLength must be a positive integer");const o=n.startsWith("0x")?2:0;return n.length<=2*a+o+3?n:`${n.slice(0,a+o)}...${n.slice(-a)}`}function c(t,e){if("string"!=typeof t)return!1;const r=t.startsWith("0x")?t.slice(2):t;return(void 0===e||r.length===e)&&/^[0-9a-fA-F]*$/.test(r)}function d(t){return t.startsWith("0x")?t.slice(2):t}const h=136,u=[0,1,62,28,27,36,44,6,55,20,3,10,43,25,39,41,45,15,21,8,18,2,61,56,14],f=new Uint32Array([1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648]),v=new Uint8Array(25);for(let t=0;t<5;t++)for(let e=0;e<5;e++)v[t+5*e]=e+(2*t+3*e)%5*5;const m=new Uint32Array(10),I=new Uint32Array(50);function g(t){for(let e=0;e<48;e+=2){for(let e=0;e<10;e++)m[e]=t[e]^t[e+10]^t[e+20]^t[e+30]^t[e+40];for(let e=0;e<5;e++){const r=(e+4)%5*2,n=(e+1)%5*2,i=m[r]^(m[n]<<1|m[n+1]>>>31),a=m[r+1]^(m[n+1]<<1|m[n]>>>31);for(let r=0;r<50;r+=10)t[2*e+r]^=i,t[2*e+r+1]^=a}for(let e=0;e<25;e++){const r=t[2*e],n=t[2*e+1],i=u[e],a=2*v[e];if(0===i)I[a]=r,I[a+1]=n;else if(i<32)I[a]=r<<i|n>>>32-i,I[a+1]=n<<i|r>>>32-i;else if(32===i)I[a]=n,I[a+1]=r;else{const t=i-32;I[a]=n<<t|r>>>32-t,I[a+1]=r<<t|n>>>32-t}}for(let e=0;e<50;e+=10)for(let r=0;r<5;r++){const n=e+2*r,i=e+(r+1)%5*2,a=e+(r+2)%5*2;t[n]=I[n]^~I[i]&I[a],t[n+1]=I[n+1]^~I[i+1]&I[a+1]}t[0]^=f[e],t[1]^=f[e+1]}}const p=new TextEncoder,A="0123456789abcdef";function E(t){if(/^[0-9]+$/.test(t))return t;const e=t.toLowerCase(),r=function(t){const e=p.encode(t),r=new Uint8Array((Math.floor(e.length/h)+1)*h);r.set(e),r[e.length]=1,r[r.length-1]|=128;const n=new Uint32Array(50);for(let t=0;t<r.length;t+=h){for(let e=0;e<h;e++)n[e>>2]^=r[t+e]<<8*(3&e);g(n)}let i="";for(let t=0;t<32;t++){const e=n[t>>2]>>>8*(3&t)&255;i+=A[e>>4]+A[15&e]}return i}(e);let n="";for(let t=0;t<e.length;t++)n+=r.charCodeAt(t)>=56?e[t].toUpperCase():e[t];return n}class w extends s{validateImplementation(e,r){const n=d(e);if(40!==n.length)return{valid:!1,error:"Invalid length",details:{errorCode:t.ValidationError.INVALID_LENGTH}};if(!c(e))return{valid:!1,error:"Invalid hex characters",details:{errorCode:t.ValidationError.INVALID_CHARACTERS}};if(!r?.allowBurnAddress&&/^0+$/.test(n))return{valid:!1,error:"Burn address detected",details:{errorCode:t.ValidationError.BURN_ADDRESS}};const i=n===E(n);return!i&&(r?.strict||n!==n.toLowerCase()&&n!==n.toUpperCase())?{valid:!1,error:"Invalid checksum",details:{errorCode:t.ValidationError.INVALID_CHECKSUM}}:{valid:!0,blockchain:"ethereum",details:{checksum:i}}}format(t,e){const r=i.sanitize(t);if(!e?.checksum)return l((n=r).startsWith("0x")?n:`0x${n}`,e);var n;if(!c(r,40))throw new Error("Expected a 20-byte hexadecimal address");return l("0x"+E(d(r)),e)}}function V(t){const e=Object.create(null);for(let r=0;r<t.length;r++)e[t[r]]=r;return r=>{let n=0;for(;n<r.length&&r[n]===t[0];)n++;const i=[];for(let t=n;t<r.length;t++){let n=e[r[t]];if(void 0===n)throw new Error(`Invalid Base58 character: ${r[t]}`);for(let t=0;t<i.length;t++)n+=58*i[t],i[t]=255&n,n>>>=8;for(;n>0;)i.push(255&n),n>>>=8}const a=new Uint8Array(n+i.length);return a.set(i.reverse(),n),a}}const C=V("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");class N extends s{validateImplementation(e){if(e.length<32||e.length>44)return{valid:!1,error:"Invalid length",details:{errorCode:t.ValidationError.INVALID_LENGTH}};try{if(32!==C(e).length)return{valid:!1,error:"Invalid public key length",details:{errorCode:t.ValidationError.INVALID_LENGTH}}}catch{return{valid:!1,error:"Invalid Base58 characters",details:{errorCode:t.ValidationError.INVALID_FORMAT}}}return"11111111111111111111111111111111"===e?{valid:!0,blockchain:"solana",details:{format:"System Program"}}:{valid:!0,blockchain:"solana"}}}const b=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function k(t){const e=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],r=64*Math.ceil((t.length+9)/64),n=new Uint8Array(r);n.set(t),n[t.length]=128;const i=8*t.length;y(n,r-8,Math.floor(i/4294967296)),y(n,r-4,i);const a=new Array(64);for(let t=0;t<r;t+=64){for(let e=0;e<16;e++){const r=t+4*e;a[e]=n[r]<<24|n[r+1]<<16|n[r+2]<<8|n[r+3]}for(let t=16;t<64;t++){const e=x(a[t-2],17)^x(a[t-2],19)^a[t-2]>>>10,r=x(a[t-15],7)^x(a[t-15],18)^a[t-15]>>>3;a[t]=e+a[t-7]+r+a[t-16]|0}let r=e[0],i=e[1],o=e[2],s=e[3],l=e[4],c=e[5],d=e[6],h=e[7];for(let t=0;t<64;t++){const e=h+(x(l,6)^x(l,11)^x(l,25))+(l&c^~l&d)+b[t]+a[t]|0,n=r&i^r&o^i&o;h=d,d=c,c=l,l=s+e|0,s=o,o=i,i=r,r=e+((x(r,2)^x(r,13)^x(r,22))+n|0)|0}e[0]=e[0]+r|0,e[1]=e[1]+i|0,e[2]=e[2]+o|0,e[3]=e[3]+s|0,e[4]=e[4]+l|0,e[5]=e[5]+c|0,e[6]=e[6]+d|0,e[7]=e[7]+h|0}const o=new Uint8Array(32);for(let t=0;t<e.length;t++)y(o,4*t,e[t]);return o}function y(t,e,r){t[e]=r>>>24,t[e+1]=r>>>16,t[e+2]=r>>>8,t[e+3]=r}function x(t,e){return t>>>e|t<<32-e}function L(t){if(t.length<5)return null;const e=t.subarray(0,-4),r=k(k(e));for(let n=0;n<4;n++)if(t[e.length+n]!==r[n])return null;return e}function T(t){try{return L(C(t))}catch{return null}}var _;!function(t){t.BECH32="bech32",t.BECH32M="bech32m"}(_||(_={}));const S=[996825010,642813549,513874426,1027748829,705979059],R=new Uint32Array(32);for(let t=1;t<R.length;t++)for(let e=0;e<S.length;e++)t&1<<e&&(R[t]^=S[e]);function D(t,e){return(33554431&t)<<5^e^R[t>>>25]}function U(t,e=90,r){if(t.length<8||t.length>e)return null;const n=t.lastIndexOf("1");if(n<1||n+7>t.length)return null;const i=t.slice(0,n).toLowerCase();if(void 0!==r&&i!==r)return null;if(/[^\x21-\x7E]/.test(t))return null;const a=t.toLowerCase();if(t!==a&&t!==t.toUpperCase())return null;const o=[];let s,l=function(t){let e=1;for(let r=0;r<t.length;r++)e=D(e,t.charCodeAt(r)>>>5);e=D(e,0);for(let r=0;r<t.length;r++)e=D(e,31&t.charCodeAt(r));return e}(i);for(let t=n+1;t<a.length;t++){const e="qpzry9x8gf2tvdw0s3jn54khce6mua7l".indexOf(a[t]);if(-1===e)return null;l=D(l,e),t<a.length-6&&o.push(e)}if(1===l)s=_.BECH32;else{if(734539939!==l)return null;s=_.BECH32M}return{hrp:i,data:o,encoding:s}}function H(t){let e=0,r=0;const n=new Uint8Array(Math.floor(5*t.length/8));let i=0;for(const a of t){if(!Number.isInteger(a)||a<0||a>31)return null;e=65535&(e<<5|a),r+=5,r>=8&&(r-=8,n[i++]=e>>>r&255)}return r>=5||e<<8-r&255?null:n}class M extends s{constructor(t){super(),this.config=t}validateImplementation(e){const r=e.toLowerCase().split("1")[0];if(this.config.hrps&&Object.prototype.hasOwnProperty.call(this.config.hrps,r))return this.validateWitness(e,this.config.hrps[r]);if(e.length<26||e.length>35)return this.invalid("Invalid address length",t.ValidationError.INVALID_LENGTH);const n=T(e);if(!n)return this.invalid("Invalid Base58Check address",t.ValidationError.INVALID_CHECKSUM);if(21!==n.length)return this.invalid("Invalid payload length",t.ValidationError.INVALID_LENGTH);const i=this.config.versions[n[0]];return i?{valid:!0,blockchain:this.config.chain,details:{format:"legacy",network:i,checksum:!0}}:this.invalid("Invalid address version")}validateWitness(e,r){const n=U(e);if(!n||0===n.data.length)return this.invalid("Invalid Bech32 encoding");const i=n.data[0],a=H(n.data.slice(1));if(i>16)return this.invalid("Invalid witness version");if(!a||a.length<2||a.length>40||0===i&&20!==a.length&&32!==a.length)return this.invalid("Invalid witness program or padding",t.ValidationError.INVALID_LENGTH);const o=0===i?_.BECH32:_.BECH32M;if(n.encoding!==o)return this.invalid("Wrong checksum encoding for witness version",t.ValidationError.INVALID_CHECKSUM);let s="future";return 0===i?s="segwit":1===i&&32===a.length?s="taproot":"bitcoin"===this.config.chain&&1===i&&2===a.length&&78===a[0]&&115===a[1]&&(s="anchor"),{valid:!0,blockchain:this.config.chain,details:{format:s,network:r,checksum:!0}}}invalid(e,r=t.ValidationError.INVALID_FORMAT){return{valid:!1,error:e,details:{errorCode:r}}}}class O extends M{constructor(){super({chain:"bitcoin",versions:{0:"mainnet",5:"mainnet",111:"testnet",196:"testnet"},hrps:{bc:"mainnet",tb:"testnet"}})}}class B extends M{constructor(){super({chain:"litecoin",versions:{48:"mainnet",50:"mainnet",5:"mainnet",111:"testnet",58:"testnet",196:"testnet"},hrps:{ltc:"mainnet",tltc:"testnet"}})}}class F extends M{constructor(){super({chain:"dogecoin",versions:{30:"mainnet",22:"mainnet",113:"testnet",196:"testnet"}})}}const z=[24,256,65536];class P{constructor(t){this.data=t,this.offset=0}head(t,e=!1){if(this.offset>=this.data.length)throw new Error("Truncated CBOR");const r=this.data[this.offset++];if(r>>>5!==t)throw new Error("Invalid CBOR type");const n=31&r;if(n<24)return n;if(n>26)throw new Error("Unsupported CBOR length");const i=1<<n-24;if(this.offset+i>this.data.length)throw new Error("Truncated CBOR");let a=0;for(let t=0;t<i;t++)a=256*a+this.data[this.offset++];if(e&&a<z[n-24])throw new Error("Noncanonical CBOR argument");return a}bytes(t=!1){const e=this.head(2,t);if(this.offset+e>this.data.length)throw new Error("Truncated bytes");const r=this.data.slice(this.offset,this.offset+e);return this.offset+=e,r}end(){if(this.offset!==this.data.length)throw new Error("Trailing CBOR data")}}const W=[4294967295,65535,65535];class $ extends s{validateImplementation(t){if(/^(addr|stake)(_test)?1/i.test(t))return this.validateShelley(t);try{const e=function(t){try{const e=new P(t);if(2!==e.head(4)||24!==e.head(6))return null;const r=e.bytes();if(e.head(0)!==function(t){let e=4294967295;for(const r of t){e^=r;for(let t=0;t<8;t++)e=e>>>1^(1&e?3988292384:0)}return(4294967295^e)>>>0}(r))return null;e.end();const n=new P(r);if(3!==n.head(4)||28!==n.bytes().length)return null;const i=n.head(5);if(i>r.length)return null;const a=new Set;let o="mainnet";for(let t=0;t<i;t++){const t=n.head(0);if(a.has(t)||t>255)return null;a.add(t);const e=n.bytes();if(1===t){const t=new P(e);t.bytes(!0),t.end()}if(2===t){const t=new P(e);t.head(0,!0),t.end(),o="testnet"}}const s=n.head(0,!0);return 0!==s&&2!==s?null:(n.end(),o)}catch{return null}}(C(t));if(e)return{valid:!0,blockchain:"cardano",details:{format:"byron",network:e,checksum:!0}}}catch{}return this.invalid()}validateShelley(t){const e=U(t,256),r=e&&H(e.data);if(!e||e.encoding!==_.BECH32||!r?.length)return this.invalid();const n=r[0]>>>4,i=15&r[0];if(0!==i&&1!==i)return this.invalid();const a=14===n||15===n,o=(a?"stake":"addr")+(0===i?"_test":"");if(e.hrp!==o)return this.invalid();let s=!1;return n<=3?s=57===r.length:6===n||7===n||a?s=29===r.length:4!==n&&5!==n||(s=this.validPointer(r)),s?{valid:!0,blockchain:"cardano",details:{format:a?"stake":"shelley",network:1===i?"mainnet":"testnet",checksum:!0}}:this.invalid()}validPointer(t){let e=29;for(const r of W){if(128===t[e])return!1;let n,i=0;do{if(e>=t.length)return!1;if(n=t[e++],i=128*i+(127&n),i>r)return!1}while(128&n)}return e===t.length}invalid(){return{valid:!1,error:"Invalid Cardano address structure, network, or checksum",details:{errorCode:t.ValidationError.INVALID_FORMAT}}}format(t,e){return l(t,e,8)}}const j=V("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz");class G extends s{validateImplementation(e){if(!e.startsWith("r"))return{valid:!1,error:"Must start with r",details:{errorCode:t.ValidationError.INVALID_FORMAT}};if(e.length<25||e.length>35)return{valid:!1,error:"Invalid length",details:{errorCode:t.ValidationError.INVALID_LENGTH}};try{const r=j(e);return 25!==r.length||0!==r[0]?{valid:!1,error:"Invalid decoded length",details:{errorCode:t.ValidationError.INVALID_LENGTH}}:L(r)?{valid:!0,blockchain:"ripple"}:{valid:!1,error:"Invalid checksum",details:{errorCode:t.ValidationError.INVALID_CHECKSUM}}}catch{return{valid:!1,error:"Invalid characters",details:{errorCode:t.ValidationError.INVALID_CHARACTERS}}}}}class K extends w{constructor(t="evm"){if(super(),this.chain=t,!e.includes(t))throw new RangeError(`Unsupported EVM chain: ${String(t)}`)}validateImplementation(t,e){const r=super.validateImplementation(t,e);return r.valid&&(r.blockchain=this.chain),r}}class q extends s{validateImplementation(e){if(/^41[0-9a-fA-F]{40}$/.test(e))return{valid:!0,blockchain:"tron",details:{format:"hex",checksum:!1}};const r=34===e.length&&e.startsWith("T")?T(e):null;return r&&21===r.length&&65===r[0]?{valid:!0,blockchain:"tron",details:{format:"base58check",checksum:!0}}:{valid:!1,error:"Invalid TRON address",details:{errorCode:t.ValidationError.INVALID_FORMAT}}}}const J={cosmos:"cosmos",osmosis:"osmo",celestia:"celestia",injective:"inj",sei:"sei"};class Q extends s{constructor(t="cosmos"){if(super(),this.chain=t,!r.includes(t))throw new RangeError(`Unsupported Cosmos chain: ${String(t)}`)}validateImplementation(e){const r=U(e,90,J[this.chain]);if(r?.encoding===_.BECH32){const t=H(r.data)?.length;if(20===t||32===t&&"injective"!==this.chain&&"celestia"!==this.chain)return{valid:!0,blockchain:this.chain,details:{format:"bech32",checksum:!0}}}return{valid:!1,error:"Invalid account prefix, checksum, length, or padding",details:{errorCode:t.ValidationError.INVALID_FORMAT}}}}const X=/^0x[0-9a-fA-F]{64}$/,Y=/^0x[0-9a-fA-F]$/,Z="0x"+"0".repeat(63);class tt extends s{validateImplementation(e){return X.test(e)?{valid:!0,blockchain:"sui",details:{format:"hex",checksum:!1}}:{valid:!1,error:"Expected 0x followed by 64 hex digits",details:{errorCode:t.ValidationError.INVALID_FORMAT}}}}class et extends s{validateImplementation(e,r){return(3===e.length?Y:X).test(e)&&(!r?.strict||!/[A-F]/.test(e)&&!e.startsWith(Z))?{valid:!0,blockchain:"aptos",details:{format:"hex",checksum:!1}}:{valid:!1,error:"Invalid Aptos address (AIP-40)",details:{errorCode:t.ValidationError.INVALID_FORMAT}}}format(t,e){if(!this.validate(t).valid)throw new Error("Invalid Aptos address");let r=t.trim().toLowerCase();return r.startsWith(Z)&&(r="0x"+r.slice(-1)),l(r,e)}}class rt extends s{validateImplementation(e){if(e.length<2||e.length>64||!/^[a-z0-9]+(?:[._-][a-z0-9]+)*$/.test(e))return{valid:!1,error:"Invalid NEAR account ID",details:{errorCode:t.ValidationError.INVALID_FORMAT}};return{valid:!0,blockchain:"near",details:{format:/^[0-9a-f]{64}$/.test(e)||/^0x[0-9a-f]{40}$/.test(e)?"implicit":/^0s[0-9a-f]{40}$/.test(e)?"deterministic":/^0u[0-9a-hjkmnp-tv-z]{51}[0g]$/.test(e)?"universal":"named",checksum:!1}}}}const nt=new Map;for(const t of e)nt.set(t,"ethereum"===t?new w:new K(t));for(const t of r)nt.set(t,new Q(t));nt.set("bitcoin",new O),nt.set("litecoin",new B),nt.set("dogecoin",new F),nt.set("solana",new N),nt.set("ripple",new G),nt.set("cardano",new $),nt.set("tron",new q),nt.set("sui",new tt),nt.set("aptos",new et),nt.set("near",new rt);const it=Object.freeze([...nt.keys()]);function at(t){const e=nt.get(t);if(!e)throw new Error(`Unsupported blockchain: ${String(t)}`);return e}const ot=it.filter(t=>!e.includes(t));t.AddressValidator=s,t.AptosValidator=et,t.ArbitrumValidator=class extends w{validateImplementation(t,e){const r=super.validateImplementation(t,e);return r.valid&&(r.blockchain="arbitrum"),r}},t.AvalancheValidator=class extends w{validateImplementation(t,e){const r=super.validateImplementation(t,e);return r.valid&&(r.blockchain="avalanche"),r}},t.BaseValidator=class extends w{validateImplementation(t,e){const r=super.validateImplementation(t,e);return r.valid&&(r.blockchain="base"),r}},t.BitcoinValidator=O,t.BscValidator=class extends w{validateImplementation(t,e){const r=super.validateImplementation(t,e);return r.valid&&(r.blockchain="bsc"),r}},t.COSMOS_CHAINS=r,t.CardanoValidator=$,t.CosmosValidator=Q,t.DogecoinValidator=F,t.EVM_CHAINS=e,t.EthereumValidator=w,t.EvmValidator=K,t.LitecoinValidator=B,t.NearValidator=rt,t.OptimismValidator=class extends w{validateImplementation(t,e){const r=super.validateImplementation(t,e);return r.valid&&(r.blockchain="optimism"),r}},t.PolygonValidator=class extends w{validateImplementation(t,e){const r=super.validateImplementation(t,e);return r.valid&&(r.blockchain="polygon"),r}},t.RippleValidator=G,t.SUPPORTED_CHAINS=it,t.SolanaValidator=N,t.SuiValidator=tt,t.TronValidator=q,t.addChecksum=function(t,r){return e.includes(r)?(new w).format(t,{checksum:!0}):i.sanitize(t)},t.detectBlockchain=function(t,r){o(r);const n=i.trySanitize(t);if(!n)return null;const a=[];at("ethereum").validate(n,r).valid&&a.push(...e);for(const t of ot){const e=at(t).validate(n,r);e.valid&&(("near"!==t||"named"!==e.details?.format||n.endsWith(".near")||n.endsWith(".testnet"))&&a.push(t))}return 0===a.length?null:1===a.length?a[0]:a},t.formatAddress=function(t,e,r){return at(e).format(t,r)},t.isSupportedChain=function(t){return"string"==typeof t&&nt.has(t)},t.normalizeAddress=function(t,r){const n=i.sanitize(t);return e.includes(r)||"sui"===r||"aptos"===r?n.toLowerCase():n},t.shortenAddress=function(t,e=4){return l(t,{shorten:!0,shortenLength:e})},t.validateAddress=function(t,e,r){return at(e).validate(t,r)},t.validateBatch=function(t,e,r){const n=at(e);if(o(r),!Array.isArray(t))return Array.from(t,t=>n.validate(t,r));const i=t.length,a=new Array(i);for(let e=0;e<i;e++){const i=Object.prototype.hasOwnProperty.call(t,e)?t[e]:void 0;a[e]=n.validate(i,r)}return a}});
package/dist/litecoin.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var t;!function(t){t.INVALID_FORMAT="INVALID_FORMAT",t.INVALID_CHECKSUM="INVALID_CHECKSUM",t.INVALID_LENGTH="INVALID_LENGTH",t.INVALID_CHARACTERS="INVALID_CHARACTERS",t.UNSUPPORTED_CHAIN="UNSUPPORTED_CHAIN",t.BURN_ADDRESS="BURN_ADDRESS",t.UNSAFE_INPUT="UNSAFE_INPUT",t.NETWORK_MISMATCH="NETWORK_MISMATCH"}(t||(t={}));class n{static sanitize(n){if(null==n)throw new Error(t.UNSAFE_INPUT);if("string"!=typeof n)throw new Error(t.UNSAFE_INPUT);if(n.length>256)throw new Error(t.UNSAFE_INPUT);if(/[^\x20-\x7E]/.test(n))throw new Error(t.UNSAFE_INPUT);return n.trim()}}class e{validate(e,r){try{const i=n.sanitize(e),s=this.validateImplementation(i,r),o=s.details?.network;return s.valid&&o&&(r?.network&&"auto"!==r.network&&r.network!==o||!1===r?.allowTestnet&&"testnet"===o)?{valid:!1,error:"Address network does not match the requested network",details:{...s.details,errorCode:t.NETWORK_MISMATCH}}:s}catch(n){const e=n instanceof Error?n.message:String(n);return e===t.UNSAFE_INPUT?{valid:!1,error:"Unsafe input detected",details:{errorCode:t.UNSAFE_INPUT}}:{valid:!1,error:e,details:{errorCode:t.INVALID_FORMAT}}}}format(t,e){return function(t,e,r=4){const i=n.sanitize(t);if(!e?.shorten)return i;const s=e.shortenLength??r;if(!Number.isSafeInteger(s)||s<1)throw new RangeError("shortenLength must be a positive integer");const o=i.startsWith("0x")?2:0;return i.length<=2*s+o+3?i:`${i.slice(0,s+o)}...${i.slice(-s)}`}(t,e)}}const r="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",i=r.charAt(0),s={};for(let t=0;t<58;t++)s[r.charAt(t)]=t;function o(t){const n=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],e=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],r=8*t.length,i=t.length,s=new Uint8Array(64-(i+8)%64+8);s[0]=128;const o=r,a=Math.floor(o/4294967296),c=o%4294967296,h=s.length;s[h-4]=c>>>24&255,s[h-3]=c>>>16&255,s[h-2]=c>>>8&255,s[h-1]=255&c,s[h-8]=a>>>24&255,s[h-7]=a>>>16&255,s[h-6]=a>>>8&255,s[h-5]=255&a;const u=new Uint8Array(i+s.length);u.set(t),u.set(s,i);const f=new Uint32Array(64);for(let t=0;t<u.length;t+=64){for(let n=0;n<16;n++)f[n]=u[t+4*n]<<24|u[t+4*n+1]<<16|u[t+4*n+2]<<8|u[t+4*n+3];for(let t=16;t<64;t++){const n=l(f[t-2],17)^l(f[t-2],19)^f[t-2]>>>10,e=l(f[t-15],7)^l(f[t-15],18)^f[t-15]>>>3;f[t]=n+f[t-7]+e+f[t-16]|0}let r=e[0],i=e[1],s=e[2],o=e[3],a=e[4],c=e[5],h=e[6],d=e[7];for(let t=0;t<64;t++){const e=d+(l(a,6)^l(a,11)^l(a,25))+(a&c^~a&h)+n[t]+f[t]|0,u=r&i^r&s^i&s;d=h,h=c,c=a,a=o+e|0,o=s,s=i,i=r,r=e+((l(r,2)^l(r,13)^l(r,22))+u|0)|0}e[0]=e[0]+r|0,e[1]=e[1]+i|0,e[2]=e[2]+s|0,e[3]=e[3]+o|0,e[4]=e[4]+a|0,e[5]=e[5]+c|0,e[6]=e[6]+h|0,e[7]=e[7]+d|0}const d=new Uint8Array(32);for(let t=0;t<8;t++)d[4*t]=e[t]>>>24&255,d[4*t+1]=e[t]>>>16&255,d[4*t+2]=e[t]>>>8&255,d[4*t+3]=255&e[t];return d}function l(t,n){return t>>>n|t<<32-n}function a(t){try{const n=function(t){if(0===t.length)return new Uint8Array(0);let n=0;for(;n<t.length&&t[n]===i;)n++;const e=n,r=[0];for(;n<t.length;n++){const e=t[n],i=s[e];if(void 0===i)throw new Error(`Invalid Base58 character: ${e}`);for(let t=0;t<r.length;t++)r[t]*=58;r[0]+=i;let o=0;for(let t=0;t<r.length;++t)r[t]+=o,o=r[t]>>8,r[t]&=255;for(;o;)r.push(255&o),o>>=8}const o=t.length===e?[]:r.reverse();return Uint8Array.from([...new Array(e).fill(0),...o])}(t);if(n.length<5)return null;const e=n.slice(0,-4),r=o(o(e));return n.slice(-4).every((t,n)=>t===r[n])?e:null}catch{return null}}var c;!function(t){t.BECH32="bech32",t.BECH32M="bech32m"}(c||(c={}));const h=[996825010,642813549,513874426,1027748829,705979059];function u(t,n,e){const r=e===c.BECH32M?734539939:1;return function(t){let n=1;for(const e of t){const t=n>>25;n=(33554431&n)<<5^e;for(let e=0;e<5;e++)t>>e&1&&(n^=h[e])}return n}(function(t){const n=[];for(let e=0;e<t.length;e++)n.push(t.charCodeAt(e)>>5);n.push(0);for(let e=0;e<t.length;e++)n.push(31&t.charCodeAt(e));return n}(t).concat(n))===r}class f extends e{constructor(t){super(),this.config=t}validateImplementation(n){const e=n.toLowerCase().split("1")[0];if(this.config.hrps&&Object.prototype.hasOwnProperty.call(this.config.hrps,e))return this.validateWitness(n,this.config.hrps[e]);if(n.length<26||n.length>35)return this.invalid("Invalid address length",t.INVALID_LENGTH);const r=a(n);if(!r)return this.invalid("Invalid Base58Check address",t.INVALID_CHECKSUM);if(21!==r.length)return this.invalid("Invalid payload length",t.INVALID_LENGTH);const i=this.config.versions[r[0]];return i?{valid:!0,blockchain:this.config.chain,details:{format:"legacy",network:i,checksum:!0}}:this.invalid("Invalid address version")}validateWitness(n,e){const r=function(t,n=90){if(t.length<8||t.length>n)return null;const e=t.toLowerCase();if(t!==e&&t!==t.toUpperCase())return null;const r=e.lastIndexOf("1");if(r<1||r+7>e.length)return null;const i=e.substring(0,r);if(/[^\x21-\x7E]/.test(i))return null;const s=[];for(let t=r+1;t<e.length;t++){const n="qpzry9x8gf2tvdw0s3jn54khce6mua7l".indexOf(e[t]);if(-1===n)return null;s.push(n)}return u(i,s,c.BECH32)?{hrp:i,data:s.slice(0,s.length-6),encoding:c.BECH32}:u(i,s,c.BECH32M)?{hrp:i,data:s.slice(0,s.length-6),encoding:c.BECH32M}:null}(n);if(!r||0===r.data.length)return this.invalid("Invalid Bech32 encoding");const i=r.data[0],s=function(t){let n=0,e=0;const r=[];for(const i of t){if(!Number.isInteger(i)||i<0||i>31)return null;n=65535&(n<<5|i),e+=5,e>=8&&(e-=8,r.push(n>>>e&255))}return e>=5||n<<8-e&255?null:Uint8Array.from(r)}(r.data.slice(1));if(i>16)return this.invalid("Invalid witness version");if(!s||s.length<2||s.length>40||0===i&&20!==s.length&&32!==s.length)return this.invalid("Invalid witness program or padding",t.INVALID_LENGTH);const o=0===i?c.BECH32:c.BECH32M;if(r.encoding!==o)return this.invalid("Wrong checksum encoding for witness version",t.INVALID_CHECKSUM);const l=0===i?"segwit":1===i&&32===s.length?"taproot":"future";return{valid:!0,blockchain:this.config.chain,details:{format:l,network:e,checksum:!0}}}invalid(n,e=t.INVALID_FORMAT){return{valid:!1,error:n,details:{errorCode:e}}}}exports.LitecoinValidator=class extends f{constructor(){super({chain:"litecoin",versions:{48:"mainnet",50:"mainnet",5:"mainnet",111:"testnet",58:"testnet",196:"testnet"},hrps:{ltc:"mainnet",tltc:"testnet"}})}};
1
+ "use strict";var e=require("./shared/utxo-DF5Lt3lY.cjs");require("./shared/base-3sYui6r0.cjs"),require("./shared/base58check-BeCwnkGe.cjs"),require("./shared/base58-DV6hu8Kq.cjs"),require("./shared/bech32-Dk6Pnay4.cjs");class t extends e.UtxoValidator{constructor(){super({chain:"litecoin",versions:{48:"mainnet",50:"mainnet",5:"mainnet",111:"testnet",58:"testnet",196:"testnet"},hrps:{ltc:"mainnet",tltc:"testnet"}})}}exports.LitecoinValidator=t;
package/dist/litecoin.mjs CHANGED
@@ -1 +1 @@
1
- var t;!function(t){t.INVALID_FORMAT="INVALID_FORMAT",t.INVALID_CHECKSUM="INVALID_CHECKSUM",t.INVALID_LENGTH="INVALID_LENGTH",t.INVALID_CHARACTERS="INVALID_CHARACTERS",t.UNSUPPORTED_CHAIN="UNSUPPORTED_CHAIN",t.BURN_ADDRESS="BURN_ADDRESS",t.UNSAFE_INPUT="UNSAFE_INPUT",t.NETWORK_MISMATCH="NETWORK_MISMATCH"}(t||(t={}));class n{static sanitize(n){if(null==n)throw new Error(t.UNSAFE_INPUT);if("string"!=typeof n)throw new Error(t.UNSAFE_INPUT);if(n.length>256)throw new Error(t.UNSAFE_INPUT);if(/[^\x20-\x7E]/.test(n))throw new Error(t.UNSAFE_INPUT);return n.trim()}}class e{validate(e,r){try{const i=n.sanitize(e),o=this.validateImplementation(i,r),s=o.details?.network;return o.valid&&s&&(r?.network&&"auto"!==r.network&&r.network!==s||!1===r?.allowTestnet&&"testnet"===s)?{valid:!1,error:"Address network does not match the requested network",details:{...o.details,errorCode:t.NETWORK_MISMATCH}}:o}catch(n){const e=n instanceof Error?n.message:String(n);return e===t.UNSAFE_INPUT?{valid:!1,error:"Unsafe input detected",details:{errorCode:t.UNSAFE_INPUT}}:{valid:!1,error:e,details:{errorCode:t.INVALID_FORMAT}}}}format(t,e){return function(t,e,r=4){const i=n.sanitize(t);if(!e?.shorten)return i;const o=e.shortenLength??r;if(!Number.isSafeInteger(o)||o<1)throw new RangeError("shortenLength must be a positive integer");const s=i.startsWith("0x")?2:0;return i.length<=2*o+s+3?i:`${i.slice(0,o+s)}...${i.slice(-o)}`}(t,e)}}const r="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",i=r.charAt(0),o={};for(let t=0;t<58;t++)o[r.charAt(t)]=t;function s(t){const n=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],e=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],r=8*t.length,i=t.length,o=new Uint8Array(64-(i+8)%64+8);o[0]=128;const s=r,a=Math.floor(s/4294967296),c=s%4294967296,h=o.length;o[h-4]=c>>>24&255,o[h-3]=c>>>16&255,o[h-2]=c>>>8&255,o[h-1]=255&c,o[h-8]=a>>>24&255,o[h-7]=a>>>16&255,o[h-6]=a>>>8&255,o[h-5]=255&a;const u=new Uint8Array(i+o.length);u.set(t),u.set(o,i);const f=new Uint32Array(64);for(let t=0;t<u.length;t+=64){for(let n=0;n<16;n++)f[n]=u[t+4*n]<<24|u[t+4*n+1]<<16|u[t+4*n+2]<<8|u[t+4*n+3];for(let t=16;t<64;t++){const n=l(f[t-2],17)^l(f[t-2],19)^f[t-2]>>>10,e=l(f[t-15],7)^l(f[t-15],18)^f[t-15]>>>3;f[t]=n+f[t-7]+e+f[t-16]|0}let r=e[0],i=e[1],o=e[2],s=e[3],a=e[4],c=e[5],h=e[6],d=e[7];for(let t=0;t<64;t++){const e=d+(l(a,6)^l(a,11)^l(a,25))+(a&c^~a&h)+n[t]+f[t]|0,u=r&i^r&o^i&o;d=h,h=c,c=a,a=s+e|0,s=o,o=i,i=r,r=e+((l(r,2)^l(r,13)^l(r,22))+u|0)|0}e[0]=e[0]+r|0,e[1]=e[1]+i|0,e[2]=e[2]+o|0,e[3]=e[3]+s|0,e[4]=e[4]+a|0,e[5]=e[5]+c|0,e[6]=e[6]+h|0,e[7]=e[7]+d|0}const d=new Uint8Array(32);for(let t=0;t<8;t++)d[4*t]=e[t]>>>24&255,d[4*t+1]=e[t]>>>16&255,d[4*t+2]=e[t]>>>8&255,d[4*t+3]=255&e[t];return d}function l(t,n){return t>>>n|t<<32-n}function a(t){try{const n=function(t){if(0===t.length)return new Uint8Array(0);let n=0;for(;n<t.length&&t[n]===i;)n++;const e=n,r=[0];for(;n<t.length;n++){const e=t[n],i=o[e];if(void 0===i)throw new Error(`Invalid Base58 character: ${e}`);for(let t=0;t<r.length;t++)r[t]*=58;r[0]+=i;let s=0;for(let t=0;t<r.length;++t)r[t]+=s,s=r[t]>>8,r[t]&=255;for(;s;)r.push(255&s),s>>=8}const s=t.length===e?[]:r.reverse();return Uint8Array.from([...new Array(e).fill(0),...s])}(t);if(n.length<5)return null;const e=n.slice(0,-4),r=s(s(e));return n.slice(-4).every((t,n)=>t===r[n])?e:null}catch{return null}}var c;!function(t){t.BECH32="bech32",t.BECH32M="bech32m"}(c||(c={}));const h=[996825010,642813549,513874426,1027748829,705979059];function u(t,n,e){const r=e===c.BECH32M?734539939:1;return function(t){let n=1;for(const e of t){const t=n>>25;n=(33554431&n)<<5^e;for(let e=0;e<5;e++)t>>e&1&&(n^=h[e])}return n}(function(t){const n=[];for(let e=0;e<t.length;e++)n.push(t.charCodeAt(e)>>5);n.push(0);for(let e=0;e<t.length;e++)n.push(31&t.charCodeAt(e));return n}(t).concat(n))===r}class f extends e{constructor(t){super(),this.config=t}validateImplementation(n){const e=n.toLowerCase().split("1")[0];if(this.config.hrps&&Object.prototype.hasOwnProperty.call(this.config.hrps,e))return this.validateWitness(n,this.config.hrps[e]);if(n.length<26||n.length>35)return this.invalid("Invalid address length",t.INVALID_LENGTH);const r=a(n);if(!r)return this.invalid("Invalid Base58Check address",t.INVALID_CHECKSUM);if(21!==r.length)return this.invalid("Invalid payload length",t.INVALID_LENGTH);const i=this.config.versions[r[0]];return i?{valid:!0,blockchain:this.config.chain,details:{format:"legacy",network:i,checksum:!0}}:this.invalid("Invalid address version")}validateWitness(n,e){const r=function(t,n=90){if(t.length<8||t.length>n)return null;const e=t.toLowerCase();if(t!==e&&t!==t.toUpperCase())return null;const r=e.lastIndexOf("1");if(r<1||r+7>e.length)return null;const i=e.substring(0,r);if(/[^\x21-\x7E]/.test(i))return null;const o=[];for(let t=r+1;t<e.length;t++){const n="qpzry9x8gf2tvdw0s3jn54khce6mua7l".indexOf(e[t]);if(-1===n)return null;o.push(n)}return u(i,o,c.BECH32)?{hrp:i,data:o.slice(0,o.length-6),encoding:c.BECH32}:u(i,o,c.BECH32M)?{hrp:i,data:o.slice(0,o.length-6),encoding:c.BECH32M}:null}(n);if(!r||0===r.data.length)return this.invalid("Invalid Bech32 encoding");const i=r.data[0],o=function(t){let n=0,e=0;const r=[];for(const i of t){if(!Number.isInteger(i)||i<0||i>31)return null;n=65535&(n<<5|i),e+=5,e>=8&&(e-=8,r.push(n>>>e&255))}return e>=5||n<<8-e&255?null:Uint8Array.from(r)}(r.data.slice(1));if(i>16)return this.invalid("Invalid witness version");if(!o||o.length<2||o.length>40||0===i&&20!==o.length&&32!==o.length)return this.invalid("Invalid witness program or padding",t.INVALID_LENGTH);const s=0===i?c.BECH32:c.BECH32M;if(r.encoding!==s)return this.invalid("Wrong checksum encoding for witness version",t.INVALID_CHECKSUM);const l=0===i?"segwit":1===i&&32===o.length?"taproot":"future";return{valid:!0,blockchain:this.config.chain,details:{format:l,network:e,checksum:!0}}}invalid(n,e=t.INVALID_FORMAT){return{valid:!1,error:n,details:{errorCode:e}}}}class d extends f{constructor(){super({chain:"litecoin",versions:{48:"mainnet",50:"mainnet",5:"mainnet",111:"testnet",58:"testnet",196:"testnet"},hrps:{ltc:"mainnet",tltc:"testnet"}})}}export{d as LitecoinValidator};
1
+ import{U as t}from"./shared/utxo-BrSxcH2x.mjs";import"./shared/base-CZZTeLCP.mjs";import"./shared/base58check-rMkz2cjy.mjs";import"./shared/base58-DY9-Un67.mjs";import"./shared/bech32-Cu41-5bd.mjs";class e extends t{constructor(){super({chain:"litecoin",versions:{48:"mainnet",50:"mainnet",5:"mainnet",111:"testnet",58:"testnet",196:"testnet"},hrps:{ltc:"mainnet",tltc:"testnet"}})}}export{e as LitecoinValidator};
package/dist/move.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var t;!function(t){t.INVALID_FORMAT="INVALID_FORMAT",t.INVALID_CHECKSUM="INVALID_CHECKSUM",t.INVALID_LENGTH="INVALID_LENGTH",t.INVALID_CHARACTERS="INVALID_CHARACTERS",t.UNSUPPORTED_CHAIN="UNSUPPORTED_CHAIN",t.BURN_ADDRESS="BURN_ADDRESS",t.UNSAFE_INPUT="UNSAFE_INPUT",t.NETWORK_MISMATCH="NETWORK_MISMATCH"}(t||(t={}));class e{static sanitize(e){if(null==e)throw new Error(t.UNSAFE_INPUT);if("string"!=typeof e)throw new Error(t.UNSAFE_INPUT);if(e.length>256)throw new Error(t.UNSAFE_INPUT);if(/[^\x20-\x7E]/.test(e))throw new Error(t.UNSAFE_INPUT);return e.trim()}}class r{validate(r,s){try{const a=e.sanitize(r),o=this.validateImplementation(a,s),i=o.details?.network;return o.valid&&i&&(s?.network&&"auto"!==s.network&&s.network!==i||!1===s?.allowTestnet&&"testnet"===i)?{valid:!1,error:"Address network does not match the requested network",details:{...o.details,errorCode:t.NETWORK_MISMATCH}}:o}catch(e){const r=e instanceof Error?e.message:String(e);return r===t.UNSAFE_INPUT?{valid:!1,error:"Unsafe input detected",details:{errorCode:t.UNSAFE_INPUT}}:{valid:!1,error:r,details:{errorCode:t.INVALID_FORMAT}}}}format(t,e){return s(t,e)}}function s(t,r,s=4){const a=e.sanitize(t);if(!r?.shorten)return a;const o=r.shortenLength??s;if(!Number.isSafeInteger(o)||o<1)throw new RangeError("shortenLength must be a positive integer");const i=a.startsWith("0x")?2:0;return a.length<=2*o+i+3?a:`${a.slice(0,o+i)}...${a.slice(-o)}`}exports.AptosValidator=class extends r{validateImplementation(e,r){const s=/^0x[0-9a-fA-F]{64}$/.test(e),a=/^0x[0-9a-f]$/.test(e),o=a||/^0x[0-9a-f]{64}$/.test(e)&&!/^0x0{63}[0-9a-f]$/.test(e);return(r?.strict?o:s||a)?{valid:!0,blockchain:"aptos",details:{format:"hex",checksum:!1}}:{valid:!1,error:"Invalid Aptos address (AIP-40)",details:{errorCode:t.INVALID_FORMAT}}}format(t,e){if(!this.validate(t).valid)throw new Error("Invalid Aptos address");let r=t.trim().toLowerCase();return/^0x0{63}[0-9a-f]$/.test(r)&&(r="0x"+r.slice(-1)),s(r,e)}},exports.SuiValidator=class extends r{validateImplementation(e){return/^0x[0-9a-fA-F]{64}$/.test(e)?{valid:!0,blockchain:"sui",details:{format:"hex",checksum:!1}}:{valid:!1,error:"Expected 0x followed by 64 hex digits",details:{errorCode:t.INVALID_FORMAT}}}};
1
+ "use strict";var t=require("./shared/base-3sYui6r0.cjs");const e=/^0x[0-9a-fA-F]{64}$/,r=/^0x[0-9a-fA-F]$/,a="0x"+"0".repeat(63);class s extends t.AddressValidator{validateImplementation(r){return e.test(r)?{valid:!0,blockchain:"sui",details:{format:"hex",checksum:!1}}:{valid:!1,error:"Expected 0x followed by 64 hex digits",details:{errorCode:t.ValidationError.INVALID_FORMAT}}}}class i extends t.AddressValidator{validateImplementation(s,i){return(3===s.length?r:e).test(s)&&(!i?.strict||!/[A-F]/.test(s)&&!s.startsWith(a))?{valid:!0,blockchain:"aptos",details:{format:"hex",checksum:!1}}:{valid:!1,error:"Invalid Aptos address (AIP-40)",details:{errorCode:t.ValidationError.INVALID_FORMAT}}}format(e,r){if(!this.validate(e).valid)throw new Error("Invalid Aptos address");let s=e.trim().toLowerCase();return s.startsWith(a)&&(s="0x"+s.slice(-1)),t.formatPlainAddress(s,r)}}exports.AptosValidator=i,exports.SuiValidator=s;
package/dist/move.mjs CHANGED
@@ -1 +1 @@
1
- var e;!function(e){e.INVALID_FORMAT="INVALID_FORMAT",e.INVALID_CHECKSUM="INVALID_CHECKSUM",e.INVALID_LENGTH="INVALID_LENGTH",e.INVALID_CHARACTERS="INVALID_CHARACTERS",e.UNSUPPORTED_CHAIN="UNSUPPORTED_CHAIN",e.BURN_ADDRESS="BURN_ADDRESS",e.UNSAFE_INPUT="UNSAFE_INPUT",e.NETWORK_MISMATCH="NETWORK_MISMATCH"}(e||(e={}));class t{static sanitize(t){if(null==t)throw new Error(e.UNSAFE_INPUT);if("string"!=typeof t)throw new Error(e.UNSAFE_INPUT);if(t.length>256)throw new Error(e.UNSAFE_INPUT);if(/[^\x20-\x7E]/.test(t))throw new Error(e.UNSAFE_INPUT);return t.trim()}}class r{validate(r,s){try{const a=t.sanitize(r),o=this.validateImplementation(a,s),i=o.details?.network;return o.valid&&i&&(s?.network&&"auto"!==s.network&&s.network!==i||!1===s?.allowTestnet&&"testnet"===i)?{valid:!1,error:"Address network does not match the requested network",details:{...o.details,errorCode:e.NETWORK_MISMATCH}}:o}catch(t){const r=t instanceof Error?t.message:String(t);return r===e.UNSAFE_INPUT?{valid:!1,error:"Unsafe input detected",details:{errorCode:e.UNSAFE_INPUT}}:{valid:!1,error:r,details:{errorCode:e.INVALID_FORMAT}}}}format(e,t){return s(e,t)}}function s(e,r,s=4){const a=t.sanitize(e);if(!r?.shorten)return a;const o=r.shortenLength??s;if(!Number.isSafeInteger(o)||o<1)throw new RangeError("shortenLength must be a positive integer");const i=a.startsWith("0x")?2:0;return a.length<=2*o+i+3?a:`${a.slice(0,o+i)}...${a.slice(-o)}`}class a extends r{validateImplementation(t){return/^0x[0-9a-fA-F]{64}$/.test(t)?{valid:!0,blockchain:"sui",details:{format:"hex",checksum:!1}}:{valid:!1,error:"Expected 0x followed by 64 hex digits",details:{errorCode:e.INVALID_FORMAT}}}}class o extends r{validateImplementation(t,r){const s=/^0x[0-9a-fA-F]{64}$/.test(t),a=/^0x[0-9a-f]$/.test(t),o=a||/^0x[0-9a-f]{64}$/.test(t)&&!/^0x0{63}[0-9a-f]$/.test(t);return(r?.strict?o:s||a)?{valid:!0,blockchain:"aptos",details:{format:"hex",checksum:!1}}:{valid:!1,error:"Invalid Aptos address (AIP-40)",details:{errorCode:e.INVALID_FORMAT}}}format(e,t){if(!this.validate(e).valid)throw new Error("Invalid Aptos address");let r=e.trim().toLowerCase();return/^0x0{63}[0-9a-f]$/.test(r)&&(r="0x"+r.slice(-1)),s(r,t)}}export{o as AptosValidator,a as SuiValidator};
1
+ import{A as e,V as t,f as a}from"./shared/base-CZZTeLCP.mjs";const s=/^0x[0-9a-fA-F]{64}$/,r=/^0x[0-9a-fA-F]$/,i="0x"+"0".repeat(63);class d extends e{validateImplementation(e){return s.test(e)?{valid:!0,blockchain:"sui",details:{format:"hex",checksum:!1}}:{valid:!1,error:"Expected 0x followed by 64 hex digits",details:{errorCode:t.INVALID_FORMAT}}}}class o extends e{validateImplementation(e,a){return(3===e.length?r:s).test(e)&&(!a?.strict||!/[A-F]/.test(e)&&!e.startsWith(i))?{valid:!0,blockchain:"aptos",details:{format:"hex",checksum:!1}}:{valid:!1,error:"Invalid Aptos address (AIP-40)",details:{errorCode:t.INVALID_FORMAT}}}format(e,t){if(!this.validate(e).valid)throw new Error("Invalid Aptos address");let s=e.trim().toLowerCase();return s.startsWith(i)&&(s="0x"+s.slice(-1)),a(s,t)}}export{o as AptosValidator,d as SuiValidator};
package/dist/near.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var t;!function(t){t.INVALID_FORMAT="INVALID_FORMAT",t.INVALID_CHECKSUM="INVALID_CHECKSUM",t.INVALID_LENGTH="INVALID_LENGTH",t.INVALID_CHARACTERS="INVALID_CHARACTERS",t.UNSUPPORTED_CHAIN="UNSUPPORTED_CHAIN",t.BURN_ADDRESS="BURN_ADDRESS",t.UNSAFE_INPUT="UNSAFE_INPUT",t.NETWORK_MISMATCH="NETWORK_MISMATCH"}(t||(t={}));class e{static sanitize(e){if(null==e)throw new Error(t.UNSAFE_INPUT);if("string"!=typeof e)throw new Error(t.UNSAFE_INPUT);if(e.length>256)throw new Error(t.UNSAFE_INPUT);if(/[^\x20-\x7E]/.test(e))throw new Error(t.UNSAFE_INPUT);return e.trim()}}class r{validate(r,n){try{const i=e.sanitize(r),s=this.validateImplementation(i,n),a=s.details?.network;return s.valid&&a&&(n?.network&&"auto"!==n.network&&n.network!==a||!1===n?.allowTestnet&&"testnet"===a)?{valid:!1,error:"Address network does not match the requested network",details:{...s.details,errorCode:t.NETWORK_MISMATCH}}:s}catch(e){const r=e instanceof Error?e.message:String(e);return r===t.UNSAFE_INPUT?{valid:!1,error:"Unsafe input detected",details:{errorCode:t.UNSAFE_INPUT}}:{valid:!1,error:r,details:{errorCode:t.INVALID_FORMAT}}}}format(t,r){return function(t,r,n=4){const i=e.sanitize(t);if(!r?.shorten)return i;const s=r.shortenLength??n;if(!Number.isSafeInteger(s)||s<1)throw new RangeError("shortenLength must be a positive integer");const a=i.startsWith("0x")?2:0;return i.length<=2*s+a+3?i:`${i.slice(0,s+a)}...${i.slice(-s)}`}(t,r)}}exports.NearValidator=class extends r{validateImplementation(e){if(e.length<2||e.length>64||!/^[a-z0-9]+(?:[._-][a-z0-9]+)*$/.test(e))return{valid:!1,error:"Invalid NEAR account ID",details:{errorCode:t.INVALID_FORMAT}};return{valid:!0,blockchain:"near",details:{format:/^[0-9a-f]{64}$/.test(e)||/^0x[0-9a-f]{40}$/.test(e)?"implicit":/^0s[0-9a-f]{40}$/.test(e)?"deterministic":/^0u[0-9a-hjkmnp-tv-z]{51}[0g]$/.test(e)?"universal":"named",checksum:!1}}}};
1
+ "use strict";var e=require("./shared/base-3sYui6r0.cjs");class t extends e.AddressValidator{validateImplementation(t){if(t.length<2||t.length>64||!/^[a-z0-9]+(?:[._-][a-z0-9]+)*$/.test(t))return{valid:!1,error:"Invalid NEAR account ID",details:{errorCode:e.ValidationError.INVALID_FORMAT}};return{valid:!0,blockchain:"near",details:{format:/^[0-9a-f]{64}$/.test(t)||/^0x[0-9a-f]{40}$/.test(t)?"implicit":/^0s[0-9a-f]{40}$/.test(t)?"deterministic":/^0u[0-9a-hjkmnp-tv-z]{51}[0g]$/.test(t)?"universal":"named",checksum:!1}}}}exports.NearValidator=t;
package/dist/near.mjs CHANGED
@@ -1 +1 @@
1
- var t;!function(t){t.INVALID_FORMAT="INVALID_FORMAT",t.INVALID_CHECKSUM="INVALID_CHECKSUM",t.INVALID_LENGTH="INVALID_LENGTH",t.INVALID_CHARACTERS="INVALID_CHARACTERS",t.UNSUPPORTED_CHAIN="UNSUPPORTED_CHAIN",t.BURN_ADDRESS="BURN_ADDRESS",t.UNSAFE_INPUT="UNSAFE_INPUT",t.NETWORK_MISMATCH="NETWORK_MISMATCH"}(t||(t={}));class e{static sanitize(e){if(null==e)throw new Error(t.UNSAFE_INPUT);if("string"!=typeof e)throw new Error(t.UNSAFE_INPUT);if(e.length>256)throw new Error(t.UNSAFE_INPUT);if(/[^\x20-\x7E]/.test(e))throw new Error(t.UNSAFE_INPUT);return e.trim()}}class r{validate(r,n){try{const i=e.sanitize(r),s=this.validateImplementation(i,n),a=s.details?.network;return s.valid&&a&&(n?.network&&"auto"!==n.network&&n.network!==a||!1===n?.allowTestnet&&"testnet"===a)?{valid:!1,error:"Address network does not match the requested network",details:{...s.details,errorCode:t.NETWORK_MISMATCH}}:s}catch(e){const r=e instanceof Error?e.message:String(e);return r===t.UNSAFE_INPUT?{valid:!1,error:"Unsafe input detected",details:{errorCode:t.UNSAFE_INPUT}}:{valid:!1,error:r,details:{errorCode:t.INVALID_FORMAT}}}}format(t,r){return function(t,r,n=4){const i=e.sanitize(t);if(!r?.shorten)return i;const s=r.shortenLength??n;if(!Number.isSafeInteger(s)||s<1)throw new RangeError("shortenLength must be a positive integer");const a=i.startsWith("0x")?2:0;return i.length<=2*s+a+3?i:`${i.slice(0,s+a)}...${i.slice(-s)}`}(t,r)}}class n extends r{validateImplementation(e){if(e.length<2||e.length>64||!/^[a-z0-9]+(?:[._-][a-z0-9]+)*$/.test(e))return{valid:!1,error:"Invalid NEAR account ID",details:{errorCode:t.INVALID_FORMAT}};return{valid:!0,blockchain:"near",details:{format:/^[0-9a-f]{64}$/.test(e)||/^0x[0-9a-f]{40}$/.test(e)?"implicit":/^0s[0-9a-f]{40}$/.test(e)?"deterministic":/^0u[0-9a-hjkmnp-tv-z]{51}[0g]$/.test(e)?"universal":"named",checksum:!1}}}}export{n as NearValidator};
1
+ import{A as e,V as t}from"./shared/base-CZZTeLCP.mjs";class a extends e{validateImplementation(e){if(e.length<2||e.length>64||!/^[a-z0-9]+(?:[._-][a-z0-9]+)*$/.test(e))return{valid:!1,error:"Invalid NEAR account ID",details:{errorCode:t.INVALID_FORMAT}};return{valid:!0,blockchain:"near",details:{format:/^[0-9a-f]{64}$/.test(e)||/^0x[0-9a-f]{40}$/.test(e)?"implicit":/^0s[0-9a-f]{40}$/.test(e)?"deterministic":/^0u[0-9a-hjkmnp-tv-z]{51}[0g]$/.test(e)?"universal":"named",checksum:!1}}}}export{a as NearValidator};
package/dist/ripple.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var r;!function(r){r.INVALID_FORMAT="INVALID_FORMAT",r.INVALID_CHECKSUM="INVALID_CHECKSUM",r.INVALID_LENGTH="INVALID_LENGTH",r.INVALID_CHARACTERS="INVALID_CHARACTERS",r.UNSUPPORTED_CHAIN="UNSUPPORTED_CHAIN",r.BURN_ADDRESS="BURN_ADDRESS",r.UNSAFE_INPUT="UNSAFE_INPUT",r.NETWORK_MISMATCH="NETWORK_MISMATCH"}(r||(r={}));class t{static sanitize(t){if(null==t)throw new Error(r.UNSAFE_INPUT);if("string"!=typeof t)throw new Error(r.UNSAFE_INPUT);if(t.length>256)throw new Error(r.UNSAFE_INPUT);if(/[^\x20-\x7E]/.test(t))throw new Error(r.UNSAFE_INPUT);return t.trim()}}class e{validate(e,n){try{const o=t.sanitize(e),i=this.validateImplementation(o,n),s=i.details?.network;return i.valid&&s&&(n?.network&&"auto"!==n.network&&n.network!==s||!1===n?.allowTestnet&&"testnet"===s)?{valid:!1,error:"Address network does not match the requested network",details:{...i.details,errorCode:r.NETWORK_MISMATCH}}:i}catch(t){const e=t instanceof Error?t.message:String(t);return e===r.UNSAFE_INPUT?{valid:!1,error:"Unsafe input detected",details:{errorCode:r.UNSAFE_INPUT}}:{valid:!1,error:e,details:{errorCode:r.INVALID_FORMAT}}}}format(r,e){return function(r,e,n=4){const o=t.sanitize(r);if(!e?.shorten)return o;const i=e.shortenLength??n;if(!Number.isSafeInteger(i)||i<1)throw new RangeError("shortenLength must be a positive integer");const s=o.startsWith("0x")?2:0;return o.length<=2*i+s+3?o:`${o.slice(0,i+s)}...${o.slice(-i)}`}(r,e)}}function n(r){const t=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],e=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],n=8*r.length,i=r.length,s=new Uint8Array(64-(i+8)%64+8);s[0]=128;const l=n,a=Math.floor(l/4294967296),c=l%4294967296,d=s.length;s[d-4]=c>>>24&255,s[d-3]=c>>>16&255,s[d-2]=c>>>8&255,s[d-1]=255&c,s[d-8]=a>>>24&255,s[d-7]=a>>>16&255,s[d-6]=a>>>8&255,s[d-5]=255&a;const A=new Uint8Array(i+s.length);A.set(r),A.set(s,i);const I=new Uint32Array(64);for(let r=0;r<A.length;r+=64){for(let t=0;t<16;t++)I[t]=A[r+4*t]<<24|A[r+4*t+1]<<16|A[r+4*t+2]<<8|A[r+4*t+3];for(let r=16;r<64;r++){const t=o(I[r-2],17)^o(I[r-2],19)^I[r-2]>>>10,e=o(I[r-15],7)^o(I[r-15],18)^I[r-15]>>>3;I[r]=t+I[r-7]+e+I[r-16]|0}let n=e[0],i=e[1],s=e[2],l=e[3],a=e[4],c=e[5],d=e[6],h=e[7];for(let r=0;r<64;r++){const e=h+(o(a,6)^o(a,11)^o(a,25))+(a&c^~a&d)+t[r]+I[r]|0,A=n&i^n&s^i&s;h=d,d=c,c=a,a=l+e|0,l=s,s=i,i=n,n=e+((o(n,2)^o(n,13)^o(n,22))+A|0)|0}e[0]=e[0]+n|0,e[1]=e[1]+i|0,e[2]=e[2]+s|0,e[3]=e[3]+l|0,e[4]=e[4]+a|0,e[5]=e[5]+c|0,e[6]=e[6]+d|0,e[7]=e[7]+h|0}const h=new Uint8Array(32);for(let r=0;r<8;r++)h[4*r]=e[r]>>>24&255,h[4*r+1]=e[r]>>>16&255,h[4*r+2]=e[r]>>>8&255,h[4*r+3]=255&e[r];return h}function o(r,t){return r>>>t|r<<32-t}const i="rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz",s=i.charAt(0),l={};for(let r=0;r<58;r++)l[i.charAt(r)]=r;exports.RippleValidator=class extends e{validateImplementation(t){if(!t.startsWith("r"))return{valid:!1,error:"Must start with r",details:{errorCode:r.INVALID_FORMAT}};if(t.length<25||t.length>35)return{valid:!1,error:"Invalid length",details:{errorCode:r.INVALID_LENGTH}};try{const e=function(r){if(0===r.length)return new Uint8Array(0);let t=0;for(;t<r.length&&r[t]===s;)t++;const e=t,n=[0];for(;t<r.length;t++){const e=r[t],o=l[e];if(void 0===o)throw new Error(`Invalid Ripple Base58 character: ${e}`);for(let r=0;r<n.length;r++)n[r]*=58;n[0]+=o;let i=0;for(let r=0;r<n.length;++r)n[r]+=i,i=n[r]>>8,n[r]&=255;for(;i;)n.push(255&i),i>>=8}let o=[];r.length!==e&&(o=n.reverse());for(let r=0;r<e;r++)o.unshift(0);return new Uint8Array(o)}(t);if(25!==e.length||0!==e[0])return{valid:!1,error:"Invalid decoded length",details:{errorCode:r.INVALID_LENGTH}};const o=e.slice(0,21),i=e.slice(21),a=n(o),c=n(a);return c[0]!==i[0]||c[1]!==i[1]||c[2]!==i[2]||c[3]!==i[3]?{valid:!1,error:"Invalid checksum",details:{errorCode:r.INVALID_CHECKSUM}}:{valid:!0,blockchain:"ripple"}}catch{return{valid:!1,error:"Invalid characters",details:{errorCode:r.INVALID_CHARACTERS}}}}};
1
+ "use strict";var r=require("./shared/base-3sYui6r0.cjs"),e=require("./shared/base58check-BeCwnkGe.cjs");const a=require("./shared/base58-DV6hu8Kq.cjs").createBase58Decoder("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz");class t extends r.AddressValidator{validateImplementation(t){if(!t.startsWith("r"))return{valid:!1,error:"Must start with r",details:{errorCode:r.ValidationError.INVALID_FORMAT}};if(t.length<25||t.length>35)return{valid:!1,error:"Invalid length",details:{errorCode:r.ValidationError.INVALID_LENGTH}};try{const d=a(t);return 25!==d.length||0!==d[0]?{valid:!1,error:"Invalid decoded length",details:{errorCode:r.ValidationError.INVALID_LENGTH}}:e.checkedPayload(d)?{valid:!0,blockchain:"ripple"}:{valid:!1,error:"Invalid checksum",details:{errorCode:r.ValidationError.INVALID_CHECKSUM}}}catch{return{valid:!1,error:"Invalid characters",details:{errorCode:r.ValidationError.INVALID_CHARACTERS}}}}}exports.RippleValidator=t;
package/dist/ripple.mjs CHANGED
@@ -1 +1 @@
1
- var r;!function(r){r.INVALID_FORMAT="INVALID_FORMAT",r.INVALID_CHECKSUM="INVALID_CHECKSUM",r.INVALID_LENGTH="INVALID_LENGTH",r.INVALID_CHARACTERS="INVALID_CHARACTERS",r.UNSUPPORTED_CHAIN="UNSUPPORTED_CHAIN",r.BURN_ADDRESS="BURN_ADDRESS",r.UNSAFE_INPUT="UNSAFE_INPUT",r.NETWORK_MISMATCH="NETWORK_MISMATCH"}(r||(r={}));class t{static sanitize(t){if(null==t)throw new Error(r.UNSAFE_INPUT);if("string"!=typeof t)throw new Error(r.UNSAFE_INPUT);if(t.length>256)throw new Error(r.UNSAFE_INPUT);if(/[^\x20-\x7E]/.test(t))throw new Error(r.UNSAFE_INPUT);return t.trim()}}class e{validate(e,n){try{const o=t.sanitize(e),i=this.validateImplementation(o,n),l=i.details?.network;return i.valid&&l&&(n?.network&&"auto"!==n.network&&n.network!==l||!1===n?.allowTestnet&&"testnet"===l)?{valid:!1,error:"Address network does not match the requested network",details:{...i.details,errorCode:r.NETWORK_MISMATCH}}:i}catch(t){const e=t instanceof Error?t.message:String(t);return e===r.UNSAFE_INPUT?{valid:!1,error:"Unsafe input detected",details:{errorCode:r.UNSAFE_INPUT}}:{valid:!1,error:e,details:{errorCode:r.INVALID_FORMAT}}}}format(r,e){return function(r,e,n=4){const o=t.sanitize(r);if(!e?.shorten)return o;const i=e.shortenLength??n;if(!Number.isSafeInteger(i)||i<1)throw new RangeError("shortenLength must be a positive integer");const l=o.startsWith("0x")?2:0;return o.length<=2*i+l+3?o:`${o.slice(0,i+l)}...${o.slice(-i)}`}(r,e)}}function n(r){const t=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],e=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],n=8*r.length,i=r.length,l=new Uint8Array(64-(i+8)%64+8);l[0]=128;const s=n,a=Math.floor(s/4294967296),c=s%4294967296,A=l.length;l[A-4]=c>>>24&255,l[A-3]=c>>>16&255,l[A-2]=c>>>8&255,l[A-1]=255&c,l[A-8]=a>>>24&255,l[A-7]=a>>>16&255,l[A-6]=a>>>8&255,l[A-5]=255&a;const I=new Uint8Array(i+l.length);I.set(r),I.set(l,i);const d=new Uint32Array(64);for(let r=0;r<I.length;r+=64){for(let t=0;t<16;t++)d[t]=I[r+4*t]<<24|I[r+4*t+1]<<16|I[r+4*t+2]<<8|I[r+4*t+3];for(let r=16;r<64;r++){const t=o(d[r-2],17)^o(d[r-2],19)^d[r-2]>>>10,e=o(d[r-15],7)^o(d[r-15],18)^d[r-15]>>>3;d[r]=t+d[r-7]+e+d[r-16]|0}let n=e[0],i=e[1],l=e[2],s=e[3],a=e[4],c=e[5],A=e[6],h=e[7];for(let r=0;r<64;r++){const e=h+(o(a,6)^o(a,11)^o(a,25))+(a&c^~a&A)+t[r]+d[r]|0,I=n&i^n&l^i&l;h=A,A=c,c=a,a=s+e|0,s=l,l=i,i=n,n=e+((o(n,2)^o(n,13)^o(n,22))+I|0)|0}e[0]=e[0]+n|0,e[1]=e[1]+i|0,e[2]=e[2]+l|0,e[3]=e[3]+s|0,e[4]=e[4]+a|0,e[5]=e[5]+c|0,e[6]=e[6]+A|0,e[7]=e[7]+h|0}const h=new Uint8Array(32);for(let r=0;r<8;r++)h[4*r]=e[r]>>>24&255,h[4*r+1]=e[r]>>>16&255,h[4*r+2]=e[r]>>>8&255,h[4*r+3]=255&e[r];return h}function o(r,t){return r>>>t|r<<32-t}const i="rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz",l=i.charAt(0),s={};for(let r=0;r<58;r++)s[i.charAt(r)]=r;class a extends e{validateImplementation(t){if(!t.startsWith("r"))return{valid:!1,error:"Must start with r",details:{errorCode:r.INVALID_FORMAT}};if(t.length<25||t.length>35)return{valid:!1,error:"Invalid length",details:{errorCode:r.INVALID_LENGTH}};try{const e=function(r){if(0===r.length)return new Uint8Array(0);let t=0;for(;t<r.length&&r[t]===l;)t++;const e=t,n=[0];for(;t<r.length;t++){const e=r[t],o=s[e];if(void 0===o)throw new Error(`Invalid Ripple Base58 character: ${e}`);for(let r=0;r<n.length;r++)n[r]*=58;n[0]+=o;let i=0;for(let r=0;r<n.length;++r)n[r]+=i,i=n[r]>>8,n[r]&=255;for(;i;)n.push(255&i),i>>=8}let o=[];r.length!==e&&(o=n.reverse());for(let r=0;r<e;r++)o.unshift(0);return new Uint8Array(o)}(t);if(25!==e.length||0!==e[0])return{valid:!1,error:"Invalid decoded length",details:{errorCode:r.INVALID_LENGTH}};const o=e.slice(0,21),i=e.slice(21),a=n(o),c=n(a);return c[0]!==i[0]||c[1]!==i[1]||c[2]!==i[2]||c[3]!==i[3]?{valid:!1,error:"Invalid checksum",details:{errorCode:r.INVALID_CHECKSUM}}:{valid:!0,blockchain:"ripple"}}catch{return{valid:!1,error:"Invalid characters",details:{errorCode:r.INVALID_CHARACTERS}}}}}export{a as RippleValidator};
1
+ import{A as r,V as e}from"./shared/base-CZZTeLCP.mjs";import{c as a}from"./shared/base58check-rMkz2cjy.mjs";import{c as t}from"./shared/base58-DY9-Un67.mjs";const s=t("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz");class d extends r{validateImplementation(r){if(!r.startsWith("r"))return{valid:!1,error:"Must start with r",details:{errorCode:e.INVALID_FORMAT}};if(r.length<25||r.length>35)return{valid:!1,error:"Invalid length",details:{errorCode:e.INVALID_LENGTH}};try{const t=s(r);return 25!==t.length||0!==t[0]?{valid:!1,error:"Invalid decoded length",details:{errorCode:e.INVALID_LENGTH}}:a(t)?{valid:!0,blockchain:"ripple"}:{valid:!1,error:"Invalid checksum",details:{errorCode:e.INVALID_CHECKSUM}}}catch{return{valid:!1,error:"Invalid characters",details:{errorCode:e.INVALID_CHARACTERS}}}}}export{d as RippleValidator};
@@ -0,0 +1 @@
1
+ "use strict";const t=Object.freeze(["ethereum","polygon","bsc","avalanche","arbitrum","optimism","base","evm","fantom","sonic","gnosis","celo","cronos","moonbeam","moonriver","zksync","linea","scroll","mantle","blast","opbnb","zora","worldchain"]),r=Object.freeze(["cosmos","osmosis","celestia","injective","sei"]);var e;exports.ValidationError=void 0,(e=exports.ValidationError||(exports.ValidationError={})).INVALID_FORMAT="INVALID_FORMAT",e.INVALID_CHECKSUM="INVALID_CHECKSUM",e.INVALID_LENGTH="INVALID_LENGTH",e.INVALID_CHARACTERS="INVALID_CHARACTERS",e.UNSUPPORTED_CHAIN="UNSUPPORTED_CHAIN",e.BURN_ADDRESS="BURN_ADDRESS",e.UNSAFE_INPUT="UNSAFE_INPUT",e.NETWORK_MISMATCH="NETWORK_MISMATCH";class o{static trySanitize(t){return"string"!=typeof t||t.length>256||/[^\x20-\x7E]/.test(t)?null:t.trim()}static sanitize(t){const r=o.trySanitize(t);if(null===r)throw new Error(exports.ValidationError.UNSAFE_INPUT);return r}}function n(){return{valid:!1,error:"Unsafe input detected",details:{errorCode:exports.ValidationError.UNSAFE_INPUT}}}function i(t){const r=t?.network;if(null!=r&&"mainnet"!==r&&"testnet"!==r&&"auto"!==r)throw new RangeError("Invalid network option (expected 'mainnet', 'testnet' or 'auto')")}function s(t,r,e=4){const n=o.sanitize(t);if(!r?.shorten)return n;const i=r.shortenLength??e;if(!Number.isSafeInteger(i)||i<1)throw new RangeError("shortenLength must be a positive integer");const s=n.startsWith("0x")?2:0;return n.length<=2*i+s+3?n:`${n.slice(0,i+s)}...${n.slice(-i)}`}exports.AddressValidator=class{validate(t,r){i(r);try{const e=o.trySanitize(t);if(null===e)return n();const i=this.validateImplementation(e,r),s=i.details?.network;return i.valid&&s&&(r?.network&&"auto"!==r.network&&r.network!==s||!1===r?.allowTestnet&&"testnet"===s)?{valid:!1,error:"Address network does not match the requested network",details:{...i.details,errorCode:exports.ValidationError.NETWORK_MISMATCH}}:i}catch(t){const r=t instanceof Error?t.message:String(t);return r===exports.ValidationError.UNSAFE_INPUT?n():{valid:!1,error:r,details:{errorCode:exports.ValidationError.INVALID_FORMAT}}}}format(t,r){return s(t,r)}},exports.COSMOS_CHAINS=r,exports.EVM_CHAINS=t,exports.InputSanitizer=o,exports.assertValidationOptions=i,exports.formatPlainAddress=s;
@@ -0,0 +1 @@
1
+ const e=Object.freeze(["ethereum","polygon","bsc","avalanche","arbitrum","optimism","base","evm","fantom","sonic","gnosis","celo","cronos","moonbeam","moonriver","zksync","linea","scroll","mantle","blast","opbnb","zora","worldchain"]),t=Object.freeze(["cosmos","osmosis","celestia","injective","sei"]);var n;!function(e){e.INVALID_FORMAT="INVALID_FORMAT",e.INVALID_CHECKSUM="INVALID_CHECKSUM",e.INVALID_LENGTH="INVALID_LENGTH",e.INVALID_CHARACTERS="INVALID_CHARACTERS",e.UNSUPPORTED_CHAIN="UNSUPPORTED_CHAIN",e.BURN_ADDRESS="BURN_ADDRESS",e.UNSAFE_INPUT="UNSAFE_INPUT",e.NETWORK_MISMATCH="NETWORK_MISMATCH"}(n||(n={}));class r{static trySanitize(e){return"string"!=typeof e||e.length>256||/[^\x20-\x7E]/.test(e)?null:e.trim()}static sanitize(e){const t=r.trySanitize(e);if(null===t)throw new Error(n.UNSAFE_INPUT);return t}}function o(){return{valid:!1,error:"Unsafe input detected",details:{errorCode:n.UNSAFE_INPUT}}}function s(e){const t=e?.network;if(null!=t&&"mainnet"!==t&&"testnet"!==t&&"auto"!==t)throw new RangeError("Invalid network option (expected 'mainnet', 'testnet' or 'auto')")}class a{validate(e,t){s(t);try{const s=r.trySanitize(e);if(null===s)return o();const a=this.validateImplementation(s,t),i=a.details?.network;return a.valid&&i&&(t?.network&&"auto"!==t.network&&t.network!==i||!1===t?.allowTestnet&&"testnet"===i)?{valid:!1,error:"Address network does not match the requested network",details:{...a.details,errorCode:n.NETWORK_MISMATCH}}:a}catch(e){const t=e instanceof Error?e.message:String(e);return t===n.UNSAFE_INPUT?o():{valid:!1,error:t,details:{errorCode:n.INVALID_FORMAT}}}}format(e,t){return i(e,t)}}function i(e,t,n=4){const o=r.sanitize(e);if(!t?.shorten)return o;const s=t.shortenLength??n;if(!Number.isSafeInteger(s)||s<1)throw new RangeError("shortenLength must be a positive integer");const a=o.startsWith("0x")?2:0;return o.length<=2*s+a+3?o:`${o.slice(0,s+a)}...${o.slice(-s)}`}export{a as A,t as C,e as E,r as I,n as V,s as a,i as f};
@@ -0,0 +1 @@
1
+ "use strict";function e(e){const t=Object.create(null);for(let r=0;r<e.length;r++)t[e[r]]=r;return r=>{let n=0;for(;n<r.length&&r[n]===e[0];)n++;const o=[];for(let e=n;e<r.length;e++){let n=t[r[e]];if(void 0===n)throw new Error(`Invalid Base58 character: ${r[e]}`);for(let e=0;e<o.length;e++)n+=58*o[e],o[e]=255&n,n>>>=8;for(;n>0;)o.push(255&n),n>>>=8}const s=new Uint8Array(n+o.length);return s.set(o.reverse(),n),s}}const t=e("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");exports.createBase58Decoder=e,exports.decodeBase58=t;
@@ -0,0 +1 @@
1
+ function e(e){const t=Object.create(null);for(let r=0;r<e.length;r++)t[e[r]]=r;return r=>{let n=0;for(;n<r.length&&r[n]===e[0];)n++;const o=[];for(let e=n;e<r.length;e++){let n=t[r[e]];if(void 0===n)throw new Error(`Invalid Base58 character: ${r[e]}`);for(let e=0;e<o.length;e++)n+=58*o[e],o[e]=255&n,n>>>=8;for(;n>0;)o.push(255&n),n>>>=8}const l=new Uint8Array(n+o.length);return l.set(o.reverse(),n),l}}const t=e("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");export{e as c,t as d};
@@ -0,0 +1 @@
1
+ "use strict";var t=require("./base58-DV6hu8Kq.cjs");const e=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function n(t){const n=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],c=64*Math.ceil((t.length+9)/64),l=new Uint8Array(c);l.set(t),l[t.length]=128;const s=8*t.length;r(l,c-8,Math.floor(s/4294967296)),r(l,c-4,s);const u=new Array(64);for(let t=0;t<c;t+=64){for(let e=0;e<16;e++){const n=t+4*e;u[e]=l[n]<<24|l[n+1]<<16|l[n+2]<<8|l[n+3]}for(let t=16;t<64;t++){const e=o(u[t-2],17)^o(u[t-2],19)^u[t-2]>>>10,n=o(u[t-15],7)^o(u[t-15],18)^u[t-15]>>>3;u[t]=e+u[t-7]+n+u[t-16]|0}let r=n[0],c=n[1],s=n[2],a=n[3],f=n[4],i=n[5],h=n[6],d=n[7];for(let t=0;t<64;t++){const n=d+(o(f,6)^o(f,11)^o(f,25))+(f&i^~f&h)+e[t]+u[t]|0,l=r&c^r&s^c&s;d=h,h=i,i=f,f=a+n|0,a=s,s=c,c=r,r=n+((o(r,2)^o(r,13)^o(r,22))+l|0)|0}n[0]=n[0]+r|0,n[1]=n[1]+c|0,n[2]=n[2]+s|0,n[3]=n[3]+a|0,n[4]=n[4]+f|0,n[5]=n[5]+i|0,n[6]=n[6]+h|0,n[7]=n[7]+d|0}const a=new Uint8Array(32);for(let t=0;t<n.length;t++)r(a,4*t,n[t]);return a}function r(t,e,n){t[e]=n>>>24,t[e+1]=n>>>16,t[e+2]=n>>>8,t[e+3]=n}function o(t,e){return t>>>e|t<<32-e}function c(t){if(t.length<5)return null;const e=t.subarray(0,-4),r=n(n(e));for(let n=0;n<4;n++)if(t[e.length+n]!==r[n])return null;return e}exports.checkedPayload=c,exports.decodeBase58Check=function(e){try{return c(t.decodeBase58(e))}catch{return null}};
@@ -0,0 +1 @@
1
+ import{d as t}from"./base58-DY9-Un67.mjs";const n=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function r(t){const r=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],l=64*Math.ceil((t.length+9)/64),c=new Uint8Array(l);c.set(t),c[t.length]=128;const s=8*t.length;e(c,l-8,Math.floor(s/4294967296)),e(c,l-4,s);const u=new Array(64);for(let t=0;t<l;t+=64){for(let n=0;n<16;n++){const r=t+4*n;u[n]=c[r]<<24|c[r+1]<<16|c[r+2]<<8|c[r+3]}for(let t=16;t<64;t++){const n=o(u[t-2],17)^o(u[t-2],19)^u[t-2]>>>10,r=o(u[t-15],7)^o(u[t-15],18)^u[t-15]>>>3;u[t]=n+u[t-7]+r+u[t-16]|0}let e=r[0],l=r[1],s=r[2],f=r[3],a=r[4],i=r[5],h=r[6],g=r[7];for(let t=0;t<64;t++){const r=g+(o(a,6)^o(a,11)^o(a,25))+(a&i^~a&h)+n[t]+u[t]|0,c=e&l^e&s^l&s;g=h,h=i,i=a,a=f+r|0,f=s,s=l,l=e,e=r+((o(e,2)^o(e,13)^o(e,22))+c|0)|0}r[0]=r[0]+e|0,r[1]=r[1]+l|0,r[2]=r[2]+s|0,r[3]=r[3]+f|0,r[4]=r[4]+a|0,r[5]=r[5]+i|0,r[6]=r[6]+h|0,r[7]=r[7]+g|0}const f=new Uint8Array(32);for(let t=0;t<r.length;t++)e(f,4*t,r[t]);return f}function e(t,n,r){t[n]=r>>>24,t[n+1]=r>>>16,t[n+2]=r>>>8,t[n+3]=r}function o(t,n){return t>>>n|t<<32-n}function l(t){if(t.length<5)return null;const n=t.subarray(0,-4),e=r(r(n));for(let r=0;r<4;r++)if(t[n.length+r]!==e[r])return null;return n}function c(n){try{return l(t(n))}catch{return null}}export{l as c,c as d};
@@ -0,0 +1 @@
1
+ var n;!function(n){n.BECH32="bech32",n.BECH32M="bech32m"}(n||(n={}));const t=[996825010,642813549,513874426,1027748829,705979059],e=new Uint32Array(32);for(let n=1;n<e.length;n++)for(let r=0;r<t.length;r++)n&1<<r&&(e[n]^=t[r]);function r(n,t){return(33554431&n)<<5^t^e[n>>>25]}function l(t,e=90,l){if(t.length<8||t.length>e)return null;const o=t.lastIndexOf("1");if(o<1||o+7>t.length)return null;const u=t.slice(0,o).toLowerCase();if(void 0!==l&&u!==l)return null;if(/[^\x21-\x7E]/.test(t))return null;const f=t.toLowerCase();if(t!==f&&t!==t.toUpperCase())return null;const i=[];let s,c=function(n){let t=1;for(let e=0;e<n.length;e++)t=r(t,n.charCodeAt(e)>>>5);t=r(t,0);for(let e=0;e<n.length;e++)t=r(t,31&n.charCodeAt(e));return t}(u);for(let n=o+1;n<f.length;n++){const t="qpzry9x8gf2tvdw0s3jn54khce6mua7l".indexOf(f[n]);if(-1===t)return null;c=r(c,t),n<f.length-6&&i.push(t)}if(1===c)s=n.BECH32;else{if(734539939!==c)return null;s=n.BECH32M}return{hrp:u,data:i,encoding:s}}function o(n){let t=0,e=0;const r=new Uint8Array(Math.floor(5*n.length/8));let l=0;for(const o of n){if(!Number.isInteger(o)||o<0||o>31)return null;t=65535&(t<<5|o),e+=5,e>=8&&(e-=8,r[l++]=t>>>e&255)}return e>=5||t<<8-e&255?null:r}export{n as B,l as d,o as w};
@@ -0,0 +1 @@
1
+ "use strict";var e;exports.Bech32Encoding=void 0,(e=exports.Bech32Encoding||(exports.Bech32Encoding={})).BECH32="bech32",e.BECH32M="bech32m";const n=[996825010,642813549,513874426,1027748829,705979059],t=new Uint32Array(32);for(let e=1;e<t.length;e++)for(let r=0;r<n.length;r++)e&1<<r&&(t[e]^=n[r]);function r(e,n){return(33554431&e)<<5^n^t[e>>>25]}exports.decodeBech32=function(e,n=90,t){if(e.length<8||e.length>n)return null;const o=e.lastIndexOf("1");if(o<1||o+7>e.length)return null;const l=e.slice(0,o).toLowerCase();if(void 0!==t&&l!==t)return null;if(/[^\x21-\x7E]/.test(e))return null;const c=e.toLowerCase();if(e!==c&&e!==e.toUpperCase())return null;const s=[];let u,i=function(e){let n=1;for(let t=0;t<e.length;t++)n=r(n,e.charCodeAt(t)>>>5);n=r(n,0);for(let t=0;t<e.length;t++)n=r(n,31&e.charCodeAt(t));return n}(l);for(let e=o+1;e<c.length;e++){const n="qpzry9x8gf2tvdw0s3jn54khce6mua7l".indexOf(c[e]);if(-1===n)return null;i=r(i,n),e<c.length-6&&s.push(n)}if(1===i)u=exports.Bech32Encoding.BECH32;else{if(734539939!==i)return null;u=exports.Bech32Encoding.BECH32M}return{hrp:l,data:s,encoding:u}},exports.wordsToBytes=function(e){let n=0,t=0;const r=new Uint8Array(Math.floor(5*e.length/8));let o=0;for(const l of e){if(!Number.isInteger(l)||l<0||l>31)return null;n=65535&(n<<5|l),t+=5,t>=8&&(t-=8,r[o++]=n>>>t&255)}return t>=5||n<<8-t&255?null:r};
@@ -0,0 +1 @@
1
+ import{A as i,V as t}from"./base-CZZTeLCP.mjs";import{d as n}from"./base58check-rMkz2cjy.mjs";import{d as s,w as e,B as a}from"./bech32-Cu41-5bd.mjs";class r extends i{constructor(i){super(),this.config=i}validateImplementation(i){const s=i.toLowerCase().split("1")[0];if(this.config.hrps&&Object.prototype.hasOwnProperty.call(this.config.hrps,s))return this.validateWitness(i,this.config.hrps[s]);if(i.length<26||i.length>35)return this.invalid("Invalid address length",t.INVALID_LENGTH);const e=n(i);if(!e)return this.invalid("Invalid Base58Check address",t.INVALID_CHECKSUM);if(21!==e.length)return this.invalid("Invalid payload length",t.INVALID_LENGTH);const a=this.config.versions[e[0]];return a?{valid:!0,blockchain:this.config.chain,details:{format:"legacy",network:a,checksum:!0}}:this.invalid("Invalid address version")}validateWitness(i,n){const r=s(i);if(!r||0===r.data.length)return this.invalid("Invalid Bech32 encoding");const o=r.data[0],l=e(r.data.slice(1));if(o>16)return this.invalid("Invalid witness version");if(!l||l.length<2||l.length>40||0===o&&20!==l.length&&32!==l.length)return this.invalid("Invalid witness program or padding",t.INVALID_LENGTH);const h=0===o?a.BECH32:a.BECH32M;if(r.encoding!==h)return this.invalid("Wrong checksum encoding for witness version",t.INVALID_CHECKSUM);let c="future";return 0===o?c="segwit":1===o&&32===l.length?c="taproot":"bitcoin"===this.config.chain&&1===o&&2===l.length&&78===l[0]&&115===l[1]&&(c="anchor"),{valid:!0,blockchain:this.config.chain,details:{format:c,network:n,checksum:!0}}}invalid(i,n=t.INVALID_FORMAT){return{valid:!1,error:i,details:{errorCode:n}}}}export{r as U};
@@ -0,0 +1 @@
1
+ "use strict";var i=require("./base-3sYui6r0.cjs"),n=require("./base58check-BeCwnkGe.cjs"),t=require("./bech32-Dk6Pnay4.cjs");class e extends i.AddressValidator{constructor(i){super(),this.config=i}validateImplementation(t){const e=t.toLowerCase().split("1")[0];if(this.config.hrps&&Object.prototype.hasOwnProperty.call(this.config.hrps,e))return this.validateWitness(t,this.config.hrps[e]);if(t.length<26||t.length>35)return this.invalid("Invalid address length",i.ValidationError.INVALID_LENGTH);const r=n.decodeBase58Check(t);if(!r)return this.invalid("Invalid Base58Check address",i.ValidationError.INVALID_CHECKSUM);if(21!==r.length)return this.invalid("Invalid payload length",i.ValidationError.INVALID_LENGTH);const a=this.config.versions[r[0]];return a?{valid:!0,blockchain:this.config.chain,details:{format:"legacy",network:a,checksum:!0}}:this.invalid("Invalid address version")}validateWitness(n,e){const r=t.decodeBech32(n);if(!r||0===r.data.length)return this.invalid("Invalid Bech32 encoding");const a=r.data[0],s=t.wordsToBytes(r.data.slice(1));if(a>16)return this.invalid("Invalid witness version");if(!s||s.length<2||s.length>40||0===a&&20!==s.length&&32!==s.length)return this.invalid("Invalid witness program or padding",i.ValidationError.INVALID_LENGTH);const o=0===a?t.Bech32Encoding.BECH32:t.Bech32Encoding.BECH32M;if(r.encoding!==o)return this.invalid("Wrong checksum encoding for witness version",i.ValidationError.INVALID_CHECKSUM);let d="future";return 0===a?d="segwit":1===a&&32===s.length?d="taproot":"bitcoin"===this.config.chain&&1===a&&2===s.length&&78===s[0]&&115===s[1]&&(d="anchor"),{valid:!0,blockchain:this.config.chain,details:{format:d,network:e,checksum:!0}}}invalid(n,t=i.ValidationError.INVALID_FORMAT){return{valid:!1,error:n,details:{errorCode:t}}}}exports.UtxoValidator=e;
package/dist/solana.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var r;!function(r){r.INVALID_FORMAT="INVALID_FORMAT",r.INVALID_CHECKSUM="INVALID_CHECKSUM",r.INVALID_LENGTH="INVALID_LENGTH",r.INVALID_CHARACTERS="INVALID_CHARACTERS",r.UNSUPPORTED_CHAIN="UNSUPPORTED_CHAIN",r.BURN_ADDRESS="BURN_ADDRESS",r.UNSAFE_INPUT="UNSAFE_INPUT",r.NETWORK_MISMATCH="NETWORK_MISMATCH"}(r||(r={}));class e{static sanitize(e){if(null==e)throw new Error(r.UNSAFE_INPUT);if("string"!=typeof e)throw new Error(r.UNSAFE_INPUT);if(e.length>256)throw new Error(r.UNSAFE_INPUT);if(/[^\x20-\x7E]/.test(e))throw new Error(r.UNSAFE_INPUT);return e.trim()}}class t{validate(t,n){try{const o=e.sanitize(t),a=this.validateImplementation(o,n),i=a.details?.network;return a.valid&&i&&(n?.network&&"auto"!==n.network&&n.network!==i||!1===n?.allowTestnet&&"testnet"===i)?{valid:!1,error:"Address network does not match the requested network",details:{...a.details,errorCode:r.NETWORK_MISMATCH}}:a}catch(e){const t=e instanceof Error?e.message:String(e);return t===r.UNSAFE_INPUT?{valid:!1,error:"Unsafe input detected",details:{errorCode:r.UNSAFE_INPUT}}:{valid:!1,error:t,details:{errorCode:r.INVALID_FORMAT}}}}format(r,t){return function(r,t,n=4){const o=e.sanitize(r);if(!t?.shorten)return o;const a=t.shortenLength??n;if(!Number.isSafeInteger(a)||a<1)throw new RangeError("shortenLength must be a positive integer");const i=o.startsWith("0x")?2:0;return o.length<=2*a+i+3?o:`${o.slice(0,a+i)}...${o.slice(-a)}`}(r,t)}}const n="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",o=n.charAt(0),a={};for(let r=0;r<58;r++)a[n.charAt(r)]=r;exports.SolanaValidator=class extends t{validateImplementation(e){if(e.length<32||e.length>44)return{valid:!1,error:"Invalid length",details:{errorCode:r.INVALID_LENGTH}};try{if(32!==function(r){if(0===r.length)return new Uint8Array(0);let e=0;for(;e<r.length&&r[e]===o;)e++;const t=e,n=[0];for(;e<r.length;e++){const t=r[e],o=a[t];if(void 0===o)throw new Error(`Invalid Base58 character: ${t}`);for(let r=0;r<n.length;r++)n[r]*=58;n[0]+=o;let i=0;for(let r=0;r<n.length;++r)n[r]+=i,i=n[r]>>8,n[r]&=255;for(;i;)n.push(255&i),i>>=8}const i=r.length===t?[]:n.reverse();return Uint8Array.from([...new Array(t).fill(0),...i])}(e).length)return{valid:!1,error:"Invalid public key length",details:{errorCode:r.INVALID_LENGTH}}}catch{return{valid:!1,error:"Invalid Base58 characters",details:{errorCode:r.INVALID_FORMAT}}}return"11111111111111111111111111111111"===e?{valid:!0,blockchain:"solana",details:{format:"System Program"}}:{valid:!0,blockchain:"solana"}}};
1
+ "use strict";var r=require("./shared/base-3sYui6r0.cjs"),a=require("./shared/base58-DV6hu8Kq.cjs");class e extends r.AddressValidator{validateImplementation(e){if(e.length<32||e.length>44)return{valid:!1,error:"Invalid length",details:{errorCode:r.ValidationError.INVALID_LENGTH}};try{if(32!==a.decodeBase58(e).length)return{valid:!1,error:"Invalid public key length",details:{errorCode:r.ValidationError.INVALID_LENGTH}}}catch{return{valid:!1,error:"Invalid Base58 characters",details:{errorCode:r.ValidationError.INVALID_FORMAT}}}return"11111111111111111111111111111111"===e?{valid:!0,blockchain:"solana",details:{format:"System Program"}}:{valid:!0,blockchain:"solana"}}}exports.SolanaValidator=e;
package/dist/solana.mjs CHANGED
@@ -1 +1 @@
1
- var r;!function(r){r.INVALID_FORMAT="INVALID_FORMAT",r.INVALID_CHECKSUM="INVALID_CHECKSUM",r.INVALID_LENGTH="INVALID_LENGTH",r.INVALID_CHARACTERS="INVALID_CHARACTERS",r.UNSUPPORTED_CHAIN="UNSUPPORTED_CHAIN",r.BURN_ADDRESS="BURN_ADDRESS",r.UNSAFE_INPUT="UNSAFE_INPUT",r.NETWORK_MISMATCH="NETWORK_MISMATCH"}(r||(r={}));class e{static sanitize(e){if(null==e)throw new Error(r.UNSAFE_INPUT);if("string"!=typeof e)throw new Error(r.UNSAFE_INPUT);if(e.length>256)throw new Error(r.UNSAFE_INPUT);if(/[^\x20-\x7E]/.test(e))throw new Error(r.UNSAFE_INPUT);return e.trim()}}class t{validate(t,n){try{const o=e.sanitize(t),a=this.validateImplementation(o,n),i=a.details?.network;return a.valid&&i&&(n?.network&&"auto"!==n.network&&n.network!==i||!1===n?.allowTestnet&&"testnet"===i)?{valid:!1,error:"Address network does not match the requested network",details:{...a.details,errorCode:r.NETWORK_MISMATCH}}:a}catch(e){const t=e instanceof Error?e.message:String(e);return t===r.UNSAFE_INPUT?{valid:!1,error:"Unsafe input detected",details:{errorCode:r.UNSAFE_INPUT}}:{valid:!1,error:t,details:{errorCode:r.INVALID_FORMAT}}}}format(r,t){return function(r,t,n=4){const o=e.sanitize(r);if(!t?.shorten)return o;const a=t.shortenLength??n;if(!Number.isSafeInteger(a)||a<1)throw new RangeError("shortenLength must be a positive integer");const i=o.startsWith("0x")?2:0;return o.length<=2*a+i+3?o:`${o.slice(0,a+i)}...${o.slice(-a)}`}(r,t)}}const n="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",o=n.charAt(0),a={};for(let r=0;r<58;r++)a[n.charAt(r)]=r;class i extends t{validateImplementation(e){if(e.length<32||e.length>44)return{valid:!1,error:"Invalid length",details:{errorCode:r.INVALID_LENGTH}};try{if(32!==function(r){if(0===r.length)return new Uint8Array(0);let e=0;for(;e<r.length&&r[e]===o;)e++;const t=e,n=[0];for(;e<r.length;e++){const t=r[e],o=a[t];if(void 0===o)throw new Error(`Invalid Base58 character: ${t}`);for(let r=0;r<n.length;r++)n[r]*=58;n[0]+=o;let i=0;for(let r=0;r<n.length;++r)n[r]+=i,i=n[r]>>8,n[r]&=255;for(;i;)n.push(255&i),i>>=8}const i=r.length===t?[]:n.reverse();return Uint8Array.from([...new Array(t).fill(0),...i])}(e).length)return{valid:!1,error:"Invalid public key length",details:{errorCode:r.INVALID_LENGTH}}}catch{return{valid:!1,error:"Invalid Base58 characters",details:{errorCode:r.INVALID_FORMAT}}}return"11111111111111111111111111111111"===e?{valid:!0,blockchain:"solana",details:{format:"System Program"}}:{valid:!0,blockchain:"solana"}}}export{i as SolanaValidator};
1
+ import{A as r,V as e}from"./shared/base-CZZTeLCP.mjs";import{d as a}from"./shared/base58-DY9-Un67.mjs";class l extends r{validateImplementation(r){if(r.length<32||r.length>44)return{valid:!1,error:"Invalid length",details:{errorCode:e.INVALID_LENGTH}};try{if(32!==a(r).length)return{valid:!1,error:"Invalid public key length",details:{errorCode:e.INVALID_LENGTH}}}catch{return{valid:!1,error:"Invalid Base58 characters",details:{errorCode:e.INVALID_FORMAT}}}return"11111111111111111111111111111111"===r?{valid:!0,blockchain:"solana",details:{format:"System Program"}}:{valid:!0,blockchain:"solana"}}}export{l as SolanaValidator};
package/dist/tron.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var t;!function(t){t.INVALID_FORMAT="INVALID_FORMAT",t.INVALID_CHECKSUM="INVALID_CHECKSUM",t.INVALID_LENGTH="INVALID_LENGTH",t.INVALID_CHARACTERS="INVALID_CHARACTERS",t.UNSUPPORTED_CHAIN="UNSUPPORTED_CHAIN",t.BURN_ADDRESS="BURN_ADDRESS",t.UNSAFE_INPUT="UNSAFE_INPUT",t.NETWORK_MISMATCH="NETWORK_MISMATCH"}(t||(t={}));class e{static sanitize(e){if(null==e)throw new Error(t.UNSAFE_INPUT);if("string"!=typeof e)throw new Error(t.UNSAFE_INPUT);if(e.length>256)throw new Error(t.UNSAFE_INPUT);if(/[^\x20-\x7E]/.test(e))throw new Error(t.UNSAFE_INPUT);return e.trim()}}class r{validate(r,n){try{const o=e.sanitize(r),s=this.validateImplementation(o,n),i=s.details?.network;return s.valid&&i&&(n?.network&&"auto"!==n.network&&n.network!==i||!1===n?.allowTestnet&&"testnet"===i)?{valid:!1,error:"Address network does not match the requested network",details:{...s.details,errorCode:t.NETWORK_MISMATCH}}:s}catch(e){const r=e instanceof Error?e.message:String(e);return r===t.UNSAFE_INPUT?{valid:!1,error:"Unsafe input detected",details:{errorCode:t.UNSAFE_INPUT}}:{valid:!1,error:r,details:{errorCode:t.INVALID_FORMAT}}}}format(t,r){return function(t,r,n=4){const o=e.sanitize(t);if(!r?.shorten)return o;const s=r.shortenLength??n;if(!Number.isSafeInteger(s)||s<1)throw new RangeError("shortenLength must be a positive integer");const i=o.startsWith("0x")?2:0;return o.length<=2*s+i+3?o:`${o.slice(0,s+i)}...${o.slice(-s)}`}(t,r)}}const n="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",o=n.charAt(0),s={};for(let t=0;t<58;t++)s[n.charAt(t)]=t;function i(t){const e=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],r=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],n=8*t.length,o=t.length,s=new Uint8Array(64-(o+8)%64+8);s[0]=128;const i=n,a=Math.floor(i/4294967296),c=i%4294967296,h=s.length;s[h-4]=c>>>24&255,s[h-3]=c>>>16&255,s[h-2]=c>>>8&255,s[h-1]=255&c,s[h-8]=a>>>24&255,s[h-7]=a>>>16&255,s[h-6]=a>>>8&255,s[h-5]=255&a;const A=new Uint8Array(o+s.length);A.set(t),A.set(s,o);const N=new Uint32Array(64);for(let t=0;t<A.length;t+=64){for(let e=0;e<16;e++)N[e]=A[t+4*e]<<24|A[t+4*e+1]<<16|A[t+4*e+2]<<8|A[t+4*e+3];for(let t=16;t<64;t++){const e=l(N[t-2],17)^l(N[t-2],19)^N[t-2]>>>10,r=l(N[t-15],7)^l(N[t-15],18)^N[t-15]>>>3;N[t]=e+N[t-7]+r+N[t-16]|0}let n=r[0],o=r[1],s=r[2],i=r[3],a=r[4],c=r[5],h=r[6],f=r[7];for(let t=0;t<64;t++){const r=f+(l(a,6)^l(a,11)^l(a,25))+(a&c^~a&h)+e[t]+N[t]|0,A=n&o^n&s^o&s;f=h,h=c,c=a,a=i+r|0,i=s,s=o,o=n,n=r+((l(n,2)^l(n,13)^l(n,22))+A|0)|0}r[0]=r[0]+n|0,r[1]=r[1]+o|0,r[2]=r[2]+s|0,r[3]=r[3]+i|0,r[4]=r[4]+a|0,r[5]=r[5]+c|0,r[6]=r[6]+h|0,r[7]=r[7]+f|0}const f=new Uint8Array(32);for(let t=0;t<8;t++)f[4*t]=r[t]>>>24&255,f[4*t+1]=r[t]>>>16&255,f[4*t+2]=r[t]>>>8&255,f[4*t+3]=255&r[t];return f}function l(t,e){return t>>>e|t<<32-e}function a(t){try{const e=function(t){if(0===t.length)return new Uint8Array(0);let e=0;for(;e<t.length&&t[e]===o;)e++;const r=e,n=[0];for(;e<t.length;e++){const r=t[e],o=s[r];if(void 0===o)throw new Error(`Invalid Base58 character: ${r}`);for(let t=0;t<n.length;t++)n[t]*=58;n[0]+=o;let i=0;for(let t=0;t<n.length;++t)n[t]+=i,i=n[t]>>8,n[t]&=255;for(;i;)n.push(255&i),i>>=8}const i=t.length===r?[]:n.reverse();return Uint8Array.from([...new Array(r).fill(0),...i])}(t);if(e.length<5)return null;const r=e.slice(0,-4),n=i(i(r));return e.slice(-4).every((t,e)=>t===n[e])?r:null}catch{return null}}exports.TronValidator=class extends r{validateImplementation(e){if(/^41[0-9a-fA-F]{40}$/.test(e))return{valid:!0,blockchain:"tron",details:{format:"hex",checksum:!1}};const r=34===e.length&&e.startsWith("T")?a(e):null;return r&&21===r.length&&65===r[0]?{valid:!0,blockchain:"tron",details:{format:"base58check",checksum:!0}}:{valid:!1,error:"Invalid TRON address",details:{errorCode:t.INVALID_FORMAT}}}};
1
+ "use strict";var e=require("./shared/base-3sYui6r0.cjs"),r=require("./shared/base58check-BeCwnkGe.cjs");require("./shared/base58-DV6hu8Kq.cjs");class a extends e.AddressValidator{validateImplementation(a){if(/^41[0-9a-fA-F]{40}$/.test(a))return{valid:!0,blockchain:"tron",details:{format:"hex",checksum:!1}};const s=34===a.length&&a.startsWith("T")?r.decodeBase58Check(a):null;return s&&21===s.length&&65===s[0]?{valid:!0,blockchain:"tron",details:{format:"base58check",checksum:!0}}:{valid:!1,error:"Invalid TRON address",details:{errorCode:e.ValidationError.INVALID_FORMAT}}}}exports.TronValidator=a;