{"_id":"@0xkey-io/wallet-stamper","_rev":"4-43dad865fe5af59c4de4c350feb800f1","name":"@0xkey-io/wallet-stamper","dist-tags":{"latest":"0.1.3"},"versions":{"0.1.0":{"name":"@0xkey-io/wallet-stamper","version":"0.1.0","keywords":["0xkey","http","stamper","wallet authentication"],"author":{"url":"https://0xkey.com/","name":"0xkey"},"license":"Apache-2.0","_id":"@0xkey-io/wallet-stamper@0.1.0","maintainers":[{"name":"0xkey-developer","email":"developer@0xkey.io"}],"homepage":"https://github.com/0xkey-io/sdk-js/tree/main/packages/wallet-stamper","bugs":{"url":"https://github.com/0xkey-io/sdk-js/issues"},"dist":{"shasum":"486260ba27a881b2ed93c6b6847d325a08e335b4","tarball":"https://registry.npmjs.org/@0xkey-io/wallet-stamper/-/wallet-stamper-0.1.0.tgz","fileCount":46,"integrity":"sha512-Ttgni9FEC0eNPsNixqvJTnJdpFGbW4Lufc0Vl6L6mfhoDJo/j+5Vr19r+jL5peF9YMrQSliJisLRKZJc9r+yvQ==","signatures":[{"sig":"MEUCIFwAYwTlHzOvsAgZl6YzLLmdfaNnYiiWqklq0Zj7grBvAiEArKXlPuZGth8BQZqWy/bbUfrUTTaNIwan6wcWqGIc5aU=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":56937},"main":"./dist/index.js","_from":"file:0xkey-io-wallet-stamper-0.1.0.tgz","types":"./dist/index.d.ts","module":"./dist/index.mjs","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","default":"./dist/index.mjs","require":"./dist/index.js"}},"scripts":{"test":"jest","build":"rollup -c","clean":"rimraf ./dist ./.cache","typecheck":"tsc -p tsconfig.typecheck.json"},"_npmUser":{"name":"0xkey-developer","email":"developer@0xkey.io"},"_resolved":"/private/var/folders/lf/b69416ms3zvccf0ght6bq02r0000gn/T/3a3e8d4bb82300a7c5e4924831c48a61/0xkey-io-wallet-stamper-0.1.0.tgz","_integrity":"sha512-Ttgni9FEC0eNPsNixqvJTnJdpFGbW4Lufc0Vl6L6mfhoDJo/j+5Vr19r+jL5peF9YMrQSliJisLRKZJc9r+yvQ==","repository":{"url":"git+https://github.com/0xkey-io/sdk-js.git","type":"git","directory":"packages/wallet-stamper"},"_npmVersion":"11.4.2","description":"Wallet stamper for @0xkey-io/http","directories":{},"_nodeVersion":"24.3.0","dependencies":{"@0xkey-io/crypto":"0.1.0","@0xkey-io/encoding":"0.1.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"dotenv":"^16.0.3","tweetnacl":"^1.0.3","typescript":"5.4.3","@0xkey-io/http":"0.1.0","tweetnacl-util":"^0.15.1","@solana/web3.js":"^1.95.8","@0xkey-io/api-key-stamper":"0.1.0"},"optionalDependencies":{"viem":"^2.21.35"},"_npmOperationalInternal":{"tmp":"tmp/wallet-stamper_0.1.0_1779443543034_0.3883479518753705","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@0xkey-io/wallet-stamper","version":"0.1.1","keywords":["0xkey","http","stamper","wallet authentication"],"author":{"url":"https://0xkey.com/","name":"0xkey"},"license":"Apache-2.0","_id":"@0xkey-io/wallet-stamper@0.1.1","maintainers":[{"name":"0xkey-developer","email":"developer@0xkey.io"}],"homepage":"https://github.com/0xkey-io/sdk-js/tree/main/packages/wallet-stamper","bugs":{"url":"https://github.com/0xkey-io/sdk-js/issues"},"dist":{"shasum":"1ea2df4291c842d08ae6c4a63f2c636a9bea87fa","tarball":"https://registry.npmjs.org/@0xkey-io/wallet-stamper/-/wallet-stamper-0.1.1.tgz","fileCount":46,"integrity":"sha512-9ScxMlrDLNHUitejkc5Q5kYuADbfMAdsRSMEU2nxYc8HbyDlbYBOFQU5y3Js74H4kZ3pijK33VLDrI5TKprGyw==","signatures":[{"sig":"MEQCIHPLXFvt0+YmgDikaHrtD4t0O5atjGyz8vtoniy+x9IuAiAHaBrmlO7cpjop4D5/FZ6SXMM4rNXts5Atg0E1a7hl7w==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":57050},"main":"./dist/index.js","_from":"file:0xkey-io-wallet-stamper-0.1.1.tgz","types":"./dist/index.d.ts","module":"./dist/index.mjs","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","default":"./dist/index.mjs","require":"./dist/index.js"}},"scripts":{"test":"jest","build":"rollup -c","clean":"rimraf ./dist ./.cache","typecheck":"tsc -p tsconfig.typecheck.json"},"_npmUser":{"name":"0xkey-developer","email":"developer@0xkey.io"},"_resolved":"/private/var/folders/lf/b69416ms3zvccf0ght6bq02r0000gn/T/ba555f63693bcad8a7f150812e06c631/0xkey-io-wallet-stamper-0.1.1.tgz","_integrity":"sha512-9ScxMlrDLNHUitejkc5Q5kYuADbfMAdsRSMEU2nxYc8HbyDlbYBOFQU5y3Js74H4kZ3pijK33VLDrI5TKprGyw==","repository":{"url":"git+https://github.com/0xkey-io/sdk-js.git","type":"git","directory":"packages/wallet-stamper"},"_npmVersion":"11.4.2","description":"Wallet stamper for @0xkey-io/http","directories":{},"_nodeVersion":"24.3.0","dependencies":{"@0xkey-io/crypto":"0.1.1","@0xkey-io/encoding":"0.1.1"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"dotenv":"^16.0.3","tweetnacl":"^1.0.3","typescript":"5.4.3","@0xkey-io/http":"0.1.1","tweetnacl-util":"^0.15.1","@solana/web3.js":"^1.95.8","@0xkey-io/api-key-stamper":"0.1.1"},"optionalDependencies":{"viem":"^2.21.35"},"_npmOperationalInternal":{"tmp":"tmp/wallet-stamper_0.1.1_1779452004436_0.45673964319491556","host":"s3://npm-registry-packages-npm-production"}},"0.1.2":{"name":"@0xkey-io/wallet-stamper","version":"0.1.2","keywords":["0xkey","http","stamper","wallet authentication"],"author":{"url":"https://0xkey.com/","name":"0xkey"},"license":"Apache-2.0","_id":"@0xkey-io/wallet-stamper@0.1.2","maintainers":[{"name":"0xkey-developer","email":"developer@0xkey.io"}],"homepage":"https://github.com/0xkey-io/sdk-js/tree/main/packages/wallet-stamper","bugs":{"url":"https://github.com/0xkey-io/sdk-js/issues"},"dist":{"shasum":"b1d498a5498ede02647a15888ae4bf2c1fd64c51","tarball":"https://registry.npmjs.org/@0xkey-io/wallet-stamper/-/wallet-stamper-0.1.2.tgz","fileCount":46,"integrity":"sha512-S55mYmrYfVNQZweg4rCX5kmCtZl6y7M+DBxFh3rBqz9lfQJ56+FhITCMafLvqmLSP1VBGkREhP8wD/XRemYDwg==","signatures":[{"sig":"MEUCIQCko5gxgmJrdT1wOsz9yVLu0xQnwAhPdseI1bvlsUp9AwIgZJK2Btjlaw3nrS3/n7Yo4VWLtZbuXi25q1cu4Ipdv18=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":57134},"main":"./dist/index.js","_from":"file:0xkey-io-wallet-stamper-0.1.2.tgz","types":"./dist/index.d.ts","module":"./dist/index.mjs","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","default":"./dist/index.mjs","require":"./dist/index.js"}},"scripts":{"test":"jest","build":"rollup -c","clean":"rimraf ./dist ./.cache","typecheck":"tsc -p tsconfig.typecheck.json"},"_npmUser":{"name":"0xkey-developer","email":"developer@0xkey.io"},"_resolved":"/tmp/c6f1a13457fe306f9facb4cd57bec9d6/0xkey-io-wallet-stamper-0.1.2.tgz","_integrity":"sha512-S55mYmrYfVNQZweg4rCX5kmCtZl6y7M+DBxFh3rBqz9lfQJ56+FhITCMafLvqmLSP1VBGkREhP8wD/XRemYDwg==","repository":{"url":"git+https://github.com/0xkey-io/sdk-js.git","type":"git","directory":"packages/wallet-stamper"},"_npmVersion":"11.5.1","description":"Wallet stamper for @0xkey-io/http","directories":{},"_nodeVersion":"20.17.0","dependencies":{"@0xkey-io/crypto":"0.2.0","@0xkey-io/encoding":"0.1.1"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"dotenv":"^16.0.3","tweetnacl":"^1.0.3","typescript":"5.4.3","@0xkey-io/http":"0.1.2","tweetnacl-util":"^0.15.1","@solana/web3.js":"^1.95.8","@0xkey-io/api-key-stamper":"0.1.2"},"optionalDependencies":{"viem":"^2.21.35"},"_npmOperationalInternal":{"tmp":"tmp/wallet-stamper_0.1.2_1782244127538_0.7682087413651024","host":"s3://npm-registry-packages-npm-production"}},"0.1.3":{"name":"@0xkey-io/wallet-stamper","version":"0.1.3","main":"./dist/index.js","module":"./dist/index.mjs","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js","default":"./dist/index.mjs"}},"types":"./dist/index.d.ts","license":"Apache-2.0","description":"Wallet stamper for @0xkey-io/http","keywords":["0xkey","http","stamper","wallet authentication"],"author":{"name":"0xkey","url":"https://0xkey.com/"},"homepage":"https://github.com/0xkey-io/sdk-js/tree/main/packages/wallet-stamper","bugs":{"url":"https://github.com/0xkey-io/sdk-js/issues"},"repository":{"type":"git","url":"git+https://github.com/0xkey-io/sdk-js.git","directory":"packages/wallet-stamper"},"publishConfig":{"access":"public"},"dependencies":{"@0xkey-io/crypto":"0.3.0","@0xkey-io/encoding":"0.1.1"},"optionalDependencies":{"viem":"^2.21.35"},"devDependencies":{"@solana/web3.js":"^1.95.8","dotenv":"^16.0.3","tweetnacl":"^1.0.3","tweetnacl-util":"^0.15.1","typescript":"5.4.3","@0xkey-io/api-key-stamper":"0.1.3","@0xkey-io/http":"0.1.3"},"scripts":{"build":"rollup -c","clean":"rimraf ./dist ./.cache","test":"jest","typecheck":"tsc -p tsconfig.typecheck.json"},"_id":"@0xkey-io/wallet-stamper@0.1.3","_integrity":"sha512-jFCCFMqvnyXTSl9UomPIpUtR6L2PpwKEOKBg7DuIr1qriUOrq0PNvmO8v7RLFcYoj8C53QG/EoUcp8Pvss7tlQ==","_resolved":"/tmp/e59ac0d6732f5ec7fc41b22f66d7b5bb/0xkey-io-wallet-stamper-0.1.3.tgz","_from":"file:0xkey-io-wallet-stamper-0.1.3.tgz","_nodeVersion":"20.17.0","_npmVersion":"11.5.1","dist":{"integrity":"sha512-jFCCFMqvnyXTSl9UomPIpUtR6L2PpwKEOKBg7DuIr1qriUOrq0PNvmO8v7RLFcYoj8C53QG/EoUcp8Pvss7tlQ==","shasum":"9344997404baa34be29cb811a16132dc0817977d","tarball":"https://registry.npmjs.org/@0xkey-io/wallet-stamper/-/wallet-stamper-0.1.3.tgz","fileCount":46,"unpackedSize":57604,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIChDrmrMPpzNDyBeeX/rHD08NTyf19CoqhngQB+jsy8zAiBYruk4tjwAlZvJj5eRsi9zycbgcXd4I6Fkot2sDwvLaA=="}]},"_npmUser":{"name":"0xkey-developer","email":"developer@0xkey.io"},"directories":{},"maintainers":[{"name":"0xkey-developer","email":"developer@0xkey.io"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/wallet-stamper_0.1.3_1783079764713_0.3149307203573175"},"_hasShrinkwrap":false}},"time":{"created":"2026-05-22T09:52:22.868Z","modified":"2026-07-03T11:56:05.122Z","0.1.0":"2026-05-22T09:52:23.173Z","0.1.1":"2026-05-22T12:13:24.624Z","0.1.2":"2026-06-23T19:48:47.691Z","0.1.3":"2026-07-03T11:56:04.872Z"},"bugs":{"url":"https://github.com/0xkey-io/sdk-js/issues"},"author":{"name":"0xkey","url":"https://0xkey.com/"},"license":"Apache-2.0","homepage":"https://github.com/0xkey-io/sdk-js/tree/main/packages/wallet-stamper","keywords":["0xkey","http","stamper","wallet authentication"],"repository":{"type":"git","url":"git+https://github.com/0xkey-io/sdk-js.git","directory":"packages/wallet-stamper"},"description":"Wallet stamper for @0xkey-io/http","maintainers":[{"name":"0xkey-developer","email":"developer@0xkey.io"}],"readme":"# ZeroXKey Wallet Stamper\n\nThe `@0xkey-io/wallet-stamper` package provides a mechanism to stamp requests using a wallet public key and signature. This package supports both Solana and Ethereum wallets, allowing for seamless integration with various blockchain applications.\n\n## Installation\n\nBefore you start using the ZeroXKey Wallet Stamper, make sure to install the necessary packages in your project. This guide assumes you have a Node.js environment ready for development.\n\nInstall the required packages using NPM, Yarn, or PNPM:\n\n```bash\nnpm install @0xkey-io/wallet-stamper @0xkey-io/http\n```\n\n## Usage\n\n### Prerequisites\n\n#### Add Wallet Public Key as Authenticator\n\nTo use the wallet stamper, you must add the user's wallet public key as an API key authenticator.\nThis can be achieved either by creating a sub-organization activity or by generating a new API key and passing in the wallet's public key.\n\nThe API key stamper is necessary because we need to use the parent organization's API key to add the authenticator initially.\nOnce this is done, the wallet can stamp activity requests independently without needing the parent organization's API private and public keys.\n\nBelow are the steps to add a Solana public key as a wallet authenticator:\n\n```typescript\nconst apiKeyStamper = new ApiKeyStamper({\n  apiPublicKey: process.env.API_PUBLIC_KEY ?? \"\",\n  apiPrivateKey: process.env.API_PRIVATE_KEY ?? \"\",\n});\n\nconst client = new ZeroXKeyClient({ baseUrl: BASE_URL }, apiKeyStamper);\n\nconst activityPoller = createActivityPoller({\n  client,\n  requestFn: client.createApiKeys,\n});\n\n// See \"Example: Signing with a Solana Wallet\" below for how to implement the SolanaWallet interface\nconst mockWallet = new MockSolanaWallet();\n\n// This is the public key of the wallet that will be added as an API key and used to stamp future requests\nconst publicKey = mockWallet.recoverPublicKey();\n\n// The userId of the user that we will add the wallet public key as an authenticator\nconst userId = \"f4a5e6b4-3b9c-4f69-b7f6-9c2f456a4d23\";\n\n// We set the curve type to 'API_KEY_CURVE_ED25519' for solana wallets\n// If using an Ethereum wallet, set the curve type to 'API_KEY_CURVE_SECP256K1'\nconst curveType = \"API_KEY_CURVE_ED25519\";\n\nconst result = activityPoller({\n  type: \"ACTIVITY_TYPE_CREATE_API_KEYS_V2\",\n  timestampMs: new Date().getTime().toString(),\n  organizationId: \"acd0bc97-2af5-475b-bc34-0fa7ca3bdc75\",\n  parameters: {\n    apiKeys: [\n      {\n        apiKeyName: \"solana-wallet\",\n        publicKey,\n        curveType,\n      },\n    ],\n    userId,\n  },\n});\n```\n\n#### Using the Wallet Stamper\n\nTo use the `@0xkey-io/wallet-stamper` package, follow these steps:\n\n1. **Choose Your Wallet Type**: Decide whether you will use an EVM-based wallet (e.g., Ethereum) or a Solana-based wallet.\n\n2. **Implement the Wallet Interface**: Depending on your chosen blockchain, implement the wallet interface. This involves creating methods to sign messages and recover public keys.\n\n> Note: We've provided a default implementation for Ethereum wallets via the `EthereumWallet` class. For custom implementations, you may implement the `WalletInterface` yourself.\n\n3. **Instantiate the WalletStamper**: Create an instance of the `WalletStamper` using the wallet interface.\n\n4. **Instantiate the ZeroXKeyClient**: Create an instance of the `ZeroXKeyClient` with the `WalletStamper` instance.\n\n5. **Stamp Requests**: Now when making request using the `ZeroXKeyClient`, the wallet stamper will automatically stamp the request with the user's wallet public key and signature.\n\n### Example: Signing with a Solana Wallet\n\nIn this example, we are using a local Solana wallet.\nFor information on using an injected Solana wallet such as Solflare, please refer to the [`with-wallet-stamper`](../../examples/with-wallet-stamper) example.\n\n```typescript\nimport { Keypair } from \"@solana/web3.js\";\nimport { decodeUTF8 } from \"tweetnacl-util\";\nimport nacl from \"tweetnacl\";\nimport { ZeroXKeyClient } from \"@0xkey-io/http\";\nimport { WalletStamper, SolanaWalletInterface } from \"@0xkey-io/wallet-stamper\";\n\nclass SolanaWallet implements SolanaWalletInterface {\n  keypair = Keypair.fromSecretKey(SOLANA_PRIVATE_KEY);\n  type = \"solana\" as const;\n\n  async signMessage(message: string): Promise<string> {\n    const messageBytes = decodeUTF8(message);\n    const signature = nacl.sign.detached(messageBytes, this.keypair.secretKey);\n    return Buffer.from(signature).toString(\"hex\");\n  }\n\n  async getPublicKey(): Promise<string> {\n    // Convert the base24 encoded Solana wallet public key (the one displayed in the wallet)\n    // into the ed25519 decoded public key\n    const ed25519PublicKey = Buffer.from(\n      this.keypair.publicKey.toBuffer(),\n    ).toString(\"hex\");\n    return ed25519PublicKey;\n  }\n}\n\n// Instantiate the WalletStamper with the SolanaWallet\nconst walletStamper = new WalletStamper(new SolanaWallet());\n\n// Instantiate the ZeroXKeyClient with the WalletStamper\nconst client = new ZeroXKeyClient({ baseUrl: BASE_URL }, walletStamper);\n\n// Call getWhoami to get the sub org's organizationId and userId passing in the parent org id\n// whoami { organizationId: string; organizationName: string; userId: string; username: string; }\nconst whoami = await client.getWhoami({\n  organizationId: process.env.NEXT_PUBLIC_ORGANIZATION_ID,\n});\n\n// Now that we have the sub organization id, we can make requests using that sub org id\n\n// Get the wallets for this sub organization\nconst wallets = await client.getWallets({\n  organizationId: whoami.organizationId,\n});\n```\n\n### Example: Signing with an Ethereum Wallet\n\nThe main distinction between signing with an Ethereum Wallet and a Solana Wallet lies in how the public key is obtained.\nFor Solana, the public key can be directly derived from the wallet.\nIn contrast, with Ethereum, the secp256k1 public key isn't directly accessible.\nInstead, you need to first obtain a signature from the user and then recover the public key from that signature.\n\n```typescript\nimport {\n  createWalletClient,\n  custom,\n  recoverPublicKey,\n  hashMessage,\n} from \"viem\";\nimport { privateKeyToAccount } from \"viem/accounts\";\nimport { mainnet } from \"viem/chains\";\n\nimport { WalletStamper, EthereumWallet } from \"@0xkey-io/wallet-stamper\";\n\n// Instantiate the WalletStamper with the EthereumWallet\nconst walletStamper = new WalletStamper(new EthereumWallet());\n\n// Instantiate the ZeroXKeyClient with the WalletStamper\nconst client = new ZeroXKeyClient({ baseUrl: BASE_URL }, walletStamper);\n\n// Call getWhoami to get the sub-org's organizationId and userId passing in the parent org id\n// whoami { organizationId: string; organizationName: string; userId: string; username: string; }\nconst whoami = await client.getWhoami({\n  organizationId: process.env.ORGANIZATION_ID,\n});\n\nlet subOrganizationId = whoami?.organizationId;\n\n// User does not yet have a sub-organization, so we need to create one\nif (!subOrganizationId) {\n  // We'll need to use the parent org's API keys to create the sub-org on behalf of the user\n  const { ApiKeyStamper } = await import(\"@0xkey-io/api-key-stamper\");\n\n  // Instantiate the ZeroXKeyClient with the ApiKeyStamper\n  const parentOrgClient = new ZeroXKeyClient(\n    { baseUrl: BASE_URL },\n    new ApiKeyStamper({\n      // In practice we'll want to ensure these keys do not get exposed to the client\n      apiPublicKey: process.env.API_PUBLIC_KEY ?? \"\",\n      apiPrivateKey: process.env.API_PRIVATE_KEY ?? \"\",\n    }),\n  );\n\n  const apiKeys = [\n    {\n      apiKeyName: \"Wallet Auth - Embedded Wallet\",\n      // The public key of the wallet that will be added as an API key and used to stamp future requests\n      publicKey,\n      // We set the curve type to 'API_KEY_CURVE_ED25519' for solana wallets\n      // If using an Ethereum wallet, set the curve type to 'API_KEY_CURVE_SECP256K1'\n      curveType,\n    },\n  ];\n\n  const subOrg = await parentOrgClient.createSubOrganization({\n    organizationId: process.env.ORGANIZATION_ID,\n    subOrganizationName: `Sub Org - ${publicKey}`,\n    rootUsers: [\n      {\n        // Replace with user provided values\n        userName: \"New User\",\n        userEmail: \"wallet@domain.com\",\n        apiKeys,\n      },\n    ],\n    rootQuorumThreshold: 1,\n    wallet: {\n      walletName: \"Default Wallet\",\n      accounts: DEFAULT_ETHEREUM_ACCOUNTS,\n    },\n  });\n\n  subOrganizationId = subOrg.subOrganizationId;\n}\n\n// Get the wallets for this sub-organization\nconst wallets = await client.getWallets({\n  organizationId: subOrganizationId,\n});\n```\n\n## Contributing\n\nContributions are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request.\n\n## License\n\nThe `@0xkey-io/wallet-stamper` package is licensed under the [MIT License](LICENSE).\n","readmeFilename":"README.md"}