@aws-sdk/client-sso-oidc 3.183.0 → 3.186.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.
@@ -1,491 +1,597 @@
1
+ import { __assign, __awaiter, __generator } from "tslib";
1
2
  import { HttpRequest as __HttpRequest } from "@aws-sdk/protocol-http";
2
3
  import { decorateServiceException as __decorateServiceException, expectInt32 as __expectInt32, expectLong as __expectLong, expectNonNull as __expectNonNull, expectObject as __expectObject, expectString as __expectString, map as __map, throwDefaultError, } from "@aws-sdk/smithy-client";
3
4
  import { AccessDeniedException, AuthorizationPendingException, ExpiredTokenException, InternalServerException, InvalidClientException, InvalidClientMetadataException, InvalidGrantException, InvalidRequestException, InvalidScopeException, SlowDownException, UnauthorizedClientException, UnsupportedGrantTypeException, } from "../models/models_0";
4
5
  import { SSOOIDCServiceException as __BaseException } from "../models/SSOOIDCServiceException";
5
- export const serializeAws_restJson1CreateTokenCommand = async (input, context) => {
6
- const { hostname, protocol = "https", port, path: basePath } = await context.endpoint();
7
- const headers = {
8
- "content-type": "application/json",
9
- };
10
- const resolvedPath = `${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` + "/token";
11
- let body;
12
- body = JSON.stringify({
13
- ...(input.clientId != null && { clientId: input.clientId }),
14
- ...(input.clientSecret != null && { clientSecret: input.clientSecret }),
15
- ...(input.code != null && { code: input.code }),
16
- ...(input.deviceCode != null && { deviceCode: input.deviceCode }),
17
- ...(input.grantType != null && { grantType: input.grantType }),
18
- ...(input.redirectUri != null && { redirectUri: input.redirectUri }),
19
- ...(input.refreshToken != null && { refreshToken: input.refreshToken }),
20
- ...(input.scope != null && { scope: serializeAws_restJson1Scopes(input.scope, context) }),
6
+ export var serializeAws_restJson1CreateTokenCommand = function (input, context) { return __awaiter(void 0, void 0, void 0, function () {
7
+ var _a, hostname, _b, protocol, port, basePath, headers, resolvedPath, body;
8
+ return __generator(this, function (_c) {
9
+ switch (_c.label) {
10
+ case 0: return [4, context.endpoint()];
11
+ case 1:
12
+ _a = _c.sent(), hostname = _a.hostname, _b = _a.protocol, protocol = _b === void 0 ? "https" : _b, port = _a.port, basePath = _a.path;
13
+ headers = {
14
+ "content-type": "application/json",
15
+ };
16
+ resolvedPath = "".concat((basePath === null || basePath === void 0 ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || "") + "/token";
17
+ body = JSON.stringify(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign({}, (input.clientId != null && { clientId: input.clientId })), (input.clientSecret != null && { clientSecret: input.clientSecret })), (input.code != null && { code: input.code })), (input.deviceCode != null && { deviceCode: input.deviceCode })), (input.grantType != null && { grantType: input.grantType })), (input.redirectUri != null && { redirectUri: input.redirectUri })), (input.refreshToken != null && { refreshToken: input.refreshToken })), (input.scope != null && { scope: serializeAws_restJson1Scopes(input.scope, context) })));
18
+ return [2, new __HttpRequest({
19
+ protocol: protocol,
20
+ hostname: hostname,
21
+ port: port,
22
+ method: "POST",
23
+ headers: headers,
24
+ path: resolvedPath,
25
+ body: body,
26
+ })];
27
+ }
21
28
  });
22
- return new __HttpRequest({
23
- protocol,
24
- hostname,
25
- port,
26
- method: "POST",
27
- headers,
28
- path: resolvedPath,
29
- body,
29
+ }); };
30
+ export var serializeAws_restJson1RegisterClientCommand = function (input, context) { return __awaiter(void 0, void 0, void 0, function () {
31
+ var _a, hostname, _b, protocol, port, basePath, headers, resolvedPath, body;
32
+ return __generator(this, function (_c) {
33
+ switch (_c.label) {
34
+ case 0: return [4, context.endpoint()];
35
+ case 1:
36
+ _a = _c.sent(), hostname = _a.hostname, _b = _a.protocol, protocol = _b === void 0 ? "https" : _b, port = _a.port, basePath = _a.path;
37
+ headers = {
38
+ "content-type": "application/json",
39
+ };
40
+ resolvedPath = "".concat((basePath === null || basePath === void 0 ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || "") + "/client/register";
41
+ body = JSON.stringify(__assign(__assign(__assign({}, (input.clientName != null && { clientName: input.clientName })), (input.clientType != null && { clientType: input.clientType })), (input.scopes != null && { scopes: serializeAws_restJson1Scopes(input.scopes, context) })));
42
+ return [2, new __HttpRequest({
43
+ protocol: protocol,
44
+ hostname: hostname,
45
+ port: port,
46
+ method: "POST",
47
+ headers: headers,
48
+ path: resolvedPath,
49
+ body: body,
50
+ })];
51
+ }
30
52
  });
31
- };
32
- export const serializeAws_restJson1RegisterClientCommand = async (input, context) => {
33
- const { hostname, protocol = "https", port, path: basePath } = await context.endpoint();
34
- const headers = {
35
- "content-type": "application/json",
36
- };
37
- const resolvedPath = `${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` + "/client/register";
38
- let body;
39
- body = JSON.stringify({
40
- ...(input.clientName != null && { clientName: input.clientName }),
41
- ...(input.clientType != null && { clientType: input.clientType }),
42
- ...(input.scopes != null && { scopes: serializeAws_restJson1Scopes(input.scopes, context) }),
53
+ }); };
54
+ export var serializeAws_restJson1StartDeviceAuthorizationCommand = function (input, context) { return __awaiter(void 0, void 0, void 0, function () {
55
+ var _a, hostname, _b, protocol, port, basePath, headers, resolvedPath, body;
56
+ return __generator(this, function (_c) {
57
+ switch (_c.label) {
58
+ case 0: return [4, context.endpoint()];
59
+ case 1:
60
+ _a = _c.sent(), hostname = _a.hostname, _b = _a.protocol, protocol = _b === void 0 ? "https" : _b, port = _a.port, basePath = _a.path;
61
+ headers = {
62
+ "content-type": "application/json",
63
+ };
64
+ resolvedPath = "".concat((basePath === null || basePath === void 0 ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || "") + "/device_authorization";
65
+ body = JSON.stringify(__assign(__assign(__assign({}, (input.clientId != null && { clientId: input.clientId })), (input.clientSecret != null && { clientSecret: input.clientSecret })), (input.startUrl != null && { startUrl: input.startUrl })));
66
+ return [2, new __HttpRequest({
67
+ protocol: protocol,
68
+ hostname: hostname,
69
+ port: port,
70
+ method: "POST",
71
+ headers: headers,
72
+ path: resolvedPath,
73
+ body: body,
74
+ })];
75
+ }
43
76
  });
44
- return new __HttpRequest({
45
- protocol,
46
- hostname,
47
- port,
48
- method: "POST",
49
- headers,
50
- path: resolvedPath,
51
- body,
77
+ }); };
78
+ export var deserializeAws_restJson1CreateTokenCommand = function (output, context) { return __awaiter(void 0, void 0, void 0, function () {
79
+ var contents, data, _a, _b;
80
+ return __generator(this, function (_c) {
81
+ switch (_c.label) {
82
+ case 0:
83
+ if (output.statusCode !== 200 && output.statusCode >= 300) {
84
+ return [2, deserializeAws_restJson1CreateTokenCommandError(output, context)];
85
+ }
86
+ contents = map({
87
+ $metadata: deserializeMetadata(output),
88
+ });
89
+ _a = __expectNonNull;
90
+ _b = __expectObject;
91
+ return [4, parseBody(output.body, context)];
92
+ case 1:
93
+ data = _a.apply(void 0, [_b.apply(void 0, [_c.sent()]), "body"]);
94
+ if (data.accessToken != null) {
95
+ contents.accessToken = __expectString(data.accessToken);
96
+ }
97
+ if (data.expiresIn != null) {
98
+ contents.expiresIn = __expectInt32(data.expiresIn);
99
+ }
100
+ if (data.idToken != null) {
101
+ contents.idToken = __expectString(data.idToken);
102
+ }
103
+ if (data.refreshToken != null) {
104
+ contents.refreshToken = __expectString(data.refreshToken);
105
+ }
106
+ if (data.tokenType != null) {
107
+ contents.tokenType = __expectString(data.tokenType);
108
+ }
109
+ return [2, contents];
110
+ }
52
111
  });
53
- };
54
- export const serializeAws_restJson1StartDeviceAuthorizationCommand = async (input, context) => {
55
- const { hostname, protocol = "https", port, path: basePath } = await context.endpoint();
56
- const headers = {
57
- "content-type": "application/json",
58
- };
59
- const resolvedPath = `${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` + "/device_authorization";
60
- let body;
61
- body = JSON.stringify({
62
- ...(input.clientId != null && { clientId: input.clientId }),
63
- ...(input.clientSecret != null && { clientSecret: input.clientSecret }),
64
- ...(input.startUrl != null && { startUrl: input.startUrl }),
112
+ }); };
113
+ var deserializeAws_restJson1CreateTokenCommandError = function (output, context) { return __awaiter(void 0, void 0, void 0, function () {
114
+ var parsedOutput, _a, errorCode, _b, parsedBody;
115
+ var _c;
116
+ return __generator(this, function (_d) {
117
+ switch (_d.label) {
118
+ case 0:
119
+ _a = [__assign({}, output)];
120
+ _c = {};
121
+ return [4, parseErrorBody(output.body, context)];
122
+ case 1:
123
+ parsedOutput = __assign.apply(void 0, _a.concat([(_c.body = _d.sent(), _c)]));
124
+ errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
125
+ _b = errorCode;
126
+ switch (_b) {
127
+ case "AccessDeniedException": return [3, 2];
128
+ case "com.amazonaws.ssooidc#AccessDeniedException": return [3, 2];
129
+ case "AuthorizationPendingException": return [3, 4];
130
+ case "com.amazonaws.ssooidc#AuthorizationPendingException": return [3, 4];
131
+ case "ExpiredTokenException": return [3, 6];
132
+ case "com.amazonaws.ssooidc#ExpiredTokenException": return [3, 6];
133
+ case "InternalServerException": return [3, 8];
134
+ case "com.amazonaws.ssooidc#InternalServerException": return [3, 8];
135
+ case "InvalidClientException": return [3, 10];
136
+ case "com.amazonaws.ssooidc#InvalidClientException": return [3, 10];
137
+ case "InvalidGrantException": return [3, 12];
138
+ case "com.amazonaws.ssooidc#InvalidGrantException": return [3, 12];
139
+ case "InvalidRequestException": return [3, 14];
140
+ case "com.amazonaws.ssooidc#InvalidRequestException": return [3, 14];
141
+ case "InvalidScopeException": return [3, 16];
142
+ case "com.amazonaws.ssooidc#InvalidScopeException": return [3, 16];
143
+ case "SlowDownException": return [3, 18];
144
+ case "com.amazonaws.ssooidc#SlowDownException": return [3, 18];
145
+ case "UnauthorizedClientException": return [3, 20];
146
+ case "com.amazonaws.ssooidc#UnauthorizedClientException": return [3, 20];
147
+ case "UnsupportedGrantTypeException": return [3, 22];
148
+ case "com.amazonaws.ssooidc#UnsupportedGrantTypeException": return [3, 22];
149
+ }
150
+ return [3, 24];
151
+ case 2: return [4, deserializeAws_restJson1AccessDeniedExceptionResponse(parsedOutput, context)];
152
+ case 3: throw _d.sent();
153
+ case 4: return [4, deserializeAws_restJson1AuthorizationPendingExceptionResponse(parsedOutput, context)];
154
+ case 5: throw _d.sent();
155
+ case 6: return [4, deserializeAws_restJson1ExpiredTokenExceptionResponse(parsedOutput, context)];
156
+ case 7: throw _d.sent();
157
+ case 8: return [4, deserializeAws_restJson1InternalServerExceptionResponse(parsedOutput, context)];
158
+ case 9: throw _d.sent();
159
+ case 10: return [4, deserializeAws_restJson1InvalidClientExceptionResponse(parsedOutput, context)];
160
+ case 11: throw _d.sent();
161
+ case 12: return [4, deserializeAws_restJson1InvalidGrantExceptionResponse(parsedOutput, context)];
162
+ case 13: throw _d.sent();
163
+ case 14: return [4, deserializeAws_restJson1InvalidRequestExceptionResponse(parsedOutput, context)];
164
+ case 15: throw _d.sent();
165
+ case 16: return [4, deserializeAws_restJson1InvalidScopeExceptionResponse(parsedOutput, context)];
166
+ case 17: throw _d.sent();
167
+ case 18: return [4, deserializeAws_restJson1SlowDownExceptionResponse(parsedOutput, context)];
168
+ case 19: throw _d.sent();
169
+ case 20: return [4, deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context)];
170
+ case 21: throw _d.sent();
171
+ case 22: return [4, deserializeAws_restJson1UnsupportedGrantTypeExceptionResponse(parsedOutput, context)];
172
+ case 23: throw _d.sent();
173
+ case 24:
174
+ parsedBody = parsedOutput.body;
175
+ throwDefaultError({
176
+ output: output,
177
+ parsedBody: parsedBody,
178
+ exceptionCtor: __BaseException,
179
+ errorCode: errorCode,
180
+ });
181
+ _d.label = 25;
182
+ case 25: return [2];
183
+ }
65
184
  });
66
- return new __HttpRequest({
67
- protocol,
68
- hostname,
69
- port,
70
- method: "POST",
71
- headers,
72
- path: resolvedPath,
73
- body,
185
+ }); };
186
+ export var deserializeAws_restJson1RegisterClientCommand = function (output, context) { return __awaiter(void 0, void 0, void 0, function () {
187
+ var contents, data, _a, _b;
188
+ return __generator(this, function (_c) {
189
+ switch (_c.label) {
190
+ case 0:
191
+ if (output.statusCode !== 200 && output.statusCode >= 300) {
192
+ return [2, deserializeAws_restJson1RegisterClientCommandError(output, context)];
193
+ }
194
+ contents = map({
195
+ $metadata: deserializeMetadata(output),
196
+ });
197
+ _a = __expectNonNull;
198
+ _b = __expectObject;
199
+ return [4, parseBody(output.body, context)];
200
+ case 1:
201
+ data = _a.apply(void 0, [_b.apply(void 0, [_c.sent()]), "body"]);
202
+ if (data.authorizationEndpoint != null) {
203
+ contents.authorizationEndpoint = __expectString(data.authorizationEndpoint);
204
+ }
205
+ if (data.clientId != null) {
206
+ contents.clientId = __expectString(data.clientId);
207
+ }
208
+ if (data.clientIdIssuedAt != null) {
209
+ contents.clientIdIssuedAt = __expectLong(data.clientIdIssuedAt);
210
+ }
211
+ if (data.clientSecret != null) {
212
+ contents.clientSecret = __expectString(data.clientSecret);
213
+ }
214
+ if (data.clientSecretExpiresAt != null) {
215
+ contents.clientSecretExpiresAt = __expectLong(data.clientSecretExpiresAt);
216
+ }
217
+ if (data.tokenEndpoint != null) {
218
+ contents.tokenEndpoint = __expectString(data.tokenEndpoint);
219
+ }
220
+ return [2, contents];
221
+ }
74
222
  });
75
- };
76
- export const deserializeAws_restJson1CreateTokenCommand = async (output, context) => {
77
- if (output.statusCode !== 200 && output.statusCode >= 300) {
78
- return deserializeAws_restJson1CreateTokenCommandError(output, context);
79
- }
80
- const contents = map({
81
- $metadata: deserializeMetadata(output),
223
+ }); };
224
+ var deserializeAws_restJson1RegisterClientCommandError = function (output, context) { return __awaiter(void 0, void 0, void 0, function () {
225
+ var parsedOutput, _a, errorCode, _b, parsedBody;
226
+ var _c;
227
+ return __generator(this, function (_d) {
228
+ switch (_d.label) {
229
+ case 0:
230
+ _a = [__assign({}, output)];
231
+ _c = {};
232
+ return [4, parseErrorBody(output.body, context)];
233
+ case 1:
234
+ parsedOutput = __assign.apply(void 0, _a.concat([(_c.body = _d.sent(), _c)]));
235
+ errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
236
+ _b = errorCode;
237
+ switch (_b) {
238
+ case "InternalServerException": return [3, 2];
239
+ case "com.amazonaws.ssooidc#InternalServerException": return [3, 2];
240
+ case "InvalidClientMetadataException": return [3, 4];
241
+ case "com.amazonaws.ssooidc#InvalidClientMetadataException": return [3, 4];
242
+ case "InvalidRequestException": return [3, 6];
243
+ case "com.amazonaws.ssooidc#InvalidRequestException": return [3, 6];
244
+ case "InvalidScopeException": return [3, 8];
245
+ case "com.amazonaws.ssooidc#InvalidScopeException": return [3, 8];
246
+ }
247
+ return [3, 10];
248
+ case 2: return [4, deserializeAws_restJson1InternalServerExceptionResponse(parsedOutput, context)];
249
+ case 3: throw _d.sent();
250
+ case 4: return [4, deserializeAws_restJson1InvalidClientMetadataExceptionResponse(parsedOutput, context)];
251
+ case 5: throw _d.sent();
252
+ case 6: return [4, deserializeAws_restJson1InvalidRequestExceptionResponse(parsedOutput, context)];
253
+ case 7: throw _d.sent();
254
+ case 8: return [4, deserializeAws_restJson1InvalidScopeExceptionResponse(parsedOutput, context)];
255
+ case 9: throw _d.sent();
256
+ case 10:
257
+ parsedBody = parsedOutput.body;
258
+ throwDefaultError({
259
+ output: output,
260
+ parsedBody: parsedBody,
261
+ exceptionCtor: __BaseException,
262
+ errorCode: errorCode,
263
+ });
264
+ _d.label = 11;
265
+ case 11: return [2];
266
+ }
82
267
  });
83
- const data = __expectNonNull(__expectObject(await parseBody(output.body, context)), "body");
84
- if (data.accessToken != null) {
85
- contents.accessToken = __expectString(data.accessToken);
86
- }
87
- if (data.expiresIn != null) {
88
- contents.expiresIn = __expectInt32(data.expiresIn);
89
- }
90
- if (data.idToken != null) {
91
- contents.idToken = __expectString(data.idToken);
92
- }
93
- if (data.refreshToken != null) {
94
- contents.refreshToken = __expectString(data.refreshToken);
95
- }
96
- if (data.tokenType != null) {
97
- contents.tokenType = __expectString(data.tokenType);
98
- }
99
- return contents;
100
- };
101
- const deserializeAws_restJson1CreateTokenCommandError = async (output, context) => {
102
- const parsedOutput = {
103
- ...output,
104
- body: await parseErrorBody(output.body, context),
105
- };
106
- const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
107
- switch (errorCode) {
108
- case "AccessDeniedException":
109
- case "com.amazonaws.ssooidc#AccessDeniedException":
110
- throw await deserializeAws_restJson1AccessDeniedExceptionResponse(parsedOutput, context);
111
- case "AuthorizationPendingException":
112
- case "com.amazonaws.ssooidc#AuthorizationPendingException":
113
- throw await deserializeAws_restJson1AuthorizationPendingExceptionResponse(parsedOutput, context);
114
- case "ExpiredTokenException":
115
- case "com.amazonaws.ssooidc#ExpiredTokenException":
116
- throw await deserializeAws_restJson1ExpiredTokenExceptionResponse(parsedOutput, context);
117
- case "InternalServerException":
118
- case "com.amazonaws.ssooidc#InternalServerException":
119
- throw await deserializeAws_restJson1InternalServerExceptionResponse(parsedOutput, context);
120
- case "InvalidClientException":
121
- case "com.amazonaws.ssooidc#InvalidClientException":
122
- throw await deserializeAws_restJson1InvalidClientExceptionResponse(parsedOutput, context);
123
- case "InvalidGrantException":
124
- case "com.amazonaws.ssooidc#InvalidGrantException":
125
- throw await deserializeAws_restJson1InvalidGrantExceptionResponse(parsedOutput, context);
126
- case "InvalidRequestException":
127
- case "com.amazonaws.ssooidc#InvalidRequestException":
128
- throw await deserializeAws_restJson1InvalidRequestExceptionResponse(parsedOutput, context);
129
- case "InvalidScopeException":
130
- case "com.amazonaws.ssooidc#InvalidScopeException":
131
- throw await deserializeAws_restJson1InvalidScopeExceptionResponse(parsedOutput, context);
132
- case "SlowDownException":
133
- case "com.amazonaws.ssooidc#SlowDownException":
134
- throw await deserializeAws_restJson1SlowDownExceptionResponse(parsedOutput, context);
135
- case "UnauthorizedClientException":
136
- case "com.amazonaws.ssooidc#UnauthorizedClientException":
137
- throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context);
138
- case "UnsupportedGrantTypeException":
139
- case "com.amazonaws.ssooidc#UnsupportedGrantTypeException":
140
- throw await deserializeAws_restJson1UnsupportedGrantTypeExceptionResponse(parsedOutput, context);
141
- default:
142
- const parsedBody = parsedOutput.body;
143
- throwDefaultError({
144
- output,
145
- parsedBody,
146
- exceptionCtor: __BaseException,
147
- errorCode,
148
- });
149
- }
150
- };
151
- export const deserializeAws_restJson1RegisterClientCommand = async (output, context) => {
152
- if (output.statusCode !== 200 && output.statusCode >= 300) {
153
- return deserializeAws_restJson1RegisterClientCommandError(output, context);
154
- }
155
- const contents = map({
156
- $metadata: deserializeMetadata(output),
268
+ }); };
269
+ export var deserializeAws_restJson1StartDeviceAuthorizationCommand = function (output, context) { return __awaiter(void 0, void 0, void 0, function () {
270
+ var contents, data, _a, _b;
271
+ return __generator(this, function (_c) {
272
+ switch (_c.label) {
273
+ case 0:
274
+ if (output.statusCode !== 200 && output.statusCode >= 300) {
275
+ return [2, deserializeAws_restJson1StartDeviceAuthorizationCommandError(output, context)];
276
+ }
277
+ contents = map({
278
+ $metadata: deserializeMetadata(output),
279
+ });
280
+ _a = __expectNonNull;
281
+ _b = __expectObject;
282
+ return [4, parseBody(output.body, context)];
283
+ case 1:
284
+ data = _a.apply(void 0, [_b.apply(void 0, [_c.sent()]), "body"]);
285
+ if (data.deviceCode != null) {
286
+ contents.deviceCode = __expectString(data.deviceCode);
287
+ }
288
+ if (data.expiresIn != null) {
289
+ contents.expiresIn = __expectInt32(data.expiresIn);
290
+ }
291
+ if (data.interval != null) {
292
+ contents.interval = __expectInt32(data.interval);
293
+ }
294
+ if (data.userCode != null) {
295
+ contents.userCode = __expectString(data.userCode);
296
+ }
297
+ if (data.verificationUri != null) {
298
+ contents.verificationUri = __expectString(data.verificationUri);
299
+ }
300
+ if (data.verificationUriComplete != null) {
301
+ contents.verificationUriComplete = __expectString(data.verificationUriComplete);
302
+ }
303
+ return [2, contents];
304
+ }
157
305
  });
158
- const data = __expectNonNull(__expectObject(await parseBody(output.body, context)), "body");
159
- if (data.authorizationEndpoint != null) {
160
- contents.authorizationEndpoint = __expectString(data.authorizationEndpoint);
161
- }
162
- if (data.clientId != null) {
163
- contents.clientId = __expectString(data.clientId);
164
- }
165
- if (data.clientIdIssuedAt != null) {
166
- contents.clientIdIssuedAt = __expectLong(data.clientIdIssuedAt);
167
- }
168
- if (data.clientSecret != null) {
169
- contents.clientSecret = __expectString(data.clientSecret);
170
- }
171
- if (data.clientSecretExpiresAt != null) {
172
- contents.clientSecretExpiresAt = __expectLong(data.clientSecretExpiresAt);
173
- }
174
- if (data.tokenEndpoint != null) {
175
- contents.tokenEndpoint = __expectString(data.tokenEndpoint);
176
- }
177
- return contents;
178
- };
179
- const deserializeAws_restJson1RegisterClientCommandError = async (output, context) => {
180
- const parsedOutput = {
181
- ...output,
182
- body: await parseErrorBody(output.body, context),
183
- };
184
- const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
185
- switch (errorCode) {
186
- case "InternalServerException":
187
- case "com.amazonaws.ssooidc#InternalServerException":
188
- throw await deserializeAws_restJson1InternalServerExceptionResponse(parsedOutput, context);
189
- case "InvalidClientMetadataException":
190
- case "com.amazonaws.ssooidc#InvalidClientMetadataException":
191
- throw await deserializeAws_restJson1InvalidClientMetadataExceptionResponse(parsedOutput, context);
192
- case "InvalidRequestException":
193
- case "com.amazonaws.ssooidc#InvalidRequestException":
194
- throw await deserializeAws_restJson1InvalidRequestExceptionResponse(parsedOutput, context);
195
- case "InvalidScopeException":
196
- case "com.amazonaws.ssooidc#InvalidScopeException":
197
- throw await deserializeAws_restJson1InvalidScopeExceptionResponse(parsedOutput, context);
198
- default:
199
- const parsedBody = parsedOutput.body;
200
- throwDefaultError({
201
- output,
202
- parsedBody,
203
- exceptionCtor: __BaseException,
204
- errorCode,
205
- });
206
- }
207
- };
208
- export const deserializeAws_restJson1StartDeviceAuthorizationCommand = async (output, context) => {
209
- if (output.statusCode !== 200 && output.statusCode >= 300) {
210
- return deserializeAws_restJson1StartDeviceAuthorizationCommandError(output, context);
211
- }
212
- const contents = map({
213
- $metadata: deserializeMetadata(output),
306
+ }); };
307
+ var deserializeAws_restJson1StartDeviceAuthorizationCommandError = function (output, context) { return __awaiter(void 0, void 0, void 0, function () {
308
+ var parsedOutput, _a, errorCode, _b, parsedBody;
309
+ var _c;
310
+ return __generator(this, function (_d) {
311
+ switch (_d.label) {
312
+ case 0:
313
+ _a = [__assign({}, output)];
314
+ _c = {};
315
+ return [4, parseErrorBody(output.body, context)];
316
+ case 1:
317
+ parsedOutput = __assign.apply(void 0, _a.concat([(_c.body = _d.sent(), _c)]));
318
+ errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
319
+ _b = errorCode;
320
+ switch (_b) {
321
+ case "InternalServerException": return [3, 2];
322
+ case "com.amazonaws.ssooidc#InternalServerException": return [3, 2];
323
+ case "InvalidClientException": return [3, 4];
324
+ case "com.amazonaws.ssooidc#InvalidClientException": return [3, 4];
325
+ case "InvalidRequestException": return [3, 6];
326
+ case "com.amazonaws.ssooidc#InvalidRequestException": return [3, 6];
327
+ case "SlowDownException": return [3, 8];
328
+ case "com.amazonaws.ssooidc#SlowDownException": return [3, 8];
329
+ case "UnauthorizedClientException": return [3, 10];
330
+ case "com.amazonaws.ssooidc#UnauthorizedClientException": return [3, 10];
331
+ }
332
+ return [3, 12];
333
+ case 2: return [4, deserializeAws_restJson1InternalServerExceptionResponse(parsedOutput, context)];
334
+ case 3: throw _d.sent();
335
+ case 4: return [4, deserializeAws_restJson1InvalidClientExceptionResponse(parsedOutput, context)];
336
+ case 5: throw _d.sent();
337
+ case 6: return [4, deserializeAws_restJson1InvalidRequestExceptionResponse(parsedOutput, context)];
338
+ case 7: throw _d.sent();
339
+ case 8: return [4, deserializeAws_restJson1SlowDownExceptionResponse(parsedOutput, context)];
340
+ case 9: throw _d.sent();
341
+ case 10: return [4, deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context)];
342
+ case 11: throw _d.sent();
343
+ case 12:
344
+ parsedBody = parsedOutput.body;
345
+ throwDefaultError({
346
+ output: output,
347
+ parsedBody: parsedBody,
348
+ exceptionCtor: __BaseException,
349
+ errorCode: errorCode,
350
+ });
351
+ _d.label = 13;
352
+ case 13: return [2];
353
+ }
214
354
  });
215
- const data = __expectNonNull(__expectObject(await parseBody(output.body, context)), "body");
216
- if (data.deviceCode != null) {
217
- contents.deviceCode = __expectString(data.deviceCode);
218
- }
219
- if (data.expiresIn != null) {
220
- contents.expiresIn = __expectInt32(data.expiresIn);
221
- }
222
- if (data.interval != null) {
223
- contents.interval = __expectInt32(data.interval);
224
- }
225
- if (data.userCode != null) {
226
- contents.userCode = __expectString(data.userCode);
227
- }
228
- if (data.verificationUri != null) {
229
- contents.verificationUri = __expectString(data.verificationUri);
230
- }
231
- if (data.verificationUriComplete != null) {
232
- contents.verificationUriComplete = __expectString(data.verificationUriComplete);
233
- }
234
- return contents;
235
- };
236
- const deserializeAws_restJson1StartDeviceAuthorizationCommandError = async (output, context) => {
237
- const parsedOutput = {
238
- ...output,
239
- body: await parseErrorBody(output.body, context),
240
- };
241
- const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
242
- switch (errorCode) {
243
- case "InternalServerException":
244
- case "com.amazonaws.ssooidc#InternalServerException":
245
- throw await deserializeAws_restJson1InternalServerExceptionResponse(parsedOutput, context);
246
- case "InvalidClientException":
247
- case "com.amazonaws.ssooidc#InvalidClientException":
248
- throw await deserializeAws_restJson1InvalidClientExceptionResponse(parsedOutput, context);
249
- case "InvalidRequestException":
250
- case "com.amazonaws.ssooidc#InvalidRequestException":
251
- throw await deserializeAws_restJson1InvalidRequestExceptionResponse(parsedOutput, context);
252
- case "SlowDownException":
253
- case "com.amazonaws.ssooidc#SlowDownException":
254
- throw await deserializeAws_restJson1SlowDownExceptionResponse(parsedOutput, context);
255
- case "UnauthorizedClientException":
256
- case "com.amazonaws.ssooidc#UnauthorizedClientException":
257
- throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context);
258
- default:
259
- const parsedBody = parsedOutput.body;
260
- throwDefaultError({
261
- output,
262
- parsedBody,
263
- exceptionCtor: __BaseException,
264
- errorCode,
265
- });
266
- }
267
- };
268
- const map = __map;
269
- const deserializeAws_restJson1AccessDeniedExceptionResponse = async (parsedOutput, context) => {
270
- const contents = map({});
271
- const data = parsedOutput.body;
272
- if (data.error != null) {
273
- contents.error = __expectString(data.error);
274
- }
275
- if (data.error_description != null) {
276
- contents.error_description = __expectString(data.error_description);
277
- }
278
- const exception = new AccessDeniedException({
279
- $metadata: deserializeMetadata(parsedOutput),
280
- ...contents,
355
+ }); };
356
+ var map = __map;
357
+ var deserializeAws_restJson1AccessDeniedExceptionResponse = function (parsedOutput, context) { return __awaiter(void 0, void 0, void 0, function () {
358
+ var contents, data, exception;
359
+ return __generator(this, function (_a) {
360
+ contents = map({});
361
+ data = parsedOutput.body;
362
+ if (data.error != null) {
363
+ contents.error = __expectString(data.error);
364
+ }
365
+ if (data.error_description != null) {
366
+ contents.error_description = __expectString(data.error_description);
367
+ }
368
+ exception = new AccessDeniedException(__assign({ $metadata: deserializeMetadata(parsedOutput) }, contents));
369
+ return [2, __decorateServiceException(exception, parsedOutput.body)];
281
370
  });
282
- return __decorateServiceException(exception, parsedOutput.body);
283
- };
284
- const deserializeAws_restJson1AuthorizationPendingExceptionResponse = async (parsedOutput, context) => {
285
- const contents = map({});
286
- const data = parsedOutput.body;
287
- if (data.error != null) {
288
- contents.error = __expectString(data.error);
289
- }
290
- if (data.error_description != null) {
291
- contents.error_description = __expectString(data.error_description);
292
- }
293
- const exception = new AuthorizationPendingException({
294
- $metadata: deserializeMetadata(parsedOutput),
295
- ...contents,
371
+ }); };
372
+ var deserializeAws_restJson1AuthorizationPendingExceptionResponse = function (parsedOutput, context) { return __awaiter(void 0, void 0, void 0, function () {
373
+ var contents, data, exception;
374
+ return __generator(this, function (_a) {
375
+ contents = map({});
376
+ data = parsedOutput.body;
377
+ if (data.error != null) {
378
+ contents.error = __expectString(data.error);
379
+ }
380
+ if (data.error_description != null) {
381
+ contents.error_description = __expectString(data.error_description);
382
+ }
383
+ exception = new AuthorizationPendingException(__assign({ $metadata: deserializeMetadata(parsedOutput) }, contents));
384
+ return [2, __decorateServiceException(exception, parsedOutput.body)];
296
385
  });
297
- return __decorateServiceException(exception, parsedOutput.body);
298
- };
299
- const deserializeAws_restJson1ExpiredTokenExceptionResponse = async (parsedOutput, context) => {
300
- const contents = map({});
301
- const data = parsedOutput.body;
302
- if (data.error != null) {
303
- contents.error = __expectString(data.error);
304
- }
305
- if (data.error_description != null) {
306
- contents.error_description = __expectString(data.error_description);
307
- }
308
- const exception = new ExpiredTokenException({
309
- $metadata: deserializeMetadata(parsedOutput),
310
- ...contents,
386
+ }); };
387
+ var deserializeAws_restJson1ExpiredTokenExceptionResponse = function (parsedOutput, context) { return __awaiter(void 0, void 0, void 0, function () {
388
+ var contents, data, exception;
389
+ return __generator(this, function (_a) {
390
+ contents = map({});
391
+ data = parsedOutput.body;
392
+ if (data.error != null) {
393
+ contents.error = __expectString(data.error);
394
+ }
395
+ if (data.error_description != null) {
396
+ contents.error_description = __expectString(data.error_description);
397
+ }
398
+ exception = new ExpiredTokenException(__assign({ $metadata: deserializeMetadata(parsedOutput) }, contents));
399
+ return [2, __decorateServiceException(exception, parsedOutput.body)];
311
400
  });
312
- return __decorateServiceException(exception, parsedOutput.body);
313
- };
314
- const deserializeAws_restJson1InternalServerExceptionResponse = async (parsedOutput, context) => {
315
- const contents = map({});
316
- const data = parsedOutput.body;
317
- if (data.error != null) {
318
- contents.error = __expectString(data.error);
319
- }
320
- if (data.error_description != null) {
321
- contents.error_description = __expectString(data.error_description);
322
- }
323
- const exception = new InternalServerException({
324
- $metadata: deserializeMetadata(parsedOutput),
325
- ...contents,
401
+ }); };
402
+ var deserializeAws_restJson1InternalServerExceptionResponse = function (parsedOutput, context) { return __awaiter(void 0, void 0, void 0, function () {
403
+ var contents, data, exception;
404
+ return __generator(this, function (_a) {
405
+ contents = map({});
406
+ data = parsedOutput.body;
407
+ if (data.error != null) {
408
+ contents.error = __expectString(data.error);
409
+ }
410
+ if (data.error_description != null) {
411
+ contents.error_description = __expectString(data.error_description);
412
+ }
413
+ exception = new InternalServerException(__assign({ $metadata: deserializeMetadata(parsedOutput) }, contents));
414
+ return [2, __decorateServiceException(exception, parsedOutput.body)];
326
415
  });
327
- return __decorateServiceException(exception, parsedOutput.body);
328
- };
329
- const deserializeAws_restJson1InvalidClientExceptionResponse = async (parsedOutput, context) => {
330
- const contents = map({});
331
- const data = parsedOutput.body;
332
- if (data.error != null) {
333
- contents.error = __expectString(data.error);
334
- }
335
- if (data.error_description != null) {
336
- contents.error_description = __expectString(data.error_description);
337
- }
338
- const exception = new InvalidClientException({
339
- $metadata: deserializeMetadata(parsedOutput),
340
- ...contents,
416
+ }); };
417
+ var deserializeAws_restJson1InvalidClientExceptionResponse = function (parsedOutput, context) { return __awaiter(void 0, void 0, void 0, function () {
418
+ var contents, data, exception;
419
+ return __generator(this, function (_a) {
420
+ contents = map({});
421
+ data = parsedOutput.body;
422
+ if (data.error != null) {
423
+ contents.error = __expectString(data.error);
424
+ }
425
+ if (data.error_description != null) {
426
+ contents.error_description = __expectString(data.error_description);
427
+ }
428
+ exception = new InvalidClientException(__assign({ $metadata: deserializeMetadata(parsedOutput) }, contents));
429
+ return [2, __decorateServiceException(exception, parsedOutput.body)];
341
430
  });
342
- return __decorateServiceException(exception, parsedOutput.body);
343
- };
344
- const deserializeAws_restJson1InvalidClientMetadataExceptionResponse = async (parsedOutput, context) => {
345
- const contents = map({});
346
- const data = parsedOutput.body;
347
- if (data.error != null) {
348
- contents.error = __expectString(data.error);
349
- }
350
- if (data.error_description != null) {
351
- contents.error_description = __expectString(data.error_description);
352
- }
353
- const exception = new InvalidClientMetadataException({
354
- $metadata: deserializeMetadata(parsedOutput),
355
- ...contents,
431
+ }); };
432
+ var deserializeAws_restJson1InvalidClientMetadataExceptionResponse = function (parsedOutput, context) { return __awaiter(void 0, void 0, void 0, function () {
433
+ var contents, data, exception;
434
+ return __generator(this, function (_a) {
435
+ contents = map({});
436
+ data = parsedOutput.body;
437
+ if (data.error != null) {
438
+ contents.error = __expectString(data.error);
439
+ }
440
+ if (data.error_description != null) {
441
+ contents.error_description = __expectString(data.error_description);
442
+ }
443
+ exception = new InvalidClientMetadataException(__assign({ $metadata: deserializeMetadata(parsedOutput) }, contents));
444
+ return [2, __decorateServiceException(exception, parsedOutput.body)];
356
445
  });
357
- return __decorateServiceException(exception, parsedOutput.body);
358
- };
359
- const deserializeAws_restJson1InvalidGrantExceptionResponse = async (parsedOutput, context) => {
360
- const contents = map({});
361
- const data = parsedOutput.body;
362
- if (data.error != null) {
363
- contents.error = __expectString(data.error);
364
- }
365
- if (data.error_description != null) {
366
- contents.error_description = __expectString(data.error_description);
367
- }
368
- const exception = new InvalidGrantException({
369
- $metadata: deserializeMetadata(parsedOutput),
370
- ...contents,
446
+ }); };
447
+ var deserializeAws_restJson1InvalidGrantExceptionResponse = function (parsedOutput, context) { return __awaiter(void 0, void 0, void 0, function () {
448
+ var contents, data, exception;
449
+ return __generator(this, function (_a) {
450
+ contents = map({});
451
+ data = parsedOutput.body;
452
+ if (data.error != null) {
453
+ contents.error = __expectString(data.error);
454
+ }
455
+ if (data.error_description != null) {
456
+ contents.error_description = __expectString(data.error_description);
457
+ }
458
+ exception = new InvalidGrantException(__assign({ $metadata: deserializeMetadata(parsedOutput) }, contents));
459
+ return [2, __decorateServiceException(exception, parsedOutput.body)];
371
460
  });
372
- return __decorateServiceException(exception, parsedOutput.body);
373
- };
374
- const deserializeAws_restJson1InvalidRequestExceptionResponse = async (parsedOutput, context) => {
375
- const contents = map({});
376
- const data = parsedOutput.body;
377
- if (data.error != null) {
378
- contents.error = __expectString(data.error);
379
- }
380
- if (data.error_description != null) {
381
- contents.error_description = __expectString(data.error_description);
382
- }
383
- const exception = new InvalidRequestException({
384
- $metadata: deserializeMetadata(parsedOutput),
385
- ...contents,
461
+ }); };
462
+ var deserializeAws_restJson1InvalidRequestExceptionResponse = function (parsedOutput, context) { return __awaiter(void 0, void 0, void 0, function () {
463
+ var contents, data, exception;
464
+ return __generator(this, function (_a) {
465
+ contents = map({});
466
+ data = parsedOutput.body;
467
+ if (data.error != null) {
468
+ contents.error = __expectString(data.error);
469
+ }
470
+ if (data.error_description != null) {
471
+ contents.error_description = __expectString(data.error_description);
472
+ }
473
+ exception = new InvalidRequestException(__assign({ $metadata: deserializeMetadata(parsedOutput) }, contents));
474
+ return [2, __decorateServiceException(exception, parsedOutput.body)];
386
475
  });
387
- return __decorateServiceException(exception, parsedOutput.body);
388
- };
389
- const deserializeAws_restJson1InvalidScopeExceptionResponse = async (parsedOutput, context) => {
390
- const contents = map({});
391
- const data = parsedOutput.body;
392
- if (data.error != null) {
393
- contents.error = __expectString(data.error);
394
- }
395
- if (data.error_description != null) {
396
- contents.error_description = __expectString(data.error_description);
397
- }
398
- const exception = new InvalidScopeException({
399
- $metadata: deserializeMetadata(parsedOutput),
400
- ...contents,
476
+ }); };
477
+ var deserializeAws_restJson1InvalidScopeExceptionResponse = function (parsedOutput, context) { return __awaiter(void 0, void 0, void 0, function () {
478
+ var contents, data, exception;
479
+ return __generator(this, function (_a) {
480
+ contents = map({});
481
+ data = parsedOutput.body;
482
+ if (data.error != null) {
483
+ contents.error = __expectString(data.error);
484
+ }
485
+ if (data.error_description != null) {
486
+ contents.error_description = __expectString(data.error_description);
487
+ }
488
+ exception = new InvalidScopeException(__assign({ $metadata: deserializeMetadata(parsedOutput) }, contents));
489
+ return [2, __decorateServiceException(exception, parsedOutput.body)];
401
490
  });
402
- return __decorateServiceException(exception, parsedOutput.body);
403
- };
404
- const deserializeAws_restJson1SlowDownExceptionResponse = async (parsedOutput, context) => {
405
- const contents = map({});
406
- const data = parsedOutput.body;
407
- if (data.error != null) {
408
- contents.error = __expectString(data.error);
409
- }
410
- if (data.error_description != null) {
411
- contents.error_description = __expectString(data.error_description);
412
- }
413
- const exception = new SlowDownException({
414
- $metadata: deserializeMetadata(parsedOutput),
415
- ...contents,
491
+ }); };
492
+ var deserializeAws_restJson1SlowDownExceptionResponse = function (parsedOutput, context) { return __awaiter(void 0, void 0, void 0, function () {
493
+ var contents, data, exception;
494
+ return __generator(this, function (_a) {
495
+ contents = map({});
496
+ data = parsedOutput.body;
497
+ if (data.error != null) {
498
+ contents.error = __expectString(data.error);
499
+ }
500
+ if (data.error_description != null) {
501
+ contents.error_description = __expectString(data.error_description);
502
+ }
503
+ exception = new SlowDownException(__assign({ $metadata: deserializeMetadata(parsedOutput) }, contents));
504
+ return [2, __decorateServiceException(exception, parsedOutput.body)];
416
505
  });
417
- return __decorateServiceException(exception, parsedOutput.body);
418
- };
419
- const deserializeAws_restJson1UnauthorizedClientExceptionResponse = async (parsedOutput, context) => {
420
- const contents = map({});
421
- const data = parsedOutput.body;
422
- if (data.error != null) {
423
- contents.error = __expectString(data.error);
424
- }
425
- if (data.error_description != null) {
426
- contents.error_description = __expectString(data.error_description);
427
- }
428
- const exception = new UnauthorizedClientException({
429
- $metadata: deserializeMetadata(parsedOutput),
430
- ...contents,
506
+ }); };
507
+ var deserializeAws_restJson1UnauthorizedClientExceptionResponse = function (parsedOutput, context) { return __awaiter(void 0, void 0, void 0, function () {
508
+ var contents, data, exception;
509
+ return __generator(this, function (_a) {
510
+ contents = map({});
511
+ data = parsedOutput.body;
512
+ if (data.error != null) {
513
+ contents.error = __expectString(data.error);
514
+ }
515
+ if (data.error_description != null) {
516
+ contents.error_description = __expectString(data.error_description);
517
+ }
518
+ exception = new UnauthorizedClientException(__assign({ $metadata: deserializeMetadata(parsedOutput) }, contents));
519
+ return [2, __decorateServiceException(exception, parsedOutput.body)];
431
520
  });
432
- return __decorateServiceException(exception, parsedOutput.body);
433
- };
434
- const deserializeAws_restJson1UnsupportedGrantTypeExceptionResponse = async (parsedOutput, context) => {
435
- const contents = map({});
436
- const data = parsedOutput.body;
437
- if (data.error != null) {
438
- contents.error = __expectString(data.error);
439
- }
440
- if (data.error_description != null) {
441
- contents.error_description = __expectString(data.error_description);
442
- }
443
- const exception = new UnsupportedGrantTypeException({
444
- $metadata: deserializeMetadata(parsedOutput),
445
- ...contents,
521
+ }); };
522
+ var deserializeAws_restJson1UnsupportedGrantTypeExceptionResponse = function (parsedOutput, context) { return __awaiter(void 0, void 0, void 0, function () {
523
+ var contents, data, exception;
524
+ return __generator(this, function (_a) {
525
+ contents = map({});
526
+ data = parsedOutput.body;
527
+ if (data.error != null) {
528
+ contents.error = __expectString(data.error);
529
+ }
530
+ if (data.error_description != null) {
531
+ contents.error_description = __expectString(data.error_description);
532
+ }
533
+ exception = new UnsupportedGrantTypeException(__assign({ $metadata: deserializeMetadata(parsedOutput) }, contents));
534
+ return [2, __decorateServiceException(exception, parsedOutput.body)];
446
535
  });
447
- return __decorateServiceException(exception, parsedOutput.body);
448
- };
449
- const serializeAws_restJson1Scopes = (input, context) => {
536
+ }); };
537
+ var serializeAws_restJson1Scopes = function (input, context) {
450
538
  return input
451
- .filter((e) => e != null)
452
- .map((entry) => {
539
+ .filter(function (e) { return e != null; })
540
+ .map(function (entry) {
453
541
  return entry;
454
542
  });
455
543
  };
456
- const deserializeMetadata = (output) => ({
457
- httpStatusCode: output.statusCode,
458
- requestId: output.headers["x-amzn-requestid"] ?? output.headers["x-amzn-request-id"],
459
- extendedRequestId: output.headers["x-amz-id-2"],
460
- cfId: output.headers["x-amz-cf-id"],
461
- });
462
- const collectBody = (streamBody = new Uint8Array(), context) => {
544
+ var deserializeMetadata = function (output) {
545
+ var _a, _b;
546
+ return ({
547
+ httpStatusCode: output.statusCode,
548
+ 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"],
549
+ extendedRequestId: output.headers["x-amz-id-2"],
550
+ cfId: output.headers["x-amz-cf-id"],
551
+ });
552
+ };
553
+ var collectBody = function (streamBody, context) {
554
+ if (streamBody === void 0) { streamBody = new Uint8Array(); }
463
555
  if (streamBody instanceof Uint8Array) {
464
556
  return Promise.resolve(streamBody);
465
557
  }
466
558
  return context.streamCollector(streamBody) || Promise.resolve(new Uint8Array());
467
559
  };
468
- const collectBodyString = (streamBody, context) => collectBody(streamBody, context).then((body) => context.utf8Encoder(body));
469
- const isSerializableHeaderValue = (value) => value !== undefined &&
470
- value !== null &&
471
- value !== "" &&
472
- (!Object.getOwnPropertyNames(value).includes("length") || value.length != 0) &&
473
- (!Object.getOwnPropertyNames(value).includes("size") || value.size != 0);
474
- const parseBody = (streamBody, context) => collectBodyString(streamBody, context).then((encoded) => {
475
- if (encoded.length) {
476
- return JSON.parse(encoded);
477
- }
478
- return {};
479
- });
480
- const parseErrorBody = async (errorBody, context) => {
481
- const value = await parseBody(errorBody, context);
482
- value.message = value.message ?? value.Message;
483
- return value;
560
+ var collectBodyString = function (streamBody, context) {
561
+ return collectBody(streamBody, context).then(function (body) { return context.utf8Encoder(body); });
562
+ };
563
+ var isSerializableHeaderValue = function (value) {
564
+ return value !== undefined &&
565
+ value !== null &&
566
+ value !== "" &&
567
+ (!Object.getOwnPropertyNames(value).includes("length") || value.length != 0) &&
568
+ (!Object.getOwnPropertyNames(value).includes("size") || value.size != 0);
484
569
  };
485
- const loadRestJsonErrorCode = (output, data) => {
486
- const findKey = (object, key) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase());
487
- const sanitizeErrorCode = (rawValue) => {
488
- let cleanValue = rawValue;
570
+ var parseBody = function (streamBody, context) {
571
+ return collectBodyString(streamBody, context).then(function (encoded) {
572
+ if (encoded.length) {
573
+ return JSON.parse(encoded);
574
+ }
575
+ return {};
576
+ });
577
+ };
578
+ var parseErrorBody = function (errorBody, context) { return __awaiter(void 0, void 0, void 0, function () {
579
+ var value;
580
+ var _a;
581
+ return __generator(this, function (_b) {
582
+ switch (_b.label) {
583
+ case 0: return [4, parseBody(errorBody, context)];
584
+ case 1:
585
+ value = _b.sent();
586
+ value.message = (_a = value.message) !== null && _a !== void 0 ? _a : value.Message;
587
+ return [2, value];
588
+ }
589
+ });
590
+ }); };
591
+ var loadRestJsonErrorCode = function (output, data) {
592
+ var findKey = function (object, key) { return Object.keys(object).find(function (k) { return k.toLowerCase() === key.toLowerCase(); }); };
593
+ var sanitizeErrorCode = function (rawValue) {
594
+ var cleanValue = rawValue;
489
595
  if (typeof cleanValue === "number") {
490
596
  cleanValue = cleanValue.toString();
491
597
  }
@@ -500,7 +606,7 @@ const loadRestJsonErrorCode = (output, data) => {
500
606
  }
501
607
  return cleanValue;
502
608
  };
503
- const headerKey = findKey(output.headers, "x-amzn-errortype");
609
+ var headerKey = findKey(output.headers, "x-amzn-errortype");
504
610
  if (headerKey !== undefined) {
505
611
  return sanitizeErrorCode(output.headers[headerKey]);
506
612
  }