@cloud-idaas/akless-tencent-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,11 @@
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
+ - Use Core SDK and PAM SDK 0.1.0-beta.3.
7
+
8
+ ## 0.1.0-beta.2
4
9
 
5
10
  - Publish a maintenance prerelease with no API changes.
6
11
 
package/dist/index.js CHANGED
@@ -5,6 +5,7 @@ exports.createTencentCloudCredentialsProvider = createTencentCloudCredentialsPro
5
5
  exports.createTencentCloudCOSCredentialsProvider = createTencentCloudCOSCredentialsProvider;
6
6
  const core_sdk_1 = require("@cloud-idaas/core-sdk");
7
7
  const pam_client_sdk_1 = require("@cloud-idaas/pam-client-sdk");
8
+ const sdk_version_1 = require("./sdk-version");
8
9
  /**
9
10
  * Provides Tencent Cloud DynamicCredential and COS beta integrations on Node.js 20/22/24.
10
11
  * @remarks The callback protocol was checked against cos-nodejs-sdk-v5 3.0.0. Inherited getCredentials returns
@@ -40,7 +41,7 @@ class IDaaSPamTencentCloudCredentialsProvider extends pam_client_sdk_1.CachedClo
40
41
  token: (0, pam_client_sdk_1.credentialString)(token.token, 'token'),
41
42
  expiration: new Date(expiration).toISOString(),
42
43
  };
43
- });
44
+ }, `idaas-typescript-akless-tencent-adapter/${sdk_version_1.SDK_VERSION}`);
44
45
  }
45
46
  /**
46
47
  * Retrieves current credentials for the Tencent Cloud SDK.
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAwKA,sFASC;AAUD,4FASC;AApMD,oDAAmG;AACnG,gEAOqC;AAsCrC;;;;;GAKG;AACH,MAAa,uCAAwC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QAAQ,GAAG,QAAQ,CAAC,qBAAqB,CAAC,OAAO,CAA6B,CAAC;IACrF,QAAQ,CAAC,KAAK,GAAG,GAAG,EAAE,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;IACxC,OAAO,QAAQ,CAAC;AAClB,CAAC;AACD,0FAA0F;AAC1F,MAAa,+BAA+B;;AAA5C,0EAKC;AAJC,0FAA0F;AACnF,qEAAqC,GAAG,qCAAqC,CAAC;AACrF,2FAA2F;AACpF,wEAAwC,GAAG,wCAAwC,CAAC","sourcesContent":["import { CredentialException, type IDaaSException, isIDaaSException } 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/** Generic PAM STS snapshot; expiration is ISO 8601 and tmpSecret fields are renamed at the adapter boundary. */\nexport interface TencentSessionCredentials extends ExpiringCredential {\n secretId: string;\n secretKey: string;\n token: string;\n}\n/** Fields required by Tencent Cloud DynamicCredential.getCredential. */\nexport interface TencentCredential {\n secretId: string;\n secretKey: string;\n token: string;\n}\n/** Temporary credential callback data accepted by cos-nodejs-sdk-v5 3.0.0. */\nexport interface COSCredential {\n TmpSecretId: string;\n TmpSecretKey: string;\n SecurityToken: string;\n /** Zero means the server did not provide an issuance time; COS uses its default time policy. */\n StartTime: number;\n /** Unix seconds; local time must not extend the server-provided expiration. */\n ExpiredTime: number;\n}\n/**\n * Structural COS getAuthorization callback; starts no background I/O before credentials are requested.\n * @param options - Request context supplied by COS; currently unused by this adapter.\n * @param callback - Credential callback that must complete; COS has no separate error argument.\n */\nexport type COSGetAuthorization = (\n options: unknown,\n callback: (value: COSCredential) => void,\n) => void;\n/** COS callback created by an independent factory, with cleanup for the underlying provider. */\nexport interface COSAuthorizationProvider extends COSGetAuthorization {\n /** Closes owned PAM/HTTP resources, leaving the COS client and injected shared sources open. */\n close(): void;\n}\n/**\n * Provides Tencent Cloud DynamicCredential and COS beta integrations on Node.js 20/22/24.\n * @remarks The callback protocol was checked against cos-nodejs-sdk-v5 3.0.0. Inherited getCredentials returns\n * independent STS snapshots. close releases only provider-owned resources; injected PAM, HTTP, and\n * machine credential sources remain caller-owned.\n */\nexport class IDaaSPamTencentCloudCredentialsProvider extends CachedCloudCredentialProvider<TencentSessionCredentials> {\n /** @returns A configuration builder without I/O; STS retrieval starts on first use after build. */\n static builder(): AklessProviderBuilder<IDaaSPamTencentCloudCredentialsProvider> {\n return new AklessProviderBuilder(\n (options) => new IDaaSPamTencentCloudCredentialsProvider(options),\n );\n }\n /**\n * Creates a Tencent Cloud provider without fetching STS credentials.\n * @param options - Required role and optional PAM, HTTP, machine credential source, and cache configuration.\n * @throws ConfigException - The role or configuration is invalid, or the required default factory is not initialized.\n */\n constructor(options: AklessProviderOptions) {\n super(options, (response) => {\n const token = response.tencentCloudStsToken;\n if (!token)\n throw new CredentialException(\n 'Response is missing tencentCloudStsToken',\n 'InvalidCredentialResponse',\n );\n let expiration = credentialExpiration(response, token.expiration);\n if (token.expiredTime !== undefined) {\n if (typeof token.expiredTime !== 'number' || !Number.isFinite(token.expiredTime))\n throw new CredentialException('expiredTime is invalid', 'InvalidExpiration');\n expiration = Math.min(expiration, token.expiredTime * 1000);\n if (!Number.isFinite(expiration) || expiration <= Date.now())\n throw new CredentialException('expiredTime has expired', 'InvalidExpiration');\n }\n return {\n secretId: credentialString(token.tmpSecretId, 'tmpSecretId'),\n secretKey: credentialString(token.tmpSecretKey, 'tmpSecretKey'),\n token: credentialString(token.token, 'token'),\n expiration: new Date(expiration).toISOString(),\n };\n });\n }\n /**\n * Retrieves current credentials for the Tencent Cloud SDK.\n * @returns An independent secretId/secretKey/token snapshot.\n * @throws IDaaSException - Retrieval fails without usable unexpired cached credentials, or the provider is closed.\n */\n async getCredential(): Promise<TencentCredential> {\n const value = await this.getCredentials();\n this.assertAvailable(value);\n return { secretId: value.secretId, secretKey: value.secretKey, token: value.token };\n }\n /**\n * Retrieves COS temporary credentials without inventing a server issuance time.\n * @returns Independent callback data; ExpiredTime uses Unix seconds and StartTime=0 selects the COS default policy.\n * @throws IDaaSException - Retrieval or parsing fails, refresh fails after expiration, or the provider is closed.\n */\n async getCOSCredential(): Promise<COSCredential> {\n const value = await this.getCredentials();\n this.assertAvailable(value);\n return {\n TmpSecretId: value.secretId,\n TmpSecretKey: value.secretKey,\n SecurityToken: value.token,\n StartTime: 0,\n ExpiredTime: Math.floor(Date.parse(value.expiration) / 1000),\n };\n }\n /**\n * Creates a COS getAuthorization callback sharing this provider.\n * @param onError - Optional observer of classified errors; observer exceptions do not prevent COS request completion.\n * @returns A callback sharing the existing cache; the caller must still close this provider.\n * @remarks COS only has a success-data callback. Retrieval failures notify the observer and pass invalid credentials to\n * trigger the official argument-error path, avoiding hung requests without inventing a COS error argument.\n */\n toCOSGetAuthorization(onError?: (error: IDaaSException) => void): COSGetAuthorization {\n const report = (error: unknown) => {\n try {\n onError?.(\n isIDaaSException(error)\n ? error\n : new CredentialException(\n 'COS credential retrieval failed',\n 'CredentialRetrievalFailed',\n ),\n );\n } catch {\n /* Error observers must not prevent request completion. */\n }\n };\n return (_options, callback) => {\n const fail = (error: unknown) => {\n report(error);\n callback({\n TmpSecretId: '',\n TmpSecretKey: '',\n SecurityToken: '',\n StartTime: 0,\n ExpiredTime: 0,\n });\n };\n void this.getCOSCredential()\n .then((value) => {\n try {\n this.assertAvailable({ expiration: new Date(value.ExpiredTime * 1000).toISOString() });\n } catch (error) {\n fail(error);\n return;\n }\n callback(value);\n }, fail)\n .catch(report);\n };\n }\n}\n/**\n * Creates a Tencent Cloud DynamicCredential 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.\n * @returns An independent provider; callers must close it after use, with owned and shared resources managed separately.\n * @throws ConfigException - The configuration is invalid or the required default factory is not initialized.\n */\nexport function createTencentCloudCredentialsProvider(\n roleOrOptions: string | AklessProviderOptions,\n options: Omit<AklessProviderOptions, 'roleExternalId'> = {},\n): IDaaSPamTencentCloudCredentialsProvider {\n return new IDaaSPamTencentCloudCredentialsProvider(\n typeof roleOrOptions === 'string'\n ? { ...options, roleExternalId: roleOrOptions }\n : roleOrOptions,\n );\n}\n/**\n * Creates an independent dynamic credential callback for cos-nodejs-sdk-v5 3.0.0.\n * @param roleOrOptions - Role external ID or complete configuration.\n * @param options - Additional configuration when the first argument is a string.\n * @param onError - Optional classified-error observer; its exceptions are isolated and cannot prevent COS request completion.\n * @returns A callback with close; close after use without closing the COS client or shared injected resources.\n * @throws ConfigException - The configuration is invalid or the required default factory is not initialized.\n * @remarks Asynchronous retrieval failures complete through the observer and the COS invalid-credential error path.\n */\nexport function createTencentCloudCOSCredentialsProvider(\n roleOrOptions: string | AklessProviderOptions,\n options: Omit<AklessProviderOptions, 'roleExternalId'> = {},\n onError?: (error: IDaaSException) => void,\n): COSAuthorizationProvider {\n const provider = createTencentCloudCredentialsProvider(roleOrOptions, options);\n const callback = provider.toCOSGetAuthorization(onError) as COSAuthorizationProvider;\n callback.close = () => provider.close();\n return callback;\n}\n/** Tencent Cloud beta convenience factories; do not create SDK or COS service clients. */\nexport class IDaaSPamAklessCredentialFactory {\n /** Arguments, errors, and resource ownership match the named general provider factory. */\n static createTencentCloudCredentialsProvider = createTencentCloudCredentialsProvider;\n /** Arguments, callback error handling, and close semantics match the named COS factory. */\n static createTencentCloudCOSCredentialsProvider = createTencentCloudCOSCredentialsProvider;\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AA6KA,sFASC;AAUD,4FASC;AAzMD,oDAAmG;AACnG,gEAOqC;AACrC,+CAA4C;AAsC5C;;;;;GAKG;AACH,MAAa,uCAAwC,SAAQ,8CAAwD;IACnH,mGAAmG;IACnG,MAAM,CAAC,OAAO;QACZ,OAAO,IAAI,sCAAqB,CAC9B,CAAC,OAAO,EAAE,EAAE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G,GAAG,EAAE,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;IACxC,OAAO,QAAQ,CAAC;AAClB,CAAC;AACD,0FAA0F;AAC1F,MAAa,+BAA+B;;AAA5C,0EAKC;AAJC,0FAA0F;AACnF,qEAAqC,GAAG,qCAAqC,CAAC;AACrF,2FAA2F;AACpF,wEAAwC,GAAG,wCAAwC,CAAC","sourcesContent":["import { CredentialException, type IDaaSException, isIDaaSException } 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/** Generic PAM STS snapshot; expiration is ISO 8601 and tmpSecret fields are renamed at the adapter boundary. */\nexport interface TencentSessionCredentials extends ExpiringCredential {\n secretId: string;\n secretKey: string;\n token: string;\n}\n/** Fields required by Tencent Cloud DynamicCredential.getCredential. */\nexport interface TencentCredential {\n secretId: string;\n secretKey: string;\n token: string;\n}\n/** Temporary credential callback data accepted by cos-nodejs-sdk-v5 3.0.0. */\nexport interface COSCredential {\n TmpSecretId: string;\n TmpSecretKey: string;\n SecurityToken: string;\n /** Zero means the server did not provide an issuance time; COS uses its default time policy. */\n StartTime: number;\n /** Unix seconds; local time must not extend the server-provided expiration. */\n ExpiredTime: number;\n}\n/**\n * Structural COS getAuthorization callback; starts no background I/O before credentials are requested.\n * @param options - Request context supplied by COS; currently unused by this adapter.\n * @param callback - Credential callback that must complete; COS has no separate error argument.\n */\nexport type COSGetAuthorization = (\n options: unknown,\n callback: (value: COSCredential) => void,\n) => void;\n/** COS callback created by an independent factory, with cleanup for the underlying provider. */\nexport interface COSAuthorizationProvider extends COSGetAuthorization {\n /** Closes owned PAM/HTTP resources, leaving the COS client and injected shared sources open. */\n close(): void;\n}\n/**\n * Provides Tencent Cloud DynamicCredential and COS beta integrations on Node.js 20/22/24.\n * @remarks The callback protocol was checked against cos-nodejs-sdk-v5 3.0.0. Inherited getCredentials returns\n * independent STS snapshots. close releases only provider-owned resources; injected PAM, HTTP, and\n * machine credential sources remain caller-owned.\n */\nexport class IDaaSPamTencentCloudCredentialsProvider extends CachedCloudCredentialProvider<TencentSessionCredentials> {\n /** @returns A configuration builder without I/O; STS retrieval starts on first use after build. */\n static builder(): AklessProviderBuilder<IDaaSPamTencentCloudCredentialsProvider> {\n return new AklessProviderBuilder(\n (options) => new IDaaSPamTencentCloudCredentialsProvider(options),\n );\n }\n /**\n * Creates a Tencent Cloud provider without fetching STS credentials.\n * @param options - Required role and optional PAM, HTTP, machine credential source, and cache configuration.\n * @throws ConfigException - The role or configuration is invalid, or the required default factory is not initialized.\n */\n constructor(options: AklessProviderOptions) {\n super(\n options,\n (response) => {\n const token = response.tencentCloudStsToken;\n if (!token)\n throw new CredentialException(\n 'Response is missing tencentCloudStsToken',\n 'InvalidCredentialResponse',\n );\n let expiration = credentialExpiration(response, token.expiration);\n if (token.expiredTime !== undefined) {\n if (typeof token.expiredTime !== 'number' || !Number.isFinite(token.expiredTime))\n throw new CredentialException('expiredTime is invalid', 'InvalidExpiration');\n expiration = Math.min(expiration, token.expiredTime * 1000);\n if (!Number.isFinite(expiration) || expiration <= Date.now())\n throw new CredentialException('expiredTime has expired', 'InvalidExpiration');\n }\n return {\n secretId: credentialString(token.tmpSecretId, 'tmpSecretId'),\n secretKey: credentialString(token.tmpSecretKey, 'tmpSecretKey'),\n token: credentialString(token.token, 'token'),\n expiration: new Date(expiration).toISOString(),\n };\n },\n `idaas-typescript-akless-tencent-adapter/${SDK_VERSION}`,\n );\n }\n /**\n * Retrieves current credentials for the Tencent Cloud SDK.\n * @returns An independent secretId/secretKey/token snapshot.\n * @throws IDaaSException - Retrieval fails without usable unexpired cached credentials, or the provider is closed.\n */\n async getCredential(): Promise<TencentCredential> {\n const value = await this.getCredentials();\n this.assertAvailable(value);\n return { secretId: value.secretId, secretKey: value.secretKey, token: value.token };\n }\n /**\n * Retrieves COS temporary credentials without inventing a server issuance time.\n * @returns Independent callback data; ExpiredTime uses Unix seconds and StartTime=0 selects the COS default policy.\n * @throws IDaaSException - Retrieval or parsing fails, refresh fails after expiration, or the provider is closed.\n */\n async getCOSCredential(): Promise<COSCredential> {\n const value = await this.getCredentials();\n this.assertAvailable(value);\n return {\n TmpSecretId: value.secretId,\n TmpSecretKey: value.secretKey,\n SecurityToken: value.token,\n StartTime: 0,\n ExpiredTime: Math.floor(Date.parse(value.expiration) / 1000),\n };\n }\n /**\n * Creates a COS getAuthorization callback sharing this provider.\n * @param onError - Optional observer of classified errors; observer exceptions do not prevent COS request completion.\n * @returns A callback sharing the existing cache; the caller must still close this provider.\n * @remarks COS only has a success-data callback. Retrieval failures notify the observer and pass invalid credentials to\n * trigger the official argument-error path, avoiding hung requests without inventing a COS error argument.\n */\n toCOSGetAuthorization(onError?: (error: IDaaSException) => void): COSGetAuthorization {\n const report = (error: unknown) => {\n try {\n onError?.(\n isIDaaSException(error)\n ? error\n : new CredentialException(\n 'COS credential retrieval failed',\n 'CredentialRetrievalFailed',\n ),\n );\n } catch {\n /* Error observers must not prevent request completion. */\n }\n };\n return (_options, callback) => {\n const fail = (error: unknown) => {\n report(error);\n callback({\n TmpSecretId: '',\n TmpSecretKey: '',\n SecurityToken: '',\n StartTime: 0,\n ExpiredTime: 0,\n });\n };\n void this.getCOSCredential()\n .then((value) => {\n try {\n this.assertAvailable({ expiration: new Date(value.ExpiredTime * 1000).toISOString() });\n } catch (error) {\n fail(error);\n return;\n }\n callback(value);\n }, fail)\n .catch(report);\n };\n }\n}\n/**\n * Creates a Tencent Cloud DynamicCredential 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.\n * @returns An independent provider; callers must close it after use, with owned and shared resources managed separately.\n * @throws ConfigException - The configuration is invalid or the required default factory is not initialized.\n */\nexport function createTencentCloudCredentialsProvider(\n roleOrOptions: string | AklessProviderOptions,\n options: Omit<AklessProviderOptions, 'roleExternalId'> = {},\n): IDaaSPamTencentCloudCredentialsProvider {\n return new IDaaSPamTencentCloudCredentialsProvider(\n typeof roleOrOptions === 'string'\n ? { ...options, roleExternalId: roleOrOptions }\n : roleOrOptions,\n );\n}\n/**\n * Creates an independent dynamic credential callback for cos-nodejs-sdk-v5 3.0.0.\n * @param roleOrOptions - Role external ID or complete configuration.\n * @param options - Additional configuration when the first argument is a string.\n * @param onError - Optional classified-error observer; its exceptions are isolated and cannot prevent COS request completion.\n * @returns A callback with close; close after use without closing the COS client or shared injected resources.\n * @throws ConfigException - The configuration is invalid or the required default factory is not initialized.\n * @remarks Asynchronous retrieval failures complete through the observer and the COS invalid-credential error path.\n */\nexport function createTencentCloudCOSCredentialsProvider(\n roleOrOptions: string | AklessProviderOptions,\n options: Omit<AklessProviderOptions, 'roleExternalId'> = {},\n onError?: (error: IDaaSException) => void,\n): COSAuthorizationProvider {\n const provider = createTencentCloudCredentialsProvider(roleOrOptions, options);\n const callback = provider.toCOSGetAuthorization(onError) as COSAuthorizationProvider;\n callback.close = () => provider.close();\n return callback;\n}\n/** Tencent Cloud beta convenience factories; do not create SDK or COS service clients. */\nexport class IDaaSPamAklessCredentialFactory {\n /** Arguments, errors, and resource ownership match the named general provider factory. */\n static createTencentCloudCredentialsProvider = createTencentCloudCredentialsProvider;\n /** Arguments, callback error handling, and close semantics match the named COS factory. */\n static createTencentCloudCOSCredentialsProvider = createTencentCloudCOSCredentialsProvider;\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-tencent-adapter",
3
- "version": "0.1.0-beta.2",
3
+ "version": "0.1.0-beta.3",
4
4
  "description": "IDaaS akless-tencent-adapter for TypeScript and JavaScript (Node.js)",
5
5
  "license": "Apache-2.0",
6
6
  "type": "commonjs",
@@ -30,8 +30,8 @@
30
30
  "node": ">=20.0.0"
31
31
  },
32
32
  "scripts": {
33
- "build": "tsc -p tsconfig.json && node scripts/build-esm.cjs",
34
- "typecheck": "tsc --noEmit -p tsconfig.json && tsc --noEmit -p test/tsconfig.json",
33
+ "build": "node scripts/build-version.cjs && tsc -p tsconfig.json && node scripts/build-esm.cjs",
34
+ "typecheck": "node scripts/build-version.cjs && tsc --noEmit -p tsconfig.json && tsc --noEmit -p test/tsconfig.json",
35
35
  "test": "npm run build && nyc mocha --require ./test/register.cjs \"test/**/*.test.{ts,cjs}\"",
36
36
  "prepack": "npm run build",
37
37
  "lint": "eslint src test",
@@ -60,8 +60,8 @@
60
60
  "cos-nodejs-sdk-v5": "3.0.0"
61
61
  },
62
62
  "dependencies": {
63
- "@cloud-idaas/core-sdk": "0.1.0-beta.1",
64
- "@cloud-idaas/pam-client-sdk": "0.1.0-beta.1"
63
+ "@cloud-idaas/core-sdk": "0.1.0-beta.3",
64
+ "@cloud-idaas/pam-client-sdk": "0.1.0-beta.3"
65
65
  },
66
66
  "publishConfig": {
67
67
  "access": "public",