@cloud-idaas/akless-aws-adapter 0.1.0-beta.2 → 0.1.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -1
- package/README.md +4 -2
- package/README_zh.md +4 -2
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/sdk-version.d.ts +1 -0
- package/dist/sdk-version.js +6 -0
- package/dist/sdk-version.js.map +1 -0
- package/examples/initialize.cjs +2 -0
- package/examples/initialize.mjs +2 -0
- package/examples/initialize.ts +2 -0
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
## 0.1.0-beta.
|
|
3
|
+
## 0.1.0-beta.4
|
|
4
|
+
|
|
5
|
+
- Support optional STS session duration in seconds. Omit it to keep the PAM default.
|
|
6
|
+
|
|
7
|
+
## 0.1.0-beta.3
|
|
8
|
+
|
|
9
|
+
- Include this adapter repository name and build version in PAM STS User-Agent headers.
|
|
10
|
+
- Use Core SDK and PAM SDK 0.1.0-beta.3.
|
|
11
|
+
|
|
12
|
+
## 0.1.0-beta.2
|
|
4
13
|
|
|
5
14
|
- Publish a maintenance prerelease with no API changes.
|
|
6
15
|
|
package/README.md
CHANGED
|
@@ -9,11 +9,13 @@ Use IDaaS PAM temporary credentials with AWS SDK for JavaScript v3.
|
|
|
9
9
|
Supports Node.js 20, 22, and 24, JavaScript CommonJS/ESM, and TypeScript 4.7 or later. This is a Node.js SDK, not a browser SDK. Check your registry for available beta versions; use a provided package archive when evaluating an unreleased version.
|
|
10
10
|
|
|
11
11
|
```sh
|
|
12
|
-
npm install @cloud-idaas/core-sdk @cloud-idaas/akless-aws-adapter
|
|
12
|
+
npm install @cloud-idaas/core-sdk@0.1.0-beta.4 @cloud-idaas/akless-aws-adapter@0.1.0-beta.4
|
|
13
13
|
```
|
|
14
14
|
|
|
15
15
|
## Usage
|
|
16
16
|
|
|
17
|
+
The Factory accepts an optional integer `durationSeconds` from 900 to 43200. Omit it to use the PAM default. The target role can impose a lower maximum. For the default, call `createAwsCredentialsProvider(roleId)`.
|
|
18
|
+
|
|
17
19
|
Configure Core using CLOUD_IDAAS_CONFIG_PATH or ~/.cloud_idaas/client-config.json. Provide developerApiEndpoint and an identity authorized for PAM access. Replace example identifiers with your settings. Save the following ESM example as `example.mjs` and run it with Node.js. CommonJS uses the same named exports through `require`; asynchronous calls belong inside an async function.
|
|
18
20
|
|
|
19
21
|
```javascript
|
|
@@ -22,7 +24,7 @@ import { createAwsCredentialsProvider } from '@cloud-idaas/akless-aws-adapter';
|
|
|
22
24
|
|
|
23
25
|
await IDaaSCredentialProviderFactory.init();
|
|
24
26
|
try {
|
|
25
|
-
const credentials = createAwsCredentialsProvider('role-external-id');
|
|
27
|
+
const credentials = createAwsCredentialsProvider('role-external-id', { durationSeconds: 1800 });
|
|
26
28
|
try {
|
|
27
29
|
await credentials();
|
|
28
30
|
// Pass credentials to new S3Client({ region: '...', credentials }).
|
package/README_zh.md
CHANGED
|
@@ -9,11 +9,13 @@
|
|
|
9
9
|
支持 Node.js 20、22、24,JavaScript CommonJS/ESM 以及 TypeScript 4.7 及以上版本。本 SDK 用于 Node.js,不用于浏览器。请以 npm registry 中的实际可用版本为准;评估尚未发布的版本时,使用提供的安装包归档。
|
|
10
10
|
|
|
11
11
|
```sh
|
|
12
|
-
npm install @cloud-idaas/core-sdk @cloud-idaas/akless-aws-adapter
|
|
12
|
+
npm install @cloud-idaas/core-sdk@0.1.0-beta.4 @cloud-idaas/akless-aws-adapter@0.1.0-beta.4
|
|
13
13
|
```
|
|
14
14
|
|
|
15
15
|
## 使用
|
|
16
16
|
|
|
17
|
+
Factory 的 `durationSeconds` 接受 900–43200 的整数秒数。省略时由 PAM 决定有效期,实际可请求的上限取决于目标角色。 使用默认值时调用 `createAwsCredentialsProvider(roleId)`。
|
|
18
|
+
|
|
17
19
|
通过 CLOUD_IDAAS_CONFIG_PATH 或 ~/.cloud_idaas/client-config.json 配置 Core,提供 developerApiEndpoint 及已获 PAM 访问授权的身份,并替换示例标识。 将以下 ESM 示例保存为 `example.mjs`,通过 Node.js 运行。CommonJS 使用相同的具名导出和 `require`,异步调用放在 async 函数中。
|
|
18
20
|
|
|
19
21
|
```javascript
|
|
@@ -22,7 +24,7 @@ import { createAwsCredentialsProvider } from '@cloud-idaas/akless-aws-adapter';
|
|
|
22
24
|
|
|
23
25
|
await IDaaSCredentialProviderFactory.init();
|
|
24
26
|
try {
|
|
25
|
-
const credentials = createAwsCredentialsProvider('role-external-id');
|
|
27
|
+
const credentials = createAwsCredentialsProvider('role-external-id', { durationSeconds: 1800 });
|
|
26
28
|
try {
|
|
27
29
|
await credentials();
|
|
28
30
|
// Pass credentials to new S3Client({ region: '...', credentials }).
|
package/dist/index.js
CHANGED
|
@@ -4,6 +4,7 @@ exports.IDaaSPamAklessCredentialFactory = exports.IDaaSPamAwsCredentialsProvider
|
|
|
4
4
|
exports.createAwsCredentialsProvider = createAwsCredentialsProvider;
|
|
5
5
|
const core_sdk_1 = require("@cloud-idaas/core-sdk");
|
|
6
6
|
const pam_client_sdk_1 = require("@cloud-idaas/pam-client-sdk");
|
|
7
|
+
const sdk_version_1 = require("./sdk-version");
|
|
7
8
|
/**
|
|
8
9
|
* IDaaS PAM dynamic credential adapter for AWS SDK v3 on Node.js 20/22/24.
|
|
9
10
|
* @remarks The signing integration was verified with @aws-sdk/client-sts 3.1152.0. Inherited getCredentials
|
|
@@ -31,7 +32,7 @@ class IDaaSPamAwsCredentialsProvider extends pam_client_sdk_1.CachedCloudCredent
|
|
|
31
32
|
sessionToken: (0, pam_client_sdk_1.credentialString)(token.sessionToken, 'sessionToken'),
|
|
32
33
|
expiration: new Date((0, pam_client_sdk_1.credentialExpiration)(response, token.expiration)).toISOString(),
|
|
33
34
|
};
|
|
34
|
-
});
|
|
35
|
+
}, `idaas-typescript-akless-aws-adapter/${sdk_version_1.SDK_VERSION}`);
|
|
35
36
|
}
|
|
36
37
|
/**
|
|
37
38
|
* Wraps this provider as an AWS SDK v3 credentials function without creating another cache or fetching credentials.
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AA8FA,oEASC;AAvGD,oDAA4D;AAC5D,gEAOqC;AACrC,+CAA4C;AAyB5C;;;;;GAKG;AACH,MAAa,8BAA+B,SAAQ,8CAAoD;IACtG,wHAAwH;IACxH,MAAM,CAAC,OAAO;QACZ,OAAO,IAAI,sCAAqB,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,8BAA8B,CAAC,OAAO,CAAC,CAAC,CAAC;IAC7F,CAAC;IACD;;;;OAIG;IACH,YAAY,OAA8B;QACxC,KAAK,CACH,OAAO,EACP,CAAC,QAAQ,EAAE,EAAE;YACX,MAAM,KAAK,GAAG,QAAQ,CAAC,WAAW,CAAC;YACnC,IAAI,CAAC,KAAK;gBACR,MAAM,IAAI,8BAAmB,CAC3B,iCAAiC,EACjC,2BAA2B,CAC5B,CAAC;YACJ,OAAO;gBACL,WAAW,EAAE,IAAA,iCAAgB,EAAC,KAAK,CAAC,WAAW,EAAE,aAAa,CAAC;gBAC/D,eAAe,EAAE,IAAA,iCAAgB,EAAC,KAAK,CAAC,eAAe,EAAE,iBAAiB,CAAC;gBAC3E,YAAY,EAAE,IAAA,iCAAgB,EAAC,KAAK,CAAC,YAAY,EAAE,cAAc,CAAC;gBAClE,UAAU,EAAE,IAAI,IAAI,CAAC,IAAA,qCAAoB,EAAC,QAAQ,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,WAAW,EAAE;aACrF,CAAC;QACJ,CAAC,EACD,uCAAuC,yBAAW,EAAE,CACrD,CAAC;IACJ,CAAC;IACD;;;;OAIG;IACH,wBAAwB;QACtB,MAAM,OAAO,GAAG,KAAK,IAAoC,EAAE;YACzD,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;YAC1C,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;YAC5B,OAAO,EAAE,GAAG,KAAK,EAAE,UAAU,EAAE,IAAI,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,EAAE,CAAC;QAC9D,CAAC,CAAC;QACF,OAAO,CAAC,KAAK,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;QACnC,OAAO,OAAO,CAAC;IACjB,CAAC;CACF;AA5CD,wEA4CC;AACD;;;;;;;;GAQG;AACH,SAAgB,4BAA4B,CAC1C,aAA6C,EAC7C,UAAyD,EAAE;IAE3D,OAAO,IAAI,8BAA8B,CACvC,OAAO,aAAa,KAAK,QAAQ;QAC/B,CAAC,CAAC,EAAE,GAAG,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE;QAC/C,CAAC,CAAC,aAAa,CAClB,CAAC,wBAAwB,EAAE,CAAC;AAC/B,CAAC;AACD,yEAAyE;AACzE,MAAa,+BAA+B;;AAA5C,0EAGC;AAFC,kHAAkH;AAC3G,4DAA4B,GAAG,4BAA4B,CAAC","sourcesContent":["import { CredentialException } from '@cloud-idaas/core-sdk';\nimport {\n type AklessProviderOptions,\n AklessProviderBuilder,\n CachedCloudCredentialProvider,\n type ExpiringCredential,\n credentialExpiration,\n credentialString,\n} from '@cloud-idaas/pam-client-sdk';\nimport { SDK_VERSION } from './sdk-version';\n\n/** AWS STS snapshot mapped from PAM, with expiration as an ISO 8601 timestamp. */\nexport interface AwsSessionCredentials extends ExpiringCredential {\n accessKeyId: string;\n secretAccessKey: string;\n sessionToken: string;\n}\n/** Structural AWS SDK v3 identity; every returned Date is an independent object. */\nexport interface AwsCredentialIdentity {\n accessKeyId: string;\n secretAccessKey: string;\n sessionToken: string;\n expiration: Date;\n}\n/**\n * Asynchronous AWS SDK v3 credential function with explicit resource cleanup.\n * @remarks Fetches STS credentials on first use; refresh failures after expiration reject instead of returning expired credentials.\n */\nexport interface AwsCredentialsProvider {\n /** @returns An independent credential snapshot for request signing; rejects with IDaaSException on failure. */\n (): Promise<AwsCredentialIdentity>;\n /** Closes owned PAM/HTTP resources, leaving the caller's AWS client and injected resources open. */\n close(): void;\n}\n/**\n * IDaaS PAM dynamic credential adapter for AWS SDK v3 on Node.js 20/22/24.\n * @remarks The signing integration was verified with @aws-sdk/client-sts 3.1152.0. Inherited getCredentials\n * returns an ISO expiration snapshot; toAwsCredentialsProvider converts it to Date at the adapter boundary.\n * Callers must call close; injected PAM, HTTP, and machine credential sources remain caller-owned.\n */\nexport class IDaaSPamAwsCredentialsProvider extends CachedCloudCredentialProvider<AwsSessionCredentials> {\n /** @returns A role configuration builder without I/O; build preserves constructor validation and resource ownership. */\n static builder(): AklessProviderBuilder<IDaaSPamAwsCredentialsProvider> {\n return new AklessProviderBuilder((options) => new IDaaSPamAwsCredentialsProvider(options));\n }\n /**\n * Creates a provider without fetching STS credentials.\n * @param options - Required role and optional PAM, HTTP, machine credential source, and cache configuration.\n * @throws ConfigException - The configuration is invalid or the required default factory is not initialized.\n */\n constructor(options: AklessProviderOptions) {\n super(\n options,\n (response) => {\n const token = response.awsStsToken;\n if (!token)\n throw new CredentialException(\n 'Response is missing awsStsToken',\n 'InvalidCredentialResponse',\n );\n return {\n accessKeyId: credentialString(token.accessKeyId, 'accessKeyId'),\n secretAccessKey: credentialString(token.secretAccessKey, 'secretAccessKey'),\n sessionToken: credentialString(token.sessionToken, 'sessionToken'),\n expiration: new Date(credentialExpiration(response, token.expiration)).toISOString(),\n };\n },\n `idaas-typescript-akless-aws-adapter/${SDK_VERSION}`,\n );\n }\n /**\n * Wraps this provider as an AWS SDK v3 credentials function without creating another cache or fetching credentials.\n * @returns A function sharing this provider; calling its close also closes this provider.\n * @remarks Every call returns an independent Date; asynchronous retrieval failures reject with IDaaSException.\n */\n toAwsCredentialsProvider(): AwsCredentialsProvider {\n const resolve = async (): Promise<AwsCredentialIdentity> => {\n const value = await this.getCredentials();\n this.assertAvailable(value);\n return { ...value, expiration: new Date(value.expiration) };\n };\n resolve.close = () => this.close();\n return resolve;\n }\n}\n/**\n * Creates a function accepted directly by the AWS SDK v3 credentials option.\n * @param roleOrOptions - Role external ID or complete configuration including the role.\n * @param options - Additional configuration when the first argument is a string; injected sources take precedence.\n * @returns An independent dynamic provider with close; fetches STS on first use and must be closed by the caller.\n * @throws ConfigException - The configuration is invalid or the required default factory is not initialized.\n * @remarks Request and expiration failures reject with IDaaSException; close leaves the AWS client\n * and caller-injected shared resources open.\n */\nexport function createAwsCredentialsProvider(\n roleOrOptions: string | AklessProviderOptions,\n options: Omit<AklessProviderOptions, 'roleExternalId'> = {},\n): AwsCredentialsProvider {\n return new IDaaSPamAwsCredentialsProvider(\n typeof roleOrOptions === 'string'\n ? { ...options, roleExternalId: roleOrOptions }\n : roleOrOptions,\n ).toAwsCredentialsProvider();\n}\n/** AWS beta convenience factories; do not create AWS service clients. */\nexport class IDaaSPamAklessCredentialFactory {\n /** Creates a dynamic credentials function with the same arguments, errors, and lifecycle as the named factory. */\n static createAwsCredentialsProvider = createAwsCredentialsProvider;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const SDK_VERSION: string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sdk-version.js","sourceRoot":"","sources":["../src/sdk-version.ts"],"names":[],"mappings":";;;AAAA,yEAAyE;AAC5D,QAAA,WAAW,GAAW,cAAc,CAAC","sourcesContent":["// Generated from package.json by scripts/build-version.cjs. Do not edit.\nexport const SDK_VERSION: string = '0.1.0-beta.4';\n"]}
|
package/examples/initialize.cjs
CHANGED
|
@@ -4,8 +4,10 @@ const { createAwsCredentialsProvider } = require('@cloud-idaas/akless-aws-adapte
|
|
|
4
4
|
async function main() {
|
|
5
5
|
await IDaaSCredentialProviderFactory.init();
|
|
6
6
|
try {
|
|
7
|
+
// For the PAM default, call createAwsCredentialsProvider(roleId).
|
|
7
8
|
const credentials = createAwsCredentialsProvider(
|
|
8
9
|
process.env.IDAAS_ROLE_EXTERNAL_ID || 'role-id',
|
|
10
|
+
{ durationSeconds: 1800 },
|
|
9
11
|
);
|
|
10
12
|
try {
|
|
11
13
|
await credentials();
|
package/examples/initialize.mjs
CHANGED
|
@@ -4,8 +4,10 @@ import { createAwsCredentialsProvider } from '@cloud-idaas/akless-aws-adapter';
|
|
|
4
4
|
async function main() {
|
|
5
5
|
await IDaaSCredentialProviderFactory.init();
|
|
6
6
|
try {
|
|
7
|
+
// For the PAM default, call createAwsCredentialsProvider(roleId).
|
|
7
8
|
const credentials = createAwsCredentialsProvider(
|
|
8
9
|
process.env.IDAAS_ROLE_EXTERNAL_ID || 'role-id',
|
|
10
|
+
{ durationSeconds: 1800 },
|
|
9
11
|
);
|
|
10
12
|
try {
|
|
11
13
|
await credentials();
|
package/examples/initialize.ts
CHANGED
|
@@ -4,8 +4,10 @@ import { createAwsCredentialsProvider } from '@cloud-idaas/akless-aws-adapter';
|
|
|
4
4
|
async function main() {
|
|
5
5
|
await IDaaSCredentialProviderFactory.init();
|
|
6
6
|
try {
|
|
7
|
+
// For the PAM default, call createAwsCredentialsProvider(roleId).
|
|
7
8
|
const credentials = createAwsCredentialsProvider(
|
|
8
9
|
process.env.IDAAS_ROLE_EXTERNAL_ID || 'role-id',
|
|
10
|
+
{ durationSeconds: 1800 },
|
|
9
11
|
);
|
|
10
12
|
try {
|
|
11
13
|
await credentials();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloud-idaas/akless-aws-adapter",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.4",
|
|
4
4
|
"description": "IDaaS akless-aws-adapter for TypeScript and JavaScript (Node.js)",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "commonjs",
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
"node": ">=20.0.0"
|
|
31
31
|
},
|
|
32
32
|
"scripts": {
|
|
33
|
-
"build": "tsc -p tsconfig.json && node scripts/build-esm.cjs",
|
|
34
|
-
"typecheck": "tsc --noEmit -p tsconfig.json && tsc --noEmit -p test/tsconfig.json",
|
|
33
|
+
"build": "node scripts/build-version.cjs && tsc -p tsconfig.json && node scripts/build-esm.cjs",
|
|
34
|
+
"typecheck": "node scripts/build-version.cjs && tsc --noEmit -p tsconfig.json && tsc --noEmit -p test/tsconfig.json",
|
|
35
35
|
"test": "npm run build && nyc mocha --require ./test/register.cjs \"test/**/*.test.{ts,cjs}\"",
|
|
36
36
|
"prepack": "npm run build",
|
|
37
37
|
"lint": "eslint src test",
|
|
@@ -60,8 +60,8 @@
|
|
|
60
60
|
"@aws-sdk/client-sts": "3.1152.0"
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"@cloud-idaas/core-sdk": "0.1.0-beta.
|
|
64
|
-
"@cloud-idaas/pam-client-sdk": "0.1.0-beta.
|
|
63
|
+
"@cloud-idaas/core-sdk": "0.1.0-beta.4",
|
|
64
|
+
"@cloud-idaas/pam-client-sdk": "0.1.0-beta.4"
|
|
65
65
|
},
|
|
66
66
|
"publishConfig": {
|
|
67
67
|
"access": "public",
|