@aws-sdk/credential-provider-cognito-identity 3.712.0 → 3.714.0

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/dist-cjs/index.js CHANGED
@@ -70,10 +70,14 @@ __name(resolveLogins, "resolveLogins");
70
70
 
71
71
  // src/fromCognitoIdentity.ts
72
72
  function fromCognitoIdentity(parameters) {
73
- return async () => {
74
- var _a, _b, _c;
73
+ return async (awsIdentityProperties) => {
74
+ var _a;
75
75
  (_a = parameters.logger) == null ? void 0 : _a.debug("@aws-sdk/credential-provider-cognito-identity - fromCognitoIdentity");
76
76
  const { GetCredentialsForIdentityCommand: GetCredentialsForIdentityCommand2, CognitoIdentityClient: CognitoIdentityClient2 } = await Promise.resolve().then(() => (init_loadCognitoIdentity(), loadCognitoIdentity_exports));
77
+ const fromConfigs = /* @__PURE__ */ __name((property) => {
78
+ var _a2, _b, _c;
79
+ return ((_a2 = parameters.clientConfig) == null ? void 0 : _a2[property]) ?? ((_b = parameters.parentClientConfig) == null ? void 0 : _b[property]) ?? ((_c = awsIdentityProperties == null ? void 0 : awsIdentityProperties.callerClientConfig) == null ? void 0 : _c[property]);
80
+ }, "fromConfigs");
77
81
  const {
78
82
  Credentials: {
79
83
  AccessKeyId = throwOnMissingAccessKeyId(parameters.logger),
@@ -83,7 +87,8 @@ function fromCognitoIdentity(parameters) {
83
87
  } = throwOnMissingCredentials(parameters.logger)
84
88
  } = await (parameters.client ?? new CognitoIdentityClient2(
85
89
  Object.assign({}, parameters.clientConfig ?? {}, {
86
- region: ((_b = parameters.clientConfig) == null ? void 0 : _b.region) ?? ((_c = parameters.parentClientConfig) == null ? void 0 : _c.region)
90
+ region: fromConfigs("region"),
91
+ profile: fromConfigs("profile")
87
92
  })
88
93
  )).send(
89
94
  new GetCredentialsForIdentityCommand2({
@@ -238,10 +243,17 @@ function fromCognitoIdentityPool({
238
243
  }) {
239
244
  logger == null ? void 0 : logger.debug("@aws-sdk/credential-provider-cognito-identity - fromCognitoIdentity");
240
245
  const cacheKey = userIdentifier ? `aws:cognito-identity-credentials:${identityPoolId}:${userIdentifier}` : void 0;
241
- let provider = /* @__PURE__ */ __name(async () => {
246
+ let provider = /* @__PURE__ */ __name(async (awsIdentityProperties) => {
242
247
  const { GetIdCommand: GetIdCommand2, CognitoIdentityClient: CognitoIdentityClient2 } = await Promise.resolve().then(() => (init_loadCognitoIdentity(), loadCognitoIdentity_exports));
248
+ const fromConfigs = /* @__PURE__ */ __name((property) => {
249
+ var _a;
250
+ return (clientConfig == null ? void 0 : clientConfig[property]) ?? (parentClientConfig == null ? void 0 : parentClientConfig[property]) ?? ((_a = awsIdentityProperties == null ? void 0 : awsIdentityProperties.callerClientConfig) == null ? void 0 : _a[property]);
251
+ }, "fromConfigs");
243
252
  const _client = client ?? new CognitoIdentityClient2(
244
- Object.assign({}, clientConfig ?? {}, { region: (clientConfig == null ? void 0 : clientConfig.region) ?? (parentClientConfig == null ? void 0 : parentClientConfig.region) })
253
+ Object.assign({}, clientConfig ?? {}, {
254
+ region: fromConfigs("region"),
255
+ profile: fromConfigs("profile")
256
+ })
245
257
  );
246
258
  let identityId = cacheKey && await cache.getItem(cacheKey);
247
259
  if (!identityId) {
@@ -264,9 +276,9 @@ function fromCognitoIdentityPool({
264
276
  logins,
265
277
  identityId
266
278
  });
267
- return provider();
279
+ return provider(awsIdentityProperties);
268
280
  }, "provider");
269
- return () => provider().catch(async (err) => {
281
+ return (awsIdentityProperties) => provider(awsIdentityProperties).catch(async (err) => {
270
282
  if (cacheKey) {
271
283
  Promise.resolve(cache.removeItem(cacheKey)).catch(() => {
272
284
  });
@@ -1,12 +1,16 @@
1
1
  import { CredentialsProviderError } from "@smithy/property-provider";
2
2
  import { resolveLogins } from "./resolveLogins";
3
3
  export function fromCognitoIdentity(parameters) {
4
- return async () => {
4
+ return async (awsIdentityProperties) => {
5
5
  parameters.logger?.debug("@aws-sdk/credential-provider-cognito-identity - fromCognitoIdentity");
6
6
  const { GetCredentialsForIdentityCommand, CognitoIdentityClient } = await import("./loadCognitoIdentity");
7
+ const fromConfigs = (property) => parameters.clientConfig?.[property] ??
8
+ parameters.parentClientConfig?.[property] ??
9
+ awsIdentityProperties?.callerClientConfig?.[property];
7
10
  const { Credentials: { AccessKeyId = throwOnMissingAccessKeyId(parameters.logger), Expiration, SecretKey = throwOnMissingSecretKey(parameters.logger), SessionToken, } = throwOnMissingCredentials(parameters.logger), } = await (parameters.client ??
8
11
  new CognitoIdentityClient(Object.assign({}, parameters.clientConfig ?? {}, {
9
- region: parameters.clientConfig?.region ?? parameters.parentClientConfig?.region,
12
+ region: fromConfigs("region"),
13
+ profile: fromConfigs("profile"),
10
14
  }))).send(new GetCredentialsForIdentityCommand({
11
15
  CustomRoleArn: parameters.customRoleArn,
12
16
  IdentityId: parameters.identityId,
@@ -7,10 +7,16 @@ export function fromCognitoIdentityPool({ accountId, cache = localStorage(), cli
7
7
  const cacheKey = userIdentifier
8
8
  ? `aws:cognito-identity-credentials:${identityPoolId}:${userIdentifier}`
9
9
  : undefined;
10
- let provider = async () => {
10
+ let provider = async (awsIdentityProperties) => {
11
11
  const { GetIdCommand, CognitoIdentityClient } = await import("./loadCognitoIdentity");
12
+ const fromConfigs = (property) => clientConfig?.[property] ??
13
+ parentClientConfig?.[property] ??
14
+ awsIdentityProperties?.callerClientConfig?.[property];
12
15
  const _client = client ??
13
- new CognitoIdentityClient(Object.assign({}, clientConfig ?? {}, { region: clientConfig?.region ?? parentClientConfig?.region }));
16
+ new CognitoIdentityClient(Object.assign({}, clientConfig ?? {}, {
17
+ region: fromConfigs("region"),
18
+ profile: fromConfigs("profile"),
19
+ }));
14
20
  let identityId = (cacheKey && (await cache.getItem(cacheKey)));
15
21
  if (!identityId) {
16
22
  const { IdentityId = throwOnMissingId(logger) } = await _client.send(new GetIdCommand({
@@ -29,9 +35,9 @@ export function fromCognitoIdentityPool({ accountId, cache = localStorage(), cli
29
35
  logins,
30
36
  identityId,
31
37
  });
32
- return provider();
38
+ return provider(awsIdentityProperties);
33
39
  };
34
- return () => provider().catch(async (err) => {
40
+ return (awsIdentityProperties) => provider(awsIdentityProperties).catch(async (err) => {
35
41
  if (cacheKey) {
36
42
  Promise.resolve(cache.removeItem(cacheKey)).catch(() => { });
37
43
  }
@@ -1,5 +1,5 @@
1
- import type { CredentialProviderOptions } from "@aws-sdk/types";
2
- import { AwsCredentialIdentity, Provider } from "@smithy/types";
1
+ import type { CredentialProviderOptions, RuntimeConfigIdentityProvider } from "@aws-sdk/types";
2
+ import type { AwsCredentialIdentity } from "@smithy/types";
3
3
  import { CognitoProviderParameters } from "./CognitoProviderParameters";
4
4
  /**
5
5
  * @internal
@@ -13,7 +13,7 @@ export interface CognitoIdentityCredentials extends AwsCredentialIdentity {
13
13
  /**
14
14
  * @internal
15
15
  */
16
- export type CognitoIdentityCredentialProvider = Provider<CognitoIdentityCredentials>;
16
+ export type CognitoIdentityCredentialProvider = RuntimeConfigIdentityProvider<CognitoIdentityCredentials>;
17
17
  /**
18
18
  * @internal
19
19
  *
@@ -1,11 +1,14 @@
1
- import { CredentialProviderOptions } from "@aws-sdk/types";
2
- import { AwsCredentialIdentity, Provider } from "@smithy/types";
1
+ import {
2
+ CredentialProviderOptions,
3
+ RuntimeConfigIdentityProvider,
4
+ } from "@aws-sdk/types";
5
+ import { AwsCredentialIdentity } from "@smithy/types";
3
6
  import { CognitoProviderParameters } from "./CognitoProviderParameters";
4
7
  export interface CognitoIdentityCredentials extends AwsCredentialIdentity {
5
8
  identityId: string;
6
9
  }
7
10
  export type CognitoIdentityCredentialProvider =
8
- Provider<CognitoIdentityCredentials>;
11
+ RuntimeConfigIdentityProvider<CognitoIdentityCredentials>;
9
12
  export declare function fromCognitoIdentity(
10
13
  parameters: FromCognitoIdentityParameters
11
14
  ): CognitoIdentityCredentialProvider;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-sdk/credential-provider-cognito-identity",
3
- "version": "3.712.0",
3
+ "version": "3.714.0",
4
4
  "scripts": {
5
5
  "build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'",
6
6
  "build:cjs": "node ../../scripts/compilation/inline credential-provider-cognito-identity",
@@ -24,8 +24,8 @@
24
24
  },
25
25
  "license": "Apache-2.0",
26
26
  "dependencies": {
27
- "@aws-sdk/client-cognito-identity": "3.712.0",
28
- "@aws-sdk/types": "3.709.0",
27
+ "@aws-sdk/client-cognito-identity": "3.714.0",
28
+ "@aws-sdk/types": "3.714.0",
29
29
  "@smithy/property-provider": "^3.1.11",
30
30
  "@smithy/types": "^3.7.2",
31
31
  "tslib": "^2.6.2"