@aws-sdk/middleware-api-key 3.893.0 → 3.910.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.
Files changed (2) hide show
  1. package/dist-cjs/index.js +41 -70
  2. package/package.json +5 -5
package/dist-cjs/index.js CHANGED
@@ -1,77 +1,48 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
1
+ 'use strict';
20
2
 
21
- // src/index.ts
22
- var index_exports = {};
23
- __export(index_exports, {
24
- apiKeyMiddleware: () => apiKeyMiddleware,
25
- apiKeyMiddlewareOptions: () => apiKeyMiddlewareOptions,
26
- getApiKeyPlugin: () => getApiKeyPlugin,
27
- resolveApiKeyConfig: () => resolveApiKeyConfig
28
- });
29
- module.exports = __toCommonJS(index_exports);
3
+ var utilMiddleware = require('@smithy/util-middleware');
4
+ var protocolHttp = require('@smithy/protocol-http');
30
5
 
31
- // src/apiKeyConfiguration.ts
32
- var import_util_middleware = require("@smithy/util-middleware");
33
- var resolveApiKeyConfig = /* @__PURE__ */ __name((input) => {
34
- const { apiKey } = input;
35
- return Object.assign(input, {
36
- apiKey: apiKey ? (0, import_util_middleware.normalizeProvider)(apiKey) : void 0
37
- });
38
- }, "resolveApiKeyConfig");
6
+ const resolveApiKeyConfig = (input) => {
7
+ const { apiKey } = input;
8
+ return Object.assign(input, {
9
+ apiKey: apiKey ? utilMiddleware.normalizeProvider(apiKey) : undefined,
10
+ });
11
+ };
39
12
 
40
- // src/apiKeyMiddleware.ts
41
- var import_protocol_http = require("@smithy/protocol-http");
42
- var apiKeyMiddleware = /* @__PURE__ */ __name((pluginConfig, middlewareConfig) => (next, context) => async function(args) {
43
- if (!import_protocol_http.HttpRequest.isInstance(args.request) || context.currentAuthConfig) return next(args);
44
- const apiKey = pluginConfig.apiKey && await pluginConfig.apiKey();
45
- if (!apiKey) {
46
- context.currentAuthConfig = void 0;
13
+ const apiKeyMiddleware = (pluginConfig, middlewareConfig) => (next, context) => async function (args) {
14
+ if (!protocolHttp.HttpRequest.isInstance(args.request) || context.currentAuthConfig)
15
+ return next(args);
16
+ const apiKey = pluginConfig.apiKey && (await pluginConfig.apiKey());
17
+ if (!apiKey) {
18
+ context.currentAuthConfig = undefined;
19
+ return next(args);
20
+ }
21
+ context.currentAuthConfig = middlewareConfig;
22
+ if (middlewareConfig.in === "header") {
23
+ args.request.headers[middlewareConfig.name.toLowerCase()] = middlewareConfig.scheme
24
+ ? `${middlewareConfig.scheme} ${apiKey}`
25
+ : apiKey;
26
+ }
27
+ else if (middlewareConfig.in === "query") {
28
+ args.request.query[middlewareConfig.name] = apiKey;
29
+ }
47
30
  return next(args);
48
- }
49
- context.currentAuthConfig = middlewareConfig;
50
- if (middlewareConfig.in === "header") {
51
- args.request.headers[middlewareConfig.name.toLowerCase()] = middlewareConfig.scheme ? `${middlewareConfig.scheme} ${apiKey}` : apiKey;
52
- } else if (middlewareConfig.in === "query") {
53
- args.request.query[middlewareConfig.name] = apiKey;
54
- }
55
- return next(args);
56
- }, "apiKeyMiddleware");
57
- var apiKeyMiddlewareOptions = {
58
- name: "apiKeyMiddleware",
59
- tags: ["APIKEY", "AUTH"],
60
- relation: "after",
61
- toMiddleware: "retryMiddleware",
62
- override: true
63
31
  };
64
- var getApiKeyPlugin = /* @__PURE__ */ __name((pluginConfig, middlewareConfig) => ({
65
- applyToStack: /* @__PURE__ */ __name((clientStack) => {
66
- clientStack.addRelativeTo(apiKeyMiddleware(pluginConfig, middlewareConfig), apiKeyMiddlewareOptions);
67
- }, "applyToStack")
68
- }), "getApiKeyPlugin");
69
- // Annotate the CommonJS export names for ESM import in node:
70
-
71
- 0 && (module.exports = {
72
- resolveApiKeyConfig,
73
- apiKeyMiddleware,
74
- apiKeyMiddlewareOptions,
75
- getApiKeyPlugin
32
+ const apiKeyMiddlewareOptions = {
33
+ name: "apiKeyMiddleware",
34
+ tags: ["APIKEY", "AUTH"],
35
+ relation: "after",
36
+ toMiddleware: "retryMiddleware",
37
+ override: true,
38
+ };
39
+ const getApiKeyPlugin = (pluginConfig, middlewareConfig) => ({
40
+ applyToStack: (clientStack) => {
41
+ clientStack.addRelativeTo(apiKeyMiddleware(pluginConfig, middlewareConfig), apiKeyMiddlewareOptions);
42
+ },
76
43
  });
77
44
 
45
+ exports.apiKeyMiddleware = apiKeyMiddleware;
46
+ exports.apiKeyMiddlewareOptions = apiKeyMiddlewareOptions;
47
+ exports.getApiKeyPlugin = getApiKeyPlugin;
48
+ exports.resolveApiKeyConfig = resolveApiKeyConfig;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-sdk/middleware-api-key",
3
- "version": "3.893.0",
3
+ "version": "3.910.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 middleware-api-key",
@@ -22,10 +22,10 @@
22
22
  },
23
23
  "license": "Apache-2.0",
24
24
  "dependencies": {
25
- "@aws-sdk/types": "3.893.0",
26
- "@smithy/protocol-http": "^5.2.1",
27
- "@smithy/types": "^4.5.0",
28
- "@smithy/util-middleware": "^4.1.1",
25
+ "@aws-sdk/types": "3.910.0",
26
+ "@smithy/protocol-http": "^5.3.2",
27
+ "@smithy/types": "^4.7.1",
28
+ "@smithy/util-middleware": "^4.2.2",
29
29
  "tslib": "^2.6.2"
30
30
  },
31
31
  "engines": {