@kwik-id/sdk-react-native 0.0.0-stage → 0.1.0-alpha.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 (269) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +81 -2
  3. package/app.plugin.js +40 -0
  4. package/lib/commonjs/api/api-client.js +213 -0
  5. package/lib/commonjs/api/api-client.js.map +1 -0
  6. package/lib/commonjs/api/api-error.js +29 -0
  7. package/lib/commonjs/api/api-error.js.map +1 -0
  8. package/lib/commonjs/api/index.js +33 -0
  9. package/lib/commonjs/api/index.js.map +1 -0
  10. package/lib/commonjs/api/upload.js +74 -0
  11. package/lib/commonjs/api/upload.js.map +1 -0
  12. package/lib/commonjs/camera/camera-view.js +227 -0
  13. package/lib/commonjs/camera/camera-view.js.map +1 -0
  14. package/lib/commonjs/camera/index.js +20 -0
  15. package/lib/commonjs/camera/index.js.map +1 -0
  16. package/lib/commonjs/camera/photo-capture.js +50 -0
  17. package/lib/commonjs/camera/photo-capture.js.map +1 -0
  18. package/lib/commonjs/crypto/fingerprint.js +43 -0
  19. package/lib/commonjs/crypto/fingerprint.js.map +1 -0
  20. package/lib/commonjs/crypto/hmac.js +150 -0
  21. package/lib/commonjs/crypto/hmac.js.map +1 -0
  22. package/lib/commonjs/crypto/index.js +39 -0
  23. package/lib/commonjs/crypto/index.js.map +1 -0
  24. package/lib/commonjs/crypto/session-manager.js +173 -0
  25. package/lib/commonjs/crypto/session-manager.js.map +1 -0
  26. package/lib/commonjs/i18n/en.js +297 -0
  27. package/lib/commonjs/i18n/en.js.map +1 -0
  28. package/lib/commonjs/i18n/fr.js +294 -0
  29. package/lib/commonjs/i18n/fr.js.map +1 -0
  30. package/lib/commonjs/i18n/index.js +34 -0
  31. package/lib/commonjs/i18n/index.js.map +1 -0
  32. package/lib/commonjs/i18n/locale.js +20 -0
  33. package/lib/commonjs/i18n/locale.js.map +1 -0
  34. package/lib/commonjs/i18n/translator.js +37 -0
  35. package/lib/commonjs/i18n/translator.js.map +1 -0
  36. package/lib/commonjs/index.js +187 -0
  37. package/lib/commonjs/index.js.map +1 -0
  38. package/lib/commonjs/lib/device-detector.js +34 -0
  39. package/lib/commonjs/lib/device-detector.js.map +1 -0
  40. package/lib/commonjs/lib/event-emitter.js +85 -0
  41. package/lib/commonjs/lib/event-emitter.js.map +1 -0
  42. package/lib/commonjs/lib/index.js +63 -0
  43. package/lib/commonjs/lib/index.js.map +1 -0
  44. package/lib/commonjs/lib/kwik-id-rn-sdk.js +156 -0
  45. package/lib/commonjs/lib/kwik-id-rn-sdk.js.map +1 -0
  46. package/lib/commonjs/lib/verification-machine.js +276 -0
  47. package/lib/commonjs/lib/verification-machine.js.map +1 -0
  48. package/lib/commonjs/package.json +1 -0
  49. package/lib/commonjs/types/events.js +6 -0
  50. package/lib/commonjs/types/events.js.map +1 -0
  51. package/lib/commonjs/types/index.js +2 -0
  52. package/lib/commonjs/types/index.js.map +1 -0
  53. package/lib/commonjs/ui/components/KwikIDVerificationModal.js +407 -0
  54. package/lib/commonjs/ui/components/KwikIDVerificationModal.js.map +1 -0
  55. package/lib/commonjs/ui/components/screens.js +338 -0
  56. package/lib/commonjs/ui/components/screens.js.map +1 -0
  57. package/lib/commonjs/ui/context/kwik-id-provider.js +52 -0
  58. package/lib/commonjs/ui/context/kwik-id-provider.js.map +1 -0
  59. package/lib/commonjs/ui/hooks/use-kwik-verification.js +77 -0
  60. package/lib/commonjs/ui/hooks/use-kwik-verification.js.map +1 -0
  61. package/lib/commonjs/ui/index.js +33 -0
  62. package/lib/commonjs/ui/index.js.map +1 -0
  63. package/lib/module/api/api-client.js +208 -0
  64. package/lib/module/api/api-client.js.map +1 -0
  65. package/lib/module/api/api-error.js +24 -0
  66. package/lib/module/api/api-error.js.map +1 -0
  67. package/lib/module/api/index.js +6 -0
  68. package/lib/module/api/index.js.map +1 -0
  69. package/lib/module/api/upload.js +68 -0
  70. package/lib/module/api/upload.js.map +1 -0
  71. package/lib/module/camera/camera-view.js +222 -0
  72. package/lib/module/camera/camera-view.js.map +1 -0
  73. package/lib/module/camera/index.js +5 -0
  74. package/lib/module/camera/index.js.map +1 -0
  75. package/lib/module/camera/photo-capture.js +45 -0
  76. package/lib/module/camera/photo-capture.js.map +1 -0
  77. package/lib/module/crypto/fingerprint.js +37 -0
  78. package/lib/module/crypto/fingerprint.js.map +1 -0
  79. package/lib/module/crypto/hmac.js +143 -0
  80. package/lib/module/crypto/hmac.js.map +1 -0
  81. package/lib/module/crypto/index.js +6 -0
  82. package/lib/module/crypto/index.js.map +1 -0
  83. package/lib/module/crypto/session-manager.js +169 -0
  84. package/lib/module/crypto/session-manager.js.map +1 -0
  85. package/lib/module/i18n/en.js +293 -0
  86. package/lib/module/i18n/en.js.map +1 -0
  87. package/lib/module/i18n/fr.js +290 -0
  88. package/lib/module/i18n/fr.js.map +1 -0
  89. package/lib/module/i18n/index.js +11 -0
  90. package/lib/module/i18n/index.js.map +1 -0
  91. package/lib/module/i18n/locale.js +15 -0
  92. package/lib/module/i18n/locale.js.map +1 -0
  93. package/lib/module/i18n/translator.js +34 -0
  94. package/lib/module/i18n/translator.js.map +1 -0
  95. package/lib/module/index.js +30 -0
  96. package/lib/module/index.js.map +1 -0
  97. package/lib/module/lib/device-detector.js +26 -0
  98. package/lib/module/lib/device-detector.js.map +1 -0
  99. package/lib/module/lib/event-emitter.js +80 -0
  100. package/lib/module/lib/event-emitter.js.map +1 -0
  101. package/lib/module/lib/index.js +6 -0
  102. package/lib/module/lib/index.js.map +1 -0
  103. package/lib/module/lib/kwik-id-rn-sdk.js +150 -0
  104. package/lib/module/lib/kwik-id-rn-sdk.js.map +1 -0
  105. package/lib/module/lib/verification-machine.js +268 -0
  106. package/lib/module/lib/verification-machine.js.map +1 -0
  107. package/lib/module/package.json +1 -0
  108. package/lib/module/types/events.js +4 -0
  109. package/lib/module/types/events.js.map +1 -0
  110. package/lib/module/types/index.js +2 -0
  111. package/lib/module/types/index.js.map +1 -0
  112. package/lib/module/ui/components/KwikIDVerificationModal.js +402 -0
  113. package/lib/module/ui/components/KwikIDVerificationModal.js.map +1 -0
  114. package/lib/module/ui/components/screens.js +328 -0
  115. package/lib/module/ui/components/screens.js.map +1 -0
  116. package/lib/module/ui/context/kwik-id-provider.js +46 -0
  117. package/lib/module/ui/context/kwik-id-provider.js.map +1 -0
  118. package/lib/module/ui/hooks/use-kwik-verification.js +72 -0
  119. package/lib/module/ui/hooks/use-kwik-verification.js.map +1 -0
  120. package/lib/module/ui/index.js +6 -0
  121. package/lib/module/ui/index.js.map +1 -0
  122. package/lib/typescript/commonjs/api/api-client.d.ts +82 -0
  123. package/lib/typescript/commonjs/api/api-client.d.ts.map +1 -0
  124. package/lib/typescript/commonjs/api/api-error.d.ts +13 -0
  125. package/lib/typescript/commonjs/api/api-error.d.ts.map +1 -0
  126. package/lib/typescript/commonjs/api/index.d.ts +6 -0
  127. package/lib/typescript/commonjs/api/index.d.ts.map +1 -0
  128. package/lib/typescript/commonjs/api/upload.d.ts +19 -0
  129. package/lib/typescript/commonjs/api/upload.d.ts.map +1 -0
  130. package/lib/typescript/commonjs/camera/camera-view.d.ts +25 -0
  131. package/lib/typescript/commonjs/camera/camera-view.d.ts.map +1 -0
  132. package/lib/typescript/commonjs/camera/index.d.ts +5 -0
  133. package/lib/typescript/commonjs/camera/index.d.ts.map +1 -0
  134. package/lib/typescript/commonjs/camera/photo-capture.d.ts +9 -0
  135. package/lib/typescript/commonjs/camera/photo-capture.d.ts.map +1 -0
  136. package/lib/typescript/commonjs/crypto/fingerprint.d.ts +3 -0
  137. package/lib/typescript/commonjs/crypto/fingerprint.d.ts.map +1 -0
  138. package/lib/typescript/commonjs/crypto/hmac.d.ts +18 -0
  139. package/lib/typescript/commonjs/crypto/hmac.d.ts.map +1 -0
  140. package/lib/typescript/commonjs/crypto/index.d.ts +4 -0
  141. package/lib/typescript/commonjs/crypto/index.d.ts.map +1 -0
  142. package/lib/typescript/commonjs/crypto/session-manager.d.ts +27 -0
  143. package/lib/typescript/commonjs/crypto/session-manager.d.ts.map +1 -0
  144. package/lib/typescript/commonjs/i18n/en.d.ts +291 -0
  145. package/lib/typescript/commonjs/i18n/en.d.ts.map +1 -0
  146. package/lib/typescript/commonjs/i18n/fr.d.ts +6 -0
  147. package/lib/typescript/commonjs/i18n/fr.d.ts.map +1 -0
  148. package/lib/typescript/commonjs/i18n/index.d.ts +10 -0
  149. package/lib/typescript/commonjs/i18n/index.d.ts.map +1 -0
  150. package/lib/typescript/commonjs/i18n/locale.d.ts +4 -0
  151. package/lib/typescript/commonjs/i18n/locale.d.ts.map +1 -0
  152. package/lib/typescript/commonjs/i18n/translator.d.ts +15 -0
  153. package/lib/typescript/commonjs/i18n/translator.d.ts.map +1 -0
  154. package/lib/typescript/commonjs/index.d.ts +24 -0
  155. package/lib/typescript/commonjs/index.d.ts.map +1 -0
  156. package/lib/typescript/commonjs/lib/device-detector.d.ts +5 -0
  157. package/lib/typescript/commonjs/lib/device-detector.d.ts.map +1 -0
  158. package/lib/typescript/commonjs/lib/event-emitter.d.ts +19 -0
  159. package/lib/typescript/commonjs/lib/event-emitter.d.ts.map +1 -0
  160. package/lib/typescript/commonjs/lib/index.d.ts +5 -0
  161. package/lib/typescript/commonjs/lib/index.d.ts.map +1 -0
  162. package/lib/typescript/commonjs/lib/kwik-id-rn-sdk.d.ts +43 -0
  163. package/lib/typescript/commonjs/lib/kwik-id-rn-sdk.d.ts.map +1 -0
  164. package/lib/typescript/commonjs/lib/verification-machine.d.ts +78 -0
  165. package/lib/typescript/commonjs/lib/verification-machine.d.ts.map +1 -0
  166. package/lib/typescript/commonjs/package.json +1 -0
  167. package/lib/typescript/commonjs/types/events.d.ts +94 -0
  168. package/lib/typescript/commonjs/types/events.d.ts.map +1 -0
  169. package/lib/typescript/commonjs/types/index.d.ts +242 -0
  170. package/lib/typescript/commonjs/types/index.d.ts.map +1 -0
  171. package/lib/typescript/commonjs/ui/components/KwikIDVerificationModal.d.ts +21 -0
  172. package/lib/typescript/commonjs/ui/components/KwikIDVerificationModal.d.ts.map +1 -0
  173. package/lib/typescript/commonjs/ui/components/screens.d.ts +46 -0
  174. package/lib/typescript/commonjs/ui/components/screens.d.ts.map +1 -0
  175. package/lib/typescript/commonjs/ui/context/kwik-id-provider.d.ts +19 -0
  176. package/lib/typescript/commonjs/ui/context/kwik-id-provider.d.ts.map +1 -0
  177. package/lib/typescript/commonjs/ui/hooks/use-kwik-verification.d.ts +29 -0
  178. package/lib/typescript/commonjs/ui/hooks/use-kwik-verification.d.ts.map +1 -0
  179. package/lib/typescript/commonjs/ui/index.d.ts +7 -0
  180. package/lib/typescript/commonjs/ui/index.d.ts.map +1 -0
  181. package/lib/typescript/module/api/api-client.d.ts +82 -0
  182. package/lib/typescript/module/api/api-client.d.ts.map +1 -0
  183. package/lib/typescript/module/api/api-error.d.ts +13 -0
  184. package/lib/typescript/module/api/api-error.d.ts.map +1 -0
  185. package/lib/typescript/module/api/index.d.ts +6 -0
  186. package/lib/typescript/module/api/index.d.ts.map +1 -0
  187. package/lib/typescript/module/api/upload.d.ts +19 -0
  188. package/lib/typescript/module/api/upload.d.ts.map +1 -0
  189. package/lib/typescript/module/camera/camera-view.d.ts +25 -0
  190. package/lib/typescript/module/camera/camera-view.d.ts.map +1 -0
  191. package/lib/typescript/module/camera/index.d.ts +5 -0
  192. package/lib/typescript/module/camera/index.d.ts.map +1 -0
  193. package/lib/typescript/module/camera/photo-capture.d.ts +9 -0
  194. package/lib/typescript/module/camera/photo-capture.d.ts.map +1 -0
  195. package/lib/typescript/module/crypto/fingerprint.d.ts +3 -0
  196. package/lib/typescript/module/crypto/fingerprint.d.ts.map +1 -0
  197. package/lib/typescript/module/crypto/hmac.d.ts +18 -0
  198. package/lib/typescript/module/crypto/hmac.d.ts.map +1 -0
  199. package/lib/typescript/module/crypto/index.d.ts +4 -0
  200. package/lib/typescript/module/crypto/index.d.ts.map +1 -0
  201. package/lib/typescript/module/crypto/session-manager.d.ts +27 -0
  202. package/lib/typescript/module/crypto/session-manager.d.ts.map +1 -0
  203. package/lib/typescript/module/i18n/en.d.ts +291 -0
  204. package/lib/typescript/module/i18n/en.d.ts.map +1 -0
  205. package/lib/typescript/module/i18n/fr.d.ts +6 -0
  206. package/lib/typescript/module/i18n/fr.d.ts.map +1 -0
  207. package/lib/typescript/module/i18n/index.d.ts +10 -0
  208. package/lib/typescript/module/i18n/index.d.ts.map +1 -0
  209. package/lib/typescript/module/i18n/locale.d.ts +4 -0
  210. package/lib/typescript/module/i18n/locale.d.ts.map +1 -0
  211. package/lib/typescript/module/i18n/translator.d.ts +15 -0
  212. package/lib/typescript/module/i18n/translator.d.ts.map +1 -0
  213. package/lib/typescript/module/index.d.ts +24 -0
  214. package/lib/typescript/module/index.d.ts.map +1 -0
  215. package/lib/typescript/module/lib/device-detector.d.ts +5 -0
  216. package/lib/typescript/module/lib/device-detector.d.ts.map +1 -0
  217. package/lib/typescript/module/lib/event-emitter.d.ts +19 -0
  218. package/lib/typescript/module/lib/event-emitter.d.ts.map +1 -0
  219. package/lib/typescript/module/lib/index.d.ts +5 -0
  220. package/lib/typescript/module/lib/index.d.ts.map +1 -0
  221. package/lib/typescript/module/lib/kwik-id-rn-sdk.d.ts +43 -0
  222. package/lib/typescript/module/lib/kwik-id-rn-sdk.d.ts.map +1 -0
  223. package/lib/typescript/module/lib/verification-machine.d.ts +78 -0
  224. package/lib/typescript/module/lib/verification-machine.d.ts.map +1 -0
  225. package/lib/typescript/module/package.json +1 -0
  226. package/lib/typescript/module/types/events.d.ts +94 -0
  227. package/lib/typescript/module/types/events.d.ts.map +1 -0
  228. package/lib/typescript/module/types/index.d.ts +242 -0
  229. package/lib/typescript/module/types/index.d.ts.map +1 -0
  230. package/lib/typescript/module/ui/components/KwikIDVerificationModal.d.ts +21 -0
  231. package/lib/typescript/module/ui/components/KwikIDVerificationModal.d.ts.map +1 -0
  232. package/lib/typescript/module/ui/components/screens.d.ts +46 -0
  233. package/lib/typescript/module/ui/components/screens.d.ts.map +1 -0
  234. package/lib/typescript/module/ui/context/kwik-id-provider.d.ts +19 -0
  235. package/lib/typescript/module/ui/context/kwik-id-provider.d.ts.map +1 -0
  236. package/lib/typescript/module/ui/hooks/use-kwik-verification.d.ts +29 -0
  237. package/lib/typescript/module/ui/hooks/use-kwik-verification.d.ts.map +1 -0
  238. package/lib/typescript/module/ui/index.d.ts +7 -0
  239. package/lib/typescript/module/ui/index.d.ts.map +1 -0
  240. package/package.json +121 -3
  241. package/src/api/api-client.ts +319 -0
  242. package/src/api/api-error.ts +28 -0
  243. package/src/api/index.ts +12 -0
  244. package/src/api/upload.ts +87 -0
  245. package/src/camera/camera-view.tsx +217 -0
  246. package/src/camera/index.ts +4 -0
  247. package/src/camera/photo-capture.ts +58 -0
  248. package/src/crypto/fingerprint.ts +46 -0
  249. package/src/crypto/hmac.ts +172 -0
  250. package/src/crypto/index.ts +3 -0
  251. package/src/crypto/session-manager.ts +200 -0
  252. package/src/i18n/en.ts +315 -0
  253. package/src/i18n/fr.ts +325 -0
  254. package/src/i18n/index.ts +9 -0
  255. package/src/i18n/locale.ts +15 -0
  256. package/src/i18n/translator.ts +37 -0
  257. package/src/index.ts +102 -0
  258. package/src/lib/device-detector.ts +32 -0
  259. package/src/lib/event-emitter.ts +90 -0
  260. package/src/lib/index.ts +15 -0
  261. package/src/lib/kwik-id-rn-sdk.ts +160 -0
  262. package/src/lib/verification-machine.ts +273 -0
  263. package/src/types/events.ts +75 -0
  264. package/src/types/index.ts +309 -0
  265. package/src/ui/components/KwikIDVerificationModal.tsx +450 -0
  266. package/src/ui/components/screens.tsx +283 -0
  267. package/src/ui/context/kwik-id-provider.tsx +72 -0
  268. package/src/ui/hooks/use-kwik-verification.ts +121 -0
  269. package/src/ui/index.ts +9 -0
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * RN KYC-flow i18n (EN + FR). Locale is supplied by the host app via SDK config
5
+ * and threaded to screens as a `t` prop.
6
+ */
7
+ export { en } from "./en.js";
8
+ export { fr } from "./fr.js";
9
+ export { getDeviceLocale } from "./locale.js";
10
+ export { createTranslator } from "./translator.js";
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["en","fr","getDeviceLocale","createTranslator"],"sourceRoot":"../../../src","sources":["i18n/index.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,SAAM;AACzB,SAASC,EAAE,QAAQ,SAAM;AACzB,SAASC,eAAe,QAAQ,aAAU;AAC1C,SAASC,gBAAgB,QAAQ,iBAAc","ignoreList":[]}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Device-locale detection for the default UI language.
5
+ */
6
+ import { getLocales } from "expo-localization";
7
+ /** 'fr' when the device's preferred language is French, otherwise 'en'. */
8
+ export function getDeviceLocale() {
9
+ try {
10
+ return getLocales()[0]?.languageCode === "fr" ? "fr" : "en";
11
+ } catch {
12
+ return "en";
13
+ }
14
+ }
15
+ //# sourceMappingURL=locale.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["getLocales","getDeviceLocale","languageCode"],"sourceRoot":"../../../src","sources":["i18n/locale.ts"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,UAAU,QAAQ,mBAAmB;AAI9C;AACA,OAAO,SAASC,eAAeA,CAAA,EAAW;EACtC,IAAI;IACA,OAAOD,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,EAAEE,YAAY,KAAK,IAAI,GAAG,IAAI,GAAG,IAAI;EAC/D,CAAC,CAAC,MAAM;IACJ,OAAO,IAAI;EACf;AACJ","ignoreList":[]}
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Tiny dependency-free translator for the RN KYC flow (mirrors the web SDK's).
5
+ * The host app supplies the locale via SDK config; missing keys fall back to English.
6
+ */
7
+
8
+ import { en } from "./en.js";
9
+ import { fr } from "./fr.js";
10
+
11
+ /** All message keys, derived from the English catalog (the source of truth). */
12
+
13
+ /** Interpolation values for `{placeholder}` tokens in a message. */
14
+
15
+ /** Translate a key to the active locale, interpolating any `{param}` tokens. */
16
+
17
+ const catalogs = {
18
+ en,
19
+ fr
20
+ };
21
+ function interpolate(template, params) {
22
+ if (!params) return template;
23
+ return template.replace(/\{(\w+)\}/g, (match, name) => name in params ? String(params[name]) : match);
24
+ }
25
+
26
+ /** Build a translator bound to a locale, falling back to English then the raw key. */
27
+ export function createTranslator(locale = "en") {
28
+ const table = catalogs[locale] ?? en;
29
+ return (key, params) => {
30
+ const template = table[key] ?? en[key] ?? key;
31
+ return interpolate(template, params);
32
+ };
33
+ }
34
+ //# sourceMappingURL=translator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["en","fr","catalogs","interpolate","template","params","replace","match","name","String","createTranslator","locale","table","key"],"sourceRoot":"../../../src","sources":["i18n/translator.ts"],"mappings":";;AAAA;AACA;AACA;AACA;;AAEA,SAASA,EAAE,QAAQ,SAAM;AACzB,SAASC,EAAE,QAAQ,SAAM;;AAEzB;;AAGA;;AAGA;;AAGA,MAAMC,QAA6D,GAAG;EAClEF,EAAE;EACFC;AACJ,CAAC;AAED,SAASE,WAAWA,CAACC,QAAgB,EAAEC,MAAwB,EAAU;EACrE,IAAI,CAACA,MAAM,EAAE,OAAOD,QAAQ;EAC5B,OAAOA,QAAQ,CAACE,OAAO,CAAC,YAAY,EAAE,CAACC,KAAK,EAAEC,IAAY,KACtDA,IAAI,IAAIH,MAAM,GAAGI,MAAM,CAACJ,MAAM,CAACG,IAAI,CAAC,CAAC,GAAGD,KAC5C,CAAC;AACL;;AAEA;AACA,OAAO,SAASG,gBAAgBA,CAACC,MAAc,GAAG,IAAI,EAAa;EAC/D,MAAMC,KAAK,GAAGV,QAAQ,CAACS,MAAM,CAAC,IAAIX,EAAE;EACpC,OAAO,CAACa,GAAG,EAAER,MAAM,KAAK;IACpB,MAAMD,QAAQ,GAAGQ,KAAK,CAACC,GAAG,CAAC,IAAIb,EAAE,CAACa,GAAG,CAAC,IAAIA,GAAG;IAC7C,OAAOV,WAAW,CAACC,QAAQ,EAAEC,MAAM,CAAC;EACxC,CAAC;AACL","ignoreList":[]}
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * @kwik-id/sdk-react-native — public API.
5
+ *
6
+ * Phase 1: on-device document + selfie capture, upload, and submit, plus the
7
+ * headless protocol foundation. On-device liveness (passive + active challenges)
8
+ * lands in Phase 2.
9
+ *
10
+ * @packageDocumentation
11
+ */
12
+
13
+ // ---- UI (primary integration) ----
14
+ export { useKwikVerification, KwikIDVerificationModal, KwikIDProvider, useKwikID } from "./ui/index.js";
15
+ // ---- Camera ----
16
+ export { CameraView, compressCapture } from "./camera/index.js";
17
+ // ---- Headless orchestrator ----
18
+ export { KwikIdRNSDK } from "./lib/kwik-id-rn-sdk.js";
19
+ // ---- API ----
20
+ export { ApiClient, ApiError, DEFAULT_BASE_URL, uploadMultipart } from "./api/index.js";
21
+ // ---- i18n (EN + FR) ----
22
+ export { createTranslator, getDeviceLocale, en as messagesEn, fr as messagesFr } from "./i18n/index.js";
23
+ // ---- Crypto / session ----
24
+ export { SessionManager, generateFingerprint, hmacSha256Hex, sha256Hex, generateNonce } from "./crypto/index.js";
25
+
26
+ // ---- Headless orchestration primitives ----
27
+ export { EventEmitter, reducer, initialState, needsBackImage, getStepProgress, computeUploadProgress, isExpoGo, assertSupportedRuntime, isRealDevice } from "./lib/index.js";
28
+
29
+ // ---- Types ----
30
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useKwikVerification","KwikIDVerificationModal","KwikIDProvider","useKwikID","CameraView","compressCapture","KwikIdRNSDK","ApiClient","ApiError","DEFAULT_BASE_URL","uploadMultipart","createTranslator","getDeviceLocale","en","messagesEn","fr","messagesFr","SessionManager","generateFingerprint","hmacSha256Hex","sha256Hex","generateNonce","EventEmitter","reducer","initialState","needsBackImage","getStepProgress","computeUploadProgress","isExpoGo","assertSupportedRuntime","isRealDevice"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,SAASA,mBAAmB,EAAEC,uBAAuB,EAAEC,cAAc,EAAEC,SAAS,QAAQ,eAAM;AAS9F;AACA,SAASC,UAAU,EAAEC,eAAe,QAAQ,mBAAU;AAGtD;AACA,SAASC,WAAW,QAAQ,yBAAsB;AAGlD;AACA,SAASC,SAAS,EAAEC,QAAQ,EAAEC,gBAAgB,EAAEC,eAAe,QAAQ,gBAAO;AAY9E;AACA,SAASC,gBAAgB,EAAEC,eAAe,EAAEC,EAAE,IAAIC,UAAU,EAAEC,EAAE,IAAIC,UAAU,QAAQ,iBAAQ;AAG9F;AACA,SACIC,cAAc,EACdC,mBAAmB,EACnBC,aAAa,EACbC,SAAS,EACTC,aAAa,QACV,mBAAU;;AAEjB;AACA,SACIC,YAAY,EACZC,OAAO,EACPC,YAAY,EACZC,cAAc,EACdC,eAAe,EACfC,qBAAqB,EACrBC,QAAQ,EACRC,sBAAsB,EACtBC,YAAY,QACT,gBAAO;;AAGd","ignoreList":[]}
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Device / runtime environment detection.
5
+ *
6
+ * Replaces the web SDK's emulator + automation heuristics. The most important
7
+ * check is Expo Go detection: vision-camera frame processors are native and
8
+ * cannot run in Expo Go, so the SDK fails fast with an actionable message.
9
+ */
10
+ import Constants, { AppOwnership, ExecutionEnvironment } from "expo-constants";
11
+ import * as Device from "expo-device";
12
+ export function isExpoGo() {
13
+ return Constants.appOwnership === AppOwnership.Expo || Constants.executionEnvironment === ExecutionEnvironment.StoreClient;
14
+ }
15
+
16
+ /** Throws an actionable error when running in an unsupported runtime. */
17
+ export function assertSupportedRuntime() {
18
+ if (isExpoGo()) {
19
+ throw new Error("[KwikID] This SDK requires a custom dev build or EAS build and cannot run in Expo Go. " + "Run `expo prebuild` and build a development client (or `eas build`). " + "See https://docs.expo.dev/develop/development-builds/introduction/");
20
+ }
21
+ }
22
+ export function isRealDevice() {
23
+ // false on iOS Simulator / Android emulator.
24
+ return Device.isDevice === true;
25
+ }
26
+ //# sourceMappingURL=device-detector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Constants","AppOwnership","ExecutionEnvironment","Device","isExpoGo","appOwnership","Expo","executionEnvironment","StoreClient","assertSupportedRuntime","Error","isRealDevice","isDevice"],"sourceRoot":"../../../src","sources":["lib/device-detector.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAOA,SAAS,IAAIC,YAAY,EAAEC,oBAAoB,QAAQ,gBAAgB;AAC9E,OAAO,KAAKC,MAAM,MAAM,aAAa;AAErC,OAAO,SAASC,QAAQA,CAAA,EAAY;EAChC,OACIJ,SAAS,CAACK,YAAY,KAAKJ,YAAY,CAACK,IAAI,IAC5CN,SAAS,CAACO,oBAAoB,KAAKL,oBAAoB,CAACM,WAAW;AAE3E;;AAEA;AACA,OAAO,SAASC,sBAAsBA,CAAA,EAAS;EAC3C,IAAIL,QAAQ,CAAC,CAAC,EAAE;IACZ,MAAM,IAAIM,KAAK,CACX,wFAAwF,GACpF,uEAAuE,GACvE,oEACR,CAAC;EACL;AACJ;AAEA,OAAO,SAASC,YAAYA,CAAA,EAAY;EACpC;EACA,OAAOR,MAAM,CAACS,QAAQ,KAAK,IAAI;AACnC","ignoreList":[]}
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Type-safe event emitter (ported from @kwik-id/sdk-core, framework-agnostic).
5
+ */
6
+
7
+ export class EventEmitter {
8
+ listeners = new Map();
9
+ wildcardListeners = new Set();
10
+ onceListeners = new Map();
11
+ on(event, handler) {
12
+ if (!this.listeners.has(event)) {
13
+ this.listeners.set(event, new Set());
14
+ }
15
+ this.listeners.get(event).add(handler);
16
+ return () => this.off(event, handler);
17
+ }
18
+ once(event, handler) {
19
+ if (!this.onceListeners.has(event)) {
20
+ this.onceListeners.set(event, new Set());
21
+ }
22
+ this.onceListeners.get(event).add(handler);
23
+ return () => {
24
+ this.onceListeners.get(event)?.delete(handler);
25
+ };
26
+ }
27
+ onAny(handler) {
28
+ this.wildcardListeners.add(handler);
29
+ return () => this.wildcardListeners.delete(handler);
30
+ }
31
+ off(event, handler) {
32
+ this.listeners.get(event)?.delete(handler);
33
+ }
34
+ emit(event, data) {
35
+ const handlers = this.listeners.get(event);
36
+ if (handlers) {
37
+ handlers.forEach(handler => {
38
+ try {
39
+ handler(data);
40
+ } catch (error) {
41
+ console.error(`Error in event handler for ${event}:`, error);
42
+ }
43
+ });
44
+ }
45
+ const onceHandlers = this.onceListeners.get(event);
46
+ if (onceHandlers) {
47
+ onceHandlers.forEach(handler => {
48
+ try {
49
+ handler(data);
50
+ } catch (error) {
51
+ console.error(`Error in once handler for ${event}:`, error);
52
+ }
53
+ });
54
+ this.onceListeners.delete(event);
55
+ }
56
+ this.wildcardListeners.forEach(handler => {
57
+ try {
58
+ handler(event, data);
59
+ } catch (error) {
60
+ console.error(`Error in wildcard handler for ${event}:`, error);
61
+ }
62
+ });
63
+ }
64
+ removeAllListeners(event) {
65
+ if (event) {
66
+ this.listeners.delete(event);
67
+ this.onceListeners.delete(event);
68
+ } else {
69
+ this.listeners.clear();
70
+ this.onceListeners.clear();
71
+ this.wildcardListeners.clear();
72
+ }
73
+ }
74
+ listenerCount(event) {
75
+ const regularCount = this.listeners.get(event)?.size || 0;
76
+ const onceCount = this.onceListeners.get(event)?.size || 0;
77
+ return regularCount + onceCount;
78
+ }
79
+ }
80
+ //# sourceMappingURL=event-emitter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["EventEmitter","listeners","Map","wildcardListeners","Set","onceListeners","on","event","handler","has","set","get","add","off","once","delete","onAny","emit","data","handlers","forEach","error","console","onceHandlers","removeAllListeners","clear","listenerCount","regularCount","size","onceCount"],"sourceRoot":"../../../src","sources":["lib/event-emitter.ts"],"mappings":";;AAAA;AACA;AACA;;AAKA,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,KAAK,CAAC;IACpC,CAAC,MAAM;MACH,IAAI,CAACN,SAAS,CAACwB,KAAK,CAAC,CAAC;MACtB,IAAI,CAACpB,aAAa,CAACoB,KAAK,CAAC,CAAC;MAC1B,IAAI,CAACtB,iBAAiB,CAACsB,KAAK,CAAC,CAAC;IAClC;EACJ;EAEAC,aAAaA,CAACnB,KAAsB,EAAU;IAC1C,MAAMoB,YAAY,GAAG,IAAI,CAAC1B,SAAS,CAACU,GAAG,CAACJ,KAAK,CAAC,EAAEqB,IAAI,IAAI,CAAC;IACzD,MAAMC,SAAS,GAAG,IAAI,CAACxB,aAAa,CAACM,GAAG,CAACJ,KAAK,CAAC,EAAEqB,IAAI,IAAI,CAAC;IAC1D,OAAOD,YAAY,GAAGE,SAAS;EACnC;AACJ","ignoreList":[]}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+
3
+ export { EventEmitter } from "./event-emitter.js";
4
+ export { reducer, initialState, needsBackImage, getStepProgress, computeUploadProgress } from "./verification-machine.js";
5
+ export { isExpoGo, assertSupportedRuntime, isRealDevice } from "./device-detector.js";
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["EventEmitter","reducer","initialState","needsBackImage","getStepProgress","computeUploadProgress","isExpoGo","assertSupportedRuntime","isRealDevice"],"sourceRoot":"../../../src","sources":["lib/index.ts"],"mappings":";;AAAA,SAASA,YAAY,QAAQ,oBAAiB;AAC9C,SACIC,OAAO,EACPC,YAAY,EACZC,cAAc,EACdC,eAAe,EACfC,qBAAqB,QAClB,2BAAwB;AAO/B,SAASC,QAAQ,EAAEC,sBAAsB,EAAEC,YAAY,QAAQ,sBAAmB","ignoreList":[]}
@@ -0,0 +1,150 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Headless orchestrator for the RN SDK.
5
+ *
6
+ * Wraps SessionManager + ApiClient + EventEmitter so the UI (and advanced
7
+ * integrators) drive a single object. No camera/UI concerns live here.
8
+ */
9
+ import { ApiClient } from "../api/api-client.js";
10
+ import { SessionManager } from "../crypto/session-manager.js";
11
+ import { assertSupportedRuntime } from "./device-detector.js";
12
+ import { EventEmitter } from "./event-emitter.js";
13
+ export class KwikIdRNSDK {
14
+ events = new EventEmitter();
15
+ sessionInfo = null;
16
+ initialized = false;
17
+ constructor(options) {
18
+ this.options = options;
19
+ this.sessionManager = new SessionManager();
20
+ this.api = new ApiClient(this.sessionManager, {
21
+ baseUrl: options.baseUrl,
22
+ timeout: options.timeout,
23
+ debug: options.debug
24
+ });
25
+ }
26
+
27
+ /** Validate the runtime + session token. Returns the org/session config. */
28
+ async initialize() {
29
+ if (!this.options.skipRuntimeCheck) {
30
+ assertSupportedRuntime();
31
+ }
32
+ try {
33
+ this.sessionInfo = await this.api.validateSession(this.options.clientSecret);
34
+ this.initialized = true;
35
+ const session = this.sessionManager.getSession();
36
+ if (session) this.events.emit("session:created", session);
37
+ this.events.emit("ready", undefined);
38
+ return this.sessionInfo;
39
+ } catch (error) {
40
+ this.events.emit("error", {
41
+ code: "INIT_FAILED",
42
+ message: error.message,
43
+ recoverable: false
44
+ });
45
+ throw error;
46
+ }
47
+ }
48
+
49
+ /** Redeem a desktop→mobile handoff code, swapping in the mobile session token. */
50
+ async redeemHandoff(code) {
51
+ try {
52
+ const {
53
+ sessionToken
54
+ } = await this.api.redeemHandoff(code);
55
+ this.sessionInfo = await this.api.validateSession(sessionToken);
56
+ this.initialized = true;
57
+ const session = this.sessionManager.getSession();
58
+ this.events.emit("handoff:redeemed", {
59
+ jobId: session?.jobId ?? ""
60
+ });
61
+ } catch (error) {
62
+ this.events.emit("handoff:error", {
63
+ error: error
64
+ });
65
+ throw error;
66
+ }
67
+ }
68
+ async uploadCapture(type, asset, onProgress) {
69
+ this.assertReady();
70
+ this.events.emit("upload:starting", {
71
+ type
72
+ });
73
+ try {
74
+ const res = await this.api.uploadCapture(type, asset, p => {
75
+ this.events.emit("upload:progress", {
76
+ type,
77
+ progress: p
78
+ });
79
+ onProgress?.(p);
80
+ });
81
+ this.events.emit("upload:complete", {
82
+ type,
83
+ uploadId: res.uploadId
84
+ });
85
+ return {
86
+ uploadId: res.uploadId
87
+ };
88
+ } catch (error) {
89
+ const retryable = typeof error.isRetryable === "function" ? error.isRetryable() : false;
90
+ this.events.emit("upload:failed", {
91
+ type,
92
+ error: error,
93
+ retryable
94
+ });
95
+ throw error;
96
+ }
97
+ }
98
+ async submit(documentType, analysis) {
99
+ this.assertReady();
100
+ this.events.emit("verification:submitting", undefined);
101
+ try {
102
+ const res = await this.api.submitVerification(documentType, {
103
+ qualityScores: analysis?.quality,
104
+ livenessResult: analysis?.liveness
105
+ });
106
+ const jobId = res.jobId ?? this.sessionManager.getSession()?.jobId ?? "";
107
+ this.events.emit("verification:submitted", {
108
+ jobId
109
+ });
110
+ return {
111
+ jobId
112
+ };
113
+ } catch (error) {
114
+ this.events.emit("verification:failed", {
115
+ error: error
116
+ });
117
+ throw error;
118
+ }
119
+ }
120
+ getStatus() {
121
+ this.assertReady();
122
+ return this.api.getStatus();
123
+ }
124
+ getSessionInfo() {
125
+ return this.sessionInfo;
126
+ }
127
+
128
+ /** True when the session token is within ~2 min of expiry. */
129
+ needsRefresh() {
130
+ return this.sessionManager.needsRefresh();
131
+ }
132
+ on(event, handler) {
133
+ return this.events.on(event, handler);
134
+ }
135
+ reset() {
136
+ this.sessionManager.clearSession();
137
+ this.sessionInfo = null;
138
+ this.initialized = false;
139
+ }
140
+ destroy() {
141
+ this.reset();
142
+ this.events.removeAllListeners();
143
+ }
144
+ assertReady() {
145
+ if (!this.initialized) {
146
+ throw new Error("KwikIdRNSDK not initialized — call initialize() first");
147
+ }
148
+ }
149
+ }
150
+ //# sourceMappingURL=kwik-id-rn-sdk.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["ApiClient","SessionManager","assertSupportedRuntime","EventEmitter","KwikIdRNSDK","events","sessionInfo","initialized","constructor","options","sessionManager","api","baseUrl","timeout","debug","initialize","skipRuntimeCheck","validateSession","clientSecret","session","getSession","emit","undefined","error","code","message","recoverable","redeemHandoff","sessionToken","jobId","uploadCapture","type","asset","onProgress","assertReady","res","p","progress","uploadId","retryable","isRetryable","submit","documentType","analysis","submitVerification","qualityScores","quality","livenessResult","liveness","getStatus","getSessionInfo","needsRefresh","on","event","handler","reset","clearSession","destroy","removeAllListeners","Error"],"sourceRoot":"../../../src","sources":["lib/kwik-id-rn-sdk.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,SAAS,QAA6B,sBAAmB;AAClE,SAASC,cAAc,QAAQ,8BAA2B;AAY1D,SAASC,sBAAsB,QAAQ,sBAAmB;AAC1D,SAASC,YAAY,QAAQ,oBAAiB;AAO9C,OAAO,MAAMC,WAAW,CAAC;EACJC,MAAM,GAAG,IAAIF,YAAY,CAAC,CAAC;EAIpCG,WAAW,GAAuB,IAAI;EACtCC,WAAW,GAAG,KAAK;EAE3BC,WAAWA,CAACC,OAA2B,EAAE;IACrC,IAAI,CAACA,OAAO,GAAGA,OAAO;IACtB,IAAI,CAACC,cAAc,GAAG,IAAIT,cAAc,CAAC,CAAC;IAC1C,IAAI,CAACU,GAAG,GAAG,IAAIX,SAAS,CAAC,IAAI,CAACU,cAAc,EAAE;MAC1CE,OAAO,EAAEH,OAAO,CAACG,OAAO;MACxBC,OAAO,EAAEJ,OAAO,CAACI,OAAO;MACxBC,KAAK,EAAEL,OAAO,CAACK;IACnB,CAAC,CAAC;EACN;;EAEA;EACA,MAAMC,UAAUA,CAAA,EAAyB;IACrC,IAAI,CAAC,IAAI,CAACN,OAAO,CAACO,gBAAgB,EAAE;MAChCd,sBAAsB,CAAC,CAAC;IAC5B;IACA,IAAI;MACA,IAAI,CAACI,WAAW,GAAG,MAAM,IAAI,CAACK,GAAG,CAACM,eAAe,CAAC,IAAI,CAACR,OAAO,CAACS,YAAY,CAAC;MAC5E,IAAI,CAACX,WAAW,GAAG,IAAI;MACvB,MAAMY,OAAO,GAAG,IAAI,CAACT,cAAc,CAACU,UAAU,CA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the RN verification flow.
5
+ *
6
+ * Adapted from the web SDK's KYCModalFlow SubStep machine. No React / no native
7
+ * dependency, so it is fully unit-testable. The selfie branch folds the web's
8
+ * `camera-selfie` into a single `liveness` step (align → passive/active → capture).
9
+ */
10
+
11
+ export function needsBackImage(doc) {
12
+ return doc === "id_card" || doc === "drivers_license" || doc === "voters_card";
13
+ }
14
+ export function initialState() {
15
+ return {
16
+ step: "intro",
17
+ context: {
18
+ documentType: null,
19
+ uploadProgress: 0,
20
+ uploadStage: null
21
+ }
22
+ };
23
+ }
24
+
25
+ /** Steps that contribute to the progress bar, in order (mirrors web getProgress). */
26
+ function progressSteps(ctx) {
27
+ const steps = ["document-type", "prepare-front", "camera-front", "confirm-front"];
28
+ if (needsBackImage(ctx.documentType)) {
29
+ steps.push("prepare-back", "camera-back", "confirm-back");
30
+ }
31
+ steps.push("prepare-selfie", "liveness", "confirm-selfie");
32
+ return steps;
33
+ }
34
+
35
+ /** Progress-bar percentage (0..100) for the current step. */
36
+ export function getStepProgress(state) {
37
+ const hidden = ["intro", "handoff-redeem", "processing", "result"];
38
+ if (hidden.includes(state.step)) return 0;
39
+ const steps = progressSteps(state.context);
40
+ const idx = steps.indexOf(state.step);
41
+ if (idx < 0) return 0;
42
+ return (idx + 1) / steps.length * 100;
43
+ }
44
+
45
+ /**
46
+ * Upload/submit progress banding (matches web performVerification):
47
+ * front 0–30, back 30–45, selfie 45–70 (or 30–55 without back), submit 80, done 100.
48
+ */
49
+ export function computeUploadProgress(stage, pct, hasBack) {
50
+ switch (stage) {
51
+ case "document_front":
52
+ return Math.round(pct * 0.3);
53
+ case "document_back":
54
+ return 30 + Math.round(pct * 0.15);
55
+ case "selfie":
56
+ {
57
+ const base = hasBack ? 45 : 30;
58
+ return base + Math.round(pct * 0.25);
59
+ }
60
+ case "submitting":
61
+ return Math.max(80, Math.round(pct));
62
+ default:
63
+ return 0;
64
+ }
65
+ }
66
+ const FORWARD_TAP = {
67
+ "prepare-front": "camera-front",
68
+ "prepare-back": "camera-back",
69
+ "prepare-selfie": "liveness",
70
+ // 'confirm-front' is resolved dynamically (needs back?) in the reducer.
71
+ "confirm-back": "prepare-selfie",
72
+ "confirm-selfie": "processing"
73
+ };
74
+ const BACK_FLOW = {
75
+ "document-type": "intro",
76
+ "prepare-front": "document-type",
77
+ "camera-front": "prepare-front",
78
+ "confirm-front": "camera-front",
79
+ "prepare-back": "confirm-front",
80
+ "camera-back": "prepare-back",
81
+ "confirm-back": "camera-back",
82
+ "confirm-selfie": "prepare-selfie"
83
+ };
84
+ export function reducer(state, event, options = {}) {
85
+ const {
86
+ step,
87
+ context
88
+ } = state;
89
+ switch (event.t) {
90
+ case "NEXT":
91
+ {
92
+ if (step === "intro") {
93
+ return {
94
+ ...state,
95
+ step: options.hasHandoffCode ? "handoff-redeem" : "document-type"
96
+ };
97
+ }
98
+ if (step === "confirm-front") {
99
+ return {
100
+ ...state,
101
+ step: needsBackImage(context.documentType) ? "prepare-back" : "prepare-selfie"
102
+ };
103
+ }
104
+ const next = FORWARD_TAP[step];
105
+ return next ? {
106
+ ...state,
107
+ step: next
108
+ } : state;
109
+ }
110
+ case "BACK":
111
+ {
112
+ // Terminal / non-reversible steps.
113
+ if (step === "processing" || step === "result" || step === "liveness") return state;
114
+ if (step === "prepare-selfie") {
115
+ return {
116
+ ...state,
117
+ step: needsBackImage(context.documentType) ? "confirm-back" : "confirm-front"
118
+ };
119
+ }
120
+ const prev = BACK_FLOW[step];
121
+ return prev ? {
122
+ ...state,
123
+ step: prev
124
+ } : state;
125
+ }
126
+ case "SELECT_DOC":
127
+ {
128
+ if (step !== "document-type") return state;
129
+ return {
130
+ step: "prepare-front",
131
+ context: {
132
+ ...context,
133
+ documentType: event.doc
134
+ }
135
+ };
136
+ }
137
+ case "HANDOFF_REDEEMED":
138
+ {
139
+ if (step !== "handoff-redeem") return state;
140
+ return {
141
+ ...state,
142
+ step: "document-type"
143
+ };
144
+ }
145
+ case "CAPTURED":
146
+ {
147
+ const ctx = {
148
+ ...context,
149
+ [event.slot]: event.asset
150
+ };
151
+ if (event.slot === "front" && step === "camera-front") {
152
+ return {
153
+ step: "confirm-front",
154
+ context: ctx
155
+ };
156
+ }
157
+ if (event.slot === "back" && step === "camera-back") {
158
+ return {
159
+ step: "confirm-back",
160
+ context: ctx
161
+ };
162
+ }
163
+ return {
164
+ ...state,
165
+ context: ctx
166
+ };
167
+ }
168
+ case "RETAKE":
169
+ {
170
+ if (event.slot === "front") {
171
+ return {
172
+ step: "camera-front",
173
+ context: {
174
+ ...context,
175
+ front: undefined
176
+ }
177
+ };
178
+ }
179
+ if (event.slot === "back") {
180
+ return {
181
+ step: "camera-back",
182
+ context: {
183
+ ...context,
184
+ back: undefined
185
+ }
186
+ };
187
+ }
188
+ return {
189
+ step: "liveness",
190
+ context: {
191
+ ...context,
192
+ selfie: undefined,
193
+ livenessResult: undefined
194
+ }
195
+ };
196
+ }
197
+ case "LIVENESS_DONE":
198
+ {
199
+ if (step !== "liveness") return state;
200
+ return {
201
+ step: "confirm-selfie",
202
+ context: {
203
+ ...context,
204
+ selfie: event.selfie,
205
+ livenessResult: event.result
206
+ }
207
+ };
208
+ }
209
+ case "PROGRESS":
210
+ {
211
+ const hasBack = !!context.back;
212
+ return {
213
+ ...state,
214
+ context: {
215
+ ...context,
216
+ uploadStage: event.stage,
217
+ uploadProgress: computeUploadProgress(event.stage, event.value, hasBack)
218
+ }
219
+ };
220
+ }
221
+ case "SUBMITTED":
222
+ {
223
+ return {
224
+ step: "result",
225
+ context: {
226
+ ...context,
227
+ uploadProgress: 100,
228
+ uploadStage: null,
229
+ outcome: {
230
+ status: "submitted",
231
+ jobId: event.jobId
232
+ }
233
+ }
234
+ };
235
+ }
236
+ case "FAILED":
237
+ {
238
+ return {
239
+ step: "result",
240
+ context: {
241
+ ...context,
242
+ error: event.error,
243
+ outcome: {
244
+ status: "error",
245
+ error: new Error(event.error)
246
+ }
247
+ }
248
+ };
249
+ }
250
+ case "CANCEL":
251
+ {
252
+ return {
253
+ ...state,
254
+ context: {
255
+ ...context,
256
+ outcome: {
257
+ status: "cancelled"
258
+ }
259
+ }
260
+ };
261
+ }
262
+ case "RESET":
263
+ return initialState();
264
+ default:
265
+ return state;
266
+ }
267
+ }
268
+ //# sourceMappingURL=verification-machine.js.map