@cloud-idaas/akless-alibabacloud-adapter 0.1.0-beta.2 → 0.1.0-beta.3

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 CHANGED
@@ -1,6 +1,12 @@
1
1
  # Changelog
2
2
 
3
- ## 0.1.0-beta.2 (Unreleased)
3
+ ## 0.1.0-beta.3
4
+
5
+ - Include this adapter repository name and build version in PAM STS User-Agent headers.
6
+ - Defer Alibaba Cloud credentials loading until client creation.
7
+ - Use Core SDK and PAM SDK 0.1.0-beta.3.
8
+
9
+ ## 0.1.0-beta.2
4
10
 
5
11
  - Publish a maintenance prerelease with no API changes.
6
12
 
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import Credential from '@alicloud/credentials';
1
+ import type Credential from '@alicloud/credentials';
2
2
  import { type AklessProviderOptions, AklessProviderBuilder, CachedCloudCredentialProvider, type ExpiringCredential } from '@cloud-idaas/pam-client-sdk';
3
3
  /** Alibaba Cloud STS snapshot; inherited expiration is ISO 8601. Never log secret fields. */
4
4
  export interface AlibabaSessionCredentials extends ExpiringCredential {
package/dist/index.js CHANGED
@@ -1,13 +1,10 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.IDaaSPamAklessCredentialFactory = exports.IDaaSPamAlibabaCloudCredentialsProvider = void 0;
7
4
  exports.createAlibabaCloudCredentialsProvider = createAlibabaCloudCredentialsProvider;
8
- const credentials_1 = __importDefault(require("@alicloud/credentials"));
9
5
  const core_sdk_1 = require("@cloud-idaas/core-sdk");
10
6
  const pam_client_sdk_1 = require("@cloud-idaas/pam-client-sdk");
7
+ const sdk_version_1 = require("./sdk-version");
11
8
  /**
12
9
  * Retrieves Alibaba Cloud STS through PAM for Credentials, SLS, and OSS integrations.
13
10
  * @remarks Supports Node.js 20/22/24; interfaces checked against @alicloud/credentials 2.4.7, ali-oss 6.23.0,
@@ -39,7 +36,7 @@ class IDaaSPamAlibabaCloudCredentialsProvider extends pam_client_sdk_1.CachedClo
39
36
  expiration: new Date((0, pam_client_sdk_1.credentialExpiration)(response, token.expiration)).toISOString(),
40
37
  providerName: 'idaas_pam',
41
38
  };
42
- });
39
+ }, `idaas-typescript-akless-alibabacloud-adapter/${sdk_version_1.SDK_VERSION}`);
43
40
  }
44
41
  /** @returns The stable source identifier idaas_pam used by the official Credentials Provider protocol. */
45
42
  getProviderName() {
@@ -50,7 +47,8 @@ class IDaaSPamAlibabaCloudCredentialsProvider extends pam_client_sdk_1.CachedClo
50
47
  * @returns An official Credential instance sharing the IDaaS cache; callers must still close this provider.
51
48
  */
52
49
  toAlibabaCloudCredential() {
53
- return new credentials_1.default(null, this);
50
+ const CredentialConstructor = require('@alicloud/credentials').default;
51
+ return new CredentialConstructor(null, this);
54
52
  }
55
53
  /**
56
54
  * Retrieves a credential snapshot and an asynchronous refresh callback for ali-oss initialization.
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAwHA,sFASC;AAjID,wEAA+C;AAC/C,oDAA4D;AAC5D,gEAOqC;AA2BrC;;;;;GAKG;AACH,MAAa,uCAAwC,SAAQ,8CAAwD;IACnH;;;OAGG;IACH,MAAM,CAAC,OAAO;QACZ,OAAO,IAAI,sCAAqB,CAC9B,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,uCAAuC,CAAC,OAAO,CAAC,CAClE,CAAC;IACJ,CAAC;IACD;;;;OAIG;IACH,YAAY,OAA8B;QACxC,KAAK,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,EAAE;YAC1B,MAAM,KAAK,GAAG,QAAQ,CAAC,oBAAoB,CAAC;YAC5C,IAAI,CAAC,KAAK;gBACR,MAAM,IAAI,8BAAmB,CAC3B,0CAA0C,E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,OAAO,CAAC,SAAS,CAAC,CAAC;YAC5B,CAAC;YACD,uBAAuB,EAAE,IAAI,CAAC,GAAG,CAC/B,CAAC,EACD,IAAI,CAAC,GAAG,CAAC,MAAO,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAC/E;SACF,CAAC;IACJ,CAAC;CACF;AAtED,0FAsEC;AACD;;;;;;GAMG;AACH,SAAgB,qCAAqC,CACnD,aAA6C,EAC7C,UAAyD,EAAE;IAE3D,OAAO,IAAI,uCAAuC,CAChD,OAAO,aAAa,KAAK,QAAQ;QAC/B,CAAC,CAAC,EAAE,GAAG,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE;QAC/C,CAAC,CAAC,aAAa,CAClB,CAAC;AACJ,CAAC;AACD,6FAA6F;AAC7F,MAAa,+BAA+B;IAK1C;;;;;;OAMG;IACH,MAAM,CAAC,KAAK,CAAC,0BAA0B,CACrC,aAA6C,EAC7C,UAAyD,EAAE;QAE3D,MAAM,QAAQ,GAAG,qCAAqC,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;QAC/E,IAAI,CAAC;YACH,OAAO,MAAM,QAAQ,CAAC,aAAa,EAAE,CAAC;QACxC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,QAAQ,CAAC,KAAK,EAAE,CAAC;YACjB,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;;AAvBH,0EAwBC;AAvBC,wGAAwG;AACjG,qEAAqC,GAAG,qCAAqC,CAAC;AACrF,oGAAoG;AAC7F,4DAA4B,GAAG,qCAAqC,CAAC","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"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AA8HA,sFASC;AAtID,oDAA4D;AAC5D,gEAOqC;AACrC,+CAA4C;AA2B5C;;;;;GAKG;AACH,MAAa,uCAAwC,SAAQ,8CAAwD;IACnH;;;OAGG;IACH,MAAM,CAAC,OAAO;QACZ,OAAO,IAAI,sCAAqB,CAC9B,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,uCAAuC,CAAC,OAAO,CAAC,CAClE,CAAC;IACJ,CAAC;IACD;;;;OAIG;IACH,YAAY,OAA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,CAAC;;AAvBH,0EAwBC;AAvBC,wGAAwG;AACjG,qEAAqC,GAAG,qCAAqC,CAAC;AACrF,oGAAoG;AAC7F,4DAA4B,GAAG,qCAAqC,CAAC","sourcesContent":["import type 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';\nimport { SDK_VERSION } from './sdk-version';\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(\n options,\n (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 `idaas-typescript-akless-alibabacloud-adapter/${SDK_VERSION}`,\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 const CredentialConstructor: typeof Credential = require('@alicloud/credentials').default;\n return new CredentialConstructor(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"]}
@@ -0,0 +1 @@
1
+ export declare const SDK_VERSION: string;
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SDK_VERSION = void 0;
4
+ // Generated from package.json by scripts/build-version.cjs. Do not edit.
5
+ exports.SDK_VERSION = '0.1.0-beta.3';
6
+ //# sourceMappingURL=sdk-version.js.map
@@ -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.3';\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloud-idaas/akless-alibabacloud-adapter",
3
- "version": "0.1.0-beta.2",
3
+ "version": "0.1.0-beta.3",
4
4
  "description": "IDaaS akless-alibabacloud-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",
@@ -61,8 +61,8 @@
61
61
  "@alicloud/log": "1.2.6"
62
62
  },
63
63
  "dependencies": {
64
- "@cloud-idaas/core-sdk": "0.1.0-beta.1",
65
- "@cloud-idaas/pam-client-sdk": "0.1.0-beta.1",
64
+ "@cloud-idaas/core-sdk": "0.1.0-beta.3",
65
+ "@cloud-idaas/pam-client-sdk": "0.1.0-beta.3",
66
66
  "@alicloud/credentials": "2.4.7"
67
67
  },
68
68
  "publishConfig": {