{"_id":"@arch-network/wallet-hub-sdk","_rev":"3-dc9a0107ccd35910d81b1f6df0f4fde2","name":"@arch-network/wallet-hub-sdk","dist-tags":{"latest":"0.1.1"},"versions":{"0.1.0":{"name":"@arch-network/wallet-hub-sdk","version":"0.1.0","_id":"@arch-network/wallet-hub-sdk@0.1.0","maintainers":[{"name":"hoffmabc","email":"brian@ob1.io"},{"name":"0xfinetuned","email":"amine@arch.network"}],"homepage":"https://github.com/Arch-Network/arch-wallet-hub/tree/main/packages/wallet-hub-sdk#readme","bugs":{"url":"https://github.com/Arch-Network/arch-wallet-hub/issues"},"dist":{"shasum":"d0c40770c92ccb5c9879cf0a3cd9e227919f5411","tarball":"https://registry.npmjs.org/@arch-network/wallet-hub-sdk/-/wallet-hub-sdk-0.1.0.tgz","fileCount":8,"integrity":"sha512-0Bo2UDHSnsxCXY67pEOyF1eIWhND/h+5CebTaNav4zJBWr9R2t0c15fOGFqDSQKJNM5B2mwFVtlJUshSZ4gAzw==","signatures":[{"sig":"MEYCIQCWZOze9H+qNRjNA3tyYjkKIaefdYPuWmPG/yIbiNby4QIhAJloVNebp3zO3dpzWvNRb7S/XTj0BJ6AWgx4nzOFFN2a","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":30307},"main":"dist/index.js","type":"module","types":"dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"gitHead":"1b718a88c5a40ca1291e5ee10ece580f668ea61a","scripts":{"build":"tsc -p tsconfig.json","prepare":"npm run build","typecheck":"tsc -p tsconfig.json --noEmit","prepublishOnly":"npm run typecheck && npm run build"},"_npmUser":{"name":"hoffmabc","email":"brian@ob1.io"},"repository":{"url":"git+https://github.com/Arch-Network/arch-wallet-hub.git","type":"git","directory":"packages/wallet-hub-sdk"},"_npmVersion":"10.9.2","description":"TypeScript client for the Arch Wallet Hub API","directories":{},"sideEffects":false,"_nodeVersion":"23.11.0","dependencies":{},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.7.3"},"_npmOperationalInternal":{"tmp":"tmp/wallet-hub-sdk_0.1.0_1779210058809_0.9998686780232131","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@arch-network/wallet-hub-sdk","version":"0.1.1","_id":"@arch-network/wallet-hub-sdk@0.1.1","maintainers":[{"name":"hoffmabc","email":"brian@ob1.io"},{"name":"0xfinetuned","email":"amine@arch.network"}],"homepage":"https://github.com/Arch-Network/arch-wallet-hub/tree/main/packages/wallet-hub-sdk#readme","bugs":{"url":"https://github.com/Arch-Network/arch-wallet-hub/issues"},"dist":{"shasum":"8fc26513bab6ddbc96494f445bf2ed29aa3f0fd2","tarball":"https://registry.npmjs.org/@arch-network/wallet-hub-sdk/-/wallet-hub-sdk-0.1.1.tgz","fileCount":8,"integrity":"sha512-VMkNA1Gusj/oQl1qjIPp4v7f8hGrnYer+CF4536CnPf/vZCUgDuXjWJ6DBC9eQx4L1hxd/0gKMLNzPIAiThBRw==","signatures":[{"sig":"MEYCIQCjfJzITlZnna4e4HVc5VgnrCJEz9peA86ScrBHQs/eGwIhAM7v1Ha5eX9QysArryHlw5rHhQVDaPbJ7IT/QLleOo//","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@arch-network%2fwallet-hub-sdk@0.1.1","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":55330},"main":"dist/index.js","type":"module","types":"dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"gitHead":"a4262140ff90afa0c5f3713d7fec5b81ee2a9fb8","scripts":{"test":"vitest run","build":"tsc -p tsconfig.json","prepare":"npm run build","typecheck":"tsc -p tsconfig.json --noEmit","prepublishOnly":"npm run typecheck && npm run build"},"_npmUser":{"name":"hoffmabc","email":"brian@ob1.io"},"repository":{"url":"git+https://github.com/Arch-Network/arch-wallet-hub.git","type":"git","directory":"packages/wallet-hub-sdk"},"_npmVersion":"10.8.2","description":"TypeScript client for the Arch Wallet Hub API","directories":{},"sideEffects":false,"_nodeVersion":"20.20.2","dependencies":{},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"vitest":"^3.2.4","typescript":"^5.7.3","@types/node":"^20.0.0"},"_npmOperationalInternal":{"tmp":"tmp/wallet-hub-sdk_0.1.1_1782058635524_0.8015964671559677","host":"s3://npm-registry-packages-npm-production"}}},"time":{"created":"2026-05-19T17:00:58.688Z","modified":"2026-07-28T17:32:56.890Z","0.1.0":"2026-05-19T17:00:58.965Z","0.1.1":"2026-06-21T16:17:15.664Z"},"bugs":{"url":"https://github.com/Arch-Network/arch-wallet-hub/issues"},"homepage":"https://github.com/Arch-Network/arch-wallet-hub/tree/main/packages/wallet-hub-sdk#readme","repository":{"url":"git+https://github.com/Arch-Network/arch-wallet-hub.git","type":"git","directory":"packages/wallet-hub-sdk"},"description":"TypeScript client for the Arch Wallet Hub API","maintainers":[{"email":"brian@ob1.io","name":"hoffmabc"},{"email":"amine@arch.network","name":"0xfinetuned"},{"email":"james@lionsmouth.digital","name":"jsblair9"}],"readme":"# Arch Wallet Hub SDK\n\nTypeScript client for the Arch Wallet Hub API. It wraps the Hub's HTTP surface with typed request and response objects for wallet linking, Turnkey wallet management, signing requests, Bitcoin helper endpoints, and email recovery flows.\n\n## Installation\n\nFrom this monorepo:\n\n```bash\nnpm install\nnpm run build\n```\n\nOnce published:\n\n```bash\nnpm install @arch-network/wallet-hub-sdk\n```\n\n## Quick Start\n\n```ts\nimport { WalletHubClient } from \"@arch-network/wallet-hub-sdk\";\n\nconst walletHub = new WalletHubClient({\n  baseUrl: \"https://your-wallet-hub.example.com/v1\",\n  apiKey: process.env.WALLET_HUB_API_KEY,\n  network: \"testnet\",\n});\n\nconst turnkeyConfig = await walletHub.getTurnkeyConfig();\nconsole.log(turnkeyConfig.organizationId);\n```\n\n`baseUrl` may include or omit `/v1`; the client normalizes it. `network` is sent as `x-network` and defaults to `testnet`. `apiKey` is sent as `x-api-key` when provided.\n\n## Runtime Support\n\nThe SDK uses the global `fetch` implementation by default. For older Node runtimes or custom test harnesses, pass `fetchImpl`:\n\n```ts\nconst walletHub = new WalletHubClient({\n  baseUrl: \"http://localhost:3005/v1\",\n  apiKey: \"dev-api-key\",\n  fetchImpl: customFetch,\n});\n```\n\n## Wallet Linking\n\nUse wallet linking when a dApp needs to prove control of an external wallet address.\n\n```ts\nconst challenge = await walletHub.createWalletLinkChallenge({\n  externalUserId: \"user_123\",\n  walletProvider: \"unisat\",\n  address: \"tb1p...\",\n  network: \"testnet\",\n});\n\n// Ask the user's wallet to sign challenge.message, then verify it.\nconst linked = await walletHub.verifyWalletLinkChallenge({\n  externalUserId: \"user_123\",\n  challengeId: challenge.challengeId,\n  signature: \"base64-or-wallet-specific-signature\",\n  schemeHint: \"bip322\",\n});\n```\n\n## Turnkey Wallets\n\nCreate a passkey-backed Turnkey wallet:\n\n```ts\nconst wallet = await walletHub.createTurnkeyPasskeyWallet({\n  idempotencyKey: crypto.randomUUID(),\n  body: {\n    externalUserId: \"user_123\",\n    walletName: \"Primary wallet\",\n    userEmail: \"user@example.com\",\n    passkey: {\n      challenge: \"base64url-challenge\",\n      attestation: passkeyAttestation,\n    },\n  },\n});\n```\n\nCreate an email-only Turnkey wallet:\n\n```ts\nconst wallet = await walletHub.createTurnkeyEmailWallet({\n  idempotencyKey: crypto.randomUUID(),\n  body: {\n    externalUserId: \"user_123\",\n    userEmail: \"user@example.com\",\n    walletName: \"Email wallet\",\n  },\n});\n```\n\nList or fetch known wallets:\n\n```ts\nconst wallets = await walletHub.listTurnkeyWallets(\"user_123\");\n\nconst walletDetails = await walletHub.getTurnkeyWallet({\n  externalUserId: \"user_123\",\n  resourceId: wallet.resourceId,\n});\n```\n\n## Email Recovery\n\nRecovery is a three-step flow:\n\n1. Discover wallet candidates for an email.\n2. Start OTP delivery for the selected candidate.\n3. Verify the OTP and receive an encrypted credential bundle.\n\n```ts\nconst init = await walletHub.initRecoveryEmail({\n  email: \"user@example.com\",\n});\n\nif (init.candidates.length === 0) {\n  // Show neutral copy for anti-enumeration:\n  // \"If a wallet exists for this email, you'll receive recovery instructions.\"\n}\n\nconst candidate = init.candidates[0];\n\nawait walletHub.startRecoveryEmailOtp({\n  email: \"user@example.com\",\n  challengeId: init.challengeId,\n  candidateToken: candidate.candidateToken,\n});\n\nconst verified = await walletHub.verifyRecoveryEmail({\n  challengeId: init.challengeId,\n  candidateToken: candidate.candidateToken,\n  code: \"123456\",\n  ephemeralPublicKey: \"04...\",\n  externalUserId: \"user_123\",\n});\n```\n\n`verified.credentialBundle` is HPKE-encrypted to the provided `ephemeralPublicKey`. The client must decrypt it locally and use the recovered credential according to `verified.authMethod`:\n\n- `passkey`: register a new authenticator on the recovered sub-organization.\n- `email`: bootstrap an IndexedDB signing session.\n\n## Signing Requests\n\nCreate a signing request for an external signer or a Turnkey-backed wallet:\n\n```ts\nconst request = await walletHub.createSigningRequest({\n  externalUserId: \"user_123\",\n  signer: {\n    kind: \"turnkey\",\n    resourceId: \"wallet_resource_id\",\n  },\n  action: {\n    type: \"arch.transfer\",\n    toAddress: \"arch1...\",\n    lamports: \"1000000\",\n  },\n});\n\nconst status = await walletHub.getSigningRequest(request.signingRequestId);\n```\n\nSubmit a client-produced signature:\n\n```ts\nawait walletHub.submitSigningRequest(request.signingRequestId, {\n  externalUserId: \"user_123\",\n  signature64Hex: \"deadbeef...\",\n});\n```\n\nOr ask the Hub to sign with Turnkey for a registered Turnkey wallet:\n\n```ts\nawait walletHub.signWithTurnkey(request.signingRequestId, {\n  externalUserId: \"user_123\",\n});\n```\n\n## Bitcoin Helpers\n\nEstimate a fee:\n\n```ts\nconst fee = await walletHub.estimateBitcoinFee({\n  externalUserId: \"user_123\",\n  turnkeyResourceId: \"wallet_resource_id\",\n  toAddress: \"tb1q...\",\n  amountSats: 10_000,\n});\n```\n\nBuild and broadcast a Bitcoin transaction:\n\n```ts\nconst psbt = await walletHub.buildBitcoinPsbt({\n  externalUserId: \"user_123\",\n  turnkeyResourceId: \"wallet_resource_id\",\n  toAddress: \"tb1q...\",\n  amountSats: 10_000,\n});\n\n// Sign and finalize psbt.unsignedPsbtHex locally, then broadcast:\nconst broadcast = await walletHub.broadcastBitcoinTransaction({\n  signedTxHex: \"0200000000...\",\n});\n```\n\n## Error Handling\n\nNon-2xx responses throw an `Error` with the HTTP status and response body:\n\n```ts\ntry {\n  await walletHub.getTurnkeyConfig();\n} catch (err) {\n  console.error(err);\n}\n```\n\n## Development\n\n```bash\ncd packages/wallet-hub-sdk\nnpm install\nnpm run typecheck\nnpm run build\n```\n\nThe public entrypoint is `src/index.ts`, which re-exports `WalletHubClient` and all SDK types.\n\n## Publishing\n\nThe package is configured for public npm publishing as `@arch-network/wallet-hub-sdk`.\n\nBefore publishing for the first time:\n\n1. Make sure the npm account or automation token has publish access to the `@arch` npm scope.\n2. Decide and add the package license.\n3. Add an `NPM_TOKEN` repository secret for the npm publish workflow.\n\nManual publish from a local authenticated npm session:\n\n```bash\ncd packages/wallet-hub-sdk\nnpm version 0.1.0 --no-git-tag-version\nnpm publish --access public\n```\n","readmeFilename":"README.md"}