@sekyro/react-native 0.1.0-rc.12 → 0.1.0-rc.14
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.
- package/CHANGELOG.md +15 -0
- package/README.md +12 -5
- package/android/src/main/java/ai/sekyro/reactnative/ConfigMapper.kt +6 -0
- package/android/src/main/java/ai/sekyro/reactnative/SekyroReactNativeModule.kt +11 -6
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +17 -5
- package/dist/index.d.ts +17 -5
- package/dist/index.js +1 -1
- package/ios/RCTSekyroReactNative.mm +15 -0
- package/ios/SekyroRNBridge.swift +100 -15
- package/package.json +3 -3
- package/sbom.cdx.json +4 -4
- package/src/specs/NativeSekyroReactNative.ts +8 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @sekyro/react-native
|
|
2
2
|
|
|
3
|
+
## 0.1.0-rc.14
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- a012c1b: Pins the native SDKs 0.1.0-rc.13: the new flow design, change the number or address on the code screen, the terms in a sheet that is easy to close, and automatic retries when the API is busy.
|
|
8
|
+
- dfd36ff: A finished result carries `level` (0 to 3, the new `SekyroLevel` type) and `assurance` (how the level was proved) once the session is decided, when the native SDK reports them (native 0.1.0-rc.13 on). Absent before that, on an expired session and with an older native SDK. The glue reads them from the native SDK's own wire form, so it builds against the current native pin too.
|
|
9
|
+
|
|
10
|
+
## 0.1.0-rc.13
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- 64ca525: `es`, `pt` and `de` now translate every screen, the identity screens (document, ID number, registry, chip, eID, summary) and the shared errors and reasons included; before, they covered the Human copy and showed English elsewhere. The copy still loads on demand, only for those locales. React Native: without a `locale`, the flow follows a device language of `es`, `pt` or `de` too.
|
|
15
|
+
- a574210: Pins the native SDKs 0.1.0-rc.12 (Android `ai.sekyro:sekyro-bom`, iOS `sekyro-ios-dist`): capture mode `choice` (the person picks who films on the first camera step, and the pick holds for the session), a session stopped with `starter_credit_claimed` or `underage_estimated` ends on its own line, the document step after an unsettled selfie age check says why it asks for an ID document, and every native screen reads in `es`, `pt` and `de`. Without a `locale`, iOS now uses the device language when it is one of the six end-user locales, else `fr`, as Android does.
|
|
16
|
+
- 65d665c: iOS: when the React instance is torn down while a flow is open (a reload, an over-the-air update, the React host destroyed), the flow closes and `startSekyro` resolves `{ status: 'failed', code: 'flow_interrupted' }`, as on Android; before, the promise never settled and the next `startSekyro` was refused with `flow_in_progress`. The same result comes back if your app dismisses the flow screen itself. The promise settles exactly once: a result the person already reached wins over a teardown that follows it. Android now also closes the open flow on teardown.
|
|
17
|
+
|
|
3
18
|
## 0.1.0-rc.12
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
# @sekyro/react-native
|
|
2
2
|
|
|
3
3
|
Sekyro AI eKYC for React Native: a thin TurboModule over the binary Sekyro Android and iOS SDKs.
|
|
4
|
-
The native drop-in runs the whole flow (
|
|
4
|
+
The native drop-in runs the whole flow (contact, identity, document, NFC chip, liveness) full screen and
|
|
5
5
|
returns a display-only result. Read the decision on your server (webhooks or `sessions.get`).
|
|
6
6
|
|
|
7
|
-
Requirements: React Native 0.76 or later with the New Architecture, Android minSdk 24, iOS 15.
|
|
7
|
+
Requirements: React Native 0.76 or later with the New Architecture, Android minSdk 24, iOS 15.1.
|
|
8
8
|
|
|
9
9
|
## Install
|
|
10
10
|
|
|
11
11
|
```sh
|
|
12
|
-
npm install @sekyro/react-native
|
|
12
|
+
npm install @sekyro/react-native@next
|
|
13
13
|
```
|
|
14
14
|
|
|
15
15
|
### iOS (Podfile)
|
|
@@ -65,10 +65,17 @@ Or declaratively: `<SekyroFlow clientToken={token} onResult={setResult} />` (ren
|
|
|
65
65
|
|
|
66
66
|
Never log the `clientToken`; it is a one-time bearer credential.
|
|
67
67
|
|
|
68
|
+
**Languages.** `locale` takes `ar`, `fr`, `en`, `es`, `pt` or `de`; only `ar` is right to left. All six translate every screen,
|
|
69
|
+
the identity screens (document, chip, ID number, registry) included. Without a locale, the SDK uses the device
|
|
70
|
+
language when it is one of the six, else `fr`.
|
|
71
|
+
|
|
68
72
|
While a flow runs, the wrapper owns the native SDK's process-wide event listener
|
|
69
73
|
(`Sekyro.setEventListener` on Android, the drop-in's `onEvent` on iOS) and clears it when the
|
|
70
|
-
flow ends, so a listener your app set natively is replaced for that time.
|
|
71
|
-
|
|
74
|
+
flow ends, so a listener your app set natively is replaced for that time. When the React
|
|
75
|
+
instance is torn down while a flow is open (a reload, the React host destroyed), the SDK closes
|
|
76
|
+
the flow and the promise resolves `{ status: 'failed', code: 'flow_interrupted' }` on Android and
|
|
77
|
+
iOS; on iOS the same happens if your app dismisses the flow screen itself. The promise settles
|
|
78
|
+
once. Unmounting `<SekyroFlow>` does not close an open flow: its result still reaches `onResult`.
|
|
72
79
|
|
|
73
80
|
Full guide: [React Native guide](https://docs.sekyro.ai/en/mobile/react-native).
|
|
74
81
|
|
|
@@ -4,6 +4,7 @@ import ai.sekyro.SekyroConfig
|
|
|
4
4
|
import ai.sekyro.SekyroLocale
|
|
5
5
|
import ai.sekyro.SekyroResult
|
|
6
6
|
import ai.sekyro.SekyroTheme
|
|
7
|
+
import ai.sekyro.SekyroWire
|
|
7
8
|
import ai.sekyro.core.DisplayStatus
|
|
8
9
|
import com.facebook.react.bridge.Arguments
|
|
9
10
|
import com.facebook.react.bridge.ReadableMap
|
|
@@ -69,6 +70,11 @@ internal object ConfigMapper {
|
|
|
69
70
|
DisplayStatus.APPROVED -> "approved"; DisplayStatus.REVIEW_PENDING -> "review_pending"
|
|
70
71
|
DisplayStatus.REJECTED -> "rejected"; DisplayStatus.EXPIRED -> "expired"
|
|
71
72
|
})
|
|
73
|
+
// The level and how it was proved when the native SDK reports them (rc.13 on), read from its own wire
|
|
74
|
+
// form (so the glue builds against an older pin too).
|
|
75
|
+
val wire = SekyroWire.result(r)
|
|
76
|
+
(wire["level"] as? Int)?.takeIf { it in 0..3 }?.let { putInt("level", it) }
|
|
77
|
+
(wire["assurance"] as? String)?.takeIf { it.isNotEmpty() }?.let { putString("assurance", it) }
|
|
72
78
|
}
|
|
73
79
|
SekyroResult.Cancelled -> putString("status", "cancelled")
|
|
74
80
|
is SekyroResult.Failed -> { putString("status", "failed"); putString("code", r.code) }
|
|
@@ -16,6 +16,7 @@ import com.facebook.react.bridge.UiThreadUtil
|
|
|
16
16
|
import com.facebook.react.bridge.WritableMap
|
|
17
17
|
import java.util.concurrent.atomic.AtomicBoolean
|
|
18
18
|
import java.util.concurrent.atomic.AtomicInteger
|
|
19
|
+
import java.util.concurrent.atomic.AtomicReference
|
|
19
20
|
|
|
20
21
|
/**
|
|
21
22
|
* `SekyroReactNative` TurboModule: presents the native drop-in (SekyroActivity) and forwards its step events.
|
|
@@ -31,7 +32,8 @@ import java.util.concurrent.atomic.AtomicInteger
|
|
|
31
32
|
class SekyroReactNativeModule(context: ReactApplicationContext) : NativeSekyroReactNativeSpec(context) {
|
|
32
33
|
private val running = AtomicBoolean(false)
|
|
33
34
|
private val seq = AtomicInteger(0)
|
|
34
|
-
|
|
35
|
+
/** The running flow's promise; taken atomically, so a result and a teardown racing on two threads settle it once. */
|
|
36
|
+
private val pending = AtomicReference<Promise?>(null)
|
|
35
37
|
|
|
36
38
|
private val activityListener = object : BaseActivityEventListener() {
|
|
37
39
|
override fun onActivityResult(activity: Activity, requestCode: Int, resultCode: Int, data: Intent?) {
|
|
@@ -58,12 +60,12 @@ class SekyroReactNativeModule(context: ReactApplicationContext) : NativeSekyroRe
|
|
|
58
60
|
UiThreadUtil.runOnUiThread {
|
|
59
61
|
try {
|
|
60
62
|
if (activity.isFinishing || activity.isDestroyed) throw IllegalStateException("activity is finishing")
|
|
61
|
-
pending
|
|
63
|
+
pending.set(promise)
|
|
62
64
|
Sekyro.setEventListener { event -> emitOnEvent(toWire(event)) }
|
|
63
65
|
activity.startActivityForResult(SekyroContract().createIntent(activity, parsed), REQUEST_CODE)
|
|
64
66
|
} catch (_: Exception) {
|
|
65
67
|
// e.g. the activity is finishing, or the drop-in activity cannot be resolved.
|
|
66
|
-
pending
|
|
68
|
+
pending.set(null)
|
|
67
69
|
Sekyro.setEventListener(null)
|
|
68
70
|
running.set(false)
|
|
69
71
|
promise.reject("no_activity", "the foreground activity cannot launch the flow")
|
|
@@ -73,8 +75,7 @@ class SekyroReactNativeModule(context: ReactApplicationContext) : NativeSekyroRe
|
|
|
73
75
|
|
|
74
76
|
/** Settle the running flow once (a duplicate or late result is ignored). */
|
|
75
77
|
private fun settle(result: SekyroResult) {
|
|
76
|
-
val p = pending ?: return
|
|
77
|
-
pending = null
|
|
78
|
+
val p = pending.getAndSet(null) ?: return
|
|
78
79
|
Sekyro.setEventListener(null)
|
|
79
80
|
running.set(false)
|
|
80
81
|
p.resolve(ConfigMapper.toWire(result))
|
|
@@ -93,7 +94,11 @@ class SekyroReactNativeModule(context: ReactApplicationContext) : NativeSekyroRe
|
|
|
93
94
|
|
|
94
95
|
override fun invalidate() {
|
|
95
96
|
reactApplicationContext.removeActivityEventListener(activityListener)
|
|
96
|
-
// The React instance is going away with a flow still open:
|
|
97
|
+
// The React instance is going away with a flow still open: close the drop-in (its result has nowhere to go
|
|
98
|
+
// now, as on iOS) and settle the promise rather than leak it.
|
|
99
|
+
if (pending.get() != null) {
|
|
100
|
+
reactApplicationContext.currentActivity?.let { host -> UiThreadUtil.runOnUiThread { host.finishActivity(REQUEST_CODE) } }
|
|
101
|
+
}
|
|
97
102
|
settle(SekyroResult.Failed("flow_interrupted"))
|
|
98
103
|
Sekyro.setEventListener(null)
|
|
99
104
|
super.invalidate()
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var f=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var C=Object.prototype.hasOwnProperty;var O=(e,r)=>{for(var t in r)f(e,t,{get:r[t],enumerable:!0})},
|
|
1
|
+
"use strict";var f=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var C=Object.prototype.hasOwnProperty;var O=(e,r)=>{for(var t in r)f(e,t,{get:r[t],enumerable:!0})},b=(e,r,t,s)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of h(r))!C.call(e,n)&&n!==t&&f(e,n,{get:()=>r[n],enumerable:!(s=w(r,n))||s.enumerable});return e};var x=e=>b(f({},"__esModule",{value:!0}),e);var Y={};O(Y,{SDK_VERSION:()=>N,SekyroError:()=>l,SekyroFlow:()=>R,nativeVersion:()=>_,startSekyro:()=>y});module.exports=x(Y);var S=require("react-native"),c=S.TurboModuleRegistry.get("SekyroReactNative");var l=class extends Error{code;constructor(r,t=r){super(t),this.name="SekyroError",this.code=r}};var T=500,I=new Set(["ar","fr","en","es","pt","de"]),D=["brand","brandFg","bg","surface","fg","fgMuted","border"],F=["danger","success","warning"],k=!1,V=new Set(["clientToken","apiOrigin","locale","theme","strings","onEvent"]),L=/^#[0-9a-fA-F]{6}$/,M=/^http:\/\/(localhost|127\.0\.0\.1|10\.0\.2\.2)(:\d+)?$/,a=e=>{throw new l("invalid_config",`invalid config: ${e}`)};function g(e){(typeof e!="object"||e===null)&&a("config");for(let s of Object.keys(e))V.has(s)||a(`unknown key "${s.slice(0,32)}"`);(typeof e.clientToken!="string"||e.clientToken.length===0)&&a("clientToken");let r={clientToken:e.clientToken};e.apiOrigin!==void 0&&(typeof e.apiOrigin=="string"&&(/^https:\/\/[a-z0-9.-]+(:\d+)?$/i.test(e.apiOrigin)||__DEV__&&M.test(e.apiOrigin))||a("apiOrigin"),r.apiOrigin=e.apiOrigin),e.locale!==void 0&&(I.has(e.locale)||a("locale"),r.locale=e.locale);let t=e.theme;if(t){if(t.colors){let s={};for(let[n,i]of Object.entries(t.colors))if(i!==void 0){if(F.includes(n)){__DEV__&&!k&&(k=!0,console.warn("[sekyro] theme.colors.danger/success/warning are ignored: status colours are standard (removed in 1.0)"));continue}(!D.includes(n)||typeof i!="string"||!L.test(i))&&a(`theme.colors.${n.slice(0,32)}`),s[n]=i}r.colors=s}t.radius!==void 0&&((typeof t.radius!="number"||!Number.isFinite(t.radius)||t.radius<0||t.radius>32)&&a("theme.radius"),r.radius=t.radius),t.fontFamily!==void 0&&((typeof t.fontFamily!="string"||!/^[\w .-]{1,64}$/.test(t.fontFamily))&&a("theme.fontFamily"),r.fontFamily=t.fontFamily),t.darkMode!==void 0&&(["system","light","dark"].includes(t.darkMode)||a("theme.darkMode"),r.darkMode=t.darkMode)}if(e.strings){e.locale||a("strings need locale");let s=e.strings[e.locale]??{},n={},i=Object.entries(s).filter(([,o])=>o!==void 0);i.length>T&&a("strings (too many overrides)");for(let[o,p]of i)/^[a-zA-Z0-9_.]{1,96}$/.test(o)||a("strings key"),(typeof p!="string"||p.length>2e3)&&a(`strings.${o}`),n[o]=p;r.strings=n}return r}var $=new Set(["method","phone_otp","email_otp","registry","document","nfc","liveness","processing","result","update_required","eid","contact_choice","identity_summary","portrait"]);function v(e){if(e.type==="waiting_for_network")return{type:"waiting_for_network"};if(e.type!=="step"||!$.has(e.step))return null;let r=e.step,t=typeof e.retryReason=="string"&&/^[a-z0-9_]{1,64}$/.test(e.retryReason)?e.retryReason:void 0;return t?{type:"step",step:r,retryReason:t}:{type:"step",step:r}}var A=new Set(["approved","review_pending","rejected","expired"]),P=new Set([0,1,2,3]);function j(e){return typeof e=="string"&&e!==""}function m(e){return e.status==="cancelled"?{status:"cancelled"}:e.status==="failed"?{status:"failed",code:e.code||"unknown_error"}:e.status==="finished"&&e.sessionId&&A.has(e.displayStatus)?{status:"finished",sessionId:e.sessionId,displayStatus:e.displayStatus,...typeof e.level=="number"&&P.has(e.level)?{level:e.level}:{},...j(e.assurance)?{assurance:e.assurance}:{}}:{status:"failed",code:"unknown_error"}}function E(){if(!c)throw new l("unsupported_platform","the SekyroReactNative native module is not linked (New Architecture app, pod install / Gradle sync)");return c}var d=!1,K=new Set(["no_activity","unsupported_platform","flow_in_progress","invalid_config"]);async function y(e){let r=g(e),t=E();if(d)throw new l("flow_in_progress");d=!0;let s=e.onEvent,n=s?t.onEvent(i=>{let o=v(i);o&&s(o)}):void 0;try{return m(await t.start(r))}catch(i){let o=i?.code;if(typeof o=="string"&&K.has(o))throw new l(o);return{status:"failed",code:"unknown_error"}}finally{n?.remove(),d=!1}}function _(){return E().nativeVersion()}var u=require("react");function R(e){let r=(0,u.useRef)(null),t=(0,u.useRef)(e);return t.current=e,(0,u.useEffect)(()=>{if(r.current===e.clientToken)return;r.current=e.clientToken;let{onResult:s,onEvent:n,...i}=t.current;y({...i,onEvent:o=>t.current.onEvent?.(o)}).then(o=>t.current.onResult(o),o=>t.current.onResult({status:"failed",code:o instanceof l?o.code:"unknown_error"}))},[e.clientToken]),null}var N="0.1.0-rc.14";0&&(module.exports={SDK_VERSION,SekyroError,SekyroFlow,nativeVersion,startSekyro});
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** UI language of the native flow
|
|
1
|
+
/** UI language of the native flow; every screen is translated in each of the six (spec 2026-10-29 §9). @public */
|
|
2
2
|
type SekyroLocale = 'ar' | 'fr' | 'en' | 'es' | 'pt' | 'de';
|
|
3
3
|
/**
|
|
4
4
|
* Themeable colour roles, shared by the Android and iOS cores. `danger`, `success` and `warning` are deprecated: status
|
|
@@ -49,8 +49,8 @@ interface SekyroConfig {
|
|
|
49
49
|
/** e.g. `'https://api-staging.sekyro.ai'`; defaults to production. */
|
|
50
50
|
apiOrigin?: string;
|
|
51
51
|
/**
|
|
52
|
-
* UI language of the flow; required when `strings` is set.
|
|
53
|
-
*
|
|
52
|
+
* UI language of the flow; required when `strings` is set. Without it, the device language when it is one of the
|
|
53
|
+
* six, else French.
|
|
54
54
|
*/
|
|
55
55
|
locale?: SekyroLocale;
|
|
56
56
|
/** Colours, radius, font and colour scheme. */
|
|
@@ -65,11 +65,23 @@ interface SekyroConfig {
|
|
|
65
65
|
* asked to start again from your app), as on the native SDKs. @public
|
|
66
66
|
*/
|
|
67
67
|
type SekyroDisplayStatus = 'approved' | 'review_pending' | 'rejected' | 'expired';
|
|
68
|
+
/** The verification level a finished session proved (0 = rejected). @public */
|
|
69
|
+
type SekyroLevel = 0 | 1 | 2 | 3;
|
|
68
70
|
/** Display-only outcome; read the decision server-side (webhooks / `sessions.get`). @public */
|
|
69
71
|
type SekyroResult = {
|
|
70
72
|
status: 'finished';
|
|
71
73
|
sessionId: string;
|
|
72
74
|
displayStatus: SekyroDisplayStatus;
|
|
75
|
+
/**
|
|
76
|
+
* What the session proved (0 to 3, 0 = rejected), when the native SDK reports it (native 0.1.0-rc.13 on). Absent on
|
|
77
|
+
* an expired session and on older servers.
|
|
78
|
+
*/
|
|
79
|
+
level?: SekyroLevel;
|
|
80
|
+
/**
|
|
81
|
+
* How `level` was proved: `live_only`, `live_unique`, `document_biometric`, `chip_biometric`, `registry_biometric`,
|
|
82
|
+
* `supplied_biometric` or `eid_authenticated` (a newer server may add one). Absent when the server reports none.
|
|
83
|
+
*/
|
|
84
|
+
assurance?: string;
|
|
73
85
|
} | {
|
|
74
86
|
status: 'cancelled';
|
|
75
87
|
} | {
|
|
@@ -84,7 +96,7 @@ type SekyroResult = {
|
|
|
84
96
|
*/
|
|
85
97
|
declare function startSekyro(config: SekyroConfig): Promise<SekyroResult>;
|
|
86
98
|
/**
|
|
87
|
-
* Version of the bundled native core: `'android 0.1.0-rc.
|
|
99
|
+
* Version of the bundled native core: `'android 0.1.0-rc.13'` / `'ios 0.1.0-rc.13'`.
|
|
88
100
|
* @public
|
|
89
101
|
*/
|
|
90
102
|
declare function nativeVersion(): string;
|
|
@@ -116,4 +128,4 @@ declare class SekyroError extends Error {
|
|
|
116
128
|
*/
|
|
117
129
|
declare const SDK_VERSION: string;
|
|
118
130
|
|
|
119
|
-
export { SDK_VERSION, type SekyroColorRole, type SekyroConfig, type SekyroDisplayStatus, SekyroError, type SekyroErrorCode, type SekyroEvent, SekyroFlow, type SekyroFlowProps, type SekyroLocale, type SekyroResult, type SekyroStep, type SekyroTheme, nativeVersion, startSekyro };
|
|
131
|
+
export { SDK_VERSION, type SekyroColorRole, type SekyroConfig, type SekyroDisplayStatus, SekyroError, type SekyroErrorCode, type SekyroEvent, SekyroFlow, type SekyroFlowProps, type SekyroLevel, type SekyroLocale, type SekyroResult, type SekyroStep, type SekyroTheme, nativeVersion, startSekyro };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** UI language of the native flow
|
|
1
|
+
/** UI language of the native flow; every screen is translated in each of the six (spec 2026-10-29 §9). @public */
|
|
2
2
|
type SekyroLocale = 'ar' | 'fr' | 'en' | 'es' | 'pt' | 'de';
|
|
3
3
|
/**
|
|
4
4
|
* Themeable colour roles, shared by the Android and iOS cores. `danger`, `success` and `warning` are deprecated: status
|
|
@@ -49,8 +49,8 @@ interface SekyroConfig {
|
|
|
49
49
|
/** e.g. `'https://api-staging.sekyro.ai'`; defaults to production. */
|
|
50
50
|
apiOrigin?: string;
|
|
51
51
|
/**
|
|
52
|
-
* UI language of the flow; required when `strings` is set.
|
|
53
|
-
*
|
|
52
|
+
* UI language of the flow; required when `strings` is set. Without it, the device language when it is one of the
|
|
53
|
+
* six, else French.
|
|
54
54
|
*/
|
|
55
55
|
locale?: SekyroLocale;
|
|
56
56
|
/** Colours, radius, font and colour scheme. */
|
|
@@ -65,11 +65,23 @@ interface SekyroConfig {
|
|
|
65
65
|
* asked to start again from your app), as on the native SDKs. @public
|
|
66
66
|
*/
|
|
67
67
|
type SekyroDisplayStatus = 'approved' | 'review_pending' | 'rejected' | 'expired';
|
|
68
|
+
/** The verification level a finished session proved (0 = rejected). @public */
|
|
69
|
+
type SekyroLevel = 0 | 1 | 2 | 3;
|
|
68
70
|
/** Display-only outcome; read the decision server-side (webhooks / `sessions.get`). @public */
|
|
69
71
|
type SekyroResult = {
|
|
70
72
|
status: 'finished';
|
|
71
73
|
sessionId: string;
|
|
72
74
|
displayStatus: SekyroDisplayStatus;
|
|
75
|
+
/**
|
|
76
|
+
* What the session proved (0 to 3, 0 = rejected), when the native SDK reports it (native 0.1.0-rc.13 on). Absent on
|
|
77
|
+
* an expired session and on older servers.
|
|
78
|
+
*/
|
|
79
|
+
level?: SekyroLevel;
|
|
80
|
+
/**
|
|
81
|
+
* How `level` was proved: `live_only`, `live_unique`, `document_biometric`, `chip_biometric`, `registry_biometric`,
|
|
82
|
+
* `supplied_biometric` or `eid_authenticated` (a newer server may add one). Absent when the server reports none.
|
|
83
|
+
*/
|
|
84
|
+
assurance?: string;
|
|
73
85
|
} | {
|
|
74
86
|
status: 'cancelled';
|
|
75
87
|
} | {
|
|
@@ -84,7 +96,7 @@ type SekyroResult = {
|
|
|
84
96
|
*/
|
|
85
97
|
declare function startSekyro(config: SekyroConfig): Promise<SekyroResult>;
|
|
86
98
|
/**
|
|
87
|
-
* Version of the bundled native core: `'android 0.1.0-rc.
|
|
99
|
+
* Version of the bundled native core: `'android 0.1.0-rc.13'` / `'ios 0.1.0-rc.13'`.
|
|
88
100
|
* @public
|
|
89
101
|
*/
|
|
90
102
|
declare function nativeVersion(): string;
|
|
@@ -116,4 +128,4 @@ declare class SekyroError extends Error {
|
|
|
116
128
|
*/
|
|
117
129
|
declare const SDK_VERSION: string;
|
|
118
130
|
|
|
119
|
-
export { SDK_VERSION, type SekyroColorRole, type SekyroConfig, type SekyroDisplayStatus, SekyroError, type SekyroErrorCode, type SekyroEvent, SekyroFlow, type SekyroFlowProps, type SekyroLocale, type SekyroResult, type SekyroStep, type SekyroTheme, nativeVersion, startSekyro };
|
|
131
|
+
export { SDK_VERSION, type SekyroColorRole, type SekyroConfig, type SekyroDisplayStatus, SekyroError, type SekyroErrorCode, type SekyroEvent, SekyroFlow, type SekyroFlowProps, type SekyroLevel, type SekyroLocale, type SekyroResult, type SekyroStep, type SekyroTheme, nativeVersion, startSekyro };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{TurboModuleRegistry as
|
|
1
|
+
import{TurboModuleRegistry as m}from"react-native";var y=m.get("SekyroReactNative");var a=class extends Error{code;constructor(r,t=r){super(t),this.name="SekyroError",this.code=r}};var E=500,_=new Set(["ar","fr","en","es","pt","de"]),R=["brand","brandFg","bg","surface","fg","fgMuted","border"],N=["danger","success","warning"],c=!1,w=new Set(["clientToken","apiOrigin","locale","theme","strings","onEvent"]),h=/^#[0-9a-fA-F]{6}$/,C=/^http:\/\/(localhost|127\.0\.0\.1|10\.0\.2\.2)(:\d+)?$/,s=e=>{throw new a("invalid_config",`invalid config: ${e}`)};function d(e){(typeof e!="object"||e===null)&&s("config");for(let i of Object.keys(e))w.has(i)||s(`unknown key "${i.slice(0,32)}"`);(typeof e.clientToken!="string"||e.clientToken.length===0)&&s("clientToken");let r={clientToken:e.clientToken};e.apiOrigin!==void 0&&(typeof e.apiOrigin=="string"&&(/^https:\/\/[a-z0-9.-]+(:\d+)?$/i.test(e.apiOrigin)||__DEV__&&C.test(e.apiOrigin))||s("apiOrigin"),r.apiOrigin=e.apiOrigin),e.locale!==void 0&&(_.has(e.locale)||s("locale"),r.locale=e.locale);let t=e.theme;if(t){if(t.colors){let i={};for(let[l,n]of Object.entries(t.colors))if(n!==void 0){if(N.includes(l)){__DEV__&&!c&&(c=!0,console.warn("[sekyro] theme.colors.danger/success/warning are ignored: status colours are standard (removed in 1.0)"));continue}(!R.includes(l)||typeof n!="string"||!h.test(n))&&s(`theme.colors.${l.slice(0,32)}`),i[l]=n}r.colors=i}t.radius!==void 0&&((typeof t.radius!="number"||!Number.isFinite(t.radius)||t.radius<0||t.radius>32)&&s("theme.radius"),r.radius=t.radius),t.fontFamily!==void 0&&((typeof t.fontFamily!="string"||!/^[\w .-]{1,64}$/.test(t.fontFamily))&&s("theme.fontFamily"),r.fontFamily=t.fontFamily),t.darkMode!==void 0&&(["system","light","dark"].includes(t.darkMode)||s("theme.darkMode"),r.darkMode=t.darkMode)}if(e.strings){e.locale||s("strings need locale");let i=e.strings[e.locale]??{},l={},n=Object.entries(i).filter(([,o])=>o!==void 0);n.length>E&&s("strings (too many overrides)");for(let[o,u]of n)/^[a-zA-Z0-9_.]{1,96}$/.test(o)||s("strings key"),(typeof u!="string"||u.length>2e3)&&s(`strings.${o}`),l[o]=u;r.strings=l}return r}var O=new Set(["method","phone_otp","email_otp","registry","document","nfc","liveness","processing","result","update_required","eid","contact_choice","identity_summary","portrait"]);function S(e){if(e.type==="waiting_for_network")return{type:"waiting_for_network"};if(e.type!=="step"||!O.has(e.step))return null;let r=e.step,t=typeof e.retryReason=="string"&&/^[a-z0-9_]{1,64}$/.test(e.retryReason)?e.retryReason:void 0;return t?{type:"step",step:r,retryReason:t}:{type:"step",step:r}}var b=new Set(["approved","review_pending","rejected","expired"]),x=new Set([0,1,2,3]);function T(e){return typeof e=="string"&&e!==""}function k(e){return e.status==="cancelled"?{status:"cancelled"}:e.status==="failed"?{status:"failed",code:e.code||"unknown_error"}:e.status==="finished"&&e.sessionId&&b.has(e.displayStatus)?{status:"finished",sessionId:e.sessionId,displayStatus:e.displayStatus,...typeof e.level=="number"&&x.has(e.level)?{level:e.level}:{},...T(e.assurance)?{assurance:e.assurance}:{}}:{status:"failed",code:"unknown_error"}}function g(){if(!y)throw new a("unsupported_platform","the SekyroReactNative native module is not linked (New Architecture app, pod install / Gradle sync)");return y}var p=!1,I=new Set(["no_activity","unsupported_platform","flow_in_progress","invalid_config"]);async function f(e){let r=d(e),t=g();if(p)throw new a("flow_in_progress");p=!0;let i=e.onEvent,l=i?t.onEvent(n=>{let o=S(n);o&&i(o)}):void 0;try{return k(await t.start(r))}catch(n){let o=n?.code;if(typeof o=="string"&&I.has(o))throw new a(o);return{status:"failed",code:"unknown_error"}}finally{l?.remove(),p=!1}}function D(){return g().nativeVersion()}import{useEffect as F,useRef as v}from"react";function V(e){let r=v(null),t=v(e);return t.current=e,F(()=>{if(r.current===e.clientToken)return;r.current=e.clientToken;let{onResult:i,onEvent:l,...n}=t.current;f({...n,onEvent:o=>t.current.onEvent?.(o)}).then(o=>t.current.onResult(o),o=>t.current.onResult({status:"failed",code:o instanceof a?o.code:"unknown_error"}))},[e.clientToken]),null}var L="0.1.0-rc.14";export{L as SDK_VERSION,a as SekyroError,V as SekyroFlow,D as nativeVersion,f as startSekyro};
|
|
@@ -6,6 +6,12 @@
|
|
|
6
6
|
#else
|
|
7
7
|
#import "SekyroReactNative-Swift.h"
|
|
8
8
|
#endif
|
|
9
|
+
#import <React/RCTInvalidating.h>
|
|
10
|
+
|
|
11
|
+
// RCTInvalidating: React Native calls -invalidate when it tears this module down (reload, React instance or host
|
|
12
|
+
// destroyed). A flow still open then settles `failed / flow_interrupted`, as the Android module does.
|
|
13
|
+
@interface RCTSekyroReactNative () <RCTInvalidating>
|
|
14
|
+
@end
|
|
9
15
|
|
|
10
16
|
@implementation RCTSekyroReactNative
|
|
11
17
|
|
|
@@ -54,4 +60,13 @@
|
|
|
54
60
|
});
|
|
55
61
|
}
|
|
56
62
|
|
|
63
|
+
- (void)invalidate {
|
|
64
|
+
// SekyroRNBridge is main-actor state; React Native may call this from the module queue or the main thread.
|
|
65
|
+
if ([NSThread isMainThread]) {
|
|
66
|
+
[SekyroRNBridge invalidate];
|
|
67
|
+
} else {
|
|
68
|
+
dispatch_async(dispatch_get_main_queue(), ^{ [SekyroRNBridge invalidate]; });
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
57
72
|
@end
|
package/ios/SekyroRNBridge.swift
CHANGED
|
@@ -5,7 +5,6 @@ import UIKit
|
|
|
5
5
|
|
|
6
6
|
@objc(SekyroRNBridge)
|
|
7
7
|
public final class SekyroRNBridge: NSObject {
|
|
8
|
-
@MainActor private static var running = false
|
|
9
8
|
@MainActor private static var seq: Int32 = 0
|
|
10
9
|
|
|
11
10
|
@objc public static func nativeVersion() -> String { "ios \(Sekyro.sdkVersion)" }
|
|
@@ -53,15 +52,71 @@ public final class SekyroRNBridge: NSObject {
|
|
|
53
52
|
return SekyroConfig(clientToken: token, apiOrigin: origin, locale: locale, theme: theme)
|
|
54
53
|
}
|
|
55
54
|
|
|
55
|
+
/// The native SDK's own wire form (`SekyroWire.dictionary`): status, session id, display status, code, and the
|
|
56
|
+
/// person ids when the native SDK reports them (rc.13 on), without matching the result's associated values here.
|
|
56
57
|
static func wire(_ result: SekyroResult) -> NSDictionary {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
58
|
+
SekyroWire.dictionary(result) as NSDictionary
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/// What the promise of a flow torn down before its result resolves (the Android module's `invalidate` does the same).
|
|
62
|
+
static let interrupted: NSDictionary = ["status": "failed", "code": "flow_interrupted"]
|
|
63
|
+
|
|
64
|
+
/// One running flow. Its promise settles exactly once: with the flow's result (after the flow is dismissed), or
|
|
65
|
+
/// with `flow_interrupted` when the React instance is torn down or the flow goes away without a result.
|
|
66
|
+
@MainActor final class Run {
|
|
67
|
+
private var completion: ((NSDictionary) -> Void)?
|
|
68
|
+
/// The flow's result, held from the moment the flow hands it back until its dismissal ends.
|
|
69
|
+
private(set) var result: NSDictionary?
|
|
70
|
+
weak var flow: UIViewController?
|
|
71
|
+
|
|
72
|
+
init(completion: @escaping (NSDictionary) -> Void) { self.completion = completion }
|
|
73
|
+
|
|
74
|
+
var isSettled: Bool { completion == nil }
|
|
75
|
+
|
|
76
|
+
/// Records the flow's result; false when this run already has one or has settled (a late or duplicate result).
|
|
77
|
+
func record(_ result: NSDictionary) -> Bool {
|
|
78
|
+
guard self.result == nil, !isSettled else { return false }
|
|
79
|
+
self.result = result
|
|
80
|
+
return true
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/// Calls the completion once; later calls do nothing.
|
|
84
|
+
func settle(_ value: NSDictionary) {
|
|
85
|
+
guard let completion else { return }
|
|
86
|
+
self.completion = nil
|
|
87
|
+
completion(value)
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/// The running flow, if any: one at a time.
|
|
92
|
+
@MainActor private(set) static var current: Run?
|
|
93
|
+
|
|
94
|
+
@MainActor static func begin(completion: @escaping (NSDictionary) -> Void) -> Run {
|
|
95
|
+
let run = Run(completion: completion)
|
|
96
|
+
current = run
|
|
97
|
+
return run
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/// Ends `run`: frees the module for the next flow and settles the promise (a no-op once settled).
|
|
101
|
+
@MainActor static func finish(_ run: Run, with value: NSDictionary) {
|
|
102
|
+
if current === run { current = nil }
|
|
103
|
+
run.settle(value)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/// The flow is gone (dismissed and released) or the React instance is going away: settle with the result the flow
|
|
107
|
+
/// already handed back, else `flow_interrupted`.
|
|
108
|
+
@MainActor static func end(_ run: Run) {
|
|
109
|
+
finish(run, with: run.result ?? interrupted)
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/// Module invalidation (bridge reload, React instance teardown, new architecture host destroyed): closes a flow
|
|
113
|
+
/// that has no result yet and settles its promise, so the module is never left locked on `flow_in_progress`.
|
|
114
|
+
@MainActor @objc public static func invalidate() {
|
|
115
|
+
guard let run = current else { return }
|
|
116
|
+
if run.result == nil, let flow = run.flow, flow.presentingViewController != nil {
|
|
117
|
+
flow.dismiss(animated: false)
|
|
64
118
|
}
|
|
119
|
+
end(run)
|
|
65
120
|
}
|
|
66
121
|
|
|
67
122
|
/// Presents the drop-in. Returns nil when started, else an error code (`invalid_config`, `no_activity`, `flow_in_progress`).
|
|
@@ -69,12 +124,17 @@ public final class SekyroRNBridge: NSObject {
|
|
|
69
124
|
onEvent: @escaping (NSDictionary) -> Void,
|
|
70
125
|
completion: @escaping (NSDictionary) -> Void) -> String? {
|
|
71
126
|
guard let parsed = try? parse(config) else { return "invalid_config" }
|
|
72
|
-
guard
|
|
127
|
+
guard current == nil else { return "flow_in_progress" }
|
|
73
128
|
// UIKit only logs (and never calls back) when the presenter is off-window, mid-transition or
|
|
74
129
|
// already presenting — refuse up front so the promise can never stay pending.
|
|
75
130
|
guard let presenter = topViewController(), canPresent(from: presenter) else { return "no_activity" }
|
|
76
|
-
|
|
77
|
-
Sekyro.start(
|
|
131
|
+
let run = begin(completion: completion)
|
|
132
|
+
// Sekyro.start's own steps (present full screen, dismiss, then the result), with the flow kept in reach for a
|
|
133
|
+
// teardown and watched for going away without a result.
|
|
134
|
+
let flow = SekyroFlowViewController(config: parsed)
|
|
135
|
+
run.flow = flow
|
|
136
|
+
flow.onEvent = { event in
|
|
137
|
+
guard current === run, !run.isSettled else { return }
|
|
78
138
|
seq &+= 1
|
|
79
139
|
switch event {
|
|
80
140
|
case .step(let step, let reason):
|
|
@@ -84,10 +144,17 @@ public final class SekyroRNBridge: NSObject {
|
|
|
84
144
|
case .waitingForNetwork:
|
|
85
145
|
onEvent(["type": "waiting_for_network", "seq": NSNumber(value: seq)])
|
|
86
146
|
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
147
|
+
}
|
|
148
|
+
flow.onResult = { [weak flow] result in
|
|
149
|
+
guard run.record(wire(result)) else { return }
|
|
150
|
+
if let flow, flow.presentingViewController != nil {
|
|
151
|
+
flow.dismiss(animated: true) { end(run) }
|
|
152
|
+
} else {
|
|
153
|
+
end(run)
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
FlowWatch.attach(to: flow) { end(run) }
|
|
157
|
+
presenter.present(flow, animated: true)
|
|
91
158
|
return nil
|
|
92
159
|
}
|
|
93
160
|
|
|
@@ -111,3 +178,21 @@ public final class SekyroRNBridge: NSObject {
|
|
|
111
178
|
&& presenter.presentedViewController == nil
|
|
112
179
|
}
|
|
113
180
|
}
|
|
181
|
+
|
|
182
|
+
/// Calls `onGone` on the main actor once the flow controller it is attached to is released: the flow left the screen
|
|
183
|
+
/// (its own dismissal after a result, or the app dismissing it or replacing its window) and nothing holds it any more.
|
|
184
|
+
final class FlowWatch: NSObject {
|
|
185
|
+
private static var key: UInt8 = 0
|
|
186
|
+
private let onGone: @MainActor () -> Void
|
|
187
|
+
|
|
188
|
+
private init(_ onGone: @escaping @MainActor () -> Void) { self.onGone = onGone }
|
|
189
|
+
|
|
190
|
+
static func attach(to object: AnyObject, onGone: @escaping @MainActor () -> Void) {
|
|
191
|
+
objc_setAssociatedObject(object, &key, FlowWatch(onGone), .OBJC_ASSOCIATION_RETAIN_NONATOMIC)
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
deinit {
|
|
195
|
+
let onGone = onGone
|
|
196
|
+
Task { @MainActor in onGone() }
|
|
197
|
+
}
|
|
198
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sekyro/react-native",
|
|
3
|
-
"version": "0.1.0-rc.
|
|
3
|
+
"version": "0.1.0-rc.14",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Sekyro AI eKYC for React Native — glue over the binary Android and iOS SDKs (New Architecture)",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|
|
@@ -99,7 +99,7 @@
|
|
|
99
99
|
}
|
|
100
100
|
},
|
|
101
101
|
"sekyro": {
|
|
102
|
-
"android": "0.1.0-rc.
|
|
103
|
-
"ios": "0.1.0-rc.
|
|
102
|
+
"android": "0.1.0-rc.13",
|
|
103
|
+
"ios": "0.1.0-rc.13"
|
|
104
104
|
}
|
|
105
105
|
}
|
package/sbom.cdx.json
CHANGED
|
@@ -97,8 +97,8 @@
|
|
|
97
97
|
"type": "application",
|
|
98
98
|
"name": "react-native",
|
|
99
99
|
"group": "@sekyro",
|
|
100
|
-
"version": "0.1.0-rc.
|
|
101
|
-
"bom-ref": "@sekyro/react-native@0.1.0-rc.
|
|
100
|
+
"version": "0.1.0-rc.14",
|
|
101
|
+
"bom-ref": "@sekyro/react-native@0.1.0-rc.14",
|
|
102
102
|
"description": "Sekyro AI eKYC for React Native — glue over the binary Android and iOS SDKs (New Architecture)",
|
|
103
103
|
"licenses": [
|
|
104
104
|
{
|
|
@@ -108,7 +108,7 @@
|
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
110
|
],
|
|
111
|
-
"purl": "pkg:npm/%40sekyro/react-native@0.1.0-rc.
|
|
111
|
+
"purl": "pkg:npm/%40sekyro/react-native@0.1.0-rc.14?vcs_url=git%2Bhttps%3A%2F%2Fgithub.com%2FIBTIKAR-Technologies%2Fibtikar-identity.git%23sekyro-mobile%2Freact-native",
|
|
112
112
|
"externalReferences": [
|
|
113
113
|
{
|
|
114
114
|
"url": "https://github.com/IBTIKAR-Technologies/ibtikar-identity/issues",
|
|
@@ -147,7 +147,7 @@
|
|
|
147
147
|
"components": [],
|
|
148
148
|
"dependencies": [
|
|
149
149
|
{
|
|
150
|
-
"ref": "@sekyro/react-native@0.1.0-rc.
|
|
150
|
+
"ref": "@sekyro/react-native@0.1.0-rc.14"
|
|
151
151
|
}
|
|
152
152
|
]
|
|
153
153
|
}
|
|
@@ -31,7 +31,14 @@ export type NativeConfig = {
|
|
|
31
31
|
strings?: UnsafeObject;
|
|
32
32
|
};
|
|
33
33
|
|
|
34
|
-
export type NativeResult = {
|
|
34
|
+
export type NativeResult = {
|
|
35
|
+
status: string;
|
|
36
|
+
sessionId?: string;
|
|
37
|
+
displayStatus?: string;
|
|
38
|
+
code?: string;
|
|
39
|
+
level?: Int32;
|
|
40
|
+
assurance?: string;
|
|
41
|
+
};
|
|
35
42
|
|
|
36
43
|
export type NativeEvent = { type: string; step?: string; retryReason?: string; seq: Int32 };
|
|
37
44
|
|