{"_id":"@cemiltan/isuwa-oauth-client","_rev":"3-a248cb1d02f300a7e7eeee172e1cf658","name":"@cemiltan/isuwa-oauth-client","dist-tags":{"latest":"2.0.0"},"versions":{"1.0.0":{"name":"@cemiltan/isuwa-oauth-client","version":"1.0.0","keywords":["oauth2","jwt","jwks","sdk","isuwa","client_credentials"],"author":{"name":"Cemil Tan","email":"cemiltan896@gmail.com"},"license":"MIT","_id":"@cemiltan/isuwa-oauth-client@1.0.0","maintainers":[{"name":"cemiltan","email":"cemiltan1999@gmail.com"}],"homepage":"https://github.com/Ctere1/isuwa-oauth-client#readme","bugs":{"url":"https://github.com/Ctere1/isuwa-oauth-client/issues"},"dist":{"shasum":"75f7912931d33ab1cc89c718c9e80ebc1fa11001","tarball":"https://registry.npmjs.org/@cemiltan/isuwa-oauth-client/-/isuwa-oauth-client-1.0.0.tgz","fileCount":5,"integrity":"sha512-/bwsCupjD9vPeHzRWuTTN2ofHsRHNVEHlU3HdKwbYwL1Q0dWbQ0jeaYWsL+DxRpQRhGp7ACq4OMaUfV7hMuiaw==","signatures":[{"sig":"MEQCICNZ9fGEPvdWu6ekgev7mSy67pqDFCP+E52R5QnfXhthAiA24YK/CMA1aXdY7W2vx1fFoZlFug4lXI2/GJFt9v0SdQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":7440},"main":"index.js","type":"module","module":"index.js","gitHead":"b2324289084377ad78deecadb1a4a1ebef968a72","_npmUser":{"name":"cemiltan","email":"cemiltan1999@gmail.com"},"repository":{"url":"git+https://github.com/Ctere1/isuwa-oauth-client.git","type":"git"},"_npmVersion":"10.9.3","description":"JavaScript SDK for ISUWA OAuth2 (client_credentials flow with JWKS verification)","directories":{},"_nodeVersion":"22.20.0","dependencies":{"axios":"^1.12.2","jsonwebtoken":"^9.0.2"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/isuwa-oauth-client_1.0.0_1760125577104_0.1854356778218753","host":"s3://npm-registry-packages-npm-production"}},"1.0.2":{"name":"@cemiltan/isuwa-oauth-client","version":"1.0.2","keywords":["oauth2","jwt","jwks","sdk","isuwa","client_credentials"],"author":{"name":"Cemil Tan","email":"cemiltan896@gmail.com"},"license":"MIT","_id":"@cemiltan/isuwa-oauth-client@1.0.2","maintainers":[{"name":"cemiltan","email":"cemiltan1999@gmail.com"}],"homepage":"https://github.com/Ctere1/isuwa-oauth-client#readme","bugs":{"url":"https://github.com/Ctere1/isuwa-oauth-client/issues"},"dist":{"shasum":"2f8c652fa94ba1eca120ac00d8d3f784b349ecb1","tarball":"https://registry.npmjs.org/@cemiltan/isuwa-oauth-client/-/isuwa-oauth-client-1.0.2.tgz","fileCount":6,"integrity":"sha512-Lz/0aZBMibEnHYKqTSTzN7lgChAHId4zks95GaO2/bb7DsePrtAtDmTzUt51mFrh1/6az45Ru5z2qFP4JRZUUg==","signatures":[{"sig":"MEUCIQD4nqXGJkVNYfe5jxMPuzT7nxTRx5Nyt6MiJIpKccaXbgIgJl7wJhvJ89VnRzmpsNskjDcMtLHyPVqO4wjf8jNPbkk=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":7774},"main":"index.js","type":"module","module":"index.js","gitHead":"2a46c8f7ab3ed88fceeabeff52c1b19bca9046db","_npmUser":{"name":"cemiltan","email":"cemiltan1999@gmail.com"},"repository":{"url":"git+https://github.com/Ctere1/isuwa-oauth-client.git","type":"git"},"_npmVersion":"10.8.2","description":"JavaScript SDK for ISUWA OAuth2 (client_credentials flow with JWKS verification)","directories":{},"_nodeVersion":"20.19.5","dependencies":{"axios":"^1.12.2","jsonwebtoken":"^9.0.2"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/isuwa-oauth-client_1.0.2_1760126173381_0.4048946532710853","host":"s3://npm-registry-packages-npm-production"}},"2.0.0":{"_id":"@cemiltan/isuwa-oauth-client@2.0.0","bugs":{"url":"https://github.com/Ctere1/isuwa-oauth-client/issues"},"dist":{"shasum":"0df45acf5b2f831a751a7fc131832fad78a46dd1","tarball":"https://registry.npmjs.org/@cemiltan/isuwa-oauth-client/-/isuwa-oauth-client-2.0.0.tgz","integrity":"sha512-YsSbv6farhp1WRt4I8dNLBEkCVc1R8VUDp20EJTW7rWBqhmBpBeXRWKbH+G1Ciqg8UzVfUeqZBKKjCckJPdYVA==","fileCount":11,"unpackedSize":168950,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@cemiltan%2fisuwa-oauth-client@2.0.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDBMPiiahYRqPD9aiTyATaz1ejnCEXF8Gz0U2FsOGW4/QIhAIs7XgyjHuOTLoN8ZlbwOz8k3FPQ5vD3gDVqqN9Itv34"}]},"main":"./dist/index.cjs","name":"@cemiltan/isuwa-oauth-client","type":"module","types":"./dist/index.d.ts","author":{"name":"Cemil Tan","email":"cemiltan896@gmail.com"},"module":"./dist/index.js","engines":{"node":">=20"},"exports":{".":{"import":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"require":{"types":"./dist/index.d.cts","default":"./dist/index.cjs"}},"./package.json":"./package.json"},"gitHead":"fa2de064ff4a9e9b36ff4183ea721c61322b4c3d","license":"MIT","scripts":{"lint":"eslint .","test":"vitest run","build":"tsup","typecheck":"tsc --noEmit","test:watch":"vitest","test:coverage":"vitest run --coverage","prepublishOnly":"npm run lint && npm run typecheck && npm run test && npm run build"},"version":"2.0.0","_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:b5dac5ca-7ae4-4822-9b3a-54e9187a8057"},"approver":{"name":"cemiltan","email":"cemiltan1999@gmail.com"}},"homepage":"https://github.com/Ctere1/isuwa-oauth-client#readme","keywords":["oauth2","jwt","jwks","sdk","isuwa","iam","client_credentials"],"repository":{"url":"git+https://github.com/Ctere1/isuwa-oauth-client.git","type":"git"},"_npmVersion":"12.0.2","description":"JavaScript/TypeScript SDK for ISUWA IAM OAuth2: client_credentials tokens, JWKS verification, and authenticated requests","directories":{},"maintainers":[{"name":"cemiltan","email":"cemiltan1999@gmail.com"}],"sideEffects":false,"_nodeVersion":"22.23.2","publishConfig":{"access":"public"},"devDependencies":{"tsup":"^8.5.1","eslint":"^10.10.0","vitest":"^5.0.0","@eslint/js":"^10.0.1","typescript":"^6.0.3","@types/node":"^26.4.1","typescript-eslint":"^8.69.0","@vitest/coverage-v8":"^5.0.0"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/isuwa-oauth-client_2.0.0_1788618981848_0.942433628374568"},"_hasShrinkwrap":false}},"time":{"created":"2025-10-10T19:46:16.951Z","modified":"2026-09-05T14:36:22.262Z","1.0.0":"2025-10-10T19:46:17.280Z","1.0.2":"2025-10-10T19:56:13.605Z","2.0.0":"2026-09-05T14:36:21.944Z"},"bugs":{"url":"https://github.com/Ctere1/isuwa-oauth-client/issues"},"author":{"name":"Cemil Tan","email":"cemiltan896@gmail.com"},"license":"MIT","homepage":"https://github.com/Ctere1/isuwa-oauth-client#readme","keywords":["oauth2","jwt","jwks","sdk","isuwa","iam","client_credentials"],"repository":{"url":"git+https://github.com/Ctere1/isuwa-oauth-client.git","type":"git"},"description":"JavaScript/TypeScript SDK for ISUWA IAM OAuth2: client_credentials tokens, JWKS verification, and authenticated requests","maintainers":[{"name":"cemiltan","email":"cemiltan1999@gmail.com"}],"readme":"# isuwa-oauth-client\n\n[![npm version](https://img.shields.io/npm/v/@cemiltan/isuwa-oauth-client.svg)](https://www.npmjs.com/package/@cemiltan/isuwa-oauth-client)\n[![GitHub stars](https://img.shields.io/github/stars/Ctere1/isuwa-oauth-client.svg)](https://github.com/Ctere1/isuwa-oauth-client)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)\n\nA lightweight JavaScript/TypeScript SDK for ISUWA IAM OAuth2.\n\nSupports:\n- `client_credentials` grant flow\n- Token caching and refresh\n- Optional JWT verification using the JWKS endpoint\n- Authenticated requests with the headers an application route expects\n- No runtime dependencies, ESM and CommonJS, typed\n\n---\n\n## 🚀 Installation\n\n```bash\nnpm install @cemiltan/isuwa-oauth-client\n```\n\nRequires Node 20 or newer. Your IAM administrator gives you the base URL, the client id\nand the client secret.\n\n## Usage Example\n\n```javascript\nimport { IsuwaClient } from '@cemiltan/isuwa-oauth-client';\n\nconst iam = new IsuwaClient({\n  baseUrl: process.env.ISUWA_BASE_URL,\n  clientId: process.env.ISUWA_CLIENT_ID,\n  clientSecret: process.env.ISUWA_CLIENT_SECRET,\n  applicationType: process.env.ISUWA_APPLICATION_TYPE, // optional\n});\n\n// Get an access token — cached and refreshed for you\nconst token = await iam.getAccessToken();\n\n// (Optional) Verify a token against the JWKS endpoint\nconst claims = await iam.verifyAccessToken(token, { requiredScopes: ['app:read'] });\n\n// Call an application route with that token\nconst data = await iam.request('/api/v1/...', { body: { … }, requestId });\n```\n\n`request()` sends the bearer token, `Client-ID`, `Content-Type` and, when the application\ndeclares one, `Application-Type`. It refreshes the token and replays the call once on a\n401, and turns any other non-2xx status into a typed error.\n\n## API\n\n```javascript\nnew IsuwaClient({ baseUrl, clientId, clientSecret, scope?, timeoutMs?, retryOn401?,\n                  applicationType?, tokenRefreshSkewMs?, fetch? })\n\nawait iam.getAccessToken({ forceRefresh? })\nawait iam.verifyAccessToken(token, { audience?, issuer?, requiredScopes?, clockToleranceSeconds? })\nawait iam.request(path, { method?, body?, headers?, requestId?, userAgent?, forwardedFor? })\niam.clearTokenCache()\niam.clearJwksCache()\n```\n\nErrors: `IsuwaConfigError`, `IsuwaOAuthError`, `IsuwaRateLimitError`, `IsuwaHttpError`,\n`IsuwaTimeoutError`, `IsuwaNetworkError`, `IsuwaTokenVerificationError`. A server message\nis carried through unchanged — log it, rather than showing it to the end user.\n\nNotes:\n\n- Keep one client per process: it caches the access token and shares one refresh between\n  concurrent callers.\n- `request()` only calls `baseUrl`'s own origin, so the token cannot leave that server,\n  and it keeps any path prefix the base URL carries. It sends `GET` without a body and\n  `POST` with one, unless you pass `method`.\n- Pass a `requestId` to correlate the calls that belong to one operation.\n- Requests time out after 20 seconds by default; the minimum is 15 000 ms.\n\n## Migration\n\nUpgrading from 1.x replaces `OAuthClient` with `IsuwaClient`. See\n[MIGRATION.md](./MIGRATION.md) and the [changelog](./CHANGELOG.md).\n\n## License\n\nMIT © Cemil Tan\n","readmeFilename":"README.md"}