@aws-sdk/token-providers 3.382.0 → 3.386.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,738 @@
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 util_user_agent_node_1 = require("@aws-sdk/util-user-agent-node");
119
+ const config_resolver_2 = require("@smithy/config-resolver");
120
+ const hash_node_1 = require("@smithy/hash-node");
121
+ const middleware_retry_2 = require("@smithy/middleware-retry");
122
+ const node_config_provider_1 = require("@smithy/node-config-provider");
123
+ const node_http_handler_1 = require("@smithy/node-http-handler");
124
+ const util_body_length_node_1 = require("@smithy/util-body-length-node");
125
+ const util_retry_1 = require("@smithy/util-retry");
126
+ const smithy_client_2 = require("@smithy/smithy-client");
127
+ const url_parser_1 = require("@smithy/url-parser");
128
+ const util_base64_1 = require("@smithy/util-base64");
129
+ const util_utf8_1 = require("@smithy/util-utf8");
130
+ const util_endpoints_1 = require("@aws-sdk/util-endpoints");
131
+ var p = "required";
132
+ var q = "fn";
133
+ var r = "argv";
134
+ var s = "ref";
135
+ var a = "PartitionResult";
136
+ var b = "tree";
137
+ var c = "error";
138
+ var d = "endpoint";
139
+ var e = { [p]: false, "type": "String" };
140
+ var f = { [p]: true, "default": false, "type": "Boolean" };
141
+ var g = { [s]: "Endpoint" };
142
+ var h = { [q]: "booleanEquals", [r]: [{ [s]: "UseFIPS" }, true] };
143
+ var i = { [q]: "booleanEquals", [r]: [{ [s]: "UseDualStack" }, true] };
144
+ var j = {};
145
+ var k = { [q]: "booleanEquals", [r]: [true, { [q]: "getAttr", [r]: [{ [s]: a }, "supportsFIPS"] }] };
146
+ var l = { [q]: "booleanEquals", [r]: [true, { [q]: "getAttr", [r]: [{ [s]: a }, "supportsDualStack"] }] };
147
+ var m = [g];
148
+ var n = [h];
149
+ var o = [i];
150
+ 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 }] }] };
151
+ var ruleSet = _data;
152
+ var defaultEndpointResolver = (endpointParams, context = {}) => {
153
+ return (0, util_endpoints_1.resolveEndpoint)(ruleSet, {
154
+ endpointParams,
155
+ logger: context.logger
156
+ });
157
+ };
158
+ var getRuntimeConfig = (config) => {
159
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
160
+ return ({
161
+ apiVersion: "2019-06-10",
162
+ base64Decoder: (_a = config === null || config === void 0 ? void 0 : config.base64Decoder) !== null && _a !== void 0 ? _a : util_base64_1.fromBase64,
163
+ base64Encoder: (_b = config === null || config === void 0 ? void 0 : config.base64Encoder) !== null && _b !== void 0 ? _b : util_base64_1.toBase64,
164
+ disableHostPrefix: (_c = config === null || config === void 0 ? void 0 : config.disableHostPrefix) !== null && _c !== void 0 ? _c : false,
165
+ endpointProvider: (_d = config === null || config === void 0 ? void 0 : config.endpointProvider) !== null && _d !== void 0 ? _d : defaultEndpointResolver,
166
+ logger: (_e = config === null || config === void 0 ? void 0 : config.logger) !== null && _e !== void 0 ? _e : new smithy_client_2.NoOpLogger(),
167
+ serviceId: (_f = config === null || config === void 0 ? void 0 : config.serviceId) !== null && _f !== void 0 ? _f : "SSO OIDC",
168
+ urlParser: (_g = config === null || config === void 0 ? void 0 : config.urlParser) !== null && _g !== void 0 ? _g : url_parser_1.parseUrl,
169
+ utf8Decoder: (_h = config === null || config === void 0 ? void 0 : config.utf8Decoder) !== null && _h !== void 0 ? _h : util_utf8_1.fromUtf8,
170
+ utf8Encoder: (_j = config === null || config === void 0 ? void 0 : config.utf8Encoder) !== null && _j !== void 0 ? _j : util_utf8_1.toUtf8
171
+ });
172
+ };
173
+ const smithy_client_3 = require("@smithy/smithy-client");
174
+ const util_defaults_mode_node_1 = require("@smithy/util-defaults-mode-node");
175
+ const smithy_client_4 = require("@smithy/smithy-client");
176
+ var getRuntimeConfig2 = (config) => {
177
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
178
+ (0, smithy_client_4.emitWarningIfUnsupportedVersion)(process.version);
179
+ const defaultsMode = (0, util_defaults_mode_node_1.resolveDefaultsModeConfig)(config);
180
+ const defaultConfigProvider = () => defaultsMode().then(smithy_client_3.loadConfigsForDefaultMode);
181
+ const clientSharedValues = getRuntimeConfig(config);
182
+ return {
183
+ ...clientSharedValues,
184
+ ...config,
185
+ runtime: "node",
186
+ defaultsMode,
187
+ bodyLengthChecker: (_a = config === null || config === void 0 ? void 0 : config.bodyLengthChecker) !== null && _a !== void 0 ? _a : util_body_length_node_1.calculateBodyLength,
188
+ defaultUserAgentProvider: (_b = config === null || config === void 0 ? void 0 : config.defaultUserAgentProvider) !== null && _b !== void 0 ? _b : (0, util_user_agent_node_1.defaultUserAgent)({ serviceId: clientSharedValues.serviceId, clientVersion: package_default.version }),
189
+ maxAttempts: (_c = config === null || config === void 0 ? void 0 : config.maxAttempts) !== null && _c !== void 0 ? _c : (0, node_config_provider_1.loadConfig)(middleware_retry_2.NODE_MAX_ATTEMPT_CONFIG_OPTIONS),
190
+ region: (_d = config === null || config === void 0 ? void 0 : config.region) !== null && _d !== void 0 ? _d : (0, node_config_provider_1.loadConfig)(config_resolver_2.NODE_REGION_CONFIG_OPTIONS, config_resolver_2.NODE_REGION_CONFIG_FILE_OPTIONS),
191
+ requestHandler: (_e = config === null || config === void 0 ? void 0 : config.requestHandler) !== null && _e !== void 0 ? _e : new node_http_handler_1.NodeHttpHandler(defaultConfigProvider),
192
+ retryMode: (_f = config === null || config === void 0 ? void 0 : config.retryMode) !== null && _f !== void 0 ? _f : (0, node_config_provider_1.loadConfig)({
193
+ ...middleware_retry_2.NODE_RETRY_MODE_CONFIG_OPTIONS,
194
+ default: async () => (await defaultConfigProvider()).retryMode || util_retry_1.DEFAULT_RETRY_MODE
195
+ }),
196
+ sha256: (_g = config === null || config === void 0 ? void 0 : config.sha256) !== null && _g !== void 0 ? _g : hash_node_1.Hash.bind(null, "sha256"),
197
+ streamCollector: (_h = config === null || config === void 0 ? void 0 : config.streamCollector) !== null && _h !== void 0 ? _h : node_http_handler_1.streamCollector,
198
+ useDualstackEndpoint: (_j = config === null || config === void 0 ? void 0 : config.useDualstackEndpoint) !== null && _j !== void 0 ? _j : (0, node_config_provider_1.loadConfig)(config_resolver_2.NODE_USE_DUALSTACK_ENDPOINT_CONFIG_OPTIONS),
199
+ useFipsEndpoint: (_k = config === null || config === void 0 ? void 0 : config.useFipsEndpoint) !== null && _k !== void 0 ? _k : (0, node_config_provider_1.loadConfig)(config_resolver_2.NODE_USE_FIPS_ENDPOINT_CONFIG_OPTIONS)
200
+ };
201
+ };
202
+ var SSOOIDCClient = class extends smithy_client_1.Client {
203
+ constructor(configuration) {
204
+ const _config_0 = getRuntimeConfig2(configuration);
205
+ const _config_1 = resolveClientEndpointParameters(_config_0);
206
+ const _config_2 = (0, config_resolver_1.resolveRegionConfig)(_config_1);
207
+ const _config_3 = (0, middleware_endpoint_1.resolveEndpointConfig)(_config_2);
208
+ const _config_4 = (0, middleware_retry_1.resolveRetryConfig)(_config_3);
209
+ const _config_5 = (0, middleware_host_header_1.resolveHostHeaderConfig)(_config_4);
210
+ const _config_6 = (0, middleware_user_agent_1.resolveUserAgentConfig)(_config_5);
211
+ super(_config_6);
212
+ this.config = _config_6;
213
+ this.middlewareStack.use((0, middleware_retry_1.getRetryPlugin)(this.config));
214
+ this.middlewareStack.use((0, middleware_content_length_1.getContentLengthPlugin)(this.config));
215
+ this.middlewareStack.use((0, middleware_host_header_1.getHostHeaderPlugin)(this.config));
216
+ this.middlewareStack.use((0, middleware_logger_1.getLoggerPlugin)(this.config));
217
+ this.middlewareStack.use((0, middleware_recursion_detection_1.getRecursionDetectionPlugin)(this.config));
218
+ this.middlewareStack.use((0, middleware_user_agent_1.getUserAgentPlugin)(this.config));
219
+ }
220
+ destroy() {
221
+ super.destroy();
222
+ }
223
+ };
224
+ exports.SSOOIDCClient = SSOOIDCClient;
225
+ const middleware_endpoint_2 = require("@smithy/middleware-endpoint");
226
+ const middleware_serde_1 = require("@smithy/middleware-serde");
227
+ const smithy_client_5 = require("@smithy/smithy-client");
228
+ const protocol_http_1 = require("@smithy/protocol-http");
229
+ const smithy_client_6 = require("@smithy/smithy-client");
230
+ const smithy_client_7 = require("@smithy/smithy-client");
231
+ var SSOOIDCServiceException = class _SSOOIDCServiceException extends smithy_client_7.ServiceException {
232
+ constructor(options) {
233
+ super(options);
234
+ Object.setPrototypeOf(this, _SSOOIDCServiceException.prototype);
235
+ }
236
+ };
237
+ var AccessDeniedException = class _AccessDeniedException extends SSOOIDCServiceException {
238
+ constructor(opts) {
239
+ super({
240
+ name: "AccessDeniedException",
241
+ $fault: "client",
242
+ ...opts
243
+ });
244
+ this.name = "AccessDeniedException";
245
+ this.$fault = "client";
246
+ Object.setPrototypeOf(this, _AccessDeniedException.prototype);
247
+ this.error = opts.error;
248
+ this.error_description = opts.error_description;
249
+ }
250
+ };
251
+ exports.AccessDeniedException = AccessDeniedException;
252
+ var AuthorizationPendingException = class _AuthorizationPendingException extends SSOOIDCServiceException {
253
+ constructor(opts) {
254
+ super({
255
+ name: "AuthorizationPendingException",
256
+ $fault: "client",
257
+ ...opts
258
+ });
259
+ this.name = "AuthorizationPendingException";
260
+ this.$fault = "client";
261
+ Object.setPrototypeOf(this, _AuthorizationPendingException.prototype);
262
+ this.error = opts.error;
263
+ this.error_description = opts.error_description;
264
+ }
265
+ };
266
+ exports.AuthorizationPendingException = AuthorizationPendingException;
267
+ var ExpiredTokenException = class _ExpiredTokenException extends SSOOIDCServiceException {
268
+ constructor(opts) {
269
+ super({
270
+ name: "ExpiredTokenException",
271
+ $fault: "client",
272
+ ...opts
273
+ });
274
+ this.name = "ExpiredTokenException";
275
+ this.$fault = "client";
276
+ Object.setPrototypeOf(this, _ExpiredTokenException.prototype);
277
+ this.error = opts.error;
278
+ this.error_description = opts.error_description;
279
+ }
280
+ };
281
+ exports.ExpiredTokenException = ExpiredTokenException;
282
+ var InternalServerException = class _InternalServerException extends SSOOIDCServiceException {
283
+ constructor(opts) {
284
+ super({
285
+ name: "InternalServerException",
286
+ $fault: "server",
287
+ ...opts
288
+ });
289
+ this.name = "InternalServerException";
290
+ this.$fault = "server";
291
+ Object.setPrototypeOf(this, _InternalServerException.prototype);
292
+ this.error = opts.error;
293
+ this.error_description = opts.error_description;
294
+ }
295
+ };
296
+ exports.InternalServerException = InternalServerException;
297
+ var InvalidClientException = class _InvalidClientException extends SSOOIDCServiceException {
298
+ constructor(opts) {
299
+ super({
300
+ name: "InvalidClientException",
301
+ $fault: "client",
302
+ ...opts
303
+ });
304
+ this.name = "InvalidClientException";
305
+ this.$fault = "client";
306
+ Object.setPrototypeOf(this, _InvalidClientException.prototype);
307
+ this.error = opts.error;
308
+ this.error_description = opts.error_description;
309
+ }
310
+ };
311
+ exports.InvalidClientException = InvalidClientException;
312
+ var InvalidGrantException = class _InvalidGrantException extends SSOOIDCServiceException {
313
+ constructor(opts) {
314
+ super({
315
+ name: "InvalidGrantException",
316
+ $fault: "client",
317
+ ...opts
318
+ });
319
+ this.name = "InvalidGrantException";
320
+ this.$fault = "client";
321
+ Object.setPrototypeOf(this, _InvalidGrantException.prototype);
322
+ this.error = opts.error;
323
+ this.error_description = opts.error_description;
324
+ }
325
+ };
326
+ var InvalidRequestException = class _InvalidRequestException extends SSOOIDCServiceException {
327
+ constructor(opts) {
328
+ super({
329
+ name: "InvalidRequestException",
330
+ $fault: "client",
331
+ ...opts
332
+ });
333
+ this.name = "InvalidRequestException";
334
+ this.$fault = "client";
335
+ Object.setPrototypeOf(this, _InvalidRequestException.prototype);
336
+ this.error = opts.error;
337
+ this.error_description = opts.error_description;
338
+ }
339
+ };
340
+ exports.InvalidRequestException = InvalidRequestException;
341
+ var InvalidScopeException = class _InvalidScopeException extends SSOOIDCServiceException {
342
+ constructor(opts) {
343
+ super({
344
+ name: "InvalidScopeException",
345
+ $fault: "client",
346
+ ...opts
347
+ });
348
+ this.name = "InvalidScopeException";
349
+ this.$fault = "client";
350
+ Object.setPrototypeOf(this, _InvalidScopeException.prototype);
351
+ this.error = opts.error;
352
+ this.error_description = opts.error_description;
353
+ }
354
+ };
355
+ exports.InvalidScopeException = InvalidScopeException;
356
+ var SlowDownException = class _SlowDownException extends SSOOIDCServiceException {
357
+ constructor(opts) {
358
+ super({
359
+ name: "SlowDownException",
360
+ $fault: "client",
361
+ ...opts
362
+ });
363
+ this.name = "SlowDownException";
364
+ this.$fault = "client";
365
+ Object.setPrototypeOf(this, _SlowDownException.prototype);
366
+ this.error = opts.error;
367
+ this.error_description = opts.error_description;
368
+ }
369
+ };
370
+ exports.SlowDownException = SlowDownException;
371
+ var UnauthorizedClientException = class _UnauthorizedClientException extends SSOOIDCServiceException {
372
+ constructor(opts) {
373
+ super({
374
+ name: "UnauthorizedClientException",
375
+ $fault: "client",
376
+ ...opts
377
+ });
378
+ this.name = "UnauthorizedClientException";
379
+ this.$fault = "client";
380
+ Object.setPrototypeOf(this, _UnauthorizedClientException.prototype);
381
+ this.error = opts.error;
382
+ this.error_description = opts.error_description;
383
+ }
384
+ };
385
+ exports.UnauthorizedClientException = UnauthorizedClientException;
386
+ var UnsupportedGrantTypeException = class _UnsupportedGrantTypeException extends SSOOIDCServiceException {
387
+ constructor(opts) {
388
+ super({
389
+ name: "UnsupportedGrantTypeException",
390
+ $fault: "client",
391
+ ...opts
392
+ });
393
+ this.name = "UnsupportedGrantTypeException";
394
+ this.$fault = "client";
395
+ Object.setPrototypeOf(this, _UnsupportedGrantTypeException.prototype);
396
+ this.error = opts.error;
397
+ this.error_description = opts.error_description;
398
+ }
399
+ };
400
+ exports.UnsupportedGrantTypeException = UnsupportedGrantTypeException;
401
+ var se_CreateTokenCommand = async (input, context) => {
402
+ const { hostname, protocol = "https", port, path: basePath } = await context.endpoint();
403
+ const headers = {
404
+ "content-type": "application/json"
405
+ };
406
+ const resolvedPath = `${(basePath === null || basePath === void 0 ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}/token`;
407
+ let body;
408
+ body = JSON.stringify((0, smithy_client_6.take)(input, {
409
+ clientId: [],
410
+ clientSecret: [],
411
+ code: [],
412
+ deviceCode: [],
413
+ grantType: [],
414
+ redirectUri: [],
415
+ refreshToken: [],
416
+ scope: (_) => (0, smithy_client_6._json)(_)
417
+ }));
418
+ return new protocol_http_1.HttpRequest({
419
+ protocol,
420
+ hostname,
421
+ port,
422
+ method: "POST",
423
+ headers,
424
+ path: resolvedPath,
425
+ body
426
+ });
427
+ };
428
+ var de_CreateTokenCommand = async (output, context) => {
429
+ if (output.statusCode !== 200 && output.statusCode >= 300) {
430
+ return de_CreateTokenCommandError(output, context);
431
+ }
432
+ const contents = (0, smithy_client_6.map)({
433
+ $metadata: deserializeMetadata(output)
434
+ });
435
+ const data = (0, smithy_client_6.expectNonNull)((0, smithy_client_6.expectObject)(await parseBody(output.body, context)), "body");
436
+ const doc = (0, smithy_client_6.take)(data, {
437
+ accessToken: smithy_client_6.expectString,
438
+ expiresIn: smithy_client_6.expectInt32,
439
+ idToken: smithy_client_6.expectString,
440
+ refreshToken: smithy_client_6.expectString,
441
+ tokenType: smithy_client_6.expectString
442
+ });
443
+ Object.assign(contents, doc);
444
+ return contents;
445
+ };
446
+ var de_CreateTokenCommandError = async (output, context) => {
447
+ const parsedOutput = {
448
+ ...output,
449
+ body: await parseErrorBody(output.body, context)
450
+ };
451
+ const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
452
+ switch (errorCode) {
453
+ case "AccessDeniedException":
454
+ case "com.amazonaws.ssooidc#AccessDeniedException":
455
+ throw await de_AccessDeniedExceptionRes(parsedOutput, context);
456
+ case "AuthorizationPendingException":
457
+ case "com.amazonaws.ssooidc#AuthorizationPendingException":
458
+ throw await de_AuthorizationPendingExceptionRes(parsedOutput, context);
459
+ case "ExpiredTokenException":
460
+ case "com.amazonaws.ssooidc#ExpiredTokenException":
461
+ throw await de_ExpiredTokenExceptionRes(parsedOutput, context);
462
+ case "InternalServerException":
463
+ case "com.amazonaws.ssooidc#InternalServerException":
464
+ throw await de_InternalServerExceptionRes(parsedOutput, context);
465
+ case "InvalidClientException":
466
+ case "com.amazonaws.ssooidc#InvalidClientException":
467
+ throw await de_InvalidClientExceptionRes(parsedOutput, context);
468
+ case "InvalidGrantException":
469
+ case "com.amazonaws.ssooidc#InvalidGrantException":
470
+ throw await de_InvalidGrantExceptionRes(parsedOutput, context);
471
+ case "InvalidRequestException":
472
+ case "com.amazonaws.ssooidc#InvalidRequestException":
473
+ throw await de_InvalidRequestExceptionRes(parsedOutput, context);
474
+ case "InvalidScopeException":
475
+ case "com.amazonaws.ssooidc#InvalidScopeException":
476
+ throw await de_InvalidScopeExceptionRes(parsedOutput, context);
477
+ case "SlowDownException":
478
+ case "com.amazonaws.ssooidc#SlowDownException":
479
+ throw await de_SlowDownExceptionRes(parsedOutput, context);
480
+ case "UnauthorizedClientException":
481
+ case "com.amazonaws.ssooidc#UnauthorizedClientException":
482
+ throw await de_UnauthorizedClientExceptionRes(parsedOutput, context);
483
+ case "UnsupportedGrantTypeException":
484
+ case "com.amazonaws.ssooidc#UnsupportedGrantTypeException":
485
+ throw await de_UnsupportedGrantTypeExceptionRes(parsedOutput, context);
486
+ default:
487
+ const parsedBody = parsedOutput.body;
488
+ return throwDefaultError({
489
+ output,
490
+ parsedBody,
491
+ errorCode
492
+ });
493
+ }
494
+ };
495
+ var throwDefaultError = (0, smithy_client_6.withBaseException)(SSOOIDCServiceException);
496
+ var de_AccessDeniedExceptionRes = async (parsedOutput, context) => {
497
+ const contents = (0, smithy_client_6.map)({});
498
+ const data = parsedOutput.body;
499
+ const doc = (0, smithy_client_6.take)(data, {
500
+ error: smithy_client_6.expectString,
501
+ error_description: smithy_client_6.expectString
502
+ });
503
+ Object.assign(contents, doc);
504
+ const exception = new AccessDeniedException({
505
+ $metadata: deserializeMetadata(parsedOutput),
506
+ ...contents
507
+ });
508
+ return (0, smithy_client_6.decorateServiceException)(exception, parsedOutput.body);
509
+ };
510
+ var de_AuthorizationPendingExceptionRes = async (parsedOutput, context) => {
511
+ const contents = (0, smithy_client_6.map)({});
512
+ const data = parsedOutput.body;
513
+ const doc = (0, smithy_client_6.take)(data, {
514
+ error: smithy_client_6.expectString,
515
+ error_description: smithy_client_6.expectString
516
+ });
517
+ Object.assign(contents, doc);
518
+ const exception = new AuthorizationPendingException({
519
+ $metadata: deserializeMetadata(parsedOutput),
520
+ ...contents
521
+ });
522
+ return (0, smithy_client_6.decorateServiceException)(exception, parsedOutput.body);
523
+ };
524
+ var de_ExpiredTokenExceptionRes = async (parsedOutput, context) => {
525
+ const contents = (0, smithy_client_6.map)({});
526
+ const data = parsedOutput.body;
527
+ const doc = (0, smithy_client_6.take)(data, {
528
+ error: smithy_client_6.expectString,
529
+ error_description: smithy_client_6.expectString
530
+ });
531
+ Object.assign(contents, doc);
532
+ const exception = new ExpiredTokenException({
533
+ $metadata: deserializeMetadata(parsedOutput),
534
+ ...contents
535
+ });
536
+ return (0, smithy_client_6.decorateServiceException)(exception, parsedOutput.body);
537
+ };
538
+ var de_InternalServerExceptionRes = async (parsedOutput, context) => {
539
+ const contents = (0, smithy_client_6.map)({});
540
+ const data = parsedOutput.body;
541
+ const doc = (0, smithy_client_6.take)(data, {
542
+ error: smithy_client_6.expectString,
543
+ error_description: smithy_client_6.expectString
544
+ });
545
+ Object.assign(contents, doc);
546
+ const exception = new InternalServerException({
547
+ $metadata: deserializeMetadata(parsedOutput),
548
+ ...contents
549
+ });
550
+ return (0, smithy_client_6.decorateServiceException)(exception, parsedOutput.body);
551
+ };
552
+ var de_InvalidClientExceptionRes = async (parsedOutput, context) => {
553
+ const contents = (0, smithy_client_6.map)({});
554
+ const data = parsedOutput.body;
555
+ const doc = (0, smithy_client_6.take)(data, {
556
+ error: smithy_client_6.expectString,
557
+ error_description: smithy_client_6.expectString
558
+ });
559
+ Object.assign(contents, doc);
560
+ const exception = new InvalidClientException({
561
+ $metadata: deserializeMetadata(parsedOutput),
562
+ ...contents
563
+ });
564
+ return (0, smithy_client_6.decorateServiceException)(exception, parsedOutput.body);
565
+ };
566
+ var de_InvalidGrantExceptionRes = async (parsedOutput, context) => {
567
+ const contents = (0, smithy_client_6.map)({});
568
+ const data = parsedOutput.body;
569
+ const doc = (0, smithy_client_6.take)(data, {
570
+ error: smithy_client_6.expectString,
571
+ error_description: smithy_client_6.expectString
572
+ });
573
+ Object.assign(contents, doc);
574
+ const exception = new InvalidGrantException({
575
+ $metadata: deserializeMetadata(parsedOutput),
576
+ ...contents
577
+ });
578
+ return (0, smithy_client_6.decorateServiceException)(exception, parsedOutput.body);
579
+ };
580
+ var de_InvalidRequestExceptionRes = async (parsedOutput, context) => {
581
+ const contents = (0, smithy_client_6.map)({});
582
+ const data = parsedOutput.body;
583
+ const doc = (0, smithy_client_6.take)(data, {
584
+ error: smithy_client_6.expectString,
585
+ error_description: smithy_client_6.expectString
586
+ });
587
+ Object.assign(contents, doc);
588
+ const exception = new InvalidRequestException({
589
+ $metadata: deserializeMetadata(parsedOutput),
590
+ ...contents
591
+ });
592
+ return (0, smithy_client_6.decorateServiceException)(exception, parsedOutput.body);
593
+ };
594
+ var de_InvalidScopeExceptionRes = async (parsedOutput, context) => {
595
+ const contents = (0, smithy_client_6.map)({});
596
+ const data = parsedOutput.body;
597
+ const doc = (0, smithy_client_6.take)(data, {
598
+ error: smithy_client_6.expectString,
599
+ error_description: smithy_client_6.expectString
600
+ });
601
+ Object.assign(contents, doc);
602
+ const exception = new InvalidScopeException({
603
+ $metadata: deserializeMetadata(parsedOutput),
604
+ ...contents
605
+ });
606
+ return (0, smithy_client_6.decorateServiceException)(exception, parsedOutput.body);
607
+ };
608
+ var de_SlowDownExceptionRes = async (parsedOutput, context) => {
609
+ const contents = (0, smithy_client_6.map)({});
610
+ const data = parsedOutput.body;
611
+ const doc = (0, smithy_client_6.take)(data, {
612
+ error: smithy_client_6.expectString,
613
+ error_description: smithy_client_6.expectString
614
+ });
615
+ Object.assign(contents, doc);
616
+ const exception = new SlowDownException({
617
+ $metadata: deserializeMetadata(parsedOutput),
618
+ ...contents
619
+ });
620
+ return (0, smithy_client_6.decorateServiceException)(exception, parsedOutput.body);
621
+ };
622
+ var de_UnauthorizedClientExceptionRes = async (parsedOutput, context) => {
623
+ const contents = (0, smithy_client_6.map)({});
624
+ const data = parsedOutput.body;
625
+ const doc = (0, smithy_client_6.take)(data, {
626
+ error: smithy_client_6.expectString,
627
+ error_description: smithy_client_6.expectString
628
+ });
629
+ Object.assign(contents, doc);
630
+ const exception = new UnauthorizedClientException({
631
+ $metadata: deserializeMetadata(parsedOutput),
632
+ ...contents
633
+ });
634
+ return (0, smithy_client_6.decorateServiceException)(exception, parsedOutput.body);
635
+ };
636
+ var de_UnsupportedGrantTypeExceptionRes = async (parsedOutput, context) => {
637
+ const contents = (0, smithy_client_6.map)({});
638
+ const data = parsedOutput.body;
639
+ const doc = (0, smithy_client_6.take)(data, {
640
+ error: smithy_client_6.expectString,
641
+ error_description: smithy_client_6.expectString
642
+ });
643
+ Object.assign(contents, doc);
644
+ const exception = new UnsupportedGrantTypeException({
645
+ $metadata: deserializeMetadata(parsedOutput),
646
+ ...contents
647
+ });
648
+ return (0, smithy_client_6.decorateServiceException)(exception, parsedOutput.body);
649
+ };
650
+ var deserializeMetadata = (output) => {
651
+ var _a, _b;
652
+ return ({
653
+ httpStatusCode: output.statusCode,
654
+ 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"],
655
+ extendedRequestId: output.headers["x-amz-id-2"],
656
+ cfId: output.headers["x-amz-cf-id"]
657
+ });
658
+ };
659
+ var collectBodyString = (streamBody, context) => (0, smithy_client_6.collectBody)(streamBody, context).then((body) => context.utf8Encoder(body));
660
+ var parseBody = (streamBody, context) => collectBodyString(streamBody, context).then((encoded) => {
661
+ if (encoded.length) {
662
+ return JSON.parse(encoded);
663
+ }
664
+ return {};
665
+ });
666
+ var parseErrorBody = async (errorBody, context) => {
667
+ var _a;
668
+ const value = await parseBody(errorBody, context);
669
+ value.message = (_a = value.message) !== null && _a !== void 0 ? _a : value.Message;
670
+ return value;
671
+ };
672
+ var loadRestJsonErrorCode = (output, data) => {
673
+ const findKey = (object, key) => Object.keys(object).find((k2) => k2.toLowerCase() === key.toLowerCase());
674
+ const sanitizeErrorCode = (rawValue) => {
675
+ let cleanValue = rawValue;
676
+ if (typeof cleanValue === "number") {
677
+ cleanValue = cleanValue.toString();
678
+ }
679
+ if (cleanValue.indexOf(",") >= 0) {
680
+ cleanValue = cleanValue.split(",")[0];
681
+ }
682
+ if (cleanValue.indexOf(":") >= 0) {
683
+ cleanValue = cleanValue.split(":")[0];
684
+ }
685
+ if (cleanValue.indexOf("#") >= 0) {
686
+ cleanValue = cleanValue.split("#")[1];
687
+ }
688
+ return cleanValue;
689
+ };
690
+ const headerKey = findKey(output.headers, "x-amzn-errortype");
691
+ if (headerKey !== void 0) {
692
+ return sanitizeErrorCode(output.headers[headerKey]);
693
+ }
694
+ if (data.code !== void 0) {
695
+ return sanitizeErrorCode(data.code);
696
+ }
697
+ if (data["__type"] !== void 0) {
698
+ return sanitizeErrorCode(data["__type"]);
699
+ }
700
+ };
701
+ var CreateTokenCommand = class _CreateTokenCommand extends smithy_client_5.Command {
702
+ constructor(input) {
703
+ super();
704
+ this.input = input;
705
+ }
706
+ static getEndpointParameterInstructions() {
707
+ return {
708
+ UseFIPS: { type: "builtInParams", name: "useFipsEndpoint" },
709
+ Endpoint: { type: "builtInParams", name: "endpoint" },
710
+ Region: { type: "builtInParams", name: "region" },
711
+ UseDualStack: { type: "builtInParams", name: "useDualstackEndpoint" }
712
+ };
713
+ }
714
+ resolveMiddleware(clientStack, configuration, options) {
715
+ this.middlewareStack.use((0, middleware_serde_1.getSerdePlugin)(configuration, this.serialize, this.deserialize));
716
+ this.middlewareStack.use((0, middleware_endpoint_2.getEndpointPlugin)(configuration, _CreateTokenCommand.getEndpointParameterInstructions()));
717
+ const stack = clientStack.concat(this.middlewareStack);
718
+ const { logger } = configuration;
719
+ const clientName = "SSOOIDCClient";
720
+ const commandName = "CreateTokenCommand";
721
+ const handlerExecutionContext = {
722
+ logger,
723
+ clientName,
724
+ commandName,
725
+ inputFilterSensitiveLog: (_) => _,
726
+ outputFilterSensitiveLog: (_) => _
727
+ };
728
+ const { requestHandler } = configuration;
729
+ return stack.resolve((request) => requestHandler.handle(request.request, options || {}), handlerExecutionContext);
730
+ }
731
+ serialize(input, context) {
732
+ return se_CreateTokenCommand(input, context);
733
+ }
734
+ deserialize(output, context) {
735
+ return de_CreateTokenCommand(output, context);
736
+ }
737
+ };
738
+ exports.CreateTokenCommand = CreateTokenCommand;