@aws-sdk/middleware-token 3.485.0 → 3.495.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.
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
module.exports = require("./index.js");
|
|
@@ -1,10 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getTokenPlugin = void 0;
|
|
4
|
-
const tokenMiddleware_1 = require("./tokenMiddleware");
|
|
5
|
-
const getTokenPlugin = (options) => ({
|
|
6
|
-
applyToStack: (clientStack) => {
|
|
7
|
-
clientStack.addRelativeTo((0, tokenMiddleware_1.tokenMiddleware)(options), tokenMiddleware_1.tokenMiddlewareOptions);
|
|
8
|
-
},
|
|
9
|
-
});
|
|
10
|
-
exports.getTokenPlugin = getTokenPlugin;
|
|
1
|
+
module.exports = require("./index.js");
|
package/dist-cjs/index.js
CHANGED
|
@@ -1,7 +1,89 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var src_exports = {};
|
|
22
|
+
__export(src_exports, {
|
|
23
|
+
getTokenPlugin: () => getTokenPlugin,
|
|
24
|
+
resolveTokenConfig: () => resolveTokenConfig,
|
|
25
|
+
tokenMiddleware: () => tokenMiddleware,
|
|
26
|
+
tokenMiddlewareOptions: () => tokenMiddlewareOptions
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(src_exports);
|
|
29
|
+
|
|
30
|
+
// src/tokenMiddleware.ts
|
|
31
|
+
var import_protocol_http = require("@smithy/protocol-http");
|
|
32
|
+
var import_types = require("@smithy/types");
|
|
33
|
+
var tokenMiddlewareOptions = {
|
|
34
|
+
name: "tokenMiddleware",
|
|
35
|
+
tags: ["TOKEN", "AUTH"],
|
|
36
|
+
relation: "after",
|
|
37
|
+
toMiddleware: "retryMiddleware",
|
|
38
|
+
override: true
|
|
39
|
+
};
|
|
40
|
+
var tokenMiddleware = /* @__PURE__ */ __name((options) => (next, context) => async (args) => {
|
|
41
|
+
if (!import_protocol_http.HttpRequest.isInstance(args.request) || context.currentAuthConfig)
|
|
42
|
+
return next(args);
|
|
43
|
+
const token = options.token && await options.token();
|
|
44
|
+
if (token == null ? void 0 : token.token) {
|
|
45
|
+
const authConfig = {
|
|
46
|
+
in: import_types.HttpAuthLocation.HEADER,
|
|
47
|
+
name: "authorization",
|
|
48
|
+
scheme: "Bearer"
|
|
49
|
+
};
|
|
50
|
+
context.currentAuthConfig = authConfig;
|
|
51
|
+
args.request.headers[authConfig.name] = `${authConfig.scheme} ${token.token}`;
|
|
52
|
+
} else {
|
|
53
|
+
context.currentAuthConfig = void 0;
|
|
54
|
+
}
|
|
55
|
+
return next(args);
|
|
56
|
+
}, "tokenMiddleware");
|
|
57
|
+
|
|
58
|
+
// src/getTokenPlugin.ts
|
|
59
|
+
var getTokenPlugin = /* @__PURE__ */ __name((options) => ({
|
|
60
|
+
applyToStack: (clientStack) => {
|
|
61
|
+
clientStack.addRelativeTo(tokenMiddleware(options), tokenMiddlewareOptions);
|
|
62
|
+
}
|
|
63
|
+
}), "getTokenPlugin");
|
|
64
|
+
|
|
65
|
+
// src/normalizeTokenProvider.ts
|
|
66
|
+
var import_property_provider = require("@smithy/property-provider");
|
|
67
|
+
var import_util_middleware = require("@smithy/util-middleware");
|
|
68
|
+
var isTokenWithExpiry = /* @__PURE__ */ __name((token) => token.expiration !== void 0, "isTokenWithExpiry");
|
|
69
|
+
var isTokenExpiringWithinFiveMins = /* @__PURE__ */ __name((token) => isTokenWithExpiry(token) && token.expiration.getTime() - Date.now() < 3e5, "isTokenExpiringWithinFiveMins");
|
|
70
|
+
var normalizeTokenProvider = /* @__PURE__ */ __name((token) => {
|
|
71
|
+
if (typeof token === "function") {
|
|
72
|
+
return (0, import_property_provider.memoize)(token, isTokenExpiringWithinFiveMins, isTokenWithExpiry);
|
|
73
|
+
}
|
|
74
|
+
return (0, import_util_middleware.normalizeProvider)(token);
|
|
75
|
+
}, "normalizeTokenProvider");
|
|
76
|
+
|
|
77
|
+
// src/resolveTokenConfig.ts
|
|
78
|
+
var import_tokenDefaultProvider = require("././tokenDefaultProvider");
|
|
79
|
+
var resolveTokenConfig = /* @__PURE__ */ __name((input) => ({
|
|
80
|
+
...input,
|
|
81
|
+
token: input.token ? normalizeTokenProvider(input.token) : (0, import_tokenDefaultProvider.tokenDefaultProvider)(input)
|
|
82
|
+
}), "resolveTokenConfig");
|
|
83
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
84
|
+
0 && (module.exports = {
|
|
85
|
+
getTokenPlugin,
|
|
86
|
+
resolveTokenConfig,
|
|
87
|
+
tokenMiddleware,
|
|
88
|
+
tokenMiddlewareOptions
|
|
89
|
+
});
|
|
@@ -1,14 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.normalizeTokenProvider = void 0;
|
|
4
|
-
const property_provider_1 = require("@smithy/property-provider");
|
|
5
|
-
const util_middleware_1 = require("@smithy/util-middleware");
|
|
6
|
-
const isTokenWithExpiry = (token) => token.expiration !== undefined;
|
|
7
|
-
const isTokenExpiringWithinFiveMins = (token) => isTokenWithExpiry(token) && token.expiration.getTime() - Date.now() < 300000;
|
|
8
|
-
const normalizeTokenProvider = (token) => {
|
|
9
|
-
if (typeof token === "function") {
|
|
10
|
-
return (0, property_provider_1.memoize)(token, isTokenExpiringWithinFiveMins, isTokenWithExpiry);
|
|
11
|
-
}
|
|
12
|
-
return (0, util_middleware_1.normalizeProvider)(token);
|
|
13
|
-
};
|
|
14
|
-
exports.normalizeTokenProvider = normalizeTokenProvider;
|
|
1
|
+
module.exports = require("./index.js");
|
|
@@ -1,10 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolveTokenConfig = void 0;
|
|
4
|
-
const normalizeTokenProvider_1 = require("./normalizeTokenProvider");
|
|
5
|
-
const tokenDefaultProvider_1 = require("./tokenDefaultProvider");
|
|
6
|
-
const resolveTokenConfig = (input) => ({
|
|
7
|
-
...input,
|
|
8
|
-
token: input.token ? (0, normalizeTokenProvider_1.normalizeTokenProvider)(input.token) : (0, tokenDefaultProvider_1.tokenDefaultProvider)(input),
|
|
9
|
-
});
|
|
10
|
-
exports.resolveTokenConfig = resolveTokenConfig;
|
|
1
|
+
module.exports = require("./index.js");
|
|
@@ -1,31 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.tokenMiddleware = exports.tokenMiddlewareOptions = void 0;
|
|
4
|
-
const protocol_http_1 = require("@smithy/protocol-http");
|
|
5
|
-
const types_1 = require("@smithy/types");
|
|
6
|
-
exports.tokenMiddlewareOptions = {
|
|
7
|
-
name: "tokenMiddleware",
|
|
8
|
-
tags: ["TOKEN", "AUTH"],
|
|
9
|
-
relation: "after",
|
|
10
|
-
toMiddleware: "retryMiddleware",
|
|
11
|
-
override: true,
|
|
12
|
-
};
|
|
13
|
-
const tokenMiddleware = (options) => (next, context) => async (args) => {
|
|
14
|
-
if (!protocol_http_1.HttpRequest.isInstance(args.request) || context.currentAuthConfig)
|
|
15
|
-
return next(args);
|
|
16
|
-
const token = options.token && (await options.token());
|
|
17
|
-
if (token === null || token === void 0 ? void 0 : token.token) {
|
|
18
|
-
const authConfig = {
|
|
19
|
-
in: types_1.HttpAuthLocation.HEADER,
|
|
20
|
-
name: "authorization",
|
|
21
|
-
scheme: "Bearer",
|
|
22
|
-
};
|
|
23
|
-
context.currentAuthConfig = authConfig;
|
|
24
|
-
args.request.headers[authConfig.name] = `${authConfig.scheme} ${token.token}`;
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
context.currentAuthConfig = undefined;
|
|
28
|
-
}
|
|
29
|
-
return next(args);
|
|
30
|
-
};
|
|
31
|
-
exports.tokenMiddleware = tokenMiddleware;
|
|
1
|
+
module.exports = require("./index.js");
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-sdk/middleware-token",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.495.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",
|
|
7
7
|
"sideEffects": false,
|
|
8
8
|
"scripts": {
|
|
9
9
|
"build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'",
|
|
10
|
-
"build:cjs": "
|
|
10
|
+
"build:cjs": "node ../../scripts/compilation/inline middleware-token",
|
|
11
11
|
"build:es": "tsc -p tsconfig.es.json",
|
|
12
12
|
"build:include:deps": "lerna run --scope $npm_package_name --include-dependencies build",
|
|
13
13
|
"build:types": "tsc -p tsconfig.types.json",
|
|
@@ -26,12 +26,12 @@
|
|
|
26
26
|
},
|
|
27
27
|
"license": "Apache-2.0",
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@aws-sdk/token-providers": "3.
|
|
30
|
-
"@aws-sdk/types": "3.
|
|
31
|
-
"@smithy/property-provider": "^2.
|
|
32
|
-
"@smithy/protocol-http": "^3.0
|
|
33
|
-
"@smithy/types": "^2.
|
|
34
|
-
"@smithy/util-middleware": "^2.0
|
|
29
|
+
"@aws-sdk/token-providers": "3.495.0",
|
|
30
|
+
"@aws-sdk/types": "3.495.0",
|
|
31
|
+
"@smithy/property-provider": "^2.1.0",
|
|
32
|
+
"@smithy/protocol-http": "^3.1.0",
|
|
33
|
+
"@smithy/types": "^2.9.0",
|
|
34
|
+
"@smithy/util-middleware": "^2.1.0",
|
|
35
35
|
"tslib": "^2.5.0"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|