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/tron.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 o=e.sanitize(r),s=this.validateImplementation(o,n),l=s.details?.network;return s.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:{...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 l=o.startsWith("0x")?2:0;return o.length<=2*s+l+3?o:`${o.slice(0,s+l)}...${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 l(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 l=n,a=Math.floor(l/4294967296),c=l%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=i(N[t-2],17)^i(N[t-2],19)^N[t-2]>>>10,r=i(N[t-15],7)^i(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],l=r[3],a=r[4],c=r[5],h=r[6],f=r[7];for(let t=0;t<64;t++){const r=f+(i(a,6)^i(a,11)^i(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=l+r|0,l=s,s=o,o=n,n=r+((i(n,2)^i(n,13)^i(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]+l|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 i(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 l=0;for(let t=0;t<n.length;++t)n[t]+=l,l=n[t]>>8,n[t]&=255;for(;l;)n.push(255&l),l>>=8}const l=t.length===r?[]:n.reverse();return Uint8Array.from([...new Array(r).fill(0),...l])}(t);if(e.length<5)return null;const r=e.slice(0,-4),n=l(l(r));return e.slice(-4).every((t,e)=>t===n[e])?r:null}catch{return null}}class c 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}}}}export{c as TronValidator};
1
+ import{A as e,V as a}from"./shared/base-CZZTeLCP.mjs";import{d as s}from"./shared/base58check-rMkz2cjy.mjs";import"./shared/base58-DY9-Un67.mjs";class r extends e{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")?s(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:a.INVALID_FORMAT}}}}export{r as TronValidator};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "validator0x",
3
- "version": "0.3.0",
3
+ "version": "0.4.1",
4
4
  "description": "Lightweight, zero-dependency wallet address validation for EVM, Bitcoin, Solana, TRON, Cosmos, Cardano, Sui, Aptos, NEAR and more.",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",
@@ -61,21 +61,22 @@
61
61
  "author": "Samarth Patel",
62
62
  "license": "MIT",
63
63
  "devDependencies": {
64
+ "@eslint/js": "^10.0.1",
65
+ "@noble/hashes": "^2.4.0",
66
+ "@rollup/plugin-terser": "^1.0.2",
64
67
  "@rollup/plugin-typescript": "^12.3.1",
68
+ "@scure/base": "^2.4.0",
65
69
  "@types/node": "^22.0.0",
70
+ "@vitest/coverage-v8": "^5.1.0",
66
71
  "eslint": "^10.14.0",
72
+ "playwright-core": "^1.65.1",
67
73
  "prettier": "^3.10.1",
68
74
  "rollup": "^4.68.3",
75
+ "rollup-plugin-dts": "^6.5.1",
69
76
  "tslib": "^2.8.1",
70
77
  "typescript": "5.9.3",
71
- "@rollup/plugin-terser": "^1.0.2",
72
- "rollup-plugin-dts": "^6.5.1",
73
78
  "typescript-eslint": "^8.72.2",
74
- "@eslint/js": "^10.0.1",
75
- "@noble/hashes": "^2.4.0",
76
- "@scure/base": "^2.4.0",
77
- "vitest": "^5.1.0",
78
- "@vitest/coverage-v8": "^5.1.0"
79
+ "vitest": "^5.1.0"
79
80
  },
80
81
  "unpkg": "./dist/index.umd.js",
81
82
  "jsdelivr": "./dist/index.umd.js",