react-native-okhi 1.2.32-beta.6 → 2.0.1
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/README.md +156 -16
- package/ReactNativeOkhi.podspec +1 -1
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/okhi/OkhiModule.kt +0 -4
- package/ios/OkHiWrapper.swift +1 -5
- package/ios/Okhi.mm +0 -4
- package/lib/commonjs/NativeOkhi.js.map +1 -1
- package/lib/commonjs/index.js +290 -34
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/types.js +390 -0
- package/lib/commonjs/types.js.map +1 -1
- package/lib/module/NativeOkhi.js.map +1 -1
- package/lib/module/index.js +261 -33
- package/lib/module/index.js.map +1 -1
- package/lib/module/types.js +385 -0
- package/lib/module/types.js.map +1 -1
- package/lib/typescript/commonjs/src/NativeOkhi.d.ts +0 -1
- package/lib/typescript/commonjs/src/NativeOkhi.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/index.d.ts +248 -2
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/types.d.ts +540 -4
- package/lib/typescript/commonjs/src/types.d.ts.map +1 -1
- package/lib/typescript/module/src/NativeOkhi.d.ts +0 -1
- package/lib/typescript/module/src/NativeOkhi.d.ts.map +1 -1
- package/lib/typescript/module/src/index.d.ts +248 -2
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/types.d.ts +540 -4
- package/lib/typescript/module/src/types.d.ts.map +1 -1
- package/package.json +4 -2
- package/src/NativeOkhi.ts +0 -1
- package/src/index.tsx +271 -33
- package/src/types.ts +655 -5
|
@@ -1,81 +1,617 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Authentication credentials for the OkHi platform.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* These credentials are provided by OkHi when you register your application.
|
|
6
|
+
* You can find them in your OkHi dashboard under API Keys.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* const auth: OkHiAuth = {
|
|
11
|
+
* branchId: 'your_branch_id',
|
|
12
|
+
* clientKey: 'your_client_key'
|
|
13
|
+
* };
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* @see {@link OkHiLogin} - Used within the login configuration
|
|
17
|
+
*/
|
|
1
18
|
export type OkHiAuth = {
|
|
19
|
+
/**
|
|
20
|
+
* Your unique OkHi branch identifier.
|
|
21
|
+
* Obtained from the OkHi dashboard.
|
|
22
|
+
*/
|
|
2
23
|
branchId: string;
|
|
24
|
+
/**
|
|
25
|
+
* Your OkHi client API key.
|
|
26
|
+
*/
|
|
3
27
|
clientKey: string;
|
|
4
28
|
env?: string;
|
|
5
29
|
};
|
|
30
|
+
/**
|
|
31
|
+
* User information for OkHi address verification.
|
|
32
|
+
*
|
|
33
|
+
* @remarks
|
|
34
|
+
* This type represents the user whose address is being verified.
|
|
35
|
+
* All contact information should be valid as it may be used for verification purposes.
|
|
36
|
+
* important: Make sure to use a phone number you own during testing!
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```typescript
|
|
40
|
+
* const user: OkHiUser = {
|
|
41
|
+
* firstName: 'John',
|
|
42
|
+
* lastName: 'Doe',
|
|
43
|
+
* phone: '+254712345678',
|
|
44
|
+
* email: 'john.doe@example.com',
|
|
45
|
+
* };
|
|
46
|
+
* ```
|
|
47
|
+
*
|
|
48
|
+
* @see {@link OkHiLogin} - Used within the login configuration
|
|
49
|
+
* @see {@link OkHiSuccessResponse} - Enriched and returned after successful verification
|
|
50
|
+
*/
|
|
6
51
|
export type OkHiUser = {
|
|
52
|
+
/**
|
|
53
|
+
* User's first name.
|
|
54
|
+
*/
|
|
7
55
|
firstName: string;
|
|
56
|
+
/**
|
|
57
|
+
* User's last name.
|
|
58
|
+
*/
|
|
8
59
|
lastName: string;
|
|
60
|
+
/**
|
|
61
|
+
* User's phone number in international format.
|
|
62
|
+
* @example `'+254712345678'`
|
|
63
|
+
*/
|
|
9
64
|
phone: string;
|
|
65
|
+
/**
|
|
66
|
+
* User's email address.
|
|
67
|
+
*/
|
|
10
68
|
email: string;
|
|
69
|
+
/**
|
|
70
|
+
* OkHi's internal user identifier.
|
|
71
|
+
*/
|
|
11
72
|
okhiUserId?: string;
|
|
73
|
+
/**
|
|
74
|
+
* Managed internally by the SDK.
|
|
75
|
+
*/
|
|
12
76
|
token?: string;
|
|
77
|
+
/**
|
|
78
|
+
* Your application's internal user identifier.
|
|
79
|
+
* Use this to link OkHi verifications to your own user records.
|
|
80
|
+
*
|
|
81
|
+
* @example `'user_abc123'`
|
|
82
|
+
*/
|
|
13
83
|
appUserId?: string;
|
|
14
84
|
};
|
|
85
|
+
/**
|
|
86
|
+
* Application context information sent to OkHi.
|
|
87
|
+
*
|
|
88
|
+
* @remarks
|
|
89
|
+
* Provides metadata about your application for analytics and debugging purposes.
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* ```typescript
|
|
93
|
+
* const appContext: OkHiAppContext = {
|
|
94
|
+
* name: 'MyApp',
|
|
95
|
+
* version: '1.2.3',
|
|
96
|
+
* build: '456',
|
|
97
|
+
* };
|
|
98
|
+
* ```
|
|
99
|
+
*
|
|
100
|
+
* @see {@link OkHiLogin} - Used within the login configuration
|
|
101
|
+
*/
|
|
15
102
|
export type OkHiAppContext = {
|
|
103
|
+
/**
|
|
104
|
+
* Your application's name.
|
|
105
|
+
* @example `'MyLoanApp'`
|
|
106
|
+
*/
|
|
16
107
|
name: string;
|
|
108
|
+
/**
|
|
109
|
+
* Your application's version string.
|
|
110
|
+
* @example `'1.2.3'`
|
|
111
|
+
*/
|
|
17
112
|
version: string;
|
|
113
|
+
/**
|
|
114
|
+
* Your application's build number.
|
|
115
|
+
* @example `'456'`
|
|
116
|
+
*/
|
|
18
117
|
build: string;
|
|
19
118
|
};
|
|
119
|
+
/**
|
|
120
|
+
* Configuration options for the login process.
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* ```typescript
|
|
124
|
+
* const loginConfig: OkHiLoginConfiguration = {
|
|
125
|
+
* withPermissionsRequest: true, // Request permissions during login
|
|
126
|
+
* };
|
|
127
|
+
* ```
|
|
128
|
+
*
|
|
129
|
+
* @see {@link OkHiLogin} - Used within the login configuration
|
|
130
|
+
*/
|
|
20
131
|
export type OkHiLoginConfiguration = {
|
|
132
|
+
/**
|
|
133
|
+
* Whether to request required permissions during login.
|
|
134
|
+
* When `true`, the SDK will prompt for necessary permissions as part of the login flow.
|
|
135
|
+
*
|
|
136
|
+
* @defaultValue `false`
|
|
137
|
+
*/
|
|
21
138
|
withPermissionsRequest?: boolean;
|
|
22
139
|
};
|
|
140
|
+
/**
|
|
141
|
+
* Complete login configuration for authenticating with OkHi.
|
|
142
|
+
*
|
|
143
|
+
* @remarks
|
|
144
|
+
* This is the primary configuration object passed to the `login()` function.
|
|
145
|
+
* It combines authentication credentials, user information, and optional settings.
|
|
146
|
+
*
|
|
147
|
+
* @example
|
|
148
|
+
* ```typescript
|
|
149
|
+
* import * as OkHi from 'react-native-okhi';
|
|
150
|
+
* import type { OkHiLogin } from 'react-native-okhi';
|
|
151
|
+
*
|
|
152
|
+
* const credentials: OkHiLogin = {
|
|
153
|
+
* auth: {
|
|
154
|
+
* branchId: 'your_branch_id',
|
|
155
|
+
* clientKey: 'your_client_key',
|
|
156
|
+
* },
|
|
157
|
+
* user: {
|
|
158
|
+
* firstName: 'John',
|
|
159
|
+
* lastName: 'Doe',
|
|
160
|
+
* phone: '+254712345678',
|
|
161
|
+
* email: 'john.doe@example.com',
|
|
162
|
+
* },
|
|
163
|
+
* configuration: {
|
|
164
|
+
* withPermissionsRequest: true,
|
|
165
|
+
* },
|
|
166
|
+
* };
|
|
167
|
+
*
|
|
168
|
+
* await OkHi.login(credentials);
|
|
169
|
+
* ```
|
|
170
|
+
*/
|
|
23
171
|
export type OkHiLogin = {
|
|
172
|
+
/**
|
|
173
|
+
* Authentication credentials for OkHi.
|
|
174
|
+
*/
|
|
24
175
|
auth: OkHiAuth;
|
|
176
|
+
/**
|
|
177
|
+
* User information.
|
|
178
|
+
*/
|
|
25
179
|
user: OkHiUser;
|
|
180
|
+
/**
|
|
181
|
+
* Optional login behavior configuration.
|
|
182
|
+
*/
|
|
26
183
|
configuration?: OkHiLoginConfiguration;
|
|
184
|
+
/**
|
|
185
|
+
* Optional application context for analytics.
|
|
186
|
+
*/
|
|
27
187
|
appContext?: OkHiAppContext;
|
|
28
188
|
};
|
|
189
|
+
/**
|
|
190
|
+
* Visual styling options for the OkCollect address collection UI.
|
|
191
|
+
*
|
|
192
|
+
* @remarks
|
|
193
|
+
* Customize the appearance of the address collection interface to match your app's branding.
|
|
194
|
+
*
|
|
195
|
+
* @example
|
|
196
|
+
* ```typescript
|
|
197
|
+
* const style: OkCollectStyle = {
|
|
198
|
+
* color: '#FF5722', // Your brand's primary color
|
|
199
|
+
* logo: 'https://example.com/logo.png',
|
|
200
|
+
* };
|
|
201
|
+
* ```
|
|
202
|
+
*
|
|
203
|
+
* @see {@link OkCollect} - Parent configuration type
|
|
204
|
+
*/
|
|
29
205
|
export type OkCollectStyle = {
|
|
206
|
+
/**
|
|
207
|
+
* Primary theme color for the UI in hexadecimal format.
|
|
208
|
+
* Applied to buttons, highlights, and accent elements.
|
|
209
|
+
*
|
|
210
|
+
* @defaultValue `'#005D67'` (OkHi teal)
|
|
211
|
+
* @example `'#FF5722'`
|
|
212
|
+
*/
|
|
30
213
|
color: string;
|
|
214
|
+
/**
|
|
215
|
+
* URL to your company logo.
|
|
216
|
+
* Displayed in the address collection header.
|
|
217
|
+
*
|
|
218
|
+
* @defaultValue `'https://cdn.okhi.co/icon.png'`
|
|
219
|
+
* @example `'https://example.com/logo.png'`
|
|
220
|
+
*/
|
|
31
221
|
logo: string;
|
|
32
222
|
};
|
|
223
|
+
/**
|
|
224
|
+
* Behavioral configuration options for the OkCollect address collection UI.
|
|
225
|
+
*
|
|
226
|
+
* @remarks
|
|
227
|
+
* Control which features are available during address collection.
|
|
228
|
+
*
|
|
229
|
+
* @example
|
|
230
|
+
* ```typescript
|
|
231
|
+
* const config: OkCollectConfig = {
|
|
232
|
+
* streetView: true,
|
|
233
|
+
* withAppBar: true,
|
|
234
|
+
* };
|
|
235
|
+
* ```
|
|
236
|
+
*
|
|
237
|
+
* @see {@link OkCollect} - Parent configuration type
|
|
238
|
+
*/
|
|
33
239
|
export type OkCollectConfig = {
|
|
240
|
+
/**
|
|
241
|
+
* Whether to enable Google Street View for address collection.
|
|
242
|
+
* When enabled, users can create addresses using street-level imagery.
|
|
243
|
+
*
|
|
244
|
+
* @defaultValue `true`
|
|
245
|
+
*/
|
|
34
246
|
streetView: boolean;
|
|
247
|
+
/**
|
|
248
|
+
* Whether to show "Home" as an address type option.
|
|
249
|
+
*
|
|
250
|
+
* @defaultValue `true`
|
|
251
|
+
*/
|
|
35
252
|
withHomeAddressType: boolean;
|
|
253
|
+
/**
|
|
254
|
+
* Whether to show "Work" as an address type option.
|
|
255
|
+
*
|
|
256
|
+
* @defaultValue `false`
|
|
257
|
+
*/
|
|
36
258
|
withWorkAddressType: boolean;
|
|
259
|
+
/**
|
|
260
|
+
* Whether to display the app bar (header) in the collection UI.
|
|
261
|
+
*
|
|
262
|
+
* @defaultValue `true`
|
|
263
|
+
*/
|
|
37
264
|
withAppBar: boolean;
|
|
38
265
|
};
|
|
266
|
+
/**
|
|
267
|
+
* Configuration options for address collection
|
|
268
|
+
*
|
|
269
|
+
* @remarks
|
|
270
|
+
* Pass this to verification functions to customize the address collection experience.
|
|
271
|
+
* All properties are optional - sensible defaults are applied automatically.
|
|
272
|
+
*
|
|
273
|
+
* @example
|
|
274
|
+
* ```typescript
|
|
275
|
+
* import * as OkHi from 'react-native-okhi';
|
|
276
|
+
* import type { OkCollect } from 'react-native-okhi';
|
|
277
|
+
*
|
|
278
|
+
* // Use with custom styling
|
|
279
|
+
* const config: OkCollect = {
|
|
280
|
+
* style: {
|
|
281
|
+
* color: '#FF5722',
|
|
282
|
+
* logo: 'https://example.com/logo.png',
|
|
283
|
+
* },
|
|
284
|
+
* configuration: {
|
|
285
|
+
* streetView: true,
|
|
286
|
+
* },
|
|
287
|
+
* };
|
|
288
|
+
*
|
|
289
|
+
* const result = await OkHi.startDigitalAddressVerification(config);
|
|
290
|
+
* ```
|
|
291
|
+
*
|
|
292
|
+
* @example
|
|
293
|
+
* ```typescript
|
|
294
|
+
* // Start verification on a previously created address.
|
|
295
|
+
* const locationId: string = await fetchLocationIdFromMyDatabase()
|
|
296
|
+
* const config: OkCollect = {
|
|
297
|
+
* locationId,
|
|
298
|
+
* };
|
|
299
|
+
*
|
|
300
|
+
* const result = await startPhysicalAddressVerification(config);
|
|
301
|
+
* ```
|
|
302
|
+
*/
|
|
39
303
|
export type OkCollect = {
|
|
304
|
+
/**
|
|
305
|
+
* Visual styling options for the collection UI.
|
|
306
|
+
* Partial - only specify the properties you want to override.
|
|
307
|
+
*/
|
|
40
308
|
style?: Partial<OkCollectStyle>;
|
|
309
|
+
/**
|
|
310
|
+
* Behavioral configuration for the collection UI.
|
|
311
|
+
* Partial - only specify the properties you want to override.
|
|
312
|
+
*/
|
|
41
313
|
configuration?: Partial<OkCollectConfig>;
|
|
314
|
+
/**
|
|
315
|
+
* OkHi identifier for the address
|
|
316
|
+
* Use this to start verification on a previously created address.
|
|
317
|
+
*/
|
|
42
318
|
locationId?: string;
|
|
43
319
|
};
|
|
320
|
+
/**
|
|
321
|
+
* Comprehensive location data returned once verification starts successfully.
|
|
322
|
+
*
|
|
323
|
+
* @remarks
|
|
324
|
+
* Contains all available address information collected.
|
|
325
|
+
* Properties may be `null` if not available for the specific location.
|
|
326
|
+
*
|
|
327
|
+
* @example
|
|
328
|
+
* ```typescript
|
|
329
|
+
* const handleVerification = async () => {
|
|
330
|
+
* const result = await OkHi.startDigitalAddressVerification();
|
|
331
|
+
* const { location } = result;
|
|
332
|
+
*
|
|
333
|
+
* console.log('Address:', location.formattedAddress);
|
|
334
|
+
* console.log('Coordinates:', location.lat, location.lng);
|
|
335
|
+
* console.log('Plus Code:', location.plusCode);
|
|
336
|
+
* };
|
|
337
|
+
* ```
|
|
338
|
+
*
|
|
339
|
+
* @see {@link OkHiSuccessResponse} - Parent response type
|
|
340
|
+
*/
|
|
44
341
|
export type OkHiLocation = {
|
|
342
|
+
/**
|
|
343
|
+
* Unique OkHi location identifier.
|
|
344
|
+
* Use this to reference the address in future API calls.
|
|
345
|
+
*/
|
|
45
346
|
id?: string | null;
|
|
347
|
+
/**
|
|
348
|
+
* Latitude coordinate of the location.
|
|
349
|
+
* @example `1.2921`
|
|
350
|
+
*/
|
|
46
351
|
lat?: number | null;
|
|
352
|
+
/**
|
|
353
|
+
* Longitude coordinate of the location.
|
|
354
|
+
* @example `36.8219`
|
|
355
|
+
*/
|
|
47
356
|
lng?: number | null;
|
|
357
|
+
/**
|
|
358
|
+
* Legacy not in use
|
|
359
|
+
*/
|
|
48
360
|
placeId?: string | null;
|
|
361
|
+
/**
|
|
362
|
+
* Open Location Code (Plus Code) for the address.
|
|
363
|
+
* A short, alphanumeric code that represents a geographic location.
|
|
364
|
+
*
|
|
365
|
+
* @see https://plus.codes/
|
|
366
|
+
* @example `'6GCRMQPX+JF'`
|
|
367
|
+
*/
|
|
49
368
|
plusCode?: string | null;
|
|
369
|
+
/**
|
|
370
|
+
* Name of the property (building, apartment complex, etc.).
|
|
371
|
+
* @example `'Sunrise Apartments'`
|
|
372
|
+
*/
|
|
50
373
|
propertyName?: string | null;
|
|
374
|
+
/**
|
|
375
|
+
* Name of the street.
|
|
376
|
+
* @example `'Ngong Road'`
|
|
377
|
+
*/
|
|
51
378
|
streetName?: string | null;
|
|
379
|
+
/**
|
|
380
|
+
* System generated title for the address.
|
|
381
|
+
*/
|
|
52
382
|
title?: string | null;
|
|
383
|
+
/**
|
|
384
|
+
* System generated subtitle for the address.
|
|
385
|
+
*/
|
|
53
386
|
subtitle?: string | null;
|
|
387
|
+
/**
|
|
388
|
+
* User-provided directions to the location.
|
|
389
|
+
*/
|
|
54
390
|
directions?: string | null;
|
|
391
|
+
/**
|
|
392
|
+
* Additional information about the location.
|
|
393
|
+
*/
|
|
55
394
|
otherInformation?: string | null;
|
|
395
|
+
/**
|
|
396
|
+
* OkHi URL for the address.
|
|
397
|
+
* Can be shared for navigation purposes.
|
|
398
|
+
*/
|
|
56
399
|
url?: string | null;
|
|
400
|
+
/**
|
|
401
|
+
* Google Street View panorama ID.
|
|
402
|
+
* Used to display street-level imagery.
|
|
403
|
+
*/
|
|
57
404
|
streetViewPanoId?: string | null;
|
|
405
|
+
/**
|
|
406
|
+
* URL to the Google Street View panorama image.
|
|
407
|
+
*/
|
|
58
408
|
streetViewPanoUrl?: string | null;
|
|
409
|
+
/**
|
|
410
|
+
* OkHi user ID associated with this location.
|
|
411
|
+
*/
|
|
59
412
|
userId?: string | null;
|
|
413
|
+
/**
|
|
414
|
+
* URL to a photo of the location.
|
|
415
|
+
*/
|
|
60
416
|
photoUrl?: string | null;
|
|
417
|
+
/**
|
|
418
|
+
* Property or house number.
|
|
419
|
+
* @example `'42'`
|
|
420
|
+
*/
|
|
61
421
|
propertyNumber?: string | null;
|
|
422
|
+
/**
|
|
423
|
+
* Country name.
|
|
424
|
+
* @example `'Kenya'`
|
|
425
|
+
*/
|
|
62
426
|
country?: string | null;
|
|
427
|
+
/**
|
|
428
|
+
* State, province, or region.
|
|
429
|
+
* @example `'Nairobi'`
|
|
430
|
+
*/
|
|
63
431
|
state?: string | null;
|
|
432
|
+
/**
|
|
433
|
+
* City or town name.
|
|
434
|
+
* @example `'Nairobi'`
|
|
435
|
+
*/
|
|
64
436
|
city?: string | null;
|
|
437
|
+
/**
|
|
438
|
+
* Display-friendly title for the address.
|
|
439
|
+
* Formatted for showing in UI.
|
|
440
|
+
*/
|
|
65
441
|
displayTitle?: string | null;
|
|
442
|
+
/**
|
|
443
|
+
* ISO 3166-1 alpha-2 country code.
|
|
444
|
+
* @example `'KE'`
|
|
445
|
+
*/
|
|
66
446
|
countryCode?: string | null;
|
|
447
|
+
/**
|
|
448
|
+
* Neighborhood or locality name.
|
|
449
|
+
* @example `'Westlands'`
|
|
450
|
+
*/
|
|
67
451
|
neighborhood?: string | null;
|
|
452
|
+
/**
|
|
453
|
+
* Used internally by the SDK
|
|
454
|
+
*/
|
|
68
455
|
usageTypes?: string[] | null;
|
|
456
|
+
/**
|
|
457
|
+
* Administrative ward.
|
|
458
|
+
* Common in African addressing systems.
|
|
459
|
+
*/
|
|
69
460
|
ward?: string | null;
|
|
461
|
+
/**
|
|
462
|
+
* Complete formatted address string.
|
|
463
|
+
* @example `'Sunrise Apartments, Ngong Road, Westlands, Nairobi, Kenya'`
|
|
464
|
+
*/
|
|
70
465
|
formattedAddress?: string | null;
|
|
466
|
+
/**
|
|
467
|
+
* Postal or ZIP code.
|
|
468
|
+
*/
|
|
71
469
|
postCode?: string | null;
|
|
72
470
|
};
|
|
73
|
-
export type OkHiException = {
|
|
74
|
-
code: string;
|
|
75
|
-
message: string;
|
|
76
|
-
};
|
|
77
471
|
export type OkHiSuccessResponse = {
|
|
472
|
+
/**
|
|
473
|
+
* User information.
|
|
474
|
+
* @see {@link OkHiUser}
|
|
475
|
+
*/
|
|
78
476
|
user: OkHiUser;
|
|
477
|
+
/**
|
|
478
|
+
* Location data.
|
|
479
|
+
* @see {@link OkHiLocation}
|
|
480
|
+
*/
|
|
79
481
|
location: OkHiLocation;
|
|
80
482
|
};
|
|
483
|
+
/**
|
|
484
|
+
* Standard error codes returned by OkHi operations.
|
|
485
|
+
*
|
|
486
|
+
* These codes are consistent across iOS and Android platforms.
|
|
487
|
+
*/
|
|
488
|
+
export type OkHiErrorCode = 'fatal_exit' | 'user_closed' | 'unknown' | 'network_error' | 'permission_denied' | 'service_unavailable' | 'unsupported_device' | 'unauthenticated' | 'invalid_phone';
|
|
489
|
+
/**
|
|
490
|
+
* Error class for OkHi operations.
|
|
491
|
+
*
|
|
492
|
+
* @remarks
|
|
493
|
+
* All OkHi functions that can fail will throw an `OkHiException`.
|
|
494
|
+
* Use the static code constants for type-safe error handling in switch statements.
|
|
495
|
+
*
|
|
496
|
+
* @example
|
|
497
|
+
* ```typescript
|
|
498
|
+
* import * as OkHi from 'react-native-okhi';
|
|
499
|
+
*
|
|
500
|
+
* try {
|
|
501
|
+
* const result = await OkHi.startDigitalAddressVerification();
|
|
502
|
+
* } catch (error) {
|
|
503
|
+
* if (error instanceof OkHi.OkHiException) {
|
|
504
|
+
* switch (error.code) {
|
|
505
|
+
* case OkHi.OkHiException.USER_CLOSED:
|
|
506
|
+
* console.log('User cancelled the verification');
|
|
507
|
+
* break;
|
|
508
|
+
* case OkHi.OkHiException.NETWORK_ERROR:
|
|
509
|
+
* console.log('Network issue:', error.message);
|
|
510
|
+
* break;
|
|
511
|
+
* case OkHi.OkHiException.PERMISSION_DENIED:
|
|
512
|
+
* console.log('Permission denied:', error.message);
|
|
513
|
+
* break;
|
|
514
|
+
* default:
|
|
515
|
+
* console.log('Error:', error.code, error.message);
|
|
516
|
+
* }
|
|
517
|
+
* }
|
|
518
|
+
* }
|
|
519
|
+
* ```
|
|
520
|
+
*/
|
|
521
|
+
export declare class OkHiException extends Error {
|
|
522
|
+
/**
|
|
523
|
+
* A fatal error occurred that caused the SDK to exit unexpectedly.
|
|
524
|
+
*/
|
|
525
|
+
static readonly FATAL_EXIT: OkHiErrorCode;
|
|
526
|
+
/**
|
|
527
|
+
* The user dismissed or closed the verification flow.
|
|
528
|
+
*/
|
|
529
|
+
static readonly USER_CLOSED: OkHiErrorCode;
|
|
530
|
+
/**
|
|
531
|
+
* An unknown or unexpected error occurred.
|
|
532
|
+
*/
|
|
533
|
+
static readonly UNKNOWN: OkHiErrorCode;
|
|
534
|
+
/**
|
|
535
|
+
* A network connectivity error occurred.
|
|
536
|
+
*/
|
|
537
|
+
static readonly NETWORK_ERROR: OkHiErrorCode;
|
|
538
|
+
/**
|
|
539
|
+
* Required permissions were not granted.
|
|
540
|
+
*/
|
|
541
|
+
static readonly PERMISSION_DENIED: OkHiErrorCode;
|
|
542
|
+
/**
|
|
543
|
+
* The OkHi service is temporarily unavailable.
|
|
544
|
+
*/
|
|
545
|
+
static readonly SERVICE_UNAVAILABLE: OkHiErrorCode;
|
|
546
|
+
/**
|
|
547
|
+
* The device is not supported (e.g., missing Play Services, unsupported platform).
|
|
548
|
+
*/
|
|
549
|
+
static readonly UNSUPPORTED_DEVICE: OkHiErrorCode;
|
|
550
|
+
/**
|
|
551
|
+
* Authentication failed. Call `login()` with valid credentials.
|
|
552
|
+
*/
|
|
553
|
+
static readonly UNAUTHENTICATED: OkHiErrorCode;
|
|
554
|
+
/**
|
|
555
|
+
* The phone number provided is invalid.
|
|
556
|
+
*/
|
|
557
|
+
static readonly INVALID_PHONE: OkHiErrorCode;
|
|
558
|
+
/**
|
|
559
|
+
* Machine-readable error code.
|
|
560
|
+
* Use this for programmatic error handling with switch statements.
|
|
561
|
+
*
|
|
562
|
+
* @example
|
|
563
|
+
* ```typescript
|
|
564
|
+
* if (error.code === OkHi.OkHiException.USER_CLOSED) {
|
|
565
|
+
* // Handle user cancellation
|
|
566
|
+
* }
|
|
567
|
+
* ```
|
|
568
|
+
*/
|
|
569
|
+
readonly code: OkHiErrorCode;
|
|
570
|
+
/**
|
|
571
|
+
* Creates a new OkHiException.
|
|
572
|
+
*
|
|
573
|
+
* @param code - The error code
|
|
574
|
+
* @param message - Human-readable error description
|
|
575
|
+
*/
|
|
576
|
+
constructor(code: OkHiErrorCode, message: string);
|
|
577
|
+
/**
|
|
578
|
+
* Normalizes error codes from native SDKs to standard OkHi error codes.
|
|
579
|
+
*
|
|
580
|
+
* @param nativeCode - The error code received from native SDK
|
|
581
|
+
* @returns The normalized OkHiErrorCode
|
|
582
|
+
*
|
|
583
|
+
* @internal
|
|
584
|
+
*/
|
|
585
|
+
static normalizeCode(nativeCode: string | undefined | null): OkHiErrorCode;
|
|
586
|
+
/**
|
|
587
|
+
* Creates an OkHiException from a native error object.
|
|
588
|
+
*
|
|
589
|
+
* @param error - The error object from native SDK
|
|
590
|
+
* @returns A new OkHiException instance
|
|
591
|
+
*
|
|
592
|
+
* @internal
|
|
593
|
+
*/
|
|
594
|
+
static fromNativeError(error: {
|
|
595
|
+
code?: string;
|
|
596
|
+
message?: string;
|
|
597
|
+
}): OkHiException;
|
|
598
|
+
/**
|
|
599
|
+
* Type guard to check if an error is an OkHiException.
|
|
600
|
+
*
|
|
601
|
+
* @param error - The error to check
|
|
602
|
+
* @returns True if the error is an OkHiException
|
|
603
|
+
*
|
|
604
|
+
* @example
|
|
605
|
+
* ```typescript
|
|
606
|
+
* try {
|
|
607
|
+
* await OkHi.startDigitalAddressVerification();
|
|
608
|
+
* } catch (error) {
|
|
609
|
+
* if (OkHi.OkHiException.isOkHiException(error)) {
|
|
610
|
+
* console.log(error.code, error.message);
|
|
611
|
+
* }
|
|
612
|
+
* }
|
|
613
|
+
* ```
|
|
614
|
+
*/
|
|
615
|
+
static isOkHiException(error: unknown): error is OkHiException;
|
|
616
|
+
}
|
|
81
617
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAAG;IACrB,QAAQ,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,MAAM,QAAQ,GAAG;IACrB;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,MAAM,QAAQ,GAAG;IACrB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH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
"name": "react-native-okhi",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "The OkHi React Native library enables you to collect and verify addresses from your users",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "https://github.com/OkHi/react-native-okhi",
|
|
@@ -60,7 +60,8 @@
|
|
|
60
60
|
"clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib",
|
|
61
61
|
"prepare": "bob build",
|
|
62
62
|
"typecheck": "tsc",
|
|
63
|
-
"lint": "eslint \"**/*.{js,ts,tsx}\""
|
|
63
|
+
"lint": "eslint \"**/*.{js,ts,tsx}\"",
|
|
64
|
+
"docs": "typedoc"
|
|
64
65
|
},
|
|
65
66
|
"peerDependencies": {
|
|
66
67
|
"react": "*",
|
|
@@ -86,6 +87,7 @@
|
|
|
86
87
|
"react-native": "0.83.0",
|
|
87
88
|
"react-native-builder-bob": "^0.40.13",
|
|
88
89
|
"turbo": "^2.5.6",
|
|
90
|
+
"typedoc": "^0.28.16",
|
|
89
91
|
"typescript": "^5.9.2"
|
|
90
92
|
},
|
|
91
93
|
"react-native-builder-bob": {
|
package/src/NativeOkhi.ts
CHANGED