@cloud-idaas/akless-aws-adapter 0.0.0-stage → 0.1.0-beta.2

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 ADDED
@@ -0,0 +1,11 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0-beta.2 (Unreleased)
4
+
5
+ - Publish a maintenance prerelease with no API changes.
6
+
7
+ ## 0.1.0-beta.1
8
+
9
+ - Provide renewable credentials for AWS SDK for JavaScript v3.
10
+ - Improve credential expiry checks, refresh behavior, and resource cleanup.
11
+ - Provide CommonJS/ESM packages, TypeScript declarations, and English/Chinese usage documentation.
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,52 @@
1
- # Temporary Holding Version
1
+ # IDaaS AWS Credentials Adapter
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ [Simplified Chinese](README_zh.md) | English
4
+
5
+ Use IDaaS PAM temporary credentials with AWS SDK for JavaScript v3.
6
+
7
+ ## Requirements and installation
8
+
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
+
11
+ ```sh
12
+ npm install @cloud-idaas/core-sdk @cloud-idaas/akless-aws-adapter
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ 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
+
19
+ ```javascript
20
+ import { IDaaSCredentialProviderFactory } from '@cloud-idaas/core-sdk';
21
+ import { createAwsCredentialsProvider } from '@cloud-idaas/akless-aws-adapter';
22
+
23
+ await IDaaSCredentialProviderFactory.init();
24
+ try {
25
+ const credentials = createAwsCredentialsProvider('role-external-id');
26
+ try {
27
+ await credentials();
28
+ // Pass credentials to new S3Client({ region: '...', credentials }).
29
+ // Await all service requests before closing the provider.
30
+ } finally {
31
+ credentials.close();
32
+ }
33
+ } finally {
34
+ await IDaaSCredentialProviderFactory.close();
35
+ }
36
+ ```
37
+
38
+ ## Integration notes
39
+
40
+ Pass the function returned by `createAwsCredentialsProvider()` to the AWS SDK v3 client's `credentials` option. Install the required AWS service client separately. Avoid replacing the function with a credential snapshot for long-running applications.
41
+
42
+ The options object accepts `roleExternalId`, `developerApiEndpoint`, `idaasInstanceId`, and `credentialProvider`. Credentials include an expiration time, and retrieval/refresh failures raise SDK errors. Keep the provider open until AWS requests finish, then call `close()`.
43
+
44
+ `httpConfiguration.userAgent` customizes requests to IDaaS; AWS service requests follow the AWS client's configuration. Caller-injected providers and clients remain caller-owned.
45
+
46
+ ## Examples and support
47
+
48
+ See [examples](examples) for CommonJS, ESM, and TypeScript samples. Report issues through [GitHub Issues](https://github.com/cloud-idaas/idaas-typescript-akless-aws-adapter/issues). Development instructions are in the repository's [contribution guide](https://github.com/cloud-idaas/idaas-typescript-akless-aws-adapter/blob/master/CONTRIBUTING.md).
49
+
50
+ ## License
51
+
52
+ [Apache License 2.0](LICENSE).
package/README_zh.md ADDED
@@ -0,0 +1,52 @@
1
+ # IDaaS AWS Credentials Adapter
2
+
3
+ 简体中文 | [English](README.md)
4
+
5
+ 将 IDaaS PAM 临时凭证用于 AWS SDK for JavaScript v3。
6
+
7
+ ## 环境与安装
8
+
9
+ 支持 Node.js 20、22、24,JavaScript CommonJS/ESM 以及 TypeScript 4.7 及以上版本。本 SDK 用于 Node.js,不用于浏览器。请以 npm registry 中的实际可用版本为准;评估尚未发布的版本时,使用提供的安装包归档。
10
+
11
+ ```sh
12
+ npm install @cloud-idaas/core-sdk @cloud-idaas/akless-aws-adapter
13
+ ```
14
+
15
+ ## 使用
16
+
17
+ 通过 CLOUD_IDAAS_CONFIG_PATH 或 ~/.cloud_idaas/client-config.json 配置 Core,提供 developerApiEndpoint 及已获 PAM 访问授权的身份,并替换示例标识。 将以下 ESM 示例保存为 `example.mjs`,通过 Node.js 运行。CommonJS 使用相同的具名导出和 `require`,异步调用放在 async 函数中。
18
+
19
+ ```javascript
20
+ import { IDaaSCredentialProviderFactory } from '@cloud-idaas/core-sdk';
21
+ import { createAwsCredentialsProvider } from '@cloud-idaas/akless-aws-adapter';
22
+
23
+ await IDaaSCredentialProviderFactory.init();
24
+ try {
25
+ const credentials = createAwsCredentialsProvider('role-external-id');
26
+ try {
27
+ await credentials();
28
+ // Pass credentials to new S3Client({ region: '...', credentials }).
29
+ // Await all service requests before closing the provider.
30
+ } finally {
31
+ credentials.close();
32
+ }
33
+ } finally {
34
+ await IDaaSCredentialProviderFactory.close();
35
+ }
36
+ ```
37
+
38
+ ## 集成说明
39
+
40
+ 将 `createAwsCredentialsProvider()` 返回的函数传给 AWS SDK v3 客户端的 `credentials` 选项,并另行安装需要的 AWS 服务客户端。长时间运行的应用应保留该函数,不要改用一次性凭证快照。
41
+
42
+ 配置对象支持 `roleExternalId`、`developerApiEndpoint`、`idaasInstanceId` 和 `credentialProvider`。返回的凭证包含过期时间,获取或刷新失败时抛出 SDK 异常。AWS 请求完成前保持提供者可用,随后调用 `close()`。
43
+
44
+ `httpConfiguration.userAgent` 定制发往 IDaaS 的请求;AWS 服务请求遵循 AWS 客户端配置。注入的提供者和客户端仍由调用方管理。
45
+
46
+ ## 示例与支持
47
+
48
+ [examples](examples) 提供 CommonJS、ESM 和 TypeScript 示例。问题反馈请使用 [GitHub Issues](https://github.com/cloud-idaas/idaas-typescript-akless-aws-adapter/issues),开发说明见源码仓库的[贡献指南](https://github.com/cloud-idaas/idaas-typescript-akless-aws-adapter/blob/master/CONTRIBUTING.md)。
49
+
50
+ ## 许可证
51
+
52
+ [Apache License 2.0](LICENSE)。
@@ -0,0 +1 @@
1
+ export * from './index.js';
@@ -0,0 +1,61 @@
1
+ import { type AklessProviderOptions, AklessProviderBuilder, CachedCloudCredentialProvider, type ExpiringCredential } from '@cloud-idaas/pam-client-sdk';
2
+ /** AWS STS snapshot mapped from PAM, with expiration as an ISO 8601 timestamp. */
3
+ export interface AwsSessionCredentials extends ExpiringCredential {
4
+ accessKeyId: string;
5
+ secretAccessKey: string;
6
+ sessionToken: string;
7
+ }
8
+ /** Structural AWS SDK v3 identity; every returned Date is an independent object. */
9
+ export interface AwsCredentialIdentity {
10
+ accessKeyId: string;
11
+ secretAccessKey: string;
12
+ sessionToken: string;
13
+ expiration: Date;
14
+ }
15
+ /**
16
+ * Asynchronous AWS SDK v3 credential function with explicit resource cleanup.
17
+ * @remarks Fetches STS credentials on first use; refresh failures after expiration reject instead of returning expired credentials.
18
+ */
19
+ export interface AwsCredentialsProvider {
20
+ /** @returns An independent credential snapshot for request signing; rejects with IDaaSException on failure. */
21
+ (): Promise<AwsCredentialIdentity>;
22
+ /** Closes owned PAM/HTTP resources, leaving the caller's AWS client and injected resources open. */
23
+ close(): void;
24
+ }
25
+ /**
26
+ * IDaaS PAM dynamic credential adapter for AWS SDK v3 on Node.js 20/22/24.
27
+ * @remarks The signing integration was verified with @aws-sdk/client-sts 3.1152.0. Inherited getCredentials
28
+ * returns an ISO expiration snapshot; toAwsCredentialsProvider converts it to Date at the adapter boundary.
29
+ * Callers must call close; injected PAM, HTTP, and machine credential sources remain caller-owned.
30
+ */
31
+ export declare class IDaaSPamAwsCredentialsProvider extends CachedCloudCredentialProvider<AwsSessionCredentials> {
32
+ /** @returns A role configuration builder without I/O; build preserves constructor validation and resource ownership. */
33
+ static builder(): AklessProviderBuilder<IDaaSPamAwsCredentialsProvider>;
34
+ /**
35
+ * Creates a provider without fetching STS credentials.
36
+ * @param options - Required role and optional PAM, HTTP, machine credential source, and cache configuration.
37
+ * @throws ConfigException - The configuration is invalid or the required default factory is not initialized.
38
+ */
39
+ constructor(options: AklessProviderOptions);
40
+ /**
41
+ * Wraps this provider as an AWS SDK v3 credentials function without creating another cache or fetching credentials.
42
+ * @returns A function sharing this provider; calling its close also closes this provider.
43
+ * @remarks Every call returns an independent Date; asynchronous retrieval failures reject with IDaaSException.
44
+ */
45
+ toAwsCredentialsProvider(): AwsCredentialsProvider;
46
+ }
47
+ /**
48
+ * Creates a function accepted directly by the AWS SDK v3 credentials option.
49
+ * @param roleOrOptions - Role external ID or complete configuration including the role.
50
+ * @param options - Additional configuration when the first argument is a string; injected sources take precedence.
51
+ * @returns An independent dynamic provider with close; fetches STS on first use and must be closed by the caller.
52
+ * @throws ConfigException - The configuration is invalid or the required default factory is not initialized.
53
+ * @remarks Request and expiration failures reject with IDaaSException; close leaves the AWS client
54
+ * and caller-injected shared resources open.
55
+ */
56
+ export declare function createAwsCredentialsProvider(roleOrOptions: string | AklessProviderOptions, options?: Omit<AklessProviderOptions, 'roleExternalId'>): AwsCredentialsProvider;
57
+ /** AWS beta convenience factories; do not create AWS service clients. */
58
+ export declare class IDaaSPamAklessCredentialFactory {
59
+ /** Creates a dynamic credentials function with the same arguments, errors, and lifecycle as the named factory. */
60
+ static createAwsCredentialsProvider: typeof createAwsCredentialsProvider;
61
+ }
package/dist/index.js ADDED
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IDaaSPamAklessCredentialFactory = exports.IDaaSPamAwsCredentialsProvider = void 0;
4
+ exports.createAwsCredentialsProvider = createAwsCredentialsProvider;
5
+ const core_sdk_1 = require("@cloud-idaas/core-sdk");
6
+ const pam_client_sdk_1 = require("@cloud-idaas/pam-client-sdk");
7
+ /**
8
+ * IDaaS PAM dynamic credential adapter for AWS SDK v3 on Node.js 20/22/24.
9
+ * @remarks The signing integration was verified with @aws-sdk/client-sts 3.1152.0. Inherited getCredentials
10
+ * returns an ISO expiration snapshot; toAwsCredentialsProvider converts it to Date at the adapter boundary.
11
+ * Callers must call close; injected PAM, HTTP, and machine credential sources remain caller-owned.
12
+ */
13
+ class IDaaSPamAwsCredentialsProvider extends pam_client_sdk_1.CachedCloudCredentialProvider {
14
+ /** @returns A role configuration builder without I/O; build preserves constructor validation and resource ownership. */
15
+ static builder() {
16
+ return new pam_client_sdk_1.AklessProviderBuilder((options) => new IDaaSPamAwsCredentialsProvider(options));
17
+ }
18
+ /**
19
+ * Creates a provider without fetching STS credentials.
20
+ * @param options - Required role and optional PAM, HTTP, machine credential source, and cache configuration.
21
+ * @throws ConfigException - The configuration is invalid or the required default factory is not initialized.
22
+ */
23
+ constructor(options) {
24
+ super(options, (response) => {
25
+ const token = response.awsStsToken;
26
+ if (!token)
27
+ throw new core_sdk_1.CredentialException('Response is missing awsStsToken', 'InvalidCredentialResponse');
28
+ return {
29
+ accessKeyId: (0, pam_client_sdk_1.credentialString)(token.accessKeyId, 'accessKeyId'),
30
+ secretAccessKey: (0, pam_client_sdk_1.credentialString)(token.secretAccessKey, 'secretAccessKey'),
31
+ sessionToken: (0, pam_client_sdk_1.credentialString)(token.sessionToken, 'sessionToken'),
32
+ expiration: new Date((0, pam_client_sdk_1.credentialExpiration)(response, token.expiration)).toISOString(),
33
+ };
34
+ });
35
+ }
36
+ /**
37
+ * Wraps this provider as an AWS SDK v3 credentials function without creating another cache or fetching credentials.
38
+ * @returns A function sharing this provider; calling its close also closes this provider.
39
+ * @remarks Every call returns an independent Date; asynchronous retrieval failures reject with IDaaSException.
40
+ */
41
+ toAwsCredentialsProvider() {
42
+ const resolve = async () => {
43
+ const value = await this.getCredentials();
44
+ this.assertAvailable(value);
45
+ return { ...value, expiration: new Date(value.expiration) };
46
+ };
47
+ resolve.close = () => this.close();
48
+ return resolve;
49
+ }
50
+ }
51
+ exports.IDaaSPamAwsCredentialsProvider = IDaaSPamAwsCredentialsProvider;
52
+ /**
53
+ * Creates a function accepted directly by the AWS SDK v3 credentials option.
54
+ * @param roleOrOptions - Role external ID or complete configuration including the role.
55
+ * @param options - Additional configuration when the first argument is a string; injected sources take precedence.
56
+ * @returns An independent dynamic provider with close; fetches STS on first use and must be closed by the caller.
57
+ * @throws ConfigException - The configuration is invalid or the required default factory is not initialized.
58
+ * @remarks Request and expiration failures reject with IDaaSException; close leaves the AWS client
59
+ * and caller-injected shared resources open.
60
+ */
61
+ function createAwsCredentialsProvider(roleOrOptions, options = {}) {
62
+ return new IDaaSPamAwsCredentialsProvider(typeof roleOrOptions === 'string'
63
+ ? { ...options, roleExternalId: roleOrOptions }
64
+ : roleOrOptions).toAwsCredentialsProvider();
65
+ }
66
+ /** AWS beta convenience factories; do not create AWS service clients. */
67
+ class IDaaSPamAklessCredentialFactory {
68
+ }
69
+ exports.IDaaSPamAklessCredentialFactory = IDaaSPamAklessCredentialFactory;
70
+ /** Creates a dynamic credentials function with the same arguments, errors, and lifecycle as the named factory. */
71
+ IDaaSPamAklessCredentialFactory.createAwsCredentialsProvider = createAwsCredentialsProvider;
72
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAyFA,oEASC;AAlGD,oDAA4D;AAC5D,gEAOqC;AAyBrC;;;;;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,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,EAAE;YAC1B,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,CAAC,CAAC;IACL,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;AAxCD,wEAwCC;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';\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(options, (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 }\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"]}
package/dist/index.mjs ADDED
@@ -0,0 +1,4 @@
1
+ import api from './index.js';
2
+ export const IDaaSPamAwsCredentialsProvider = api.IDaaSPamAwsCredentialsProvider;
3
+ export const IDaaSPamAklessCredentialFactory = api.IDaaSPamAklessCredentialFactory;
4
+ export const createAwsCredentialsProvider = api.createAwsCredentialsProvider;
@@ -0,0 +1,22 @@
1
+ const { IDaaSCredentialProviderFactory } = require('@cloud-idaas/core-sdk');
2
+ const { createAwsCredentialsProvider } = require('@cloud-idaas/akless-aws-adapter');
3
+
4
+ async function main() {
5
+ await IDaaSCredentialProviderFactory.init();
6
+ try {
7
+ const credentials = createAwsCredentialsProvider(
8
+ process.env.IDAAS_ROLE_EXTERNAL_ID || 'role-id',
9
+ );
10
+ try {
11
+ await credentials();
12
+ } finally {
13
+ credentials.close();
14
+ }
15
+ } finally {
16
+ await IDaaSCredentialProviderFactory.close();
17
+ }
18
+ }
19
+ main().catch((error) => {
20
+ console.error(error instanceof Error ? error.message : 'SDK call failed');
21
+ process.exitCode = 1;
22
+ });
@@ -0,0 +1,22 @@
1
+ import { IDaaSCredentialProviderFactory } from '@cloud-idaas/core-sdk';
2
+ import { createAwsCredentialsProvider } from '@cloud-idaas/akless-aws-adapter';
3
+
4
+ async function main() {
5
+ await IDaaSCredentialProviderFactory.init();
6
+ try {
7
+ const credentials = createAwsCredentialsProvider(
8
+ process.env.IDAAS_ROLE_EXTERNAL_ID || 'role-id',
9
+ );
10
+ try {
11
+ await credentials();
12
+ } finally {
13
+ credentials.close();
14
+ }
15
+ } finally {
16
+ await IDaaSCredentialProviderFactory.close();
17
+ }
18
+ }
19
+ main().catch((error) => {
20
+ console.error(error instanceof Error ? error.message : 'SDK call failed');
21
+ process.exitCode = 1;
22
+ });
@@ -0,0 +1,22 @@
1
+ import { IDaaSCredentialProviderFactory } from '@cloud-idaas/core-sdk';
2
+ import { createAwsCredentialsProvider } from '@cloud-idaas/akless-aws-adapter';
3
+
4
+ async function main() {
5
+ await IDaaSCredentialProviderFactory.init();
6
+ try {
7
+ const credentials = createAwsCredentialsProvider(
8
+ process.env.IDAAS_ROLE_EXTERNAL_ID || 'role-id',
9
+ );
10
+ try {
11
+ await credentials();
12
+ } finally {
13
+ credentials.close();
14
+ }
15
+ } finally {
16
+ await IDaaSCredentialProviderFactory.close();
17
+ }
18
+ }
19
+ main().catch((error) => {
20
+ console.error(error instanceof Error ? error.message : 'SDK call failed');
21
+ process.exitCode = 1;
22
+ });
package/package.json CHANGED
@@ -1,6 +1,78 @@
1
1
  {
2
2
  "name": "@cloud-idaas/akless-aws-adapter",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0-beta.2",
4
+ "description": "IDaaS akless-aws-adapter for TypeScript and JavaScript (Node.js)",
5
+ "license": "Apache-2.0",
6
+ "type": "commonjs",
7
+ "main": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "import": {
12
+ "types": "./dist/index.d.mts",
13
+ "default": "./dist/index.mjs"
14
+ },
15
+ "require": {
16
+ "types": "./dist/index.d.ts",
17
+ "default": "./dist/index.js"
18
+ }
19
+ }
20
+ },
21
+ "files": [
22
+ "dist",
23
+ "README.md",
24
+ "README_zh.md",
25
+ "CHANGELOG.md",
26
+ "examples",
27
+ "LICENSE"
28
+ ],
29
+ "engines": {
30
+ "node": ">=20.0.0"
31
+ },
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",
35
+ "test": "npm run build && nyc mocha --require ./test/register.cjs \"test/**/*.test.{ts,cjs}\"",
36
+ "prepack": "npm run build",
37
+ "lint": "eslint src test",
38
+ "format": "prettier --write \"src/**/*.ts\" \"test/**/*.{ts,cjs}\" \"scripts/**/*.{cjs,cts,mts}\" \".github/workflows/*.yml\" \"examples/**/*.{ts,cjs,mjs}\" \"*.{json,cjs,md}\"",
39
+ "format:check": "prettier --check \"src/**/*.ts\" \"test/**/*.{ts,cjs}\" \"scripts/**/*.{cjs,cts,mts}\" \".github/workflows/*.yml\" \"examples/**/*.{ts,cjs,mjs}\" \"*.{json,cjs,md}\"",
40
+ "verify": "npm run check:language && npm run typecheck && npm run lint && npm run format:check && npm test",
41
+ "bootstrap:deps": "node scripts/stage-upstreams.cjs",
42
+ "lock:deps": "node scripts/lock-upstreams.cjs",
43
+ "release:check": "node scripts/release-tools.cjs check",
44
+ "validate:workspace": "node scripts/validate-workspace.cjs",
45
+ "prepublishOnly": "npm run release:check",
46
+ "validate:repository": "node scripts/validate-workspace.cjs --target idaas-typescript-akless-aws-adapter",
47
+ "check:language": "node scripts/check-language.cjs"
48
+ },
49
+ "devDependencies": {
50
+ "typescript": "5.9.3",
51
+ "@types/node": "20.17.0",
52
+ "@types/mocha": "10.0.10",
53
+ "mocha": "11.7.5",
54
+ "ts-node": "10.9.2",
55
+ "nyc": "17.1.0",
56
+ "eslint": "10.13.0",
57
+ "@typescript-eslint/parser": "8.71.2",
58
+ "@typescript-eslint/eslint-plugin": "8.71.2",
59
+ "prettier": "3.6.2",
60
+ "@aws-sdk/client-sts": "3.1152.0"
61
+ },
62
+ "dependencies": {
63
+ "@cloud-idaas/core-sdk": "0.1.0-beta.1",
64
+ "@cloud-idaas/pam-client-sdk": "0.1.0-beta.1"
65
+ },
66
+ "publishConfig": {
67
+ "access": "public",
68
+ "registry": "https://registry.npmjs.org/"
69
+ },
70
+ "repository": {
71
+ "type": "git",
72
+ "url": "https://github.com/cloud-idaas/idaas-typescript-akless-aws-adapter.git"
73
+ },
74
+ "homepage": "https://github.com/cloud-idaas/idaas-typescript-akless-aws-adapter#readme",
75
+ "bugs": {
76
+ "url": "https://github.com/cloud-idaas/idaas-typescript-akless-aws-adapter/issues"
77
+ }
78
+ }