@smithy/core 2.5.7 → 3.1.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
CHANGED
|
@@ -60,7 +60,6 @@ function convertHttpAuthSchemesToMap(httpAuthSchemes) {
|
|
|
60
60
|
}
|
|
61
61
|
__name(convertHttpAuthSchemesToMap, "convertHttpAuthSchemesToMap");
|
|
62
62
|
var httpAuthSchemeMiddleware = /* @__PURE__ */ __name((config, mwOptions) => (next, context) => async (args) => {
|
|
63
|
-
var _a;
|
|
64
63
|
const options = config.httpAuthSchemeProvider(
|
|
65
64
|
await mwOptions.httpAuthSchemeParametersProvider(config, context, args.input)
|
|
66
65
|
);
|
|
@@ -78,7 +77,7 @@ var httpAuthSchemeMiddleware = /* @__PURE__ */ __name((config, mwOptions) => (ne
|
|
|
78
77
|
failureReasons.push(`HttpAuthScheme \`${option.schemeId}\` did not have an IdentityProvider configured.`);
|
|
79
78
|
continue;
|
|
80
79
|
}
|
|
81
|
-
const { identityProperties = {}, signingProperties = {} } =
|
|
80
|
+
const { identityProperties = {}, signingProperties = {} } = option.propertiesExtractor?.(config, context) || {};
|
|
82
81
|
option.identityProperties = Object.assign(option.identityProperties || {}, identityProperties);
|
|
83
82
|
option.signingProperties = Object.assign(option.signingProperties || {}, signingProperties);
|
|
84
83
|
smithyContext.selectedHttpAuthScheme = {
|
|
@@ -198,21 +197,30 @@ var normalizeProvider = /* @__PURE__ */ __name((input) => {
|
|
|
198
197
|
}, "normalizeProvider");
|
|
199
198
|
|
|
200
199
|
// src/pagination/createPaginator.ts
|
|
201
|
-
var makePagedClientRequest = /* @__PURE__ */ __name(async (CommandCtor, client, input, ...args) => {
|
|
202
|
-
|
|
200
|
+
var makePagedClientRequest = /* @__PURE__ */ __name(async (CommandCtor, client, input, withCommand = (_) => _, ...args) => {
|
|
201
|
+
let command = new CommandCtor(input);
|
|
202
|
+
command = withCommand(command) ?? command;
|
|
203
|
+
return await client.send(command, ...args);
|
|
203
204
|
}, "makePagedClientRequest");
|
|
204
205
|
function createPaginator(ClientCtor, CommandCtor, inputTokenName, outputTokenName, pageSizeTokenName) {
|
|
205
206
|
return /* @__PURE__ */ __name(async function* paginateOperation(config, input, ...additionalArguments) {
|
|
206
|
-
|
|
207
|
+
const _input = input;
|
|
208
|
+
let token = config.startingToken ?? _input[inputTokenName];
|
|
207
209
|
let hasNext = true;
|
|
208
210
|
let page;
|
|
209
211
|
while (hasNext) {
|
|
210
|
-
|
|
212
|
+
_input[inputTokenName] = token;
|
|
211
213
|
if (pageSizeTokenName) {
|
|
212
|
-
|
|
214
|
+
_input[pageSizeTokenName] = _input[pageSizeTokenName] ?? config.pageSize;
|
|
213
215
|
}
|
|
214
216
|
if (config.client instanceof ClientCtor) {
|
|
215
|
-
page = await makePagedClientRequest(
|
|
217
|
+
page = await makePagedClientRequest(
|
|
218
|
+
CommandCtor,
|
|
219
|
+
config.client,
|
|
220
|
+
input,
|
|
221
|
+
config.withCommand,
|
|
222
|
+
...additionalArguments
|
|
223
|
+
);
|
|
216
224
|
} else {
|
|
217
225
|
throw new Error(`Invalid client, expected instance of ${ClientCtor.name}`);
|
|
218
226
|
}
|
|
@@ -254,7 +262,7 @@ function setFeature(context, feature, value) {
|
|
|
254
262
|
__name(setFeature, "setFeature");
|
|
255
263
|
|
|
256
264
|
// src/util-identity-and-auth/DefaultIdentityProviderConfig.ts
|
|
257
|
-
var
|
|
265
|
+
var DefaultIdentityProviderConfig = class {
|
|
258
266
|
/**
|
|
259
267
|
* Creates an IdentityProviderConfig with a record of scheme IDs to identity providers.
|
|
260
268
|
*
|
|
@@ -268,17 +276,21 @@ var _DefaultIdentityProviderConfig = class _DefaultIdentityProviderConfig {
|
|
|
268
276
|
}
|
|
269
277
|
}
|
|
270
278
|
}
|
|
279
|
+
static {
|
|
280
|
+
__name(this, "DefaultIdentityProviderConfig");
|
|
281
|
+
}
|
|
271
282
|
getIdentityProvider(schemeId) {
|
|
272
283
|
return this.authSchemes.get(schemeId);
|
|
273
284
|
}
|
|
274
285
|
};
|
|
275
|
-
__name(_DefaultIdentityProviderConfig, "DefaultIdentityProviderConfig");
|
|
276
|
-
var DefaultIdentityProviderConfig = _DefaultIdentityProviderConfig;
|
|
277
286
|
|
|
278
287
|
// src/util-identity-and-auth/httpAuthSchemes/httpApiKeyAuth.ts
|
|
279
288
|
|
|
280
289
|
|
|
281
|
-
var
|
|
290
|
+
var HttpApiKeyAuthSigner = class {
|
|
291
|
+
static {
|
|
292
|
+
__name(this, "HttpApiKeyAuthSigner");
|
|
293
|
+
}
|
|
282
294
|
async sign(httpRequest, identity, signingProperties) {
|
|
283
295
|
if (!signingProperties) {
|
|
284
296
|
throw new Error(
|
|
@@ -307,12 +319,13 @@ var _HttpApiKeyAuthSigner = class _HttpApiKeyAuthSigner {
|
|
|
307
319
|
return clonedRequest;
|
|
308
320
|
}
|
|
309
321
|
};
|
|
310
|
-
__name(_HttpApiKeyAuthSigner, "HttpApiKeyAuthSigner");
|
|
311
|
-
var HttpApiKeyAuthSigner = _HttpApiKeyAuthSigner;
|
|
312
322
|
|
|
313
323
|
// src/util-identity-and-auth/httpAuthSchemes/httpBearerAuth.ts
|
|
314
324
|
|
|
315
|
-
var
|
|
325
|
+
var HttpBearerAuthSigner = class {
|
|
326
|
+
static {
|
|
327
|
+
__name(this, "HttpBearerAuthSigner");
|
|
328
|
+
}
|
|
316
329
|
async sign(httpRequest, identity, signingProperties) {
|
|
317
330
|
const clonedRequest = import_protocol_http.HttpRequest.clone(httpRequest);
|
|
318
331
|
if (!identity.token) {
|
|
@@ -322,17 +335,16 @@ var _HttpBearerAuthSigner = class _HttpBearerAuthSigner {
|
|
|
322
335
|
return clonedRequest;
|
|
323
336
|
}
|
|
324
337
|
};
|
|
325
|
-
__name(_HttpBearerAuthSigner, "HttpBearerAuthSigner");
|
|
326
|
-
var HttpBearerAuthSigner = _HttpBearerAuthSigner;
|
|
327
338
|
|
|
328
339
|
// src/util-identity-and-auth/httpAuthSchemes/noAuth.ts
|
|
329
|
-
var
|
|
340
|
+
var NoAuthSigner = class {
|
|
341
|
+
static {
|
|
342
|
+
__name(this, "NoAuthSigner");
|
|
343
|
+
}
|
|
330
344
|
async sign(httpRequest, identity, signingProperties) {
|
|
331
345
|
return httpRequest;
|
|
332
346
|
}
|
|
333
347
|
};
|
|
334
|
-
__name(_NoAuthSigner, "NoAuthSigner");
|
|
335
|
-
var NoAuthSigner = _NoAuthSigner;
|
|
336
348
|
|
|
337
349
|
// src/util-identity-and-auth/memoizeIdentityProvider.ts
|
|
338
350
|
var createIsIdentityExpiredFunction = /* @__PURE__ */ __name((expirationMs) => (identity) => doesIdentityRequireRefresh(identity) && identity.expiration.getTime() - Date.now() < expirationMs, "createIsIdentityExpiredFunction");
|
|
@@ -363,14 +375,14 @@ var memoizeIdentityProvider = /* @__PURE__ */ __name((provider, isExpired, requi
|
|
|
363
375
|
}, "coalesceProvider");
|
|
364
376
|
if (isExpired === void 0) {
|
|
365
377
|
return async (options) => {
|
|
366
|
-
if (!hasResult ||
|
|
378
|
+
if (!hasResult || options?.forceRefresh) {
|
|
367
379
|
resolved = await coalesceProvider(options);
|
|
368
380
|
}
|
|
369
381
|
return resolved;
|
|
370
382
|
};
|
|
371
383
|
}
|
|
372
384
|
return async (options) => {
|
|
373
|
-
if (!hasResult ||
|
|
385
|
+
if (!hasResult || options?.forceRefresh) {
|
|
374
386
|
resolved = await coalesceProvider(options);
|
|
375
387
|
}
|
|
376
388
|
if (isConstant) {
|
|
@@ -164,8 +164,7 @@ function decode(at, to) {
|
|
|
164
164
|
}
|
|
165
165
|
}
|
|
166
166
|
function bytesToUtf8(bytes, at, to) {
|
|
167
|
-
|
|
168
|
-
if (USE_BUFFER && ((_a = bytes.constructor) == null ? void 0 : _a.name) === "Buffer") {
|
|
167
|
+
if (USE_BUFFER && bytes.constructor?.name === "Buffer") {
|
|
169
168
|
return bytes.toString("utf-8", at, to);
|
|
170
169
|
}
|
|
171
170
|
if (textDecoder) {
|
|
@@ -492,7 +491,6 @@ function encodeHeader(major, value) {
|
|
|
492
491
|
}
|
|
493
492
|
}
|
|
494
493
|
function encode(_input) {
|
|
495
|
-
var _a;
|
|
496
494
|
const encodeStack = [_input];
|
|
497
495
|
while (encodeStack.length) {
|
|
498
496
|
const input = encodeStack.pop();
|
|
@@ -602,7 +600,7 @@ function encode(_input) {
|
|
|
602
600
|
encodeHeader(majorMap, keys.length);
|
|
603
601
|
continue;
|
|
604
602
|
}
|
|
605
|
-
throw new Error(`data type ${
|
|
603
|
+
throw new Error(`data type ${input?.constructor?.name ?? typeof input} not compatible for encoding.`);
|
|
606
604
|
}
|
|
607
605
|
}
|
|
608
606
|
|
|
@@ -112,7 +112,7 @@ var RequestBuilder = class {
|
|
|
112
112
|
*/
|
|
113
113
|
bp(uriLabel) {
|
|
114
114
|
this.resolvePathStack.push((basePath) => {
|
|
115
|
-
this.path = `${
|
|
115
|
+
this.path = `${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` + uriLabel;
|
|
116
116
|
});
|
|
117
117
|
return this;
|
|
118
118
|
}
|
|
@@ -1,18 +1,21 @@
|
|
|
1
|
-
const makePagedClientRequest = async (CommandCtor, client, input, ...args) => {
|
|
2
|
-
|
|
1
|
+
const makePagedClientRequest = async (CommandCtor, client, input, withCommand = (_) => _, ...args) => {
|
|
2
|
+
let command = new CommandCtor(input);
|
|
3
|
+
command = withCommand(command) ?? command;
|
|
4
|
+
return await client.send(command, ...args);
|
|
3
5
|
};
|
|
4
6
|
export function createPaginator(ClientCtor, CommandCtor, inputTokenName, outputTokenName, pageSizeTokenName) {
|
|
5
7
|
return async function* paginateOperation(config, input, ...additionalArguments) {
|
|
6
|
-
|
|
8
|
+
const _input = input;
|
|
9
|
+
let token = config.startingToken ?? _input[inputTokenName];
|
|
7
10
|
let hasNext = true;
|
|
8
11
|
let page;
|
|
9
12
|
while (hasNext) {
|
|
10
|
-
|
|
13
|
+
_input[inputTokenName] = token;
|
|
11
14
|
if (pageSizeTokenName) {
|
|
12
|
-
|
|
15
|
+
_input[pageSizeTokenName] = _input[pageSizeTokenName] ?? config.pageSize;
|
|
13
16
|
}
|
|
14
17
|
if (config.client instanceof ClientCtor) {
|
|
15
|
-
page = await makePagedClientRequest(CommandCtor, config.client, input, ...additionalArguments);
|
|
18
|
+
page = await makePagedClientRequest(CommandCtor, config.client, input, config.withCommand, ...additionalArguments);
|
|
16
19
|
}
|
|
17
20
|
else {
|
|
18
21
|
throw new Error(`Invalid client, expected instance of ${ClientCtor.name}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smithy/core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.1.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",
|
|
@@ -54,17 +54,17 @@
|
|
|
54
54
|
},
|
|
55
55
|
"license": "Apache-2.0",
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@smithy/middleware-serde": "^
|
|
58
|
-
"@smithy/protocol-http": "^
|
|
59
|
-
"@smithy/types": "^
|
|
60
|
-
"@smithy/util-body-length-browser": "^
|
|
61
|
-
"@smithy/util-middleware": "^
|
|
62
|
-
"@smithy/util-stream": "^
|
|
63
|
-
"@smithy/util-utf8": "^
|
|
57
|
+
"@smithy/middleware-serde": "^4.0.1",
|
|
58
|
+
"@smithy/protocol-http": "^5.0.1",
|
|
59
|
+
"@smithy/types": "^4.1.0",
|
|
60
|
+
"@smithy/util-body-length-browser": "^4.0.0",
|
|
61
|
+
"@smithy/util-middleware": "^4.0.1",
|
|
62
|
+
"@smithy/util-stream": "^4.0.1",
|
|
63
|
+
"@smithy/util-utf8": "^4.0.0",
|
|
64
64
|
"tslib": "^2.6.2"
|
|
65
65
|
},
|
|
66
66
|
"engines": {
|
|
67
|
-
"node": ">=
|
|
67
|
+
"node": ">=18.0.0"
|
|
68
68
|
},
|
|
69
69
|
"typesVersions": {
|
|
70
70
|
"<4.0": {
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
"directory": "packages/core"
|
|
88
88
|
},
|
|
89
89
|
"devDependencies": {
|
|
90
|
-
"@types/node": "^
|
|
90
|
+
"@types/node": "^18.11.9",
|
|
91
91
|
"concurrently": "7.0.0",
|
|
92
92
|
"downlevel-dts": "0.10.1",
|
|
93
93
|
"json-bigint": "^1.0.0",
|