@aws-sdk/client-rekognitionstreaming 3.305.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.
Files changed (71) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +222 -0
  3. package/dist-cjs/RekognitionStreaming.js +37 -0
  4. package/dist-cjs/RekognitionStreamingClient.js +46 -0
  5. package/dist-cjs/commands/StartFaceLivenessSessionCommand.js +50 -0
  6. package/dist-cjs/commands/StartStreamingLivenessSessionCommand.js +50 -0
  7. package/dist-cjs/commands/index.js +5 -0
  8. package/dist-cjs/endpoint/EndpointParameters.js +12 -0
  9. package/dist-cjs/endpoint/endpointResolver.js +12 -0
  10. package/dist-cjs/endpoint/ruleset.js +7 -0
  11. package/dist-cjs/index.js +10 -0
  12. package/dist-cjs/models/RekognitionStreamingServiceException.js +11 -0
  13. package/dist-cjs/models/index.js +4 -0
  14. package/dist-cjs/models/models_0.js +188 -0
  15. package/dist-cjs/protocols/Aws_restJson1.js +573 -0
  16. package/dist-cjs/runtimeConfig.browser.js +44 -0
  17. package/dist-cjs/runtimeConfig.js +52 -0
  18. package/dist-cjs/runtimeConfig.native.js +18 -0
  19. package/dist-cjs/runtimeConfig.shared.js +21 -0
  20. package/dist-es/RekognitionStreaming.js +33 -0
  21. package/dist-es/RekognitionStreamingClient.js +42 -0
  22. package/dist-es/commands/StartFaceLivenessSessionCommand.js +46 -0
  23. package/dist-es/commands/StartStreamingLivenessSessionCommand.js +46 -0
  24. package/dist-es/commands/index.js +2 -0
  25. package/dist-es/endpoint/EndpointParameters.js +8 -0
  26. package/dist-es/endpoint/endpointResolver.js +8 -0
  27. package/dist-es/endpoint/ruleset.js +4 -0
  28. package/dist-es/index.js +5 -0
  29. package/dist-es/models/RekognitionStreamingServiceException.js +7 -0
  30. package/dist-es/models/index.js +1 -0
  31. package/dist-es/models/models_0.js +173 -0
  32. package/dist-es/protocols/Aws_restJson1.js +566 -0
  33. package/dist-es/runtimeConfig.browser.js +39 -0
  34. package/dist-es/runtimeConfig.js +47 -0
  35. package/dist-es/runtimeConfig.native.js +14 -0
  36. package/dist-es/runtimeConfig.shared.js +17 -0
  37. package/dist-types/RekognitionStreaming.d.ts +21 -0
  38. package/dist-types/RekognitionStreamingClient.d.ts +174 -0
  39. package/dist-types/commands/StartFaceLivenessSessionCommand.d.ts +39 -0
  40. package/dist-types/commands/StartStreamingLivenessSessionCommand.d.ts +39 -0
  41. package/dist-types/commands/index.d.ts +2 -0
  42. package/dist-types/endpoint/EndpointParameters.d.ts +19 -0
  43. package/dist-types/endpoint/endpointResolver.d.ts +5 -0
  44. package/dist-types/endpoint/ruleset.d.ts +2 -0
  45. package/dist-types/index.d.ts +5 -0
  46. package/dist-types/models/RekognitionStreamingServiceException.d.ts +12 -0
  47. package/dist-types/models/index.d.ts +1 -0
  48. package/dist-types/models/models_0.d.ts +415 -0
  49. package/dist-types/protocols/Aws_restJson1.d.ts +8 -0
  50. package/dist-types/runtimeConfig.browser.d.ts +44 -0
  51. package/dist-types/runtimeConfig.d.ts +44 -0
  52. package/dist-types/runtimeConfig.native.d.ts +43 -0
  53. package/dist-types/runtimeConfig.shared.d.ts +18 -0
  54. package/dist-types/ts3.4/RekognitionStreaming.d.ts +38 -0
  55. package/dist-types/ts3.4/RekognitionStreamingClient.d.ts +147 -0
  56. package/dist-types/ts3.4/commands/StartFaceLivenessSessionCommand.d.ts +41 -0
  57. package/dist-types/ts3.4/commands/StartStreamingLivenessSessionCommand.d.ts +41 -0
  58. package/dist-types/ts3.4/commands/index.d.ts +2 -0
  59. package/dist-types/ts3.4/endpoint/EndpointParameters.d.ts +33 -0
  60. package/dist-types/ts3.4/endpoint/endpointResolver.d.ts +8 -0
  61. package/dist-types/ts3.4/endpoint/ruleset.d.ts +2 -0
  62. package/dist-types/ts3.4/index.d.ts +5 -0
  63. package/dist-types/ts3.4/models/RekognitionStreamingServiceException.d.ts +7 -0
  64. package/dist-types/ts3.4/models/index.d.ts +1 -0
  65. package/dist-types/ts3.4/models/models_0.d.ts +316 -0
  66. package/dist-types/ts3.4/protocols/Aws_restJson1.d.ts +32 -0
  67. package/dist-types/ts3.4/runtimeConfig.browser.d.ts +95 -0
  68. package/dist-types/ts3.4/runtimeConfig.d.ts +95 -0
  69. package/dist-types/ts3.4/runtimeConfig.native.d.ts +84 -0
  70. package/dist-types/ts3.4/runtimeConfig.shared.d.ts +20 -0
  71. package/package.json +104 -0
@@ -0,0 +1,566 @@
1
+ import { HttpRequest as __HttpRequest } from "@aws-sdk/protocol-http";
2
+ import { decorateServiceException as __decorateServiceException, expectInt32 as __expectInt32, expectLong as __expectLong, expectString as __expectString, expectUnion as __expectUnion, limitedParseFloat32 as __limitedParseFloat32, map as __map, serializeFloat as __serializeFloat, throwDefaultError, } from "@aws-sdk/smithy-client";
3
+ import { AccessDeniedException, ClientChallenge, InternalServerException, LivenessRequestStream, ServiceQuotaExceededException, SessionNotFoundException, ThrottlingException, ValidationException, } from "../models/models_0";
4
+ import { RekognitionStreamingServiceException as __BaseException } from "../models/RekognitionStreamingServiceException";
5
+ export const serializeAws_restJson1StartFaceLivenessSessionCommand = async (input, context) => {
6
+ const { hostname, protocol = "https", port, path: basePath } = await context.endpoint();
7
+ const headers = map({}, isSerializableHeaderValue, {
8
+ "x-amz-rekognition-streaming-liveness-session-id": input.SessionId,
9
+ "x-amz-rekognition-streaming-liveness-client-sdk-version": input.ClientSDKVersion,
10
+ });
11
+ const resolvedPath = `${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` + "/start-face-liveness-session";
12
+ let body;
13
+ if (input.LivenessRequestStream !== undefined) {
14
+ body = serializeAws_restJson1LivenessRequestStream(input.LivenessRequestStream, context);
15
+ }
16
+ return new __HttpRequest({
17
+ protocol,
18
+ hostname,
19
+ port,
20
+ method: "POST",
21
+ headers,
22
+ path: resolvedPath,
23
+ body,
24
+ });
25
+ };
26
+ export const serializeAws_restJson1StartStreamingLivenessSessionCommand = async (input, context) => {
27
+ const { hostname, protocol = "https", port, path: basePath } = await context.endpoint();
28
+ const headers = map({}, isSerializableHeaderValue, {
29
+ "x-amz-rekognition-streaming-liveness-session-id": input.SessionId,
30
+ "x-amz-rekognition-streaming-liveness-client-sdk-version": input.ClientSDKVersion,
31
+ });
32
+ const resolvedPath = `${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` + "/start-streaming-liveness-session";
33
+ let body;
34
+ if (input.LivenessRequestStream !== undefined) {
35
+ body = serializeAws_restJson1LivenessRequestStream(input.LivenessRequestStream, context);
36
+ }
37
+ return new __HttpRequest({
38
+ protocol,
39
+ hostname,
40
+ port,
41
+ method: "POST",
42
+ headers,
43
+ path: resolvedPath,
44
+ body,
45
+ });
46
+ };
47
+ export const deserializeAws_restJson1StartFaceLivenessSessionCommand = async (output, context) => {
48
+ if (output.statusCode !== 200 && output.statusCode >= 300) {
49
+ return deserializeAws_restJson1StartFaceLivenessSessionCommandError(output, context);
50
+ }
51
+ const contents = map({
52
+ $metadata: deserializeMetadata(output),
53
+ SessionId: [, output.headers["x-amz-rekognition-streaming-liveness-session-id"]],
54
+ });
55
+ const data = output.body;
56
+ contents.LivenessResponseStream = deserializeAws_restJson1LivenessResponseStream(data, context);
57
+ return contents;
58
+ };
59
+ const deserializeAws_restJson1StartFaceLivenessSessionCommandError = async (output, context) => {
60
+ const parsedOutput = {
61
+ ...output,
62
+ body: await parseErrorBody(output.body, context),
63
+ };
64
+ const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
65
+ switch (errorCode) {
66
+ case "AccessDeniedException":
67
+ case "com.amazonaws.rekognitionstreaming#AccessDeniedException":
68
+ throw await deserializeAws_restJson1AccessDeniedExceptionResponse(parsedOutput, context);
69
+ case "InternalServerException":
70
+ case "com.amazonaws.rekognitionstreaming#InternalServerException":
71
+ throw await deserializeAws_restJson1InternalServerExceptionResponse(parsedOutput, context);
72
+ case "ServiceQuotaExceededException":
73
+ case "com.amazonaws.rekognitionstreaming#ServiceQuotaExceededException":
74
+ throw await deserializeAws_restJson1ServiceQuotaExceededExceptionResponse(parsedOutput, context);
75
+ case "SessionNotFoundException":
76
+ case "com.amazonaws.rekognitionstreaming#SessionNotFoundException":
77
+ throw await deserializeAws_restJson1SessionNotFoundExceptionResponse(parsedOutput, context);
78
+ case "ThrottlingException":
79
+ case "com.amazonaws.rekognitionstreaming#ThrottlingException":
80
+ throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context);
81
+ case "ValidationException":
82
+ case "com.amazonaws.rekognitionstreaming#ValidationException":
83
+ throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context);
84
+ default:
85
+ const parsedBody = parsedOutput.body;
86
+ throwDefaultError({
87
+ output,
88
+ parsedBody,
89
+ exceptionCtor: __BaseException,
90
+ errorCode,
91
+ });
92
+ }
93
+ };
94
+ export const deserializeAws_restJson1StartStreamingLivenessSessionCommand = async (output, context) => {
95
+ if (output.statusCode !== 200 && output.statusCode >= 300) {
96
+ return deserializeAws_restJson1StartStreamingLivenessSessionCommandError(output, context);
97
+ }
98
+ const contents = map({
99
+ $metadata: deserializeMetadata(output),
100
+ SessionId: [, output.headers["x-amz-rekognition-streaming-liveness-session-id"]],
101
+ });
102
+ const data = output.body;
103
+ contents.LivenessResponseStream = deserializeAws_restJson1LivenessResponseStream(data, context);
104
+ return contents;
105
+ };
106
+ const deserializeAws_restJson1StartStreamingLivenessSessionCommandError = async (output, context) => {
107
+ const parsedOutput = {
108
+ ...output,
109
+ body: await parseErrorBody(output.body, context),
110
+ };
111
+ const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
112
+ switch (errorCode) {
113
+ case "AccessDeniedException":
114
+ case "com.amazonaws.rekognitionstreaming#AccessDeniedException":
115
+ throw await deserializeAws_restJson1AccessDeniedExceptionResponse(parsedOutput, context);
116
+ case "InternalServerException":
117
+ case "com.amazonaws.rekognitionstreaming#InternalServerException":
118
+ throw await deserializeAws_restJson1InternalServerExceptionResponse(parsedOutput, context);
119
+ case "ServiceQuotaExceededException":
120
+ case "com.amazonaws.rekognitionstreaming#ServiceQuotaExceededException":
121
+ throw await deserializeAws_restJson1ServiceQuotaExceededExceptionResponse(parsedOutput, context);
122
+ case "SessionNotFoundException":
123
+ case "com.amazonaws.rekognitionstreaming#SessionNotFoundException":
124
+ throw await deserializeAws_restJson1SessionNotFoundExceptionResponse(parsedOutput, context);
125
+ case "ThrottlingException":
126
+ case "com.amazonaws.rekognitionstreaming#ThrottlingException":
127
+ throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context);
128
+ case "ValidationException":
129
+ case "com.amazonaws.rekognitionstreaming#ValidationException":
130
+ throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context);
131
+ default:
132
+ const parsedBody = parsedOutput.body;
133
+ throwDefaultError({
134
+ output,
135
+ parsedBody,
136
+ exceptionCtor: __BaseException,
137
+ errorCode,
138
+ });
139
+ }
140
+ };
141
+ const map = __map;
142
+ const deserializeAws_restJson1AccessDeniedExceptionResponse = async (parsedOutput, context) => {
143
+ const contents = map({});
144
+ const data = parsedOutput.body;
145
+ if (data.Code != null) {
146
+ contents.Code = __expectString(data.Code);
147
+ }
148
+ if (data.Message != null) {
149
+ contents.Message = __expectString(data.Message);
150
+ }
151
+ const exception = new AccessDeniedException({
152
+ $metadata: deserializeMetadata(parsedOutput),
153
+ ...contents,
154
+ });
155
+ return __decorateServiceException(exception, parsedOutput.body);
156
+ };
157
+ const deserializeAws_restJson1InternalServerExceptionResponse = async (parsedOutput, context) => {
158
+ const contents = map({});
159
+ const data = parsedOutput.body;
160
+ if (data.Code != null) {
161
+ contents.Code = __expectString(data.Code);
162
+ }
163
+ if (data.Message != null) {
164
+ contents.Message = __expectString(data.Message);
165
+ }
166
+ const exception = new InternalServerException({
167
+ $metadata: deserializeMetadata(parsedOutput),
168
+ ...contents,
169
+ });
170
+ return __decorateServiceException(exception, parsedOutput.body);
171
+ };
172
+ const deserializeAws_restJson1ServiceQuotaExceededExceptionResponse = async (parsedOutput, context) => {
173
+ const contents = map({});
174
+ const data = parsedOutput.body;
175
+ if (data.Code != null) {
176
+ contents.Code = __expectString(data.Code);
177
+ }
178
+ if (data.Message != null) {
179
+ contents.Message = __expectString(data.Message);
180
+ }
181
+ const exception = new ServiceQuotaExceededException({
182
+ $metadata: deserializeMetadata(parsedOutput),
183
+ ...contents,
184
+ });
185
+ return __decorateServiceException(exception, parsedOutput.body);
186
+ };
187
+ const deserializeAws_restJson1SessionNotFoundExceptionResponse = async (parsedOutput, context) => {
188
+ const contents = map({});
189
+ const data = parsedOutput.body;
190
+ if (data.Code != null) {
191
+ contents.Code = __expectString(data.Code);
192
+ }
193
+ if (data.Message != null) {
194
+ contents.Message = __expectString(data.Message);
195
+ }
196
+ const exception = new SessionNotFoundException({
197
+ $metadata: deserializeMetadata(parsedOutput),
198
+ ...contents,
199
+ });
200
+ return __decorateServiceException(exception, parsedOutput.body);
201
+ };
202
+ const deserializeAws_restJson1ThrottlingExceptionResponse = async (parsedOutput, context) => {
203
+ const contents = map({});
204
+ const data = parsedOutput.body;
205
+ if (data.Code != null) {
206
+ contents.Code = __expectString(data.Code);
207
+ }
208
+ if (data.Message != null) {
209
+ contents.Message = __expectString(data.Message);
210
+ }
211
+ const exception = new ThrottlingException({
212
+ $metadata: deserializeMetadata(parsedOutput),
213
+ ...contents,
214
+ });
215
+ return __decorateServiceException(exception, parsedOutput.body);
216
+ };
217
+ const deserializeAws_restJson1ValidationExceptionResponse = async (parsedOutput, context) => {
218
+ const contents = map({});
219
+ const data = parsedOutput.body;
220
+ if (data.Code != null) {
221
+ contents.Code = __expectString(data.Code);
222
+ }
223
+ if (data.Message != null) {
224
+ contents.Message = __expectString(data.Message);
225
+ }
226
+ const exception = new ValidationException({
227
+ $metadata: deserializeMetadata(parsedOutput),
228
+ ...contents,
229
+ });
230
+ return __decorateServiceException(exception, parsedOutput.body);
231
+ };
232
+ const serializeAws_restJson1LivenessRequestStream = (input, context) => {
233
+ const eventMarshallingVisitor = (event) => LivenessRequestStream.visit(event, {
234
+ VideoEvent: (value) => serializeAws_restJson1VideoEvent_event(value, context),
235
+ ClientSessionInformationEvent: (value) => serializeAws_restJson1ClientSessionInformationEvent_event(value, context),
236
+ _: (value) => value,
237
+ });
238
+ return context.eventStreamMarshaller.serialize(input, eventMarshallingVisitor);
239
+ };
240
+ const serializeAws_restJson1ClientSessionInformationEvent_event = (input, context) => {
241
+ const headers = {
242
+ ":event-type": { type: "string", value: "ClientSessionInformationEvent" },
243
+ ":message-type": { type: "string", value: "event" },
244
+ ":content-type": { type: "string", value: "application/json" },
245
+ };
246
+ let body = new Uint8Array();
247
+ body = serializeAws_restJson1ClientSessionInformationEvent(input, context);
248
+ body = context.utf8Decoder(JSON.stringify(body));
249
+ return { headers, body };
250
+ };
251
+ const serializeAws_restJson1VideoEvent_event = (input, context) => {
252
+ const headers = {
253
+ ":event-type": { type: "string", value: "VideoEvent" },
254
+ ":message-type": { type: "string", value: "event" },
255
+ ":content-type": { type: "string", value: "application/json" },
256
+ };
257
+ let body = new Uint8Array();
258
+ body = serializeAws_restJson1VideoEvent(input, context);
259
+ body = context.utf8Decoder(JSON.stringify(body));
260
+ return { headers, body };
261
+ };
262
+ const deserializeAws_restJson1LivenessResponseStream = (output, context) => {
263
+ return context.eventStreamMarshaller.deserialize(output, async (event) => {
264
+ if (event["ServerSessionInformationEvent"] != null) {
265
+ return {
266
+ ServerSessionInformationEvent: await deserializeAws_restJson1ServerSessionInformationEvent_event(event["ServerSessionInformationEvent"], context),
267
+ };
268
+ }
269
+ if (event["DisconnectionEvent"] != null) {
270
+ return {
271
+ DisconnectionEvent: await deserializeAws_restJson1DisconnectionEvent_event(event["DisconnectionEvent"], context),
272
+ };
273
+ }
274
+ if (event["ValidationException"] != null) {
275
+ return {
276
+ ValidationException: await deserializeAws_restJson1ValidationException_event(event["ValidationException"], context),
277
+ };
278
+ }
279
+ if (event["InternalServerException"] != null) {
280
+ return {
281
+ InternalServerException: await deserializeAws_restJson1InternalServerException_event(event["InternalServerException"], context),
282
+ };
283
+ }
284
+ if (event["ThrottlingException"] != null) {
285
+ return {
286
+ ThrottlingException: await deserializeAws_restJson1ThrottlingException_event(event["ThrottlingException"], context),
287
+ };
288
+ }
289
+ if (event["ServiceQuotaExceededException"] != null) {
290
+ return {
291
+ ServiceQuotaExceededException: await deserializeAws_restJson1ServiceQuotaExceededException_event(event["ServiceQuotaExceededException"], context),
292
+ };
293
+ }
294
+ return { $unknown: output };
295
+ });
296
+ };
297
+ const deserializeAws_restJson1DisconnectionEvent_event = async (output, context) => {
298
+ const contents = {};
299
+ const data = await parseBody(output.body, context);
300
+ Object.assign(contents, deserializeAws_restJson1DisconnectionEvent(data, context));
301
+ return contents;
302
+ };
303
+ const deserializeAws_restJson1InternalServerException_event = async (output, context) => {
304
+ const parsedOutput = {
305
+ ...output,
306
+ body: await parseBody(output.body, context),
307
+ };
308
+ return deserializeAws_restJson1InternalServerExceptionResponse(parsedOutput, context);
309
+ };
310
+ const deserializeAws_restJson1ServerSessionInformationEvent_event = async (output, context) => {
311
+ const contents = {};
312
+ const data = await parseBody(output.body, context);
313
+ Object.assign(contents, deserializeAws_restJson1ServerSessionInformationEvent(data, context));
314
+ return contents;
315
+ };
316
+ const deserializeAws_restJson1ServiceQuotaExceededException_event = async (output, context) => {
317
+ const parsedOutput = {
318
+ ...output,
319
+ body: await parseBody(output.body, context),
320
+ };
321
+ return deserializeAws_restJson1ServiceQuotaExceededExceptionResponse(parsedOutput, context);
322
+ };
323
+ const deserializeAws_restJson1ThrottlingException_event = async (output, context) => {
324
+ const parsedOutput = {
325
+ ...output,
326
+ body: await parseBody(output.body, context),
327
+ };
328
+ return deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context);
329
+ };
330
+ const deserializeAws_restJson1ValidationException_event = async (output, context) => {
331
+ const parsedOutput = {
332
+ ...output,
333
+ body: await parseBody(output.body, context),
334
+ };
335
+ return deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context);
336
+ };
337
+ const serializeAws_restJson1BoundingBox = (input, context) => {
338
+ return {
339
+ ...(input.Height != null && { Height: __serializeFloat(input.Height) }),
340
+ ...(input.Left != null && { Left: __serializeFloat(input.Left) }),
341
+ ...(input.Top != null && { Top: __serializeFloat(input.Top) }),
342
+ ...(input.Width != null && { Width: __serializeFloat(input.Width) }),
343
+ };
344
+ };
345
+ const serializeAws_restJson1ClientChallenge = (input, context) => {
346
+ return ClientChallenge.visit(input, {
347
+ FaceMovementAndLightChallenge: (value) => ({
348
+ FaceMovementAndLightChallenge: serializeAws_restJson1FaceMovementAndLightClientChallenge(value, context),
349
+ }),
350
+ _: (name, value) => ({ name: value }),
351
+ });
352
+ };
353
+ const serializeAws_restJson1ClientSessionInformationEvent = (input, context) => {
354
+ return {
355
+ ...(input.Challenge != null && { Challenge: serializeAws_restJson1ClientChallenge(input.Challenge, context) }),
356
+ ...(input.DeviceInformation != null && {
357
+ DeviceInformation: serializeAws_restJson1DeviceInformation(input.DeviceInformation, context),
358
+ }),
359
+ };
360
+ };
361
+ const serializeAws_restJson1ColorComponentList = (input, context) => {
362
+ return input
363
+ .filter((e) => e != null)
364
+ .map((entry) => {
365
+ return entry;
366
+ });
367
+ };
368
+ const serializeAws_restJson1ColorDisplayed = (input, context) => {
369
+ return {
370
+ ...(input.CurrentColor != null && {
371
+ CurrentColor: serializeAws_restJson1FreshnessColor(input.CurrentColor, context),
372
+ }),
373
+ ...(input.CurrentColorStartTimestamp != null && { CurrentColorStartTimestamp: input.CurrentColorStartTimestamp }),
374
+ ...(input.PreviousColor != null && {
375
+ PreviousColor: serializeAws_restJson1FreshnessColor(input.PreviousColor, context),
376
+ }),
377
+ ...(input.SequenceNumber != null && { SequenceNumber: input.SequenceNumber }),
378
+ };
379
+ };
380
+ const serializeAws_restJson1DeviceInformation = (input, context) => {
381
+ return {
382
+ ...(input.ClientSDKVersion != null && { ClientSDKVersion: input.ClientSDKVersion }),
383
+ ...(input.VideoHeight != null && { VideoHeight: __serializeFloat(input.VideoHeight) }),
384
+ ...(input.VideoWidth != null && { VideoWidth: __serializeFloat(input.VideoWidth) }),
385
+ };
386
+ };
387
+ const serializeAws_restJson1FaceMovementAndLightClientChallenge = (input, context) => {
388
+ return {
389
+ ...(input.ChallengeId != null && { ChallengeId: input.ChallengeId }),
390
+ ...(input.ColorDisplayed != null && {
391
+ ColorDisplayed: serializeAws_restJson1ColorDisplayed(input.ColorDisplayed, context),
392
+ }),
393
+ ...(input.InitialFace != null && { InitialFace: serializeAws_restJson1InitialFace(input.InitialFace, context) }),
394
+ ...(input.TargetFace != null && { TargetFace: serializeAws_restJson1TargetFace(input.TargetFace, context) }),
395
+ ...(input.VideoStartTimestamp != null && { VideoStartTimestamp: input.VideoStartTimestamp }),
396
+ };
397
+ };
398
+ const serializeAws_restJson1FreshnessColor = (input, context) => {
399
+ return {
400
+ ...(input.RGB != null && { RGB: serializeAws_restJson1ColorComponentList(input.RGB, context) }),
401
+ };
402
+ };
403
+ const serializeAws_restJson1InitialFace = (input, context) => {
404
+ return {
405
+ ...(input.BoundingBox != null && { BoundingBox: serializeAws_restJson1BoundingBox(input.BoundingBox, context) }),
406
+ ...(input.InitialFaceDetectedTimestamp != null && {
407
+ InitialFaceDetectedTimestamp: input.InitialFaceDetectedTimestamp,
408
+ }),
409
+ };
410
+ };
411
+ const serializeAws_restJson1TargetFace = (input, context) => {
412
+ return {
413
+ ...(input.BoundingBox != null && { BoundingBox: serializeAws_restJson1BoundingBox(input.BoundingBox, context) }),
414
+ ...(input.FaceDetectedInTargetPositionEndTimestamp != null && {
415
+ FaceDetectedInTargetPositionEndTimestamp: input.FaceDetectedInTargetPositionEndTimestamp,
416
+ }),
417
+ ...(input.FaceDetectedInTargetPositionStartTimestamp != null && {
418
+ FaceDetectedInTargetPositionStartTimestamp: input.FaceDetectedInTargetPositionStartTimestamp,
419
+ }),
420
+ };
421
+ };
422
+ const serializeAws_restJson1VideoEvent = (input, context) => {
423
+ return {
424
+ ...(input.TimestampMillis != null && { TimestampMillis: input.TimestampMillis }),
425
+ ...(input.VideoChunk != null && { VideoChunk: context.base64Encoder(input.VideoChunk) }),
426
+ };
427
+ };
428
+ const deserializeAws_restJson1ColorComponentList = (output, context) => {
429
+ const retVal = (output || [])
430
+ .filter((e) => e != null)
431
+ .map((entry) => {
432
+ if (entry === null) {
433
+ return null;
434
+ }
435
+ return __expectInt32(entry);
436
+ });
437
+ return retVal;
438
+ };
439
+ const deserializeAws_restJson1ColorSequence = (output, context) => {
440
+ return {
441
+ DownscrollDuration: __limitedParseFloat32(output.DownscrollDuration),
442
+ FlatDisplayDuration: __limitedParseFloat32(output.FlatDisplayDuration),
443
+ FreshnessColor: output.FreshnessColor != null
444
+ ? deserializeAws_restJson1FreshnessColor(output.FreshnessColor, context)
445
+ : undefined,
446
+ };
447
+ };
448
+ const deserializeAws_restJson1ColorSequences = (output, context) => {
449
+ const retVal = (output || [])
450
+ .filter((e) => e != null)
451
+ .map((entry) => {
452
+ if (entry === null) {
453
+ return null;
454
+ }
455
+ return deserializeAws_restJson1ColorSequence(entry, context);
456
+ });
457
+ return retVal;
458
+ };
459
+ const deserializeAws_restJson1DisconnectionEvent = (output, context) => {
460
+ return {
461
+ TimestampMillis: __expectLong(output.TimestampMillis),
462
+ };
463
+ };
464
+ const deserializeAws_restJson1FaceMovementAndLightServerChallenge = (output, context) => {
465
+ return {
466
+ ColorSequences: output.ColorSequences != null
467
+ ? deserializeAws_restJson1ColorSequences(output.ColorSequences, context)
468
+ : undefined,
469
+ LightChallengeType: __expectString(output.LightChallengeType),
470
+ OvalScaleFactors: output.OvalScaleFactors != null
471
+ ? deserializeAws_restJson1OvalScaleFactors(output.OvalScaleFactors, context)
472
+ : undefined,
473
+ };
474
+ };
475
+ const deserializeAws_restJson1FreshnessColor = (output, context) => {
476
+ return {
477
+ RGB: output.RGB != null ? deserializeAws_restJson1ColorComponentList(output.RGB, context) : undefined,
478
+ };
479
+ };
480
+ const deserializeAws_restJson1OvalScaleFactors = (output, context) => {
481
+ return {
482
+ CenterX: __limitedParseFloat32(output.CenterX),
483
+ CenterY: __limitedParseFloat32(output.CenterY),
484
+ Width: __limitedParseFloat32(output.Width),
485
+ };
486
+ };
487
+ const deserializeAws_restJson1ServerChallenge = (output, context) => {
488
+ if (output.FaceMovementAndLightChallenge != null) {
489
+ return {
490
+ FaceMovementAndLightChallenge: deserializeAws_restJson1FaceMovementAndLightServerChallenge(output.FaceMovementAndLightChallenge, context),
491
+ };
492
+ }
493
+ return { $unknown: Object.entries(output)[0] };
494
+ };
495
+ const deserializeAws_restJson1ServerSessionInformationEvent = (output, context) => {
496
+ return {
497
+ SessionInformation: output.SessionInformation != null
498
+ ? deserializeAws_restJson1SessionInformation(output.SessionInformation, context)
499
+ : undefined,
500
+ };
501
+ };
502
+ const deserializeAws_restJson1SessionInformation = (output, context) => {
503
+ return {
504
+ Challenge: output.Challenge != null
505
+ ? deserializeAws_restJson1ServerChallenge(__expectUnion(output.Challenge), context)
506
+ : undefined,
507
+ };
508
+ };
509
+ const deserializeMetadata = (output) => ({
510
+ httpStatusCode: output.statusCode,
511
+ requestId: output.headers["x-amzn-requestid"] ?? output.headers["x-amzn-request-id"] ?? output.headers["x-amz-request-id"],
512
+ extendedRequestId: output.headers["x-amz-id-2"],
513
+ cfId: output.headers["x-amz-cf-id"],
514
+ });
515
+ const collectBody = (streamBody = new Uint8Array(), context) => {
516
+ if (streamBody instanceof Uint8Array) {
517
+ return Promise.resolve(streamBody);
518
+ }
519
+ return context.streamCollector(streamBody) || Promise.resolve(new Uint8Array());
520
+ };
521
+ const collectBodyString = (streamBody, context) => collectBody(streamBody, context).then((body) => context.utf8Encoder(body));
522
+ const isSerializableHeaderValue = (value) => value !== undefined &&
523
+ value !== null &&
524
+ value !== "" &&
525
+ (!Object.getOwnPropertyNames(value).includes("length") || value.length != 0) &&
526
+ (!Object.getOwnPropertyNames(value).includes("size") || value.size != 0);
527
+ const parseBody = (streamBody, context) => collectBodyString(streamBody, context).then((encoded) => {
528
+ if (encoded.length) {
529
+ return JSON.parse(encoded);
530
+ }
531
+ return {};
532
+ });
533
+ const parseErrorBody = async (errorBody, context) => {
534
+ const value = await parseBody(errorBody, context);
535
+ value.message = value.message ?? value.Message;
536
+ return value;
537
+ };
538
+ const loadRestJsonErrorCode = (output, data) => {
539
+ const findKey = (object, key) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase());
540
+ const sanitizeErrorCode = (rawValue) => {
541
+ let cleanValue = rawValue;
542
+ if (typeof cleanValue === "number") {
543
+ cleanValue = cleanValue.toString();
544
+ }
545
+ if (cleanValue.indexOf(",") >= 0) {
546
+ cleanValue = cleanValue.split(",")[0];
547
+ }
548
+ if (cleanValue.indexOf(":") >= 0) {
549
+ cleanValue = cleanValue.split(":")[0];
550
+ }
551
+ if (cleanValue.indexOf("#") >= 0) {
552
+ cleanValue = cleanValue.split("#")[1];
553
+ }
554
+ return cleanValue;
555
+ };
556
+ const headerKey = findKey(output.headers, "x-amzn-errortype");
557
+ if (headerKey !== undefined) {
558
+ return sanitizeErrorCode(output.headers[headerKey]);
559
+ }
560
+ if (data.code !== undefined) {
561
+ return sanitizeErrorCode(data.code);
562
+ }
563
+ if (data["__type"] !== undefined) {
564
+ return sanitizeErrorCode(data["__type"]);
565
+ }
566
+ };
@@ -0,0 +1,39 @@
1
+ import packageInfo from "../package.json";
2
+ import { Sha256 } from "@aws-crypto/sha256-browser";
3
+ import { DEFAULT_USE_DUALSTACK_ENDPOINT, DEFAULT_USE_FIPS_ENDPOINT } from "@aws-sdk/config-resolver";
4
+ import { eventStreamSerdeProvider } from "@aws-sdk/eventstream-serde-browser";
5
+ import { FetchHttpHandler as HttpRequestHandler, streamCollector } from "@aws-sdk/fetch-http-handler";
6
+ import { invalidProvider } from "@aws-sdk/invalid-dependency";
7
+ import { WebSocketFetchHandler as WebSocketRequestHandler, eventStreamPayloadHandlerProvider, } from "@aws-sdk/middleware-websocket";
8
+ import { calculateBodyLength } from "@aws-sdk/util-body-length-browser";
9
+ import { DEFAULT_MAX_ATTEMPTS, DEFAULT_RETRY_MODE } from "@aws-sdk/util-retry";
10
+ import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser";
11
+ import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared";
12
+ import { loadConfigsForDefaultMode } from "@aws-sdk/smithy-client";
13
+ import { resolveDefaultsModeConfig } from "@aws-sdk/util-defaults-mode-browser";
14
+ export const getRuntimeConfig = (config) => {
15
+ const defaultsMode = resolveDefaultsModeConfig(config);
16
+ const defaultConfigProvider = () => defaultsMode().then(loadConfigsForDefaultMode);
17
+ const clientSharedValues = getSharedRuntimeConfig(config);
18
+ return {
19
+ ...clientSharedValues,
20
+ ...config,
21
+ runtime: "browser",
22
+ defaultsMode,
23
+ bodyLengthChecker: config?.bodyLengthChecker ?? calculateBodyLength,
24
+ credentialDefaultProvider: config?.credentialDefaultProvider ?? ((_) => () => Promise.reject(new Error("Credential is missing"))),
25
+ defaultUserAgentProvider: config?.defaultUserAgentProvider ??
26
+ defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }),
27
+ eventStreamPayloadHandlerProvider: config?.eventStreamPayloadHandlerProvider ?? eventStreamPayloadHandlerProvider,
28
+ eventStreamSerdeProvider: config?.eventStreamSerdeProvider ?? eventStreamSerdeProvider,
29
+ maxAttempts: config?.maxAttempts ?? DEFAULT_MAX_ATTEMPTS,
30
+ region: config?.region ?? invalidProvider("Region is missing"),
31
+ requestHandler: config?.requestHandler ??
32
+ new WebSocketRequestHandler(defaultConfigProvider, new HttpRequestHandler(defaultConfigProvider)),
33
+ retryMode: config?.retryMode ?? (async () => (await defaultConfigProvider()).retryMode || DEFAULT_RETRY_MODE),
34
+ sha256: config?.sha256 ?? Sha256,
35
+ streamCollector: config?.streamCollector ?? streamCollector,
36
+ useDualstackEndpoint: config?.useDualstackEndpoint ?? (() => Promise.resolve(DEFAULT_USE_DUALSTACK_ENDPOINT)),
37
+ useFipsEndpoint: config?.useFipsEndpoint ?? (() => Promise.resolve(DEFAULT_USE_FIPS_ENDPOINT)),
38
+ };
39
+ };
@@ -0,0 +1,47 @@
1
+ import packageInfo from "../package.json";
2
+ import { decorateDefaultCredentialProvider } from "@aws-sdk/client-sts";
3
+ import { NODE_REGION_CONFIG_FILE_OPTIONS, NODE_REGION_CONFIG_OPTIONS, NODE_USE_DUALSTACK_ENDPOINT_CONFIG_OPTIONS, NODE_USE_FIPS_ENDPOINT_CONFIG_OPTIONS, } from "@aws-sdk/config-resolver";
4
+ import { defaultProvider as credentialDefaultProvider } from "@aws-sdk/credential-provider-node";
5
+ import { eventStreamPayloadHandlerProvider } from "@aws-sdk/eventstream-handler-node";
6
+ import { eventStreamSerdeProvider } from "@aws-sdk/eventstream-serde-node";
7
+ import { Hash } from "@aws-sdk/hash-node";
8
+ import { NODE_MAX_ATTEMPT_CONFIG_OPTIONS, NODE_RETRY_MODE_CONFIG_OPTIONS } from "@aws-sdk/middleware-retry";
9
+ import { loadConfig as loadNodeConfig } from "@aws-sdk/node-config-provider";
10
+ import { NodeHttpHandler as RequestHandler, streamCollector } from "@aws-sdk/node-http-handler";
11
+ import { calculateBodyLength } from "@aws-sdk/util-body-length-node";
12
+ import { DEFAULT_RETRY_MODE } from "@aws-sdk/util-retry";
13
+ import { defaultUserAgent } from "@aws-sdk/util-user-agent-node";
14
+ import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared";
15
+ import { loadConfigsForDefaultMode } from "@aws-sdk/smithy-client";
16
+ import { resolveDefaultsModeConfig } from "@aws-sdk/util-defaults-mode-node";
17
+ import { emitWarningIfUnsupportedVersion } from "@aws-sdk/smithy-client";
18
+ export const getRuntimeConfig = (config) => {
19
+ emitWarningIfUnsupportedVersion(process.version);
20
+ const defaultsMode = resolveDefaultsModeConfig(config);
21
+ const defaultConfigProvider = () => defaultsMode().then(loadConfigsForDefaultMode);
22
+ const clientSharedValues = getSharedRuntimeConfig(config);
23
+ return {
24
+ ...clientSharedValues,
25
+ ...config,
26
+ runtime: "node",
27
+ defaultsMode,
28
+ bodyLengthChecker: config?.bodyLengthChecker ?? calculateBodyLength,
29
+ credentialDefaultProvider: config?.credentialDefaultProvider ?? decorateDefaultCredentialProvider(credentialDefaultProvider),
30
+ defaultUserAgentProvider: config?.defaultUserAgentProvider ??
31
+ defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }),
32
+ eventStreamPayloadHandlerProvider: config?.eventStreamPayloadHandlerProvider ?? eventStreamPayloadHandlerProvider,
33
+ eventStreamSerdeProvider: config?.eventStreamSerdeProvider ?? eventStreamSerdeProvider,
34
+ maxAttempts: config?.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS),
35
+ region: config?.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS),
36
+ requestHandler: config?.requestHandler ?? new RequestHandler(defaultConfigProvider),
37
+ retryMode: config?.retryMode ??
38
+ loadNodeConfig({
39
+ ...NODE_RETRY_MODE_CONFIG_OPTIONS,
40
+ default: async () => (await defaultConfigProvider()).retryMode || DEFAULT_RETRY_MODE,
41
+ }),
42
+ sha256: config?.sha256 ?? Hash.bind(null, "sha256"),
43
+ streamCollector: config?.streamCollector ?? streamCollector,
44
+ useDualstackEndpoint: config?.useDualstackEndpoint ?? loadNodeConfig(NODE_USE_DUALSTACK_ENDPOINT_CONFIG_OPTIONS),
45
+ useFipsEndpoint: config?.useFipsEndpoint ?? loadNodeConfig(NODE_USE_FIPS_ENDPOINT_CONFIG_OPTIONS),
46
+ };
47
+ };
@@ -0,0 +1,14 @@
1
+ import { Sha256 } from "@aws-crypto/sha256-js";
2
+ import { invalidFunction } from "@aws-sdk/invalid-dependency";
3
+ import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser";
4
+ export const getRuntimeConfig = (config) => {
5
+ const browserDefaults = getBrowserRuntimeConfig(config);
6
+ return {
7
+ ...browserDefaults,
8
+ ...config,
9
+ runtime: "react-native",
10
+ eventStreamPayloadHandlerProvider: config?.eventStreamPayloadHandlerProvider ??
11
+ (() => ({ handle: invalidFunction("event stream request is not supported in ReactNative.") })),
12
+ sha256: config?.sha256 ?? Sha256,
13
+ };
14
+ };