@velion-la/onboarding-sdk-react-native 1.0.0-beta.3 → 1.0.0-beta.5
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/app.plugin.js +101 -0
- package/lib/commonjs/camera/LivenessCamera.js +85 -6
- package/lib/commonjs/camera/LivenessCamera.js.map +1 -1
- package/lib/commonjs/core/VelionOnboarding.js +17 -3
- package/lib/commonjs/core/VelionOnboarding.js.map +1 -1
- package/lib/commonjs/steps/DocumentsOcrStep.js +8 -4
- package/lib/commonjs/steps/DocumentsOcrStep.js.map +1 -1
- package/lib/commonjs/steps/LivenessMatchStep.js +435 -11
- package/lib/commonjs/steps/LivenessMatchStep.js.map +1 -1
- package/lib/commonjs/types/index.js +16 -0
- package/lib/commonjs/types/index.js.map +1 -1
- package/lib/commonjs/utils/googleMapsPreflight.js +20 -9
- package/lib/commonjs/utils/googleMapsPreflight.js.map +1 -1
- package/lib/commonjs/utils/velionExtra.js +48 -0
- package/lib/commonjs/utils/velionExtra.js.map +1 -0
- package/lib/module/camera/LivenessCamera.js +86 -7
- package/lib/module/camera/LivenessCamera.js.map +1 -1
- package/lib/module/core/VelionOnboarding.js +17 -3
- package/lib/module/core/VelionOnboarding.js.map +1 -1
- package/lib/module/steps/DocumentsOcrStep.js +9 -5
- package/lib/module/steps/DocumentsOcrStep.js.map +1 -1
- package/lib/module/steps/LivenessMatchStep.js +434 -11
- package/lib/module/steps/LivenessMatchStep.js.map +1 -1
- package/lib/module/types/index.js +19 -0
- package/lib/module/types/index.js.map +1 -1
- package/lib/module/utils/googleMapsPreflight.js +20 -9
- package/lib/module/utils/googleMapsPreflight.js.map +1 -1
- package/lib/module/utils/velionExtra.js +44 -0
- package/lib/module/utils/velionExtra.js.map +1 -0
- package/lib/typescript/camera/LivenessCamera.d.ts +18 -1
- package/lib/typescript/camera/LivenessCamera.d.ts.map +1 -1
- package/lib/typescript/core/VelionOnboarding.d.ts.map +1 -1
- package/lib/typescript/steps/LivenessMatchStep.d.ts.map +1 -1
- package/lib/typescript/steps/types.d.ts +7 -1
- package/lib/typescript/steps/types.d.ts.map +1 -1
- package/lib/typescript/types/index.d.ts +57 -0
- package/lib/typescript/types/index.d.ts.map +1 -1
- package/lib/typescript/utils/googleMapsPreflight.d.ts +15 -7
- package/lib/typescript/utils/googleMapsPreflight.d.ts.map +1 -1
- package/lib/typescript/utils/velionExtra.d.ts +24 -0
- package/lib/typescript/utils/velionExtra.d.ts.map +1 -0
- package/package.json +9 -2
- package/src/camera/LivenessCamera.tsx +100 -3
- package/src/core/VelionOnboarding.ts +18 -3
- package/src/steps/DocumentsOcrStep.tsx +7 -3
- package/src/steps/LivenessMatchStep.tsx +449 -11
- package/src/steps/types.ts +7 -1
- package/src/types/index.ts +61 -0
- package/src/utils/googleMapsPreflight.ts +27 -10
- package/src/utils/velionExtra.ts +46 -0
|
@@ -42,13 +42,21 @@ export function isReactNativeMapsAvailable(): boolean {
|
|
|
42
42
|
*
|
|
43
43
|
* Returns:
|
|
44
44
|
* - `true` on iOS (the check does not apply — Apple Maps needs no key).
|
|
45
|
-
* - `true` when we can confirm the key is wired via the Expo config
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
45
|
+
* - `true` when we can confirm the key is wired via the Expo config. We look
|
|
46
|
+
* at two places, in order:
|
|
47
|
+
* a) `extra.velionGoogleMapsApiKey` — the value the SDK's own
|
|
48
|
+
* config plugin publishes specifically for runtime. This is
|
|
49
|
+
* the reliable source: `extra` is always serialized into
|
|
50
|
+
* `Constants.expoConfig`.
|
|
51
|
+
* b) `android.config.googleMaps.apiKey` — the prebuild-canonical
|
|
52
|
+
* location that produces the manifest meta-data. Config-plugin
|
|
53
|
+
* mutations to `android.config` are NOT reliably reflected in
|
|
54
|
+
* the runtime `Constants.expoConfig`, so this is only a
|
|
55
|
+
* secondary signal (true when the host set it statically).
|
|
56
|
+
* Either being present is a reliable proxy for the real meta-data.
|
|
57
|
+
* - `false` when `expo-constants` is available AND neither location declares
|
|
58
|
+
* the key — we know prebuild produced a manifest without the
|
|
59
|
+
* meta-data, so mounting `<MapView>` would crash.
|
|
52
60
|
* - `undefined` when `expo-constants` is not installed (bare RN). We cannot
|
|
53
61
|
* probe the manifest without a custom native module; the caller
|
|
54
62
|
* should default to the previous behaviour (trust the integrator
|
|
@@ -65,8 +73,17 @@ export function isAndroidGoogleMapsKeyInManifest(): boolean | undefined {
|
|
|
65
73
|
return undefined;
|
|
66
74
|
}
|
|
67
75
|
const expoConfig = (Constants as { expoConfig?: unknown } | undefined)?.expoConfig as
|
|
68
|
-
| {
|
|
76
|
+
| {
|
|
77
|
+
extra?: { velionGoogleMapsApiKey?: unknown };
|
|
78
|
+
android?: { config?: { googleMaps?: { apiKey?: unknown } } };
|
|
79
|
+
}
|
|
69
80
|
| undefined;
|
|
70
|
-
|
|
71
|
-
|
|
81
|
+
// Primary: the value the SDK config plugin publishes for runtime via `extra`.
|
|
82
|
+
// Secondary: the prebuild-canonical `android.config.googleMaps.apiKey` (only
|
|
83
|
+
// present in runtime config when the host set it statically in app.config).
|
|
84
|
+
const candidates = [
|
|
85
|
+
expoConfig?.extra?.velionGoogleMapsApiKey,
|
|
86
|
+
expoConfig?.android?.config?.googleMaps?.apiKey,
|
|
87
|
+
];
|
|
88
|
+
return candidates.some((key) => typeof key === 'string' && key.trim().length > 0);
|
|
72
89
|
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reads values that the SDK's Expo config plugin (`app.plugin.js`) stashed
|
|
3
|
+
* under `expoConfig.extra.*` during `expo prebuild`.
|
|
4
|
+
*
|
|
5
|
+
* The plugin lives at the package root and is meant to be registered by
|
|
6
|
+
* host apps. When it is, it copies the values it received from
|
|
7
|
+
* `app.json` into Expo's `extra` namespace so they survive into the
|
|
8
|
+
* runtime config exposed by `expo-constants`. This module is the runtime
|
|
9
|
+
* side of that hand-off.
|
|
10
|
+
*
|
|
11
|
+
* On bare React Native (no `expo-constants` installed) every getter
|
|
12
|
+
* returns `undefined`, and the SDK falls back to whatever the host
|
|
13
|
+
* passed via `VelionConfig`.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
interface VelionExtra {
|
|
17
|
+
velionGoogleMapsApiKey?: unknown;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function readVelionExtra(): VelionExtra | undefined {
|
|
21
|
+
let Constants: unknown;
|
|
22
|
+
try {
|
|
23
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires
|
|
24
|
+
const mod = require('expo-constants');
|
|
25
|
+
Constants = mod?.default ?? mod;
|
|
26
|
+
} catch {
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
const expoConfig = (Constants as { expoConfig?: { extra?: unknown } } | undefined)
|
|
30
|
+
?.expoConfig;
|
|
31
|
+
return expoConfig?.extra as VelionExtra | undefined;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Returns the Google Maps API key the plugin wrote to
|
|
36
|
+
* `expoConfig.extra.velionGoogleMapsApiKey`, or `undefined` when the
|
|
37
|
+
* plugin wasn't registered or the value isn't a non-empty string.
|
|
38
|
+
*
|
|
39
|
+
* Hosts that pass `VelionConfig.googleMapsApiKey` at runtime take
|
|
40
|
+
* precedence over this value — see `VelionOnboarding`.
|
|
41
|
+
*/
|
|
42
|
+
export function getGoogleMapsApiKeyFromExpoExtra(): string | undefined {
|
|
43
|
+
const extra = readVelionExtra();
|
|
44
|
+
const key = extra?.velionGoogleMapsApiKey;
|
|
45
|
+
return typeof key === 'string' && key.trim().length > 0 ? key.trim() : undefined;
|
|
46
|
+
}
|