{"_id":"@aws/token-generator-for-aws-external-anthropic","name":"@aws/token-generator-for-aws-external-anthropic","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@aws/token-generator-for-aws-external-anthropic","version":"1.0.0","description":"A lightweight library for generating short-term bearer tokens for AWS External Anthropic API authentication","main":"dist/index.js","types":"dist/index.d.ts","scripts":{"build":"tsc","test":"jest","test:watch":"jest --watch","clean":"rm -rf dist","prepublishOnly":"npm run clean && npm run build","lint":"echo 'No linter configured'","format":"prettier --write src/**/*.ts","docs":"typedoc --options typedoc.json","postbuild":"npm run docs"},"keywords":["aws","aws-external-anthropic","bearer-token","authentication","amazon","token-generator"],"author":{"name":"Amazon Web Services","email":"aws-mantle-oss@amazon.com"},"license":"Apache-2.0","repository":{"type":"git","url":"git+https://github.com/aws/token-generator-for-aws-external-anthropic-js.git"},"homepage":"https://github.com/aws/token-generator-for-aws-external-anthropic-js#readme","bugs":{"url":"https://github.com/aws/token-generator-for-aws-external-anthropic-js/issues"},"browser":{"./dist/runtimeConfig":"./dist/runtimeConfig.browser"},"dependencies":{"@aws-sdk/credential-providers":"^3.525.0","@aws-sdk/util-format-url":">=3.525.0","@smithy/config-resolver":"^4.1.4","@smithy/hash-node":">=2.1.3","@smithy/invalid-dependency":"^4.0.4","@smithy/node-config-provider":"^4.1.3","@smithy/protocol-http":">=3.2.1","@smithy/signature-v4":">=2.1.3","@smithy/types":">=2.11.0"},"devDependencies":{"@types/jest":"^29.5.5","@types/node":"^20.6.0","@typescript-eslint/eslint-plugin":"^6.7.0","@typescript-eslint/parser":"^6.7.0","eslint":"^8.49.0","jest":"^29.7.0","prettier":"^3.0.3","ts-jest":"^29.1.1","typedoc":"^0.28.7","typedoc-plugin-markdown":"^4.7.0","typescript":"^5.2.2"},"engines":{"node":">=16.0.0"},"_id":"@aws/token-generator-for-aws-external-anthropic@1.0.0","gitHead":"870a04ee8da4cbe5e57045780a7a1a6ff713c2d8","_nodeVersion":"20.18.2","_npmVersion":"10.8.2","dist":{"integrity":"sha512-KCJlD5QwgNdBEIpWBgVZUaexFZyk6a551o6BjarNDU+yna/kNCNv8soi2Qy/d2RdZKgE1GaKgAE9NzHO84wHow==","shasum":"f2d59109f32db8fba8954e3db75d32cf643f7a1a","tarball":"https://registry.npmjs.org/@aws/token-generator-for-aws-external-anthropic/-/token-generator-for-aws-external-anthropic-1.0.0.tgz","fileCount":52,"unpackedSize":86332,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDdeUc6FNwquWIKYlDrO10ZfSdYUZi3wiPoJHL2l03G8AIgXa7TqFO+6A/9en0+kDOM7zX772+2zPpJUU3HlnU7HWw="}]},"_npmUser":{"name":"aws_mantle","email":"aws-mantle-oss@amazon.com"},"directories":{},"maintainers":[{"name":"aws_mantle","email":"aws-mantle-oss@amazon.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/token-generator-for-aws-external-anthropic_1.0.0_1778175327255_0.6529863705022272"},"_hasShrinkwrap":false}},"time":{"created":"2026-05-07T17:35:27.172Z","1.0.0":"2026-05-07T17:35:27.411Z","modified":"2026-05-07T17:35:27.616Z"},"maintainers":[{"name":"aws_mantle","email":"aws-mantle-oss@amazon.com"}],"description":"A lightweight library for generating short-term bearer tokens for AWS External Anthropic API authentication","homepage":"https://github.com/aws/token-generator-for-aws-external-anthropic-js#readme","keywords":["aws","aws-external-anthropic","bearer-token","authentication","amazon","token-generator"],"repository":{"type":"git","url":"git+https://github.com/aws/token-generator-for-aws-external-anthropic-js.git"},"author":{"name":"Amazon Web Services","email":"aws-mantle-oss@amazon.com"},"bugs":{"url":"https://github.com/aws/token-generator-for-aws-external-anthropic-js/issues"},"license":"Apache-2.0","readme":"# Token Generator for AWS External Anthropic (JavaScript/TypeScript)\n\nA lightweight library for generating short-term bearer tokens for AWS External Anthropic API authentication.\n\n## Installation\n\n```bash\nnpm install @aws/token-generator-for-aws-external-anthropic\n```\n\n## Quick Start\n\nToken duration can be customized (1 second to 12 hours). The actual token lifetime will be:\n`min(specified duration, credentials expiry, 12 hours)`. Default is 12 hours.\n\n### Usage 1 — Using Default Credentials and Region\n\n```typescript\nimport { getTokenProvider } from \"@aws/token-generator-for-aws-external-anthropic\";\n\n// Create a token provider that uses default credentials and region providers.\nconst provideToken = getTokenProvider();\n\nasync function example() {\n  const token = await provideToken();\n\n  // Use the token for API calls. The token has a default expiration of 12 hour.\n  // If the expiresInSeconds parameter is specified during token creation, the \n  // expiration can be configured up to a maximum of 12 hours. However, the actual \n  // token validity period will always be the minimum of the requested expiration \n  // time and the AWS credentials' expiry time\n  console.log(`Bearer Token: ${token}`);\n}\n```\n\n### Usage 2 — Using Custom Configuration\n\nThis example uses STS Assume Role. You can use any [supported credentials provider](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-credential-providers/).\n\n```typescript\nimport { getTokenProvider } from \"@aws/token-generator-for-aws-external-anthropic\";\nimport { fromTemporaryCredentials } from \"@aws-sdk/credential-providers\";\n\nconst provideToken = getTokenProvider({\n  credentials: fromTemporaryCredentials({\n    params: {\n      RoleArn: \"arn:aws:iam::123456789012:role/MyRole\",\n    },\n  }),\n  region: \"us-east-1\",\n  expiresInSeconds: 3600,\n});\n\nasync function example() {\n  const token = await provideToken();\n  console.log(`Bearer Token: ${token}`);\n}\n```\n\n### Usage 3 — Using Static One-Shot\n\nPass credentials, region, and expiry directly. No instance needed.\n\n```typescript\nimport { getToken } from \"@aws/token-generator-for-aws-external-anthropic\";\n\nasync function example() {\n  const token = await getToken({\n    credentials: {\n      accessKeyId: \"YOUR_ACCESS_KEY_ID\",\n      secretAccessKey: \"YOUR_SECRET_ACCESS_KEY\",\n      sessionToken: \"YOUR_SESSION_TOKEN\",\n    },\n    region: \"us-east-1\",\n    expiresInSeconds: 7200,\n  });\n\n  // Use the token for API calls. The token has an expiration of 2 hour. However, the actual token validity period\n  // will always be the minimum of the requested expiration time and the AWS credentials' expiry time\n  console.log(`Bearer Token: ${token}`);\n}\n```\n\n## API Reference\n\n- [API Reference](apidocs/README.md) - Detailed API documentation\n\n## Token Format\n\nThe generated token has the format:\n\n```\naws-external-anthropic-api-key-<base64-encoded-payload>\n```\n\nThe payload is a Base64-encoded SigV4 presigned URL scoped to the `aws-external-anthropic` service. The token can be decoded for debugging purposes but should be treated as an opaque string in production.\n\n## Requirements\n\n- **Node.js**: 16.0.0 or later\n- **TypeScript**: 4.7.0 or later (for TypeScript users)\n\n## Security Considerations\n\n- **Token Expiration**: Tokens are short-lived with a maximum lifetime of 12 hours. The actual expiry is `min(specified duration, credentials expiry, 12 hours)`. Use the shortest practical duration for your use case.\n- **Secure Storage**: Do not log or store tokens in plain text. Treat them as sensitive credentials.\n- **No Embedded Credentials**: No long-term credentials are embedded in the token. The token contains a SigV4 presigned URL, not the signing keys themselves.\n- **Credential Management**: Use IAM roles or temporary credentials instead of long-term access keys where possible.\n- **Network Security**: Always transmit tokens over HTTPS.\n- **Least Privilege**: Scope IAM permissions to the minimum required for your use case.\n- **Region Scoping**: Tokens are scoped to a specific AWS region and cannot be used across regions.\n\n## Development\n\n```bash\n# Install dependencies\nnpm install\n\n# Build the project\nnpm run build\n\n# Run tests\nnpm test\n```\n\n## Contributing\n\nSee [CONTRIBUTING](CONTRIBUTING.md) for more information.\n\n## License\n\nThis project is licensed under the Apache License, Version 2.0. See the [LICENSE](LICENSE) file for details.\n\n## Changelog\n\nSee [CHANGELOG](CHANGELOG.md) for release history.\n","readmeFilename":"README.md","_rev":"1-1396e35c4393edf126b8071ba1cb6387"}