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.
@@ -1,10 +1,256 @@
1
+ /**
2
+ * @packageDocumentation
3
+ * React Native OkHi SDK
4
+ *
5
+ * A comprehensive React Native library for address verification using OkHi's
6
+ * digital and physical verification methods.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * import * as OkHi from 'react-native-okhi';
11
+ *
12
+ * // 1. Login
13
+ * await OkHi.login({
14
+ * auth: { branchId: 'xxx', clientKey: 'xxx' },
15
+ * user: { firstName: 'John', lastName: 'Doe', phone: '+254...', email: '...' },
16
+ * });
17
+ *
18
+ * // 2. Start verification
19
+ * const result = await OkHi.startDigitalAddressVerification();
20
+ * console.log('Verified address:', result.location.formattedAddress);
21
+ * ```
22
+ */
1
23
  import type { OkCollect, OkHiLogin, OkHiSuccessResponse } from './types';
2
- export type * from './types';
3
- export declare function multiply(a: number, b: number): number;
24
+ export * from './types';
25
+ /**
26
+ * Authenticates a user with the OkHi platform.
27
+ *
28
+ * @remarks
29
+ * This must be called before any verification functions. It establishes
30
+ * the user session and validates your API credentials.
31
+ *
32
+ * **When to call login:** The login function should be called once you have
33
+ * an authenticated user in your app. A common place to call login is immediately
34
+ * after the app dashboard is rendered, for example in a banking app after a user
35
+ * successfully signs in.
36
+ *
37
+ * It initializes OkHi and enables your users to resume verification if they
38
+ * switch devices, as well as enables re-verification of previously unknown addresses.
39
+ *
40
+ * The login persists for the duration of the app session.
41
+ *
42
+ * @param credentials - The login configuration containing auth credentials and user info
43
+ * @returns A promise that resolves with an array of permission strings that were granted,
44
+ * or `null` if `withPermissionsRequest` was not enabled
45
+ *
46
+ * @example
47
+ * ```typescript
48
+ * import * as OkHi from 'react-native-okhi';
49
+ * import type { OkHiLogin } from 'react-native-okhi';
50
+ *
51
+ * const credentials: OkHiLogin = {
52
+ * auth: {
53
+ * branchId: 'your_branch_id',
54
+ * clientKey: 'your_client_key',
55
+ * },
56
+ * user: {
57
+ * firstName: 'John',
58
+ * lastName: 'Doe',
59
+ * phone: '+254712345678',
60
+ * email: 'john.doe@example.com',
61
+ * },
62
+ * };
63
+ *
64
+ * try {
65
+ * await OkHi.login(credentials);
66
+ * console.log('Login successful');
67
+ * } catch (error) {
68
+ * console.error('Login failed:', error);
69
+ * }
70
+ * ```
71
+ *
72
+ * @see {@link OkHiLogin} - Configuration type
73
+ * @see {@link startDigitalAddressVerification} - Call after login to verify addresses
74
+ */
4
75
  export declare function login(credentials: OkHiLogin): Promise<string[] | null>;
76
+ /**
77
+ * @remarks
78
+ * Starts the digital address verification flow.
79
+ *
80
+ * **Prerequisites:**
81
+ * - Must call {@link login} first
82
+ *
83
+ * @param okcollect - Optional configuration for styling and behavior
84
+ * @returns A promise that resolves with the user and location data
85
+ *
86
+ * @example
87
+ * ```typescript
88
+ * import * as OkHi from 'react-native-okhi';
89
+ *
90
+ * // Basic usage with defaults
91
+ * const result = await OkHi.startDigitalAddressVerification();
92
+ * console.log('Address:', result.location.formattedAddress);
93
+ * console.log('Location ID:', result.location.id);
94
+ * ```
95
+ *
96
+ * @example
97
+ * ```typescript
98
+ * import * as OkHi from 'react-native-okhi';
99
+ * import type { OkCollect } from 'react-native-okhi';
100
+ *
101
+ * // With custom styling
102
+ * const config: OkCollect = {
103
+ * style: {
104
+ * color: '#FF5722',
105
+ * logo: 'https://example.com/logo.png',
106
+ * },
107
+ * configuration: {
108
+ * streetView: true,
109
+ * },
110
+ * };
111
+ *
112
+ * const result = await OkHi.startDigitalAddressVerification(config);
113
+ * ```
114
+ *
115
+ * @example
116
+ * ```typescript
117
+ * import * as OkHi from 'react-native-okhi';
118
+ *
119
+ * // Start verification on previously created address
120
+ * const locationId: string = await fetchLocationIDFromMyDB()
121
+ * const result = await OkHi.startDigitalAddressVerification({
122
+ * locationId: locationId,
123
+ * });
124
+ * ```
125
+ *
126
+ * @see {@link OkCollect} - Configuration options
127
+ * @see {@link OkHiSuccessResponse} - Return type
128
+ * @see {@link startPhysicalAddressVerification} - For physical verification
129
+ * @see {@link startDigitalAndPhysicalAddressVerification} - For combined verification
130
+ */
5
131
  export declare function startDigitalAddressVerification(okcollect?: OkCollect): Promise<OkHiSuccessResponse>;
132
+ /**
133
+ * Starts the physical address verification flow.
134
+ *
135
+ * @remarks
136
+ * Physical verification requires an agent to visit the user's location
137
+ * in person.
138
+ *
139
+ * **Prerequisites:**
140
+ * - Must call {@link login} first
141
+ *
142
+ * @param okcollect - Optional configuration for styling and behavior
143
+ * @returns A promise that resolves with the user and location data
144
+ *
145
+ * @example
146
+ * ```typescript
147
+ * import * as OkHi from 'react-native-okhi';
148
+ *
149
+ * const result = await OkHi.startPhysicalAddressVerification();
150
+ * console.log('Verification requested for:', result.location.formattedAddress);
151
+ * console.log('Location ID for tracking:', result.location.id);
152
+ * ```
153
+ *
154
+ * @example
155
+ * ```typescript
156
+ * import * as OkHi from 'react-native-okhi';
157
+ *
158
+ * // With custom configuration
159
+ * const result = await OkHi.startPhysicalAddressVerification({
160
+ * style: { color: '#2196F3' },
161
+ * });
162
+ * ```
163
+ *
164
+ * @see {@link OkCollect} - Configuration options
165
+ * @see {@link OkHiSuccessResponse} - Return type
166
+ * @see {@link startDigitalAddressVerification} - For instant digital verification
167
+ * @see {@link startDigitalAndPhysicalAddressVerification} - For combined verification
168
+ */
6
169
  export declare function startPhysicalAddressVerification(okcollect?: OkCollect): Promise<OkHiSuccessResponse>;
170
+ /**
171
+ * Starts both digital and physical address verification flows.
172
+ *
173
+ * @remarks
174
+ * This combines both verification methods for maximum confidence.
175
+ *
176
+ * **Prerequisites:**
177
+ * - Must call {@link login} first
178
+ *
179
+ * @param okcollect - Optional configuration for styling and behavior
180
+ * @returns A promise that resolves with the user and location data
181
+ *
182
+ * @example
183
+ * ```typescript
184
+ * import * as OkHi from 'react-native-okhi';
185
+ *
186
+ * const result = await OkHi.startDigitalAndPhysicalAddressVerification();
187
+ * console.log('Physical + Digital Verification started for:', result.location.id);
188
+ * ```
189
+ *
190
+ * @example
191
+ * ```typescript
192
+ * import * as OkHi from 'react-native-okhi';
193
+ *
194
+ * // With full customization
195
+ * const result = await OkHi.startDigitalAndPhysicalAddressVerification({
196
+ * style: {
197
+ * color: '#4CAF50',
198
+ * logo: 'https://example.com/logo.png',
199
+ * },
200
+ * configuration: {
201
+ * streetView: true,
202
+ * },
203
+ * });
204
+ * ```
205
+ *
206
+ * @see {@link OkCollect} - Configuration options
207
+ * @see {@link OkHiSuccessResponse} - Return type
208
+ * @see {@link startDigitalAddressVerification} - For digital-only verification
209
+ * @see {@link startPhysicalAddressVerification} - For physical-only verification
210
+ */
7
211
  export declare function startDigitalAndPhysicalAddressVerification(okcollect?: OkCollect): Promise<OkHiSuccessResponse>;
212
+ /**
213
+ * Creates an address without starting verification.
214
+ *
215
+ * @remarks
216
+ * Use this when you want to collect and store an address but defer
217
+ * verification to a later time. The address can
218
+ * be verified later using the returned `locationId`.
219
+ *
220
+ * **Prerequisites:**
221
+ * - Must call {@link login} first
222
+ *
223
+ * @param okcollect - Optional configuration for styling and behavior
224
+ * @returns A promise that resolves with the user and location data
225
+ *
226
+ * @example
227
+ * ```typescript
228
+ * import * as OkHi from 'react-native-okhi';
229
+ *
230
+ * // Create address without verification
231
+ * const result = await OkHi.createAddress();
232
+ * console.log('Address created:', result.location.id);
233
+ *
234
+ * // Save the location ID to verify later
235
+ * const locationId = result.location.id;
236
+ * await saveToDatabase({ locationId: locationId });
237
+ * ```
238
+ *
239
+ * @example
240
+ * ```typescript
241
+ * import * as OkHi from 'react-native-okhi';
242
+ *
243
+ * // Later, verify the saved address
244
+ * const savedLocationId = await fetchLocationIdFromMyDB();
245
+ * const result = await OkHi.startDigitalAddressVerification({
246
+ * locationId: savedLocationId,
247
+ * });
248
+ * ```
249
+ *
250
+ * @see {@link OkCollect} - Configuration options
251
+ * @see {@link OkHiSuccessResponse} - Return type
252
+ * @see {@link startDigitalAddressVerification} - To verify an address
253
+ */
8
254
  export declare function createAddress(okcollect?: OkCollect): Promise<OkHiSuccessResponse>;
9
255
  export declare function isLocationServicesEnabled(): Promise<boolean>;
10
256
  export declare function canOpenProtectedApps(): Promise<boolean>;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AACzE,mBAAmB,SAAS,CAAC;AAE7B,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAErD;AAED,wBAAgB,KAAK,CAAC,WAAW,EAAE,SAAS,GAAG,OAAO,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,CAMtE;AAuDD,wBAAgB,+BAA+B,CAC7C,SAAS,CAAC,EAAE,SAAS,GACpB,OAAO,CAAC,mBAAmB,CAAC,CAO9B;AAED,wBAAgB,gCAAgC,CAC9C,SAAS,CAAC,EAAE,SAAS,GACpB,OAAO,CAAC,mBAAmB,CAAC,CAO9B;AAED,wBAAgB,0CAA0C,CACxD,SAAS,CAAC,EAAE,SAAS,GACpB,OAAO,CAAC,mBAAmB,CAAC,CAU9B;AAED,wBAAgB,aAAa,CAC3B,SAAS,CAAC,EAAE,SAAS,GACpB,OAAO,CAAC,mBAAmB,CAAC,CAO9B;AAkCD,wBAAgB,yBAAyB,IAAI,OAAO,CAAC,OAAO,CAAC,CAM5D;AAED,wBAAgB,oBAAoB,IAAI,OAAO,CAAC,OAAO,CAAC,CAMvD;AAED,wBAAgB,wBAAwB,IAAI,OAAO,CAAC,MAAM,CAAC,CAM1D;AAED,wBAAgB,qCAAqC,IAAI,OAAO,CAAC,OAAO,CAAC,CAMxE;AAED,wBAAgB,iCAAiC,IAAI,OAAO,CAAC,OAAO,CAAC,CAMpE;AAED,wBAAgB,+BAA+B,IAAI,OAAO,CAAC,OAAO,CAAC,CAMlE;AAED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