{"_id":"@atap-dev/sdk","name":"@atap-dev/sdk","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"@atap-dev/sdk","version":"0.1.0","description":"JavaScript/TypeScript client for the ATAP (Agent Trust and Authority Protocol) platform","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","test:coverage":"vitest run --coverage","lint":"eslint src/"},"dependencies":{"@noble/ed25519":"^2.2.3","@noble/hashes":"^1.7.1"},"devDependencies":{"@vitest/coverage-v8":"^3.0.0","eslint":"^9.0.0","tsup":"^8.0.0","typescript":"^5.7.0","vitest":"^3.0.0"},"engines":{"node":">=18.0.0"},"license":"Apache-2.0","repository":{"type":"git","url":"git+https://github.com/atap-dev/atap.git","directory":"sdks/javascript"},"keywords":["atap","agent","trust","delegation","did","verifiable-credentials","ed25519","dpop"],"_id":"@atap-dev/sdk@0.1.0","gitHead":"0926b9cfb634c555d381da1a81c9aec36235dbce","bugs":{"url":"https://github.com/atap-dev/atap/issues"},"homepage":"https://github.com/atap-dev/atap#readme","_nodeVersion":"22.22.0","_npmVersion":"10.9.4","dist":{"integrity":"sha512-fopk+an5UsDkegUFu9d1pVvw6U5d/Rj4kUx8NzED91rqAf2HWWkhGXdf8xHikAUbPXk9oC2vWlNp6AqXAfBcjA==","shasum":"9206827a2f7190f6b760094d48b56787ae885359","tarball":"https://registry.npmjs.org/@atap-dev/sdk/-/sdk-0.1.0.tgz","fileCount":8,"unpackedSize":231079,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIC98W24lWZny2wdSXg3bgD6MMwi0dYyH6NGXd8guozEsAiEA0mt6n0S9fvmCsre1jkOywUFSOPAQzQmxTMqiYHkHCp8="}]},"_npmUser":{"name":"8up","email":"sven@8up.io"},"directories":{},"maintainers":[{"name":"8up","email":"sven@8up.io"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/sdk_0.1.0_1773863647970_0.4373635175666235"},"_hasShrinkwrap":false}},"time":{"created":"2026-03-18T19:54:07.836Z","0.1.0":"2026-03-18T19:54:08.110Z","modified":"2026-03-18T19:54:08.636Z"},"maintainers":[{"name":"8up","email":"sven@8up.io"}],"description":"JavaScript/TypeScript client for the ATAP (Agent Trust and Authority Protocol) platform","homepage":"https://github.com/atap-dev/atap#readme","keywords":["atap","agent","trust","delegation","did","verifiable-credentials","ed25519","dpop"],"repository":{"type":"git","url":"git+https://github.com/atap-dev/atap.git","directory":"sdks/javascript"},"bugs":{"url":"https://github.com/atap-dev/atap/issues"},"license":"Apache-2.0","readme":"# ATAP JavaScript/TypeScript SDK\n\nTypeScript client for the [ATAP](https://atap.dev) (Agent Trust and Authority Protocol) platform.\n\n## Installation\n\n```bash\nnpm install @atap/sdk\n```\n\n## Quick Start\n\n```typescript\nimport { ATAPClient } from \"@atap/sdk\";\n\n// Register a new agent\nconst client = new ATAPClient({ baseUrl: \"http://localhost:8080\" });\nconst entity = await client.entities.register(\"agent\", { name: \"my-agent\" });\n\n// Create an authenticated client\nconst authed = new ATAPClient({\n  baseUrl: \"http://localhost:8080\",\n  did: entity.did,\n  privateKey: entity.privateKey!,\n  clientSecret: entity.clientSecret!,\n});\n\n// List approvals\nconst approvals = await authed.approvals.list();\n\n// Check DIDComm inbox\nconst inbox = await authed.didcomm.inbox();\n```\n\n## Authentication\n\nThe SDK handles OAuth 2.1 + DPoP authentication automatically.\n\n**Agent/Machine** (client_credentials grant):\n```typescript\nconst client = new ATAPClient({\n  baseUrl: \"http://localhost:8080\",\n  did: \"did:web:localhost%3A8080:agent:abc\",\n  privateKey: \"<base64 Ed25519 seed>\",\n  clientSecret: \"atap_...\",\n});\n// Tokens are obtained and refreshed automatically\n```\n\n**Human/Org** (authorization_code + PKCE):\n```typescript\nconst client = new ATAPClient({\n  baseUrl: \"http://localhost:8080\",\n  did: \"did:web:localhost%3A8080:human:abc\",\n  privateKey: \"<base64 Ed25519 seed>\",\n});\nawait client.tokenManager.obtainAuthorizationCode();\n```\n\n## API Reference\n\n### Entities\n\n```typescript\n// Register\nconst entity = await client.entities.register(\"agent\", { name: \"my-agent\" });\nconst entity = await client.entities.register(\"human\", { publicKey: \"<base64 pubkey>\" });\n\n// Get\nconst entity = await client.entities.get(\"entity_id\");\n\n// Delete (requires atap:manage)\nawait client.entities.delete(\"entity_id\");\n\n// Rotate key (requires atap:manage)\nconst kv = await client.entities.rotateKey(\"entity_id\", \"<base64 new pubkey>\");\n```\n\n### Approvals\n\n```typescript\nimport type { ApprovalSubject } from \"@atap/sdk\";\n\n// Create (requires atap:send)\nconst approval = await client.approvals.create(\n  \"did:web:...:agent:requester\",\n  \"did:web:...:human:approver\",\n  {\n    type: \"com.example.payment\",\n    label: \"Payment of $100\",\n    payload: { amount: 100 },\n  } satisfies ApprovalSubject,\n);\n\n// Respond (requires atap:send)\nconst result = await client.approvals.respond(\"apr_...\", \"<JWS>\");\n\n// List (requires atap:inbox)\nconst approvals = await client.approvals.list();\n\n// Revoke (requires atap:revoke)\nawait client.approvals.revoke(\"apr_...\");\n```\n\n### Revocations\n\n```typescript\n// Submit (requires atap:revoke)\nconst rev = await client.revocations.submit(\"apr_...\", \"<JWS>\");\n\n// List (public)\nconst result = await client.revocations.list(\"did:web:...:agent:abc\");\n```\n\n### DIDComm\n\n```typescript\n// Send message (public)\nawait client.didcomm.send(jweBytes);\n\n// Check inbox (requires atap:inbox)\nconst inbox = await client.didcomm.inbox({ limit: 50 });\nfor (const msg of inbox.messages) {\n  console.log(`From: ${msg.senderDid}, Type: ${msg.messageType}`);\n}\n```\n\n### Credentials\n\n```typescript\n// Email verification (requires atap:manage)\nawait client.credentials.startEmailVerification(\"user@example.com\");\nconst cred = await client.credentials.verifyEmail(\"user@example.com\", \"123456\");\n\n// Phone verification (requires atap:manage)\nawait client.credentials.startPhoneVerification(\"+1234567890\");\nconst cred = await client.credentials.verifyPhone(\"+1234567890\", \"654321\");\n\n// Personhood (requires atap:manage)\nconst cred = await client.credentials.submitPersonhood();\n\n// List credentials (requires atap:manage)\nconst creds = await client.credentials.list();\n\n// Status list (public)\nconst status = await client.credentials.statusList(\"1\");\n```\n\n### Discovery\n\n```typescript\n// Server discovery\nconst doc = await client.discovery.discover();\n\n// DID resolution\nconst didDoc = await client.discovery.resolveDid(\"agent\", \"entity_id\");\n\n// Server DID\nconst serverDid = await client.discovery.serverDid();\n\n// Health check\nconst health = await client.discovery.health();\n```\n\n## Error Handling\n\n```typescript\nimport {\n  ATAPError,\n  ATAPProblemError,\n  ATAPAuthError,\n  ATAPNotFoundError,\n  ATAPRateLimitError,\n} from \"@atap/sdk\";\n\ntry {\n  const entity = await client.entities.get(\"missing\");\n} catch (e) {\n  if (e instanceof ATAPNotFoundError) {\n    console.log(`Not found: ${e.message}`);\n  } else if (e instanceof ATAPAuthError) {\n    console.log(`Auth error (${e.statusCode}): ${e.message}`);\n  } else if (e instanceof ATAPRateLimitError) {\n    console.log(`Rate limited: ${e.message}`);\n  } else if (e instanceof ATAPProblemError) {\n    console.log(`API error: ${e.problem.title} - ${e.problem.detail}`);\n  } else if (e instanceof ATAPError) {\n    console.log(`Error: ${e.message}`);\n  }\n}\n```\n\n## Configuration\n\n```typescript\nconst client = new ATAPClient({\n  baseUrl: \"http://localhost:8080\",       // HTTP target\n  did: \"did:web:...\",                     // Entity DID\n  privateKey: \"<base64>\",                 // Ed25519 private key\n  clientSecret: \"atap_...\",              // For agent/machine auth\n  scopes: [\"atap:inbox\", \"atap:send\"],   // OAuth scopes\n  platformDomain: \"api.atap.app\",        // Domain for DPoP htu\n  timeout: 30000,                        // Request timeout (ms)\n});\n```\n\n## Crypto Utilities\n\nThe SDK exports low-level cryptographic functions:\n\n```typescript\nimport {\n  generateKeypair,\n  loadSigningKey,\n  makeDPoPProof,\n  jwkThumbprint,\n  generatePKCE,\n  b64urlEncode,\n  b64urlDecode,\n  domainFromDID,\n} from \"@atap/sdk\";\n\n// Generate Ed25519 keypair\nconst { privateKey, publicKey } = await generateKeypair();\n\n// Create DPoP proof\nconst proof = await makeDPoPProof(privateKey, \"POST\", \"https://api.atap.app/v1/oauth/token\");\n\n// Generate PKCE challenge\nconst { verifier, challenge } = generatePKCE();\n```\n\n## Examples\n\nSee the [examples/](examples/) directory:\n- [register-agent.ts](examples/register-agent.ts) -- Register and authenticate\n- [approval-flow.ts](examples/approval-flow.ts) -- Create and respond to approvals\n- [credential-verification.ts](examples/credential-verification.ts) -- Email verification\n\n## Development\n\n```bash\nnpm install\nnpm test\nnpm run test:coverage\nnpm run build\nnpm run lint\n```\n\n## License\n\nApache-2.0\n","readmeFilename":"README.md","_rev":"1-5e658739bd1a5570c195047bc48e62cd"}