react-native-persona 2.6.0 → 2.7.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/RNPersonaInquiry2.podspec +2 -2
- package/android/build.gradle +3 -2
- package/android/gradle/wrapper/gradle-wrapper.properties +1 -1
- package/android/src/main/java/com/withpersona/sdk2/reactnative/PersonaInquiryModule2.java +16 -21
- package/ios/PersonaInquiry2.swift +6 -6
- package/lib/commonjs/index.js +23 -4
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/index.js +23 -4
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/index.d.ts +9 -4
- package/package.json +1 -1
- package/src/index.ts +27 -10
|
@@ -25,11 +25,11 @@ Pod::Spec.new do |s|
|
|
|
25
25
|
|
|
26
26
|
s.default_subspec = 'Core'
|
|
27
27
|
s.subspec 'Core' do |ss|
|
|
28
|
-
ss.dependency 'PersonaInquirySDK2', '2.
|
|
28
|
+
ss.dependency 'PersonaInquirySDK2', '2.12.0'
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
s.subspec 'Nfc' do |ss|
|
|
32
|
-
ss.dependency 'PersonaNfc', '2.
|
|
32
|
+
ss.dependency 'PersonaNfc', '2.12.0'
|
|
33
33
|
ss.dependency 'OpenSSL-Universal', '1.1.180'
|
|
34
34
|
end
|
|
35
35
|
end
|
package/android/build.gradle
CHANGED
|
@@ -11,7 +11,7 @@ buildscript {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
dependencies {
|
|
14
|
-
classpath 'com.android.tools.build:gradle:
|
|
14
|
+
classpath 'com.android.tools.build:gradle:8.1.1'
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
}
|
|
@@ -66,5 +66,6 @@ dependencies {
|
|
|
66
66
|
//noinspection GradleDynamicVersion
|
|
67
67
|
implementation 'com.facebook.react:react-native:+' // From node_modules
|
|
68
68
|
|
|
69
|
-
|
|
69
|
+
// NB: be sure to bump `nfc-impl` in example/android/app/build.gradle as well
|
|
70
|
+
implementation 'com.withpersona.sdk2:inquiry:2.9.1'
|
|
70
71
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
distributionBase=GRADLE_USER_HOME
|
|
2
2
|
distributionPath=wrapper/dists
|
|
3
|
-
distributionUrl=https\://services.gradle.org/distributions/gradle-
|
|
3
|
+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-all.zip
|
|
4
4
|
zipStoreBase=GRADLE_USER_HOME
|
|
5
5
|
zipStorePath=wrapper/dists
|
|
@@ -23,7 +23,6 @@ import com.withpersona.sdk2.inquiry.InquiryBuilder;
|
|
|
23
23
|
import com.withpersona.sdk2.inquiry.InquiryField;
|
|
24
24
|
import com.withpersona.sdk2.inquiry.InquiryResponse;
|
|
25
25
|
import com.withpersona.sdk2.inquiry.InquiryTemplateBuilder;
|
|
26
|
-
import com.withpersona.sdk2.inquiry.RoutingCountry;
|
|
27
26
|
import com.withpersona.sdk2.inquiry.ServerThemeSource;
|
|
28
27
|
import com.withpersona.sdk2.inquiry.types.collected_data.CollectedData;
|
|
29
28
|
import com.withpersona.sdk2.inquiry.types.collected_data.DocumentFile;
|
|
@@ -44,10 +43,12 @@ public class PersonaInquiryModule2 extends ReactContextBaseJavaModule
|
|
|
44
43
|
private static final int PERSONA_INQUIRY_REQUEST_CODE = 31416;
|
|
45
44
|
private static final String INQUIRY_ID = "inquiryId";
|
|
46
45
|
private static final String TEMPLATE_ID = "templateId";
|
|
46
|
+
private static final String TEMPLATE_VERSION = "templateVersion";
|
|
47
47
|
private static final String ACCOUNT_ID = "accountId";
|
|
48
48
|
private static final String REFERENCE_ID = "referenceId";
|
|
49
49
|
private static final String ACCESS_TOKEN = "sessionToken";
|
|
50
50
|
private static final String ENVIRONMENT = "environment";
|
|
51
|
+
private static final String ENVIRONMENT_ID = "environmentId";
|
|
51
52
|
private static final String FIELDS = "fields";
|
|
52
53
|
private static final String FIELD_ADDITIONAL_FIELDS = "additionalFields";
|
|
53
54
|
private static final String RETURN_COLLECTED_DATA = "returnCollectedData";
|
|
@@ -287,6 +288,7 @@ public class PersonaInquiryModule2 extends ReactContextBaseJavaModule
|
|
|
287
288
|
|
|
288
289
|
String inquiryId = options.hasKey(INQUIRY_ID) ? options.getString(INQUIRY_ID) : null;
|
|
289
290
|
String templateId = options.hasKey(TEMPLATE_ID) ? options.getString(TEMPLATE_ID) : null;
|
|
291
|
+
String templateVersion = options.hasKey(TEMPLATE_VERSION) ? options.getString(TEMPLATE_VERSION) : null;
|
|
290
292
|
|
|
291
293
|
if (inquiryId != null) {
|
|
292
294
|
InquiryBuilder builder = Inquiry.fromInquiry(inquiryId);
|
|
@@ -305,8 +307,13 @@ public class PersonaInquiryModule2 extends ReactContextBaseJavaModule
|
|
|
305
307
|
}
|
|
306
308
|
}
|
|
307
309
|
|
|
308
|
-
if (templateId != null) {
|
|
309
|
-
InquiryTemplateBuilder builder
|
|
310
|
+
if (templateId != null || templateVersion != null) {
|
|
311
|
+
InquiryTemplateBuilder builder;
|
|
312
|
+
if (templateId != null) {
|
|
313
|
+
builder = Inquiry.fromTemplate(templateId);
|
|
314
|
+
} else {
|
|
315
|
+
builder = Inquiry.fromTemplateVersion(templateVersion);
|
|
316
|
+
}
|
|
310
317
|
|
|
311
318
|
String themeSource = options.hasKey(THEME_SOURCE) ? options.getString(THEME_SOURCE) : null;
|
|
312
319
|
builder = builder.theme(themeSource != null && themeSource.equals("server") ?
|
|
@@ -329,9 +336,12 @@ public class PersonaInquiryModule2 extends ReactContextBaseJavaModule
|
|
|
329
336
|
builder = builder.environment(environment);
|
|
330
337
|
}
|
|
331
338
|
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
339
|
+
String environmentId = options.hasKey(ENVIRONMENT_ID) ? options.getString(ENVIRONMENT_ID) : null;
|
|
340
|
+
if (environmentId != null) {
|
|
341
|
+
builder = builder.environmentId(environmentId);
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
String routingCountry = options.hasKey(ROUTING_COUNTRY) ? options.getString(ROUTING_COUNTRY) : null;
|
|
335
345
|
if (routingCountry != null) {
|
|
336
346
|
builder = builder.routingCountry(routingCountry);
|
|
337
347
|
}
|
|
@@ -395,19 +405,4 @@ public class PersonaInquiryModule2 extends ReactContextBaseJavaModule
|
|
|
395
405
|
return null;
|
|
396
406
|
}
|
|
397
407
|
}
|
|
398
|
-
|
|
399
|
-
private RoutingCountry routingCountryFromString(@Nullable String routingCountry) {
|
|
400
|
-
if (routingCountry == null) {
|
|
401
|
-
return null;
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
switch (routingCountry) {
|
|
405
|
-
case "de":
|
|
406
|
-
return RoutingCountry.DE;
|
|
407
|
-
case "us":
|
|
408
|
-
return RoutingCountry.US;
|
|
409
|
-
default:
|
|
410
|
-
return null;
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
408
|
}
|
|
@@ -44,6 +44,7 @@ class PersonaInquiry2: RCTEventEmitter {
|
|
|
44
44
|
let referenceId = options["referenceId"] as? String
|
|
45
45
|
let accountId = options["accountId"] as? String
|
|
46
46
|
let environment = options["environment"] as? String
|
|
47
|
+
let environmentId = options["environmentId"] as? String
|
|
47
48
|
let sessionToken = options["sessionToken"] as? String
|
|
48
49
|
let themeObject = options["iosTheme"] as? [String: String]
|
|
49
50
|
let themeSource = options["themeSource"] as? String
|
|
@@ -63,30 +64,29 @@ class PersonaInquiry2: RCTEventEmitter {
|
|
|
63
64
|
.theme(makeTheme(from: themeObject, themeSource: themeSource))
|
|
64
65
|
.nfcAdapter(nfcAdapter)
|
|
65
66
|
.collectionDelegate(returnCollectedData ? self : nil)
|
|
66
|
-
|
|
67
|
-
.routingCountry(routingCountry == "de" ? .de : .us)
|
|
67
|
+
.routingCountry(routingCountry)
|
|
68
68
|
.build()
|
|
69
69
|
} else if let templateId {
|
|
70
70
|
inquiry = Inquiry.from(templateId: templateId, delegate: self)
|
|
71
71
|
.referenceId(referenceId)
|
|
72
72
|
.environment(Environment.from(rawValue: environment))
|
|
73
|
+
.environmentId(environmentId)
|
|
73
74
|
.fields(fieldsFrom(fieldsObject))
|
|
74
75
|
.theme(makeTheme(from: themeObject, themeSource: themeSource))
|
|
75
76
|
.nfcAdapter(nfcAdapter)
|
|
76
77
|
.collectionDelegate(returnCollectedData ? self : nil)
|
|
77
|
-
|
|
78
|
-
.routingCountry(routingCountry == "de" ? .de : .us)
|
|
78
|
+
.routingCountry(routingCountry)
|
|
79
79
|
.build()
|
|
80
80
|
} else if let templateVersion {
|
|
81
81
|
inquiry = Inquiry.from(templateVersion: templateVersion, delegate: self)
|
|
82
82
|
.referenceId(referenceId)
|
|
83
83
|
.environment(Environment.from(rawValue: environment))
|
|
84
|
+
.environmentId(environmentId)
|
|
84
85
|
.fields(fieldsFrom(fieldsObject))
|
|
85
86
|
.theme(makeTheme(from: themeObject, themeSource: themeSource))
|
|
86
87
|
.nfcAdapter(nfcAdapter)
|
|
87
88
|
.collectionDelegate(returnCollectedData ? self : nil)
|
|
88
|
-
|
|
89
|
-
.routingCountry(routingCountry == "de" ? .de : .us)
|
|
89
|
+
.routingCountry(routingCountry)
|
|
90
90
|
.build()
|
|
91
91
|
}
|
|
92
92
|
|
package/lib/commonjs/index.js
CHANGED
|
@@ -58,7 +58,10 @@ class InvalidAccountId extends Error {}
|
|
|
58
58
|
exports.InvalidAccountId = InvalidAccountId;
|
|
59
59
|
|
|
60
60
|
function makeInquiryId(candidate) {
|
|
61
|
-
if (candidate.startsWith('inq_'))
|
|
61
|
+
if (candidate && candidate.startsWith('inq_')) {
|
|
62
|
+
return candidate;
|
|
63
|
+
}
|
|
64
|
+
|
|
62
65
|
throw new InvalidInquiryId(`Valid template IDs start with "inq_". Received: ${candidate} `);
|
|
63
66
|
}
|
|
64
67
|
/**
|
|
@@ -70,7 +73,7 @@ function makeInquiryId(candidate) {
|
|
|
70
73
|
|
|
71
74
|
|
|
72
75
|
function makeTemplateId(candidate) {
|
|
73
|
-
if (candidate.startsWith('itmpl_')) {
|
|
76
|
+
if (candidate && candidate.startsWith('itmpl_')) {
|
|
74
77
|
return candidate;
|
|
75
78
|
}
|
|
76
79
|
|
|
@@ -85,7 +88,7 @@ function makeTemplateId(candidate) {
|
|
|
85
88
|
|
|
86
89
|
|
|
87
90
|
function makeTemplateVersion(candidate) {
|
|
88
|
-
if (candidate.startsWith('itmplv_')) {
|
|
91
|
+
if (candidate && candidate.startsWith('itmplv_')) {
|
|
89
92
|
return candidate;
|
|
90
93
|
}
|
|
91
94
|
|
|
@@ -100,7 +103,7 @@ function makeTemplateVersion(candidate) {
|
|
|
100
103
|
|
|
101
104
|
|
|
102
105
|
function makeAccountId(candidate) {
|
|
103
|
-
if (candidate.startsWith('act_')) {
|
|
106
|
+
if (candidate && candidate.startsWith('act_')) {
|
|
104
107
|
return candidate;
|
|
105
108
|
}
|
|
106
109
|
|
|
@@ -234,6 +237,8 @@ class Inquiry {
|
|
|
234
237
|
constructor(options) {
|
|
235
238
|
_defineProperty(this, "templateId", void 0);
|
|
236
239
|
|
|
240
|
+
_defineProperty(this, "templateVersion", void 0);
|
|
241
|
+
|
|
237
242
|
_defineProperty(this, "inquiryId", void 0);
|
|
238
243
|
|
|
239
244
|
_defineProperty(this, "referenceId", void 0);
|
|
@@ -242,6 +247,8 @@ class Inquiry {
|
|
|
242
247
|
|
|
243
248
|
_defineProperty(this, "environment", void 0);
|
|
244
249
|
|
|
250
|
+
_defineProperty(this, "environmentId", void 0);
|
|
251
|
+
|
|
245
252
|
_defineProperty(this, "sessionToken", void 0);
|
|
246
253
|
|
|
247
254
|
_defineProperty(this, "returnCollectedData", void 0);
|
|
@@ -267,10 +274,12 @@ class Inquiry {
|
|
|
267
274
|
_defineProperty(this, "onErrorListener", void 0);
|
|
268
275
|
|
|
269
276
|
this.templateId = options.templateId;
|
|
277
|
+
this.templateVersion = options.templateVersion;
|
|
270
278
|
this.inquiryId = options.inquiryId;
|
|
271
279
|
this.referenceId = options.referenceId;
|
|
272
280
|
this.accountId = options.accountId;
|
|
273
281
|
this.environment = options.environment;
|
|
282
|
+
this.environmentId = options.environmentId;
|
|
274
283
|
this.sessionToken = options.sessionToken;
|
|
275
284
|
this.fields = options.fields;
|
|
276
285
|
this.returnCollectedData = options.returnCollectedData;
|
|
@@ -423,10 +432,12 @@ class Inquiry {
|
|
|
423
432
|
});
|
|
424
433
|
PersonaInquiry2.startInquiry({
|
|
425
434
|
templateId: this.templateId,
|
|
435
|
+
templateVersion: this.templateVersion,
|
|
426
436
|
inquiryId: this.inquiryId,
|
|
427
437
|
referenceId: this.referenceId,
|
|
428
438
|
accountId: this.accountId,
|
|
429
439
|
environment: this.environment,
|
|
440
|
+
environmentId: this.environmentId,
|
|
430
441
|
sessionToken: this.sessionToken,
|
|
431
442
|
fields: this.fields,
|
|
432
443
|
returnCollectedData: this.returnCollectedData,
|
|
@@ -535,6 +546,8 @@ class TemplateBuilder {
|
|
|
535
546
|
|
|
536
547
|
_defineProperty(this, "_environment", void 0);
|
|
537
548
|
|
|
549
|
+
_defineProperty(this, "_environmentId", void 0);
|
|
550
|
+
|
|
538
551
|
_defineProperty(this, "_fields", void 0);
|
|
539
552
|
|
|
540
553
|
_defineProperty(this, "_sessionToken", void 0);
|
|
@@ -586,6 +599,11 @@ class TemplateBuilder {
|
|
|
586
599
|
return this;
|
|
587
600
|
}
|
|
588
601
|
|
|
602
|
+
environmentId(environmentId) {
|
|
603
|
+
this._environmentId = environmentId;
|
|
604
|
+
return this;
|
|
605
|
+
}
|
|
606
|
+
|
|
589
607
|
sessionToken(sessionToken) {
|
|
590
608
|
this._sessionToken = sessionToken;
|
|
591
609
|
return this;
|
|
@@ -639,6 +657,7 @@ class TemplateBuilder {
|
|
|
639
657
|
accountId: this._accountId,
|
|
640
658
|
referenceId: this._referenceId,
|
|
641
659
|
environment: this._environment,
|
|
660
|
+
environmentId: this._environmentId,
|
|
642
661
|
sessionToken: this._sessionToken,
|
|
643
662
|
fields: this._fields,
|
|
644
663
|
onComplete: this._onComplete,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.ts"],"names":["PersonaInquiry2","NativeModules","InvalidTemplateId","Error","InvalidTemplateVersion","InvalidInquiryId","InvalidAccountId","makeInquiryId","candidate","startsWith","makeTemplateId","makeTemplateVersion","makeAccountId","Environment","ThemeSource","RoutingCountry","DocumentStepData","constructor","stepName","documents","GovernmentIdStepData","captures","GovernmentIdCaptureMethod","GovernmentIdCaptureSide","SelfieStepData","centerCapture","leftCapture","rightCapture","SelfieCaptureMethod","UiStepData","componentParams","eventEmitter","NativeEventEmitter","Inquiry","options","templateId","inquiryId","referenceId","accountId","environment","sessionToken","fields","returnCollectedData","routingCountry","onComplete","onCanceled","onError","iosThemeObject","themeSource","clearListeners","onCompleteListener","remove","onCanceledListener","onErrorListener","fromTemplate","TemplateBuilder","fromTemplateVersion","templateVersion","fromInquiry","InquiryBuilder","start","addListener","event","key","Object","keys","field","undefined","InquiryField","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","_routingCountry","build","_fields","_templateId","_templateVersion","_returnCollectedData","_accountId","_referenceId","_environment","InquiryBuilders"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;AAKA;;AACA;;AAIA;;;;AAIA,MAAM;AAAEA,EAAAA;AAAF,IAAsBC,0BAA5B,C,CAEA;AACA;;AASO,MAAMC,iBAAN,SAAgCC,KAAhC,CAAsC;;;;AAEtC,MAAMC,sBAAN,SAAqCD,KAArC,CAA2C;;;;AAE3C,MAAME,gBAAN,SAA+BF,KAA/B,CAAqC;;;;AAErC,MAAMG,gBAAN,SAA+BH,KAA/B,CAAqC;AAE5C;AACA;AACA;AACA;AACA;AACA;;;;;AACA,SAASI,aAAT,CAAuBC,SAAvB,EAAqD;AACnD,MAAIA,SAAS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S,WAAS1C,WAAT,CAAqBtB,SAArB,EAAwC;AAC7C,WAAOH,OAAO,CAACyB,WAAR,CAAoBtB,SAApB,CAAP;AACD;;;;AAKM,WAASkB,YAAT,CAAsBnB,UAAtB,EAA0C;AAC/C,WAAOF,OAAO,CAACqB,YAAR,CAAqBnB,UAArB,CAAP;AACD;;;;AAKM,WAASqB,mBAAT,CAA6BC,eAA7B,EAAsD;AAC3D,WAAOxB,OAAO,CAACuB,mBAAR,CAA4BC,eAA5B,CAAP;AACD;;;GApBOoD,e,KAAAA,e;;eAuBKA,e","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\n/**\n * Defines the country api requests route to\n */\nexport enum RoutingCountry {\n /**\n * Route api requests to germany servers\n */\n DE = 'de',\n /**\n * Route api requests to us servers\n */\n US = 'us',\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 routingCountry?: RoutingCountry;\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 routingCountry?: RoutingCountry;\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 this.routingCountry = options.routingCountry;\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(\n Object.assign(new DocumentStepData(), stepDatum)\n );\n break;\n case 'GovernmentIdStepData':\n translatedStepData.push(\n Object.assign(new GovernmentIdStepData(), stepDatum)\n );\n break;\n case 'SelfieStepData':\n translatedStepData.push(\n Object.assign(new SelfieStepData(), stepDatum)\n );\n break;\n case 'UiStepData':\n translatedStepData.push(\n Object.assign(new UiStepData(), stepDatum)\n );\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 routingCountry: this.routingCountry,\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 private _routingCountry?: RoutingCountry;\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 routingCountry(routingCountry: RoutingCountry): InquiryBuilder {\n this._routingCountry = routingCountry;\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 routingCountry: this._routingCountry,\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 private _routingCountry?: RoutingCountry;\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 routingCountry(routingCountry: RoutingCountry): TemplateBuilder {\n this._routingCountry = routingCountry;\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(\n themeObject: Object,\n themeSource: ThemeSource\n ): 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 routingCountry: this._routingCountry,\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":["PersonaInquiry2","NativeModules","InvalidTemplateId","Error","InvalidTemplateVersion","InvalidInquiryId","InvalidAccountId","makeInquiryId","candidate","startsWith","makeTemplateId","makeTemplateVersion","makeAccountId","Environment","ThemeSource","RoutingCountry","DocumentStepData","constructor","stepName","documents","GovernmentIdStepData","captures","GovernmentIdCaptureMethod","GovernmentIdCaptureSide","SelfieStepData","centerCapture","leftCapture","rightCapture","SelfieCaptureMethod","UiStepData","componentParams","eventEmitter","NativeEventEmitter","Inquiry","options","templateId","templateVersion","inquiryId","referenceId","accountId","environment","environmentId","sessionToken","fields","returnCollectedData","routingCountry","onComplete","onCanceled","onError","iosThemeObject","themeSource","clearListeners","onCompleteListener","remove","onCanceledListener","onErrorListener","fromTemplate","TemplateBuilder","fromTemplateVersion","fromInquiry","InquiryBuilder","start","addListener","event","key","Object","keys","field","undefined","InquiryField","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","_routingCountry","build","_fields","_templateId","_templateVersion","_returnCollectedData","_accountId","_referenceId","_environment","_environmentId","InquiryBuilders"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;AAKA;;AACA;;AAIA;;;;AAIA,MAAM;AAAEA,EAAAA;AAAF,IAAsBC,0BAA5B,C,CAEA;AACA;;AASO,MAAMC,iBAAN,SAAgCC,KAAhC,CAAsC;;;;AAEtC,MAAMC,sBAAN,SAAqCD,KAArC,CAA2C;;;;AAE3C,MAAME,gBAAN,SAA+BF,KAA/B,CAAqC;;;;AAErC,MAAMG,gBAAN,SAA+BH,KAA/B,CAAqC;AAE5C;AACA;AACA;AACA;AACA;AACA;;;;;AACA,SAASI,aAAT,CAAuBC,SAAvB,EAAqD;AACnD,MAAIA,SAAS,IAAIA,SAAS,CAACC,UAAV,CAAqB,MAArB,CAAjB,EAA+C;AAC7C,WAAOD,SAAP;AACD;;AAED,QAAM,IAAIH,gBAA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AAE,KAAK+C,WAVA;AAWjB9C,MAAAA,OAAO,EAAE,KAAK+C,QAXG;AAYjB9C,MAAAA,cAAc,EAAE,KAAKgD,eAZJ;AAajB/C,MAAAA,WAAW,EAAE,KAAKgD,YAbD;AAcjBtD,MAAAA,mBAAmB,EAAE,KAAK8D,oBAdT;AAejB7D,MAAAA,cAAc,EAAE,KAAKwD;AAfJ,KAAZ,CAAP;AAiBD;;AA/ImB;AAkJtB;AACA;AACA;;;;;;AAKS,WAAS1C,WAAT,CAAqBtB,SAArB,EAAwC;AAC7C,WAAOJ,OAAO,CAAC0B,WAAR,CAAoBtB,SAApB,CAAP;AACD;;;;AAKM,WAASmB,YAAT,CAAsBrB,UAAtB,EAA0C;AAC/C,WAAOF,OAAO,CAACuB,YAAR,CAAqBrB,UAArB,CAAP;AACD;;;;AAKM,WAASuB,mBAAT,CAA6BtB,eAA7B,EAAsD;AAC3D,WAAOH,OAAO,CAACyB,mBAAR,CAA4BtB,eAA5B,CAAP;AACD;;;GApBO2E,e,KAAAA,e;;eAuBKA,e","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 && candidate.startsWith('inq_')) {\n return candidate as InquiryId;\n }\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 && 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 && 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 && 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\n/**\n * Defines the country api requests route to\n */\nexport enum RoutingCountry {\n /**\n * Route api requests to germany servers\n */\n DE = 'de',\n /**\n * Route api requests to us servers\n */\n US = 'us',\n}\n\nexport interface InquiryOptions {\n templateId?: TemplateId;\n templateVersion?: TemplateVersion;\n inquiryId?: InquiryId;\n referenceId?: string;\n accountId?: AccountId;\n environment?: Environment;\n environmentId?: string;\n sessionToken?: string;\n returnCollectedData?: boolean;\n routingCountry?: 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 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 templateVersion?: TemplateVersion;\n inquiryId?: InquiryId;\n referenceId?: string;\n accountId?: AccountId;\n environment?: Environment;\n environmentId?: string;\n sessionToken?: string;\n returnCollectedData?: boolean;\n routingCountry?: string;\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.templateVersion = options.templateVersion;\n this.inquiryId = options.inquiryId;\n this.referenceId = options.referenceId;\n this.accountId = options.accountId;\n this.environment = options.environment;\n this.environmentId = options.environmentId;\n this.sessionToken = options.sessionToken;\n this.fields = options.fields;\n this.returnCollectedData = options.returnCollectedData;\n this.routingCountry = options.routingCountry;\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(\n Object.assign(new DocumentStepData(), stepDatum)\n );\n break;\n case 'GovernmentIdStepData':\n translatedStepData.push(\n Object.assign(new GovernmentIdStepData(), stepDatum)\n );\n break;\n case 'SelfieStepData':\n translatedStepData.push(\n Object.assign(new SelfieStepData(), stepDatum)\n );\n break;\n case 'UiStepData':\n translatedStepData.push(\n Object.assign(new UiStepData(), stepDatum)\n );\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 templateVersion: this.templateVersion,\n inquiryId: this.inquiryId,\n referenceId: this.referenceId,\n accountId: this.accountId,\n environment: this.environment,\n environmentId: this.environmentId,\n sessionToken: this.sessionToken,\n fields: this.fields,\n returnCollectedData: this.returnCollectedData,\n themeSource: this.themeSource,\n iosTheme: processThemeValues(this.iosThemeObject || {}),\n routingCountry: this.routingCountry,\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 private _routingCountry?: string;\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 routingCountry(routingCountry: string): InquiryBuilder {\n this._routingCountry = routingCountry;\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 routingCountry: this._routingCountry,\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 _environmentId?: string;\n private _fields?: Fields;\n private _sessionToken?: string;\n private _returnCollectedData?: boolean;\n private _routingCountry?: string;\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 environmentId(environmentId: string): TemplateBuilder {\n this._environmentId = environmentId;\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 routingCountry(routingCountry: string): TemplateBuilder {\n this._routingCountry = routingCountry;\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(\n themeObject: Object,\n themeSource: ThemeSource\n ): 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 environmentId: this._environmentId,\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 routingCountry: this._routingCountry,\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"]}
|
package/lib/module/index.js
CHANGED
|
@@ -23,7 +23,10 @@ export class InvalidAccountId extends Error {}
|
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
25
|
function makeInquiryId(candidate) {
|
|
26
|
-
if (candidate.startsWith('inq_'))
|
|
26
|
+
if (candidate && candidate.startsWith('inq_')) {
|
|
27
|
+
return candidate;
|
|
28
|
+
}
|
|
29
|
+
|
|
27
30
|
throw new InvalidInquiryId(`Valid template IDs start with "inq_". Received: ${candidate} `);
|
|
28
31
|
}
|
|
29
32
|
/**
|
|
@@ -35,7 +38,7 @@ function makeInquiryId(candidate) {
|
|
|
35
38
|
|
|
36
39
|
|
|
37
40
|
function makeTemplateId(candidate) {
|
|
38
|
-
if (candidate.startsWith('itmpl_')) {
|
|
41
|
+
if (candidate && candidate.startsWith('itmpl_')) {
|
|
39
42
|
return candidate;
|
|
40
43
|
}
|
|
41
44
|
|
|
@@ -50,7 +53,7 @@ function makeTemplateId(candidate) {
|
|
|
50
53
|
|
|
51
54
|
|
|
52
55
|
function makeTemplateVersion(candidate) {
|
|
53
|
-
if (candidate.startsWith('itmplv_')) {
|
|
56
|
+
if (candidate && candidate.startsWith('itmplv_')) {
|
|
54
57
|
return candidate;
|
|
55
58
|
}
|
|
56
59
|
|
|
@@ -65,7 +68,7 @@ function makeTemplateVersion(candidate) {
|
|
|
65
68
|
|
|
66
69
|
|
|
67
70
|
function makeAccountId(candidate) {
|
|
68
|
-
if (candidate.startsWith('act_')) {
|
|
71
|
+
if (candidate && candidate.startsWith('act_')) {
|
|
69
72
|
return candidate;
|
|
70
73
|
}
|
|
71
74
|
|
|
@@ -181,6 +184,8 @@ export class Inquiry {
|
|
|
181
184
|
constructor(options) {
|
|
182
185
|
_defineProperty(this, "templateId", void 0);
|
|
183
186
|
|
|
187
|
+
_defineProperty(this, "templateVersion", void 0);
|
|
188
|
+
|
|
184
189
|
_defineProperty(this, "inquiryId", void 0);
|
|
185
190
|
|
|
186
191
|
_defineProperty(this, "referenceId", void 0);
|
|
@@ -189,6 +194,8 @@ export class Inquiry {
|
|
|
189
194
|
|
|
190
195
|
_defineProperty(this, "environment", void 0);
|
|
191
196
|
|
|
197
|
+
_defineProperty(this, "environmentId", void 0);
|
|
198
|
+
|
|
192
199
|
_defineProperty(this, "sessionToken", void 0);
|
|
193
200
|
|
|
194
201
|
_defineProperty(this, "returnCollectedData", void 0);
|
|
@@ -214,10 +221,12 @@ export class Inquiry {
|
|
|
214
221
|
_defineProperty(this, "onErrorListener", void 0);
|
|
215
222
|
|
|
216
223
|
this.templateId = options.templateId;
|
|
224
|
+
this.templateVersion = options.templateVersion;
|
|
217
225
|
this.inquiryId = options.inquiryId;
|
|
218
226
|
this.referenceId = options.referenceId;
|
|
219
227
|
this.accountId = options.accountId;
|
|
220
228
|
this.environment = options.environment;
|
|
229
|
+
this.environmentId = options.environmentId;
|
|
221
230
|
this.sessionToken = options.sessionToken;
|
|
222
231
|
this.fields = options.fields;
|
|
223
232
|
this.returnCollectedData = options.returnCollectedData;
|
|
@@ -370,10 +379,12 @@ export class Inquiry {
|
|
|
370
379
|
});
|
|
371
380
|
PersonaInquiry2.startInquiry({
|
|
372
381
|
templateId: this.templateId,
|
|
382
|
+
templateVersion: this.templateVersion,
|
|
373
383
|
inquiryId: this.inquiryId,
|
|
374
384
|
referenceId: this.referenceId,
|
|
375
385
|
accountId: this.accountId,
|
|
376
386
|
environment: this.environment,
|
|
387
|
+
environmentId: this.environmentId,
|
|
377
388
|
sessionToken: this.sessionToken,
|
|
378
389
|
fields: this.fields,
|
|
379
390
|
returnCollectedData: this.returnCollectedData,
|
|
@@ -480,6 +491,8 @@ class TemplateBuilder {
|
|
|
480
491
|
|
|
481
492
|
_defineProperty(this, "_environment", void 0);
|
|
482
493
|
|
|
494
|
+
_defineProperty(this, "_environmentId", void 0);
|
|
495
|
+
|
|
483
496
|
_defineProperty(this, "_fields", void 0);
|
|
484
497
|
|
|
485
498
|
_defineProperty(this, "_sessionToken", void 0);
|
|
@@ -531,6 +544,11 @@ class TemplateBuilder {
|
|
|
531
544
|
return this;
|
|
532
545
|
}
|
|
533
546
|
|
|
547
|
+
environmentId(environmentId) {
|
|
548
|
+
this._environmentId = environmentId;
|
|
549
|
+
return this;
|
|
550
|
+
}
|
|
551
|
+
|
|
534
552
|
sessionToken(sessionToken) {
|
|
535
553
|
this._sessionToken = sessionToken;
|
|
536
554
|
return this;
|
|
@@ -584,6 +602,7 @@ class TemplateBuilder {
|
|
|
584
602
|
accountId: this._accountId,
|
|
585
603
|
referenceId: this._referenceId,
|
|
586
604
|
environment: this._environment,
|
|
605
|
+
environmentId: this._environmentId,
|
|
587
606
|
sessionToken: this._sessionToken,
|
|
588
607
|
fields: this._fields,
|
|
589
608
|
onComplete: this._onComplete,
|
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","ThemeSource","RoutingCountry","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","routingCountry","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","_routingCountry","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,IAAIH,gBAAJ,CACH,mDAAkDG,SAAU,GADzD,CAAN;AAGD;AAED;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASE,cAAT,CAAwBF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B,CAAP;AACD;;;;AAKM,WAASkB,YAAT,CAAsBnB,UAAtB,EAA0C;AAC/C,WAAOF,OAAO,CAACqB,YAAR,CAAqBnB,UAArB,CAAP;AACD;;;;AAKM,WAASqB,mBAAT,CAA6BC,eAA7B,EAAsD;AAC3D,WAAOxB,OAAO,CAACuB,mBAAR,CAA4BC,eAA5B,CAAP;AACD;;;GApBOmD,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\n/**\n * Defines the country api requests route to\n */\nexport enum RoutingCountry {\n /**\n * Route api requests to germany servers\n */\n DE = 'de',\n /**\n * Route api requests to us servers\n */\n US = 'us',\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 routingCountry?: RoutingCountry;\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 routingCountry?: RoutingCountry;\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 this.routingCountry = options.routingCountry;\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(\n Object.assign(new DocumentStepData(), stepDatum)\n );\n break;\n case 'GovernmentIdStepData':\n translatedStepData.push(\n Object.assign(new GovernmentIdStepData(), stepDatum)\n );\n break;\n case 'SelfieStepData':\n translatedStepData.push(\n Object.assign(new SelfieStepData(), stepDatum)\n );\n break;\n case 'UiStepData':\n translatedStepData.push(\n Object.assign(new UiStepData(), stepDatum)\n );\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 routingCountry: this.routingCountry,\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 private _routingCountry?: RoutingCountry;\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 routingCountry(routingCountry: RoutingCountry): InquiryBuilder {\n this._routingCountry = routingCountry;\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 routingCountry: this._routingCountry,\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 private _routingCountry?: RoutingCountry;\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 routingCountry(routingCountry: RoutingCountry): TemplateBuilder {\n this._routingCountry = routingCountry;\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(\n themeObject: Object,\n themeSource: ThemeSource\n ): 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 routingCountry: this._routingCountry,\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","RoutingCountry","DocumentStepData","constructor","stepName","documents","GovernmentIdStepData","captures","GovernmentIdCaptureMethod","GovernmentIdCaptureSide","SelfieStepData","centerCapture","leftCapture","rightCapture","SelfieCaptureMethod","UiStepData","componentParams","eventEmitter","Inquiry","options","templateId","templateVersion","inquiryId","referenceId","accountId","environment","environmentId","sessionToken","fields","returnCollectedData","routingCountry","onComplete","onCanceled","onError","iosThemeObject","themeSource","clearListeners","onCompleteListener","remove","onCanceledListener","onErrorListener","fromTemplate","TemplateBuilder","fromTemplateVersion","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","_routingCountry","build","_fields","_templateId","_templateVersion","_returnCollectedData","_accountId","_referenceId","_environment","_environmentId","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,IAAIA,SAA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;AAMjBnE,MAAAA,aAAa,EAAE,KAAKoE,cANH;AAOjBnE,MAAAA,YAAY,EAAE,KAAKgD,aAPF;AAQjB/C,MAAAA,MAAM,EAAE,KAAK2D,OARI;AASjBxD,MAAAA,UAAU,EAAE,KAAK8C,WATA;AAUjB7C,MAAAA,UAAU,EAAE,KAAK8C,WAVA;AAWjB7C,MAAAA,OAAO,EAAE,KAAK8C,QAXG;AAYjB7C,MAAAA,cAAc,EAAE,KAAK+C,eAZJ;AAajB9C,MAAAA,WAAW,EAAE,KAAK+C,YAbD;AAcjBrD,MAAAA,mBAAmB,EAAE,KAAK6D,oBAdT;AAejB5D,MAAAA,cAAc,EAAE,KAAKuD;AAfJ,KAAZ,CAAP;AAiBD;;AA/ImB;AAkJtB;AACA;AACA;;;;;;AAKS,WAASzC,WAAT,CAAqBtB,SAArB,EAAwC;AAC7C,WAAOJ,OAAO,CAAC0B,WAAR,CAAoBtB,SAApB,CAAP;AACD;;;;AAKM,WAASmB,YAAT,CAAsBrB,UAAtB,EAA0C;AAC/C,WAAOF,OAAO,CAACuB,YAAR,CAAqBrB,UAArB,CAAP;AACD;;;;AAKM,WAASuB,mBAAT,CAA6BtB,eAA7B,EAAsD;AAC3D,WAAOH,OAAO,CAACyB,mBAAR,CAA4BtB,eAA5B,CAAP;AACD;;;GApBO0E,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 && candidate.startsWith('inq_')) {\n return candidate as InquiryId;\n }\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 && 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 && 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 && 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\n/**\n * Defines the country api requests route to\n */\nexport enum RoutingCountry {\n /**\n * Route api requests to germany servers\n */\n DE = 'de',\n /**\n * Route api requests to us servers\n */\n US = 'us',\n}\n\nexport interface InquiryOptions {\n templateId?: TemplateId;\n templateVersion?: TemplateVersion;\n inquiryId?: InquiryId;\n referenceId?: string;\n accountId?: AccountId;\n environment?: Environment;\n environmentId?: string;\n sessionToken?: string;\n returnCollectedData?: boolean;\n routingCountry?: 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 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 templateVersion?: TemplateVersion;\n inquiryId?: InquiryId;\n referenceId?: string;\n accountId?: AccountId;\n environment?: Environment;\n environmentId?: string;\n sessionToken?: string;\n returnCollectedData?: boolean;\n routingCountry?: string;\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.templateVersion = options.templateVersion;\n this.inquiryId = options.inquiryId;\n this.referenceId = options.referenceId;\n this.accountId = options.accountId;\n this.environment = options.environment;\n this.environmentId = options.environmentId;\n this.sessionToken = options.sessionToken;\n this.fields = options.fields;\n this.returnCollectedData = options.returnCollectedData;\n this.routingCountry = options.routingCountry;\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(\n Object.assign(new DocumentStepData(), stepDatum)\n );\n break;\n case 'GovernmentIdStepData':\n translatedStepData.push(\n Object.assign(new GovernmentIdStepData(), stepDatum)\n );\n break;\n case 'SelfieStepData':\n translatedStepData.push(\n Object.assign(new SelfieStepData(), stepDatum)\n );\n break;\n case 'UiStepData':\n translatedStepData.push(\n Object.assign(new UiStepData(), stepDatum)\n );\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 templateVersion: this.templateVersion,\n inquiryId: this.inquiryId,\n referenceId: this.referenceId,\n accountId: this.accountId,\n environment: this.environment,\n environmentId: this.environmentId,\n sessionToken: this.sessionToken,\n fields: this.fields,\n returnCollectedData: this.returnCollectedData,\n themeSource: this.themeSource,\n iosTheme: processThemeValues(this.iosThemeObject || {}),\n routingCountry: this.routingCountry,\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 private _routingCountry?: string;\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 routingCountry(routingCountry: string): InquiryBuilder {\n this._routingCountry = routingCountry;\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 routingCountry: this._routingCountry,\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 _environmentId?: string;\n private _fields?: Fields;\n private _sessionToken?: string;\n private _returnCollectedData?: boolean;\n private _routingCountry?: string;\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 environmentId(environmentId: string): TemplateBuilder {\n this._environmentId = environmentId;\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 routingCountry(routingCountry: string): TemplateBuilder {\n this._routingCountry = routingCountry;\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(\n themeObject: Object,\n themeSource: ThemeSource\n ): 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 environmentId: this._environmentId,\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 routingCountry: this._routingCountry,\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"]}
|
|
@@ -57,9 +57,10 @@ export interface InquiryOptions {
|
|
|
57
57
|
referenceId?: string;
|
|
58
58
|
accountId?: AccountId;
|
|
59
59
|
environment?: Environment;
|
|
60
|
+
environmentId?: string;
|
|
60
61
|
sessionToken?: string;
|
|
61
62
|
returnCollectedData?: boolean;
|
|
62
|
-
routingCountry?:
|
|
63
|
+
routingCountry?: string;
|
|
63
64
|
fields?: Fields;
|
|
64
65
|
onComplete?: OnCompleteCallback;
|
|
65
66
|
onCanceled?: OnCanceledCallback;
|
|
@@ -134,13 +135,15 @@ declare type OnCanceledCallback = (inquiryId?: string, sessionToken?: string) =>
|
|
|
134
135
|
declare type OnErrorCallback = (error: Error) => void;
|
|
135
136
|
export declare class Inquiry {
|
|
136
137
|
templateId?: TemplateId;
|
|
138
|
+
templateVersion?: TemplateVersion;
|
|
137
139
|
inquiryId?: InquiryId;
|
|
138
140
|
referenceId?: string;
|
|
139
141
|
accountId?: AccountId;
|
|
140
142
|
environment?: Environment;
|
|
143
|
+
environmentId?: string;
|
|
141
144
|
sessionToken?: string;
|
|
142
145
|
returnCollectedData?: boolean;
|
|
143
|
-
routingCountry?:
|
|
146
|
+
routingCountry?: string;
|
|
144
147
|
iosThemeObject?: Object | null;
|
|
145
148
|
themeSource?: ThemeSource | null;
|
|
146
149
|
fields?: Fields | null;
|
|
@@ -210,7 +213,7 @@ declare class InquiryBuilder {
|
|
|
210
213
|
*/
|
|
211
214
|
iosTheme(themeObject: Object): InquiryBuilder;
|
|
212
215
|
iosThemeToUse(themeObject: Object, themeSource: ThemeSource): InquiryBuilder;
|
|
213
|
-
routingCountry(routingCountry:
|
|
216
|
+
routingCountry(routingCountry: string): InquiryBuilder;
|
|
214
217
|
build(): Inquiry;
|
|
215
218
|
}
|
|
216
219
|
declare class TemplateBuilder {
|
|
@@ -219,6 +222,7 @@ declare class TemplateBuilder {
|
|
|
219
222
|
private _accountId?;
|
|
220
223
|
private _referenceId?;
|
|
221
224
|
private _environment?;
|
|
225
|
+
private _environmentId?;
|
|
222
226
|
private _fields?;
|
|
223
227
|
private _sessionToken?;
|
|
224
228
|
private _returnCollectedData?;
|
|
@@ -233,9 +237,10 @@ declare class TemplateBuilder {
|
|
|
233
237
|
referenceId(referenceId: string): TemplateBuilder;
|
|
234
238
|
accountId(accountId: string): TemplateBuilder;
|
|
235
239
|
environment(environment: Environment): TemplateBuilder;
|
|
240
|
+
environmentId(environmentId: string): TemplateBuilder;
|
|
236
241
|
sessionToken(sessionToken: string): TemplateBuilder;
|
|
237
242
|
fields(fields: Fields): TemplateBuilder;
|
|
238
|
-
routingCountry(routingCountry:
|
|
243
|
+
routingCountry(routingCountry: string): TemplateBuilder;
|
|
239
244
|
onComplete(callback: OnCompleteCallback): TemplateBuilder;
|
|
240
245
|
onCanceled(callback: OnCanceledCallback): TemplateBuilder;
|
|
241
246
|
onError(callback: OnErrorCallback): 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.
|
|
4
|
+
"version": "2.7.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
|
@@ -39,7 +39,9 @@ export class InvalidAccountId extends Error {}
|
|
|
39
39
|
* @param candidate
|
|
40
40
|
*/
|
|
41
41
|
function makeInquiryId(candidate: string): InquiryId {
|
|
42
|
-
if (candidate.startsWith('inq_'))
|
|
42
|
+
if (candidate && candidate.startsWith('inq_')) {
|
|
43
|
+
return candidate as InquiryId;
|
|
44
|
+
}
|
|
43
45
|
|
|
44
46
|
throw new InvalidInquiryId(
|
|
45
47
|
`Valid template IDs start with "inq_". Received: ${candidate} `
|
|
@@ -53,7 +55,7 @@ function makeInquiryId(candidate: string): InquiryId {
|
|
|
53
55
|
* @param candidate
|
|
54
56
|
*/
|
|
55
57
|
function makeTemplateId(candidate: string): TemplateId {
|
|
56
|
-
if (candidate.startsWith('itmpl_')) {
|
|
58
|
+
if (candidate && candidate.startsWith('itmpl_')) {
|
|
57
59
|
return candidate as TemplateId;
|
|
58
60
|
}
|
|
59
61
|
|
|
@@ -69,7 +71,7 @@ function makeTemplateId(candidate: string): TemplateId {
|
|
|
69
71
|
* @param candidate
|
|
70
72
|
*/
|
|
71
73
|
function makeTemplateVersion(candidate: string): TemplateVersion {
|
|
72
|
-
if (candidate.startsWith('itmplv_')) {
|
|
74
|
+
if (candidate && candidate.startsWith('itmplv_')) {
|
|
73
75
|
return candidate as TemplateVersion;
|
|
74
76
|
}
|
|
75
77
|
|
|
@@ -85,7 +87,7 @@ function makeTemplateVersion(candidate: string): TemplateVersion {
|
|
|
85
87
|
* @param candidate
|
|
86
88
|
*/
|
|
87
89
|
function makeAccountId(candidate: string): AccountId {
|
|
88
|
-
if (candidate.startsWith('act_')) {
|
|
90
|
+
if (candidate && candidate.startsWith('act_')) {
|
|
89
91
|
return candidate as AccountId;
|
|
90
92
|
}
|
|
91
93
|
|
|
@@ -136,9 +138,10 @@ export interface InquiryOptions {
|
|
|
136
138
|
referenceId?: string;
|
|
137
139
|
accountId?: AccountId;
|
|
138
140
|
environment?: Environment;
|
|
141
|
+
environmentId?: string;
|
|
139
142
|
sessionToken?: string;
|
|
140
143
|
returnCollectedData?: boolean;
|
|
141
|
-
routingCountry?:
|
|
144
|
+
routingCountry?: string;
|
|
142
145
|
|
|
143
146
|
// Fields
|
|
144
147
|
fields?: Fields;
|
|
@@ -267,13 +270,15 @@ const eventEmitter = new NativeEventEmitter(PersonaInquiry2);
|
|
|
267
270
|
|
|
268
271
|
export class Inquiry {
|
|
269
272
|
templateId?: TemplateId;
|
|
273
|
+
templateVersion?: TemplateVersion;
|
|
270
274
|
inquiryId?: InquiryId;
|
|
271
275
|
referenceId?: string;
|
|
272
276
|
accountId?: AccountId;
|
|
273
277
|
environment?: Environment;
|
|
278
|
+
environmentId?: string;
|
|
274
279
|
sessionToken?: string;
|
|
275
280
|
returnCollectedData?: boolean;
|
|
276
|
-
routingCountry?:
|
|
281
|
+
routingCountry?: string;
|
|
277
282
|
|
|
278
283
|
iosThemeObject?: Object | null;
|
|
279
284
|
themeSource?: ThemeSource | null;
|
|
@@ -289,10 +294,12 @@ export class Inquiry {
|
|
|
289
294
|
|
|
290
295
|
constructor(options: InquiryOptions) {
|
|
291
296
|
this.templateId = options.templateId;
|
|
297
|
+
this.templateVersion = options.templateVersion;
|
|
292
298
|
this.inquiryId = options.inquiryId;
|
|
293
299
|
this.referenceId = options.referenceId;
|
|
294
300
|
this.accountId = options.accountId;
|
|
295
301
|
this.environment = options.environment;
|
|
302
|
+
this.environmentId = options.environmentId;
|
|
296
303
|
this.sessionToken = options.sessionToken;
|
|
297
304
|
this.fields = options.fields;
|
|
298
305
|
this.returnCollectedData = options.returnCollectedData;
|
|
@@ -460,10 +467,12 @@ export class Inquiry {
|
|
|
460
467
|
|
|
461
468
|
PersonaInquiry2.startInquiry({
|
|
462
469
|
templateId: this.templateId,
|
|
470
|
+
templateVersion: this.templateVersion,
|
|
463
471
|
inquiryId: this.inquiryId,
|
|
464
472
|
referenceId: this.referenceId,
|
|
465
473
|
accountId: this.accountId,
|
|
466
474
|
environment: this.environment,
|
|
475
|
+
environmentId: this.environmentId,
|
|
467
476
|
sessionToken: this.sessionToken,
|
|
468
477
|
fields: this.fields,
|
|
469
478
|
returnCollectedData: this.returnCollectedData,
|
|
@@ -485,7 +494,7 @@ class InquiryBuilder {
|
|
|
485
494
|
private _iosThemeObject?: Object;
|
|
486
495
|
private _themeSource: ThemeSource = ThemeSource.SERVER;
|
|
487
496
|
private _fields?: Fields;
|
|
488
|
-
private _routingCountry?:
|
|
497
|
+
private _routingCountry?: string;
|
|
489
498
|
|
|
490
499
|
constructor(inquiryId: InquiryId) {
|
|
491
500
|
this._inquiryId = inquiryId;
|
|
@@ -532,7 +541,7 @@ class InquiryBuilder {
|
|
|
532
541
|
return this;
|
|
533
542
|
}
|
|
534
543
|
|
|
535
|
-
routingCountry(routingCountry:
|
|
544
|
+
routingCountry(routingCountry: string): InquiryBuilder {
|
|
536
545
|
this._routingCountry = routingCountry;
|
|
537
546
|
|
|
538
547
|
return this;
|
|
@@ -559,10 +568,11 @@ class TemplateBuilder {
|
|
|
559
568
|
private _accountId?: AccountId;
|
|
560
569
|
private _referenceId?: string;
|
|
561
570
|
private _environment?: Environment;
|
|
571
|
+
private _environmentId?: string;
|
|
562
572
|
private _fields?: Fields;
|
|
563
573
|
private _sessionToken?: string;
|
|
564
574
|
private _returnCollectedData?: boolean;
|
|
565
|
-
private _routingCountry?:
|
|
575
|
+
private _routingCountry?: string;
|
|
566
576
|
|
|
567
577
|
// Callbacks
|
|
568
578
|
private _onComplete?: OnCompleteCallback;
|
|
@@ -615,6 +625,12 @@ class TemplateBuilder {
|
|
|
615
625
|
return this;
|
|
616
626
|
}
|
|
617
627
|
|
|
628
|
+
environmentId(environmentId: string): TemplateBuilder {
|
|
629
|
+
this._environmentId = environmentId;
|
|
630
|
+
|
|
631
|
+
return this;
|
|
632
|
+
}
|
|
633
|
+
|
|
618
634
|
sessionToken(sessionToken: string): TemplateBuilder {
|
|
619
635
|
this._sessionToken = sessionToken;
|
|
620
636
|
|
|
@@ -627,7 +643,7 @@ class TemplateBuilder {
|
|
|
627
643
|
return this;
|
|
628
644
|
}
|
|
629
645
|
|
|
630
|
-
routingCountry(routingCountry:
|
|
646
|
+
routingCountry(routingCountry: string): TemplateBuilder {
|
|
631
647
|
this._routingCountry = routingCountry;
|
|
632
648
|
|
|
633
649
|
return this;
|
|
@@ -678,6 +694,7 @@ class TemplateBuilder {
|
|
|
678
694
|
accountId: this._accountId,
|
|
679
695
|
referenceId: this._referenceId,
|
|
680
696
|
environment: this._environment,
|
|
697
|
+
environmentId: this._environmentId,
|
|
681
698
|
sessionToken: this._sessionToken,
|
|
682
699
|
fields: this._fields,
|
|
683
700
|
onComplete: this._onComplete,
|