@smithy/core 3.1.5 → 3.3.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/dist-cjs/index.js +27 -1
- package/dist-cjs/middleware-http-auth-scheme/resolveAuthOptions.js +1 -0
- package/dist-cjs/submodules/serde/index.js +41 -0
- package/dist-es/middleware-http-auth-scheme/httpAuthSchemeMiddleware.js +4 -1
- package/dist-es/middleware-http-auth-scheme/resolveAuthOptions.js +20 -0
- package/dist-es/submodules/serde/index.js +1 -0
- package/dist-es/submodules/serde/value/NumericValue.js +9 -0
- package/dist-types/middleware-http-auth-scheme/httpAuthSchemeMiddleware.d.ts +2 -1
- package/dist-types/middleware-http-auth-scheme/resolveAuthOptions.d.ts +10 -0
- package/dist-types/submodules/serde/index.d.ts +1 -0
- package/dist-types/submodules/serde/value/NumericValue.d.ts +31 -0
- package/dist-types/ts3.4/middleware-http-auth-scheme/httpAuthSchemeMiddleware.d.ts +2 -1
- package/dist-types/ts3.4/middleware-http-auth-scheme/resolveAuthOptions.d.ts +10 -0
- package/dist-types/ts3.4/submodules/serde/index.d.ts +1 -0
- package/dist-types/ts3.4/submodules/serde/value/NumericValue.d.ts +31 -0
- package/package.json +17 -8
- package/serde.d.ts +7 -0
- package/serde.js +6 -0
package/dist-cjs/index.js
CHANGED
|
@@ -51,6 +51,30 @@ var getSmithyContext = /* @__PURE__ */ __name((context) => context[import_types.
|
|
|
51
51
|
|
|
52
52
|
// src/middleware-http-auth-scheme/httpAuthSchemeMiddleware.ts
|
|
53
53
|
var import_util_middleware = require("@smithy/util-middleware");
|
|
54
|
+
|
|
55
|
+
// src/middleware-http-auth-scheme/resolveAuthOptions.ts
|
|
56
|
+
var resolveAuthOptions = /* @__PURE__ */ __name((candidateAuthOptions, authSchemePreference) => {
|
|
57
|
+
if (!authSchemePreference || authSchemePreference.length === 0) {
|
|
58
|
+
return candidateAuthOptions;
|
|
59
|
+
}
|
|
60
|
+
const preferredAuthOptions = [];
|
|
61
|
+
for (const preferredSchemeName of authSchemePreference) {
|
|
62
|
+
for (const candidateAuthOption of candidateAuthOptions) {
|
|
63
|
+
const candidateAuthSchemeName = candidateAuthOption.schemeId.split("#")[1];
|
|
64
|
+
if (candidateAuthSchemeName === preferredSchemeName) {
|
|
65
|
+
preferredAuthOptions.push(candidateAuthOption);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
for (const candidateAuthOption of candidateAuthOptions) {
|
|
70
|
+
if (!preferredAuthOptions.find(({ schemeId }) => schemeId === candidateAuthOption.schemeId)) {
|
|
71
|
+
preferredAuthOptions.push(candidateAuthOption);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return preferredAuthOptions;
|
|
75
|
+
}, "resolveAuthOptions");
|
|
76
|
+
|
|
77
|
+
// src/middleware-http-auth-scheme/httpAuthSchemeMiddleware.ts
|
|
54
78
|
function convertHttpAuthSchemesToMap(httpAuthSchemes) {
|
|
55
79
|
const map = /* @__PURE__ */ new Map();
|
|
56
80
|
for (const scheme of httpAuthSchemes) {
|
|
@@ -63,10 +87,12 @@ var httpAuthSchemeMiddleware = /* @__PURE__ */ __name((config, mwOptions) => (ne
|
|
|
63
87
|
const options = config.httpAuthSchemeProvider(
|
|
64
88
|
await mwOptions.httpAuthSchemeParametersProvider(config, context, args.input)
|
|
65
89
|
);
|
|
90
|
+
const authSchemePreference = config.authSchemePreference ? await config.authSchemePreference() : [];
|
|
91
|
+
const resolvedOptions = resolveAuthOptions(options, authSchemePreference);
|
|
66
92
|
const authSchemes = convertHttpAuthSchemesToMap(config.httpAuthSchemes);
|
|
67
93
|
const smithyContext = (0, import_util_middleware.getSmithyContext)(context);
|
|
68
94
|
const failureReasons = [];
|
|
69
|
-
for (const option of
|
|
95
|
+
for (const option of resolvedOptions) {
|
|
70
96
|
const scheme = authSchemes.get(option.schemeId);
|
|
71
97
|
if (!scheme) {
|
|
72
98
|
failureReasons.push(`HttpAuthScheme \`${option.schemeId}\` was not enabled for this service.`);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require("../index.js");
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/submodules/serde/index.ts
|
|
20
|
+
var serde_exports = {};
|
|
21
|
+
__export(serde_exports, {
|
|
22
|
+
NumericValue: () => NumericValue,
|
|
23
|
+
nv: () => nv
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(serde_exports);
|
|
26
|
+
|
|
27
|
+
// src/submodules/serde/value/NumericValue.ts
|
|
28
|
+
var NumericValue = class {
|
|
29
|
+
constructor(string, type) {
|
|
30
|
+
this.string = string;
|
|
31
|
+
this.type = type;
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
function nv(string) {
|
|
35
|
+
return new NumericValue(string, "bigDecimal");
|
|
36
|
+
}
|
|
37
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
38
|
+
0 && (module.exports = {
|
|
39
|
+
NumericValue,
|
|
40
|
+
nv
|
|
41
|
+
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { SMITHY_CONTEXT_KEY, } from "@smithy/types";
|
|
2
2
|
import { getSmithyContext } from "@smithy/util-middleware";
|
|
3
|
+
import { resolveAuthOptions } from "./resolveAuthOptions";
|
|
3
4
|
function convertHttpAuthSchemesToMap(httpAuthSchemes) {
|
|
4
5
|
const map = new Map();
|
|
5
6
|
for (const scheme of httpAuthSchemes) {
|
|
@@ -9,10 +10,12 @@ function convertHttpAuthSchemesToMap(httpAuthSchemes) {
|
|
|
9
10
|
}
|
|
10
11
|
export const httpAuthSchemeMiddleware = (config, mwOptions) => (next, context) => async (args) => {
|
|
11
12
|
const options = config.httpAuthSchemeProvider(await mwOptions.httpAuthSchemeParametersProvider(config, context, args.input));
|
|
13
|
+
const authSchemePreference = config.authSchemePreference ? await config.authSchemePreference() : [];
|
|
14
|
+
const resolvedOptions = resolveAuthOptions(options, authSchemePreference);
|
|
12
15
|
const authSchemes = convertHttpAuthSchemesToMap(config.httpAuthSchemes);
|
|
13
16
|
const smithyContext = getSmithyContext(context);
|
|
14
17
|
const failureReasons = [];
|
|
15
|
-
for (const option of
|
|
18
|
+
for (const option of resolvedOptions) {
|
|
16
19
|
const scheme = authSchemes.get(option.schemeId);
|
|
17
20
|
if (!scheme) {
|
|
18
21
|
failureReasons.push(`HttpAuthScheme \`${option.schemeId}\` was not enabled for this service.`);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export const resolveAuthOptions = (candidateAuthOptions, authSchemePreference) => {
|
|
2
|
+
if (!authSchemePreference || authSchemePreference.length === 0) {
|
|
3
|
+
return candidateAuthOptions;
|
|
4
|
+
}
|
|
5
|
+
const preferredAuthOptions = [];
|
|
6
|
+
for (const preferredSchemeName of authSchemePreference) {
|
|
7
|
+
for (const candidateAuthOption of candidateAuthOptions) {
|
|
8
|
+
const candidateAuthSchemeName = candidateAuthOption.schemeId.split("#")[1];
|
|
9
|
+
if (candidateAuthSchemeName === preferredSchemeName) {
|
|
10
|
+
preferredAuthOptions.push(candidateAuthOption);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
for (const candidateAuthOption of candidateAuthOptions) {
|
|
15
|
+
if (!preferredAuthOptions.find(({ schemeId }) => schemeId === candidateAuthOption.schemeId)) {
|
|
16
|
+
preferredAuthOptions.push(candidateAuthOption);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return preferredAuthOptions;
|
|
20
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./value/NumericValue";
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { HandlerExecutionContext, HttpAuthScheme, HttpAuthSchemeParameters, HttpAuthSchemeParametersProvider, HttpAuthSchemeProvider, IdentityProviderConfig, SelectedHttpAuthScheme, SerializeMiddleware, SMITHY_CONTEXT_KEY } from "@smithy/types";
|
|
1
|
+
import { HandlerExecutionContext, HttpAuthScheme, HttpAuthSchemeParameters, HttpAuthSchemeParametersProvider, HttpAuthSchemeProvider, IdentityProviderConfig, Provider, SelectedHttpAuthScheme, SerializeMiddleware, SMITHY_CONTEXT_KEY } from "@smithy/types";
|
|
2
2
|
/**
|
|
3
3
|
* @internal
|
|
4
4
|
*/
|
|
5
5
|
export interface PreviouslyResolved<TParameters extends HttpAuthSchemeParameters> {
|
|
6
|
+
authSchemePreference?: Provider<string[]>;
|
|
6
7
|
httpAuthSchemes: HttpAuthScheme[];
|
|
7
8
|
httpAuthSchemeProvider: HttpAuthSchemeProvider<TParameters>;
|
|
8
9
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { HttpAuthOption } from "@smithy/types";
|
|
2
|
+
/**
|
|
3
|
+
* Resolves list of auth options based on the supported ones, vs the preference list.
|
|
4
|
+
*
|
|
5
|
+
* @param candidateAuthOptions list of supported auth options selected by the standard
|
|
6
|
+
* resolution process (model-based, endpoints 2.0, etc.)
|
|
7
|
+
* @param authSchemePreference list of auth schemes preferred by user.
|
|
8
|
+
* @returns
|
|
9
|
+
*/
|
|
10
|
+
export declare const resolveAuthOptions: (candidateAuthOptions: HttpAuthOption[], authSchemePreference: string[]) => HttpAuthOption[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./value/NumericValue";
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types which may be represented by {@link NumericValue}.
|
|
3
|
+
*
|
|
4
|
+
* There is currently only one option, because BigInteger and Long should
|
|
5
|
+
* use JS BigInt directly, and all other numeric types can be contained in JS Number.
|
|
6
|
+
*
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
export type NumericType = "bigDecimal";
|
|
10
|
+
/**
|
|
11
|
+
* Serialization container for Smithy simple types that do not have a
|
|
12
|
+
* direct JavaScript runtime representation.
|
|
13
|
+
*
|
|
14
|
+
* This container does not perform numeric mathematical operations.
|
|
15
|
+
* It is a container for discerning a value's true type.
|
|
16
|
+
*
|
|
17
|
+
* It allows storage of numeric types not representable in JS without
|
|
18
|
+
* making a decision on what numeric library to use.
|
|
19
|
+
*
|
|
20
|
+
* @public
|
|
21
|
+
*/
|
|
22
|
+
export declare class NumericValue {
|
|
23
|
+
readonly string: string;
|
|
24
|
+
readonly type: NumericType;
|
|
25
|
+
constructor(string: string, type: NumericType);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Serde shortcut.
|
|
29
|
+
* @internal
|
|
30
|
+
*/
|
|
31
|
+
export declare function nv(string: string): NumericValue;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { HandlerExecutionContext, HttpAuthScheme, HttpAuthSchemeParameters, HttpAuthSchemeParametersProvider, HttpAuthSchemeProvider, IdentityProviderConfig, SelectedHttpAuthScheme, SerializeMiddleware, SMITHY_CONTEXT_KEY } from "@smithy/types";
|
|
1
|
+
import { HandlerExecutionContext, HttpAuthScheme, HttpAuthSchemeParameters, HttpAuthSchemeParametersProvider, HttpAuthSchemeProvider, IdentityProviderConfig, Provider, SelectedHttpAuthScheme, SerializeMiddleware, SMITHY_CONTEXT_KEY } from "@smithy/types";
|
|
2
2
|
/**
|
|
3
3
|
* @internal
|
|
4
4
|
*/
|
|
5
5
|
export interface PreviouslyResolved<TParameters extends HttpAuthSchemeParameters> {
|
|
6
|
+
authSchemePreference?: Provider<string[]>;
|
|
6
7
|
httpAuthSchemes: HttpAuthScheme[];
|
|
7
8
|
httpAuthSchemeProvider: HttpAuthSchemeProvider<TParameters>;
|
|
8
9
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { HttpAuthOption } from "@smithy/types";
|
|
2
|
+
/**
|
|
3
|
+
* Resolves list of auth options based on the supported ones, vs the preference list.
|
|
4
|
+
*
|
|
5
|
+
* @param candidateAuthOptions list of supported auth options selected by the standard
|
|
6
|
+
* resolution process (model-based, endpoints 2.0, etc.)
|
|
7
|
+
* @param authSchemePreference list of auth schemes preferred by user.
|
|
8
|
+
* @returns
|
|
9
|
+
*/
|
|
10
|
+
export declare const resolveAuthOptions: (candidateAuthOptions: HttpAuthOption[], authSchemePreference: string[]) => HttpAuthOption[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./value/NumericValue";
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types which may be represented by {@link NumericValue}.
|
|
3
|
+
*
|
|
4
|
+
* There is currently only one option, because BigInteger and Long should
|
|
5
|
+
* use JS BigInt directly, and all other numeric types can be contained in JS Number.
|
|
6
|
+
*
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
export type NumericType = "bigDecimal";
|
|
10
|
+
/**
|
|
11
|
+
* Serialization container for Smithy simple types that do not have a
|
|
12
|
+
* direct JavaScript runtime representation.
|
|
13
|
+
*
|
|
14
|
+
* This container does not perform numeric mathematical operations.
|
|
15
|
+
* It is a container for discerning a value's true type.
|
|
16
|
+
*
|
|
17
|
+
* It allows storage of numeric types not representable in JS without
|
|
18
|
+
* making a decision on what numeric library to use.
|
|
19
|
+
*
|
|
20
|
+
* @public
|
|
21
|
+
*/
|
|
22
|
+
export declare class NumericValue {
|
|
23
|
+
readonly string: string;
|
|
24
|
+
readonly type: NumericType;
|
|
25
|
+
constructor(string: string, type: NumericType);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Serde shortcut.
|
|
29
|
+
* @internal
|
|
30
|
+
*/
|
|
31
|
+
export declare function nv(string: string): NumericValue;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smithy/core",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.0",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"build": "yarn lint && concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types && yarn build:types:downlevel'",
|
|
6
6
|
"build:cjs": "node ../../scripts/inline core",
|
|
@@ -45,6 +45,13 @@
|
|
|
45
45
|
"import": "./dist-es/submodules/protocols/index.js",
|
|
46
46
|
"require": "./dist-cjs/submodules/protocols/index.js",
|
|
47
47
|
"types": "./dist-types/submodules/protocols/index.d.ts"
|
|
48
|
+
},
|
|
49
|
+
"./serde": {
|
|
50
|
+
"module": "./dist-es/submodules/serde/index.js",
|
|
51
|
+
"node": "./dist-cjs/submodules/serde/index.js",
|
|
52
|
+
"import": "./dist-es/submodules/serde/index.js",
|
|
53
|
+
"require": "./dist-cjs/submodules/serde/index.js",
|
|
54
|
+
"types": "./dist-types/submodules/serde/index.d.ts"
|
|
48
55
|
}
|
|
49
56
|
},
|
|
50
57
|
"author": {
|
|
@@ -54,12 +61,12 @@
|
|
|
54
61
|
},
|
|
55
62
|
"license": "Apache-2.0",
|
|
56
63
|
"dependencies": {
|
|
57
|
-
"@smithy/middleware-serde": "^4.0.
|
|
58
|
-
"@smithy/protocol-http": "^5.0
|
|
59
|
-
"@smithy/types": "^4.
|
|
64
|
+
"@smithy/middleware-serde": "^4.0.3",
|
|
65
|
+
"@smithy/protocol-http": "^5.1.0",
|
|
66
|
+
"@smithy/types": "^4.2.0",
|
|
60
67
|
"@smithy/util-body-length-browser": "^4.0.0",
|
|
61
|
-
"@smithy/util-middleware": "^4.0.
|
|
62
|
-
"@smithy/util-stream": "^4.
|
|
68
|
+
"@smithy/util-middleware": "^4.0.2",
|
|
69
|
+
"@smithy/util-stream": "^4.2.0",
|
|
63
70
|
"@smithy/util-utf8": "^4.0.0",
|
|
64
71
|
"tslib": "^2.6.2"
|
|
65
72
|
},
|
|
@@ -78,12 +85,14 @@
|
|
|
78
85
|
"./cbor.js",
|
|
79
86
|
"./protocols.d.ts",
|
|
80
87
|
"./protocols.js",
|
|
88
|
+
"./serde.d.ts",
|
|
89
|
+
"./serde.js",
|
|
81
90
|
"dist-*/**"
|
|
82
91
|
],
|
|
83
|
-
"homepage": "https://github.com/
|
|
92
|
+
"homepage": "https://github.com/smithy-lang/smithy-typescript/tree/main/packages/core",
|
|
84
93
|
"repository": {
|
|
85
94
|
"type": "git",
|
|
86
|
-
"url": "https://github.com/
|
|
95
|
+
"url": "https://github.com/smithy-lang/smithy-typescript.git",
|
|
87
96
|
"directory": "packages/core"
|
|
88
97
|
},
|
|
89
98
|
"devDependencies": {
|
package/serde.d.ts
ADDED