react-native-persona 2.2.30 → 2.4.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/CHANGELOG.md +45 -0
- package/README.md +5 -2
- package/RNPersonaInquiry2.podspec +1 -1
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/withpersona/sdk2/reactnative/PersonaInquiryModule2.java +161 -3
- package/ios/PersonaInquiry2.swift +134 -120
- package/lib/commonjs/index.js +182 -5
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/index.js +166 -3
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/index.d.ts +90 -1
- package/package.json +1 -1
- package/src/index.ts +191 -2
package/lib/module/index.js
CHANGED
|
@@ -78,12 +78,94 @@ function makeAccountId(candidate) {
|
|
|
78
78
|
|
|
79
79
|
|
|
80
80
|
export let Environment;
|
|
81
|
+
/**
|
|
82
|
+
* An enum value which determines whether this sdk should use the theme values sent from the server.
|
|
83
|
+
*/
|
|
81
84
|
|
|
82
85
|
(function (Environment) {
|
|
83
86
|
Environment["SANDBOX"] = "sandbox";
|
|
84
87
|
Environment["PRODUCTION"] = "production";
|
|
85
88
|
})(Environment || (Environment = {}));
|
|
86
89
|
|
|
90
|
+
export let ThemeSource;
|
|
91
|
+
|
|
92
|
+
(function (ThemeSource) {
|
|
93
|
+
ThemeSource["SERVER"] = "server";
|
|
94
|
+
ThemeSource["CLIENT"] = "client";
|
|
95
|
+
})(ThemeSource || (ThemeSource = {}));
|
|
96
|
+
|
|
97
|
+
export class DocumentStepData {
|
|
98
|
+
constructor() {
|
|
99
|
+
_defineProperty(this, "stepName", void 0);
|
|
100
|
+
|
|
101
|
+
_defineProperty(this, "documents", void 0);
|
|
102
|
+
|
|
103
|
+
this.stepName = "";
|
|
104
|
+
this.documents = [];
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
}
|
|
108
|
+
export class GovernmentIdStepData {
|
|
109
|
+
constructor() {
|
|
110
|
+
_defineProperty(this, "stepName", void 0);
|
|
111
|
+
|
|
112
|
+
_defineProperty(this, "captures", void 0);
|
|
113
|
+
|
|
114
|
+
this.stepName = "";
|
|
115
|
+
this.captures = [];
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
}
|
|
119
|
+
export let GovernmentIdCaptureMethod;
|
|
120
|
+
|
|
121
|
+
(function (GovernmentIdCaptureMethod) {
|
|
122
|
+
GovernmentIdCaptureMethod["Manual"] = "Manual";
|
|
123
|
+
GovernmentIdCaptureMethod["Auto"] = "Auto";
|
|
124
|
+
GovernmentIdCaptureMethod["Upload"] = "Upload";
|
|
125
|
+
})(GovernmentIdCaptureMethod || (GovernmentIdCaptureMethod = {}));
|
|
126
|
+
|
|
127
|
+
export let GovernmentIdCaptureSide;
|
|
128
|
+
|
|
129
|
+
(function (GovernmentIdCaptureSide) {
|
|
130
|
+
GovernmentIdCaptureSide["Front"] = "Front";
|
|
131
|
+
GovernmentIdCaptureSide["Back"] = "Back";
|
|
132
|
+
})(GovernmentIdCaptureSide || (GovernmentIdCaptureSide = {}));
|
|
133
|
+
|
|
134
|
+
export class SelfieStepData {
|
|
135
|
+
constructor() {
|
|
136
|
+
_defineProperty(this, "stepName", void 0);
|
|
137
|
+
|
|
138
|
+
_defineProperty(this, "centerCapture", void 0);
|
|
139
|
+
|
|
140
|
+
_defineProperty(this, "leftCapture", void 0);
|
|
141
|
+
|
|
142
|
+
_defineProperty(this, "rightCapture", void 0);
|
|
143
|
+
|
|
144
|
+
this.stepName = "";
|
|
145
|
+
this.centerCapture = null;
|
|
146
|
+
this.leftCapture = null;
|
|
147
|
+
this.rightCapture = null;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
}
|
|
151
|
+
export let SelfieCaptureMethod;
|
|
152
|
+
|
|
153
|
+
(function (SelfieCaptureMethod) {
|
|
154
|
+
SelfieCaptureMethod["Manual"] = "Manual";
|
|
155
|
+
SelfieCaptureMethod["Auto"] = "Auto";
|
|
156
|
+
})(SelfieCaptureMethod || (SelfieCaptureMethod = {}));
|
|
157
|
+
|
|
158
|
+
export class UiStepData {
|
|
159
|
+
constructor() {
|
|
160
|
+
_defineProperty(this, "stepName", void 0);
|
|
161
|
+
|
|
162
|
+
_defineProperty(this, "componentParams", void 0);
|
|
163
|
+
|
|
164
|
+
this.stepName = "";
|
|
165
|
+
this.componentParams = {};
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
}
|
|
87
169
|
const eventEmitter = new NativeEventEmitter(PersonaInquiry2);
|
|
88
170
|
export class Inquiry {
|
|
89
171
|
constructor(options) {
|
|
@@ -99,8 +181,12 @@ export class Inquiry {
|
|
|
99
181
|
|
|
100
182
|
_defineProperty(this, "sessionToken", void 0);
|
|
101
183
|
|
|
184
|
+
_defineProperty(this, "returnCollectedData", void 0);
|
|
185
|
+
|
|
102
186
|
_defineProperty(this, "iosThemeObject", void 0);
|
|
103
187
|
|
|
188
|
+
_defineProperty(this, "themeSource", void 0);
|
|
189
|
+
|
|
104
190
|
_defineProperty(this, "fields", void 0);
|
|
105
191
|
|
|
106
192
|
_defineProperty(this, "onComplete", void 0);
|
|
@@ -121,13 +207,15 @@ export class Inquiry {
|
|
|
121
207
|
this.accountId = options.accountId;
|
|
122
208
|
this.environment = options.environment;
|
|
123
209
|
this.sessionToken = options.sessionToken;
|
|
124
|
-
this.fields = options.fields;
|
|
210
|
+
this.fields = options.fields;
|
|
211
|
+
this.returnCollectedData = options.returnCollectedData; // Callbacks
|
|
125
212
|
|
|
126
213
|
this.onComplete = options.onComplete;
|
|
127
214
|
this.onCanceled = options.onCanceled;
|
|
128
215
|
this.onError = options.onError; // Theme object
|
|
129
216
|
|
|
130
217
|
this.iosThemeObject = options.iosThemeObject;
|
|
218
|
+
this.themeSource = options.themeSource;
|
|
131
219
|
}
|
|
132
220
|
|
|
133
221
|
clearListeners() {
|
|
@@ -188,6 +276,8 @@ export class Inquiry {
|
|
|
188
276
|
start() {
|
|
189
277
|
this.onCompleteListener = eventEmitter.addListener('onComplete', event => {
|
|
190
278
|
if (this.onComplete) {
|
|
279
|
+
var _event$collectedData;
|
|
280
|
+
|
|
191
281
|
let fields = {};
|
|
192
282
|
|
|
193
283
|
for (let key of Object.keys(event.fields || {})) {
|
|
@@ -217,7 +307,42 @@ export class Inquiry {
|
|
|
217
307
|
}
|
|
218
308
|
}
|
|
219
309
|
|
|
220
|
-
|
|
310
|
+
let collectedData = null;
|
|
311
|
+
let stepData = (_event$collectedData = event.collectedData) === null || _event$collectedData === void 0 ? void 0 : _event$collectedData.stepData;
|
|
312
|
+
|
|
313
|
+
if (stepData != null) {
|
|
314
|
+
// Translate the step data from JSON to actual class objects
|
|
315
|
+
let translatedStepData = [];
|
|
316
|
+
|
|
317
|
+
for (let stepDatum of stepData) {
|
|
318
|
+
switch (stepDatum.type) {
|
|
319
|
+
case 'DocumentStepData':
|
|
320
|
+
translatedStepData.push(Object.assign(new DocumentStepData(), stepDatum));
|
|
321
|
+
break;
|
|
322
|
+
|
|
323
|
+
case 'GovernmentIdStepData':
|
|
324
|
+
translatedStepData.push(Object.assign(new GovernmentIdStepData(), stepDatum));
|
|
325
|
+
break;
|
|
326
|
+
|
|
327
|
+
case 'SelfieStepData':
|
|
328
|
+
translatedStepData.push(Object.assign(new SelfieStepData(), stepDatum));
|
|
329
|
+
break;
|
|
330
|
+
|
|
331
|
+
case 'UiStepData':
|
|
332
|
+
translatedStepData.push(Object.assign(new UiStepData(), stepDatum));
|
|
333
|
+
break;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
collectedData = {
|
|
338
|
+
stepData: translatedStepData
|
|
339
|
+
};
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
let extraData = {
|
|
343
|
+
collectedData: collectedData
|
|
344
|
+
};
|
|
345
|
+
this.onComplete(event.inquiryId, event.status, fields, extraData);
|
|
221
346
|
}
|
|
222
347
|
|
|
223
348
|
this.clearListeners();
|
|
@@ -238,6 +363,8 @@ export class Inquiry {
|
|
|
238
363
|
environment: this.environment,
|
|
239
364
|
sessionToken: this.sessionToken,
|
|
240
365
|
fields: this.fields,
|
|
366
|
+
returnCollectedData: this.returnCollectedData,
|
|
367
|
+
themeSource: this.themeSource,
|
|
241
368
|
iosTheme: processThemeValues(this.iosThemeObject || {})
|
|
242
369
|
});
|
|
243
370
|
}
|
|
@@ -259,6 +386,8 @@ class InquiryBuilder {
|
|
|
259
386
|
|
|
260
387
|
_defineProperty(this, "_iosThemeObject", void 0);
|
|
261
388
|
|
|
389
|
+
_defineProperty(this, "_themeSource", ThemeSource.SERVER);
|
|
390
|
+
|
|
262
391
|
_defineProperty(this, "_fields", void 0);
|
|
263
392
|
|
|
264
393
|
this._inquiryId = inquiryId;
|
|
@@ -283,9 +412,20 @@ class InquiryBuilder {
|
|
|
283
412
|
this._onError = callback;
|
|
284
413
|
return this;
|
|
285
414
|
}
|
|
415
|
+
/**
|
|
416
|
+
* @deprecated Use iosThemeToUse
|
|
417
|
+
*/
|
|
418
|
+
|
|
286
419
|
|
|
287
420
|
iosTheme(themeObject) {
|
|
288
421
|
this._iosThemeObject = themeObject;
|
|
422
|
+
this._themeSource = ThemeSource.CLIENT;
|
|
423
|
+
return this;
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
iosThemeToUse(themeObject, themeSource) {
|
|
427
|
+
this._iosThemeObject = themeObject;
|
|
428
|
+
this._themeSource = themeSource;
|
|
289
429
|
return this;
|
|
290
430
|
}
|
|
291
431
|
|
|
@@ -297,6 +437,7 @@ class InquiryBuilder {
|
|
|
297
437
|
onCanceled: this._onCanceled,
|
|
298
438
|
onError: this._onError,
|
|
299
439
|
iosThemeObject: this._iosThemeObject,
|
|
440
|
+
themeSource: this._themeSource,
|
|
300
441
|
fields: this._fields
|
|
301
442
|
});
|
|
302
443
|
}
|
|
@@ -321,6 +462,8 @@ class TemplateBuilder {
|
|
|
321
462
|
|
|
322
463
|
_defineProperty(this, "_sessionToken", void 0);
|
|
323
464
|
|
|
465
|
+
_defineProperty(this, "_returnCollectedData", void 0);
|
|
466
|
+
|
|
324
467
|
_defineProperty(this, "_onComplete", void 0);
|
|
325
468
|
|
|
326
469
|
_defineProperty(this, "_onCanceled", void 0);
|
|
@@ -329,6 +472,8 @@ class TemplateBuilder {
|
|
|
329
472
|
|
|
330
473
|
_defineProperty(this, "_iosThemeObject", void 0);
|
|
331
474
|
|
|
475
|
+
_defineProperty(this, "_themeSource", ThemeSource.SERVER);
|
|
476
|
+
|
|
332
477
|
if (templateId != null) {
|
|
333
478
|
this._templateId = templateId;
|
|
334
479
|
} else if (templateVersion != null) {
|
|
@@ -340,6 +485,11 @@ class TemplateBuilder {
|
|
|
340
485
|
return this;
|
|
341
486
|
}
|
|
342
487
|
|
|
488
|
+
returnCollectedData(returnCollectedData) {
|
|
489
|
+
this._returnCollectedData = returnCollectedData;
|
|
490
|
+
return this;
|
|
491
|
+
}
|
|
492
|
+
|
|
343
493
|
referenceId(referenceId) {
|
|
344
494
|
this._accountId = undefined;
|
|
345
495
|
this._referenceId = referenceId;
|
|
@@ -381,9 +531,20 @@ class TemplateBuilder {
|
|
|
381
531
|
this._onError = callback;
|
|
382
532
|
return this;
|
|
383
533
|
}
|
|
534
|
+
/**
|
|
535
|
+
* @deprecated Use iosThemeToUse
|
|
536
|
+
*/
|
|
537
|
+
|
|
384
538
|
|
|
385
539
|
iosTheme(themeObject) {
|
|
386
540
|
this._iosThemeObject = themeObject;
|
|
541
|
+
this._themeSource = ThemeSource.CLIENT;
|
|
542
|
+
return this;
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
iosThemeToUse(themeObject, themeSource) {
|
|
546
|
+
this._iosThemeObject = themeObject;
|
|
547
|
+
this._themeSource = themeSource;
|
|
387
548
|
return this;
|
|
388
549
|
}
|
|
389
550
|
|
|
@@ -399,7 +560,9 @@ class TemplateBuilder {
|
|
|
399
560
|
onComplete: this._onComplete,
|
|
400
561
|
onCanceled: this._onCanceled,
|
|
401
562
|
onError: this._onError,
|
|
402
|
-
iosThemeObject: this._iosThemeObject
|
|
563
|
+
iosThemeObject: this._iosThemeObject,
|
|
564
|
+
themeSource: this._themeSource,
|
|
565
|
+
returnCollectedData: this._returnCollectedData
|
|
403
566
|
});
|
|
404
567
|
}
|
|
405
568
|
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.ts"],"names":["NativeEventEmitter","NativeModules","processThemeValues","Fields","InquiryField","Versions","PersonaInquiry2","InvalidTemplateId","Error","InvalidTemplateVersion","InvalidInquiryId","InvalidAccountId","makeInquiryId","candidate","startsWith","makeTemplateId","makeTemplateVersion","makeAccountId","Environment","eventEmitter","Inquiry","constructor","options","templateId","inquiryId","referenceId","accountId","environment","sessionToken","fields","onComplete","onCanceled","onError","iosThemeObject","clearListeners","onCompleteListener","remove","onCanceledListener","onErrorListener","fromTemplate","TemplateBuilder","fromTemplateVersion","templateVersion","fromInquiry","InquiryBuilder","start","addListener","event","key","Object","keys","field","undefined","Unknown","type","Integer","Number","parseInt","value","Boolean","String","status","debugMessage","startInquiry","iosTheme","_inquiryId","_sessionToken","callback","_onComplete","_onCanceled","_onError","themeObject","_iosThemeObject","build","_fields","_templateId","_templateVersion","_accountId","_referenceId","_environment","InquiryBuilders"],"mappings":";;AAAA,SAEEA,kBAFF,EAGEC,aAHF,QAIO,cAJP;AAKA,SAASC,kBAAT,QAAmC,QAAnC;AACA,SAASC,MAAT,EAAiBC,YAAjB,QAAsD,UAAtD;AAEA,SAASD,MAAT;AAEA,SAASE,QAAT,QAAyB,YAAzB;AAEA,SAASA,QAAT;AAEA,MAAM;AAAEC,EAAAA;AAAF,IAAsBL,aAA5B,C,CAEA;AACA;;AASA,OAAO,MAAMM,iBAAN,SAAgCC,KAAhC,CAAsC;AAE7C,OAAO,MAAMC,sBAAN,SAAqCD,KAArC,CAA2C;AAElD,OAAO,MAAME,gBAAN,SAA+BF,KAA/B,CAAqC;AAE5C,OAAO,MAAMG,gBAAN,SAA+BH,KAA/B,CA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,YALD;AAMjBnD,MAAAA,YAAY,EAAE,KAAKsC,aANF;AAOjBrC,MAAAA,MAAM,EAAE,KAAK6C,OAPI;AAQjB5C,MAAAA,UAAU,EAAE,KAAKsC,WARA;AASjBrC,MAAAA,UAAU,EAAE,KAAKsC,WATA;AAUjBrC,MAAAA,OAAO,EAAE,KAAKsC,QAVG;AAWjBrC,MAAAA,cAAc,EAAE,KAAKuC;AAXJ,KAAZ,CAAP;AAaD;;AAvGmB;AA0GtB;AACA;AACA;;;;;;AAKS,WAAS7B,WAAT,CAAqBnB,SAArB,EAAwC;AAC7C,WAAOJ,OAAO,CAACuB,WAAR,CAAoBnB,SAApB,CAAP;AACD;;;;AAKM,WAASe,YAAT,CAAsBhB,UAAtB,EAA0C;AAC/C,WAAOH,OAAO,CAACmB,YAAR,CAAqBhB,UAArB,CAAP;AACD;;;;AAKM,WAASkB,mBAAT,CAA6BC,eAA7B,EAAsD;AAC3D,WAAOtB,OAAO,CAACqB,mBAAR,CAA4BC,eAA5B,CAAP;AACD;;;GApBOsC,e,KAAAA,e;;AAuBV,eAAeA,eAAf","sourcesContent":["import {\n EventSubscription,\n NativeEventEmitter,\n NativeModules,\n} from 'react-native';\nimport { processThemeValues } from './util';\nimport { Fields, InquiryField, RawInquiryField } from './fields';\n\nexport { Fields };\n\nimport { Versions } from './versions';\n\nexport { Versions };\n\nconst { PersonaInquiry2 } = NativeModules;\n\n// Using Opaque types + Smart Constructor enforces validation at\n// instantiation time for IDS\ndeclare const Unique: unique symbol;\nexport type Opaque<T, Tag> = T & { [Unique]: Tag };\n\ntype TemplateId = Opaque<string, 'TemplateId'>;\ntype TemplateVersion = Opaque<string, 'TemplateVersion'>;\ntype InquiryId = Opaque<string, 'InquiryId'>;\ntype AccountId = Opaque<string, 'AccountId'>;\n\nexport class InvalidTemplateId extends Error {}\n\nexport class InvalidTemplateVersion extends Error {}\n\nexport class InvalidInquiryId extends Error {}\n\nexport class InvalidAccountId extends Error {}\n\n/**\n * Run validations that the string is in proper Inquiry token format\n * and do a type conversion to InquiryId.\n *\n * @param candidate\n */\nfunction makeInquiryId(candidate: string): InquiryId {\n if (candidate.startsWith('inq_')) return candidate as InquiryId;\n\n throw new InvalidInquiryId(\n `Valid template IDs start with \"inq_\". Received: ${candidate} `\n );\n}\n\n/**\n * Run validations that the string is in proper Template token format\n * and do a type conversion to TemplateId.\n *\n * @param candidate\n */\nfunction makeTemplateId(candidate: string): TemplateId {\n if (candidate.startsWith('itmpl_')) {\n return candidate as TemplateId;\n }\n\n throw new InvalidTemplateId(\n `Valid template IDs start with \"itmpl_\". Received: ${candidate} `\n );\n}\n\n/**\n * Run validations that the string is in proper Template Version token format\n * and do a type conversion to TemplateVersion.\n *\n * @param candidate\n */\nfunction makeTemplateVersion(candidate: string): TemplateVersion {\n if (candidate.startsWith('itmplv_')) {\n return candidate as TemplateVersion;\n }\n\n throw new InvalidTemplateVersion(\n `Valid template versions start with \"itmplv_\". Received: ${candidate} `\n );\n}\n\n/**\n * Run validations that the string is in proper Template token format\n * and do a type conversion to AccountId.\n *\n * @param candidate\n */\nfunction makeAccountId(candidate: string): AccountId {\n if (candidate.startsWith('act_')) {\n return candidate as AccountId;\n }\n\n throw new InvalidAccountId(\n `Valid account IDs start with \"act_\". Received: ${candidate} `\n );\n}\n\n/**\n * String enum for environments. These strings will be parsed\n * on the native side bridge into Kotlin / Swift enums.\n */\nexport enum Environment {\n SANDBOX = 'sandbox',\n PRODUCTION = 'production',\n}\n\nexport interface InquiryOptions {\n templateId?: TemplateId;\n templateVersion?: TemplateVersion;\n inquiryId?: InquiryId;\n referenceId?: string;\n accountId?: AccountId;\n environment?: Environment;\n sessionToken?: string;\n\n // Fields\n fields?: Fields;\n\n // Callbacks\n onComplete?: OnCompleteCallback;\n onCanceled?: OnCanceledCallback;\n onError?: OnErrorCallback;\n\n // Customization\n iosThemeObject?: Object | null;\n}\n\ntype OnCompleteCallback = (\n inquiryId: string,\n status: string,\n fields: Fields\n) => void;\n\ntype OnCanceledCallback = (inquiryId?: string, sessionToken?: string) => void;\n\ntype OnErrorCallback = (error: Error) => void;\n\nconst eventEmitter = new NativeEventEmitter(PersonaInquiry2);\n\nexport class Inquiry {\n templateId?: TemplateId;\n inquiryId?: InquiryId;\n referenceId?: string;\n accountId?: AccountId;\n environment?: Environment;\n sessionToken?: string;\n\n iosThemeObject?: Object | null;\n fields?: Fields | null;\n\n private readonly onComplete?: OnCompleteCallback;\n private readonly onCanceled?: OnCanceledCallback;\n private readonly onError?: OnErrorCallback;\n\n private onCompleteListener?: EventSubscription;\n private onCanceledListener?: EventSubscription;\n private onErrorListener?: EventSubscription;\n\n constructor(options: InquiryOptions) {\n this.templateId = options.templateId;\n this.inquiryId = options.inquiryId;\n this.referenceId = options.referenceId;\n this.accountId = options.accountId;\n this.environment = options.environment;\n this.sessionToken = options.sessionToken;\n this.fields = options.fields;\n\n // Callbacks\n this.onComplete = options.onComplete;\n this.onCanceled = options.onCanceled;\n this.onError = options.onError;\n\n // Theme object\n this.iosThemeObject = options.iosThemeObject;\n }\n\n private clearListeners() {\n if (this.onCompleteListener) this.onCompleteListener.remove();\n if (this.onCanceledListener) this.onCanceledListener.remove();\n if (this.onErrorListener) this.onErrorListener.remove();\n }\n\n /**\n * Create an Inquiry flow builder based on a template ID.\n *\n * You can find your template ID on the Dashboard under Inquiries > Templates.\n * {@link https://app.withpersona.com/dashboard/inquiry-templates}\n *\n * @param templateId template ID from your Persona Dashboard\n * @return builder for the Inquiry flow\n */\n static fromTemplate(templateId: string) {\n return new TemplateBuilder(makeTemplateId(templateId), null);\n }\n\n /**\n * Create an Inquiry flow builder based on a template ID version.\n *\n * You can find your template ID version on the Dashboard under the\n * settings view of a specific template.\n * {@link https://app.withpersona.com/dashboard/inquiry-templates}\n *\n * @param templateVersion template version from your Persona Dashboard\n * @return builder for the Inquiry flow\n */\n static fromTemplateVersion(templateVersion: string) {\n return new TemplateBuilder(null, makeTemplateVersion(templateVersion));\n }\n\n /**\n * Create an Inquiry flow builder based on an inquiry ID.\n *\n * You will need to generate the inquiry ID on the server. To try it out, you can create an\n * inquiry from the Persona Dashboard under \"Inquiries\". Click on the \"Create Inquiry\" button\n * and copy the inquiry ID from the URL.\n * {@link https://app.withpersona.com/dashboard/inquiries}\n *\n * @param inquiryId inquiry ID from your server\n * @return builder for the Inquiry flow\n */\n static fromInquiry(inquiryId: string) {\n return new InquiryBuilder(makeInquiryId(inquiryId));\n }\n\n /**\n * Launch the Persona Inquiry.\n */\n start() {\n this.onCompleteListener = eventEmitter.addListener(\n 'onComplete',\n (event: {\n inquiryId: string;\n status: string;\n fields: Record<string, RawInquiryField>;\n }) => {\n if (this.onComplete) {\n let fields: Fields = {};\n for (let key of Object.keys(event.fields || {})) {\n let field = event.fields[key];\n if (field == undefined) {\n fields[key] = new InquiryField.Unknown('null');\n continue;\n }\n switch (field.type) {\n case 'integer':\n fields[key] = new InquiryField.Integer(\n Number.parseInt(field.value)\n );\n break;\n case 'boolean':\n fields[key] = new InquiryField.Boolean(field.value);\n break;\n case 'string':\n fields[key] = new InquiryField.String(field.value);\n break;\n default:\n fields[key] = new InquiryField.Unknown(field.type);\n break;\n }\n }\n this.onComplete(event.inquiryId, event.status, fields);\n }\n this.clearListeners();\n }\n );\n\n this.onCanceledListener = eventEmitter.addListener(\n 'onCanceled',\n (event: { inquiryId?: string; sessionToken?: string }) => {\n if (this.onCanceled)\n this.onCanceled(event.inquiryId, event.sessionToken);\n this.clearListeners();\n }\n );\n\n this.onErrorListener = eventEmitter.addListener(\n 'onError',\n (event: { debugMessage: string }) => {\n if (this.onError) this.onError(new Error(event.debugMessage));\n this.clearListeners();\n }\n );\n\n PersonaInquiry2.startInquiry({\n templateId: this.templateId,\n inquiryId: this.inquiryId,\n referenceId: this.referenceId,\n accountId: this.accountId,\n environment: this.environment,\n sessionToken: this.sessionToken,\n fields: this.fields,\n iosTheme: processThemeValues(this.iosThemeObject || {}),\n });\n }\n}\n\nclass InquiryBuilder {\n private _inquiryId: InquiryId;\n private _sessionToken?: string;\n\n // Callbacks\n private _onComplete?: OnCompleteCallback;\n private _onCanceled?: OnCanceledCallback;\n private _onError?: OnErrorCallback;\n private _iosThemeObject?: Object;\n private _fields?: Fields;\n\n constructor(inquiryId: InquiryId) {\n this._inquiryId = inquiryId;\n }\n\n sessionToken(sessionToken: string): InquiryBuilder {\n this._sessionToken = sessionToken;\n\n return this;\n }\n\n onComplete(callback: OnCompleteCallback): InquiryBuilder {\n this._onComplete = callback;\n\n return this;\n }\n\n onCanceled(callback: OnCanceledCallback): InquiryBuilder {\n this._onCanceled = callback;\n\n return this;\n }\n\n onError(callback: OnErrorCallback): InquiryBuilder {\n this._onError = callback;\n\n return this;\n }\n\n iosTheme(themeObject: Object): InquiryBuilder {\n this._iosThemeObject = themeObject;\n\n return this;\n }\n\n build(): Inquiry {\n return new Inquiry({\n inquiryId: this._inquiryId,\n sessionToken: this._sessionToken,\n onComplete: this._onComplete,\n onCanceled: this._onCanceled,\n onError: this._onError,\n iosThemeObject: this._iosThemeObject,\n fields: this._fields,\n });\n }\n}\n\nclass TemplateBuilder {\n private readonly _templateId?: TemplateId;\n private readonly _templateVersion?: TemplateVersion;\n private _accountId?: AccountId;\n private _referenceId?: string;\n private _environment?: Environment;\n private _fields?: Fields;\n private _sessionToken?: string;\n\n // Callbacks\n private _onComplete?: OnCompleteCallback;\n private _onCanceled?: OnCanceledCallback;\n private _onError?: OnErrorCallback;\n\n // Customization\n private _iosThemeObject?: Object;\n\n constructor(\n templateId?: TemplateId | null,\n templateVersion?: TemplateVersion | null\n ) {\n if (templateId != null) {\n this._templateId = templateId;\n } else if (templateVersion != null) {\n this._templateVersion = templateVersion;\n } else {\n throw new InvalidTemplateId(\n `Either templateId or templateVersion needs to be set.`\n );\n }\n return this;\n }\n\n referenceId(referenceId: string): TemplateBuilder {\n this._accountId = undefined;\n this._referenceId = referenceId;\n\n return this;\n }\n\n accountId(accountId: string): TemplateBuilder {\n this._referenceId = undefined;\n this._accountId = makeAccountId(accountId);\n\n return this;\n }\n\n environment(environment: Environment): TemplateBuilder {\n this._environment = environment;\n\n return this;\n }\n\n sessionToken(sessionToken: string): TemplateBuilder {\n this._sessionToken = sessionToken;\n\n return this;\n }\n\n fields(fields: Fields): TemplateBuilder {\n this._fields = fields;\n\n return this;\n }\n\n onComplete(callback: OnCompleteCallback): TemplateBuilder {\n this._onComplete = callback;\n\n return this;\n }\n\n onCanceled(callback: OnCanceledCallback): TemplateBuilder {\n this._onCanceled = callback;\n\n return this;\n }\n\n onError(callback: OnErrorCallback): TemplateBuilder {\n this._onError = callback;\n\n return this;\n }\n\n iosTheme(themeObject: Object): TemplateBuilder {\n this._iosThemeObject = themeObject;\n\n return this;\n }\n\n build(): Inquiry {\n return new Inquiry({\n templateId: this._templateId,\n templateVersion: this._templateVersion,\n accountId: this._accountId,\n referenceId: this._referenceId,\n environment: this._environment,\n sessionToken: this._sessionToken,\n fields: this._fields,\n onComplete: this._onComplete,\n onCanceled: this._onCanceled,\n onError: this._onError,\n iosThemeObject: this._iosThemeObject,\n });\n }\n}\n\n/**\n * @deprecated Use the `Inquiry` static methods instead\n */\nnamespace InquiryBuilders {\n /**\n * @deprecated Use {@link Inquiry#fromInquiry} instead\n */\n export function fromInquiry(inquiryId: string) {\n return Inquiry.fromInquiry(inquiryId);\n }\n\n /**\n * @deprecated Use {@link Inquiry#fromTemplate} instead\n */\n export function fromTemplate(templateId: string) {\n return Inquiry.fromTemplate(templateId);\n }\n\n /**\n * @deprecated Use {@link Inquiry#fromTemplateVersion} instead\n */\n export function fromTemplateVersion(templateVersion: string) {\n return Inquiry.fromTemplateVersion(templateVersion);\n }\n}\n\nexport default InquiryBuilders;\n"]}
|
|
1
|
+
{"version":3,"sources":["index.ts"],"names":["NativeEventEmitter","NativeModules","processThemeValues","Fields","InquiryField","Versions","PersonaInquiry2","InvalidTemplateId","Error","InvalidTemplateVersion","InvalidInquiryId","InvalidAccountId","makeInquiryId","candidate","startsWith","makeTemplateId","makeTemplateVersion","makeAccountId","Environment","ThemeSource","DocumentStepData","constructor","stepName","documents","GovernmentIdStepData","captures","GovernmentIdCaptureMethod","GovernmentIdCaptureSide","SelfieStepData","centerCapture","leftCapture","rightCapture","SelfieCaptureMethod","UiStepData","componentParams","eventEmitter","Inquiry","options","templateId","inquiryId","referenceId","accountId","environment","sessionToken","fields","returnCollectedData","onComplete","onCanceled","onError","iosThemeObject","themeSource","clearListeners","onCompleteListener","remove","onCanceledListener","onErrorListener","fromTemplate","TemplateBuilder","fromTemplateVersion","templateVersion","fromInquiry","InquiryBuilder","start","addListener","event","key","Object","keys","field","undefined","Unknown","type","Integer","Number","parseInt","value","Boolean","String","collectedData","stepData","translatedStepData","stepDatum","push","assign","extraData","status","debugMessage","startInquiry","iosTheme","SERVER","_inquiryId","_sessionToken","callback","_onComplete","_onCanceled","_onError","themeObject","_iosThemeObject","_themeSource","CLIENT","iosThemeToUse","build","_fields","_templateId","_templateVersion","_returnCollectedData","_accountId","_referenceId","_environment","InquiryBuilders"],"mappings":";;AAAA,SAEEA,kBAFF,EAGEC,aAHF,QAIO,cAJP;AAKA,SAASC,kBAAT,QAAmC,QAAnC;AACA,SAASC,MAAT,EAAiBC,YAAjB,QAAsD,UAAtD;AAEA,SAASD,MAAT;AAEA,SAASE,QAAT,QAAyB,YAAzB;AAEA,SAASA,QAAT;AAEA,MAAM;AAAEC,EAAAA;AAAF,IAAsBL,aAA5B,C,CAEA;AACA;;AASA,OAAO,MAAMM,iBAAN,SAAgCC,KAAhC,CAAsC;AAE7C,OAAO,MAAMC,sBAAN,SAAqCD,KAArC,CAA2C;AAElD,OAAO,MAAME,gBAAN,SAA+BF,KAA/B,CAAqC;AAE5C,OAAO,MAAMG,gBAAN,SAA+BH,KAA/B,CAAqC;AAE5C;AACA;AACA;AACA;AACA;AACA;;AACA,SAASI,aAAT,CAAuBC,SAAvB,EAAqD;AACnD,MAAIA,SAAS,CAACC,UAAV,CAAqB,MAArB,CAAJ,EAAkC,OAAOD,SAAP;AAElC,QAAM,I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AAC5E,SAAK+C,eAAL,GAAuBD,WAAvB;AACA,SAAKE,YAAL,GAAoBhD,WAApB;AAEA,WAAO,IAAP;AACD;;AAEDmD,EAAAA,KAAK,GAAY;AACf,WAAO,IAAIjE,OAAJ,CAAY;AACjBE,MAAAA,UAAU,EAAE,KAAKiE,WADA;AAEjB5C,MAAAA,eAAe,EAAE,KAAK6C,gBAFL;AAGjB/D,MAAAA,SAAS,EAAE,KAAKiE,UAHC;AAIjBlE,MAAAA,WAAW,EAAE,KAAKmE,YAJD;AAKjBjE,MAAAA,WAAW,EAAE,KAAKkE,YALD;AAMjBjE,MAAAA,YAAY,EAAE,KAAKgD,aANF;AAOjB/C,MAAAA,MAAM,EAAE,KAAK0D,OAPI;AAQjBxD,MAAAA,UAAU,EAAE,KAAK+C,WARA;AASjB9C,MAAAA,UAAU,EAAE,KAAK+C,WATA;AAUjB9C,MAAAA,OAAO,EAAE,KAAK+C,QAVG;AAWjB9C,MAAAA,cAAc,EAAE,KAAKgD,eAXJ;AAYjB/C,MAAAA,WAAW,EAAE,KAAKgD,YAZD;AAajBrD,MAAAA,mBAAmB,EAAE,KAAK4D;AAbT,KAAZ,CAAP;AAeD;;AA5HmB;AA+HtB;AACA;AACA;;;;;;AAKS,WAAS7C,WAAT,CAAqBrB,SAArB,EAAwC;AAC7C,WAAOH,OAAO,CAACwB,WAAR,CAAoBrB,SAApB,CAAP;AACD;;;;AAKM,WAASiB,YAAT,CAAsBlB,UAAtB,EAA0C;AAC/C,WAAOF,OAAO,CAACoB,YAAR,CAAqBlB,UAArB,CAAP;AACD;;;;AAKM,WAASoB,mBAAT,CAA6BC,eAA7B,EAAsD;AAC3D,WAAOvB,OAAO,CAACsB,mBAAR,CAA4BC,eAA5B,CAAP;AACD;;;GApBOkD,e,KAAAA,e;;AAuBV,eAAeA,eAAf","sourcesContent":["import {\n EventSubscription,\n NativeEventEmitter,\n NativeModules,\n} from 'react-native';\nimport { processThemeValues } from './util';\nimport { Fields, InquiryField, RawInquiryField } from './fields';\n\nexport { Fields };\n\nimport { Versions } from './versions';\n\nexport { Versions };\n\nconst { PersonaInquiry2 } = NativeModules;\n\n// Using Opaque types + Smart Constructor enforces validation at\n// instantiation time for IDS\ndeclare const Unique: unique symbol;\nexport type Opaque<T, Tag> = T & { [Unique]: Tag };\n\ntype TemplateId = Opaque<string, 'TemplateId'>;\ntype TemplateVersion = Opaque<string, 'TemplateVersion'>;\ntype InquiryId = Opaque<string, 'InquiryId'>;\ntype AccountId = Opaque<string, 'AccountId'>;\n\nexport class InvalidTemplateId extends Error {}\n\nexport class InvalidTemplateVersion extends Error {}\n\nexport class InvalidInquiryId extends Error {}\n\nexport class InvalidAccountId extends Error {}\n\n/**\n * Run validations that the string is in proper Inquiry token format\n * and do a type conversion to InquiryId.\n *\n * @param candidate\n */\nfunction makeInquiryId(candidate: string): InquiryId {\n if (candidate.startsWith('inq_')) return candidate as InquiryId;\n\n throw new InvalidInquiryId(\n `Valid template IDs start with \"inq_\". Received: ${candidate} `\n );\n}\n\n/**\n * Run validations that the string is in proper Template token format\n * and do a type conversion to TemplateId.\n *\n * @param candidate\n */\nfunction makeTemplateId(candidate: string): TemplateId {\n if (candidate.startsWith('itmpl_')) {\n return candidate as TemplateId;\n }\n\n throw new InvalidTemplateId(\n `Valid template IDs start with \"itmpl_\". Received: ${candidate} `\n );\n}\n\n/**\n * Run validations that the string is in proper Template Version token format\n * and do a type conversion to TemplateVersion.\n *\n * @param candidate\n */\nfunction makeTemplateVersion(candidate: string): TemplateVersion {\n if (candidate.startsWith('itmplv_')) {\n return candidate as TemplateVersion;\n }\n\n throw new InvalidTemplateVersion(\n `Valid template versions start with \"itmplv_\". Received: ${candidate} `\n );\n}\n\n/**\n * Run validations that the string is in proper Template token format\n * and do a type conversion to AccountId.\n *\n * @param candidate\n */\nfunction makeAccountId(candidate: string): AccountId {\n if (candidate.startsWith('act_')) {\n return candidate as AccountId;\n }\n\n throw new InvalidAccountId(\n `Valid account IDs start with \"act_\". Received: ${candidate} `\n );\n}\n\n/**\n * String enum for environments. These strings will be parsed\n * on the native side bridge into Kotlin / Swift enums.\n */\nexport enum Environment {\n SANDBOX = 'sandbox',\n PRODUCTION = 'production',\n}\n\n/**\n * An enum value which determines whether this sdk should use the theme values sent from the server.\n */\nexport enum ThemeSource {\n SERVER = 'server',\n /**\n * @deprecated Client side theming is deprecated, please configure your theme inside\n * the Persona Dashboard and use SERVER as the theme source.\n */\n CLIENT = 'client',\n}\n\nexport interface InquiryOptions {\n templateId?: TemplateId;\n templateVersion?: TemplateVersion;\n inquiryId?: InquiryId;\n referenceId?: string;\n accountId?: AccountId;\n environment?: Environment;\n sessionToken?: string;\n returnCollectedData?: boolean;\n\n // Fields\n fields?: Fields;\n\n // Callbacks\n onComplete?: OnCompleteCallback;\n onCanceled?: OnCanceledCallback;\n onError?: OnErrorCallback;\n\n // Customization\n iosThemeObject?: Object | null;\n themeSource?: ThemeSource | null;\n}\n\ntype OnCompleteCallback = (\n inquiryId: string,\n status: string,\n fields: Fields,\n extraData: ExtraData,\n) => void;\n\n/**\n * Type for collected data that came directly from iOS/Android. \n * Needs to be translated to TS classes before returning.\n */\ninterface ExternalCollectedData {\n stepData: any[]\n}\n\nexport interface ExtraData {\n collectedData: CollectedData | null;\n}\nexport interface CollectedData {\n stepData: StepData[]\n}\n\nexport interface StepData {\n stepName: string;\n}\n \nexport class DocumentStepData implements StepData {\n stepName: string;\n documents: Document[];\n\n constructor() {\n this.stepName = \"\"\n this.documents = []\n }\n}\n \nexport interface Document {\n absoluteFilePath: string;\n}\n \nexport class GovernmentIdStepData implements StepData {\n stepName: string;\n captures: GovernmentIdCapture[];\n\n constructor() {\n this.stepName = \"\"\n this.captures = []\n }\n}\n\nexport interface GovernmentIdCapture {\n idClass: string;\n captureMethod: GovernmentIdCaptureMethod;\n side: GovernmentIdCaptureSide;\n frames: GovernmentIdCaptureFrames[];\n}\n\nexport enum GovernmentIdCaptureMethod {\n Manual = \"Manual\",\n Auto = \"Auto\",\n Upload = \"Upload\",\n}\n\nexport enum GovernmentIdCaptureSide {\n Front = \"Front\",\n Back = \"Back\",\n}\n\nexport interface GovernmentIdCaptureFrames {\n absoluteFilePath: string;\n}\n\nexport class SelfieStepData implements StepData {\n stepName: string;\n centerCapture: SelfieCapture | null;\n leftCapture: SelfieCapture | null;\n rightCapture: SelfieCapture | null;\n\n constructor() {\n this.stepName = \"\"\n this.centerCapture = null\n this.leftCapture = null\n this.rightCapture = null\n }\n}\n\nexport interface SelfieCapture {\n captureMethod: SelfieCaptureMethod;\n absoluteFilePath: string;\n}\n\nexport enum SelfieCaptureMethod {\n Manual = \"Manual\",\n Auto = \"Auto\",\n}\n\nexport class UiStepData implements StepData {\n stepName: string;\n componentParams: { [key: string]: any }\n\n constructor() {\n this.stepName = \"\"\n this.componentParams = {}\n }\n}\n\ntype OnCanceledCallback = (inquiryId?: string, sessionToken?: string) => void;\n\ntype OnErrorCallback = (error: Error) => void;\n\nconst eventEmitter = new NativeEventEmitter(PersonaInquiry2);\n\nexport class Inquiry {\n templateId?: TemplateId;\n inquiryId?: InquiryId;\n referenceId?: string;\n accountId?: AccountId;\n environment?: Environment;\n sessionToken?: string;\n returnCollectedData?: boolean;\n\n iosThemeObject?: Object | null;\n themeSource?: ThemeSource | null;\n fields?: Fields | null;\n\n private readonly onComplete?: OnCompleteCallback;\n private readonly onCanceled?: OnCanceledCallback;\n private readonly onError?: OnErrorCallback;\n\n private onCompleteListener?: EventSubscription;\n private onCanceledListener?: EventSubscription;\n private onErrorListener?: EventSubscription;\n\n constructor(options: InquiryOptions) {\n this.templateId = options.templateId;\n this.inquiryId = options.inquiryId;\n this.referenceId = options.referenceId;\n this.accountId = options.accountId;\n this.environment = options.environment;\n this.sessionToken = options.sessionToken;\n this.fields = options.fields;\n this.returnCollectedData = options.returnCollectedData;\n\n // Callbacks\n this.onComplete = options.onComplete;\n this.onCanceled = options.onCanceled;\n this.onError = options.onError;\n\n // Theme object\n this.iosThemeObject = options.iosThemeObject;\n this.themeSource = options.themeSource;\n }\n\n private clearListeners() {\n if (this.onCompleteListener) this.onCompleteListener.remove();\n if (this.onCanceledListener) this.onCanceledListener.remove();\n if (this.onErrorListener) this.onErrorListener.remove();\n }\n\n /**\n * Create an Inquiry flow builder based on a template ID.\n *\n * You can find your template ID on the Dashboard under Inquiries > Templates.\n * {@link https://app.withpersona.com/dashboard/inquiry-templates}\n *\n * @param templateId template ID from your Persona Dashboard\n * @return builder for the Inquiry flow\n */\n static fromTemplate(templateId: string) {\n return new TemplateBuilder(makeTemplateId(templateId), null);\n }\n\n /**\n * Create an Inquiry flow builder based on a template ID version.\n *\n * You can find your template ID version on the Dashboard under the\n * settings view of a specific template.\n * {@link https://app.withpersona.com/dashboard/inquiry-templates}\n *\n * @param templateVersion template version from your Persona Dashboard\n * @return builder for the Inquiry flow\n */\n static fromTemplateVersion(templateVersion: string) {\n return new TemplateBuilder(null, makeTemplateVersion(templateVersion));\n }\n\n /**\n * Create an Inquiry flow builder based on an inquiry ID.\n *\n * You will need to generate the inquiry ID on the server. To try it out, you can create an\n * inquiry from the Persona Dashboard under \"Inquiries\". Click on the \"Create Inquiry\" button\n * and copy the inquiry ID from the URL.\n * {@link https://app.withpersona.com/dashboard/inquiries}\n *\n * @param inquiryId inquiry ID from your server\n * @return builder for the Inquiry flow\n */\n static fromInquiry(inquiryId: string) {\n return new InquiryBuilder(makeInquiryId(inquiryId));\n }\n\n /**\n * Launch the Persona Inquiry.\n */\n start() {\n this.onCompleteListener = eventEmitter.addListener(\n 'onComplete',\n (event: {\n inquiryId: string;\n status: string;\n fields: Record<string, RawInquiryField>;\n collectedData: ExternalCollectedData | null;\n }) => {\n if (this.onComplete) {\n let fields: Fields = {};\n for (let key of Object.keys(event.fields || {})) {\n let field = event.fields[key];\n if (field == undefined) {\n fields[key] = new InquiryField.Unknown('null');\n continue;\n }\n switch (field.type) {\n case 'integer':\n fields[key] = new InquiryField.Integer(\n Number.parseInt(field.value)\n );\n break;\n case 'boolean':\n fields[key] = new InquiryField.Boolean(field.value);\n break;\n case 'string':\n fields[key] = new InquiryField.String(field.value);\n break;\n default:\n fields[key] = new InquiryField.Unknown(field.type);\n break;\n }\n }\n\n let collectedData: CollectedData | null = null\n\n let stepData = event.collectedData?.stepData\n if (stepData != null) {\n // Translate the step data from JSON to actual class objects\n let translatedStepData = []\n\n for (let stepDatum of stepData) {\n switch (stepDatum.type) {\n case 'DocumentStepData':\n translatedStepData.push(Object.assign(new DocumentStepData(), stepDatum))\n break;\n case 'GovernmentIdStepData':\n translatedStepData.push(Object.assign(new GovernmentIdStepData(), stepDatum))\n break;\n case 'SelfieStepData':\n translatedStepData.push(Object.assign(new SelfieStepData(), stepDatum))\n break;\n case 'UiStepData':\n translatedStepData.push(Object.assign(new UiStepData(), stepDatum))\n break;\n }\n }\n\n collectedData = {\n stepData: translatedStepData\n }\n }\n\n let extraData: ExtraData = {\n collectedData: collectedData\n }\n\n this.onComplete(event.inquiryId, event.status, fields, extraData);\n }\n this.clearListeners();\n }\n );\n\n this.onCanceledListener = eventEmitter.addListener(\n 'onCanceled',\n (event: { inquiryId?: string; sessionToken?: string }) => {\n if (this.onCanceled)\n this.onCanceled(event.inquiryId, event.sessionToken);\n this.clearListeners();\n }\n );\n\n this.onErrorListener = eventEmitter.addListener(\n 'onError',\n (event: { debugMessage: string }) => {\n if (this.onError) this.onError(new Error(event.debugMessage));\n this.clearListeners();\n }\n );\n\n PersonaInquiry2.startInquiry({\n templateId: this.templateId,\n inquiryId: this.inquiryId,\n referenceId: this.referenceId,\n accountId: this.accountId,\n environment: this.environment,\n sessionToken: this.sessionToken,\n fields: this.fields,\n returnCollectedData: this.returnCollectedData,\n themeSource: this.themeSource,\n iosTheme: processThemeValues(this.iosThemeObject || {}),\n });\n }\n}\n\nclass InquiryBuilder {\n private _inquiryId: InquiryId;\n private _sessionToken?: string;\n\n // Callbacks\n private _onComplete?: OnCompleteCallback;\n private _onCanceled?: OnCanceledCallback;\n private _onError?: OnErrorCallback;\n private _iosThemeObject?: Object;\n private _themeSource: ThemeSource = ThemeSource.SERVER;\n private _fields?: Fields;\n\n constructor(inquiryId: InquiryId) {\n this._inquiryId = inquiryId;\n }\n\n sessionToken(sessionToken: string): InquiryBuilder {\n this._sessionToken = sessionToken;\n\n return this;\n }\n\n onComplete(callback: OnCompleteCallback): InquiryBuilder {\n this._onComplete = callback;\n\n return this;\n }\n\n onCanceled(callback: OnCanceledCallback): InquiryBuilder {\n this._onCanceled = callback;\n\n return this;\n }\n\n onError(callback: OnErrorCallback): InquiryBuilder {\n this._onError = callback;\n\n return this;\n }\n\n /**\n * @deprecated Use iosThemeToUse\n */\n iosTheme(themeObject: Object): InquiryBuilder {\n this._iosThemeObject = themeObject;\n this._themeSource = ThemeSource.CLIENT;\n\n return this;\n }\n\n iosThemeToUse(themeObject: Object, themeSource: ThemeSource): InquiryBuilder {\n this._iosThemeObject = themeObject;\n this._themeSource = themeSource;\n\n return this;\n }\n\n build(): Inquiry {\n return new Inquiry({\n inquiryId: this._inquiryId,\n sessionToken: this._sessionToken,\n onComplete: this._onComplete,\n onCanceled: this._onCanceled,\n onError: this._onError,\n iosThemeObject: this._iosThemeObject,\n themeSource: this._themeSource,\n fields: this._fields,\n });\n }\n}\n\nclass TemplateBuilder {\n private readonly _templateId?: TemplateId;\n private readonly _templateVersion?: TemplateVersion;\n private _accountId?: AccountId;\n private _referenceId?: string;\n private _environment?: Environment;\n private _fields?: Fields;\n private _sessionToken?: string;\n private _returnCollectedData?: boolean;\n\n // Callbacks\n private _onComplete?: OnCompleteCallback;\n private _onCanceled?: OnCanceledCallback;\n private _onError?: OnErrorCallback;\n\n // Customization\n private _iosThemeObject?: Object;\n private _themeSource: ThemeSource = ThemeSource.SERVER;\n\n constructor(\n templateId?: TemplateId | null,\n templateVersion?: TemplateVersion | null\n ) {\n if (templateId != null) {\n this._templateId = templateId;\n } else if (templateVersion != null) {\n this._templateVersion = templateVersion;\n } else {\n throw new InvalidTemplateId(\n `Either templateId or templateVersion needs to be set.`\n );\n }\n return this;\n }\n\n returnCollectedData(returnCollectedData: boolean) {\n this._returnCollectedData = returnCollectedData\n\n return this\n }\n\n referenceId(referenceId: string): TemplateBuilder {\n this._accountId = undefined;\n this._referenceId = referenceId;\n\n return this;\n }\n\n accountId(accountId: string): TemplateBuilder {\n this._referenceId = undefined;\n this._accountId = makeAccountId(accountId);\n\n return this;\n }\n\n environment(environment: Environment): TemplateBuilder {\n this._environment = environment;\n\n return this;\n }\n\n sessionToken(sessionToken: string): TemplateBuilder {\n this._sessionToken = sessionToken;\n\n return this;\n }\n\n fields(fields: Fields): TemplateBuilder {\n this._fields = fields;\n\n return this;\n }\n\n onComplete(callback: OnCompleteCallback): TemplateBuilder {\n this._onComplete = callback;\n\n return this;\n }\n\n onCanceled(callback: OnCanceledCallback): TemplateBuilder {\n this._onCanceled = callback;\n\n return this;\n }\n\n onError(callback: OnErrorCallback): TemplateBuilder {\n this._onError = callback;\n\n return this;\n }\n\n /**\n * @deprecated Use iosThemeToUse\n */\n iosTheme(themeObject: Object): TemplateBuilder {\n this._iosThemeObject = themeObject;\n this._themeSource = ThemeSource.CLIENT;\n\n return this;\n }\n\n iosThemeToUse(themeObject: Object, themeSource: ThemeSource): TemplateBuilder {\n this._iosThemeObject = themeObject;\n this._themeSource = themeSource;\n\n return this;\n }\n\n build(): Inquiry {\n return new Inquiry({\n templateId: this._templateId,\n templateVersion: this._templateVersion,\n accountId: this._accountId,\n referenceId: this._referenceId,\n environment: this._environment,\n sessionToken: this._sessionToken,\n fields: this._fields,\n onComplete: this._onComplete,\n onCanceled: this._onCanceled,\n onError: this._onError,\n iosThemeObject: this._iosThemeObject,\n themeSource: this._themeSource,\n returnCollectedData: this._returnCollectedData,\n });\n }\n}\n\n/**\n * @deprecated Use the `Inquiry` static methods instead\n */\nnamespace InquiryBuilders {\n /**\n * @deprecated Use {@link Inquiry#fromInquiry} instead\n */\n export function fromInquiry(inquiryId: string) {\n return Inquiry.fromInquiry(inquiryId);\n }\n\n /**\n * @deprecated Use {@link Inquiry#fromTemplate} instead\n */\n export function fromTemplate(templateId: string) {\n return Inquiry.fromTemplate(templateId);\n }\n\n /**\n * @deprecated Use {@link Inquiry#fromTemplateVersion} instead\n */\n export function fromTemplateVersion(templateVersion: string) {\n return Inquiry.fromTemplateVersion(templateVersion);\n }\n}\n\nexport default InquiryBuilders;\n"]}
|
|
@@ -26,6 +26,17 @@ export declare enum Environment {
|
|
|
26
26
|
SANDBOX = "sandbox",
|
|
27
27
|
PRODUCTION = "production"
|
|
28
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* An enum value which determines whether this sdk should use the theme values sent from the server.
|
|
31
|
+
*/
|
|
32
|
+
export declare enum ThemeSource {
|
|
33
|
+
SERVER = "server",
|
|
34
|
+
/**
|
|
35
|
+
* @deprecated Client side theming is deprecated, please configure your theme inside
|
|
36
|
+
* the Persona Dashboard and use SERVER as the theme source.
|
|
37
|
+
*/
|
|
38
|
+
CLIENT = "client"
|
|
39
|
+
}
|
|
29
40
|
export interface InquiryOptions {
|
|
30
41
|
templateId?: TemplateId;
|
|
31
42
|
templateVersion?: TemplateVersion;
|
|
@@ -34,13 +45,77 @@ export interface InquiryOptions {
|
|
|
34
45
|
accountId?: AccountId;
|
|
35
46
|
environment?: Environment;
|
|
36
47
|
sessionToken?: string;
|
|
48
|
+
returnCollectedData?: boolean;
|
|
37
49
|
fields?: Fields;
|
|
38
50
|
onComplete?: OnCompleteCallback;
|
|
39
51
|
onCanceled?: OnCanceledCallback;
|
|
40
52
|
onError?: OnErrorCallback;
|
|
41
53
|
iosThemeObject?: Object | null;
|
|
54
|
+
themeSource?: ThemeSource | null;
|
|
55
|
+
}
|
|
56
|
+
declare type OnCompleteCallback = (inquiryId: string, status: string, fields: Fields, extraData: ExtraData) => void;
|
|
57
|
+
export interface ExtraData {
|
|
58
|
+
collectedData: CollectedData | null;
|
|
59
|
+
}
|
|
60
|
+
export interface CollectedData {
|
|
61
|
+
stepData: StepData[];
|
|
62
|
+
}
|
|
63
|
+
export interface StepData {
|
|
64
|
+
stepName: string;
|
|
65
|
+
}
|
|
66
|
+
export declare class DocumentStepData implements StepData {
|
|
67
|
+
stepName: string;
|
|
68
|
+
documents: Document[];
|
|
69
|
+
constructor();
|
|
70
|
+
}
|
|
71
|
+
export interface Document {
|
|
72
|
+
absoluteFilePath: string;
|
|
73
|
+
}
|
|
74
|
+
export declare class GovernmentIdStepData implements StepData {
|
|
75
|
+
stepName: string;
|
|
76
|
+
captures: GovernmentIdCapture[];
|
|
77
|
+
constructor();
|
|
78
|
+
}
|
|
79
|
+
export interface GovernmentIdCapture {
|
|
80
|
+
idClass: string;
|
|
81
|
+
captureMethod: GovernmentIdCaptureMethod;
|
|
82
|
+
side: GovernmentIdCaptureSide;
|
|
83
|
+
frames: GovernmentIdCaptureFrames[];
|
|
84
|
+
}
|
|
85
|
+
export declare enum GovernmentIdCaptureMethod {
|
|
86
|
+
Manual = "Manual",
|
|
87
|
+
Auto = "Auto",
|
|
88
|
+
Upload = "Upload"
|
|
89
|
+
}
|
|
90
|
+
export declare enum GovernmentIdCaptureSide {
|
|
91
|
+
Front = "Front",
|
|
92
|
+
Back = "Back"
|
|
93
|
+
}
|
|
94
|
+
export interface GovernmentIdCaptureFrames {
|
|
95
|
+
absoluteFilePath: string;
|
|
96
|
+
}
|
|
97
|
+
export declare class SelfieStepData implements StepData {
|
|
98
|
+
stepName: string;
|
|
99
|
+
centerCapture: SelfieCapture | null;
|
|
100
|
+
leftCapture: SelfieCapture | null;
|
|
101
|
+
rightCapture: SelfieCapture | null;
|
|
102
|
+
constructor();
|
|
103
|
+
}
|
|
104
|
+
export interface SelfieCapture {
|
|
105
|
+
captureMethod: SelfieCaptureMethod;
|
|
106
|
+
absoluteFilePath: string;
|
|
107
|
+
}
|
|
108
|
+
export declare enum SelfieCaptureMethod {
|
|
109
|
+
Manual = "Manual",
|
|
110
|
+
Auto = "Auto"
|
|
111
|
+
}
|
|
112
|
+
export declare class UiStepData implements StepData {
|
|
113
|
+
stepName: string;
|
|
114
|
+
componentParams: {
|
|
115
|
+
[key: string]: any;
|
|
116
|
+
};
|
|
117
|
+
constructor();
|
|
42
118
|
}
|
|
43
|
-
declare type OnCompleteCallback = (inquiryId: string, status: string, fields: Fields) => void;
|
|
44
119
|
declare type OnCanceledCallback = (inquiryId?: string, sessionToken?: string) => void;
|
|
45
120
|
declare type OnErrorCallback = (error: Error) => void;
|
|
46
121
|
export declare class Inquiry {
|
|
@@ -50,7 +125,9 @@ export declare class Inquiry {
|
|
|
50
125
|
accountId?: AccountId;
|
|
51
126
|
environment?: Environment;
|
|
52
127
|
sessionToken?: string;
|
|
128
|
+
returnCollectedData?: boolean;
|
|
53
129
|
iosThemeObject?: Object | null;
|
|
130
|
+
themeSource?: ThemeSource | null;
|
|
54
131
|
fields?: Fields | null;
|
|
55
132
|
private readonly onComplete?;
|
|
56
133
|
private readonly onCanceled?;
|
|
@@ -105,13 +182,18 @@ declare class InquiryBuilder {
|
|
|
105
182
|
private _onCanceled?;
|
|
106
183
|
private _onError?;
|
|
107
184
|
private _iosThemeObject?;
|
|
185
|
+
private _themeSource;
|
|
108
186
|
private _fields?;
|
|
109
187
|
constructor(inquiryId: InquiryId);
|
|
110
188
|
sessionToken(sessionToken: string): InquiryBuilder;
|
|
111
189
|
onComplete(callback: OnCompleteCallback): InquiryBuilder;
|
|
112
190
|
onCanceled(callback: OnCanceledCallback): InquiryBuilder;
|
|
113
191
|
onError(callback: OnErrorCallback): InquiryBuilder;
|
|
192
|
+
/**
|
|
193
|
+
* @deprecated Use iosThemeToUse
|
|
194
|
+
*/
|
|
114
195
|
iosTheme(themeObject: Object): InquiryBuilder;
|
|
196
|
+
iosThemeToUse(themeObject: Object, themeSource: ThemeSource): InquiryBuilder;
|
|
115
197
|
build(): Inquiry;
|
|
116
198
|
}
|
|
117
199
|
declare class TemplateBuilder {
|
|
@@ -122,11 +204,14 @@ declare class TemplateBuilder {
|
|
|
122
204
|
private _environment?;
|
|
123
205
|
private _fields?;
|
|
124
206
|
private _sessionToken?;
|
|
207
|
+
private _returnCollectedData?;
|
|
125
208
|
private _onComplete?;
|
|
126
209
|
private _onCanceled?;
|
|
127
210
|
private _onError?;
|
|
128
211
|
private _iosThemeObject?;
|
|
212
|
+
private _themeSource;
|
|
129
213
|
constructor(templateId?: TemplateId | null, templateVersion?: TemplateVersion | null);
|
|
214
|
+
returnCollectedData(returnCollectedData: boolean): this;
|
|
130
215
|
referenceId(referenceId: string): TemplateBuilder;
|
|
131
216
|
accountId(accountId: string): TemplateBuilder;
|
|
132
217
|
environment(environment: Environment): TemplateBuilder;
|
|
@@ -135,7 +220,11 @@ declare class TemplateBuilder {
|
|
|
135
220
|
onComplete(callback: OnCompleteCallback): TemplateBuilder;
|
|
136
221
|
onCanceled(callback: OnCanceledCallback): TemplateBuilder;
|
|
137
222
|
onError(callback: OnErrorCallback): TemplateBuilder;
|
|
223
|
+
/**
|
|
224
|
+
* @deprecated Use iosThemeToUse
|
|
225
|
+
*/
|
|
138
226
|
iosTheme(themeObject: Object): TemplateBuilder;
|
|
227
|
+
iosThemeToUse(themeObject: Object, themeSource: ThemeSource): TemplateBuilder;
|
|
139
228
|
build(): Inquiry;
|
|
140
229
|
}
|
|
141
230
|
/**
|
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.
|
|
4
|
+
"version": "2.4.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",
|