@proxze/kyc-react-native 0.1.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.
package/LICENSE ADDED
@@ -0,0 +1,51 @@
1
+ Proxze KYC React Native SDK — Proprietary Software License
2
+
3
+ Copyright (c) 2026 Sage Grey Technologies Limited. All rights reserved.
4
+
5
+ This software and its associated files (the "Software") are the proprietary
6
+ property of Sage Grey Technologies Limited ("Proxze"). The Software is made
7
+ available through the public npm registry for convenience of installation
8
+ only; its availability there does not place it in the public domain or under
9
+ any open-source license.
10
+
11
+ 1. Grant of use. Subject to the terms below, Proxze grants you a limited,
12
+ non-exclusive, non-transferable, revocable license to install the Software
13
+ and incorporate it, unmodified, into your applications solely for the
14
+ purpose of integrating with Proxze services under a valid agreement with
15
+ Proxze.
16
+
17
+ 2. Restrictions. Except as expressly permitted in writing by Proxze, you may
18
+ not:
19
+ a. modify, adapt, translate or create derivative works of the Software;
20
+ b. copy, publish, distribute, sublicense, sell, lease or otherwise make
21
+ the Software, or any modified version or portion of it, available to
22
+ any third party, whether under an open-source license or otherwise;
23
+ c. reverse engineer the Software or use it to build a competing product
24
+ or service;
25
+ d. remove or alter any copyright, license or proprietary notices.
26
+
27
+ Distribution of the Software solely as a compiled, embedded component of
28
+ your own application, for the purpose in section 1, is permitted.
29
+
30
+ 3. Ownership. Proxze retains all right, title and interest in the Software,
31
+ including all intellectual property rights. No rights are granted except
32
+ as expressly stated in this license.
33
+
34
+ 4. Termination. This license terminates automatically if you breach any of
35
+ its terms or your agreement with Proxze ends. On termination you must
36
+ stop using the Software and delete all copies in your possession.
37
+
38
+ 5. No warranty. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
39
+ KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
40
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
41
+
42
+ 6. Limitation of liability. IN NO EVENT SHALL PROXZE OR SAGE GREY
43
+ TECHNOLOGIES LIMITED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
44
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
45
+ OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
46
+ SOFTWARE.
47
+
48
+ 7. Governing law. This license is governed by the laws of the Federal
49
+ Republic of Nigeria.
50
+
51
+ For licensing enquiries, contact Sage Grey Technologies Limited.
package/README.md ADDED
@@ -0,0 +1,216 @@
1
+ # @proxze/kyc-react-native
2
+
3
+ Proxze Enterprise Address KYC SDK. Embeds passive geofence-based address
4
+ verification into a bank's React Native app: NDPR consent, night-presence
5
+ tracking (12AM–5AM, 3 consecutive nights), utility-bill upload and optional
6
+ daily video KYC — against `proxze-kyc-service`'s `/v2/sdk/*` surface.
7
+
8
+ ## Install
9
+
10
+ ```sh
11
+ yarn add @proxze/kyc-react-native
12
+ # recommended peers
13
+ yarn add react-native-background-geolocation @react-native-async-storage/async-storage
14
+ ```
15
+
16
+ `react-native-background-geolocation` (licensed, Transistorsoft) powers the
17
+ default location adapter — Google Play Services fused location + Geofencing API
18
+ on Android, CoreLocation region monitoring on iOS. It is an **optional** peer:
19
+ a bank with its own location stack can implement the `LocationAdapter`
20
+ interface instead and skip the dependency entirely.
21
+
22
+ `@react-native-async-storage/async-storage` persists the offline event queue.
23
+ Also optional — without it the queue lives in memory only (events survive
24
+ connectivity loss but not a process kill).
25
+
26
+ ## Security model
27
+
28
+ The app only ever holds a **session token** (`pst_…`) scoped to one
29
+ verification. The bank's `pxz_live_…` API key stays on the bank's backend:
30
+
31
+ 1. Bank backend calls `POST /v2/kyc/initiate` with its API key.
32
+ 2. It hands the returned `session_token` to the app (its own auth channel).
33
+ 3. The app drives this SDK with that token; the token can only report evidence
34
+ for its own session and dies when the verification completes.
35
+
36
+ ## Quickstart
37
+
38
+ ```tsx
39
+ import { useProxzeKyc } from '@proxze/kyc-react-native';
40
+
41
+ function AddressVerification({ sessionToken }: { sessionToken: string }) {
42
+ const { session, state, loading, kyc } = useProxzeKyc({
43
+ baseUrl: 'https://api.proxze.com',
44
+ sessionToken,
45
+ });
46
+
47
+ if (loading || !session) return <Spinner />;
48
+
49
+ switch (state) {
50
+ case 'awaiting_consent':
51
+ // NDPR: show your consent copy, then:
52
+ return <ConsentScreen onAccept={() => kyc.grantConsent('1.0.0')} />;
53
+
54
+ case 'awaiting_address_pin':
55
+ // The declared address geocoded too coarsely — ask the customer to
56
+ // drop a pin at home (map screen), then:
57
+ return <PinScreen onConfirm={(p) => kyc.confirmAddress(p)} />;
58
+
59
+ case 'awaiting_permissions':
60
+ return (
61
+ <ExplainerScreen
62
+ onContinue={async () => {
63
+ const permission = await kyc.startTracking();
64
+ if (permission.grade === 'denied') {
65
+ // Explain why tracking is needed and re-prompt / open settings.
66
+ } else if (!permission.precise) {
67
+ // Approximate location can't confirm a 100m fence —
68
+ // walk the user to settings to enable Precise Location.
69
+ } else if (permission.grade === 'granted_when_in_use') {
70
+ // Warn: overnight confirmation unlikely without "Always allow".
71
+ }
72
+ }}
73
+ />
74
+ );
75
+
76
+ case 'tracking':
77
+ return (
78
+ <ProgressScreen
79
+ nights={session.requirements.nights}
80
+ onUploadBill={(file) => kyc.uploadUtilityBill(file, 'electricity_bill')}
81
+ />
82
+ );
83
+
84
+ case 'completed':
85
+ return <DoneScreen status={session.status} />;
86
+ }
87
+ }
88
+ ```
89
+
90
+ Imperative use without React is the same machine: `new ProxzeKycSession({...})`.
91
+
92
+ ## How night tracking works
93
+
94
+ The server evaluates nights in **hybrid** mode and this SDK feeds both models:
95
+
96
+ - **Geofence transitions** (`enter`/`exit`/`dwell`) come from the OS and
97
+ survive app termination and reboots (`stopOnTerminate: false`,
98
+ `startOnBoot: true`).
99
+ - **Pings** are sampled on the 30-minute marks inside the 12AM–5AM window
100
+ (Africa/Lagos), where the OS allows. iOS will not run a 30-minute background
101
+ timer — that's expected; the transitions plus the **morning check** (one
102
+ in-fence sample in the 3 hours after 05:00) satisfy the server's
103
+ arrived-and-stayed strategy.
104
+ - Everything is queued offline-first and flushed in batches; the server
105
+ dedupes on `clientEventId`, so replays are harmless.
106
+ - Android's mock-location flag rides along on every event; spoofed nights are
107
+ flagged server-side.
108
+
109
+ ## Evidence uploads
110
+
111
+ ```ts
112
+ // Compulsory utility bill (photo or PDF, ≤10MB, ≤3 months old):
113
+ await kyc.uploadUtilityBill(
114
+ { uri: photo.uri, name: 'bill.jpg', type: 'image/jpeg' },
115
+ 'electricity_bill',
116
+ );
117
+
118
+ // Daily geo-tagged video, only when the integration requires it:
119
+ await kyc.uploadVideo(
120
+ { uri: rec.uri, name: 'day1.mp4', type: 'video/mp4' },
121
+ {
122
+ dayNumber: 1,
123
+ durationSec: 22,
124
+ lat, lng, accuracyM,
125
+ recordedAt: new Date().toISOString(),
126
+ },
127
+ );
128
+ ```
129
+
130
+ The bill response carries the OCR/match outcome (`status`, `matchStatus`,
131
+ `rejectionReason`, `canRetry`) — one re-upload is allowed after a rejection.
132
+
133
+ ## Permissions — the full matrix
134
+
135
+ `startTracking()` requests permissions and returns what was actually granted
136
+ (`{ grade, precise }`); `kyc.diagnostics()` re-checks at any time. The SDK
137
+ starts tracking on anything better than an outright denial — degraded signals
138
+ still feed the server's hybrid evaluator, which routes unclear nights to
139
+ review instead of failing the customer — but the app should tell the customer
140
+ what each state means for their verification:
141
+
142
+ | State | Effect | App should |
143
+ | --- | --- | --- |
144
+ | `granted_always` + precise | Full night tracking | Nothing — happy path |
145
+ | `granted_when_in_use` | Fence events only while app foregrounded; nights mostly inconclusive | Prompt to upgrade to "Allow all the time" (Android takes the user to settings for this on 11+) |
146
+ | `precise: false` | Approximate fixes are km-wide; a 100m fence can never confirm | Walk the user to settings → enable Precise Location |
147
+ | `denied` | No tracking at all | Explain, re-prompt, or offer to cancel the verification |
148
+
149
+ Platform notes the host app owns:
150
+
151
+ - **Android 10+**: `ACCESS_BACKGROUND_LOCATION` is a separate grant; on 11+
152
+ the system never shows an "always" button in the dialog — the user must pick
153
+ it in settings. Google Play also requires an in-app prominent disclosure
154
+ *before* the permission prompt; the consent screen you show at
155
+ `awaiting_consent` is the natural place.
156
+ - **Android 12+**: users can grant approximate-only — that's the
157
+ `precise: false` state above.
158
+ - **Android 13+**: add `POST_NOTIFICATIONS`; the background-geolocation
159
+ foreground-service notification needs it.
160
+ - **Battery optimization**: aggressive OEMs (Tecno/Infinix/Xiaomi — a large
161
+ share of Nigerian handsets) kill background services. The Transistorsoft lib
162
+ ships `DeviceSettings` helpers to request an exemption; wire them into your
163
+ "tracking health" screen for best confirmation rates.
164
+ - **iOS**: "Always" authorization is granted provisionally and can be
165
+ downgraded silently by the user; re-check with `diagnostics()` when the app
166
+ foregrounds. iOS 14+'s Precise Location toggle maps to `precise: false`.
167
+
168
+ **Android** (`AndroidManifest.xml`):
169
+
170
+ ```xml
171
+ <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
172
+ <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
173
+ <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
174
+ <uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
175
+ ```
176
+
177
+ **iOS** (`Info.plist`):
178
+
179
+ ```xml
180
+ <key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
181
+ <string>Your bank uses your location at night to confirm you live at your registered address.</string>
182
+ <key>NSLocationWhenInUseUsageDescription</key>
183
+ <string>Your bank uses your location to confirm your address.</string>
184
+ <key>UIBackgroundModes</key>
185
+ <array><string>location</string></array>
186
+ ```
187
+
188
+ Follow `react-native-background-geolocation`'s own setup guide for its native
189
+ configuration and license key.
190
+
191
+ ## Custom location stack
192
+
193
+ ```ts
194
+ import { LocationAdapter, ProxzeKycSession } from '@proxze/kyc-react-native';
195
+
196
+ class MyAdapter implements LocationAdapter { /* ... */ }
197
+
198
+ const kyc = new ProxzeKycSession({
199
+ baseUrl,
200
+ sessionToken,
201
+ adapter: new MyAdapter(),
202
+ });
203
+ ```
204
+
205
+ ## Build
206
+
207
+ ```sh
208
+ yarn build # tsc → dist/
209
+ yarn test # queue + night-window unit tests
210
+ ```
211
+
212
+ ## License
213
+
214
+ Proprietary — © Sage Grey Technologies Limited. Use is permitted only for
215
+ integrating with Proxze services; modification and redistribution are not.
216
+ See [LICENSE](./LICENSE).
@@ -0,0 +1,55 @@
1
+ import { BillUploadResponse, ConfirmAddressResponse, ConsentResponse, IngestResponse, LocationEventInput, RestartResponse, RNFile, SdkSession, UtilityDocumentType, VideoMeta, VideoUploadResponse } from './types';
2
+ export interface ProxzeKycClientOptions {
3
+ /** e.g. `https://api.proxze.com` — no trailing slash, no `/v2`. */
4
+ baseUrl: string;
5
+ /** The `session_token` the bank's backend received from `POST /v2/kyc/initiate`. */
6
+ sessionToken: string;
7
+ /** Per-request timeout. Defaults to 20s (mobile networks are slow, not dead). */
8
+ timeoutMs?: number;
9
+ }
10
+ export declare class ProxzeKycError extends Error {
11
+ /** HTTP status, or 0 for network-level failures. */
12
+ readonly status: number;
13
+ readonly body?: unknown | undefined;
14
+ constructor(message: string,
15
+ /** HTTP status, or 0 for network-level failures. */
16
+ status: number, body?: unknown | undefined);
17
+ /** Session finished / token expired — stop tracking, nothing to retry. */
18
+ get isSessionClosed(): boolean;
19
+ /** Worth retrying later (offline, timeout, 5xx). */
20
+ get isTransient(): boolean;
21
+ }
22
+ /**
23
+ * Typed client for the device-facing `/v2/sdk/*` surface.
24
+ *
25
+ * Holds only the session token — scoped to one verification, useless for
26
+ * anything else. The bank's `pxz_live_*` API key must never reach the app.
27
+ */
28
+ export declare class ProxzeKycClient {
29
+ private readonly baseUrl;
30
+ private readonly token;
31
+ private readonly timeoutMs;
32
+ constructor(options: ProxzeKycClientOptions);
33
+ getSession(): Promise<SdkSession>;
34
+ grantConsent(consentVersion: string, deviceId?: string): Promise<ConsentResponse>;
35
+ withdrawConsent(): Promise<{
36
+ withdrawn: boolean;
37
+ }>;
38
+ confirmAddress(pin: {
39
+ lat: number;
40
+ lng: number;
41
+ accuracyM?: number;
42
+ }): Promise<ConfirmAddressResponse>;
43
+ acknowledgeGeofence(): Promise<{
44
+ acknowledged: boolean;
45
+ }>;
46
+ submitEvents(events: LocationEventInput[], device?: {
47
+ platform?: 'ios' | 'android';
48
+ sdkVersion?: string;
49
+ deviceId?: string;
50
+ }): Promise<IngestResponse>;
51
+ uploadUtilityBill(file: RNFile, documentType?: UtilityDocumentType): Promise<BillUploadResponse>;
52
+ uploadVideo(file: RNFile, meta: VideoMeta): Promise<VideoUploadResponse>;
53
+ restart(): Promise<RestartResponse>;
54
+ private request;
55
+ }
package/dist/client.js ADDED
@@ -0,0 +1,120 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ProxzeKycClient = exports.ProxzeKycError = void 0;
4
+ class ProxzeKycError extends Error {
5
+ constructor(message,
6
+ /** HTTP status, or 0 for network-level failures. */
7
+ status, body) {
8
+ super(message);
9
+ this.status = status;
10
+ this.body = body;
11
+ this.name = 'ProxzeKycError';
12
+ }
13
+ /** Session finished / token expired — stop tracking, nothing to retry. */
14
+ get isSessionClosed() {
15
+ return this.status === 401;
16
+ }
17
+ /** Worth retrying later (offline, timeout, 5xx). */
18
+ get isTransient() {
19
+ return this.status === 0 || this.status >= 500 || this.status === 429;
20
+ }
21
+ }
22
+ exports.ProxzeKycError = ProxzeKycError;
23
+ /**
24
+ * Typed client for the device-facing `/v2/sdk/*` surface.
25
+ *
26
+ * Holds only the session token — scoped to one verification, useless for
27
+ * anything else. The bank's `pxz_live_*` API key must never reach the app.
28
+ */
29
+ class ProxzeKycClient {
30
+ constructor(options) {
31
+ var _a;
32
+ this.baseUrl = options.baseUrl.replace(/\/+$/, '');
33
+ this.token = options.sessionToken;
34
+ this.timeoutMs = (_a = options.timeoutMs) !== null && _a !== void 0 ? _a : 20000;
35
+ }
36
+ getSession() {
37
+ return this.request('GET', '/v2/sdk/session');
38
+ }
39
+ grantConsent(consentVersion, deviceId) {
40
+ return this.request('POST', '/v2/sdk/consent', {
41
+ consentVersion: consentVersion,
42
+ deviceId: deviceId,
43
+ });
44
+ }
45
+ withdrawConsent() {
46
+ return this.request('POST', '/v2/sdk/consent/withdraw', {});
47
+ }
48
+ confirmAddress(pin) {
49
+ return this.request('POST', '/v2/sdk/address/confirm', pin);
50
+ }
51
+ acknowledgeGeofence() {
52
+ return this.request('POST', '/v2/sdk/geofence/registered', {});
53
+ }
54
+ submitEvents(events, device = {}) {
55
+ return this.request('POST', '/v2/sdk/events', { events, ...device });
56
+ }
57
+ uploadUtilityBill(file, documentType) {
58
+ const form = new FormData();
59
+ form.append('file', file);
60
+ if (documentType)
61
+ form.append('documentType', documentType);
62
+ return this.request('POST', '/v2/sdk/utility-bill', form);
63
+ }
64
+ uploadVideo(file, meta) {
65
+ const form = new FormData();
66
+ form.append('file', file);
67
+ for (const [key, value] of Object.entries(meta)) {
68
+ if (value !== undefined)
69
+ form.append(key, String(value));
70
+ }
71
+ return this.request('POST', '/v2/sdk/video', form);
72
+ }
73
+ restart() {
74
+ return this.request('POST', '/v2/sdk/restart', {});
75
+ }
76
+ async request(method, path, body) {
77
+ var _a, _b;
78
+ const isForm = typeof FormData !== 'undefined' && body instanceof FormData;
79
+ let timer;
80
+ const timeout = new Promise((_, reject) => {
81
+ timer = setTimeout(() => reject(new ProxzeKycError('Request timed out', 0)), this.timeoutMs);
82
+ });
83
+ let response;
84
+ try {
85
+ response = await Promise.race([
86
+ fetch(`${this.baseUrl}${path}`, {
87
+ method,
88
+ headers: {
89
+ 'x-proxze-session-token': this.token,
90
+ accept: 'application/json',
91
+ // RN sets the multipart boundary itself; only JSON is explicit.
92
+ ...(body && !isForm ? { 'content-type': 'application/json' } : {}),
93
+ },
94
+ body: body === undefined ? undefined : isForm ? body : JSON.stringify(body),
95
+ }),
96
+ timeout,
97
+ ]);
98
+ }
99
+ catch (err) {
100
+ if (err instanceof ProxzeKycError)
101
+ throw err;
102
+ throw new ProxzeKycError((_a = err === null || err === void 0 ? void 0 : err.message) !== null && _a !== void 0 ? _a : 'Network request failed', 0);
103
+ }
104
+ finally {
105
+ clearTimeout(timer);
106
+ }
107
+ let parsed = null;
108
+ try {
109
+ parsed = await response.json();
110
+ }
111
+ catch {
112
+ /* non-JSON error body */
113
+ }
114
+ if (!response.ok) {
115
+ throw new ProxzeKycError((_b = parsed === null || parsed === void 0 ? void 0 : parsed.message) !== null && _b !== void 0 ? _b : `Request failed with status ${response.status}`, response.status, parsed);
116
+ }
117
+ return parsed;
118
+ }
119
+ }
120
+ exports.ProxzeKycClient = ProxzeKycClient;
@@ -0,0 +1,27 @@
1
+ import { ProxzeKycSession, KycTrackingState, ProxzeKycSessionOptions } from './session';
2
+ import { SdkSession } from './types';
3
+ export interface UseProxzeKycResult {
4
+ /** Server-side session state, refreshed after every action. */
5
+ session: SdkSession | null;
6
+ /** Local step machine — drive the UI off this. */
7
+ state: KycTrackingState;
8
+ loading: boolean;
9
+ error: Error | null;
10
+ /** The orchestrator, for the imperative calls (uploads, restart, consent). */
11
+ kyc: ProxzeKycSession;
12
+ }
13
+ /**
14
+ * React binding over {@link ProxzeKycSession}.
15
+ *
16
+ * ```tsx
17
+ * const { session, state, kyc } = useProxzeKyc({
18
+ * baseUrl: 'https://api.proxze.com',
19
+ * sessionToken,
20
+ * });
21
+ *
22
+ * if (state === 'awaiting_consent') {
23
+ * return <ConsentScreen onAccept={() => kyc.grantConsent('1.0.0')} />;
24
+ * }
25
+ * ```
26
+ */
27
+ export declare function useProxzeKyc(options: Omit<ProxzeKycSessionOptions, 'events'>): UseProxzeKycResult;
package/dist/hooks.js ADDED
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useProxzeKyc = useProxzeKyc;
4
+ const react_1 = require("react");
5
+ const session_1 = require("./session");
6
+ /**
7
+ * React binding over {@link ProxzeKycSession}.
8
+ *
9
+ * ```tsx
10
+ * const { session, state, kyc } = useProxzeKyc({
11
+ * baseUrl: 'https://api.proxze.com',
12
+ * sessionToken,
13
+ * });
14
+ *
15
+ * if (state === 'awaiting_consent') {
16
+ * return <ConsentScreen onAccept={() => kyc.grantConsent('1.0.0')} />;
17
+ * }
18
+ * ```
19
+ */
20
+ function useProxzeKyc(options) {
21
+ const [session, setSession] = (0, react_1.useState)(null);
22
+ const [state, setState] = (0, react_1.useState)('idle');
23
+ const [error, setError] = (0, react_1.useState)(null);
24
+ const [loading, setLoading] = (0, react_1.useState)(true);
25
+ // The orchestrator's lifetime spans renders; only a new token replaces it.
26
+ const kycRef = (0, react_1.useRef)(null);
27
+ const kyc = (0, react_1.useMemo)(() => {
28
+ const instance = new session_1.ProxzeKycSession({
29
+ ...options,
30
+ events: {
31
+ onSessionUpdate: setSession,
32
+ onStateChange: setState,
33
+ onError: setError,
34
+ },
35
+ });
36
+ kycRef.current = instance;
37
+ return instance;
38
+ // eslint-disable-next-line react-hooks/exhaustive-deps
39
+ }, [options.baseUrl, options.sessionToken]);
40
+ (0, react_1.useEffect)(() => {
41
+ let cancelled = false;
42
+ setLoading(true);
43
+ kyc
44
+ .bootstrap()
45
+ .catch((err) => {
46
+ if (!cancelled)
47
+ setError(err);
48
+ })
49
+ .finally(() => {
50
+ if (!cancelled)
51
+ setLoading(false);
52
+ });
53
+ return () => {
54
+ cancelled = true;
55
+ void kyc.stopTracking();
56
+ };
57
+ }, [kyc]);
58
+ return { session, state, loading, error, kyc };
59
+ }
@@ -0,0 +1,15 @@
1
+ export { ProxzeKycClient, ProxzeKycError } from './client';
2
+ export type { ProxzeKycClientOptions } from './client';
3
+ export { ProxzeKycSession } from './session';
4
+ export type { KycTrackingState, KycSessionEvents, ProxzeKycSessionOptions, } from './session';
5
+ export { useProxzeKyc } from './hooks';
6
+ export type { UseProxzeKycResult } from './hooks';
7
+ export { OfflineEventQueue } from './queue';
8
+ export type { QueueEventInput } from './queue';
9
+ export { memoryStorage, defaultStorage } from './storage';
10
+ export type { StorageAdapter } from './storage';
11
+ export type { LocationAdapter, AdapterLocationEvent, LocationEventListener, PermissionState, PermissionGrade, } from './location/adapter';
12
+ export { BackgroundGeolocationAdapter } from './location/backgroundGeolocationAdapter';
13
+ export { buildWindow, nightWindowFor, isWithinNightWindow, isInMorningCheckSlot, msUntilNextSample, WAT_OFFSET_MINUTES, PING_INTERVAL_MINUTES, } from './nightWindow';
14
+ export type { NightWindow } from './nightWindow';
15
+ export * from './types';
package/dist/index.js ADDED
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.PING_INTERVAL_MINUTES = exports.WAT_OFFSET_MINUTES = exports.msUntilNextSample = exports.isInMorningCheckSlot = exports.isWithinNightWindow = exports.nightWindowFor = exports.buildWindow = exports.BackgroundGeolocationAdapter = exports.defaultStorage = exports.memoryStorage = exports.OfflineEventQueue = exports.useProxzeKyc = exports.ProxzeKycSession = exports.ProxzeKycError = exports.ProxzeKycClient = void 0;
18
+ var client_1 = require("./client");
19
+ Object.defineProperty(exports, "ProxzeKycClient", { enumerable: true, get: function () { return client_1.ProxzeKycClient; } });
20
+ Object.defineProperty(exports, "ProxzeKycError", { enumerable: true, get: function () { return client_1.ProxzeKycError; } });
21
+ var session_1 = require("./session");
22
+ Object.defineProperty(exports, "ProxzeKycSession", { enumerable: true, get: function () { return session_1.ProxzeKycSession; } });
23
+ var hooks_1 = require("./hooks");
24
+ Object.defineProperty(exports, "useProxzeKyc", { enumerable: true, get: function () { return hooks_1.useProxzeKyc; } });
25
+ var queue_1 = require("./queue");
26
+ Object.defineProperty(exports, "OfflineEventQueue", { enumerable: true, get: function () { return queue_1.OfflineEventQueue; } });
27
+ var storage_1 = require("./storage");
28
+ Object.defineProperty(exports, "memoryStorage", { enumerable: true, get: function () { return storage_1.memoryStorage; } });
29
+ Object.defineProperty(exports, "defaultStorage", { enumerable: true, get: function () { return storage_1.defaultStorage; } });
30
+ var backgroundGeolocationAdapter_1 = require("./location/backgroundGeolocationAdapter");
31
+ Object.defineProperty(exports, "BackgroundGeolocationAdapter", { enumerable: true, get: function () { return backgroundGeolocationAdapter_1.BackgroundGeolocationAdapter; } });
32
+ var nightWindow_1 = require("./nightWindow");
33
+ Object.defineProperty(exports, "buildWindow", { enumerable: true, get: function () { return nightWindow_1.buildWindow; } });
34
+ Object.defineProperty(exports, "nightWindowFor", { enumerable: true, get: function () { return nightWindow_1.nightWindowFor; } });
35
+ Object.defineProperty(exports, "isWithinNightWindow", { enumerable: true, get: function () { return nightWindow_1.isWithinNightWindow; } });
36
+ Object.defineProperty(exports, "isInMorningCheckSlot", { enumerable: true, get: function () { return nightWindow_1.isInMorningCheckSlot; } });
37
+ Object.defineProperty(exports, "msUntilNextSample", { enumerable: true, get: function () { return nightWindow_1.msUntilNextSample; } });
38
+ Object.defineProperty(exports, "WAT_OFFSET_MINUTES", { enumerable: true, get: function () { return nightWindow_1.WAT_OFFSET_MINUTES; } });
39
+ Object.defineProperty(exports, "PING_INTERVAL_MINUTES", { enumerable: true, get: function () { return nightWindow_1.PING_INTERVAL_MINUTES; } });
40
+ __exportStar(require("./types"), exports);
@@ -0,0 +1,57 @@
1
+ import { GeofenceConfig, LocationEventType } from '../types';
2
+ export interface AdapterLocationEvent {
3
+ type: LocationEventType;
4
+ lat?: number;
5
+ lng?: number;
6
+ accuracyM?: number;
7
+ recordedAt: Date;
8
+ /** OS mock-location signal (Android `isFromMockProvider` etc). */
9
+ isMocked?: boolean;
10
+ batteryLevel?: number;
11
+ isCharging?: boolean;
12
+ }
13
+ export type LocationEventListener = (event: AdapterLocationEvent) => void;
14
+ export type PermissionGrade = 'granted_always' | 'granted_when_in_use' | 'denied';
15
+ export interface PermissionState {
16
+ grade: PermissionGrade;
17
+ /**
18
+ * False when the user granted only approximate location (Android 12+'s
19
+ * "Approximate" toggle, iOS 14+'s "Precise Location" off). Approximate
20
+ * fixes are kilometres wide — a 100m geofence cannot confirm nights with
21
+ * them, so the app should walk the user back to settings.
22
+ */
23
+ precise: boolean;
24
+ }
25
+ /**
26
+ * The seam between the SDK's verification logic and whatever location stack
27
+ * the host app ships.
28
+ *
29
+ * The default implementation wraps `react-native-background-geolocation`
30
+ * (Play Services fused location + geofencing on Android, CoreLocation region
31
+ * monitoring on iOS). Banks with their own location stack implement this
32
+ * interface instead and the rest of the SDK is unchanged.
33
+ */
34
+ export interface LocationAdapter {
35
+ /**
36
+ * Request the permissions night tracking needs. `granted_always` with
37
+ * `precise: true` is the target; `granted_when_in_use` still tracks while
38
+ * the app is foreground but nights will mostly be inconclusive, and
39
+ * `precise: false` cannot anchor a 100m fence at all — surface both to the
40
+ * customer instead of tracking silently toward a failed verification.
41
+ */
42
+ requestPermissions(): Promise<PermissionState>;
43
+ /** Current permission state without prompting. */
44
+ checkPermissions(): Promise<PermissionState>;
45
+ /** Register the verification geofence with the OS. */
46
+ registerGeofence(fence: GeofenceConfig): Promise<void>;
47
+ /** Remove the geofence and stop monitoring. */
48
+ clearGeofence(): Promise<void>;
49
+ /** Begin background monitoring; events flow to the registered listener. */
50
+ start(): Promise<void>;
51
+ /** Stop background monitoring entirely. */
52
+ stop(): Promise<void>;
53
+ /** One-shot position read — used for pings and the morning check. */
54
+ getCurrentPosition(): Promise<AdapterLocationEvent>;
55
+ /** Subscribe to geofence transitions and heartbeats. Returns unsubscribe. */
56
+ onEvent(listener: LocationEventListener): () => void;
57
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });