{"_id":"@bluesky-social/xrpc","_rev":"2-05c7711f9502c5447952306347ad7e23","name":"@bluesky-social/xrpc","dist-tags":{"latest":"0.7.5"},"versions":{"0.7.1":{"name":"@bluesky-social/xrpc","version":"0.7.1","keywords":["atproto","xrpc"],"license":"MIT","_id":"@bluesky-social/xrpc@0.7.1","maintainers":[{"name":"openweb3.io","email":"mtsocialdao@gmail.com"},{"name":"web3km","email":"web3km@proton.me"}],"homepage":"https://atproto.com","bugs":{"url":"https://github.com/bluesky-social/atproto/issues"},"dist":{"shasum":"c96a23ac395f2d6cee075ec2bce827141c7ce4d4","tarball":"https://registry.npmjs.org/@bluesky-social/xrpc/-/xrpc-0.7.1.tgz","fileCount":37,"integrity":"sha512-WZThcxgCfEKpNLpDQttYeQT7W4qb0tq9PjH2fglx/lY3waoGsQDnmASb4gbq6thcR4d4lbVNQJ6OGKwxVrIRcA==","signatures":[{"sig":"MEYCIQCK4Glp3bVvoAvgwgAObJYzoaAbGUxWfSJXb1Io2FvAfQIhAMuZO2UELkRJxsaVP2QGXkk0V3ItGPHKa8X9pLxrU+rK","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":116011},"main":"dist/index.js","_from":"file:bluesky-social-xrpc-0.7.1.tgz","types":"dist/index.d.ts","scripts":{"build":"tsc --build tsconfig.build.json"},"_npmUser":{"name":"web3km","email":"web3km@proton.me"},"_resolved":"/private/var/folders/cb/7sst87dj7jd40nc7b7q7h76r0000gn/T/b4f2020afbdf081c1a8d7ec2c03b9c71/bluesky-social-xrpc-0.7.1.tgz","_integrity":"sha512-WZThcxgCfEKpNLpDQttYeQT7W4qb0tq9PjH2fglx/lY3waoGsQDnmASb4gbq6thcR4d4lbVNQJ6OGKwxVrIRcA==","repository":{"url":"git+https://github.com/bluesky-social/atproto.git","type":"git","directory":"packages/xrpc"},"_npmVersion":"10.7.0","description":"atproto HTTP API (XRPC) client library","directories":{},"_nodeVersion":"20.15.0","dependencies":{"zod":"^3.23.8","@bluesky-social/lexicon":"^0.4.12"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.6.3"},"_npmOperationalInternal":{"tmp":"tmp/xrpc_0.7.1_1753693255961_0.8532531827702161","host":"s3://npm-registry-packages-npm-production"}},"0.7.5":{"name":"@bluesky-social/xrpc","version":"0.7.5","license":"MIT","description":"atproto HTTP API (XRPC) client library","keywords":["atproto","xrpc"],"homepage":"https://atproto.com","repository":{"type":"git","url":"git+https://github.com/bluesky-social/atproto.git","directory":"packages/xrpc"},"main":"dist/index.js","types":"dist/index.d.ts","dependencies":{"zod":"^3.25.76","@bluesky-social/lexicon":"^0.5.1"},"devDependencies":{"typescript":"^5.9.3"},"scripts":{"build":"tsc --build tsconfig.build.json"},"_id":"@bluesky-social/xrpc@0.7.5","bugs":{"url":"https://github.com/bluesky-social/atproto/issues"},"_integrity":"sha512-9ItUp5F1tsWWOqD3IXRVFLK+1Fa+uNnz3w4rkUTwX1mQZWAnx6tezlFmQrR+lYdiAaAlYr7jEhEPmIHU1PSclQ==","_resolved":"/private/var/folders/cb/7sst87dj7jd40nc7b7q7h76r0000gn/T/0717e2c8e71dbaa115f031e07b042f93/bluesky-social-xrpc-0.7.5.tgz","_from":"file:bluesky-social-xrpc-0.7.5.tgz","_nodeVersion":"20.15.0","_npmVersion":"10.7.0","dist":{"integrity":"sha512-9ItUp5F1tsWWOqD3IXRVFLK+1Fa+uNnz3w4rkUTwX1mQZWAnx6tezlFmQrR+lYdiAaAlYr7jEhEPmIHU1PSclQ==","shasum":"7e08a03d9e67301372177f8e19929ac9a813497b","tarball":"https://registry.npmjs.org/@bluesky-social/xrpc/-/xrpc-0.7.5.tgz","fileCount":37,"unpackedSize":143729,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCX3ZnZTggTuxnvzRhkZ6S+Lz1z/0W4hzAOa354sotxQAIhAJrrnRM9xZcuTeqUWxtaWrpWwibyKHooUHb88emNU91W"}]},"_npmUser":{"name":"web3km","email":"web3km@proton.me"},"directories":{},"maintainers":[{"name":"openweb3.io","email":"mtsocialdao@gmail.com"},{"name":"web3km","email":"web3km@proton.me"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/xrpc_0.7.5_1761039233639_0.042552926995817586"},"_hasShrinkwrap":false}},"time":{"created":"2025-07-28T09:00:55.868Z","modified":"2025-10-21T09:33:54.018Z","0.7.1":"2025-07-28T09:00:56.129Z","0.7.5":"2025-10-21T09:33:53.835Z"},"bugs":{"url":"https://github.com/bluesky-social/atproto/issues"},"license":"MIT","homepage":"https://atproto.com","keywords":["atproto","xrpc"],"repository":{"type":"git","url":"git+https://github.com/bluesky-social/atproto.git","directory":"packages/xrpc"},"description":"atproto HTTP API (XRPC) client library","maintainers":[{"name":"openweb3.io","email":"mtsocialdao@gmail.com"},{"name":"web3km","email":"web3km@proton.me"}],"readme":"# @bluesky-social/xrpc: atproto HTTP API Client\n\nTypeScript client library for talking to [atproto](https://atproto.com) services, with Lexicon schema validation.\n\n[![NPM](https://img.shields.io/npm/v/@bluesky-social/xrpc)](https://www.npmjs.com/package/@bluesky-social/xrpc)\n[![Github CI Status](https://github.com/bluesky-social/atproto/actions/workflows/repo.yaml/badge.svg)](https://github.com/bluesky-social/atproto/actions/workflows/repo.yaml)\n\n## Usage\n\n```typescript\nimport { LexiconDoc } from '@bluesky-social/lexicon'\nimport { XrpcClient } from '@bluesky-social/xrpc'\n\nconst pingLexicon = {\n  lexicon: 1,\n  id: 'io.example.ping',\n  defs: {\n    main: {\n      type: 'query',\n      description: 'Ping the server',\n      parameters: {\n        type: 'params',\n        properties: { message: { type: 'string' } },\n      },\n      output: {\n        encoding: 'application/json',\n        schema: {\n          type: 'object',\n          required: ['message'],\n          properties: { message: { type: 'string' } },\n        },\n      },\n    },\n  },\n} satisfies LexiconDoc\n\nconst xrpc = new XrpcClient('https://ping.example.com', [\n  // Any number of lexicon here\n  pingLexicon,\n])\n\nconst res1 = await xrpc.call('io.example.ping', {\n  message: 'hello world',\n})\nres1.encoding // => 'application/json'\nres1.body // => {message: 'hello world'}\n```\n\n### With a custom fetch handler\n\n```typescript\nimport { XrpcClient } from '@bluesky-social/xrpc'\n\nconst session = {\n  serviceUrl: 'https://ping.example.com',\n  token: '<my-token>',\n  async refreshToken() {\n    const { token } = await fetch('https://auth.example.com/refresh', {\n      method: 'POST',\n      headers: { Authorization: `Bearer ${this.token}` },\n    }).then((res) => res.json())\n\n    this.token = token\n\n    return token\n  },\n}\n\nconst sessionBasedFetch: FetchHandler = async (\n  url: string,\n  init: RequestInit,\n) => {\n  const headers = new Headers(init.headers)\n\n  headers.set('Authorization', `Bearer ${session.token}`)\n\n  const response = await fetch(new URL(url, session.serviceUrl), {\n    ...init,\n    headers,\n  })\n\n  if (response.status === 401) {\n    // Refresh token, then try again.\n    const newToken = await session.refreshToken()\n    headers.set('Authorization', `Bearer ${newToken}`)\n    return fetch(new URL(url, session.serviceUrl), { ...init, headers })\n  }\n\n  return response\n}\n\nconst xrpc = new XrpcClient(sessionBasedFetch, [\n  // Any number of lexicon here\n  pingLexicon,\n])\n\n//\n```\n\n## License\n\nThis project is dual-licensed under MIT and Apache 2.0 terms:\n\n- MIT license ([LICENSE-MIT.txt](https://github.com/bluesky-social/atproto/blob/main/LICENSE-MIT.txt) or http://opensource.org/licenses/MIT)\n- Apache License, Version 2.0, ([LICENSE-APACHE.txt](https://github.com/bluesky-social/atproto/blob/main/LICENSE-APACHE.txt) or http://www.apache.org/licenses/LICENSE-2.0)\n\nDownstream projects and end users may chose either license individually, or both together, at their discretion. The motivation for this dual-licensing is the additional software patent assurance provided by Apache 2.0.\n","readmeFilename":"README.md"}