@aws-sdk/credential-provider-cognito-identity 3.501.0 → 3.503.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 +31 -8
- package/dist-cjs/loadCognitoIdentity.js +1 -0
- package/dist-es/fromCognitoIdentity.js +3 -2
- package/dist-es/fromCognitoIdentityPool.js +10 -6
- package/dist-es/loadCognitoIdentity.js +2 -0
- package/dist-types/CognitoProviderParameters.d.ts +6 -2
- package/dist-types/fromCognitoIdentity.d.ts +2 -1
- package/dist-types/fromCognitoIdentityPool.d.ts +3 -2
- package/dist-types/loadCognitoIdentity.d.ts +3 -0
- package/dist-types/ts3.4/CognitoProviderParameters.d.ts +6 -2
- package/dist-types/ts3.4/fromCognitoIdentity.d.ts +3 -1
- package/dist-types/ts3.4/fromCognitoIdentityPool.d.ts +5 -1
- package/dist-types/ts3.4/loadCognitoIdentity.d.ts +11 -0
- package/package.json +3 -3
package/dist-cjs/index.js
CHANGED
|
@@ -3,6 +3,9 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
3
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
5
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
|
+
var __esm = (fn, res) => function __init() {
|
|
7
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
8
|
+
};
|
|
6
9
|
var __export = (target, all) => {
|
|
7
10
|
for (var name in all)
|
|
8
11
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -17,6 +20,20 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
20
|
};
|
|
18
21
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
22
|
|
|
23
|
+
// src/loadCognitoIdentity.ts
|
|
24
|
+
var loadCognitoIdentity_exports = {};
|
|
25
|
+
__export(loadCognitoIdentity_exports, {
|
|
26
|
+
CognitoIdentityClient: () => import_client_cognito_identity.CognitoIdentityClient,
|
|
27
|
+
GetCredentialsForIdentityCommand: () => import_client_cognito_identity.GetCredentialsForIdentityCommand,
|
|
28
|
+
GetIdCommand: () => import_client_cognito_identity.GetIdCommand
|
|
29
|
+
});
|
|
30
|
+
var import_client_cognito_identity;
|
|
31
|
+
var init_loadCognitoIdentity = __esm({
|
|
32
|
+
"src/loadCognitoIdentity.ts"() {
|
|
33
|
+
import_client_cognito_identity = require("@aws-sdk/client-cognito-identity");
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
|
|
20
37
|
// src/index.ts
|
|
21
38
|
var src_exports = {};
|
|
22
39
|
__export(src_exports, {
|
|
@@ -26,7 +43,6 @@ __export(src_exports, {
|
|
|
26
43
|
module.exports = __toCommonJS(src_exports);
|
|
27
44
|
|
|
28
45
|
// src/fromCognitoIdentity.ts
|
|
29
|
-
var import_client_cognito_identity = require("@aws-sdk/client-cognito-identity");
|
|
30
46
|
var import_property_provider = require("@smithy/property-provider");
|
|
31
47
|
|
|
32
48
|
// src/resolveLogins.ts
|
|
@@ -53,6 +69,9 @@ __name(resolveLogins, "resolveLogins");
|
|
|
53
69
|
// src/fromCognitoIdentity.ts
|
|
54
70
|
function fromCognitoIdentity(parameters) {
|
|
55
71
|
return async () => {
|
|
72
|
+
var _a;
|
|
73
|
+
(_a = parameters.logger) == null ? void 0 : _a.debug("@aws-sdk/credential-provider-cognito-identity", "fromCognitoIdentity");
|
|
74
|
+
const { GetCredentialsForIdentityCommand: GetCredentialsForIdentityCommand2, CognitoIdentityClient: CognitoIdentityClient2 } = await Promise.resolve().then(() => (init_loadCognitoIdentity(), loadCognitoIdentity_exports));
|
|
56
75
|
const {
|
|
57
76
|
Credentials: {
|
|
58
77
|
AccessKeyId = throwOnMissingAccessKeyId(),
|
|
@@ -60,8 +79,8 @@ function fromCognitoIdentity(parameters) {
|
|
|
60
79
|
SecretKey = throwOnMissingSecretKey(),
|
|
61
80
|
SessionToken
|
|
62
81
|
} = throwOnMissingCredentials()
|
|
63
|
-
} = await parameters.client.send(
|
|
64
|
-
new
|
|
82
|
+
} = await (parameters.client ?? new CognitoIdentityClient2(parameters.clientConfig ?? {})).send(
|
|
83
|
+
new GetCredentialsForIdentityCommand2({
|
|
65
84
|
CustomRoleArn: parameters.customRoleArn,
|
|
66
85
|
IdentityId: parameters.identityId,
|
|
67
86
|
Logins: parameters.logins ? await resolveLogins(parameters.logins) : void 0
|
|
@@ -93,7 +112,6 @@ __name(throwOnMissingSecretKey, "throwOnMissingSecretKey");
|
|
|
93
112
|
// src/fromCognitoIdentityPool.ts
|
|
94
113
|
|
|
95
114
|
|
|
96
|
-
|
|
97
115
|
// src/IndexedDbStorage.ts
|
|
98
116
|
var STORE_NAME = "IdentityIds";
|
|
99
117
|
var _IndexedDbStorage = class _IndexedDbStorage {
|
|
@@ -204,17 +222,22 @@ function fromCognitoIdentityPool({
|
|
|
204
222
|
accountId,
|
|
205
223
|
cache = localStorage(),
|
|
206
224
|
client,
|
|
225
|
+
clientConfig,
|
|
207
226
|
customRoleArn,
|
|
208
227
|
identityPoolId,
|
|
209
228
|
logins,
|
|
210
|
-
userIdentifier = !logins || Object.keys(logins).length === 0 ? "ANONYMOUS" : void 0
|
|
229
|
+
userIdentifier = !logins || Object.keys(logins).length === 0 ? "ANONYMOUS" : void 0,
|
|
230
|
+
logger
|
|
211
231
|
}) {
|
|
232
|
+
logger == null ? void 0 : logger.debug("@aws-sdk/credential-provider-cognito-identity", "fromCognitoIdentity");
|
|
212
233
|
const cacheKey = userIdentifier ? `aws:cognito-identity-credentials:${identityPoolId}:${userIdentifier}` : void 0;
|
|
213
234
|
let provider = /* @__PURE__ */ __name(async () => {
|
|
235
|
+
const { GetIdCommand: GetIdCommand2, CognitoIdentityClient: CognitoIdentityClient2 } = await Promise.resolve().then(() => (init_loadCognitoIdentity(), loadCognitoIdentity_exports));
|
|
236
|
+
const _client = client ?? new CognitoIdentityClient2(clientConfig ?? {});
|
|
214
237
|
let identityId = cacheKey && await cache.getItem(cacheKey);
|
|
215
238
|
if (!identityId) {
|
|
216
|
-
const { IdentityId = throwOnMissingId() } = await
|
|
217
|
-
new
|
|
239
|
+
const { IdentityId = throwOnMissingId() } = await _client.send(
|
|
240
|
+
new GetIdCommand2({
|
|
218
241
|
AccountId: accountId,
|
|
219
242
|
IdentityPoolId: identityPoolId,
|
|
220
243
|
Logins: logins ? await resolveLogins(logins) : void 0
|
|
@@ -227,7 +250,7 @@ function fromCognitoIdentityPool({
|
|
|
227
250
|
}
|
|
228
251
|
}
|
|
229
252
|
provider = fromCognitoIdentity({
|
|
230
|
-
client,
|
|
253
|
+
client: _client,
|
|
231
254
|
customRoleArn,
|
|
232
255
|
logins,
|
|
233
256
|
identityId
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require("./index.js");
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { GetCredentialsForIdentityCommand } from "@aws-sdk/client-cognito-identity";
|
|
2
1
|
import { CredentialsProviderError } from "@smithy/property-provider";
|
|
3
2
|
import { resolveLogins } from "./resolveLogins";
|
|
4
3
|
export function fromCognitoIdentity(parameters) {
|
|
5
4
|
return async () => {
|
|
6
|
-
|
|
5
|
+
parameters.logger?.debug("@aws-sdk/credential-provider-cognito-identity", "fromCognitoIdentity");
|
|
6
|
+
const { GetCredentialsForIdentityCommand, CognitoIdentityClient } = await import("./loadCognitoIdentity");
|
|
7
|
+
const { Credentials: { AccessKeyId = throwOnMissingAccessKeyId(), Expiration, SecretKey = throwOnMissingSecretKey(), SessionToken, } = throwOnMissingCredentials(), } = await (parameters.client ?? new CognitoIdentityClient(parameters.clientConfig ?? {})).send(new GetCredentialsForIdentityCommand({
|
|
7
8
|
CustomRoleArn: parameters.customRoleArn,
|
|
8
9
|
IdentityId: parameters.identityId,
|
|
9
10
|
Logins: parameters.logins ? await resolveLogins(parameters.logins) : undefined,
|
|
@@ -1,14 +1,18 @@
|
|
|
1
|
-
import { GetIdCommand } from "@aws-sdk/client-cognito-identity";
|
|
2
1
|
import { CredentialsProviderError } from "@smithy/property-provider";
|
|
3
2
|
import { fromCognitoIdentity } from "./fromCognitoIdentity";
|
|
4
3
|
import { localStorage } from "./localStorage";
|
|
5
4
|
import { resolveLogins } from "./resolveLogins";
|
|
6
|
-
export function fromCognitoIdentityPool({ accountId, cache = localStorage(), client, customRoleArn, identityPoolId, logins, userIdentifier = !logins || Object.keys(logins).length === 0 ? "ANONYMOUS" : undefined, }) {
|
|
7
|
-
|
|
5
|
+
export function fromCognitoIdentityPool({ accountId, cache = localStorage(), client, clientConfig, customRoleArn, identityPoolId, logins, userIdentifier = !logins || Object.keys(logins).length === 0 ? "ANONYMOUS" : undefined, logger, }) {
|
|
6
|
+
logger?.debug("@aws-sdk/credential-provider-cognito-identity", "fromCognitoIdentity");
|
|
7
|
+
const cacheKey = userIdentifier
|
|
8
|
+
? `aws:cognito-identity-credentials:${identityPoolId}:${userIdentifier}`
|
|
9
|
+
: undefined;
|
|
8
10
|
let provider = async () => {
|
|
9
|
-
|
|
11
|
+
const { GetIdCommand, CognitoIdentityClient } = await import("./loadCognitoIdentity");
|
|
12
|
+
const _client = client ?? new CognitoIdentityClient(clientConfig ?? {});
|
|
13
|
+
let identityId = (cacheKey && (await cache.getItem(cacheKey)));
|
|
10
14
|
if (!identityId) {
|
|
11
|
-
const { IdentityId = throwOnMissingId() } = await
|
|
15
|
+
const { IdentityId = throwOnMissingId() } = await _client.send(new GetIdCommand({
|
|
12
16
|
AccountId: accountId,
|
|
13
17
|
IdentityPoolId: identityPoolId,
|
|
14
18
|
Logins: logins ? await resolveLogins(logins) : undefined,
|
|
@@ -19,7 +23,7 @@ export function fromCognitoIdentityPool({ accountId, cache = localStorage(), cli
|
|
|
19
23
|
}
|
|
20
24
|
}
|
|
21
25
|
provider = fromCognitoIdentity({
|
|
22
|
-
client,
|
|
26
|
+
client: _client,
|
|
23
27
|
customRoleArn,
|
|
24
28
|
logins,
|
|
25
29
|
identityId,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CognitoIdentityClient } from "
|
|
1
|
+
import type { CognitoIdentityClient, CognitoIdentityClientConfig } from "./loadCognitoIdentity";
|
|
2
2
|
import { Logins } from "./Logins";
|
|
3
3
|
/**
|
|
4
4
|
* @internal
|
|
@@ -8,7 +8,11 @@ export interface CognitoProviderParameters {
|
|
|
8
8
|
* The SDK client with which the credential provider will contact the Amazon
|
|
9
9
|
* Cognito service.
|
|
10
10
|
*/
|
|
11
|
-
client
|
|
11
|
+
client?: CognitoIdentityClient;
|
|
12
|
+
/**
|
|
13
|
+
* Client config, only used when not supplying a client.
|
|
14
|
+
*/
|
|
15
|
+
clientConfig?: CognitoIdentityClientConfig;
|
|
12
16
|
/**
|
|
13
17
|
* The Amazon Resource Name (ARN) of the role to be assumed when multiple
|
|
14
18
|
* roles were received in the token from the identity provider. For example,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { CredentialProviderOptions } from "@aws-sdk/types";
|
|
1
2
|
import { AwsCredentialIdentity, Provider } from "@smithy/types";
|
|
2
3
|
import { CognitoProviderParameters } from "./CognitoProviderParameters";
|
|
3
4
|
/**
|
|
@@ -25,7 +26,7 @@ export declare function fromCognitoIdentity(parameters: FromCognitoIdentityParam
|
|
|
25
26
|
/**
|
|
26
27
|
* @internal
|
|
27
28
|
*/
|
|
28
|
-
export interface FromCognitoIdentityParameters extends CognitoProviderParameters {
|
|
29
|
+
export interface FromCognitoIdentityParameters extends CognitoProviderParameters, CredentialProviderOptions {
|
|
29
30
|
/**
|
|
30
31
|
* The unique identifier for the identity against which credentials will be
|
|
31
32
|
* issued.
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { CredentialProviderOptions } from "@aws-sdk/types";
|
|
1
2
|
import { CognitoProviderParameters } from "./CognitoProviderParameters";
|
|
2
3
|
import { CognitoIdentityCredentialProvider } from "./fromCognitoIdentity";
|
|
3
4
|
import { Storage } from "./Storage";
|
|
@@ -11,11 +12,11 @@ import { Storage } from "./Storage";
|
|
|
11
12
|
* Results from `GetId` are cached internally, but results from
|
|
12
13
|
* `GetCredentialsForIdentity` are not.
|
|
13
14
|
*/
|
|
14
|
-
export declare function fromCognitoIdentityPool({ accountId, cache, client, customRoleArn, identityPoolId, logins, userIdentifier, }: FromCognitoIdentityPoolParameters): CognitoIdentityCredentialProvider;
|
|
15
|
+
export declare function fromCognitoIdentityPool({ accountId, cache, client, clientConfig, customRoleArn, identityPoolId, logins, userIdentifier, logger, }: FromCognitoIdentityPoolParameters): CognitoIdentityCredentialProvider;
|
|
15
16
|
/**
|
|
16
17
|
* @internal
|
|
17
18
|
*/
|
|
18
|
-
export interface FromCognitoIdentityPoolParameters extends CognitoProviderParameters {
|
|
19
|
+
export interface FromCognitoIdentityPoolParameters extends CognitoProviderParameters, CredentialProviderOptions {
|
|
19
20
|
/**
|
|
20
21
|
* A standard AWS account ID (9+ digits).
|
|
21
22
|
*/
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { CognitoIdentityClient, GetCredentialsForIdentityCommand, GetIdCommand } from "@aws-sdk/client-cognito-identity";
|
|
2
|
+
export { CognitoIdentityClient, GetCredentialsForIdentityCommand, GetIdCommand };
|
|
3
|
+
export type { CognitoIdentityClientConfig } from "@aws-sdk/client-cognito-identity";
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
CognitoIdentityClient,
|
|
3
|
+
CognitoIdentityClientConfig,
|
|
4
|
+
} from "./loadCognitoIdentity";
|
|
2
5
|
import { Logins } from "./Logins";
|
|
3
6
|
export interface CognitoProviderParameters {
|
|
4
|
-
client
|
|
7
|
+
client?: CognitoIdentityClient;
|
|
8
|
+
clientConfig?: CognitoIdentityClientConfig;
|
|
5
9
|
customRoleArn?: string;
|
|
6
10
|
logins?: Logins;
|
|
7
11
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CredentialProviderOptions } from "@aws-sdk/types";
|
|
1
2
|
import { AwsCredentialIdentity, Provider } from "@smithy/types";
|
|
2
3
|
import { CognitoProviderParameters } from "./CognitoProviderParameters";
|
|
3
4
|
export interface CognitoIdentityCredentials extends AwsCredentialIdentity {
|
|
@@ -9,6 +10,7 @@ export declare function fromCognitoIdentity(
|
|
|
9
10
|
parameters: FromCognitoIdentityParameters
|
|
10
11
|
): CognitoIdentityCredentialProvider;
|
|
11
12
|
export interface FromCognitoIdentityParameters
|
|
12
|
-
extends CognitoProviderParameters
|
|
13
|
+
extends CognitoProviderParameters,
|
|
14
|
+
CredentialProviderOptions {
|
|
13
15
|
identityId: string;
|
|
14
16
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CredentialProviderOptions } from "@aws-sdk/types";
|
|
1
2
|
import { CognitoProviderParameters } from "./CognitoProviderParameters";
|
|
2
3
|
import { CognitoIdentityCredentialProvider } from "./fromCognitoIdentity";
|
|
3
4
|
import { Storage } from "./Storage";
|
|
@@ -5,13 +6,16 @@ export declare function fromCognitoIdentityPool({
|
|
|
5
6
|
accountId,
|
|
6
7
|
cache,
|
|
7
8
|
client,
|
|
9
|
+
clientConfig,
|
|
8
10
|
customRoleArn,
|
|
9
11
|
identityPoolId,
|
|
10
12
|
logins,
|
|
11
13
|
userIdentifier,
|
|
14
|
+
logger,
|
|
12
15
|
}: FromCognitoIdentityPoolParameters): CognitoIdentityCredentialProvider;
|
|
13
16
|
export interface FromCognitoIdentityPoolParameters
|
|
14
|
-
extends CognitoProviderParameters
|
|
17
|
+
extends CognitoProviderParameters,
|
|
18
|
+
CredentialProviderOptions {
|
|
15
19
|
accountId?: string;
|
|
16
20
|
cache?: Storage;
|
|
17
21
|
identityPoolId: string;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CognitoIdentityClient,
|
|
3
|
+
GetCredentialsForIdentityCommand,
|
|
4
|
+
GetIdCommand,
|
|
5
|
+
} from "@aws-sdk/client-cognito-identity";
|
|
6
|
+
export {
|
|
7
|
+
CognitoIdentityClient,
|
|
8
|
+
GetCredentialsForIdentityCommand,
|
|
9
|
+
GetIdCommand,
|
|
10
|
+
};
|
|
11
|
+
export { CognitoIdentityClientConfig } from "@aws-sdk/client-cognito-identity";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-sdk/credential-provider-cognito-identity",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.503.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",
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
},
|
|
22
22
|
"license": "Apache-2.0",
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@aws-sdk/client-cognito-identity": "3.
|
|
25
|
-
"@aws-sdk/types": "3.
|
|
24
|
+
"@aws-sdk/client-cognito-identity": "3.503.0",
|
|
25
|
+
"@aws-sdk/types": "3.502.0",
|
|
26
26
|
"@smithy/property-provider": "^2.1.1",
|
|
27
27
|
"@smithy/types": "^2.9.1",
|
|
28
28
|
"tslib": "^2.5.0"
|