react-native-persona 2.2.29 → 2.3.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.
@@ -34,13 +34,76 @@ export interface InquiryOptions {
34
34
  accountId?: AccountId;
35
35
  environment?: Environment;
36
36
  sessionToken?: string;
37
+ returnCollectedData?: boolean;
37
38
  fields?: Fields;
38
39
  onComplete?: OnCompleteCallback;
39
40
  onCanceled?: OnCanceledCallback;
40
41
  onError?: OnErrorCallback;
41
42
  iosThemeObject?: Object | null;
42
43
  }
43
- declare type OnCompleteCallback = (inquiryId: string, status: string, fields: Fields) => void;
44
+ declare type OnCompleteCallback = (inquiryId: string, status: string, fields: Fields, extraData: ExtraData) => void;
45
+ export interface ExtraData {
46
+ collectedData: CollectedData | null;
47
+ }
48
+ export interface CollectedData {
49
+ stepData: StepData[];
50
+ }
51
+ export interface StepData {
52
+ stepName: string;
53
+ }
54
+ export declare class DocumentStepData implements StepData {
55
+ stepName: string;
56
+ documents: Document[];
57
+ constructor();
58
+ }
59
+ export interface Document {
60
+ absoluteFilePath: string;
61
+ }
62
+ export declare class GovernmentIdStepData implements StepData {
63
+ stepName: string;
64
+ captures: GovernmentIdCapture[];
65
+ constructor();
66
+ }
67
+ export interface GovernmentIdCapture {
68
+ idClass: string;
69
+ captureMethod: GovernmentIdCaptureMethod;
70
+ side: GovernmentIdCaptureSide;
71
+ frames: GovernmentIdCaptureFrames[];
72
+ }
73
+ export declare enum GovernmentIdCaptureMethod {
74
+ Manual = "Manual",
75
+ Auto = "Auto",
76
+ Upload = "Upload"
77
+ }
78
+ export declare enum GovernmentIdCaptureSide {
79
+ Front = "Front",
80
+ Back = "Back"
81
+ }
82
+ export interface GovernmentIdCaptureFrames {
83
+ absoluteFilePath: string;
84
+ }
85
+ export declare class SelfieStepData implements StepData {
86
+ stepName: string;
87
+ centerCapture: SelfieCapture | null;
88
+ leftCapture: SelfieCapture | null;
89
+ rightCapture: SelfieCapture | null;
90
+ constructor();
91
+ }
92
+ export interface SelfieCapture {
93
+ captureMethod: SelfieCaptureMethod;
94
+ absoluteFilePath: string;
95
+ }
96
+ export declare enum SelfieCaptureMethod {
97
+ Manual = "Manual",
98
+ Auto = "Auto"
99
+ }
100
+ export declare class UiStepData implements StepData {
101
+ stepName: string;
102
+ componentParams: {
103
+ [key: string]: any;
104
+ };
105
+ constructor();
106
+ }
44
107
  declare type OnCanceledCallback = (inquiryId?: string, sessionToken?: string) => void;
45
108
  declare type OnErrorCallback = (error: Error) => void;
46
109
  export declare class Inquiry {
@@ -50,6 +113,7 @@ export declare class Inquiry {
50
113
  accountId?: AccountId;
51
114
  environment?: Environment;
52
115
  sessionToken?: string;
116
+ returnCollectedData?: boolean;
53
117
  iosThemeObject?: Object | null;
54
118
  fields?: Fields | null;
55
119
  private readonly onComplete?;
@@ -122,11 +186,13 @@ declare class TemplateBuilder {
122
186
  private _environment?;
123
187
  private _fields?;
124
188
  private _sessionToken?;
189
+ private _returnCollectedData?;
125
190
  private _onComplete?;
126
191
  private _onCanceled?;
127
192
  private _onError?;
128
193
  private _iosThemeObject?;
129
194
  constructor(templateId?: TemplateId | null, templateVersion?: TemplateVersion | null);
195
+ returnCollectedData(returnCollectedData: boolean): this;
130
196
  referenceId(referenceId: string): TemplateBuilder;
131
197
  accountId(accountId: string): TemplateBuilder;
132
198
  environment(environment: Environment): TemplateBuilder;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "react-native-persona",
3
3
  "title": "React Native Persona",
4
- "version": "2.2.29",
4
+ "version": "2.3.0",
5
5
  "description": "Launch a mobile native implementation of the Persona inquiry flow from React Native.",
6
6
  "main": "lib/commonjs/index",
7
7
  "module": "lib/module/index",
package/src/index.ts CHANGED
@@ -111,6 +111,7 @@ export interface InquiryOptions {
111
111
  accountId?: AccountId;
112
112
  environment?: Environment;
113
113
  sessionToken?: string;
114
+ returnCollectedData?: boolean;
114
115
 
115
116
  // Fields
116
117
  fields?: Fields;
@@ -127,9 +128,109 @@ export interface InquiryOptions {
127
128
  type OnCompleteCallback = (
128
129
  inquiryId: string,
129
130
  status: string,
130
- fields: Fields
131
+ fields: Fields,
132
+ extraData: ExtraData,
131
133
  ) => void;
132
134
 
135
+ /**
136
+ * Type for collected data that came directly from iOS/Android.
137
+ * Needs to be translated to TS classes before returning.
138
+ */
139
+ interface ExternalCollectedData {
140
+ stepData: any[]
141
+ }
142
+
143
+ export interface ExtraData {
144
+ collectedData: CollectedData | null;
145
+ }
146
+ export interface CollectedData {
147
+ stepData: StepData[]
148
+ }
149
+
150
+ export interface StepData {
151
+ stepName: string;
152
+ }
153
+
154
+ export class DocumentStepData implements StepData {
155
+ stepName: string;
156
+ documents: Document[];
157
+
158
+ constructor() {
159
+ this.stepName = ""
160
+ this.documents = []
161
+ }
162
+ }
163
+
164
+ export interface Document {
165
+ absoluteFilePath: string;
166
+ }
167
+
168
+ export class GovernmentIdStepData implements StepData {
169
+ stepName: string;
170
+ captures: GovernmentIdCapture[];
171
+
172
+ constructor() {
173
+ this.stepName = ""
174
+ this.captures = []
175
+ }
176
+ }
177
+
178
+ export interface GovernmentIdCapture {
179
+ idClass: string;
180
+ captureMethod: GovernmentIdCaptureMethod;
181
+ side: GovernmentIdCaptureSide;
182
+ frames: GovernmentIdCaptureFrames[];
183
+ }
184
+
185
+ export enum GovernmentIdCaptureMethod {
186
+ Manual = "Manual",
187
+ Auto = "Auto",
188
+ Upload = "Upload",
189
+ }
190
+
191
+ export enum GovernmentIdCaptureSide {
192
+ Front = "Front",
193
+ Back = "Back",
194
+ }
195
+
196
+ export interface GovernmentIdCaptureFrames {
197
+ absoluteFilePath: string;
198
+ }
199
+
200
+ export class SelfieStepData implements StepData {
201
+ stepName: string;
202
+ centerCapture: SelfieCapture | null;
203
+ leftCapture: SelfieCapture | null;
204
+ rightCapture: SelfieCapture | null;
205
+
206
+ constructor() {
207
+ this.stepName = ""
208
+ this.centerCapture = null
209
+ this.leftCapture = null
210
+ this.rightCapture = null
211
+ }
212
+ }
213
+
214
+ export interface SelfieCapture {
215
+ captureMethod: SelfieCaptureMethod;
216
+ absoluteFilePath: string;
217
+ }
218
+
219
+ export enum SelfieCaptureMethod {
220
+ Manual = "Manual",
221
+ Auto = "Auto",
222
+ }
223
+
224
+ export class UiStepData implements StepData {
225
+ stepName: string;
226
+ componentParams: { [key: string]: any }
227
+
228
+ constructor() {
229
+ this.stepName = ""
230
+ this.componentParams = {}
231
+ }
232
+ }
233
+
133
234
  type OnCanceledCallback = (inquiryId?: string, sessionToken?: string) => void;
134
235
 
135
236
  type OnErrorCallback = (error: Error) => void;
@@ -143,6 +244,7 @@ export class Inquiry {
143
244
  accountId?: AccountId;
144
245
  environment?: Environment;
145
246
  sessionToken?: string;
247
+ returnCollectedData?: boolean;
146
248
 
147
249
  iosThemeObject?: Object | null;
148
250
  fields?: Fields | null;
@@ -163,6 +265,7 @@ export class Inquiry {
163
265
  this.environment = options.environment;
164
266
  this.sessionToken = options.sessionToken;
165
267
  this.fields = options.fields;
268
+ this.returnCollectedData = options.returnCollectedData;
166
269
 
167
270
  // Callbacks
168
271
  this.onComplete = options.onComplete;
@@ -231,6 +334,7 @@ export class Inquiry {
231
334
  inquiryId: string;
232
335
  status: string;
233
336
  fields: Record<string, RawInquiryField>;
337
+ collectedData: ExternalCollectedData | null;
234
338
  }) => {
235
339
  if (this.onComplete) {
236
340
  let fields: Fields = {};
@@ -257,7 +361,41 @@ export class Inquiry {
257
361
  break;
258
362
  }
259
363
  }
260
- this.onComplete(event.inquiryId, event.status, fields);
364
+
365
+ let collectedData: CollectedData | null = null
366
+
367
+ let stepData = event.collectedData?.stepData
368
+ if (stepData != null) {
369
+ // Translate the step data from JSON to actual class objects
370
+ let translatedStepData = []
371
+
372
+ for (let stepDatum of stepData) {
373
+ switch (stepDatum.type) {
374
+ case 'DocumentStepData':
375
+ translatedStepData.push(Object.assign(new DocumentStepData(), stepDatum))
376
+ break;
377
+ case 'GovernmentIdStepData':
378
+ translatedStepData.push(Object.assign(new GovernmentIdStepData(), stepDatum))
379
+ break;
380
+ case 'SelfieStepData':
381
+ translatedStepData.push(Object.assign(new SelfieStepData(), stepDatum))
382
+ break;
383
+ case 'UiStepData':
384
+ translatedStepData.push(Object.assign(new UiStepData(), stepDatum))
385
+ break;
386
+ }
387
+ }
388
+
389
+ collectedData = {
390
+ stepData: translatedStepData
391
+ }
392
+ }
393
+
394
+ let extraData: ExtraData = {
395
+ collectedData: collectedData
396
+ }
397
+
398
+ this.onComplete(event.inquiryId, event.status, fields, extraData);
261
399
  }
262
400
  this.clearListeners();
263
401
  }
@@ -288,6 +426,7 @@ export class Inquiry {
288
426
  environment: this.environment,
289
427
  sessionToken: this.sessionToken,
290
428
  fields: this.fields,
429
+ returnCollectedData: this.returnCollectedData,
291
430
  iosTheme: processThemeValues(this.iosThemeObject || {}),
292
431
  });
293
432
  }
@@ -359,6 +498,7 @@ class TemplateBuilder {
359
498
  private _environment?: Environment;
360
499
  private _fields?: Fields;
361
500
  private _sessionToken?: string;
501
+ private _returnCollectedData?: boolean;
362
502
 
363
503
  // Callbacks
364
504
  private _onComplete?: OnCompleteCallback;
@@ -384,6 +524,12 @@ class TemplateBuilder {
384
524
  return this;
385
525
  }
386
526
 
527
+ returnCollectedData(returnCollectedData: boolean) {
528
+ this._returnCollectedData = returnCollectedData
529
+
530
+ return this
531
+ }
532
+
387
533
  referenceId(referenceId: string): TemplateBuilder {
388
534
  this._accountId = undefined;
389
535
  this._referenceId = referenceId;
@@ -453,6 +599,7 @@ class TemplateBuilder {
453
599
  onCanceled: this._onCanceled,
454
600
  onError: this._onError,
455
601
  iosThemeObject: this._iosThemeObject,
602
+ returnCollectedData: this._returnCollectedData,
456
603
  });
457
604
  }
458
605
  }