@aws-sdk/credential-providers 3.935.0 → 3.936.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/README.md +106 -0
- package/dist-cjs/fromLoginCredentials.js +8 -0
- package/dist-cjs/index.js +2 -1
- package/dist-es/fromLoginCredentials.js +4 -0
- package/dist-es/index.js +2 -1
- package/dist-types/fromLoginCredentials.d.ts +7 -0
- package/dist-types/index.d.ts +2 -1
- package/dist-types/ts3.4/fromLoginCredentials.d.ts +5 -0
- package/dist-types/ts3.4/index.d.ts +2 -1
- package/package.json +14 -13
package/README.md
CHANGED
|
@@ -28,6 +28,9 @@ A collection of all credential providers.
|
|
|
28
28
|
- [Supported Configuration](#supported-configuration)
|
|
29
29
|
- [SSO login with AWS CLI](#sso-login-with-the-aws-cli)
|
|
30
30
|
- [Sample Files](#sample-files-2)
|
|
31
|
+
- [From Login Credentials](#fromLoginCredentials)
|
|
32
|
+
- [Login with AWS CLI](#login-with-aws-cli)
|
|
33
|
+
- [Sample Files](#sample-files-3)
|
|
31
34
|
- [From Node.js default credentials provider chain](#fromnodeproviderchain)
|
|
32
35
|
- [Creating a custom credentials chain](#createcredentialchain)
|
|
33
36
|
|
|
@@ -920,6 +923,109 @@ sso_role_name = SampleRole
|
|
|
920
923
|
sso_start_url = https://d-abc123.awsapps.com/start
|
|
921
924
|
```
|
|
922
925
|
|
|
926
|
+
## `fromLoginCredentials()`
|
|
927
|
+
|
|
928
|
+
- Uses `@aws-sdk/client-signin`
|
|
929
|
+
- Not available in browsers & native apps
|
|
930
|
+
|
|
931
|
+
`fromLoginCredentials` creates an `AwsCredentialIdentityProvider` function that reads from cached login credentials stored on disk after authenticating with the AWS CLI using the `aws login` command. The provider automatically refreshes when the credentials are about to expire.
|
|
932
|
+
|
|
933
|
+
This provider is not typically used in an explicit fashion and is designed to simplify credential usage by allowing SDK clients to work seamlessly after running `aws login` with AWS CLI, without requiring any additional configuration.
|
|
934
|
+
|
|
935
|
+
```javascript
|
|
936
|
+
import { fromLoginCredentials } from "@aws-sdk/credential-providers"; // ES6 import
|
|
937
|
+
|
|
938
|
+
const client = new FooClient({
|
|
939
|
+
// Optional, available on clients as of v3.714.0.
|
|
940
|
+
profile: "my-profile",
|
|
941
|
+
credentials: fromLoginCredentials({
|
|
942
|
+
// Optional. Defaults to the client's profile if that is set.
|
|
943
|
+
// Optional. Should match the profile name used with 'aws login --profile <name>'
|
|
944
|
+
// to ensure credentials are found in the cache. Uses 'default' if no
|
|
945
|
+
// --profile was specified during aws login or if this option is omitted.
|
|
946
|
+
profile: "my-profile",
|
|
947
|
+
// Optional. Overwrite the configuration used to construct the signin service client.
|
|
948
|
+
// If not specified, a default signin client will be created with the region specified in the profile.
|
|
949
|
+
// Warning: setting a region here overrides the region set in the config file
|
|
950
|
+
// for the selected profile.
|
|
951
|
+
clientConfig: { region },
|
|
952
|
+
}),
|
|
953
|
+
});
|
|
954
|
+
```
|
|
955
|
+
|
|
956
|
+
### Login with AWS CLI
|
|
957
|
+
|
|
958
|
+
This credential provider relies on the AWS CLI to authenticate and cache login credentials. Here's how to set it up:
|
|
959
|
+
|
|
960
|
+
1. **Initial Login**: Run the `aws login` command to authenticate using your existing AWS Management Console credentials:
|
|
961
|
+
|
|
962
|
+
```console
|
|
963
|
+
$ aws login
|
|
964
|
+
```
|
|
965
|
+
|
|
966
|
+
2. **Named Profile**: To sign in to a named profile or create a new one, use the `--profile` option:
|
|
967
|
+
|
|
968
|
+
```console
|
|
969
|
+
$ aws login --profile my-dev-profile
|
|
970
|
+
```
|
|
971
|
+
|
|
972
|
+
3. **Region Configuration**: If this is a new profile or no AWS Region has been specified, the AWS CLI prompts you to provide a region:
|
|
973
|
+
|
|
974
|
+
```console
|
|
975
|
+
No AWS region has been configured. The AWS region is the geographic location of
|
|
976
|
+
your AWS resources.
|
|
977
|
+
|
|
978
|
+
If you've used AWS before and already have resources in your account, tell us
|
|
979
|
+
which region they were created in. If you haven't created resources in your account
|
|
980
|
+
before, you can pick the region closest to you:
|
|
981
|
+
https://docs.aws.amazon.com/global-infrastructure/latest/regions/aws-regions.html.
|
|
982
|
+
You are able to change the region in the CLI at any time with the command
|
|
983
|
+
`aws configure set region NEW_REGION`.
|
|
984
|
+
|
|
985
|
+
AWS Region [us-east-1]:
|
|
986
|
+
```
|
|
987
|
+
|
|
988
|
+
4. **Browser Authentication**: The AWS CLI attempts to open your default browser for the sign in process:
|
|
989
|
+
|
|
990
|
+
```console
|
|
991
|
+
Attempting to open the login page for `us-east-1` in your default browser.
|
|
992
|
+
If the browser does not open, use the following URL to complete your login:
|
|
993
|
+
https://signin.us-east-1.amazonaws.com/authorize?<abbreviated>
|
|
994
|
+
```
|
|
995
|
+
|
|
996
|
+
5. **No Browser Option**: If the device using the AWS CLI does not have a browser, you can use the `--no-browser` option:
|
|
997
|
+
|
|
998
|
+
```console
|
|
999
|
+
$ aws login --no-browser
|
|
1000
|
+
```
|
|
1001
|
+
|
|
1002
|
+
This will provide a URL for you to open on a browser-enabled device and prompt for an authorization code.
|
|
1003
|
+
|
|
1004
|
+
6. **Logout**: When you are done using your session, you can let your credentials expire, or run the `aws logout` command:
|
|
1005
|
+
|
|
1006
|
+
```console
|
|
1007
|
+
$ aws logout
|
|
1008
|
+
$ aws logout --profile my-dev-profile
|
|
1009
|
+
```
|
|
1010
|
+
|
|
1011
|
+
### Cached Credentials
|
|
1012
|
+
|
|
1013
|
+
The temporary cached credentials, as well as the metadata required to refresh them are stored by default in `~/.aws/login/cache` on Linux and macOS, or `%USERPROFILE%\.aws\login\cache` on Windows.
|
|
1014
|
+
|
|
1015
|
+
You can override this location by setting the `AWS_LOGIN_CACHE_DIRECTORY` environment variable.
|
|
1016
|
+
|
|
1017
|
+
### Sample Files
|
|
1018
|
+
|
|
1019
|
+
After running `aws login`, the configuration file will contain a `login_session` entry:
|
|
1020
|
+
|
|
1021
|
+
#### `~/.aws/config`
|
|
1022
|
+
|
|
1023
|
+
```ini
|
|
1024
|
+
[default]
|
|
1025
|
+
login_session = arn:aws:iam::0123456789012:user/username
|
|
1026
|
+
region = us-east-1
|
|
1027
|
+
```
|
|
1028
|
+
|
|
923
1029
|
## `fromNodeProviderChain()`
|
|
924
1030
|
|
|
925
1031
|
- May use `@aws-sdk/client-sts`, `@aws-sdk/client-sso`, etc. depending on
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fromLoginCredentials = void 0;
|
|
4
|
+
const credential_provider_login_1 = require("@aws-sdk/credential-provider-login");
|
|
5
|
+
const fromLoginCredentials = (init) => (0, credential_provider_login_1.fromLoginCredentials)({
|
|
6
|
+
...init,
|
|
7
|
+
});
|
|
8
|
+
exports.fromLoginCredentials = fromLoginCredentials;
|
package/dist-cjs/index.js
CHANGED
|
@@ -6,11 +6,12 @@ tslib_1.__exportStar(require("./createCredentialChain"), exports);
|
|
|
6
6
|
tslib_1.__exportStar(require("./fromCognitoIdentity"), exports);
|
|
7
7
|
tslib_1.__exportStar(require("./fromCognitoIdentityPool"), exports);
|
|
8
8
|
tslib_1.__exportStar(require("./fromContainerMetadata"), exports);
|
|
9
|
+
tslib_1.__exportStar(require("./fromEnv"), exports);
|
|
9
10
|
var credential_provider_http_1 = require("@aws-sdk/credential-provider-http");
|
|
10
11
|
Object.defineProperty(exports, "fromHttp", { enumerable: true, get: function () { return credential_provider_http_1.fromHttp; } });
|
|
11
|
-
tslib_1.__exportStar(require("./fromEnv"), exports);
|
|
12
12
|
tslib_1.__exportStar(require("./fromIni"), exports);
|
|
13
13
|
tslib_1.__exportStar(require("./fromInstanceMetadata"), exports);
|
|
14
|
+
tslib_1.__exportStar(require("./fromLoginCredentials"), exports);
|
|
14
15
|
tslib_1.__exportStar(require("./fromNodeProviderChain"), exports);
|
|
15
16
|
tslib_1.__exportStar(require("./fromProcess"), exports);
|
|
16
17
|
tslib_1.__exportStar(require("./fromSSO"), exports);
|
package/dist-es/index.js
CHANGED
|
@@ -2,10 +2,11 @@ export * from "./createCredentialChain";
|
|
|
2
2
|
export * from "./fromCognitoIdentity";
|
|
3
3
|
export * from "./fromCognitoIdentityPool";
|
|
4
4
|
export * from "./fromContainerMetadata";
|
|
5
|
-
export { fromHttp } from "@aws-sdk/credential-provider-http";
|
|
6
5
|
export * from "./fromEnv";
|
|
6
|
+
export { fromHttp } from "@aws-sdk/credential-provider-http";
|
|
7
7
|
export * from "./fromIni";
|
|
8
8
|
export * from "./fromInstanceMetadata";
|
|
9
|
+
export * from "./fromLoginCredentials";
|
|
9
10
|
export * from "./fromNodeProviderChain";
|
|
10
11
|
export * from "./fromProcess";
|
|
11
12
|
export * from "./fromSSO";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type FromLoginCredentialsInit } from "@aws-sdk/credential-provider-login";
|
|
2
|
+
import type { RuntimeConfigAwsCredentialIdentityProvider } from "@aws-sdk/types";
|
|
3
|
+
/**
|
|
4
|
+
* Creates a credential provider that sources credentials from `aws login` cached tokens
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export declare const fromLoginCredentials: (init?: FromLoginCredentialsInit) => RuntimeConfigAwsCredentialIdentityProvider;
|
package/dist-types/index.d.ts
CHANGED
|
@@ -2,10 +2,11 @@ export * from "./createCredentialChain";
|
|
|
2
2
|
export * from "./fromCognitoIdentity";
|
|
3
3
|
export * from "./fromCognitoIdentityPool";
|
|
4
4
|
export * from "./fromContainerMetadata";
|
|
5
|
-
export { fromHttp, FromHttpOptions, HttpProviderCredentials } from "@aws-sdk/credential-provider-http";
|
|
6
5
|
export * from "./fromEnv";
|
|
6
|
+
export { fromHttp, FromHttpOptions, HttpProviderCredentials } from "@aws-sdk/credential-provider-http";
|
|
7
7
|
export * from "./fromIni";
|
|
8
8
|
export * from "./fromInstanceMetadata";
|
|
9
|
+
export * from "./fromLoginCredentials";
|
|
9
10
|
export * from "./fromNodeProviderChain";
|
|
10
11
|
export * from "./fromProcess";
|
|
11
12
|
export * from "./fromSSO";
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { FromLoginCredentialsInit } from "@aws-sdk/credential-provider-login";
|
|
2
|
+
import { RuntimeConfigAwsCredentialIdentityProvider } from "@aws-sdk/types";
|
|
3
|
+
export declare const fromLoginCredentials: (
|
|
4
|
+
init?: FromLoginCredentialsInit
|
|
5
|
+
) => RuntimeConfigAwsCredentialIdentityProvider;
|
|
@@ -2,14 +2,15 @@ export * from "./createCredentialChain";
|
|
|
2
2
|
export * from "./fromCognitoIdentity";
|
|
3
3
|
export * from "./fromCognitoIdentityPool";
|
|
4
4
|
export * from "./fromContainerMetadata";
|
|
5
|
+
export * from "./fromEnv";
|
|
5
6
|
export {
|
|
6
7
|
fromHttp,
|
|
7
8
|
FromHttpOptions,
|
|
8
9
|
HttpProviderCredentials,
|
|
9
10
|
} from "@aws-sdk/credential-provider-http";
|
|
10
|
-
export * from "./fromEnv";
|
|
11
11
|
export * from "./fromIni";
|
|
12
12
|
export * from "./fromInstanceMetadata";
|
|
13
|
+
export * from "./fromLoginCredentials";
|
|
13
14
|
export * from "./fromNodeProviderChain";
|
|
14
15
|
export * from "./fromProcess";
|
|
15
16
|
export * from "./fromSSO";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-sdk/credential-providers",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.936.0",
|
|
4
4
|
"description": "A collection of credential providers, without requiring service clients like STS, Cognito",
|
|
5
5
|
"main": "./dist-cjs/index.js",
|
|
6
6
|
"module": "./dist-es/index.js",
|
|
@@ -31,18 +31,19 @@
|
|
|
31
31
|
},
|
|
32
32
|
"license": "Apache-2.0",
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@aws-sdk/client-cognito-identity": "3.
|
|
35
|
-
"@aws-sdk/core": "3.
|
|
36
|
-
"@aws-sdk/credential-provider-cognito-identity": "3.
|
|
37
|
-
"@aws-sdk/credential-provider-env": "3.
|
|
38
|
-
"@aws-sdk/credential-provider-http": "3.
|
|
39
|
-
"@aws-sdk/credential-provider-ini": "3.
|
|
40
|
-
"@aws-sdk/credential-provider-
|
|
41
|
-
"@aws-sdk/credential-provider-
|
|
42
|
-
"@aws-sdk/credential-provider-
|
|
43
|
-
"@aws-sdk/credential-provider-
|
|
44
|
-
"@aws-sdk/
|
|
45
|
-
"@aws-sdk/
|
|
34
|
+
"@aws-sdk/client-cognito-identity": "3.936.0",
|
|
35
|
+
"@aws-sdk/core": "3.936.0",
|
|
36
|
+
"@aws-sdk/credential-provider-cognito-identity": "3.936.0",
|
|
37
|
+
"@aws-sdk/credential-provider-env": "3.936.0",
|
|
38
|
+
"@aws-sdk/credential-provider-http": "3.936.0",
|
|
39
|
+
"@aws-sdk/credential-provider-ini": "3.936.0",
|
|
40
|
+
"@aws-sdk/credential-provider-login": "3.936.0",
|
|
41
|
+
"@aws-sdk/credential-provider-node": "3.936.0",
|
|
42
|
+
"@aws-sdk/credential-provider-process": "3.936.0",
|
|
43
|
+
"@aws-sdk/credential-provider-sso": "3.936.0",
|
|
44
|
+
"@aws-sdk/credential-provider-web-identity": "3.936.0",
|
|
45
|
+
"@aws-sdk/nested-clients": "3.936.0",
|
|
46
|
+
"@aws-sdk/types": "3.936.0",
|
|
46
47
|
"@smithy/config-resolver": "^4.4.3",
|
|
47
48
|
"@smithy/core": "^3.18.5",
|
|
48
49
|
"@smithy/credential-provider-imds": "^4.2.5",
|