@aws-sdk/middleware-token 3.183.0 → 3.186.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,14 @@
|
|
|
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.186.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.185.0...v3.186.0) (2022-10-06)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @aws-sdk/middleware-token
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
6
14
|
# [3.183.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.182.0...v3.183.0) (2022-10-03)
|
|
7
15
|
|
|
8
16
|
**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: (clientStack)
|
|
2
|
+
export var getTokenPlugin = function (options) { return ({
|
|
3
|
+
applyToStack: function (clientStack) {
|
|
4
4
|
clientStack.addRelativeTo(tokenMiddleware(options), TokenMiddlewareOptions);
|
|
5
5
|
},
|
|
6
|
-
});
|
|
6
|
+
}); };
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { memoize } from "@aws-sdk/property-provider";
|
|
2
2
|
import { normalizeProvider } from "@aws-sdk/util-middleware";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
var isTokenWithExpiry = function (token) { return token.expiration !== undefined; };
|
|
4
|
+
var isTokenExpiringWithinFiveMins = function (token) {
|
|
5
|
+
return isTokenWithExpiry(token) && token.expiration.getTime() - Date.now() < 300000;
|
|
6
|
+
};
|
|
7
|
+
export var normalizeTokenProvider = function (token) {
|
|
6
8
|
if (typeof token === "function") {
|
|
7
9
|
return memoize(token, isTokenExpiringWithinFiveMins, isTokenWithExpiry);
|
|
8
10
|
}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
+
import { __assign } from "tslib";
|
|
1
2
|
import { normalizeTokenProvider } from "./normalizeTokenProvider";
|
|
2
|
-
export
|
|
3
|
-
...input,
|
|
4
|
-
token: input.token ? normalizeTokenProvider(input.token) : input.tokenDefaultProvider(input),
|
|
5
|
-
});
|
|
3
|
+
export var resolveTokenConfig = function (input) { return (__assign(__assign({}, input), { token: input.token ? normalizeTokenProvider(input.token) : input.tokenDefaultProvider(input) })); };
|
|
@@ -1,15 +1,28 @@
|
|
|
1
|
+
import { __awaiter, __generator } from "tslib";
|
|
1
2
|
import { HttpRequest } from "@aws-sdk/protocol-http";
|
|
2
|
-
export
|
|
3
|
+
export var TokenMiddlewareOptions = {
|
|
3
4
|
name: "tokenMiddleware",
|
|
4
5
|
tags: ["TOKEN"],
|
|
5
6
|
relation: "after",
|
|
6
7
|
toMiddleware: "retryMiddleware",
|
|
7
8
|
override: true,
|
|
8
9
|
};
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
return
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
export var tokenMiddleware = function (options) {
|
|
11
|
+
return function (next) {
|
|
12
|
+
return function (args) { return __awaiter(void 0, void 0, void 0, function () {
|
|
13
|
+
var token;
|
|
14
|
+
return __generator(this, function (_a) {
|
|
15
|
+
switch (_a.label) {
|
|
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
|
+
};
|
|
15
28
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-sdk/middleware-token",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.186.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.186.0",
|
|
29
|
+
"@aws-sdk/protocol-http": "3.186.0",
|
|
30
|
+
"@aws-sdk/types": "3.186.0",
|
|
31
|
+
"@aws-sdk/util-middleware": "3.186.0",
|
|
32
32
|
"tslib": "^2.3.1"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|