{"_id":"@casper-ecosystem/casper-eip-712","_rev":"8-d190ee6ed2789a9bdf0c906356ae75d4","name":"@casper-ecosystem/casper-eip-712","dist-tags":{"latest":"1.2.1"},"versions":{"1.0.0":{"name":"@casper-ecosystem/casper-eip-712","version":"1.0.0","keywords":["casper","eip-712","blockchain","cryptography","typed-data"],"license":"Apache-2.0","_id":"@casper-ecosystem/casper-eip-712@1.0.0","maintainers":[{"name":"michaelsteuer","email":"michael@make.services"}],"homepage":"https://github.com/casper-ecosystem/casper-eip-712#readme","bugs":{"url":"https://github.com/casper-ecosystem/casper-eip-712/issues"},"dist":{"shasum":"f090185c3d93cbea9565984cd6713b0b5d34189c","tarball":"https://registry.npmjs.org/@casper-ecosystem/casper-eip-712/-/casper-eip-712-1.0.0.tgz","fileCount":8,"integrity":"sha512-XPQYsnsP2dMGDHfNztHh57KNXX5t/oyOP9o2zcfSSJOSZXILlnYGL2i9qib0lKNhaBhR1ZZqIMNnIdKC7FpooQ==","signatures":[{"sig":"MEYCIQC6k/trChP7Z/R/EPntxvCoJbTCG+CJ9ORpOMqttN++ZQIhAKuBd4bnfiQ8658jOkzVvpJqbPyD2I8tjtcNSKMcVyw6","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":85399},"main":"dist/index.cjs","type":"module","types":"dist/index.d.ts","module":"dist/index.js","exports":{".":{"import":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"require":{"types":"./dist/index.d.cts","default":"./dist/index.cjs"}}},"gitHead":"a9296db4352d7930b661f4d44aa7ee76d629c477","scripts":{"test":"vitest run","build":"tsup","test:watch":"vitest","generate:vectors":"npx tsx ../scripts/generate-vectors.ts"},"_npmUser":{"name":"michaelsteuer","email":"michael@make.services"},"repository":{"url":"git+https://github.com/casper-ecosystem/casper-eip-712.git","type":"git","directory":"js"},"_npmVersion":"10.9.4","description":"EIP-712 typed data hashing and verification for Casper Network","directories":{},"_nodeVersion":"22.22.0","dependencies":{"@noble/curves":"^1.8.0","@noble/hashes":"^1.7.0"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","ethers":"^6.16.0","vitest":"^3.0.0","typescript":"^5.7.0"},"_npmOperationalInternal":{"tmp":"tmp/casper-eip-712_1.0.0_1773696457752_0.5370815532979345","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@casper-ecosystem/casper-eip-712","version":"1.0.1","keywords":["casper","eip-712","blockchain","cryptography","typed-data"],"license":"Apache-2.0","_id":"@casper-ecosystem/casper-eip-712@1.0.1","maintainers":[{"name":"michaelsteuer","email":"michael@make.services"}],"homepage":"https://github.com/casper-ecosystem/casper-eip-712#readme","bugs":{"url":"https://github.com/casper-ecosystem/casper-eip-712/issues"},"dist":{"shasum":"b2c25bcedce3d2da80c07d6e3d9715a9d51f5cdb","tarball":"https://registry.npmjs.org/@casper-ecosystem/casper-eip-712/-/casper-eip-712-1.0.1.tgz","fileCount":8,"integrity":"sha512-3BbLjkGAKwaqtZYxZ1Cxo0UA8iOKH014B0nbfUexxQIfoIMsP7/YasRJOU6OIjJORLL2X4EVPS692pDa3ozwRg==","signatures":[{"sig":"MEUCIQCJz7cy2C1sG2IN5gyt4pGdEHxp7YdXckjiY/OOOfP1iwIgbxxdkR+u2JgkeAZ2WUuG/fGFxDiR+H0hlnfzQrB2X+8=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":85783},"main":"dist/index.cjs","type":"module","types":"dist/index.d.ts","module":"dist/index.js","exports":{".":{"import":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"require":{"types":"./dist/index.d.cts","default":"./dist/index.cjs"}}},"gitHead":"51bb3f99a75576e7150dd35f01e0b0c09c376f8f","scripts":{"test":"vitest run","build":"tsup","test:watch":"vitest","generate:vectors":"npx tsx ../scripts/generate-vectors.ts"},"_npmUser":{"name":"michaelsteuer","email":"michael@make.services"},"repository":{"url":"git+https://github.com/casper-ecosystem/casper-eip-712.git","type":"git","directory":"js"},"_npmVersion":"10.9.4","description":"EIP-712 typed data hashing and verification for Casper Network","directories":{},"_nodeVersion":"22.22.0","dependencies":{"@noble/curves":"^1.8.0","@noble/hashes":"^1.7.0"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","ethers":"^6.16.0","vitest":"^3.0.0","typescript":"^5.7.0"},"_npmOperationalInternal":{"tmp":"tmp/casper-eip-712_1.0.1_1773772386559_0.8768067120039174","host":"s3://npm-registry-packages-npm-production"}},"1.1.0":{"name":"@casper-ecosystem/casper-eip-712","version":"1.1.0","keywords":["casper","eip-712","blockchain","cryptography","typed-data"],"license":"Apache-2.0","_id":"@casper-ecosystem/casper-eip-712@1.1.0","maintainers":[{"name":"michaelsteuer","email":"michael@make.services"},{"name":"make.services","email":"david.hernando@make.services"},{"name":"burlachenko","email":"ihor.burlachenko@gmail.com"},{"name":"alex_myshchyshyn","email":"oleksandrm@make.services"}],"homepage":"https://github.com/casper-ecosystem/casper-eip-712#readme","bugs":{"url":"https://github.com/casper-ecosystem/casper-eip-712/issues"},"dist":{"shasum":"084722af706062f6b66bea7224ac19ed3b77e1c7","tarball":"https://registry.npmjs.org/@casper-ecosystem/casper-eip-712/-/casper-eip-712-1.1.0.tgz","fileCount":8,"integrity":"sha512-q8111SXXmGeKtcg1gEEhdvUli+0g4szhMjufpDWFJ5WiLder9yo4vypAO1m8wa3bx50f2LnIvAhQJpoRsqaWqg==","signatures":[{"sig":"MEYCIQCwxr7D6+hXCvswaRfmX0/TngXM97RiSfXGOohCvONwhwIhALOFRPwidAcWLM+z/c5kPZ+Wrd+1+XdPvNTXTnHmj0AC","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":85783},"main":"dist/index.cjs","type":"module","types":"dist/index.d.ts","module":"dist/index.js","exports":{".":{"import":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"require":{"types":"./dist/index.d.cts","default":"./dist/index.cjs"}}},"gitHead":"a2f455cdaecb93dbfe2be0f2433ba36975f0cb32","scripts":{"test":"vitest run","build":"tsup","test:watch":"vitest","generate:vectors":"npx tsx ../scripts/generate-vectors.ts"},"_npmUser":{"name":"michaelsteuer","email":"michael@make.services"},"repository":{"url":"git+https://github.com/casper-ecosystem/casper-eip-712.git","type":"git","directory":"js"},"_npmVersion":"10.9.7","description":"EIP-712 typed data hashing and verification for Casper Network","directories":{},"_nodeVersion":"22.22.2","dependencies":{"@noble/curves":"^1.8.0","@noble/hashes":"^1.7.0"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","ethers":"^6.16.0","vitest":"^3.0.0","typescript":"^5.7.0"},"_npmOperationalInternal":{"tmp":"tmp/casper-eip-712_1.1.0_1775767239943_0.5706016020523459","host":"s3://npm-registry-packages-npm-production"}},"1.2.0":{"name":"@casper-ecosystem/casper-eip-712","version":"1.2.0","keywords":["casper","eip-712","blockchain","cryptography","typed-data"],"license":"Apache-2.0","_id":"@casper-ecosystem/casper-eip-712@1.2.0","maintainers":[{"name":"michaelsteuer","email":"michael@make.services"},{"name":"make.services","email":"david.hernando@make.services"},{"name":"burlachenko","email":"ihor.burlachenko@gmail.com"},{"name":"alex_myshchyshyn","email":"oleksandrm@make.services"}],"homepage":"https://github.com/casper-ecosystem/casper-eip-712#readme","bugs":{"url":"https://github.com/casper-ecosystem/casper-eip-712/issues"},"dist":{"shasum":"e835276d50869c40c34efb5a94b329abd70fde0b","tarball":"https://registry.npmjs.org/@casper-ecosystem/casper-eip-712/-/casper-eip-712-1.2.0.tgz","fileCount":8,"integrity":"sha512-MSs6cvSfHQ8/S/2g5zpkXPt0DpFeC+40JzyZClHKfUtIhPR68sJjRxK43yT/Jr4qTWWaeAL17JNkmDFDsV/Fng==","signatures":[{"sig":"MEYCIQCS3GE8IvvRU8MA27mEPCbLlIAXkmrVS/SsTN3fSQHB/wIhAPhxeoeHc9fM5Cy2fTL3/hNGib4mXwxFq3ZJB9+tCKpT","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":100504},"main":"dist/index.cjs","type":"module","types":"dist/index.d.ts","module":"dist/index.js","exports":{".":{"import":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"require":{"types":"./dist/index.d.cts","default":"./dist/index.cjs"}}},"gitHead":"a6a7eaac675c03abb12c4f46bcddf37fbe866ce8","scripts":{"test":"vitest run","build":"tsup","test:watch":"vitest","generate:vectors":"npx tsx ../scripts/generate-vectors.ts"},"_npmUser":{"name":"michaelsteuer","email":"michael@make.services"},"repository":{"url":"git+https://github.com/casper-ecosystem/casper-eip-712.git","type":"git","directory":"js"},"_npmVersion":"10.9.7","description":"EIP-712 typed data hashing and verification for Casper Network","directories":{},"_nodeVersion":"22.22.2","dependencies":{"@noble/curves":"^1.8.0","@noble/hashes":"^1.7.0"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","ethers":"^6.16.0","vitest":"^3.0.0","typescript":"^5.7.0"},"_npmOperationalInternal":{"tmp":"tmp/casper-eip-712_1.2.0_1777189909838_0.929913636509833","host":"s3://npm-registry-packages-npm-production"}},"1.2.1":{"name":"@casper-ecosystem/casper-eip-712","version":"1.2.1","description":"EIP-712 typed data hashing and verification for Casper Network","type":"module","main":"dist/index.cjs","module":"dist/index.js","types":"dist/index.d.ts","exports":{".":{"import":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"require":{"types":"./dist/index.d.cts","default":"./dist/index.cjs"}}},"scripts":{"build":"tsup","test":"vitest run","test:watch":"vitest","generate:vectors":"npx tsx ../scripts/generate-vectors.ts"},"keywords":["casper","eip-712","blockchain","cryptography","typed-data"],"license":"Apache-2.0","repository":{"type":"git","url":"git+https://github.com/casper-ecosystem/casper-eip-712.git","directory":"js"},"dependencies":{"@noble/hashes":"^1.7.0","@noble/curves":"^1.8.0"},"devDependencies":{"tsup":"^8.0.0","typescript":"^5.7.0","vitest":"^3.0.0","ethers":"^6.16.0"},"_id":"@casper-ecosystem/casper-eip-712@1.2.1","gitHead":"eec325975823f0079e07bc84f3de7f32e0082d2a","bugs":{"url":"https://github.com/casper-ecosystem/casper-eip-712/issues"},"homepage":"https://github.com/casper-ecosystem/casper-eip-712#readme","_nodeVersion":"22.22.2","_npmVersion":"11.5.1","dist":{"integrity":"sha512-qhrpaISByIoOnbELH7hhLMVBinIP1vOc4Z+6ZI5aItcc1O3SrDXNu0fdKm5qRSLLb5p94JxaS+jGegiIAwiKDA==","shasum":"6f8c09b8673d39ec1be847f5a35c2068f5b57ab5","tarball":"https://registry.npmjs.org/@casper-ecosystem/casper-eip-712/-/casper-eip-712-1.2.1.tgz","fileCount":8,"unpackedSize":102048,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@casper-ecosystem%2fcasper-eip-712@1.2.1","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIGJSO0265BRHwyzaLv27bRs8wGjx3h0TMd3Iw9qezfKEAiEA5fsyDvtgjcHv36bupYX/Oq14x1VltPQKjKUXFJHLghw="}]},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:ebca589d-8ff1-442c-8014-07d36897817f"}},"directories":{},"maintainers":[{"name":"michaelsteuer","email":"michael@make.services"},{"name":"make.services","email":"david.hernando@make.services"},{"name":"burlachenko","email":"ihor.burlachenko@gmail.com"},{"name":"alex_myshchyshyn","email":"oleksandrm@make.services"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/casper-eip-712_1.2.1_1778695286105_0.1414855158404451"},"_hasShrinkwrap":false}},"time":{"created":"2026-03-16T21:27:37.630Z","modified":"2026-05-13T18:01:26.909Z","1.0.0":"2026-03-16T21:27:37.911Z","1.0.1":"2026-03-17T18:33:06.721Z","1.1.0":"2026-04-09T20:40:40.100Z","1.2.0":"2026-04-26T07:51:49.980Z","1.2.1":"2026-05-13T18:01:26.308Z"},"bugs":{"url":"https://github.com/casper-ecosystem/casper-eip-712/issues"},"license":"Apache-2.0","homepage":"https://github.com/casper-ecosystem/casper-eip-712#readme","keywords":["casper","eip-712","blockchain","cryptography","typed-data"],"repository":{"type":"git","url":"git+https://github.com/casper-ecosystem/casper-eip-712.git","directory":"js"},"description":"EIP-712 typed data hashing and verification for Casper Network","maintainers":[{"name":"michaelsteuer","email":"michael@make.services"},{"name":"make.services","email":"david.hernando@make.services"},{"name":"burlachenko","email":"ihor.burlachenko@gmail.com"},{"name":"alex_myshchyshyn","email":"oleksandrm@make.services"}],"readme":"# @casper-ecosystem/casper-eip-712\n\nTypeScript companion package for the Rust `casper-eip-712` crate.\n\nIt provides EIP-712 typed data hashing plus ECDSA signature recovery for Casper-oriented flows, including support for Casper-specific domain fields when you supply explicit domain types.\n\n## Install\n\n```bash\nnpm install @casper-ecosystem/casper-eip-712\n```\n\n## Quick start\n\n```ts\nimport {\n  hashTypedData,\n  recoverTypedDataSigner,\n  verifySignature,\n  PermitTypes,\n  type PermitMessage,\n} from \"@casper-ecosystem/casper-eip-712\";\n\nconst domain = {\n  name: \"My Token\",\n  version: \"1\",\n  chainId: 1,\n  verifyingContract: \"0x1111111111111111111111111111111111111111\",\n};\n\nconst message: PermitMessage = {\n  owner: \"0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\n  spender: \"0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\n  value: \"0x01\",\n  nonce: \"0x00\",\n  deadline: \"0xffff\",\n};\n\nconst signature = new Uint8Array(65); // Illustrative placeholder only; use a real 65-byte signature in production.\nconst digest = hashTypedData(domain, PermitTypes, \"Permit\", message);\nconst signer = recoverTypedDataSigner(domain, PermitTypes, \"Permit\", message, signature);\nconst isValid = verifySignature(digest, signature, \"0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\");\n```\n\n## Casper-specific domains\n\nIf your domain uses Casper-specific fields such as `chain_name` or `contract_package_hash`, pass explicit `domainTypes` so the package knows the intended domain schema.\n\nThe `chain_name` field is recommended to be a [CAIP-2](https://github.com/ChainAgnostic/namespaces/blob/main/casper/caip2.md) chain id of the form `casper:<chainspec_name>` — for example `casper:casper` for mainnet and `casper:casper-test` for testnet.\n\n```ts\nimport { hashTypedData } from \"@casper-ecosystem/casper-eip-712\";\n\nconst domain = {\n  name: \"CSPR\",\n  version: \"1\",\n  chain_name: \"casper:casper-test\",\n  contract_package_hash:\n    \"0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\",\n};\n\nconst digest = hashTypedData(domain, types, \"Permit\", message, {\n  domainTypes: [\n    { name: \"name\", type: \"string\" },\n    { name: \"version\", type: \"string\" },\n    { name: \"chain_name\", type: \"string\" },\n    { name: \"contract_package_hash\", type: \"bytes32\" },\n  ],\n});\n```\n\n## Building the canonical type string\n\nWhen you need the EIP-712 canonical type string for a primary type use `buildCanonicalTypeString`. It resolves nested struct dependencies and appends them in alphabetical order, as required by the EIP-712 spec.\n\n```ts\nimport { buildCanonicalTypeString, computeTypeHash } from \"@casper-ecosystem/casper-eip-712\";\n\nconst types = {\n  Person: [\n    { name: \"name\", type: \"string\" },\n    { name: \"wallet\", type: \"address\" },\n  ],\n  Mail: [\n    { name: \"from\", type: \"Person\" },\n    { name: \"to\", type: \"Person\" },\n    { name: \"contents\", type: \"string\" },\n  ],\n};\n\nconst typeString = buildCanonicalTypeString(\"Mail\", types);\n// \"Mail(Person from,Person to,string contents)Person(string name,address wallet)\"\n\nconst typeHash = computeTypeHash(typeString);\n```\n\n## Rust-mirroring convenience helpers\n\nFor callers that want the lower-level shape from the Rust crate, the package also exposes:\n\n```ts\nimport {\n  buildDomain,\n  CASPER_DOMAIN_TYPES,\n  computeTypeHash,\n  encodeAddress,\n  encodeUint256,\n  hashTypedDataRaw,\n} from \"@casper-ecosystem/casper-eip-712\";\n\nconst domain = buildDomain(\n  \"CasperToken\",\n  \"1\",\n  \"casper:casper-test\",\n  \"0x7777777777777777777777777777777777777777777777777777777777777777\",\n);\n\nconst typeHash = computeTypeHash(\n  \"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\",\n);\n\nconst encodedStruct = new Uint8Array(32 * 5);\nencodedStruct.set(encodeAddress(\"0x2222222222222222222222222222222222222222\"), 0);\nencodedStruct.set(encodeAddress(\"0x3333333333333333333333333333333333333333\"), 32);\nencodedStruct.set(encodeUint256(1n), 64);\nencodedStruct.set(encodeUint256(0n), 96);\nencodedStruct.set(encodeUint256(999999n), 128);\n\nconst digest = hashTypedDataRaw(domain, typeHash, encodedStruct, {\n  domainTypes: CASPER_DOMAIN_TYPES,\n});\n```\n\n## API surface\n\n- `buildDomain(name, version, chainName, contractPackageHash)`\n- `hashDomainSeparator(domain, domainTypes?)`\n- `hashStruct(primaryType, types, message)`\n- `hashTypedData(domain, types, primaryType, message, options?)`\n- `hashTypedDataRaw(domain, typeHash, encodedStruct, options?)`\n- `buildCanonicalTypeString(primaryType, types)`\n- `computeTypeHash(typeString)`\n- `recoverAddress(digest, signature)`\n- `recoverTypedDataSigner(domain, types, primaryType, message, signature, options?)`\n- `verifySignature(digest, signature, expectedAddress)`\n- Encoding helpers: `encodeAddress`, `encodeUint256`, `encodeUint64`, `encodeBytes32`, `encodeBytes`, `encodeString`, `encodeBool`, `encodeField`\n- Domain helpers: `CASPER_DOMAIN_TYPES`, `buildDomainTypeString`\n- Prebuilt message types: `PermitTypes`, `ApprovalTypes`, `TransferTypes`\n\n## Development\n\n```bash\nnpm test\nnpm run build\n```\n\nCross-language parity is covered by test vectors in `../tests/vectors.json`.\n","readmeFilename":"README.md"}