@sekyro/react-native 0.1.0-rc.11 → 0.1.0-rc.13
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 +14 -0
- package/README.md +12 -5
- package/android/src/main/java/ai/sekyro/reactnative/SekyroReactNativeModule.kt +11 -6
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +1 -1
- package/ios/RCTSekyroReactNative.mm +15 -0
- package/ios/SekyroRNBridge.swift +98 -8
- package/package.json +3 -3
- package/sbom.cdx.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @sekyro/react-native
|
|
2
2
|
|
|
3
|
+
## 0.1.0-rc.13
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 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.
|
|
8
|
+
- 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.
|
|
9
|
+
- 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.
|
|
10
|
+
|
|
11
|
+
## 0.1.0-rc.12
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- ff8fb41: Pins the native SDKs 0.1.0-rc.11 (Android `ai.sekyro:sekyro-bom`, iOS `sekyro-ios-dist`): the finished result and the reference on the result screen carry the public session id (`ses_…`), the form `POST /sessions` and the webhooks use. Every API route accepts both forms, so a stored bare id keeps working.
|
|
16
|
+
|
|
3
17
|
## 0.1.0-rc.11
|
|
4
18
|
|
|
5
19
|
### 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
|
|
|
@@ -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})},x=(e,r,t,i)=>{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:!(i=w(r,n))||i.enumerable});return e};var b=e=>x(f({},"__esModule",{value:!0}),e);var L={};O(L,{SDK_VERSION:()=>N,SekyroError:()=>l,SekyroFlow:()=>R,nativeVersion:()=>E,startSekyro:()=>u});module.exports=b(L);var S=require("react-native"),d=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"]),M=/^#[0-9a-fA-F]{6}$/,$=/^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 i of Object.keys(e))V.has(i)||a(`unknown key "${i.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__&&$.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 i={};for(let[n,s]of Object.entries(t.colors))if(s!==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 s!="string"||!M.test(s))&&a(`theme.colors.${n.slice(0,32)}`),i[n]=s}r.colors=i}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 i=e.strings[e.locale]??{},n={},s=Object.entries(i).filter(([,o])=>o!==void 0);s.length>T&&a("strings (too many overrides)");for(let[o,y]of s)/^[a-zA-Z0-9_.]{1,96}$/.test(o)||a("strings key"),(typeof y!="string"||y.length>2e3)&&a(`strings.${o}`),n[o]=y;r.strings=n}return r}var A=new Set(["method","phone_otp","email_otp","registry","document","nfc","liveness","processing","result","update_required","eid","contact_choice","identity_summary","portrait"]);function m(e){if(e.type==="waiting_for_network")return{type:"waiting_for_network"};if(e.type!=="step"||!A.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 P=new Set(["approved","review_pending","rejected","expired"]);function v(e){return e.status==="cancelled"?{status:"cancelled"}:e.status==="failed"?{status:"failed",code:e.code||"unknown_error"}:e.status==="finished"&&e.sessionId&&P.has(e.displayStatus)?{status:"finished",sessionId:e.sessionId,displayStatus:e.displayStatus}:{status:"failed",code:"unknown_error"}}function _(){if(!d)throw new l("unsupported_platform","the SekyroReactNative native module is not linked (New Architecture app, pod install / Gradle sync)");return d}var c=!1,j=new Set(["no_activity","unsupported_platform","flow_in_progress","invalid_config"]);async function u(e){let r=g(e),t=_();if(c)throw new l("flow_in_progress");c=!0;let i=e.onEvent,n=i?t.onEvent(s=>{let o=m(s);o&&i(o)}):void 0;try{return v(await t.start(r))}catch(s){let o=s?.code;if(typeof o=="string"&&j.has(o))throw new l(o);return{status:"failed",code:"unknown_error"}}finally{n?.remove(),c=!1}}function E(){return _().nativeVersion()}var p=require("react");function R(e){let r=(0,p.useRef)(null),t=(0,p.useRef)(e);return t.current=e,(0,p.useEffect)(()=>{if(r.current===e.clientToken)return;r.current=e.clientToken;let{onResult:i,onEvent:n,...s}=t.current;u({...s,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.
|
|
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})},x=(e,r,t,i)=>{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:!(i=w(r,n))||i.enumerable});return e};var b=e=>x(f({},"__esModule",{value:!0}),e);var L={};O(L,{SDK_VERSION:()=>N,SekyroError:()=>l,SekyroFlow:()=>R,nativeVersion:()=>E,startSekyro:()=>u});module.exports=b(L);var S=require("react-native"),d=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"]),M=/^#[0-9a-fA-F]{6}$/,$=/^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 i of Object.keys(e))V.has(i)||a(`unknown key "${i.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__&&$.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 i={};for(let[n,s]of Object.entries(t.colors))if(s!==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 s!="string"||!M.test(s))&&a(`theme.colors.${n.slice(0,32)}`),i[n]=s}r.colors=i}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 i=e.strings[e.locale]??{},n={},s=Object.entries(i).filter(([,o])=>o!==void 0);s.length>T&&a("strings (too many overrides)");for(let[o,y]of s)/^[a-zA-Z0-9_.]{1,96}$/.test(o)||a("strings key"),(typeof y!="string"||y.length>2e3)&&a(`strings.${o}`),n[o]=y;r.strings=n}return r}var A=new Set(["method","phone_otp","email_otp","registry","document","nfc","liveness","processing","result","update_required","eid","contact_choice","identity_summary","portrait"]);function m(e){if(e.type==="waiting_for_network")return{type:"waiting_for_network"};if(e.type!=="step"||!A.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 P=new Set(["approved","review_pending","rejected","expired"]);function v(e){return e.status==="cancelled"?{status:"cancelled"}:e.status==="failed"?{status:"failed",code:e.code||"unknown_error"}:e.status==="finished"&&e.sessionId&&P.has(e.displayStatus)?{status:"finished",sessionId:e.sessionId,displayStatus:e.displayStatus}:{status:"failed",code:"unknown_error"}}function _(){if(!d)throw new l("unsupported_platform","the SekyroReactNative native module is not linked (New Architecture app, pod install / Gradle sync)");return d}var c=!1,j=new Set(["no_activity","unsupported_platform","flow_in_progress","invalid_config"]);async function u(e){let r=g(e),t=_();if(c)throw new l("flow_in_progress");c=!0;let i=e.onEvent,n=i?t.onEvent(s=>{let o=m(s);o&&i(o)}):void 0;try{return v(await t.start(r))}catch(s){let o=s?.code;if(typeof o=="string"&&j.has(o))throw new l(o);return{status:"failed",code:"unknown_error"}}finally{n?.remove(),c=!1}}function E(){return _().nativeVersion()}var p=require("react");function R(e){let r=(0,p.useRef)(null),t=(0,p.useRef)(e);return t.current=e,(0,p.useEffect)(()=>{if(r.current===e.clientToken)return;r.current=e.clientToken;let{onResult:i,onEvent:n,...s}=t.current;u({...s,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.13";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. */
|
|
@@ -84,7 +84,7 @@ type SekyroResult = {
|
|
|
84
84
|
*/
|
|
85
85
|
declare function startSekyro(config: SekyroConfig): Promise<SekyroResult>;
|
|
86
86
|
/**
|
|
87
|
-
* Version of the bundled native core: `'android 0.1.0-rc.
|
|
87
|
+
* Version of the bundled native core: `'android 0.1.0-rc.12'` / `'ios 0.1.0-rc.12'`.
|
|
88
88
|
* @public
|
|
89
89
|
*/
|
|
90
90
|
declare function nativeVersion(): string;
|
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. */
|
|
@@ -84,7 +84,7 @@ type SekyroResult = {
|
|
|
84
84
|
*/
|
|
85
85
|
declare function startSekyro(config: SekyroConfig): Promise<SekyroResult>;
|
|
86
86
|
/**
|
|
87
|
-
* Version of the bundled native core: `'android 0.1.0-rc.
|
|
87
|
+
* Version of the bundled native core: `'android 0.1.0-rc.12'` / `'ios 0.1.0-rc.12'`.
|
|
88
88
|
* @public
|
|
89
89
|
*/
|
|
90
90
|
declare function nativeVersion(): string;
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{TurboModuleRegistry as v}from"react-native";var u=v.get("SekyroReactNative");var a=class extends Error{code;constructor(r,t=r){super(t),this.name="SekyroError",this.code=r}};var _=500,E=new Set(["ar","fr","en","es","pt","de"]),R=["brand","brandFg","bg","surface","fg","fgMuted","border"],N=["danger","success","warning"],d=!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+)?$/,i=e=>{throw new a("invalid_config",`invalid config: ${e}`)};function c(e){(typeof e!="object"||e===null)&&i("config");for(let s of Object.keys(e))w.has(s)||i(`unknown key "${s.slice(0,32)}"`);(typeof e.clientToken!="string"||e.clientToken.length===0)&&i("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))||i("apiOrigin"),r.apiOrigin=e.apiOrigin),e.locale!==void 0&&(E.has(e.locale)||i("locale"),r.locale=e.locale);let t=e.theme;if(t){if(t.colors){let s={};for(let[l,n]of Object.entries(t.colors))if(n!==void 0){if(N.includes(l)){__DEV__&&!d&&(d=!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))&&i(`theme.colors.${l.slice(0,32)}`),s[l]=n}r.colors=s}t.radius!==void 0&&((typeof t.radius!="number"||!Number.isFinite(t.radius)||t.radius<0||t.radius>32)&&i("theme.radius"),r.radius=t.radius),t.fontFamily!==void 0&&((typeof t.fontFamily!="string"||!/^[\w .-]{1,64}$/.test(t.fontFamily))&&i("theme.fontFamily"),r.fontFamily=t.fontFamily),t.darkMode!==void 0&&(["system","light","dark"].includes(t.darkMode)||i("theme.darkMode"),r.darkMode=t.darkMode)}if(e.strings){e.locale||i("strings need locale");let s=e.strings[e.locale]??{},l={},n=Object.entries(s).filter(([,o])=>o!==void 0);n.length>_&&i("strings (too many overrides)");for(let[o,p]of n)/^[a-zA-Z0-9_.]{1,96}$/.test(o)||i("strings key"),(typeof p!="string"||p.length>2e3)&&i(`strings.${o}`),l[o]=p;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 x=new Set(["approved","review_pending","rejected","expired"]);function k(e){return e.status==="cancelled"?{status:"cancelled"}:e.status==="failed"?{status:"failed",code:e.code||"unknown_error"}:e.status==="finished"&&e.sessionId&&x.has(e.displayStatus)?{status:"finished",sessionId:e.sessionId,displayStatus:e.displayStatus}:{status:"failed",code:"unknown_error"}}function g(){if(!u)throw new a("unsupported_platform","the SekyroReactNative native module is not linked (New Architecture app, pod install / Gradle sync)");return u}var y=!1,b=new Set(["no_activity","unsupported_platform","flow_in_progress","invalid_config"]);async function f(e){let r=c(e),t=g();if(y)throw new a("flow_in_progress");y=!0;let s=e.onEvent,l=s?t.onEvent(n=>{let o=S(n);o&&s(o)}):void 0;try{return k(await t.start(r))}catch(n){let o=n?.code;if(typeof o=="string"&&b.has(o))throw new a(o);return{status:"failed",code:"unknown_error"}}finally{l?.remove(),y=!1}}function T(){return g().nativeVersion()}import{useEffect as I,useRef as m}from"react";function D(e){let r=m(null),t=m(e);return t.current=e,I(()=>{if(r.current===e.clientToken)return;r.current=e.clientToken;let{onResult:s,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 F="0.1.0-rc.
|
|
1
|
+
import{TurboModuleRegistry as v}from"react-native";var u=v.get("SekyroReactNative");var a=class extends Error{code;constructor(r,t=r){super(t),this.name="SekyroError",this.code=r}};var _=500,E=new Set(["ar","fr","en","es","pt","de"]),R=["brand","brandFg","bg","surface","fg","fgMuted","border"],N=["danger","success","warning"],d=!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+)?$/,i=e=>{throw new a("invalid_config",`invalid config: ${e}`)};function c(e){(typeof e!="object"||e===null)&&i("config");for(let s of Object.keys(e))w.has(s)||i(`unknown key "${s.slice(0,32)}"`);(typeof e.clientToken!="string"||e.clientToken.length===0)&&i("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))||i("apiOrigin"),r.apiOrigin=e.apiOrigin),e.locale!==void 0&&(E.has(e.locale)||i("locale"),r.locale=e.locale);let t=e.theme;if(t){if(t.colors){let s={};for(let[l,n]of Object.entries(t.colors))if(n!==void 0){if(N.includes(l)){__DEV__&&!d&&(d=!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))&&i(`theme.colors.${l.slice(0,32)}`),s[l]=n}r.colors=s}t.radius!==void 0&&((typeof t.radius!="number"||!Number.isFinite(t.radius)||t.radius<0||t.radius>32)&&i("theme.radius"),r.radius=t.radius),t.fontFamily!==void 0&&((typeof t.fontFamily!="string"||!/^[\w .-]{1,64}$/.test(t.fontFamily))&&i("theme.fontFamily"),r.fontFamily=t.fontFamily),t.darkMode!==void 0&&(["system","light","dark"].includes(t.darkMode)||i("theme.darkMode"),r.darkMode=t.darkMode)}if(e.strings){e.locale||i("strings need locale");let s=e.strings[e.locale]??{},l={},n=Object.entries(s).filter(([,o])=>o!==void 0);n.length>_&&i("strings (too many overrides)");for(let[o,p]of n)/^[a-zA-Z0-9_.]{1,96}$/.test(o)||i("strings key"),(typeof p!="string"||p.length>2e3)&&i(`strings.${o}`),l[o]=p;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 x=new Set(["approved","review_pending","rejected","expired"]);function k(e){return e.status==="cancelled"?{status:"cancelled"}:e.status==="failed"?{status:"failed",code:e.code||"unknown_error"}:e.status==="finished"&&e.sessionId&&x.has(e.displayStatus)?{status:"finished",sessionId:e.sessionId,displayStatus:e.displayStatus}:{status:"failed",code:"unknown_error"}}function g(){if(!u)throw new a("unsupported_platform","the SekyroReactNative native module is not linked (New Architecture app, pod install / Gradle sync)");return u}var y=!1,b=new Set(["no_activity","unsupported_platform","flow_in_progress","invalid_config"]);async function f(e){let r=c(e),t=g();if(y)throw new a("flow_in_progress");y=!0;let s=e.onEvent,l=s?t.onEvent(n=>{let o=S(n);o&&s(o)}):void 0;try{return k(await t.start(r))}catch(n){let o=n?.code;if(typeof o=="string"&&b.has(o))throw new a(o);return{status:"failed",code:"unknown_error"}}finally{l?.remove(),y=!1}}function T(){return g().nativeVersion()}import{useEffect as I,useRef as m}from"react";function D(e){let r=m(null),t=m(e);return t.current=e,I(()=>{if(r.current===e.clientToken)return;r.current=e.clientToken;let{onResult:s,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 F="0.1.0-rc.13";export{F as SDK_VERSION,a as SekyroError,D as SekyroFlow,T 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)" }
|
|
@@ -64,17 +63,83 @@ public final class SekyroRNBridge: NSObject {
|
|
|
64
63
|
}
|
|
65
64
|
}
|
|
66
65
|
|
|
66
|
+
/// What the promise of a flow torn down before its result resolves (the Android module's `invalidate` does the same).
|
|
67
|
+
static let interrupted: NSDictionary = ["status": "failed", "code": "flow_interrupted"]
|
|
68
|
+
|
|
69
|
+
/// One running flow. Its promise settles exactly once: with the flow's result (after the flow is dismissed), or
|
|
70
|
+
/// with `flow_interrupted` when the React instance is torn down or the flow goes away without a result.
|
|
71
|
+
@MainActor final class Run {
|
|
72
|
+
private var completion: ((NSDictionary) -> Void)?
|
|
73
|
+
/// The flow's result, held from the moment the flow hands it back until its dismissal ends.
|
|
74
|
+
private(set) var result: NSDictionary?
|
|
75
|
+
weak var flow: UIViewController?
|
|
76
|
+
|
|
77
|
+
init(completion: @escaping (NSDictionary) -> Void) { self.completion = completion }
|
|
78
|
+
|
|
79
|
+
var isSettled: Bool { completion == nil }
|
|
80
|
+
|
|
81
|
+
/// Records the flow's result; false when this run already has one or has settled (a late or duplicate result).
|
|
82
|
+
func record(_ result: NSDictionary) -> Bool {
|
|
83
|
+
guard self.result == nil, !isSettled else { return false }
|
|
84
|
+
self.result = result
|
|
85
|
+
return true
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/// Calls the completion once; later calls do nothing.
|
|
89
|
+
func settle(_ value: NSDictionary) {
|
|
90
|
+
guard let completion else { return }
|
|
91
|
+
self.completion = nil
|
|
92
|
+
completion(value)
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/// The running flow, if any: one at a time.
|
|
97
|
+
@MainActor private(set) static var current: Run?
|
|
98
|
+
|
|
99
|
+
@MainActor static func begin(completion: @escaping (NSDictionary) -> Void) -> Run {
|
|
100
|
+
let run = Run(completion: completion)
|
|
101
|
+
current = run
|
|
102
|
+
return run
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/// Ends `run`: frees the module for the next flow and settles the promise (a no-op once settled).
|
|
106
|
+
@MainActor static func finish(_ run: Run, with value: NSDictionary) {
|
|
107
|
+
if current === run { current = nil }
|
|
108
|
+
run.settle(value)
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/// The flow is gone (dismissed and released) or the React instance is going away: settle with the result the flow
|
|
112
|
+
/// already handed back, else `flow_interrupted`.
|
|
113
|
+
@MainActor static func end(_ run: Run) {
|
|
114
|
+
finish(run, with: run.result ?? interrupted)
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/// Module invalidation (bridge reload, React instance teardown, new architecture host destroyed): closes a flow
|
|
118
|
+
/// that has no result yet and settles its promise, so the module is never left locked on `flow_in_progress`.
|
|
119
|
+
@MainActor @objc public static func invalidate() {
|
|
120
|
+
guard let run = current else { return }
|
|
121
|
+
if run.result == nil, let flow = run.flow, flow.presentingViewController != nil {
|
|
122
|
+
flow.dismiss(animated: false)
|
|
123
|
+
}
|
|
124
|
+
end(run)
|
|
125
|
+
}
|
|
126
|
+
|
|
67
127
|
/// Presents the drop-in. Returns nil when started, else an error code (`invalid_config`, `no_activity`, `flow_in_progress`).
|
|
68
128
|
@MainActor @objc public static func start(_ config: NSDictionary,
|
|
69
129
|
onEvent: @escaping (NSDictionary) -> Void,
|
|
70
130
|
completion: @escaping (NSDictionary) -> Void) -> String? {
|
|
71
131
|
guard let parsed = try? parse(config) else { return "invalid_config" }
|
|
72
|
-
guard
|
|
132
|
+
guard current == nil else { return "flow_in_progress" }
|
|
73
133
|
// UIKit only logs (and never calls back) when the presenter is off-window, mid-transition or
|
|
74
134
|
// already presenting — refuse up front so the promise can never stay pending.
|
|
75
135
|
guard let presenter = topViewController(), canPresent(from: presenter) else { return "no_activity" }
|
|
76
|
-
|
|
77
|
-
Sekyro.start(
|
|
136
|
+
let run = begin(completion: completion)
|
|
137
|
+
// Sekyro.start's own steps (present full screen, dismiss, then the result), with the flow kept in reach for a
|
|
138
|
+
// teardown and watched for going away without a result.
|
|
139
|
+
let flow = SekyroFlowViewController(config: parsed)
|
|
140
|
+
run.flow = flow
|
|
141
|
+
flow.onEvent = { event in
|
|
142
|
+
guard current === run, !run.isSettled else { return }
|
|
78
143
|
seq &+= 1
|
|
79
144
|
switch event {
|
|
80
145
|
case .step(let step, let reason):
|
|
@@ -84,10 +149,17 @@ public final class SekyroRNBridge: NSObject {
|
|
|
84
149
|
case .waitingForNetwork:
|
|
85
150
|
onEvent(["type": "waiting_for_network", "seq": NSNumber(value: seq)])
|
|
86
151
|
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
152
|
+
}
|
|
153
|
+
flow.onResult = { [weak flow] result in
|
|
154
|
+
guard run.record(wire(result)) else { return }
|
|
155
|
+
if let flow, flow.presentingViewController != nil {
|
|
156
|
+
flow.dismiss(animated: true) { end(run) }
|
|
157
|
+
} else {
|
|
158
|
+
end(run)
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
FlowWatch.attach(to: flow) { end(run) }
|
|
162
|
+
presenter.present(flow, animated: true)
|
|
91
163
|
return nil
|
|
92
164
|
}
|
|
93
165
|
|
|
@@ -111,3 +183,21 @@ public final class SekyroRNBridge: NSObject {
|
|
|
111
183
|
&& presenter.presentedViewController == nil
|
|
112
184
|
}
|
|
113
185
|
}
|
|
186
|
+
|
|
187
|
+
/// Calls `onGone` on the main actor once the flow controller it is attached to is released: the flow left the screen
|
|
188
|
+
/// (its own dismissal after a result, or the app dismissing it or replacing its window) and nothing holds it any more.
|
|
189
|
+
final class FlowWatch: NSObject {
|
|
190
|
+
private static var key: UInt8 = 0
|
|
191
|
+
private let onGone: @MainActor () -> Void
|
|
192
|
+
|
|
193
|
+
private init(_ onGone: @escaping @MainActor () -> Void) { self.onGone = onGone }
|
|
194
|
+
|
|
195
|
+
static func attach(to object: AnyObject, onGone: @escaping @MainActor () -> Void) {
|
|
196
|
+
objc_setAssociatedObject(object, &key, FlowWatch(onGone), .OBJC_ASSOCIATION_RETAIN_NONATOMIC)
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
deinit {
|
|
200
|
+
let onGone = onGone
|
|
201
|
+
Task { @MainActor in onGone() }
|
|
202
|
+
}
|
|
203
|
+
}
|
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.13",
|
|
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.12",
|
|
103
|
+
"ios": "0.1.0-rc.12"
|
|
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.13",
|
|
101
|
+
"bom-ref": "@sekyro/react-native@0.1.0-rc.13",
|
|
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.13?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.13"
|
|
151
151
|
}
|
|
152
152
|
]
|
|
153
153
|
}
|