@aws-sdk/middleware-token 3.171.0 → 3.183.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/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,22 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [3.183.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.182.0...v3.183.0) (2022-10-03)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @aws-sdk/middleware-token
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# [3.178.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.177.0...v3.178.0) (2022-09-23)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @aws-sdk/middleware-token
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
6
22
|
# [3.171.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.170.0...v3.171.0) (2022-09-14)
|
|
7
23
|
|
|
8
24
|
**Note:** Version bump only for package @aws-sdk/middleware-token
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { tokenMiddleware, TokenMiddlewareOptions } from "./tokenMiddleware";
|
|
2
|
-
export
|
|
3
|
-
applyToStack:
|
|
2
|
+
export const getTokenPlugin = (options) => ({
|
|
3
|
+
applyToStack: (clientStack) => {
|
|
4
4
|
clientStack.addRelativeTo(tokenMiddleware(options), TokenMiddlewareOptions);
|
|
5
5
|
},
|
|
6
|
-
});
|
|
6
|
+
});
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { memoize } from "@aws-sdk/property-provider";
|
|
2
2
|
import { normalizeProvider } from "@aws-sdk/util-middleware";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
};
|
|
7
|
-
export var normalizeTokenProvider = function (token) {
|
|
3
|
+
const isTokenWithExpiry = (token) => token.expiration !== undefined;
|
|
4
|
+
const isTokenExpiringWithinFiveMins = (token) => isTokenWithExpiry(token) && token.expiration.getTime() - Date.now() < 300000;
|
|
5
|
+
export const normalizeTokenProvider = (token) => {
|
|
8
6
|
if (typeof token === "function") {
|
|
9
7
|
return memoize(token, isTokenExpiringWithinFiveMins, isTokenWithExpiry);
|
|
10
8
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
import { __assign } from "tslib";
|
|
2
1
|
import { normalizeTokenProvider } from "./normalizeTokenProvider";
|
|
3
|
-
export
|
|
2
|
+
export const resolveTokenConfig = (input) => ({
|
|
3
|
+
...input,
|
|
4
|
+
token: input.token ? normalizeTokenProvider(input.token) : input.tokenDefaultProvider(input),
|
|
5
|
+
});
|
|
@@ -1,28 +1,15 @@
|
|
|
1
|
-
import { __awaiter, __generator } from "tslib";
|
|
2
1
|
import { HttpRequest } from "@aws-sdk/protocol-http";
|
|
3
|
-
export
|
|
2
|
+
export const TokenMiddlewareOptions = {
|
|
4
3
|
name: "tokenMiddleware",
|
|
5
4
|
tags: ["TOKEN"],
|
|
6
5
|
relation: "after",
|
|
7
6
|
toMiddleware: "retryMiddleware",
|
|
8
7
|
override: true,
|
|
9
8
|
};
|
|
10
|
-
export
|
|
11
|
-
|
|
12
|
-
return
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
case 0:
|
|
17
|
-
if (!HttpRequest.isInstance(args.request))
|
|
18
|
-
return [2, next(args)];
|
|
19
|
-
return [4, options.token()];
|
|
20
|
-
case 1:
|
|
21
|
-
token = _a.sent();
|
|
22
|
-
args.request.headers["Authorization"] = "Bearer ".concat(token.token);
|
|
23
|
-
return [2, next(args)];
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
}); };
|
|
27
|
-
};
|
|
9
|
+
export const tokenMiddleware = (options) => (next) => async (args) => {
|
|
10
|
+
if (!HttpRequest.isInstance(args.request))
|
|
11
|
+
return next(args);
|
|
12
|
+
const token = await options.token();
|
|
13
|
+
args.request.headers["Authorization"] = `Bearer ${token.token}`;
|
|
14
|
+
return next(args);
|
|
28
15
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-sdk/middleware-token",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.183.0",
|
|
4
4
|
"description": "Middleware and Plugin for setting token authentication",
|
|
5
5
|
"main": "./dist-cjs/index.js",
|
|
6
6
|
"module": "./dist-es/index.js",
|
|
@@ -25,10 +25,10 @@
|
|
|
25
25
|
},
|
|
26
26
|
"license": "Apache-2.0",
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@aws-sdk/property-provider": "3.
|
|
29
|
-
"@aws-sdk/protocol-http": "3.
|
|
30
|
-
"@aws-sdk/types": "3.
|
|
31
|
-
"@aws-sdk/util-middleware": "3.
|
|
28
|
+
"@aws-sdk/property-provider": "3.183.0",
|
|
29
|
+
"@aws-sdk/protocol-http": "3.183.0",
|
|
30
|
+
"@aws-sdk/types": "3.183.0",
|
|
31
|
+
"@aws-sdk/util-middleware": "3.183.0",
|
|
32
32
|
"tslib": "^2.3.1"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|