{"_id":"@dyadex-finance/tamperproof-transactions","name":"@dyadex-finance/tamperproof-transactions","dist-tags":{"latest":"2.0.0"},"versions":{"2.0.0":{"name":"@dyadex-finance/tamperproof-transactions","version":"2.0.0","type":"module","main":"./lib/index.js","module":"./dist/index.js","types":"./dist/index.d.ts","repository":{"type":"git","url":"git+https://github.com/dyadex-finance/uniswap-sdks.git"},"author":{"name":"Uniswap Labs Security","email":"security@dyadex-finance.org"},"license":"MIT","devDependencies":{"@types/node":"^18.7.16","@typescript-eslint/eslint-plugin":"^8.38.0","@typescript-eslint/parser":"^8.38.0","eslint":"^8.57.0","eslint-config-prettier":"^9.1.0","eslint-plugin-prettier":"^3.4.1","prettier":"^2.4.1","typescript":"^4.3.3"},"scripts":{"build:cjs":"tsc -p tsconfig.browserify.json","build:esm":"tsc -p tsconfig.json","build:browser:unminified":"bun build ./lib/index.js --outfile=dist/_twist.cjs --target=browser --format=cjs && node scripts/wrap-umd.cjs dist/_twist.cjs dist/twist.js twist && rm dist/_twist.cjs","build:browser:minified":"bun build ./lib/index.js --outfile=dist/_twist.min.cjs --target=browser --format=cjs --minify && node scripts/wrap-umd.cjs dist/_twist.min.cjs dist/twist.min.js twist && rm dist/_twist.min.cjs","build:browser":"bun run build:browser:unminified && bun run build:browser:minified","build":"bun run build:cjs && bun run build:esm && bun run build:browser","test":"bun test","lint":"eslint src --ext .ts --ignore-pattern '*.test.ts'","lint:fix":"eslint src --ext .ts --fix","format":"prettier --write src/**/*.ts","prepack":"bun run build","release":"changeset publish"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./lib/index.js"}},"browser":{"./lib/utils/webcrypto.js":"./lib/utils/crypto-browser-shim.js","node:crypto":false},"publishConfig":{"access":"public","provenance":true},"dependencies":{"dohjs":"^0.3.3"},"gitHead":"06ab4ee985528ad0159a9bfb6d4356a5693d59a1","_id":"@dyadex-finance/tamperproof-transactions@2.0.0","description":"[![npm version](https://img.shields.io/npm/v/@uniswap/tamperproof-transactions.svg)](https://www.npmjs.com/package/@uniswap/tamperproof-transactions) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MI","bugs":{"url":"https://github.com/dyadex-finance/uniswap-sdks/issues"},"homepage":"https://github.com/dyadex-finance/uniswap-sdks#readme","_nodeVersion":"24.14.1","_npmVersion":"11.11.0","dist":{"integrity":"sha512-NII4I5kqLZF+qo4n431YBnIK13xQjAJJ0dFMTVNaGIvISCVdK3z+jAFkHhLx/gJWrwFLKmxnTOeZgLQo19m93g==","shasum":"0eec267ff9f88df92f0049010d0fd6374b33650e","tarball":"https://registry.npmjs.org/@dyadex-finance/tamperproof-transactions/-/tamperproof-transactions-2.0.0.tgz","fileCount":37,"unpackedSize":777446,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@dyadex-finance%2ftamperproof-transactions@2.0.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDBgdTzB99Cm4zkuuQjwfpZf+rMpaUvzY+aXDs0343sgwIhAM/ugO7bg4wPACS+Mso8B4BbHbvdwHLWCxT8s3j4NfHD"}]},"_npmUser":{"name":"neddy34","email":"edwardlee9534@gmail.com"},"directories":{},"maintainers":[{"name":"neddy34","email":"edwardlee9534@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/tamperproof-transactions_2.0.0_1777304624830_0.24832626667143098"},"_hasShrinkwrap":false}},"time":{"created":"2026-04-27T15:43:44.743Z","2.0.0":"2026-04-27T15:43:44.973Z","modified":"2026-04-27T15:43:45.357Z"},"maintainers":[{"name":"neddy34","email":"edwardlee9534@gmail.com"}],"description":"[![npm version](https://img.shields.io/npm/v/@uniswap/tamperproof-transactions.svg)](https://www.npmjs.com/package/@uniswap/tamperproof-transactions) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MI","homepage":"https://github.com/dyadex-finance/uniswap-sdks#readme","repository":{"type":"git","url":"git+https://github.com/dyadex-finance/uniswap-sdks.git"},"author":{"name":"Uniswap Labs Security","email":"security@dyadex-finance.org"},"bugs":{"url":"https://github.com/dyadex-finance/uniswap-sdks/issues"},"license":"MIT","readme":"# tamperproof-transactions\n\n[![npm version](https://img.shields.io/npm/v/@uniswap/tamperproof-transactions.svg)](https://www.npmjs.com/package/@uniswap/tamperproof-transactions)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\nImplementation of [EIP-7754](https://eips.ethereum.org/EIPS/eip-7754)\n\n**Repository:** [https://github.com/Uniswap/sdks](https://github.com/Uniswap/sdks)\n\n## Installation\n\n```bash\nyarn add @uniswap/tamperproof-transactions\n# or\nnpm install @uniswap/tamperproof-transactions\n```\n\n## API\n\n### Supported algorithms\n\nAlgorithms are specified using standard JWS-style names. The library currently supports:\n\n```ts\n'ES256' | 'ES384' | 'ES512' | 'EdDSA' | 'PS256' | 'PS384' | 'PS512' | 'RS256' | 'RS384' | 'RS512'\n```\n\n---\n\n### `sign(data, privateKeyHex, algorithm): Promise<string>`\n\nSigns input using Web Crypto with the given algorithm.\n\n- **data**: `string | object`. If an object is provided, it is serialized to bytes using canonical JSON (sorted keys, `undefined` dropped).\n- **privateKeyHex**: PKCS#8-encoded private key as a hex string (with or without `0x`).\n- **algorithm**: one of the supported algorithm names listed above.\n- Returns a `Promise<string>` resolving to a hex string signature prefixed with `0x`. For ECDSA algorithms, the signature is raw `r || s` bytes.\n\n#### Example\n\n```ts\nimport { sign } from '@uniswap/tamperproof-transactions';\n\nconst data = { method: 'eth_sendTransaction', params: { to: '0xabc...', value: '0x1' } };\nconst privateKeyHex = '0x...'; // PKCS#8 private key, hex-encoded\nconst signature = await sign(data, privateKeyHex, 'RS256');\n```\n\n---\n\n### `verifyAsyncJson(calldata, signatureHex, url, id): Promise<boolean>`\n\nVerifies a signature by fetching a manifest of public keys (over HTTPS) and selecting the key with matching `id`.\n\n- **calldata**: `string | object` (object is canonicalized the same way as in `sign`).\n- **signatureHex**: hex string signature (with or without `0x`).\n- **url**: a `URL` instance pointing to the manifest (must be `https:`).\n- **id**: string identifier of the public key within the manifest.\n\n#### Example\n\n```ts\nimport { verifyAsyncJson } from '@uniswap/tamperproof-transactions';\n\nconst url = new URL('https://example.com/keys.json');\nconst ok = await verifyAsyncJson({ foo: 'bar' }, '0x...', url, '1');\n```\n\n---\n\n### `verifyAsyncDns(calldata, signatureHex, host, id): Promise<boolean>`\n\nResolves a DNS TXT record for `host` using DNS-over-HTTPS, extracts a `TWIST=` path, fetches the manifest over HTTPS, and verifies the signature using the key with the provided `id`.\n\n- **calldata**: `string`.\n- **signatureHex**: hex string signature (with or without `0x`).\n- **host**: domain name to query for a TXT record containing `TWIST=`.\n- **id**: string identifier of the public key within the manifest.\n\n#### Example\n\n```ts\nimport { verifyAsyncDns } from '@uniswap/tamperproof-transactions';\n\nconst ok = await verifyAsyncDns('hello', '0x...', 'example.com', '1');\n```\n\n---\n\n### `verify(calldata, signatureHex, publicKey, algorithm): Promise<boolean>`\n\nLower-level verification helper if you already have a `CryptoKey` public key object.\n\n- **publicKey**: a Web Crypto `CryptoKey` imported for verification.\n- **algorithm**: one of the supported algorithm names listed above.\n\n---\n\n### `generate(...publicKeys): string`\n\nGenerates a JSON manifest string containing an array of public keys.\n\n#### Types\n\n```ts\ntype PublicKey = {\n  key: string; // SPKI-encoded public key as hex (with or without 0x)\n  algorithm: 'ES256' | 'ES384' | 'ES512' | 'EdDSA' | 'PS256' | 'PS384' | 'PS512' | 'RS256' | 'RS384' | 'RS512';\n};\n```\n\nThe returned JSON has the shape:\n\n```json\n{\n  \"publicKeys\": [\n    { \"id\": \"1\", \"alg\": \"RS256\", \"publicKey\": \"0x...\" }\n  ]\n}\n```\n\n#### Example\n\n```ts\nimport { generate } from '@uniswap/tamperproof-transactions';\n\nconst json = generate({ key: '0x...', algorithm: 'RS256' });\n```\n\n---\n\n### Utilities\n\nThe following helpers are also exported:\n\n- `canonicalStringify(value: unknown): string`\n- `serializeRequestPayload<T>(value: T): Uint8Array`\n\nThese are used internally to canonicalize objects before signing/verifying.\n\n---\n\n## License\n\nMIT\n","readmeFilename":"README.md","_rev":"1-8a0655ec1d8b9138b47cfde4979f5f60"}