@aws-sdk/token-providers 3.382.0 → 3.385.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.
@@ -0,0 +1,732 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UnsupportedGrantTypeException = exports.UnauthorizedClientException = exports.SlowDownException = exports.SSOOIDCClient = exports.InvalidScopeException = exports.InvalidRequestException = exports.InvalidClientException = exports.InternalServerException = exports.ExpiredTokenException = exports.CreateTokenCommand = exports.AuthorizationPendingException = exports.AccessDeniedException = void 0;
4
+ const middleware_host_header_1 = require("@aws-sdk/middleware-host-header");
5
+ const middleware_logger_1 = require("@aws-sdk/middleware-logger");
6
+ const middleware_recursion_detection_1 = require("@aws-sdk/middleware-recursion-detection");
7
+ const middleware_user_agent_1 = require("@aws-sdk/middleware-user-agent");
8
+ const config_resolver_1 = require("@smithy/config-resolver");
9
+ const middleware_content_length_1 = require("@smithy/middleware-content-length");
10
+ const middleware_endpoint_1 = require("@smithy/middleware-endpoint");
11
+ const middleware_retry_1 = require("@smithy/middleware-retry");
12
+ const smithy_client_1 = require("@smithy/smithy-client");
13
+ var resolveClientEndpointParameters = (options) => {
14
+ var _a, _b;
15
+ return {
16
+ ...options,
17
+ useDualstackEndpoint: (_a = options.useDualstackEndpoint) !== null && _a !== void 0 ? _a : false,
18
+ useFipsEndpoint: (_b = options.useFipsEndpoint) !== null && _b !== void 0 ? _b : false,
19
+ defaultSigningName: "awsssooidc"
20
+ };
21
+ };
22
+ var package_default = {
23
+ name: "@aws-sdk/client-sso-oidc",
24
+ description: "AWS SDK for JavaScript Sso Oidc Client for Node.js, Browser and React Native",
25
+ version: "3.382.0",
26
+ scripts: {
27
+ build: "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'",
28
+ "build:cjs": "tsc -p tsconfig.cjs.json",
29
+ "build:docs": "typedoc",
30
+ "build:es": "tsc -p tsconfig.es.json",
31
+ "build:include:deps": "lerna run --scope $npm_package_name --include-dependencies build",
32
+ "build:types": "tsc -p tsconfig.types.json",
33
+ "build:types:downlevel": "downlevel-dts dist-types dist-types/ts3.4",
34
+ clean: "rimraf ./dist-* && rimraf *.tsbuildinfo",
35
+ "extract:docs": "api-extractor run --local",
36
+ "generate:client": "node ../../scripts/generate-clients/single-service --solo sso-oidc"
37
+ },
38
+ main: "./dist-cjs/index.js",
39
+ types: "./dist-types/index.d.ts",
40
+ module: "./dist-es/index.js",
41
+ sideEffects: false,
42
+ dependencies: {
43
+ "@aws-crypto/sha256-browser": "3.0.0",
44
+ "@aws-crypto/sha256-js": "3.0.0",
45
+ "@aws-sdk/middleware-host-header": "*",
46
+ "@aws-sdk/middleware-logger": "*",
47
+ "@aws-sdk/middleware-recursion-detection": "*",
48
+ "@aws-sdk/middleware-user-agent": "*",
49
+ "@aws-sdk/types": "*",
50
+ "@aws-sdk/util-endpoints": "*",
51
+ "@aws-sdk/util-user-agent-browser": "*",
52
+ "@aws-sdk/util-user-agent-node": "*",
53
+ "@smithy/config-resolver": "^2.0.1",
54
+ "@smithy/fetch-http-handler": "^2.0.1",
55
+ "@smithy/hash-node": "^2.0.1",
56
+ "@smithy/invalid-dependency": "^2.0.1",
57
+ "@smithy/middleware-content-length": "^2.0.1",
58
+ "@smithy/middleware-endpoint": "^2.0.1",
59
+ "@smithy/middleware-retry": "^2.0.1",
60
+ "@smithy/middleware-serde": "^2.0.1",
61
+ "@smithy/middleware-stack": "^2.0.0",
62
+ "@smithy/node-config-provider": "^2.0.1",
63
+ "@smithy/node-http-handler": "^2.0.1",
64
+ "@smithy/protocol-http": "^2.0.1",
65
+ "@smithy/smithy-client": "^2.0.1",
66
+ "@smithy/types": "^2.0.2",
67
+ "@smithy/url-parser": "^2.0.1",
68
+ "@smithy/util-base64": "^2.0.0",
69
+ "@smithy/util-body-length-browser": "^2.0.0",
70
+ "@smithy/util-body-length-node": "^2.0.0",
71
+ "@smithy/util-defaults-mode-browser": "^2.0.1",
72
+ "@smithy/util-defaults-mode-node": "^2.0.1",
73
+ "@smithy/util-retry": "^2.0.0",
74
+ "@smithy/util-utf8": "^2.0.0",
75
+ tslib: "^2.5.0"
76
+ },
77
+ devDependencies: {
78
+ "@smithy/service-client-documentation-generator": "^2.0.0",
79
+ "@tsconfig/node14": "1.0.3",
80
+ "@types/node": "^14.14.31",
81
+ concurrently: "7.0.0",
82
+ "downlevel-dts": "0.10.1",
83
+ rimraf: "3.0.2",
84
+ typedoc: "0.23.23",
85
+ typescript: "~4.9.5"
86
+ },
87
+ engines: {
88
+ node: ">=14.0.0"
89
+ },
90
+ typesVersions: {
91
+ "<4.0": {
92
+ "dist-types/*": [
93
+ "dist-types/ts3.4/*"
94
+ ]
95
+ }
96
+ },
97
+ files: [
98
+ "dist-*/**"
99
+ ],
100
+ author: {
101
+ name: "AWS SDK for JavaScript Team",
102
+ url: "https://aws.amazon.com/javascript/"
103
+ },
104
+ license: "Apache-2.0",
105
+ browser: {
106
+ "./dist-es/runtimeConfig": "./dist-es/runtimeConfig.browser"
107
+ },
108
+ "react-native": {
109
+ "./dist-es/runtimeConfig": "./dist-es/runtimeConfig.native"
110
+ },
111
+ homepage: "https://github.com/aws/aws-sdk-js-v3/tree/main/clients/client-sso-oidc",
112
+ repository: {
113
+ type: "git",
114
+ url: "https://github.com/aws/aws-sdk-js-v3.git",
115
+ directory: "clients/client-sso-oidc"
116
+ }
117
+ };
118
+ const sha256_browser_1 = require("@aws-crypto/sha256-browser");
119
+ const util_user_agent_browser_1 = require("@aws-sdk/util-user-agent-browser");
120
+ const config_resolver_2 = require("@smithy/config-resolver");
121
+ const fetch_http_handler_1 = require("@smithy/fetch-http-handler");
122
+ const invalid_dependency_1 = require("@smithy/invalid-dependency");
123
+ const util_body_length_browser_1 = require("@smithy/util-body-length-browser");
124
+ const util_retry_1 = require("@smithy/util-retry");
125
+ const smithy_client_2 = require("@smithy/smithy-client");
126
+ const url_parser_1 = require("@smithy/url-parser");
127
+ const util_base64_1 = require("@smithy/util-base64");
128
+ const util_utf8_1 = require("@smithy/util-utf8");
129
+ const util_endpoints_1 = require("@aws-sdk/util-endpoints");
130
+ var p = "required";
131
+ var q = "fn";
132
+ var r = "argv";
133
+ var s = "ref";
134
+ var a = "PartitionResult";
135
+ var b = "tree";
136
+ var c = "error";
137
+ var d = "endpoint";
138
+ var e = { [p]: false, "type": "String" };
139
+ var f = { [p]: true, "default": false, "type": "Boolean" };
140
+ var g = { [s]: "Endpoint" };
141
+ var h = { [q]: "booleanEquals", [r]: [{ [s]: "UseFIPS" }, true] };
142
+ var i = { [q]: "booleanEquals", [r]: [{ [s]: "UseDualStack" }, true] };
143
+ var j = {};
144
+ var k = { [q]: "booleanEquals", [r]: [true, { [q]: "getAttr", [r]: [{ [s]: a }, "supportsFIPS"] }] };
145
+ var l = { [q]: "booleanEquals", [r]: [true, { [q]: "getAttr", [r]: [{ [s]: a }, "supportsDualStack"] }] };
146
+ var m = [g];
147
+ var n = [h];
148
+ var o = [i];
149
+ var _data = { version: "1.0", parameters: { Region: e, UseDualStack: f, UseFIPS: f, Endpoint: e }, rules: [{ conditions: [{ [q]: "aws.partition", [r]: [{ [s]: "Region" }], assign: a }], type: b, rules: [{ conditions: [{ [q]: "isSet", [r]: m }, { [q]: "parseURL", [r]: m, assign: "url" }], type: b, rules: [{ conditions: n, error: "Invalid Configuration: FIPS and custom endpoint are not supported", type: c }, { type: b, rules: [{ conditions: o, error: "Invalid Configuration: Dualstack and custom endpoint are not supported", type: c }, { endpoint: { url: g, properties: j, headers: j }, type: d }] }] }, { conditions: [h, i], type: b, rules: [{ conditions: [k, l], type: b, rules: [{ endpoint: { url: "https://oidc-fips.{Region}.{PartitionResult#dualStackDnsSuffix}", properties: j, headers: j }, type: d }] }, { error: "FIPS and DualStack are enabled, but this partition does not support one or both", type: c }] }, { conditions: n, type: b, rules: [{ conditions: [k], type: b, rules: [{ type: b, rules: [{ endpoint: { url: "https://oidc-fips.{Region}.{PartitionResult#dnsSuffix}", properties: j, headers: j }, type: d }] }] }, { error: "FIPS is enabled but this partition does not support FIPS", type: c }] }, { conditions: o, type: b, rules: [{ conditions: [l], type: b, rules: [{ endpoint: { url: "https://oidc.{Region}.{PartitionResult#dualStackDnsSuffix}", properties: j, headers: j }, type: d }] }, { error: "DualStack is enabled but this partition does not support DualStack", type: c }] }, { endpoint: { url: "https://oidc.{Region}.{PartitionResult#dnsSuffix}", properties: j, headers: j }, type: d }] }] };
150
+ var ruleSet = _data;
151
+ var defaultEndpointResolver = (endpointParams, context = {}) => {
152
+ return (0, util_endpoints_1.resolveEndpoint)(ruleSet, {
153
+ endpointParams,
154
+ logger: context.logger
155
+ });
156
+ };
157
+ var getRuntimeConfig = (config) => {
158
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
159
+ return ({
160
+ apiVersion: "2019-06-10",
161
+ base64Decoder: (_a = config === null || config === void 0 ? void 0 : config.base64Decoder) !== null && _a !== void 0 ? _a : util_base64_1.fromBase64,
162
+ base64Encoder: (_b = config === null || config === void 0 ? void 0 : config.base64Encoder) !== null && _b !== void 0 ? _b : util_base64_1.toBase64,
163
+ disableHostPrefix: (_c = config === null || config === void 0 ? void 0 : config.disableHostPrefix) !== null && _c !== void 0 ? _c : false,
164
+ endpointProvider: (_d = config === null || config === void 0 ? void 0 : config.endpointProvider) !== null && _d !== void 0 ? _d : defaultEndpointResolver,
165
+ logger: (_e = config === null || config === void 0 ? void 0 : config.logger) !== null && _e !== void 0 ? _e : new smithy_client_2.NoOpLogger(),
166
+ serviceId: (_f = config === null || config === void 0 ? void 0 : config.serviceId) !== null && _f !== void 0 ? _f : "SSO OIDC",
167
+ urlParser: (_g = config === null || config === void 0 ? void 0 : config.urlParser) !== null && _g !== void 0 ? _g : url_parser_1.parseUrl,
168
+ utf8Decoder: (_h = config === null || config === void 0 ? void 0 : config.utf8Decoder) !== null && _h !== void 0 ? _h : util_utf8_1.fromUtf8,
169
+ utf8Encoder: (_j = config === null || config === void 0 ? void 0 : config.utf8Encoder) !== null && _j !== void 0 ? _j : util_utf8_1.toUtf8
170
+ });
171
+ };
172
+ const smithy_client_3 = require("@smithy/smithy-client");
173
+ const util_defaults_mode_browser_1 = require("@smithy/util-defaults-mode-browser");
174
+ var getRuntimeConfig2 = (config) => {
175
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
176
+ const defaultsMode = (0, util_defaults_mode_browser_1.resolveDefaultsModeConfig)(config);
177
+ const defaultConfigProvider = () => defaultsMode().then(smithy_client_3.loadConfigsForDefaultMode);
178
+ const clientSharedValues = getRuntimeConfig(config);
179
+ return {
180
+ ...clientSharedValues,
181
+ ...config,
182
+ runtime: "browser",
183
+ defaultsMode,
184
+ bodyLengthChecker: (_a = config === null || config === void 0 ? void 0 : config.bodyLengthChecker) !== null && _a !== void 0 ? _a : util_body_length_browser_1.calculateBodyLength,
185
+ defaultUserAgentProvider: (_b = config === null || config === void 0 ? void 0 : config.defaultUserAgentProvider) !== null && _b !== void 0 ? _b : (0, util_user_agent_browser_1.defaultUserAgent)({ serviceId: clientSharedValues.serviceId, clientVersion: package_default.version }),
186
+ maxAttempts: (_c = config === null || config === void 0 ? void 0 : config.maxAttempts) !== null && _c !== void 0 ? _c : util_retry_1.DEFAULT_MAX_ATTEMPTS,
187
+ region: (_d = config === null || config === void 0 ? void 0 : config.region) !== null && _d !== void 0 ? _d : (0, invalid_dependency_1.invalidProvider)("Region is missing"),
188
+ requestHandler: (_e = config === null || config === void 0 ? void 0 : config.requestHandler) !== null && _e !== void 0 ? _e : new fetch_http_handler_1.FetchHttpHandler(defaultConfigProvider),
189
+ retryMode: (_f = config === null || config === void 0 ? void 0 : config.retryMode) !== null && _f !== void 0 ? _f : (async () => (await defaultConfigProvider()).retryMode || util_retry_1.DEFAULT_RETRY_MODE),
190
+ sha256: (_g = config === null || config === void 0 ? void 0 : config.sha256) !== null && _g !== void 0 ? _g : sha256_browser_1.Sha256,
191
+ streamCollector: (_h = config === null || config === void 0 ? void 0 : config.streamCollector) !== null && _h !== void 0 ? _h : fetch_http_handler_1.streamCollector,
192
+ useDualstackEndpoint: (_j = config === null || config === void 0 ? void 0 : config.useDualstackEndpoint) !== null && _j !== void 0 ? _j : (() => Promise.resolve(config_resolver_2.DEFAULT_USE_DUALSTACK_ENDPOINT)),
193
+ useFipsEndpoint: (_k = config === null || config === void 0 ? void 0 : config.useFipsEndpoint) !== null && _k !== void 0 ? _k : (() => Promise.resolve(config_resolver_2.DEFAULT_USE_FIPS_ENDPOINT))
194
+ };
195
+ };
196
+ var SSOOIDCClient = class extends smithy_client_1.Client {
197
+ constructor(configuration) {
198
+ const _config_0 = getRuntimeConfig2(configuration);
199
+ const _config_1 = resolveClientEndpointParameters(_config_0);
200
+ const _config_2 = (0, config_resolver_1.resolveRegionConfig)(_config_1);
201
+ const _config_3 = (0, middleware_endpoint_1.resolveEndpointConfig)(_config_2);
202
+ const _config_4 = (0, middleware_retry_1.resolveRetryConfig)(_config_3);
203
+ const _config_5 = (0, middleware_host_header_1.resolveHostHeaderConfig)(_config_4);
204
+ const _config_6 = (0, middleware_user_agent_1.resolveUserAgentConfig)(_config_5);
205
+ super(_config_6);
206
+ this.config = _config_6;
207
+ this.middlewareStack.use((0, middleware_retry_1.getRetryPlugin)(this.config));
208
+ this.middlewareStack.use((0, middleware_content_length_1.getContentLengthPlugin)(this.config));
209
+ this.middlewareStack.use((0, middleware_host_header_1.getHostHeaderPlugin)(this.config));
210
+ this.middlewareStack.use((0, middleware_logger_1.getLoggerPlugin)(this.config));
211
+ this.middlewareStack.use((0, middleware_recursion_detection_1.getRecursionDetectionPlugin)(this.config));
212
+ this.middlewareStack.use((0, middleware_user_agent_1.getUserAgentPlugin)(this.config));
213
+ }
214
+ destroy() {
215
+ super.destroy();
216
+ }
217
+ };
218
+ exports.SSOOIDCClient = SSOOIDCClient;
219
+ const middleware_endpoint_2 = require("@smithy/middleware-endpoint");
220
+ const middleware_serde_1 = require("@smithy/middleware-serde");
221
+ const smithy_client_4 = require("@smithy/smithy-client");
222
+ const protocol_http_1 = require("@smithy/protocol-http");
223
+ const smithy_client_5 = require("@smithy/smithy-client");
224
+ const smithy_client_6 = require("@smithy/smithy-client");
225
+ var SSOOIDCServiceException = class _SSOOIDCServiceException extends smithy_client_6.ServiceException {
226
+ constructor(options) {
227
+ super(options);
228
+ Object.setPrototypeOf(this, _SSOOIDCServiceException.prototype);
229
+ }
230
+ };
231
+ var AccessDeniedException = class _AccessDeniedException extends SSOOIDCServiceException {
232
+ constructor(opts) {
233
+ super({
234
+ name: "AccessDeniedException",
235
+ $fault: "client",
236
+ ...opts
237
+ });
238
+ this.name = "AccessDeniedException";
239
+ this.$fault = "client";
240
+ Object.setPrototypeOf(this, _AccessDeniedException.prototype);
241
+ this.error = opts.error;
242
+ this.error_description = opts.error_description;
243
+ }
244
+ };
245
+ exports.AccessDeniedException = AccessDeniedException;
246
+ var AuthorizationPendingException = class _AuthorizationPendingException extends SSOOIDCServiceException {
247
+ constructor(opts) {
248
+ super({
249
+ name: "AuthorizationPendingException",
250
+ $fault: "client",
251
+ ...opts
252
+ });
253
+ this.name = "AuthorizationPendingException";
254
+ this.$fault = "client";
255
+ Object.setPrototypeOf(this, _AuthorizationPendingException.prototype);
256
+ this.error = opts.error;
257
+ this.error_description = opts.error_description;
258
+ }
259
+ };
260
+ exports.AuthorizationPendingException = AuthorizationPendingException;
261
+ var ExpiredTokenException = class _ExpiredTokenException extends SSOOIDCServiceException {
262
+ constructor(opts) {
263
+ super({
264
+ name: "ExpiredTokenException",
265
+ $fault: "client",
266
+ ...opts
267
+ });
268
+ this.name = "ExpiredTokenException";
269
+ this.$fault = "client";
270
+ Object.setPrototypeOf(this, _ExpiredTokenException.prototype);
271
+ this.error = opts.error;
272
+ this.error_description = opts.error_description;
273
+ }
274
+ };
275
+ exports.ExpiredTokenException = ExpiredTokenException;
276
+ var InternalServerException = class _InternalServerException extends SSOOIDCServiceException {
277
+ constructor(opts) {
278
+ super({
279
+ name: "InternalServerException",
280
+ $fault: "server",
281
+ ...opts
282
+ });
283
+ this.name = "InternalServerException";
284
+ this.$fault = "server";
285
+ Object.setPrototypeOf(this, _InternalServerException.prototype);
286
+ this.error = opts.error;
287
+ this.error_description = opts.error_description;
288
+ }
289
+ };
290
+ exports.InternalServerException = InternalServerException;
291
+ var InvalidClientException = class _InvalidClientException extends SSOOIDCServiceException {
292
+ constructor(opts) {
293
+ super({
294
+ name: "InvalidClientException",
295
+ $fault: "client",
296
+ ...opts
297
+ });
298
+ this.name = "InvalidClientException";
299
+ this.$fault = "client";
300
+ Object.setPrototypeOf(this, _InvalidClientException.prototype);
301
+ this.error = opts.error;
302
+ this.error_description = opts.error_description;
303
+ }
304
+ };
305
+ exports.InvalidClientException = InvalidClientException;
306
+ var InvalidGrantException = class _InvalidGrantException extends SSOOIDCServiceException {
307
+ constructor(opts) {
308
+ super({
309
+ name: "InvalidGrantException",
310
+ $fault: "client",
311
+ ...opts
312
+ });
313
+ this.name = "InvalidGrantException";
314
+ this.$fault = "client";
315
+ Object.setPrototypeOf(this, _InvalidGrantException.prototype);
316
+ this.error = opts.error;
317
+ this.error_description = opts.error_description;
318
+ }
319
+ };
320
+ var InvalidRequestException = class _InvalidRequestException extends SSOOIDCServiceException {
321
+ constructor(opts) {
322
+ super({
323
+ name: "InvalidRequestException",
324
+ $fault: "client",
325
+ ...opts
326
+ });
327
+ this.name = "InvalidRequestException";
328
+ this.$fault = "client";
329
+ Object.setPrototypeOf(this, _InvalidRequestException.prototype);
330
+ this.error = opts.error;
331
+ this.error_description = opts.error_description;
332
+ }
333
+ };
334
+ exports.InvalidRequestException = InvalidRequestException;
335
+ var InvalidScopeException = class _InvalidScopeException extends SSOOIDCServiceException {
336
+ constructor(opts) {
337
+ super({
338
+ name: "InvalidScopeException",
339
+ $fault: "client",
340
+ ...opts
341
+ });
342
+ this.name = "InvalidScopeException";
343
+ this.$fault = "client";
344
+ Object.setPrototypeOf(this, _InvalidScopeException.prototype);
345
+ this.error = opts.error;
346
+ this.error_description = opts.error_description;
347
+ }
348
+ };
349
+ exports.InvalidScopeException = InvalidScopeException;
350
+ var SlowDownException = class _SlowDownException extends SSOOIDCServiceException {
351
+ constructor(opts) {
352
+ super({
353
+ name: "SlowDownException",
354
+ $fault: "client",
355
+ ...opts
356
+ });
357
+ this.name = "SlowDownException";
358
+ this.$fault = "client";
359
+ Object.setPrototypeOf(this, _SlowDownException.prototype);
360
+ this.error = opts.error;
361
+ this.error_description = opts.error_description;
362
+ }
363
+ };
364
+ exports.SlowDownException = SlowDownException;
365
+ var UnauthorizedClientException = class _UnauthorizedClientException extends SSOOIDCServiceException {
366
+ constructor(opts) {
367
+ super({
368
+ name: "UnauthorizedClientException",
369
+ $fault: "client",
370
+ ...opts
371
+ });
372
+ this.name = "UnauthorizedClientException";
373
+ this.$fault = "client";
374
+ Object.setPrototypeOf(this, _UnauthorizedClientException.prototype);
375
+ this.error = opts.error;
376
+ this.error_description = opts.error_description;
377
+ }
378
+ };
379
+ exports.UnauthorizedClientException = UnauthorizedClientException;
380
+ var UnsupportedGrantTypeException = class _UnsupportedGrantTypeException extends SSOOIDCServiceException {
381
+ constructor(opts) {
382
+ super({
383
+ name: "UnsupportedGrantTypeException",
384
+ $fault: "client",
385
+ ...opts
386
+ });
387
+ this.name = "UnsupportedGrantTypeException";
388
+ this.$fault = "client";
389
+ Object.setPrototypeOf(this, _UnsupportedGrantTypeException.prototype);
390
+ this.error = opts.error;
391
+ this.error_description = opts.error_description;
392
+ }
393
+ };
394
+ exports.UnsupportedGrantTypeException = UnsupportedGrantTypeException;
395
+ var se_CreateTokenCommand = async (input, context) => {
396
+ const { hostname, protocol = "https", port, path: basePath } = await context.endpoint();
397
+ const headers = {
398
+ "content-type": "application/json"
399
+ };
400
+ const resolvedPath = `${(basePath === null || basePath === void 0 ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/token`;
401
+ let body;
402
+ body = JSON.stringify((0, smithy_client_5.take)(input, {
403
+ clientId: [],
404
+ clientSecret: [],
405
+ code: [],
406
+ deviceCode: [],
407
+ grantType: [],
408
+ redirectUri: [],
409
+ refreshToken: [],
410
+ scope: (_) => (0, smithy_client_5._json)(_)
411
+ }));
412
+ return new protocol_http_1.HttpRequest({
413
+ protocol,
414
+ hostname,
415
+ port,
416
+ method: "POST",
417
+ headers,
418
+ path: resolvedPath,
419
+ body
420
+ });
421
+ };
422
+ var de_CreateTokenCommand = async (output, context) => {
423
+ if (output.statusCode !== 200 && output.statusCode >= 300) {
424
+ return de_CreateTokenCommandError(output, context);
425
+ }
426
+ const contents = (0, smithy_client_5.map)({
427
+ $metadata: deserializeMetadata(output)
428
+ });
429
+ const data = (0, smithy_client_5.expectNonNull)((0, smithy_client_5.expectObject)(await parseBody(output.body, context)), "body");
430
+ const doc = (0, smithy_client_5.take)(data, {
431
+ accessToken: smithy_client_5.expectString,
432
+ expiresIn: smithy_client_5.expectInt32,
433
+ idToken: smithy_client_5.expectString,
434
+ refreshToken: smithy_client_5.expectString,
435
+ tokenType: smithy_client_5.expectString
436
+ });
437
+ Object.assign(contents, doc);
438
+ return contents;
439
+ };
440
+ var de_CreateTokenCommandError = async (output, context) => {
441
+ const parsedOutput = {
442
+ ...output,
443
+ body: await parseErrorBody(output.body, context)
444
+ };
445
+ const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
446
+ switch (errorCode) {
447
+ case "AccessDeniedException":
448
+ case "com.amazonaws.ssooidc#AccessDeniedException":
449
+ throw await de_AccessDeniedExceptionRes(parsedOutput, context);
450
+ case "AuthorizationPendingException":
451
+ case "com.amazonaws.ssooidc#AuthorizationPendingException":
452
+ throw await de_AuthorizationPendingExceptionRes(parsedOutput, context);
453
+ case "ExpiredTokenException":
454
+ case "com.amazonaws.ssooidc#ExpiredTokenException":
455
+ throw await de_ExpiredTokenExceptionRes(parsedOutput, context);
456
+ case "InternalServerException":
457
+ case "com.amazonaws.ssooidc#InternalServerException":
458
+ throw await de_InternalServerExceptionRes(parsedOutput, context);
459
+ case "InvalidClientException":
460
+ case "com.amazonaws.ssooidc#InvalidClientException":
461
+ throw await de_InvalidClientExceptionRes(parsedOutput, context);
462
+ case "InvalidGrantException":
463
+ case "com.amazonaws.ssooidc#InvalidGrantException":
464
+ throw await de_InvalidGrantExceptionRes(parsedOutput, context);
465
+ case "InvalidRequestException":
466
+ case "com.amazonaws.ssooidc#InvalidRequestException":
467
+ throw await de_InvalidRequestExceptionRes(parsedOutput, context);
468
+ case "InvalidScopeException":
469
+ case "com.amazonaws.ssooidc#InvalidScopeException":
470
+ throw await de_InvalidScopeExceptionRes(parsedOutput, context);
471
+ case "SlowDownException":
472
+ case "com.amazonaws.ssooidc#SlowDownException":
473
+ throw await de_SlowDownExceptionRes(parsedOutput, context);
474
+ case "UnauthorizedClientException":
475
+ case "com.amazonaws.ssooidc#UnauthorizedClientException":
476
+ throw await de_UnauthorizedClientExceptionRes(parsedOutput, context);
477
+ case "UnsupportedGrantTypeException":
478
+ case "com.amazonaws.ssooidc#UnsupportedGrantTypeException":
479
+ throw await de_UnsupportedGrantTypeExceptionRes(parsedOutput, context);
480
+ default:
481
+ const parsedBody = parsedOutput.body;
482
+ return throwDefaultError({
483
+ output,
484
+ parsedBody,
485
+ errorCode
486
+ });
487
+ }
488
+ };
489
+ var throwDefaultError = (0, smithy_client_5.withBaseException)(SSOOIDCServiceException);
490
+ var de_AccessDeniedExceptionRes = async (parsedOutput, context) => {
491
+ const contents = (0, smithy_client_5.map)({});
492
+ const data = parsedOutput.body;
493
+ const doc = (0, smithy_client_5.take)(data, {
494
+ error: smithy_client_5.expectString,
495
+ error_description: smithy_client_5.expectString
496
+ });
497
+ Object.assign(contents, doc);
498
+ const exception = new AccessDeniedException({
499
+ $metadata: deserializeMetadata(parsedOutput),
500
+ ...contents
501
+ });
502
+ return (0, smithy_client_5.decorateServiceException)(exception, parsedOutput.body);
503
+ };
504
+ var de_AuthorizationPendingExceptionRes = async (parsedOutput, context) => {
505
+ const contents = (0, smithy_client_5.map)({});
506
+ const data = parsedOutput.body;
507
+ const doc = (0, smithy_client_5.take)(data, {
508
+ error: smithy_client_5.expectString,
509
+ error_description: smithy_client_5.expectString
510
+ });
511
+ Object.assign(contents, doc);
512
+ const exception = new AuthorizationPendingException({
513
+ $metadata: deserializeMetadata(parsedOutput),
514
+ ...contents
515
+ });
516
+ return (0, smithy_client_5.decorateServiceException)(exception, parsedOutput.body);
517
+ };
518
+ var de_ExpiredTokenExceptionRes = async (parsedOutput, context) => {
519
+ const contents = (0, smithy_client_5.map)({});
520
+ const data = parsedOutput.body;
521
+ const doc = (0, smithy_client_5.take)(data, {
522
+ error: smithy_client_5.expectString,
523
+ error_description: smithy_client_5.expectString
524
+ });
525
+ Object.assign(contents, doc);
526
+ const exception = new ExpiredTokenException({
527
+ $metadata: deserializeMetadata(parsedOutput),
528
+ ...contents
529
+ });
530
+ return (0, smithy_client_5.decorateServiceException)(exception, parsedOutput.body);
531
+ };
532
+ var de_InternalServerExceptionRes = async (parsedOutput, context) => {
533
+ const contents = (0, smithy_client_5.map)({});
534
+ const data = parsedOutput.body;
535
+ const doc = (0, smithy_client_5.take)(data, {
536
+ error: smithy_client_5.expectString,
537
+ error_description: smithy_client_5.expectString
538
+ });
539
+ Object.assign(contents, doc);
540
+ const exception = new InternalServerException({
541
+ $metadata: deserializeMetadata(parsedOutput),
542
+ ...contents
543
+ });
544
+ return (0, smithy_client_5.decorateServiceException)(exception, parsedOutput.body);
545
+ };
546
+ var de_InvalidClientExceptionRes = async (parsedOutput, context) => {
547
+ const contents = (0, smithy_client_5.map)({});
548
+ const data = parsedOutput.body;
549
+ const doc = (0, smithy_client_5.take)(data, {
550
+ error: smithy_client_5.expectString,
551
+ error_description: smithy_client_5.expectString
552
+ });
553
+ Object.assign(contents, doc);
554
+ const exception = new InvalidClientException({
555
+ $metadata: deserializeMetadata(parsedOutput),
556
+ ...contents
557
+ });
558
+ return (0, smithy_client_5.decorateServiceException)(exception, parsedOutput.body);
559
+ };
560
+ var de_InvalidGrantExceptionRes = async (parsedOutput, context) => {
561
+ const contents = (0, smithy_client_5.map)({});
562
+ const data = parsedOutput.body;
563
+ const doc = (0, smithy_client_5.take)(data, {
564
+ error: smithy_client_5.expectString,
565
+ error_description: smithy_client_5.expectString
566
+ });
567
+ Object.assign(contents, doc);
568
+ const exception = new InvalidGrantException({
569
+ $metadata: deserializeMetadata(parsedOutput),
570
+ ...contents
571
+ });
572
+ return (0, smithy_client_5.decorateServiceException)(exception, parsedOutput.body);
573
+ };
574
+ var de_InvalidRequestExceptionRes = async (parsedOutput, context) => {
575
+ const contents = (0, smithy_client_5.map)({});
576
+ const data = parsedOutput.body;
577
+ const doc = (0, smithy_client_5.take)(data, {
578
+ error: smithy_client_5.expectString,
579
+ error_description: smithy_client_5.expectString
580
+ });
581
+ Object.assign(contents, doc);
582
+ const exception = new InvalidRequestException({
583
+ $metadata: deserializeMetadata(parsedOutput),
584
+ ...contents
585
+ });
586
+ return (0, smithy_client_5.decorateServiceException)(exception, parsedOutput.body);
587
+ };
588
+ var de_InvalidScopeExceptionRes = async (parsedOutput, context) => {
589
+ const contents = (0, smithy_client_5.map)({});
590
+ const data = parsedOutput.body;
591
+ const doc = (0, smithy_client_5.take)(data, {
592
+ error: smithy_client_5.expectString,
593
+ error_description: smithy_client_5.expectString
594
+ });
595
+ Object.assign(contents, doc);
596
+ const exception = new InvalidScopeException({
597
+ $metadata: deserializeMetadata(parsedOutput),
598
+ ...contents
599
+ });
600
+ return (0, smithy_client_5.decorateServiceException)(exception, parsedOutput.body);
601
+ };
602
+ var de_SlowDownExceptionRes = async (parsedOutput, context) => {
603
+ const contents = (0, smithy_client_5.map)({});
604
+ const data = parsedOutput.body;
605
+ const doc = (0, smithy_client_5.take)(data, {
606
+ error: smithy_client_5.expectString,
607
+ error_description: smithy_client_5.expectString
608
+ });
609
+ Object.assign(contents, doc);
610
+ const exception = new SlowDownException({
611
+ $metadata: deserializeMetadata(parsedOutput),
612
+ ...contents
613
+ });
614
+ return (0, smithy_client_5.decorateServiceException)(exception, parsedOutput.body);
615
+ };
616
+ var de_UnauthorizedClientExceptionRes = async (parsedOutput, context) => {
617
+ const contents = (0, smithy_client_5.map)({});
618
+ const data = parsedOutput.body;
619
+ const doc = (0, smithy_client_5.take)(data, {
620
+ error: smithy_client_5.expectString,
621
+ error_description: smithy_client_5.expectString
622
+ });
623
+ Object.assign(contents, doc);
624
+ const exception = new UnauthorizedClientException({
625
+ $metadata: deserializeMetadata(parsedOutput),
626
+ ...contents
627
+ });
628
+ return (0, smithy_client_5.decorateServiceException)(exception, parsedOutput.body);
629
+ };
630
+ var de_UnsupportedGrantTypeExceptionRes = async (parsedOutput, context) => {
631
+ const contents = (0, smithy_client_5.map)({});
632
+ const data = parsedOutput.body;
633
+ const doc = (0, smithy_client_5.take)(data, {
634
+ error: smithy_client_5.expectString,
635
+ error_description: smithy_client_5.expectString
636
+ });
637
+ Object.assign(contents, doc);
638
+ const exception = new UnsupportedGrantTypeException({
639
+ $metadata: deserializeMetadata(parsedOutput),
640
+ ...contents
641
+ });
642
+ return (0, smithy_client_5.decorateServiceException)(exception, parsedOutput.body);
643
+ };
644
+ var deserializeMetadata = (output) => {
645
+ var _a, _b;
646
+ return ({
647
+ httpStatusCode: output.statusCode,
648
+ requestId: (_b = (_a = output.headers["x-amzn-requestid"]) !== null && _a !== void 0 ? _a : output.headers["x-amzn-request-id"]) !== null && _b !== void 0 ? _b : output.headers["x-amz-request-id"],
649
+ extendedRequestId: output.headers["x-amz-id-2"],
650
+ cfId: output.headers["x-amz-cf-id"]
651
+ });
652
+ };
653
+ var collectBodyString = (streamBody, context) => (0, smithy_client_5.collectBody)(streamBody, context).then((body) => context.utf8Encoder(body));
654
+ var parseBody = (streamBody, context) => collectBodyString(streamBody, context).then((encoded) => {
655
+ if (encoded.length) {
656
+ return JSON.parse(encoded);
657
+ }
658
+ return {};
659
+ });
660
+ var parseErrorBody = async (errorBody, context) => {
661
+ var _a;
662
+ const value = await parseBody(errorBody, context);
663
+ value.message = (_a = value.message) !== null && _a !== void 0 ? _a : value.Message;
664
+ return value;
665
+ };
666
+ var loadRestJsonErrorCode = (output, data) => {
667
+ const findKey = (object, key) => Object.keys(object).find((k2) => k2.toLowerCase() === key.toLowerCase());
668
+ const sanitizeErrorCode = (rawValue) => {
669
+ let cleanValue = rawValue;
670
+ if (typeof cleanValue === "number") {
671
+ cleanValue = cleanValue.toString();
672
+ }
673
+ if (cleanValue.indexOf(",") >= 0) {
674
+ cleanValue = cleanValue.split(",")[0];
675
+ }
676
+ if (cleanValue.indexOf(":") >= 0) {
677
+ cleanValue = cleanValue.split(":")[0];
678
+ }
679
+ if (cleanValue.indexOf("#") >= 0) {
680
+ cleanValue = cleanValue.split("#")[1];
681
+ }
682
+ return cleanValue;
683
+ };
684
+ const headerKey = findKey(output.headers, "x-amzn-errortype");
685
+ if (headerKey !== void 0) {
686
+ return sanitizeErrorCode(output.headers[headerKey]);
687
+ }
688
+ if (data.code !== void 0) {
689
+ return sanitizeErrorCode(data.code);
690
+ }
691
+ if (data["__type"] !== void 0) {
692
+ return sanitizeErrorCode(data["__type"]);
693
+ }
694
+ };
695
+ var CreateTokenCommand = class _CreateTokenCommand extends smithy_client_4.Command {
696
+ constructor(input) {
697
+ super();
698
+ this.input = input;
699
+ }
700
+ static getEndpointParameterInstructions() {
701
+ return {
702
+ UseFIPS: { type: "builtInParams", name: "useFipsEndpoint" },
703
+ Endpoint: { type: "builtInParams", name: "endpoint" },
704
+ Region: { type: "builtInParams", name: "region" },
705
+ UseDualStack: { type: "builtInParams", name: "useDualstackEndpoint" }
706
+ };
707
+ }
708
+ resolveMiddleware(clientStack, configuration, options) {
709
+ this.middlewareStack.use((0, middleware_serde_1.getSerdePlugin)(configuration, this.serialize, this.deserialize));
710
+ this.middlewareStack.use((0, middleware_endpoint_2.getEndpointPlugin)(configuration, _CreateTokenCommand.getEndpointParameterInstructions()));
711
+ const stack = clientStack.concat(this.middlewareStack);
712
+ const { logger } = configuration;
713
+ const clientName = "SSOOIDCClient";
714
+ const commandName = "CreateTokenCommand";
715
+ const handlerExecutionContext = {
716
+ logger,
717
+ clientName,
718
+ commandName,
719
+ inputFilterSensitiveLog: (_) => _,
720
+ outputFilterSensitiveLog: (_) => _
721
+ };
722
+ const { requestHandler } = configuration;
723
+ return stack.resolve((request) => requestHandler.handle(request.request, options || {}), handlerExecutionContext);
724
+ }
725
+ serialize(input, context) {
726
+ return se_CreateTokenCommand(input, context);
727
+ }
728
+ deserialize(output, context) {
729
+ return de_CreateTokenCommand(output, context);
730
+ }
731
+ };
732
+ exports.CreateTokenCommand = CreateTokenCommand;