@cloud-idaas/akless-alibabacloud-adapter 0.0.0-stage → 0.1.0-beta.1
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 +7 -0
- package/LICENSE +201 -0
- package/README.md +55 -2
- package/README_zh.md +56 -0
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +82 -0
- package/dist/index.js +118 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +4 -0
- package/examples/initialize.cjs +24 -0
- package/examples/initialize.mjs +22 -0
- package/examples/initialize.ts +22 -0
- package/package.json +78 -4
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.1.0-beta.1 (Unreleased)
|
|
4
|
+
|
|
5
|
+
- Support renewable credentials for Alibaba Cloud OpenAPI, OSS, and SLS.
|
|
6
|
+
- Improve credential expiry checks, refresh behavior, and resource cleanup.
|
|
7
|
+
- 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,56 @@
|
|
|
1
|
-
#
|
|
1
|
+
# IDaaS Alibaba Cloud Credentials Adapter
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[Simplified Chinese](README_zh.md) | English
|
|
4
|
+
|
|
5
|
+
Use IDaaS PAM temporary credentials with Alibaba Cloud OpenAPI, OSS, and SLS clients.
|
|
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-alibabacloud-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 { createAlibabaCloudCredentialsProvider } from '@cloud-idaas/akless-alibabacloud-adapter';
|
|
22
|
+
|
|
23
|
+
await IDaaSCredentialProviderFactory.init();
|
|
24
|
+
try {
|
|
25
|
+
const credentials = createAlibabaCloudCredentialsProvider('role-external-id');
|
|
26
|
+
try {
|
|
27
|
+
const officialCredential = credentials.toAlibabaCloudCredential();
|
|
28
|
+
await officialCredential.getCredential();
|
|
29
|
+
// Pass officialCredential to the OpenAPI Config credential field.
|
|
30
|
+
const ossOptions = await credentials.getOSSOptions();
|
|
31
|
+
// Pass ossOptions to new OSS({ ...ossOptions, region: '...', bucket: '...' }).
|
|
32
|
+
// SLS uses new SLS({ credentialsProvider: credentials, region: '...' }).
|
|
33
|
+
// Await all service requests before closing the provider.
|
|
34
|
+
} finally {
|
|
35
|
+
credentials.close();
|
|
36
|
+
}
|
|
37
|
+
} finally {
|
|
38
|
+
await IDaaSCredentialProviderFactory.close();
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Integration notes
|
|
43
|
+
|
|
44
|
+
Use `toAlibabaCloudCredential()` for Alibaba Cloud OpenAPI clients, `getOSSOptions()` for OSS, or the provider's `getCredentials()` integration for SLS. Install the official service client needed by your application separately.
|
|
45
|
+
|
|
46
|
+
For OSS, use the returned refresh-capable options instead of storing a one-time credential snapshot. Keep the provider open until service requests finish, then close its owned resources. Caller-supplied providers and clients remain caller-owned.
|
|
47
|
+
|
|
48
|
+
The options object accepts `roleExternalId`, `developerApiEndpoint`, `idaasInstanceId`, and `credentialProvider`. `httpConfiguration.userAgent` customizes requests to IDaaS; cloud-service requests follow their official client's configuration.
|
|
49
|
+
|
|
50
|
+
## Examples and support
|
|
51
|
+
|
|
52
|
+
See [examples](examples) for CommonJS, ESM, and TypeScript samples. Report issues through [GitHub Issues](https://github.com/cloud-idaas/idaas-typescript-akless-alibabacloud-adapter/issues). Development instructions are in the repository's [contribution guide](https://github.com/cloud-idaas/idaas-typescript-akless-alibabacloud-adapter/blob/master/CONTRIBUTING.md).
|
|
53
|
+
|
|
54
|
+
## License
|
|
55
|
+
|
|
56
|
+
[Apache License 2.0](LICENSE).
|
package/README_zh.md
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# IDaaS Alibaba Cloud Credentials Adapter
|
|
2
|
+
|
|
3
|
+
简体中文 | [English](README.md)
|
|
4
|
+
|
|
5
|
+
将 IDaaS PAM 临时凭证用于阿里云 OpenAPI、OSS 和 SLS 客户端。
|
|
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-alibabacloud-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 { createAlibabaCloudCredentialsProvider } from '@cloud-idaas/akless-alibabacloud-adapter';
|
|
22
|
+
|
|
23
|
+
await IDaaSCredentialProviderFactory.init();
|
|
24
|
+
try {
|
|
25
|
+
const credentials = createAlibabaCloudCredentialsProvider('role-external-id');
|
|
26
|
+
try {
|
|
27
|
+
const officialCredential = credentials.toAlibabaCloudCredential();
|
|
28
|
+
await officialCredential.getCredential();
|
|
29
|
+
// Pass officialCredential to the OpenAPI Config credential field.
|
|
30
|
+
const ossOptions = await credentials.getOSSOptions();
|
|
31
|
+
// Pass ossOptions to new OSS({ ...ossOptions, region: '...', bucket: '...' }).
|
|
32
|
+
// SLS uses new SLS({ credentialsProvider: credentials, region: '...' }).
|
|
33
|
+
// Await all service requests before closing the provider.
|
|
34
|
+
} finally {
|
|
35
|
+
credentials.close();
|
|
36
|
+
}
|
|
37
|
+
} finally {
|
|
38
|
+
await IDaaSCredentialProviderFactory.close();
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## 集成说明
|
|
43
|
+
|
|
44
|
+
阿里云 OpenAPI 客户端使用 `toAlibabaCloudCredential()`,OSS 使用 `getOSSOptions()`,SLS 使用提供者的 `getCredentials()` 集成入口。请另行安装应用需要的官方服务客户端。
|
|
45
|
+
|
|
46
|
+
OSS 应使用返回的可刷新配置,不要长期保存一次性凭证快照。服务请求完成前保持提供者可用,随后关闭其自有资源;调用方传入的提供者和客户端仍由调用方管理。
|
|
47
|
+
|
|
48
|
+
配置对象支持 `roleExternalId`、`developerApiEndpoint`、`idaasInstanceId` 和 `credentialProvider`。`httpConfiguration.userAgent` 定制发往 IDaaS 的请求;云服务请求遵循其官方客户端配置。
|
|
49
|
+
|
|
50
|
+
## 示例与支持
|
|
51
|
+
|
|
52
|
+
[examples](examples) 提供 CommonJS、ESM 和 TypeScript 示例。问题反馈请使用 [GitHub Issues](https://github.com/cloud-idaas/idaas-typescript-akless-alibabacloud-adapter/issues),开发说明见源码仓库的[贡献指南](https://github.com/cloud-idaas/idaas-typescript-akless-alibabacloud-adapter/blob/master/CONTRIBUTING.md)。
|
|
53
|
+
|
|
54
|
+
## 许可证
|
|
55
|
+
|
|
56
|
+
[Apache License 2.0](LICENSE)。
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './index.js';
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import Credential from '@alicloud/credentials';
|
|
2
|
+
import { type AklessProviderOptions, AklessProviderBuilder, CachedCloudCredentialProvider, type ExpiringCredential } from '@cloud-idaas/pam-client-sdk';
|
|
3
|
+
/** Alibaba Cloud STS snapshot; inherited expiration is ISO 8601. Never log secret fields. */
|
|
4
|
+
export interface AlibabaSessionCredentials extends ExpiringCredential {
|
|
5
|
+
accessKeyId: string;
|
|
6
|
+
accessKeySecret: string;
|
|
7
|
+
securityToken: string;
|
|
8
|
+
providerName: string;
|
|
9
|
+
}
|
|
10
|
+
/** Temporary credentials accepted by ali-oss; securityToken maps to stsToken at this boundary. */
|
|
11
|
+
export interface OSSSTSCredentials {
|
|
12
|
+
accessKeyId: string;
|
|
13
|
+
accessKeySecret: string;
|
|
14
|
+
stsToken: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Initialization and refresh options verified with ali-oss 6.23.0; do not include an OSS service instance.
|
|
18
|
+
* @remarks Initial fields are snapshots; refreshSTSToken reads the provider again. Call close after use.
|
|
19
|
+
*/
|
|
20
|
+
export interface OSSCredentialOptions extends OSSSTSCredentials {
|
|
21
|
+
/** Returns a valid STS snapshot; rejects when refresh fails and cached credentials have expired. */
|
|
22
|
+
refreshSTSToken: () => Promise<OSSSTSCredentials>;
|
|
23
|
+
/** Refresh interval checked before OSS requests, in milliseconds. */
|
|
24
|
+
refreshSTSTokenInterval: number;
|
|
25
|
+
/** Closes the underlying IDaaS provider, leaving the caller-owned OSS client and shared injected resources open. */
|
|
26
|
+
close(): void;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Retrieves Alibaba Cloud STS through PAM for Credentials, SLS, and OSS integrations.
|
|
30
|
+
* @remarks Supports Node.js 20/22/24; interfaces checked against @alicloud/credentials 2.4.7, ali-oss 6.23.0,
|
|
31
|
+
* and @alicloud/log 1.2.6. Inherited getCredentials returns independent snapshots; close releases only owned
|
|
32
|
+
* PAM/HTTP resources, leaving injected PAM, HTTP, and machine credential sources open.
|
|
33
|
+
*/
|
|
34
|
+
export declare class IDaaSPamAlibabaCloudCredentialsProvider extends CachedCloudCredentialProvider<AlibabaSessionCredentials> {
|
|
35
|
+
/**
|
|
36
|
+
* Creates a fluent builder without I/O; retrieval starts on first use after build.
|
|
37
|
+
* @returns A builder for the role, endpoints, and injected sources.
|
|
38
|
+
*/
|
|
39
|
+
static builder(): AklessProviderBuilder<IDaaSPamAlibabaCloudCredentialsProvider>;
|
|
40
|
+
/**
|
|
41
|
+
* Creates an independent STS provider for a role without immediately fetching credentials.
|
|
42
|
+
* @param options - Required role and optional PAM, HTTP, machine credential source, and cache options.
|
|
43
|
+
* @throws ConfigException - The role or configuration is invalid, or the default factory required for missing options is not initialized.
|
|
44
|
+
*/
|
|
45
|
+
constructor(options: AklessProviderOptions);
|
|
46
|
+
/** @returns The stable source identifier idaas_pam used by the official Credentials Provider protocol. */
|
|
47
|
+
getProviderName(): string;
|
|
48
|
+
/**
|
|
49
|
+
* Wraps this dynamic provider in an official @alicloud/credentials 2.4.7 client.
|
|
50
|
+
* @returns An official Credential instance sharing the IDaaS cache; callers must still close this provider.
|
|
51
|
+
*/
|
|
52
|
+
toAlibabaCloudCredential(): Credential;
|
|
53
|
+
/**
|
|
54
|
+
* Retrieves a credential snapshot and an asynchronous refresh callback for ali-oss initialization.
|
|
55
|
+
* @returns Options with a refresh interval in milliseconds and close; close also closes this provider.
|
|
56
|
+
* @throws IDaaSException - PAM requests, credential parsing, or refresh fail without usable unexpired cached credentials.
|
|
57
|
+
*/
|
|
58
|
+
getOSSOptions(): Promise<OSSCredentialOptions>;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Creates an Alibaba Cloud/SLS dynamic credential provider without immediately fetching STS credentials.
|
|
62
|
+
* @param roleOrOptions - Role external ID or complete configuration including the role.
|
|
63
|
+
* @param options - Additional configuration when the first argument is a string; injected sources take precedence over the default factory.
|
|
64
|
+
* @returns An independent provider; callers must call close after use to release only owned resources.
|
|
65
|
+
* @throws ConfigException - The role or configuration is invalid, or the required default factory is not initialized.
|
|
66
|
+
*/
|
|
67
|
+
export declare function createAlibabaCloudCredentialsProvider(roleOrOptions: string | AklessProviderOptions, options?: Omit<AklessProviderOptions, 'roleExternalId'>): IDaaSPamAlibabaCloudCredentialsProvider;
|
|
68
|
+
/** Alibaba Cloud beta adapter factories; do not create or manage OSS/SLS service clients. */
|
|
69
|
+
export declare class IDaaSPamAklessCredentialFactory {
|
|
70
|
+
/** Convenience provider factory with the same arguments, lifecycle, and errors as the named factory. */
|
|
71
|
+
static createAlibabaCloudCredentialsProvider: typeof createAlibabaCloudCredentialsProvider;
|
|
72
|
+
/** getCredentials integration for @alicloud/log 1.2.6; callers must close the returned provider. */
|
|
73
|
+
static createSLSCredentialsProvider: typeof createAlibabaCloudCredentialsProvider;
|
|
74
|
+
/**
|
|
75
|
+
* Creates an independent provider and retrieves ali-oss initialization and refresh options.
|
|
76
|
+
* @param roleOrOptions - Role external ID or complete configuration.
|
|
77
|
+
* @param options - Additional configuration when the role is a string.
|
|
78
|
+
* @returns Options with initial STS credentials and refreshSTSToken; call the returned close after use.
|
|
79
|
+
* @throws IDaaSException - The configuration is invalid or the initial STS request fails.
|
|
80
|
+
*/
|
|
81
|
+
static createOSSCredentialOptions(roleOrOptions: string | AklessProviderOptions, options?: Omit<AklessProviderOptions, 'roleExternalId'>): Promise<OSSCredentialOptions>;
|
|
82
|
+
}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.IDaaSPamAklessCredentialFactory = exports.IDaaSPamAlibabaCloudCredentialsProvider = void 0;
|
|
7
|
+
exports.createAlibabaCloudCredentialsProvider = createAlibabaCloudCredentialsProvider;
|
|
8
|
+
const credentials_1 = __importDefault(require("@alicloud/credentials"));
|
|
9
|
+
const core_sdk_1 = require("@cloud-idaas/core-sdk");
|
|
10
|
+
const pam_client_sdk_1 = require("@cloud-idaas/pam-client-sdk");
|
|
11
|
+
/**
|
|
12
|
+
* Retrieves Alibaba Cloud STS through PAM for Credentials, SLS, and OSS integrations.
|
|
13
|
+
* @remarks Supports Node.js 20/22/24; interfaces checked against @alicloud/credentials 2.4.7, ali-oss 6.23.0,
|
|
14
|
+
* and @alicloud/log 1.2.6. Inherited getCredentials returns independent snapshots; close releases only owned
|
|
15
|
+
* PAM/HTTP resources, leaving injected PAM, HTTP, and machine credential sources open.
|
|
16
|
+
*/
|
|
17
|
+
class IDaaSPamAlibabaCloudCredentialsProvider extends pam_client_sdk_1.CachedCloudCredentialProvider {
|
|
18
|
+
/**
|
|
19
|
+
* Creates a fluent builder without I/O; retrieval starts on first use after build.
|
|
20
|
+
* @returns A builder for the role, endpoints, and injected sources.
|
|
21
|
+
*/
|
|
22
|
+
static builder() {
|
|
23
|
+
return new pam_client_sdk_1.AklessProviderBuilder((options) => new IDaaSPamAlibabaCloudCredentialsProvider(options));
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Creates an independent STS provider for a role without immediately fetching credentials.
|
|
27
|
+
* @param options - Required role and optional PAM, HTTP, machine credential source, and cache options.
|
|
28
|
+
* @throws ConfigException - The role or configuration is invalid, or the default factory required for missing options is not initialized.
|
|
29
|
+
*/
|
|
30
|
+
constructor(options) {
|
|
31
|
+
super(options, (response) => {
|
|
32
|
+
const token = response.alibabaCloudStsToken;
|
|
33
|
+
if (!token)
|
|
34
|
+
throw new core_sdk_1.CredentialException('Response is missing alibabaCloudStsToken', 'InvalidCredentialResponse');
|
|
35
|
+
return {
|
|
36
|
+
accessKeyId: (0, pam_client_sdk_1.credentialString)(token.accessKeyId, 'accessKeyId'),
|
|
37
|
+
accessKeySecret: (0, pam_client_sdk_1.credentialString)(token.accessKeySecret, 'accessKeySecret'),
|
|
38
|
+
securityToken: (0, pam_client_sdk_1.credentialString)(token.securityToken, 'securityToken'),
|
|
39
|
+
expiration: new Date((0, pam_client_sdk_1.credentialExpiration)(response, token.expiration)).toISOString(),
|
|
40
|
+
providerName: 'idaas_pam',
|
|
41
|
+
};
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
/** @returns The stable source identifier idaas_pam used by the official Credentials Provider protocol. */
|
|
45
|
+
getProviderName() {
|
|
46
|
+
return 'idaas_pam';
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Wraps this dynamic provider in an official @alicloud/credentials 2.4.7 client.
|
|
50
|
+
* @returns An official Credential instance sharing the IDaaS cache; callers must still close this provider.
|
|
51
|
+
*/
|
|
52
|
+
toAlibabaCloudCredential() {
|
|
53
|
+
return new credentials_1.default(null, this);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Retrieves a credential snapshot and an asynchronous refresh callback for ali-oss initialization.
|
|
57
|
+
* @returns Options with a refresh interval in milliseconds and close; close also closes this provider.
|
|
58
|
+
* @throws IDaaSException - PAM requests, credential parsing, or refresh fail without usable unexpired cached credentials.
|
|
59
|
+
*/
|
|
60
|
+
async getOSSOptions() {
|
|
61
|
+
const convert = (value) => ({
|
|
62
|
+
accessKeyId: value.accessKeyId,
|
|
63
|
+
accessKeySecret: value.accessKeySecret,
|
|
64
|
+
stsToken: value.securityToken,
|
|
65
|
+
});
|
|
66
|
+
const value = await this.getCredentials();
|
|
67
|
+
this.assertAvailable(value);
|
|
68
|
+
return {
|
|
69
|
+
...convert(value),
|
|
70
|
+
close: () => this.close(),
|
|
71
|
+
refreshSTSToken: async () => {
|
|
72
|
+
const refreshed = await this.getCredentials();
|
|
73
|
+
this.assertAvailable(refreshed);
|
|
74
|
+
return convert(refreshed);
|
|
75
|
+
},
|
|
76
|
+
refreshSTSTokenInterval: Math.max(1, Math.min(300000, Math.floor((Date.parse(value.expiration) - Date.now()) / 6))),
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
exports.IDaaSPamAlibabaCloudCredentialsProvider = IDaaSPamAlibabaCloudCredentialsProvider;
|
|
81
|
+
/**
|
|
82
|
+
* Creates an Alibaba Cloud/SLS dynamic credential provider without immediately fetching STS credentials.
|
|
83
|
+
* @param roleOrOptions - Role external ID or complete configuration including the role.
|
|
84
|
+
* @param options - Additional configuration when the first argument is a string; injected sources take precedence over the default factory.
|
|
85
|
+
* @returns An independent provider; callers must call close after use to release only owned resources.
|
|
86
|
+
* @throws ConfigException - The role or configuration is invalid, or the required default factory is not initialized.
|
|
87
|
+
*/
|
|
88
|
+
function createAlibabaCloudCredentialsProvider(roleOrOptions, options = {}) {
|
|
89
|
+
return new IDaaSPamAlibabaCloudCredentialsProvider(typeof roleOrOptions === 'string'
|
|
90
|
+
? { ...options, roleExternalId: roleOrOptions }
|
|
91
|
+
: roleOrOptions);
|
|
92
|
+
}
|
|
93
|
+
/** Alibaba Cloud beta adapter factories; do not create or manage OSS/SLS service clients. */
|
|
94
|
+
class IDaaSPamAklessCredentialFactory {
|
|
95
|
+
/**
|
|
96
|
+
* Creates an independent provider and retrieves ali-oss initialization and refresh options.
|
|
97
|
+
* @param roleOrOptions - Role external ID or complete configuration.
|
|
98
|
+
* @param options - Additional configuration when the role is a string.
|
|
99
|
+
* @returns Options with initial STS credentials and refreshSTSToken; call the returned close after use.
|
|
100
|
+
* @throws IDaaSException - The configuration is invalid or the initial STS request fails.
|
|
101
|
+
*/
|
|
102
|
+
static async createOSSCredentialOptions(roleOrOptions, options = {}) {
|
|
103
|
+
const provider = createAlibabaCloudCredentialsProvider(roleOrOptions, options);
|
|
104
|
+
try {
|
|
105
|
+
return await provider.getOSSOptions();
|
|
106
|
+
}
|
|
107
|
+
catch (error) {
|
|
108
|
+
provider.close();
|
|
109
|
+
throw error;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
exports.IDaaSPamAklessCredentialFactory = IDaaSPamAklessCredentialFactory;
|
|
114
|
+
/** Convenience provider factory with the same arguments, lifecycle, and errors as the named factory. */
|
|
115
|
+
IDaaSPamAklessCredentialFactory.createAlibabaCloudCredentialsProvider = createAlibabaCloudCredentialsProvider;
|
|
116
|
+
/** getCredentials integration for @alicloud/log 1.2.6; callers must close the returned provider. */
|
|
117
|
+
IDaaSPamAklessCredentialFactory.createSLSCredentialsProvider = createAlibabaCloudCredentialsProvider;
|
|
118
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"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","sourcesContent":["import Credential from '@alicloud/credentials';\nimport { 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/** Alibaba Cloud STS snapshot; inherited expiration is ISO 8601. Never log secret fields. */\nexport interface AlibabaSessionCredentials extends ExpiringCredential {\n accessKeyId: string;\n accessKeySecret: string;\n securityToken: string;\n providerName: string;\n}\n/** Temporary credentials accepted by ali-oss; securityToken maps to stsToken at this boundary. */\nexport interface OSSSTSCredentials {\n accessKeyId: string;\n accessKeySecret: string;\n stsToken: string;\n}\n/**\n * Initialization and refresh options verified with ali-oss 6.23.0; do not include an OSS service instance.\n * @remarks Initial fields are snapshots; refreshSTSToken reads the provider again. Call close after use.\n */\nexport interface OSSCredentialOptions extends OSSSTSCredentials {\n /** Returns a valid STS snapshot; rejects when refresh fails and cached credentials have expired. */\n refreshSTSToken: () => Promise<OSSSTSCredentials>;\n /** Refresh interval checked before OSS requests, in milliseconds. */\n refreshSTSTokenInterval: number;\n /** Closes the underlying IDaaS provider, leaving the caller-owned OSS client and shared injected resources open. */\n close(): void;\n}\n/**\n * Retrieves Alibaba Cloud STS through PAM for Credentials, SLS, and OSS integrations.\n * @remarks Supports Node.js 20/22/24; interfaces checked against @alicloud/credentials 2.4.7, ali-oss 6.23.0,\n * and @alicloud/log 1.2.6. Inherited getCredentials returns independent snapshots; close releases only owned\n * PAM/HTTP resources, leaving injected PAM, HTTP, and machine credential sources open.\n */\nexport class IDaaSPamAlibabaCloudCredentialsProvider extends CachedCloudCredentialProvider<AlibabaSessionCredentials> {\n /**\n * Creates a fluent builder without I/O; retrieval starts on first use after build.\n * @returns A builder for the role, endpoints, and injected sources.\n */\n static builder(): AklessProviderBuilder<IDaaSPamAlibabaCloudCredentialsProvider> {\n return new AklessProviderBuilder(\n (options) => new IDaaSPamAlibabaCloudCredentialsProvider(options),\n );\n }\n /**\n * Creates an independent STS provider for a role without immediately fetching credentials.\n * @param options - Required role and optional PAM, HTTP, machine credential source, and cache options.\n * @throws ConfigException - The role or configuration is invalid, or the default factory required for missing options is not initialized.\n */\n constructor(options: AklessProviderOptions) {\n super(options, (response) => {\n const token = response.alibabaCloudStsToken;\n if (!token)\n throw new CredentialException(\n 'Response is missing alibabaCloudStsToken',\n 'InvalidCredentialResponse',\n );\n return {\n accessKeyId: credentialString(token.accessKeyId, 'accessKeyId'),\n accessKeySecret: credentialString(token.accessKeySecret, 'accessKeySecret'),\n securityToken: credentialString(token.securityToken, 'securityToken'),\n expiration: new Date(credentialExpiration(response, token.expiration)).toISOString(),\n providerName: 'idaas_pam',\n };\n });\n }\n /** @returns The stable source identifier idaas_pam used by the official Credentials Provider protocol. */\n getProviderName(): string {\n return 'idaas_pam';\n }\n /**\n * Wraps this dynamic provider in an official @alicloud/credentials 2.4.7 client.\n * @returns An official Credential instance sharing the IDaaS cache; callers must still close this provider.\n */\n toAlibabaCloudCredential(): Credential {\n return new Credential(null, this);\n }\n /**\n * Retrieves a credential snapshot and an asynchronous refresh callback for ali-oss initialization.\n * @returns Options with a refresh interval in milliseconds and close; close also closes this provider.\n * @throws IDaaSException - PAM requests, credential parsing, or refresh fail without usable unexpired cached credentials.\n */\n async getOSSOptions(): Promise<OSSCredentialOptions> {\n const convert = (value: AlibabaSessionCredentials): OSSSTSCredentials => ({\n accessKeyId: value.accessKeyId,\n accessKeySecret: value.accessKeySecret,\n stsToken: value.securityToken,\n });\n const value = await this.getCredentials();\n this.assertAvailable(value);\n return {\n ...convert(value),\n close: () => this.close(),\n refreshSTSToken: async () => {\n const refreshed = await this.getCredentials();\n this.assertAvailable(refreshed);\n return convert(refreshed);\n },\n refreshSTSTokenInterval: Math.max(\n 1,\n Math.min(300_000, Math.floor((Date.parse(value.expiration) - Date.now()) / 6)),\n ),\n };\n }\n}\n/**\n * Creates an Alibaba Cloud/SLS dynamic credential provider without immediately fetching STS credentials.\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 over the default factory.\n * @returns An independent provider; callers must call close after use to release only owned resources.\n * @throws ConfigException - The role or configuration is invalid, or the required default factory is not initialized.\n */\nexport function createAlibabaCloudCredentialsProvider(\n roleOrOptions: string | AklessProviderOptions,\n options: Omit<AklessProviderOptions, 'roleExternalId'> = {},\n): IDaaSPamAlibabaCloudCredentialsProvider {\n return new IDaaSPamAlibabaCloudCredentialsProvider(\n typeof roleOrOptions === 'string'\n ? { ...options, roleExternalId: roleOrOptions }\n : roleOrOptions,\n );\n}\n/** Alibaba Cloud beta adapter factories; do not create or manage OSS/SLS service clients. */\nexport class IDaaSPamAklessCredentialFactory {\n /** Convenience provider factory with the same arguments, lifecycle, and errors as the named factory. */\n static createAlibabaCloudCredentialsProvider = createAlibabaCloudCredentialsProvider;\n /** getCredentials integration for @alicloud/log 1.2.6; callers must close the returned provider. */\n static createSLSCredentialsProvider = createAlibabaCloudCredentialsProvider;\n /**\n * Creates an independent provider and retrieves ali-oss initialization and refresh options.\n * @param roleOrOptions - Role external ID or complete configuration.\n * @param options - Additional configuration when the role is a string.\n * @returns Options with initial STS credentials and refreshSTSToken; call the returned close after use.\n * @throws IDaaSException - The configuration is invalid or the initial STS request fails.\n */\n static async createOSSCredentialOptions(\n roleOrOptions: string | AklessProviderOptions,\n options: Omit<AklessProviderOptions, 'roleExternalId'> = {},\n ): Promise<OSSCredentialOptions> {\n const provider = createAlibabaCloudCredentialsProvider(roleOrOptions, options);\n try {\n return await provider.getOSSOptions();\n } catch (error) {\n provider.close();\n throw error;\n }\n }\n}\n"]}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import api from './index.js';
|
|
2
|
+
export const IDaaSPamAlibabaCloudCredentialsProvider = api.IDaaSPamAlibabaCloudCredentialsProvider;
|
|
3
|
+
export const IDaaSPamAklessCredentialFactory = api.IDaaSPamAklessCredentialFactory;
|
|
4
|
+
export const createAlibabaCloudCredentialsProvider = api.createAlibabaCloudCredentialsProvider;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const { IDaaSCredentialProviderFactory } = require('@cloud-idaas/core-sdk');
|
|
2
|
+
const {
|
|
3
|
+
createAlibabaCloudCredentialsProvider,
|
|
4
|
+
} = require('@cloud-idaas/akless-alibabacloud-adapter');
|
|
5
|
+
|
|
6
|
+
async function main() {
|
|
7
|
+
await IDaaSCredentialProviderFactory.init();
|
|
8
|
+
try {
|
|
9
|
+
const provider = createAlibabaCloudCredentialsProvider(
|
|
10
|
+
process.env.IDAAS_ROLE_EXTERNAL_ID || 'role-id',
|
|
11
|
+
);
|
|
12
|
+
try {
|
|
13
|
+
await provider.toAlibabaCloudCredential().getCredential();
|
|
14
|
+
} finally {
|
|
15
|
+
provider.close();
|
|
16
|
+
}
|
|
17
|
+
} finally {
|
|
18
|
+
await IDaaSCredentialProviderFactory.close();
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
main().catch((error) => {
|
|
22
|
+
console.error(error instanceof Error ? error.message : 'SDK call failed');
|
|
23
|
+
process.exitCode = 1;
|
|
24
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { IDaaSCredentialProviderFactory } from '@cloud-idaas/core-sdk';
|
|
2
|
+
import { createAlibabaCloudCredentialsProvider } from '@cloud-idaas/akless-alibabacloud-adapter';
|
|
3
|
+
|
|
4
|
+
async function main() {
|
|
5
|
+
await IDaaSCredentialProviderFactory.init();
|
|
6
|
+
try {
|
|
7
|
+
const provider = createAlibabaCloudCredentialsProvider(
|
|
8
|
+
process.env.IDAAS_ROLE_EXTERNAL_ID || 'role-id',
|
|
9
|
+
);
|
|
10
|
+
try {
|
|
11
|
+
await provider.toAlibabaCloudCredential().getCredential();
|
|
12
|
+
} finally {
|
|
13
|
+
provider.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 { createAlibabaCloudCredentialsProvider } from '@cloud-idaas/akless-alibabacloud-adapter';
|
|
3
|
+
|
|
4
|
+
async function main() {
|
|
5
|
+
await IDaaSCredentialProviderFactory.init();
|
|
6
|
+
try {
|
|
7
|
+
const provider = createAlibabaCloudCredentialsProvider(
|
|
8
|
+
process.env.IDAAS_ROLE_EXTERNAL_ID || 'role-id',
|
|
9
|
+
);
|
|
10
|
+
try {
|
|
11
|
+
await provider.toAlibabaCloudCredential().getCredential();
|
|
12
|
+
} finally {
|
|
13
|
+
provider.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,80 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloud-idaas/akless-alibabacloud-adapter",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0-beta.1",
|
|
4
|
+
"description": "IDaaS akless-alibabacloud-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-alibabacloud-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
|
+
"ali-oss": "6.23.0",
|
|
61
|
+
"@alicloud/log": "1.2.6"
|
|
62
|
+
},
|
|
63
|
+
"dependencies": {
|
|
64
|
+
"@cloud-idaas/core-sdk": "0.1.0-beta.1",
|
|
65
|
+
"@cloud-idaas/pam-client-sdk": "0.1.0-beta.1",
|
|
66
|
+
"@alicloud/credentials": "2.4.7"
|
|
67
|
+
},
|
|
68
|
+
"publishConfig": {
|
|
69
|
+
"access": "public",
|
|
70
|
+
"registry": "https://registry.npmjs.org/"
|
|
71
|
+
},
|
|
72
|
+
"repository": {
|
|
73
|
+
"type": "git",
|
|
74
|
+
"url": "https://github.com/cloud-idaas/idaas-typescript-akless-alibabacloud-adapter.git"
|
|
75
|
+
},
|
|
76
|
+
"homepage": "https://github.com/cloud-idaas/idaas-typescript-akless-alibabacloud-adapter#readme",
|
|
77
|
+
"bugs": {
|
|
78
|
+
"url": "https://github.com/cloud-idaas/idaas-typescript-akless-alibabacloud-adapter/issues"
|
|
79
|
+
}
|
|
80
|
+
}
|