santoid-sdk 7.0.0 → 9.0.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 (60) hide show
  1. package/CHANGELOG.md +25 -4
  2. package/README.md +123 -237
  3. package/api/AbstractService.js +9 -3
  4. package/api/ApiLivenessSessionService.d.ts +14 -1
  5. package/api/ApiLivenessSessionService.js +20 -11
  6. package/browser/index.js +1 -1
  7. package/browser/liveness-capture.js +2 -0
  8. package/browser/liveness-capture.js.LICENSE.txt +350 -0
  9. package/client/age/index.d.ts +18 -0
  10. package/client/age/index.js +40 -0
  11. package/client/index.d.ts +4 -2
  12. package/client/index.js +4 -2
  13. package/client/liveness/index.d.ts +2 -2
  14. package/client/liveness/index.js +3 -3
  15. package/client/liveness/methods/livenessSession/Service.d.ts +10 -3
  16. package/client/liveness/methods/livenessSession/Service.js +14 -6
  17. package/client/liveness/methods/livenessSession/index.d.ts +13 -9
  18. package/client/liveness/methods/livenessSession/index.js +12 -9
  19. package/client/liveness/methods/livenessSession/isLivenessApproved.d.ts +6 -0
  20. package/client/liveness/methods/livenessSession/isLivenessApproved.js +13 -0
  21. package/client/liveness/methods/uploadIdentificationDocument/Service.d.ts +8 -29
  22. package/client/liveness/methods/uploadIdentificationDocument/Service.js +25 -66
  23. package/client/liveness/methods/uploadIdentificationDocument/index.d.ts +4 -18
  24. package/client/liveness/methods/uploadIdentificationDocument/index.js +4 -8
  25. package/client/liveness-capture/LivenessCapture.d.ts +13 -0
  26. package/client/liveness-capture/LivenessCapture.js +23 -0
  27. package/client/liveness-capture/displayText.d.ts +54 -0
  28. package/client/liveness-capture/displayText.js +57 -0
  29. package/client/liveness-capture/index.d.ts +36 -0
  30. package/client/liveness-capture/index.js +2 -0
  31. package/client/liveness-capture/index.js.LICENSE.txt +350 -0
  32. package/package.json +11 -4
  33. package/server/index.d.ts +0 -2
  34. package/server/index.js +0 -2
  35. package/server/liveness/index.d.ts +1 -2
  36. package/server/liveness/index.js +1 -3
  37. package/server/liveness/methods/uploadIdentificationDocument/Service.d.ts +3 -3
  38. package/server/liveness/methods/uploadIdentificationDocument/Service.js +2 -2
  39. package/server/liveness/methods/uploadIdentificationDocument/index.d.ts +7 -21
  40. package/server/liveness/methods/uploadIdentificationDocument/index.js +4 -10
  41. package/tsconfig.json +3 -0
  42. package/tsconfig.prod.json +3 -0
  43. package/utils/constants.d.ts +1 -2
  44. package/utils/constants.js +4 -3
  45. package/utils/error.d.ts +6 -5
  46. package/utils/error.js +7 -6
  47. package/utils/index.d.ts +2 -0
  48. package/utils/index.js +12 -1
  49. package/utils/types.d.ts +8 -39
  50. package/webpack.config.cjs +45 -2
  51. package/client/liveness/methods/livenessDetection/Service.d.ts +0 -28
  52. package/client/liveness/methods/livenessDetection/Service.js +0 -138
  53. package/client/liveness/methods/livenessDetection/index.d.ts +0 -23
  54. package/client/liveness/methods/livenessDetection/index.js +0 -58
  55. package/server/liveness/methods/livenessDetection/Service.d.ts +0 -6
  56. package/server/liveness/methods/livenessDetection/Service.js +0 -20
  57. package/server/liveness/methods/livenessDetection/index.d.ts +0 -13
  58. package/server/liveness/methods/livenessDetection/index.js +0 -50
  59. package/utils/websocket.d.ts +0 -18
  60. package/utils/websocket.js +0 -62
@@ -0,0 +1,350 @@
1
+ /*!
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2016 Christian Speckner <cnspeckn@googlemail.com>
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in
14
+ * all copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+ * THE SOFTWARE.
23
+ */
24
+
25
+ /*! *****************************************************************************
26
+ Copyright (c) Microsoft Corporation.
27
+
28
+ Permission to use, copy, modify, and/or distribute this software for any
29
+ purpose with or without fee is hereby granted.
30
+
31
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
32
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
33
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
34
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
35
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
36
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
37
+ PERFORMANCE OF THIS SOFTWARE.
38
+ ***************************************************************************** */
39
+
40
+ /*! crc32.js (C) 2014-present SheetJS -- http://sheetjs.com */
41
+
42
+ /**
43
+ * @license
44
+ * Copyright 2017 Google LLC. All Rights Reserved.
45
+ * Licensed under the Apache License, Version 2.0 (the "License");
46
+ * you may not use this file except in compliance with the License.
47
+ * You may obtain a copy of the License at
48
+ *
49
+ * http://www.apache.org/licenses/LICENSE-2.0
50
+ *
51
+ * Unless required by applicable law or agreed to in writing, software
52
+ * distributed under the License is distributed on an "AS IS" BASIS,
53
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
54
+ * See the License for the specific language governing permissions and
55
+ * limitations under the License.
56
+ * =============================================================================
57
+ */
58
+
59
+ /**
60
+ * @license
61
+ * Copyright 2018 Google LLC. All Rights Reserved.
62
+ * Licensed under the Apache License, Version 2.0 (the "License");
63
+ * you may not use this file except in compliance with the License.
64
+ * You may obtain a copy of the License at
65
+ *
66
+ * http://www.apache.org/licenses/LICENSE-2.0
67
+ *
68
+ * Unless required by applicable law or agreed to in writing, software
69
+ * distributed under the License is distributed on an "AS IS" BASIS,
70
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
71
+ * See the License for the specific language governing permissions and
72
+ * limitations under the License.
73
+ * =============================================================================
74
+ */
75
+
76
+ /**
77
+ * @license
78
+ * Copyright 2019 Google LLC. All Rights Reserved.
79
+ * Licensed under the Apache License, Version 2.0 (the "License");
80
+ * you may not use this file except in compliance with the License.
81
+ * You may obtain a copy of the License at
82
+ *
83
+ * http://www.apache.org/licenses/LICENSE-2.0
84
+ *
85
+ * Unless required by applicable law or agreed to in writing, software
86
+ * distributed under the License is distributed on an "AS IS" BASIS,
87
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
88
+ * See the License for the specific language governing permissions and
89
+ * limitations under the License.
90
+ * =============================================================================
91
+ */
92
+
93
+ /**
94
+ * @license
95
+ * Copyright 2019 Google LLC. All Rights Reserved.
96
+ * Licensed under the Apache License, Version 2.0 (the 'License');
97
+ * you may not use this file except in compliance with the License.
98
+ * You may obtain a copy of the License at
99
+ *
100
+ * http://www.apache.org/licenses/LICENSE-2.0
101
+ *
102
+ * Unless required by applicable law or agreed to in writing, software
103
+ * distributed under the License is distributed on an 'AS IS' BASIS,
104
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
105
+ * See the License for the specific language governing permissions and
106
+ * limitations under the License.
107
+ * =============================================================================
108
+ */
109
+
110
+ /**
111
+ * @license
112
+ * Copyright 2020 Google Inc. All Rights Reserved.
113
+ * Licensed under the Apache License, Version 2.0 (the "License");
114
+ * you may not use this file except in compliance with the License.
115
+ * You may obtain a copy of the License at
116
+ *
117
+ * http://www.apache.org/licenses/LICENSE-2.0
118
+ *
119
+ * Unless required by applicable law or agreed to in writing, software
120
+ * distributed under the License is distributed on an "AS IS" BASIS,
121
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
122
+ * See the License for the specific language governing permissions and
123
+ * limitations under the License.
124
+ * =============================================================================
125
+ */
126
+
127
+ /**
128
+ * @license
129
+ * Copyright 2020 Google LLC. All Rights Reserved.
130
+ * Licensed under the Apache License, Version 2.0 (the "License");
131
+ * you may not use this file except in compliance with the License.
132
+ * You may obtain a copy of the License at
133
+ *
134
+ * http://www.apache.org/licenses/LICENSE-2.0
135
+ *
136
+ * Unless required by applicable law or agreed to in writing, software
137
+ * distributed under the License is distributed on an "AS IS" BASIS,
138
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
139
+ * See the License for the specific language governing permissions and
140
+ * limitations under the License.
141
+ * =============================================================================
142
+ */
143
+
144
+ /**
145
+ * @license
146
+ * Copyright 2020 Google LLC. All Rights Reserved.
147
+ * Licensed under the Apache License, Version 2.0 (the License);
148
+ * you may not use this file except in compliance with the License.
149
+ * You may obtain a copy of the License at
150
+ *
151
+ * http://www.apache.org/licenses/LICENSE-2.0
152
+ *
153
+ * Unless required by applicable law or agreed to in writing, software
154
+ * distributed under the License is distributed on an AS IS BASIS,
155
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
156
+ * See the License for the specific language governing permissions and
157
+ * limitations under the License.
158
+ * =============================================================================
159
+ */
160
+
161
+ /**
162
+ * @license
163
+ * Copyright 2021 Google LLC. All Rights Reserved.
164
+ * Licensed under the Apache License, Version 2.0 (the "License");
165
+ * you may not use this file except in compliance with the License.
166
+ * You may obtain a copy of the License at
167
+ *
168
+ * http://www.apache.org/licenses/LICENSE-2.0
169
+ *
170
+ * Unless required by applicable law or agreed to in writing, software
171
+ * distributed under the License is distributed on an "AS IS" BASIS,
172
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
173
+ * See the License for the specific language governing permissions and
174
+ * limitations under the License.
175
+ * =============================================================================
176
+ */
177
+
178
+ /**
179
+ * @license
180
+ * Copyright 2021 Google LLC. All Rights Reserved.
181
+ * Licensed under the Apache License, Version 2.0 (the "License");
182
+ * you may not use this file except in compliance with the License.
183
+ * You may obtain a copy of the License at
184
+ *
185
+ * https://www.apache.org/licenses/LICENSE-2.0
186
+ *
187
+ * Unless required by applicable law or agreed to in writing, software
188
+ * distributed under the License is distributed on an "AS IS" BASIS,
189
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
190
+ * See the License for the specific language governing permissions and
191
+ * limitations under the License.
192
+ * =============================================================================
193
+ */
194
+
195
+ /**
196
+ * @license
197
+ * Copyright 2022 Google LLC.
198
+ * Licensed under the Apache License, Version 2.0 (the "License");
199
+ * you may not use this file except in compliance with the License.
200
+ * You may obtain a copy of the License at
201
+ *
202
+ * http://www.apache.org/licenses/LICENSE-2.0
203
+ *
204
+ * Unless required by applicable law or agreed to in writing, software
205
+ * distributed under the License is distributed on an "AS IS" BASIS,
206
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
207
+ * See the License for the specific language governing permissions and
208
+ * limitations under the License.
209
+ * =============================================================================
210
+ */
211
+
212
+ /**
213
+ * @license
214
+ * Copyright 2022 Google LLC. All Rights Reserved.
215
+ * Licensed under the Apache License, Version 2.0 (the "License");
216
+ * you may not use this file except in compliance with the License.
217
+ * You may obtain a copy of the License at
218
+ *
219
+ * http://www.apache.org/licenses/LICENSE-2.0
220
+ *
221
+ * Unless required by applicable law or agreed to in writing, software
222
+ * distributed under the License is distributed on an "AS IS" BASIS,
223
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
224
+ * See the License for the specific language governing permissions and
225
+ * limitations under the License.
226
+ * =============================================================================
227
+ */
228
+
229
+ /**
230
+ * @license
231
+ * Copyright 2022 Google LLC. All Rights Reserved.
232
+ * Licensed under the Apache License, Version 2.0 (the 'License');
233
+ * you may not use this file except in compliance with the License.
234
+ * You may obtain a copy of the License at
235
+ *
236
+ * http://www.apache.org/licenses/LICENSE-2.0
237
+ *
238
+ * Unless required by applicable law or agreed to in writing, software
239
+ * distributed under the License is distributed on an 'AS IS' BASIS,
240
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
241
+ * See the License for the specific language governing permissions and
242
+ * limitations under the License.
243
+ * =============================================================================
244
+ */
245
+
246
+ /**
247
+ * @license
248
+ * Copyright 2023 Google LLC.
249
+ * Licensed under the Apache License, Version 2.0 (the "License");
250
+ * you may not use this file except in compliance with the License.
251
+ * You may obtain a copy of the License at
252
+ *
253
+ * http://www.apache.org/licenses/LICENSE-2.0
254
+ *
255
+ * Unless required by applicable law or agreed to in writing, software
256
+ * distributed under the License is distributed on an "AS IS" BASIS,
257
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
258
+ * See the License for the specific language governing permissions and
259
+ * limitations under the License.
260
+ * =============================================================================
261
+ */
262
+
263
+ /**
264
+ * @license
265
+ * Copyright 2023 Google LLC. All Rights Reserved.
266
+ * Licensed under the Apache License, Version 2.0 (the "License");
267
+ * you may not use this file except in compliance with the License.
268
+ * You may obtain a copy of the License at
269
+ *
270
+ * http://www.apache.org/licenses/LICENSE-2.0
271
+ *
272
+ * Unless required by applicable law or agreed to in writing, software
273
+ * distributed under the License is distributed on an "AS IS" BASIS,
274
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
275
+ * See the License for the specific language governing permissions and
276
+ * limitations under the License.
277
+ * =============================================================================
278
+ */
279
+
280
+ /**
281
+ * @license React
282
+ * react-dom-client.production.js
283
+ *
284
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
285
+ *
286
+ * This source code is licensed under the MIT license found in the
287
+ * LICENSE file in the root directory of this source tree.
288
+ */
289
+
290
+ /**
291
+ * @license React
292
+ * react-dom.production.js
293
+ *
294
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
295
+ *
296
+ * This source code is licensed under the MIT license found in the
297
+ * LICENSE file in the root directory of this source tree.
298
+ */
299
+
300
+ /**
301
+ * @license React
302
+ * react-jsx-runtime.production.js
303
+ *
304
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
305
+ *
306
+ * This source code is licensed under the MIT license found in the
307
+ * LICENSE file in the root directory of this source tree.
308
+ */
309
+
310
+ /**
311
+ * @license React
312
+ * react.production.js
313
+ *
314
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
315
+ *
316
+ * This source code is licensed under the MIT license found in the
317
+ * LICENSE file in the root directory of this source tree.
318
+ */
319
+
320
+ /**
321
+ * @license React
322
+ * scheduler.production.js
323
+ *
324
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
325
+ *
326
+ * This source code is licensed under the MIT license found in the
327
+ * LICENSE file in the root directory of this source tree.
328
+ */
329
+
330
+ /**
331
+ * @license React
332
+ * use-sync-external-store-shim.production.js
333
+ *
334
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
335
+ *
336
+ * This source code is licensed under the MIT license found in the
337
+ * LICENSE file in the root directory of this source tree.
338
+ */
339
+
340
+ /**
341
+ * @license React
342
+ * use-sync-external-store-shim/with-selector.production.js
343
+ *
344
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
345
+ *
346
+ * This source code is licensed under the MIT license found in the
347
+ * LICENSE file in the root directory of this source tree.
348
+ */
349
+
350
+ /** @license See the LICENSE file. */
@@ -0,0 +1,18 @@
1
+ import { type IBaseSDKOptions } from '../../utils/types';
2
+ export type { IAgeEstimate, IAgeRange } from '../../api/ApiLivenessSessionService';
3
+ export type TEstimateAgeOptions = Omit<IBaseSDKOptions, 'track' | 'token'> & {
4
+ /** Token do usuario. Opcional quando apiKey for informada. */
5
+ token?: string;
6
+ track?: string;
7
+ customerRequestId?: string;
8
+ /** Sessao de prova de vida concluida e aprovada. */
9
+ sessionId: string;
10
+ };
11
+ /**
12
+ * Estima a idade a partir da foto de uma prova de vida aprovada.
13
+ *
14
+ * Nao ha upload: a idade sai da foto capturada na propria sessao, entao quem
15
+ * responde e' a pessoa que passou pela camera. Sessao nao concluida responde
16
+ * 409; reprovada ou sem um unico rosto, 422.
17
+ */
18
+ export declare function estimateAge({ sessionId, customerRequestId, ...options }: TEstimateAgeOptions): Promise<import("../../api/ApiLivenessSessionService").IAgeEstimate>;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.estimateAge = void 0;
15
+ const ApiLivenessSessionService_1 = require("../../api/ApiLivenessSessionService");
16
+ const error_1 = require("../../utils/error");
17
+ const index_1 = require("../liveness/utils/index");
18
+ /**
19
+ * Estima a idade a partir da foto de uma prova de vida aprovada.
20
+ *
21
+ * Nao ha upload: a idade sai da foto capturada na propria sessao, entao quem
22
+ * responde e' a pessoa que passou pela camera. Sessao nao concluida responde
23
+ * 409; reprovada ou sem um unico rosto, 422.
24
+ */
25
+ async function estimateAge(_a) {
26
+ var { sessionId, customerRequestId } = _a, options = __rest(_a, ["sessionId", "customerRequestId"]);
27
+ try {
28
+ const service = new ApiLivenessSessionService_1.ApiLivenessSessionService(options, { FormDataClass: FormData, tryDecodeJwt: index_1.tryDecodeJwt });
29
+ return await service.estimateAge(sessionId, customerRequestId);
30
+ }
31
+ catch (err) {
32
+ throw new error_1.SDKError({
33
+ message: 'Error while estimating age',
34
+ code: error_1.EDefaultErrorCodes.INTERNAL_ERROR,
35
+ fatal: false,
36
+ details: err,
37
+ });
38
+ }
39
+ }
40
+ exports.estimateAge = estimateAge;
package/client/index.d.ts CHANGED
@@ -1,13 +1,15 @@
1
- import { livenessDetection } from './liveness/methods/livenessDetection';
2
1
  import { livenessSession } from './liveness/methods/livenessSession';
2
+ import { isLivenessApproved } from './liveness/methods/livenessSession/isLivenessApproved';
3
+ import { estimateAge } from './age';
3
4
  import { uploadIdentificationDocument } from './liveness/methods/uploadIdentificationDocument';
4
5
  import { insertUploadIdentificationDocument } from './embedded/methods/insertUploadIdentificationDocument';
5
6
  import { typification } from './core/methods/typification';
6
7
  import { faceMatch } from './core/methods/faceMatch';
7
8
  import { ocr } from './core/methods/ocr';
8
9
  export default class SantoiDSDK {
9
- static readonly livenessDetection: typeof livenessDetection;
10
10
  static readonly livenessSession: typeof livenessSession;
11
+ static readonly isLivenessApproved: typeof isLivenessApproved;
12
+ static readonly estimateAge: typeof estimateAge;
11
13
  static readonly uploadIdentificationDocument: typeof uploadIdentificationDocument;
12
14
  static readonly insertUploadIdentificationDocument: typeof insertUploadIdentificationDocument;
13
15
  static readonly typification: typeof typification;
package/client/index.js CHANGED
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const livenessDetection_1 = require("./liveness/methods/livenessDetection");
4
3
  const livenessSession_1 = require("./liveness/methods/livenessSession");
4
+ const isLivenessApproved_1 = require("./liveness/methods/livenessSession/isLivenessApproved");
5
+ const age_1 = require("./age");
5
6
  const uploadIdentificationDocument_1 = require("./liveness/methods/uploadIdentificationDocument");
6
7
  const insertUploadIdentificationDocument_1 = require("./embedded/methods/insertUploadIdentificationDocument");
7
8
  const typification_1 = require("./core/methods/typification");
@@ -9,8 +10,9 @@ const faceMatch_1 = require("./core/methods/faceMatch");
9
10
  const ocr_1 = require("./core/methods/ocr");
10
11
  class SantoiDSDK {
11
12
  }
12
- SantoiDSDK.livenessDetection = livenessDetection_1.livenessDetection;
13
13
  SantoiDSDK.livenessSession = livenessSession_1.livenessSession;
14
+ SantoiDSDK.isLivenessApproved = isLivenessApproved_1.isLivenessApproved;
15
+ SantoiDSDK.estimateAge = age_1.estimateAge;
14
16
  SantoiDSDK.uploadIdentificationDocument = uploadIdentificationDocument_1.uploadIdentificationDocument;
15
17
  SantoiDSDK.insertUploadIdentificationDocument = insertUploadIdentificationDocument_1.insertUploadIdentificationDocument;
16
18
  SantoiDSDK.typification = typification_1.typification;
@@ -1,4 +1,4 @@
1
- import { livenessDetection } from './methods/livenessDetection';
2
1
  import { livenessSession } from './methods/livenessSession';
2
+ import { isLivenessApproved } from './methods/livenessSession/isLivenessApproved';
3
3
  import { uploadIdentificationDocument } from './methods/uploadIdentificationDocument';
4
- export { livenessDetection, livenessSession, uploadIdentificationDocument, };
4
+ export { livenessSession, isLivenessApproved, uploadIdentificationDocument, };
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.uploadIdentificationDocument = exports.livenessSession = exports.livenessDetection = void 0;
4
- const livenessDetection_1 = require("./methods/livenessDetection");
5
- Object.defineProperty(exports, "livenessDetection", { enumerable: true, get: function () { return livenessDetection_1.livenessDetection; } });
3
+ exports.uploadIdentificationDocument = exports.isLivenessApproved = exports.livenessSession = void 0;
6
4
  const livenessSession_1 = require("./methods/livenessSession");
7
5
  Object.defineProperty(exports, "livenessSession", { enumerable: true, get: function () { return livenessSession_1.livenessSession; } });
6
+ const isLivenessApproved_1 = require("./methods/livenessSession/isLivenessApproved");
7
+ Object.defineProperty(exports, "isLivenessApproved", { enumerable: true, get: function () { return isLivenessApproved_1.isLivenessApproved; } });
8
8
  const uploadIdentificationDocument_1 = require("./methods/uploadIdentificationDocument");
9
9
  Object.defineProperty(exports, "uploadIdentificationDocument", { enumerable: true, get: function () { return uploadIdentificationDocument_1.uploadIdentificationDocument; } });
@@ -1,7 +1,9 @@
1
- import { ApiLivenessSessionService, type ILivenessSessionResult } from '../../../../api/ApiLivenessSessionService';
1
+ import { ApiLivenessSessionService, type ILivenessSession, type ILivenessSessionResult } from '../../../../api/ApiLivenessSessionService';
2
2
  import { type IBaseSDKOptions } from '../../../../utils/types';
3
3
  import { SDKError } from '../../../../utils/error';
4
- export type TLivenessSessionOptions = Omit<IBaseSDKOptions, 'track'> & {
4
+ export type TLivenessSessionOptions = Omit<IBaseSDKOptions, 'track' | 'token'> & {
5
+ /** Token do usuario. Opcional quando apiKey for informada. */
6
+ token?: string;
5
7
  track?: string;
6
8
  customerRequestId?: string;
7
9
  onSessionCreated?: (sessionId: string) => void | Promise<void>;
@@ -11,9 +13,14 @@ export type TLivenessSessionOptions = Omit<IBaseSDKOptions, 'track'> & {
11
13
  export declare class LivenessSessionService {
12
14
  options: TLivenessSessionOptions;
13
15
  service: ApiLivenessSessionService;
14
- sessionId: string | null;
16
+ session: ILivenessSession | null;
17
+ get sessionId(): string | null;
15
18
  constructor(options: TLivenessSessionOptions);
16
19
  createSession(): Promise<string>;
17
20
  getResults(sessionId?: string | null): Promise<ILivenessSessionResult>;
21
+ getSessionConfig(): {
22
+ region: string;
23
+ identityPoolId: string;
24
+ } | null;
18
25
  private fail;
19
26
  }
@@ -7,8 +7,12 @@ const utils_1 = require("../../../../utils");
7
7
  const constants_1 = require("../../../../utils/constants");
8
8
  const index_1 = require("../../utils/index");
9
9
  class LivenessSessionService {
10
+ get sessionId() {
11
+ var _a, _b;
12
+ return (_b = (_a = this.session) === null || _a === void 0 ? void 0 : _a.SessionId) !== null && _b !== void 0 ? _b : null;
13
+ }
10
14
  constructor(options) {
11
- this.sessionId = null;
15
+ this.session = null;
12
16
  this.options = options;
13
17
  this.service = new ApiLivenessSessionService_1.ApiLivenessSessionService(options, { FormDataClass: FormData, tryDecodeJwt: index_1.tryDecodeJwt });
14
18
  }
@@ -16,7 +20,7 @@ class LivenessSessionService {
16
20
  var _a, _b;
17
21
  try {
18
22
  const session = await this.service.createSession(this.options.customerRequestId);
19
- this.sessionId = session.SessionId;
23
+ this.session = session;
20
24
  await ((_b = (_a = this.options).onSessionCreated) === null || _b === void 0 ? void 0 : _b.call(_a, session.SessionId));
21
25
  return session.SessionId;
22
26
  }
@@ -24,10 +28,9 @@ class LivenessSessionService {
24
28
  throw await this.fail('Error while creating liveness session', err);
25
29
  }
26
30
  }
27
- // A AWS avisa que terminou de transmitir os frames antes do Rekognition
28
- // terminar de avaliar, entao o resultado fica CREATED/IN_PROGRESS por alguns
29
- // instantes. Sem este polling o chamador recebe um status que ainda nao e'
30
- // o final.
31
+ // A captura termina antes da analise, entao o resultado fica
32
+ // CREATED/IN_PROGRESS por alguns instantes. Sem este polling o chamador
33
+ // recebe um status que ainda nao e' o final.
31
34
  async getResults(sessionId = this.sessionId) {
32
35
  var _a, _b;
33
36
  if (!sessionId) {
@@ -48,6 +51,11 @@ class LivenessSessionService {
48
51
  throw await this.fail('Error while fetching liveness session results', err);
49
52
  }
50
53
  }
54
+ getSessionConfig() {
55
+ if (!this.session)
56
+ return null;
57
+ return { region: this.session.Region, identityPoolId: this.session.IdentityPoolId };
58
+ }
51
59
  async fail(message, cause) {
52
60
  var _a, _b;
53
61
  const error = new error_1.SDKError({
@@ -1,20 +1,24 @@
1
1
  import { type TLivenessSessionOptions } from './Service';
2
2
  export type { TLivenessSessionOptions };
3
3
  /**
4
- * Prova de vida v2, sobre o AWS Rekognition Face Liveness.
4
+ * Prova de vida: ciclo da sessao.
5
5
  *
6
- * Cobre o ciclo de sessao: cria a sessao e busca o resultado, com o polling
7
- * necessario enquanto o Rekognition ainda avalia. A captura em si - camera,
8
- * oval e desafio - fica a cargo do <FaceLivenessDetector> da AWS, que e' um
9
- * componente React e por isso nao mora neste pacote.
6
+ * Cria a sessao e busca o resultado, com o polling necessario enquanto a
7
+ * analise termina. Para a captura pela camera, use `mountLiveness`, em
8
+ * `santoid-sdk/client/liveness-capture`, que ja faz este ciclo por dentro.
10
9
  *
11
- * Fluxo esperado:
12
- * 1. createSession() -> entrega o sessionId para o detector
13
- * 2. o detector transmite os frames direto para a AWS
14
- * 3. getResults() quando o detector sinalizar que terminou
10
+ * Fluxo:
11
+ * 1. createSession() -> sessionId
12
+ * 2. captura pela camera com o sessionId (getSessionConfig() traz o que o
13
+ * componente de captura precisa)
14
+ * 3. getResults() quando a captura terminar
15
15
  */
16
16
  export declare function livenessSession(options: TLivenessSessionOptions): {
17
17
  createSession: () => Promise<string>;
18
18
  getResults: (sessionId?: string | null | undefined) => Promise<import("../../../../api/ApiLivenessSessionService").ILivenessSessionResult>;
19
19
  getSessionId: () => string | null;
20
+ getSessionConfig: () => {
21
+ region: string;
22
+ identityPoolId: string;
23
+ } | null;
20
24
  };
@@ -4,17 +4,17 @@ exports.livenessSession = void 0;
4
4
  const Service_1 = require("./Service");
5
5
  const error_1 = require("../../../../utils/error");
6
6
  /**
7
- * Prova de vida v2, sobre o AWS Rekognition Face Liveness.
7
+ * Prova de vida: ciclo da sessao.
8
8
  *
9
- * Cobre o ciclo de sessao: cria a sessao e busca o resultado, com o polling
10
- * necessario enquanto o Rekognition ainda avalia. A captura em si - camera,
11
- * oval e desafio - fica a cargo do <FaceLivenessDetector> da AWS, que e' um
12
- * componente React e por isso nao mora neste pacote.
9
+ * Cria a sessao e busca o resultado, com o polling necessario enquanto a
10
+ * analise termina. Para a captura pela camera, use `mountLiveness`, em
11
+ * `santoid-sdk/client/liveness-capture`, que ja faz este ciclo por dentro.
13
12
  *
14
- * Fluxo esperado:
15
- * 1. createSession() -> entrega o sessionId para o detector
16
- * 2. o detector transmite os frames direto para a AWS
17
- * 3. getResults() quando o detector sinalizar que terminou
13
+ * Fluxo:
14
+ * 1. createSession() -> sessionId
15
+ * 2. captura pela camera com o sessionId (getSessionConfig() traz o que o
16
+ * componente de captura precisa)
17
+ * 3. getResults() quando a captura terminar
18
18
  */
19
19
  function livenessSession(options) {
20
20
  try {
@@ -30,6 +30,9 @@ function livenessSession(options) {
30
30
  getSessionId: () => {
31
31
  return service.sessionId;
32
32
  },
33
+ getSessionConfig: () => {
34
+ return service.getSessionConfig();
35
+ },
33
36
  };
34
37
  }
35
38
  catch (err) {
@@ -0,0 +1,6 @@
1
+ import { type ILivenessSessionResult } from '../../../../api/ApiLivenessSessionService';
2
+ /**
3
+ * `Status: SUCCEEDED` so diz que a sessao terminou; quem aprova e' a
4
+ * confianca. Uma sessao concluida com confianca 0 e' uma reprovacao.
5
+ */
6
+ export declare function isLivenessApproved(result: Pick<ILivenessSessionResult, 'Status' | 'Confidence'> | null | undefined, threshold?: number): boolean;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isLivenessApproved = void 0;
4
+ const constants_1 = require("../../../../utils/constants");
5
+ /**
6
+ * `Status: SUCCEEDED` so diz que a sessao terminou; quem aprova e' a
7
+ * confianca. Uma sessao concluida com confianca 0 e' uma reprovacao.
8
+ */
9
+ function isLivenessApproved(result, threshold = constants_1.LIVENESS_APPROVAL_THRESHOLD) {
10
+ var _a;
11
+ return (result === null || result === void 0 ? void 0 : result.Status) === 'SUCCEEDED' && ((_a = result.Confidence) !== null && _a !== void 0 ? _a : 0) >= threshold;
12
+ }
13
+ exports.isLivenessApproved = isLivenessApproved;