react-native-persona 2.1.1 → 2.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +38 -0
- package/{RNPersonaInquiry.podspec → RNPersonaInquiry2.podspec} +2 -2
- package/android/README.md +14 -0
- package/android/build.gradle +22 -99
- package/android/gradle/wrapper/gradle-wrapper.properties +1 -1
- package/android/src/main/AndroidManifest.xml +1 -1
- package/android/src/main/java/com/withpersona/{sdk/reactnative/PersonaInquiryModule.java → sdk2/reactnative/PersonaInquiryModule2.java} +24 -14
- package/android/src/main/java/com/withpersona/{sdk/reactnative/PersonaInquiryPackage.java → sdk2/reactnative/PersonaInquiryPackage2.java} +3 -3
- package/android/src/main/java/com/withpersona/{sdk → sdk2}/reactnative/exceptions/InvalidConfiguration.java +1 -1
- package/android/src/main/res/values/theme.xml +2 -3
- package/ios/{PersonaInquiry.swift → PersonaInquiry2.swift} +17 -13
- package/ios/PersonaInquiryBridge.m +1 -1
- package/lib/commonjs/fields.js +141 -0
- package/lib/commonjs/fields.js.map +1 -0
- package/lib/commonjs/index.js +475 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/util.js +36 -0
- package/lib/commonjs/util.js.map +1 -0
- package/lib/commonjs/versions.js +25 -0
- package/lib/commonjs/versions.js.map +1 -0
- package/lib/module/fields.js +132 -0
- package/lib/module/fields.js.map +1 -0
- package/lib/module/index.js +435 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/util.js +29 -0
- package/lib/module/util.js.map +1 -0
- package/lib/module/versions.js +14 -0
- package/lib/module/versions.js.map +1 -0
- package/{generatedTypes/persona-tools/config.d.ts → lib/typescript/persona-tools/Config.d.ts} +0 -0
- package/{generatedTypes → lib/typescript}/persona-tools/Theme.d.ts +0 -0
- package/{generatedTypes → lib/typescript}/persona-tools/index.d.ts +0 -0
- package/{generatedTypes → lib/typescript}/persona-tools/lib/AndroidResourcePrinter.d.ts +2 -2
- package/{generatedTypes → lib/typescript}/persona-tools/lib/prompts.d.ts +0 -0
- package/{generatedTypes → lib/typescript}/persona-tools/tools/AndroidThemeGenerator.d.ts +0 -0
- package/{generatedTypes → lib/typescript}/persona-tools/tools/IosThemeInstructions.d.ts +0 -0
- package/{generatedTypes → lib/typescript}/src/fields.d.ts +0 -0
- package/{generatedTypes → lib/typescript}/src/index.d.ts +56 -5
- package/{generatedTypes → lib/typescript}/src/util.d.ts +0 -0
- package/lib/typescript/src/versions.d.ts +6 -0
- package/package.json +73 -17
- package/persona-tools/{config.ts → Config.ts} +7 -7
- package/persona-tools/Theme.ts +107 -107
- package/persona-tools/index.ts +9 -9
- package/persona-tools/lib/AndroidResourcePrinter.ts +4 -4
- package/persona-tools/tools/AndroidThemeGenerator.ts +18 -18
- package/persona-tools/tools/IosThemeInstructions.ts +8 -8
- package/src/fields.ts +7 -7
- package/src/index.ts +89 -26
- package/src/util.ts +2 -2
- package/src/versions.ts +12 -0
- package/generatedTypes/persona-tools/lib/AndroidResourcePrinter.spec.d.ts +0 -1
- package/generatedTypes/src/fields.spec.d.ts +0 -1
- package/generatedTypes/src/util.spec.d.ts +0 -1
- package/jest.config.js +0 -10
- package/persona-tools/Theme.js +0 -186
- package/persona-tools/config.js +0 -72
- package/persona-tools/index.js +0 -30
- package/persona-tools/lib/AndroidResourcePrinter.js +0 -573
- package/persona-tools/lib/AndroidResourcePrinter.spec.js +0 -914
- package/persona-tools/lib/AndroidResourcePrinter.spec.ts +0 -952
- package/persona-tools/lib/prompts.js +0 -39
- package/persona-tools/tools/AndroidThemeGenerator.js +0 -55
- package/persona-tools/tools/IosThemeInstructions.js +0 -34
- package/src/fields.js +0 -88
- package/src/fields.spec.js +0 -18
- package/src/fields.spec.ts +0 -17
- package/src/index.js +0 -271
- package/src/util.js +0 -29
- package/src/util.spec.js +0 -17
- package/src/util.spec.ts +0 -22
- package/tsconfig.json +0 -29
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,44 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
|
7
7
|
|
|
8
8
|
## Unreleased
|
|
9
9
|
|
|
10
|
+
## [v2.2.1] - 2022-02-17
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- Upgrade to Android Inquiry SDK 2.2.6
|
|
15
|
+
- Upgrade to iOS Inquiry SDK 2.2.3
|
|
16
|
+
|
|
17
|
+
### Added
|
|
18
|
+
|
|
19
|
+
- Expose underlying Android/iOS SDK version with `#nativeSdkVersion`
|
|
20
|
+
- Add `#fromInquiry`, `#fromTemplate`, and `#fromTemplateVersion` static methods to `Inquiry`
|
|
21
|
+
|
|
22
|
+
### Deprecated
|
|
23
|
+
|
|
24
|
+
- Deprecate the default namespace and it's methods: `#fromInquiry`, `#fromTemplate`, and `#fromTemplateVersion`
|
|
25
|
+
|
|
26
|
+
## [v2.2.0] - 2022-02-16
|
|
27
|
+
|
|
28
|
+
### Changed
|
|
29
|
+
|
|
30
|
+
- Upgrade to iOS Inquiry SDK 2.2.2
|
|
31
|
+
- Upgrade to Android Inquiry SDK 2.2.4
|
|
32
|
+
- Update iOS and Android's namespace to allow for 1.x and 2.x implementations in parallel
|
|
33
|
+
|
|
34
|
+
## [v2.1.3] - 2022-01-31
|
|
35
|
+
|
|
36
|
+
### Changed
|
|
37
|
+
|
|
38
|
+
- Upgrade to iOS Inquiry SDK 2.1.3
|
|
39
|
+
- Upgrade to Android Inquiry SDK 2.1.3
|
|
40
|
+
|
|
41
|
+
## [v2.1.2] - 2021-12-17
|
|
42
|
+
|
|
43
|
+
### Changed
|
|
44
|
+
|
|
45
|
+
- Upgrade to iOS Inquiry SDK 2.1.2
|
|
46
|
+
- Upgrade to Android Inquiry SDK 2.1.1
|
|
47
|
+
|
|
10
48
|
## [v2.1.1] - 2021-12-02
|
|
11
49
|
|
|
12
50
|
### Changed
|
|
@@ -3,7 +3,7 @@ require 'json'
|
|
|
3
3
|
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
|
|
4
4
|
|
|
5
5
|
Pod::Spec.new do |s|
|
|
6
|
-
s.name = '
|
|
6
|
+
s.name = 'RNPersonaInquiry2'
|
|
7
7
|
s.version = package['version']
|
|
8
8
|
s.summary = package['description']
|
|
9
9
|
s.description = <<-DESC
|
|
@@ -22,7 +22,7 @@ Pod::Spec.new do |s|
|
|
|
22
22
|
s.requires_arc = true
|
|
23
23
|
|
|
24
24
|
s.dependency 'React-Core'
|
|
25
|
-
s.dependency '
|
|
25
|
+
s.dependency 'PersonaInquirySDK2', '2.2.3'
|
|
26
26
|
|
|
27
27
|
s.static_framework = true
|
|
28
28
|
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
README
|
|
2
|
+
======
|
|
3
|
+
|
|
4
|
+
If you want to publish the lib as a maven dependency, follow these steps before publishing a new version to npm:
|
|
5
|
+
|
|
6
|
+
1. Be sure to have the Android [SDK](https://developer.android.com/studio/index.html) and [NDK](https://developer.android.com/ndk/guides/index.html) installed
|
|
7
|
+
2. Be sure to have a `local.properties` file in this folder that points to the Android SDK and NDK
|
|
8
|
+
```
|
|
9
|
+
ndk.dir=/Users/{username}/Library/Android/sdk/ndk-bundle
|
|
10
|
+
sdk.dir=/Users/{username}/Library/Android/sdk
|
|
11
|
+
```
|
|
12
|
+
3. Delete the `maven` folder
|
|
13
|
+
4. Run `./gradlew installArchives`
|
|
14
|
+
5. Verify that latest set of generated files is in the maven folder with the correct version number
|
package/android/build.gradle
CHANGED
|
@@ -1,34 +1,15 @@
|
|
|
1
|
-
// android/build.gradle
|
|
2
|
-
|
|
3
|
-
// based on:
|
|
4
|
-
//
|
|
5
|
-
// * https://github.com/facebook/react-native/blob/0.60-stable/template/android/build.gradle
|
|
6
|
-
// original location:
|
|
7
|
-
// - https://github.com/facebook/react-native/blob/0.58-stable/local-cli/templates/HelloWorld/android/build.gradle
|
|
8
|
-
//
|
|
9
|
-
// * https://github.com/facebook/react-native/blob/0.60-stable/template/android/app/build.gradle
|
|
10
|
-
// original location:
|
|
11
|
-
// - https://github.com/facebook/react-native/blob/0.58-stable/local-cli/templates/HelloWorld/android/app/build.gradle
|
|
12
|
-
|
|
13
1
|
def DEFAULT_COMPILE_SDK_VERSION = 29
|
|
14
|
-
def DEFAULT_BUILD_TOOLS_VERSION = '29.0.3'
|
|
15
2
|
def DEFAULT_MIN_SDK_VERSION = 21
|
|
16
3
|
def DEFAULT_TARGET_SDK_VERSION = 29
|
|
17
4
|
|
|
18
|
-
def safeExtGet(prop, fallback) {
|
|
19
|
-
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
|
|
20
|
-
}
|
|
21
|
-
|
|
22
5
|
buildscript {
|
|
23
|
-
// The Android Gradle plugin is only required when opening the android folder stand-alone.
|
|
24
|
-
// This avoids unnecessary downloads and potential conflicts when the library is included as a
|
|
25
|
-
// module dependency in an application project.
|
|
26
|
-
// ref: https://docs.gradle.org/current/userguide/tutorial_using_tasks.html#sec:build_script_external_dependencies
|
|
27
6
|
if (project == rootProject) {
|
|
28
7
|
repositories {
|
|
29
8
|
google()
|
|
9
|
+
mavenCentral()
|
|
30
10
|
jcenter()
|
|
31
11
|
}
|
|
12
|
+
|
|
32
13
|
dependencies {
|
|
33
14
|
classpath 'com.android.tools.build:gradle:3.6.1'
|
|
34
15
|
}
|
|
@@ -36,112 +17,54 @@ buildscript {
|
|
|
36
17
|
}
|
|
37
18
|
|
|
38
19
|
apply plugin: 'com.android.library'
|
|
39
|
-
|
|
20
|
+
|
|
21
|
+
def safeExtGet(prop, fallback) {
|
|
22
|
+
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
|
|
23
|
+
}
|
|
40
24
|
|
|
41
25
|
android {
|
|
42
26
|
compileSdkVersion safeExtGet('compileSdkVersion', DEFAULT_COMPILE_SDK_VERSION)
|
|
43
|
-
buildToolsVersion safeExtGet('buildToolsVersion', DEFAULT_BUILD_TOOLS_VERSION)
|
|
44
27
|
defaultConfig {
|
|
45
28
|
minSdkVersion safeExtGet('minSdkVersion', DEFAULT_MIN_SDK_VERSION)
|
|
46
29
|
targetSdkVersion safeExtGet('targetSdkVersion', DEFAULT_TARGET_SDK_VERSION)
|
|
47
30
|
versionCode 1
|
|
48
31
|
versionName "1.0"
|
|
49
32
|
}
|
|
33
|
+
|
|
34
|
+
buildTypes {
|
|
35
|
+
release {
|
|
36
|
+
minifyEnabled false
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
lintOptions {
|
|
40
|
+
disable 'GradleCompatible'
|
|
41
|
+
}
|
|
50
42
|
compileOptions {
|
|
51
43
|
sourceCompatibility JavaVersion.VERSION_1_8
|
|
52
44
|
targetCompatibility JavaVersion.VERSION_1_8
|
|
53
45
|
}
|
|
54
|
-
lintOptions {
|
|
55
|
-
abortOnError false
|
|
56
|
-
}
|
|
57
46
|
}
|
|
58
47
|
|
|
59
48
|
repositories {
|
|
60
|
-
// ref: https://www.baeldung.com/maven-local-repository
|
|
61
49
|
mavenLocal()
|
|
62
50
|
maven {
|
|
63
51
|
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
|
|
64
|
-
url
|
|
65
|
-
}
|
|
66
|
-
maven {
|
|
67
|
-
// Android JSC is installed from npm
|
|
68
|
-
url "$rootDir/../node_modules/jsc-android/dist"
|
|
52
|
+
url("$rootDir/../node_modules/react-native/android")
|
|
69
53
|
}
|
|
54
|
+
google()
|
|
55
|
+
mavenCentral()
|
|
56
|
+
jcenter()
|
|
70
57
|
maven {
|
|
71
58
|
url "https://sdk.withpersona.com/android/releases"
|
|
72
59
|
}
|
|
73
60
|
google()
|
|
74
|
-
|
|
61
|
+
mavenCentral()
|
|
62
|
+
maven { url 'https://jitpack.io' }
|
|
75
63
|
}
|
|
76
64
|
|
|
77
65
|
dependencies {
|
|
78
66
|
//noinspection GradleDynamicVersion
|
|
79
67
|
implementation 'com.facebook.react:react-native:+' // From node_modules
|
|
80
68
|
|
|
81
|
-
|
|
82
|
-
implementation 'com.withpersona.sdk:inquiry:2.1.0'
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
def configureReactNativePom(def pom) {
|
|
86
|
-
def packageJson = new groovy.json.JsonSlurper().parseText(file('../package.json').text)
|
|
87
|
-
|
|
88
|
-
pom.project {
|
|
89
|
-
name packageJson.title
|
|
90
|
-
artifactId packageJson.name
|
|
91
|
-
version = packageJson.version
|
|
92
|
-
group = "com.withpersona.sdk.reactnative"
|
|
93
|
-
description packageJson.description
|
|
94
|
-
|
|
95
|
-
developers {
|
|
96
|
-
developer {
|
|
97
|
-
id packageJson.author.username
|
|
98
|
-
name packageJson.author.name
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
afterEvaluate { project ->
|
|
105
|
-
// some Gradle build hooks ref:
|
|
106
|
-
// https://www.oreilly.com/library/view/gradle-beyond-the/9781449373801/ch03.html
|
|
107
|
-
task androidJavadoc(type: Javadoc) {
|
|
108
|
-
source = android.sourceSets.main.java.srcDirs
|
|
109
|
-
classpath += files(android.bootClasspath)
|
|
110
|
-
classpath += files(project.getConfigurations().getByName('compile').asList())
|
|
111
|
-
include '**/*.java'
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
task androidJavadocJar(type: Jar, dependsOn: androidJavadoc) {
|
|
115
|
-
classifier = 'javadoc'
|
|
116
|
-
from androidJavadoc.destinationDir
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
task androidSourcesJar(type: Jar) {
|
|
120
|
-
classifier = 'sources'
|
|
121
|
-
from android.sourceSets.main.java.srcDirs
|
|
122
|
-
include '**/*.java'
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
android.libraryVariants.all { variant ->
|
|
126
|
-
def name = variant.name.capitalize()
|
|
127
|
-
def javaCompileTask = variant.javaCompileProvider.get()
|
|
128
|
-
|
|
129
|
-
task "jar${name}"(type: Jar, dependsOn: javaCompileTask) {
|
|
130
|
-
from javaCompileTask.destinationDir
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
artifacts {
|
|
135
|
-
archives androidSourcesJar
|
|
136
|
-
archives androidJavadocJar
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
task installArchives(type: Upload) {
|
|
140
|
-
configuration = configurations.archives
|
|
141
|
-
repositories.mavenDeployer {
|
|
142
|
-
// Deploy to react-native-event-bridge/maven, ready to publish to npm
|
|
143
|
-
repository url: "file://${projectDir}/../android/maven"
|
|
144
|
-
configureReactNativePom pom
|
|
145
|
-
}
|
|
146
|
-
}
|
|
69
|
+
implementation 'com.withpersona.sdk2:inquiry:2.2.6'
|
|
147
70
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
distributionBase=GRADLE_USER_HOME
|
|
2
2
|
distributionPath=wrapper/dists
|
|
3
|
-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.
|
|
3
|
+
distributionUrl=https\://services.gradle.org/distributions/gradle-6.9.2-all.zip
|
|
4
4
|
zipStoreBase=GRADLE_USER_HOME
|
|
5
5
|
zipStorePath=wrapper/dists
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<manifest package="com.withpersona.
|
|
1
|
+
<manifest package="com.withpersona.sdk2.reactnative" />
|
|
@@ -1,33 +1,32 @@
|
|
|
1
|
-
package com.withpersona.
|
|
1
|
+
package com.withpersona.sdk2.reactnative;
|
|
2
2
|
|
|
3
3
|
import android.app.Activity;
|
|
4
4
|
import android.content.Intent;
|
|
5
5
|
import androidx.annotation.Nullable;
|
|
6
|
+
import com.facebook.react.ReactActivityDelegate;
|
|
6
7
|
import com.facebook.react.bridge.ActivityEventListener;
|
|
7
8
|
import com.facebook.react.bridge.Arguments;
|
|
8
|
-
import com.facebook.react.bridge.JavaOnlyMap;
|
|
9
9
|
import com.facebook.react.bridge.ReactApplicationContext;
|
|
10
10
|
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
11
11
|
import com.facebook.react.bridge.ReactMethod;
|
|
12
12
|
import com.facebook.react.bridge.ReadableMap;
|
|
13
13
|
import com.facebook.react.bridge.WritableMap;
|
|
14
14
|
import com.facebook.react.modules.core.DeviceEventManagerModule;
|
|
15
|
-
import com.withpersona.
|
|
16
|
-
import com.withpersona.
|
|
17
|
-
import com.withpersona.
|
|
18
|
-
import com.withpersona.
|
|
19
|
-
import com.withpersona.
|
|
20
|
-
import com.withpersona.
|
|
21
|
-
import com.withpersona.
|
|
22
|
-
import java.util.ArrayList;
|
|
15
|
+
import com.withpersona.sdk2.inquiry.Environment;
|
|
16
|
+
import com.withpersona.sdk2.inquiry.Fields;
|
|
17
|
+
import com.withpersona.sdk2.inquiry.Inquiry;
|
|
18
|
+
import com.withpersona.sdk2.inquiry.InquiryBuilder;
|
|
19
|
+
import com.withpersona.sdk2.inquiry.InquiryField;
|
|
20
|
+
import com.withpersona.sdk2.inquiry.InquiryResponse;
|
|
21
|
+
import com.withpersona.sdk2.inquiry.InquiryTemplateBuilder;
|
|
23
22
|
import java.util.HashMap;
|
|
24
23
|
import java.util.Map;
|
|
25
24
|
import org.jetbrains.annotations.NotNull;
|
|
26
25
|
|
|
27
|
-
public class
|
|
26
|
+
public class PersonaInquiryModule2 extends ReactContextBaseJavaModule
|
|
28
27
|
implements ActivityEventListener {
|
|
29
28
|
|
|
30
|
-
private static final int PERSONA_INQUIRY_REQUEST_CODE =
|
|
29
|
+
private static final int PERSONA_INQUIRY_REQUEST_CODE = 31416;
|
|
31
30
|
private static final String INQUIRY_ID = "inquiryId";
|
|
32
31
|
private static final String TEMPLATE_ID = "templateId";
|
|
33
32
|
private static final String ACCOUNT_ID = "accountId";
|
|
@@ -39,7 +38,7 @@ public class PersonaInquiryModule extends ReactContextBaseJavaModule
|
|
|
39
38
|
|
|
40
39
|
private final ReactApplicationContext reactContext;
|
|
41
40
|
|
|
42
|
-
public
|
|
41
|
+
public PersonaInquiryModule2(ReactApplicationContext reactContext) {
|
|
43
42
|
super(reactContext);
|
|
44
43
|
this.reactContext = reactContext;
|
|
45
44
|
reactContext.addActivityEventListener(this);
|
|
@@ -120,7 +119,7 @@ public class PersonaInquiryModule extends ReactContextBaseJavaModule
|
|
|
120
119
|
@NotNull
|
|
121
120
|
@Override
|
|
122
121
|
public String getName() {
|
|
123
|
-
return "
|
|
122
|
+
return "PersonaInquiry2";
|
|
124
123
|
}
|
|
125
124
|
|
|
126
125
|
/**
|
|
@@ -140,6 +139,8 @@ public class PersonaInquiryModule extends ReactContextBaseJavaModule
|
|
|
140
139
|
if (inquiryId != null) {
|
|
141
140
|
InquiryBuilder builder = Inquiry.fromInquiry(inquiryId);
|
|
142
141
|
|
|
142
|
+
builder = builder.theme(R.style.Persona_Inquiry2_Theme);
|
|
143
|
+
|
|
143
144
|
String sessionToken = options.hasKey(ACCESS_TOKEN) ? options.getString(ACCESS_TOKEN) : null;
|
|
144
145
|
if (sessionToken != null) {
|
|
145
146
|
builder = builder.sessionToken(sessionToken);
|
|
@@ -153,6 +154,8 @@ public class PersonaInquiryModule extends ReactContextBaseJavaModule
|
|
|
153
154
|
if (templateId != null) {
|
|
154
155
|
InquiryTemplateBuilder builder = Inquiry.fromTemplate(templateId);
|
|
155
156
|
|
|
157
|
+
builder = builder.theme(R.style.Persona_Inquiry2_Theme);
|
|
158
|
+
|
|
156
159
|
String referenceId = options.hasKey(REFERENCE_ID) ? options.getString(REFERENCE_ID) : null;
|
|
157
160
|
if (referenceId != null) {
|
|
158
161
|
builder = builder.referenceId(referenceId);
|
|
@@ -201,6 +204,13 @@ public class PersonaInquiryModule extends ReactContextBaseJavaModule
|
|
|
201
204
|
}
|
|
202
205
|
}
|
|
203
206
|
|
|
207
|
+
@Override
|
|
208
|
+
public Map<String, Object> getConstants() {
|
|
209
|
+
final Map<String, Object> constants = new HashMap<>();
|
|
210
|
+
constants.put("INQUIRY_SDK_VERSION", com.withpersona.sdk2.inquiry.BuildConfig.INQUIRY_SDK_VERSION);
|
|
211
|
+
return constants;
|
|
212
|
+
}
|
|
213
|
+
|
|
204
214
|
private Environment environmentFromString(@Nullable String environment) {
|
|
205
215
|
if (environment == null) {
|
|
206
216
|
return null;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
package com.withpersona.
|
|
1
|
+
package com.withpersona.sdk2.reactnative;
|
|
2
2
|
|
|
3
3
|
import java.util.Arrays;
|
|
4
4
|
import java.util.Collections;
|
|
@@ -9,10 +9,10 @@ import com.facebook.react.bridge.NativeModule;
|
|
|
9
9
|
import com.facebook.react.bridge.ReactApplicationContext;
|
|
10
10
|
import com.facebook.react.uimanager.ViewManager;
|
|
11
11
|
|
|
12
|
-
public class
|
|
12
|
+
public class PersonaInquiryPackage2 implements ReactPackage {
|
|
13
13
|
@Override
|
|
14
14
|
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
|
|
15
|
-
return Arrays.<NativeModule>asList(new
|
|
15
|
+
return Arrays.<NativeModule>asList(new PersonaInquiryModule2(reactContext));
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
@Override
|
|
@@ -1,28 +1,32 @@
|
|
|
1
1
|
//
|
|
2
|
-
//
|
|
3
|
-
//
|
|
2
|
+
// PersonaInquiry2.swift
|
|
3
|
+
// PersonaInquiry2
|
|
4
4
|
//
|
|
5
5
|
// Copyright © 2020 Persona. All rights reserved.
|
|
6
6
|
//
|
|
7
7
|
|
|
8
8
|
import Foundation
|
|
9
|
-
import
|
|
9
|
+
import Persona2
|
|
10
10
|
|
|
11
|
-
@objc(
|
|
12
|
-
class
|
|
11
|
+
@objc(PersonaInquiry2)
|
|
12
|
+
class PersonaInquiry2: RCTEventEmitter {
|
|
13
13
|
|
|
14
14
|
override func supportedEvents() -> [String] {
|
|
15
15
|
["onComplete", "onCanceled", "onError"]
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
override static func moduleName() -> String {
|
|
19
|
-
"
|
|
19
|
+
"PersonaInquiry2"
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
override static func requiresMainQueueSetup() -> Bool {
|
|
23
23
|
true
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
override func constantsToExport() -> [AnyHashable : Any]! {
|
|
27
|
+
["INQUIRY_SDK_VERSION": Inquiry.versionNumber]
|
|
28
|
+
}
|
|
29
|
+
|
|
26
30
|
/// To keep the bridge simple, we'll expose a single method to both configure and start the inquiry. The config is
|
|
27
31
|
/// validated within the React Native side of the bridge.
|
|
28
32
|
@objc
|
|
@@ -68,7 +72,7 @@ class PersonaInquiry: RCTEventEmitter {
|
|
|
68
72
|
|
|
69
73
|
// MARK: - Inquiry Delegate Methods
|
|
70
74
|
|
|
71
|
-
extension
|
|
75
|
+
extension PersonaInquiry2: InquiryDelegate {
|
|
72
76
|
func inquiryComplete(inquiryId: String, status: String, fields: [String: InquiryField]) {
|
|
73
77
|
sendEvent(
|
|
74
78
|
withName: "onComplete",
|
|
@@ -103,7 +107,7 @@ extension PersonaInquiry: InquiryDelegate {
|
|
|
103
107
|
|
|
104
108
|
// MARK: - Helpers
|
|
105
109
|
|
|
106
|
-
extension
|
|
110
|
+
extension PersonaInquiry2 {
|
|
107
111
|
|
|
108
112
|
enum InvalidConfiguration: Error {
|
|
109
113
|
case argumentError(String)
|
|
@@ -382,7 +386,7 @@ extension PersonaInquiry {
|
|
|
382
386
|
if let successAssetName = dictionary["successAssetName"],
|
|
383
387
|
let successAssetWidth = int(from: dictionary["successAssetWidth"]),
|
|
384
388
|
let successAssetHeight = int(from: dictionary["successAssetHeight"]),
|
|
385
|
-
let successAssetPath = Bundle(for:
|
|
389
|
+
let successAssetPath = Bundle(for: PersonaInquiry2.self).path(forResource: successAssetName, ofType: "svg") {
|
|
386
390
|
let customSuccessAsset = InquiryTheme.SVGAsset(
|
|
387
391
|
path: successAssetPath,
|
|
388
392
|
size: CGSize(width: successAssetWidth, height: successAssetHeight)
|
|
@@ -394,7 +398,7 @@ extension PersonaInquiry {
|
|
|
394
398
|
if let verificationFailAssetName = dictionary["verificationFailAssetName"],
|
|
395
399
|
let verificationFailAssetWidth = int(from: dictionary["verificationFailAssetWidth"]),
|
|
396
400
|
let verificationFailAssetHeight = int(from: dictionary["verificationFailAssetHeight"]),
|
|
397
|
-
let verificationFailAssetPath = Bundle(for:
|
|
401
|
+
let verificationFailAssetPath = Bundle(for: PersonaInquiry2.self).path(forResource: verificationFailAssetName, ofType: "svg") {
|
|
398
402
|
let customVerificationFailAsset = InquiryTheme.SVGAsset(
|
|
399
403
|
path: verificationFailAssetPath,
|
|
400
404
|
size: CGSize(width: verificationFailAssetWidth, height: verificationFailAssetHeight)
|
|
@@ -406,7 +410,7 @@ extension PersonaInquiry {
|
|
|
406
410
|
if let failAssetName = dictionary["failAssetName"],
|
|
407
411
|
let failAssetWidth = int(from: dictionary["failAssetWidth"]),
|
|
408
412
|
let failAssetHeight = int(from: dictionary["failAssetHeight"]),
|
|
409
|
-
let failAssetPath = Bundle(for:
|
|
413
|
+
let failAssetPath = Bundle(for: PersonaInquiry2.self).path(forResource: failAssetName, ofType: "svg") {
|
|
410
414
|
let customFailAsset = InquiryTheme.SVGAsset(
|
|
411
415
|
path: failAssetPath,
|
|
412
416
|
size: CGSize(width: failAssetWidth, height: failAssetHeight)
|
|
@@ -418,7 +422,7 @@ extension PersonaInquiry {
|
|
|
418
422
|
if let loadingAnimationAssetName = dictionary["loadingAnimationAssetName"],
|
|
419
423
|
let loadingAnimationAssetWidth = int(from: dictionary["loadingAnimationAssetWidth"]),
|
|
420
424
|
let loadingAnimationAssetHeight = int(from: dictionary["loadingAnimationAssetHeight"]),
|
|
421
|
-
let loadingAnimationAssetPath = Bundle(for:
|
|
425
|
+
let loadingAnimationAssetPath = Bundle(for: PersonaInquiry2.self).path(forResource: loadingAnimationAssetName, ofType: "json") {
|
|
422
426
|
let customLoadingAnimationAsset = InquiryTheme.AnimationAsset(
|
|
423
427
|
path: loadingAnimationAssetPath,
|
|
424
428
|
size: CGSize(width: loadingAnimationAssetWidth, height: loadingAnimationAssetHeight)
|
|
@@ -430,7 +434,7 @@ extension PersonaInquiry {
|
|
|
430
434
|
if let processingAnimationAssetName = dictionary["processingAnimationAssetName"],
|
|
431
435
|
let processingAnimationAssetWidth = int(from: dictionary["processingAnimationAssetWidth"]),
|
|
432
436
|
let processingAnimationAssetHeight = int(from: dictionary["processingAnimationAssetHeight"]),
|
|
433
|
-
let processingAnimationAssetPath = Bundle(for:
|
|
437
|
+
let processingAnimationAssetPath = Bundle(for: PersonaInquiry2.self).path(forResource: processingAnimationAssetName, ofType: "json") {
|
|
434
438
|
let customProcessingAnimationAsset = InquiryTheme.AnimationAsset(
|
|
435
439
|
path: processingAnimationAssetPath,
|
|
436
440
|
size: CGSize(width: processingAnimationAssetWidth, height: processingAnimationAssetHeight)
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.InquiryField = exports.Fields = void 0;
|
|
7
|
+
|
|
8
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
9
|
+
|
|
10
|
+
let InquiryField;
|
|
11
|
+
exports.InquiryField = InquiryField;
|
|
12
|
+
|
|
13
|
+
(function (_InquiryField) {
|
|
14
|
+
class Integer {
|
|
15
|
+
constructor(value) {
|
|
16
|
+
_defineProperty(this, "type", 'integer');
|
|
17
|
+
|
|
18
|
+
_defineProperty(this, "value", void 0);
|
|
19
|
+
|
|
20
|
+
this.value = value;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
_InquiryField.Integer = Integer;
|
|
26
|
+
|
|
27
|
+
class String {
|
|
28
|
+
constructor(value) {
|
|
29
|
+
_defineProperty(this, "type", 'string');
|
|
30
|
+
|
|
31
|
+
_defineProperty(this, "value", void 0);
|
|
32
|
+
|
|
33
|
+
this.value = value;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
_InquiryField.String = String;
|
|
39
|
+
|
|
40
|
+
class Boolean {
|
|
41
|
+
constructor(value) {
|
|
42
|
+
_defineProperty(this, "type", 'boolean');
|
|
43
|
+
|
|
44
|
+
_defineProperty(this, "value", void 0);
|
|
45
|
+
|
|
46
|
+
this.value = value;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
_InquiryField.Boolean = Boolean;
|
|
52
|
+
|
|
53
|
+
class Unknown {
|
|
54
|
+
constructor(type) {
|
|
55
|
+
_defineProperty(this, "type", void 0);
|
|
56
|
+
|
|
57
|
+
this.type = type;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
_InquiryField.Unknown = Unknown;
|
|
63
|
+
|
|
64
|
+
function parse(_ref) {
|
|
65
|
+
let {
|
|
66
|
+
type,
|
|
67
|
+
value
|
|
68
|
+
} = _ref;
|
|
69
|
+
|
|
70
|
+
if (value == null) {
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
switch (type) {
|
|
75
|
+
case 'integer':
|
|
76
|
+
return new InquiryField.Integer(Number.parseInt(value));
|
|
77
|
+
|
|
78
|
+
case 'string':
|
|
79
|
+
return new InquiryField.String(value);
|
|
80
|
+
|
|
81
|
+
case 'boolean':
|
|
82
|
+
return new InquiryField.Boolean(JSON.parse(value));
|
|
83
|
+
|
|
84
|
+
case 'unknown':
|
|
85
|
+
return new InquiryField.Unknown(value);
|
|
86
|
+
|
|
87
|
+
default:
|
|
88
|
+
return new InquiryField.Unknown(type);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
_InquiryField.parse = parse;
|
|
93
|
+
})(InquiryField || (exports.InquiryField = InquiryField = {}));
|
|
94
|
+
|
|
95
|
+
let Fields;
|
|
96
|
+
exports.Fields = Fields;
|
|
97
|
+
|
|
98
|
+
(function (_Fields) {
|
|
99
|
+
function builder() {
|
|
100
|
+
return new Fields.Builder();
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
_Fields.builder = builder;
|
|
104
|
+
|
|
105
|
+
class Builder {
|
|
106
|
+
constructor() {
|
|
107
|
+
_defineProperty(this, "_fields", void 0);
|
|
108
|
+
|
|
109
|
+
this._fields = {};
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
integer(fieldKey, value) {
|
|
113
|
+
this._fields = { ...this._fields,
|
|
114
|
+
[fieldKey]: new InquiryField.Integer(value)
|
|
115
|
+
};
|
|
116
|
+
return this;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
boolean(fieldKey, value) {
|
|
120
|
+
this._fields = { ...this._fields,
|
|
121
|
+
[fieldKey]: new InquiryField.Boolean(value)
|
|
122
|
+
};
|
|
123
|
+
return this;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
string(fieldKey, value) {
|
|
127
|
+
this._fields = { ...this._fields,
|
|
128
|
+
[fieldKey]: new InquiryField.String(value)
|
|
129
|
+
};
|
|
130
|
+
return this;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
build() {
|
|
134
|
+
return this._fields;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
_Fields.Builder = Builder;
|
|
140
|
+
})(Fields || (exports.Fields = Fields = {}));
|
|
141
|
+
//# sourceMappingURL=fields.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["fields.ts"],"names":["Integer","constructor","value","String","Boolean","Unknown","type","parse","InquiryField","Number","parseInt","JSON","builder","Fields","Builder","_fields","integer","fieldKey","boolean","string","build"],"mappings":";;;;;;;;;;;;;AAUS,QAAMA,OAAN,CAAsC;AAI3CC,IAAAA,WAAW,CAACC,KAAD,EAAiB;AAAA,oCAHJ,SAGI;;AAAA;;AAC1B,WAAKA,KAAL,GAAaA,KAAb;AACD;;AAN0C;;;;AAStC,QAAMC,MAAN,CAAqC;AAI1CF,IAAAA,WAAW,CAACC,KAAD,EAAiB;AAAA,oCAHJ,QAGI;;AAAA;;AAC1B,WAAKA,KAAL,GAAaA,KAAb;AACD;;AANyC;;;;AASrC,QAAME,OAAN,CAAsC;AAI3CH,IAAAA,WAAW,CAACC,KAAD,EAAkB;AAAA,oCAHL,SAGK;;AAAA;;AAC3B,WAAKA,KAAL,GAAaA,KAAb;AACD;;AAN0C;;;;AAStC,QAAMG,OAAN,CAAsC;AAG3CJ,IAAAA,WAAW,CAACK,IAAD,EAAe;AAAA;;AACxB,WAAKA,IAAL,GAAYA,IAAZ;AACD;;AAL0C;;;;AAQtC,WAASC,KAAT,OAAsE;AAAA,QAAvD;AAAED,MAAAA,IAAF;AAAQJ,MAAAA;AAAR,KAAuD;;AAC3E,QAAIA,KAAK,IAAI,IAAb,EAAmB;AACjB,aAAO,IAAP;AACD;;AACD,YAAQI,IAAR;AACE,WAAK,SAAL;AACE,eAAO,IAAIE,YAAY,CAACR,OAAjB,CAAyBS,MAAM,CAACC,QAAP,CAAgBR,KAAhB,CAAzB,CAAP;;AACF,WAAK,QAAL;AACE,eAAO,IAAIM,YAAY,CAACL,MAAjB,CAAwBD,KAAxB,CAAP;;AACF,WAAK,SAAL;AACE,eAAO,IAAIM,YAAY,CAACJ,OAAjB,CAAyBO,IAAI,CAACJ,KAAL,CAAWL,KAAX,CAAzB,CAAP;;AACF,WAAK,SAAL;AACE,eAAO,IAAIM,YAAY,CAACH,OAAjB,CAAyBH,KAAzB,CAAP;;AACF;AACE,eAAO,IAAIM,YAAY,CAACH,OAAjB,CAAyBC,IAAzB,CAAP;AAVJ;AAYD;;;GApDcE,Y,4BAAAA,Y;;;;;;AA0DR,WAASI,OAAT,GAA4B;AACjC,WAAO,IAAIC,MAAM,CAACC,OAAX,EAAP;AACD;;;;AAEM,QAAMA,OAAN,CAAc;AAGnBb,IAAAA,WAAW,GAAG;AAAA;;AACZ,WAAKc,OAAL,GAAe,EAAf;AACD;;AAEMC,IAAAA,OAAO,CAACC,QAAD,EAAmBf,KAAnB,EAAmC;AAC/C,WAAKa,OAAL,GAAe,EACb,GAAG,KAAKA,OADK;AAEb,SAACE,QAAD,GAAY,IAAIT,YAAY,CAACR,OAAjB,CAAyBE,KAAzB;AAFC,OAAf;AAKA,aAAO,IAAP;AACD;;AAEMgB,IAAAA,OAAO,CAACD,QAAD,EAAmBf,KAAnB,EAAoC;AAChD,WAAKa,OAAL,GAAe,EACb,GAAG,KAAKA,OADK;AAEb,SAACE,QAAD,GAAY,IAAIT,YAAY,CAACJ,OAAjB,CAAyBF,KAAzB;AAFC,OAAf;AAKA,aAAO,IAAP;AACD;;AAEMiB,IAAAA,MAAM,CAACF,QAAD,EAAmBf,KAAnB,EAAmC;AAC9C,WAAKa,OAAL,GAAe,EACb,GAAG,KAAKA,OADK;AAEb,SAACE,QAAD,GAAY,IAAIT,YAAY,CAACL,MAAjB,CAAwBD,KAAxB;AAFC,OAAf;AAKA,aAAO,IAAP;AACD;;AAEMkB,IAAAA,KAAK,GAAW;AACrB,aAAO,KAAKL,OAAZ;AACD;;AApCkB;;;GALNF,M,sBAAAA,M","sourcesContent":["interface InquiryField {\n readonly type: string;\n}\n\nexport type RawInquiryField = {\n type: string;\n value?: any;\n};\n\nexport namespace InquiryField {\n export class Integer implements InquiryField {\n readonly type: string = 'integer';\n readonly value?: number;\n\n constructor(value?: number) {\n this.value = value;\n }\n }\n\n export class String implements InquiryField {\n readonly type: string = 'string';\n readonly value?: string;\n\n constructor(value?: string) {\n this.value = value;\n }\n }\n\n export class Boolean implements InquiryField {\n readonly type: string = 'boolean';\n readonly value?: boolean;\n\n constructor(value?: boolean) {\n this.value = value;\n }\n }\n\n export class Unknown implements InquiryField {\n readonly type: string;\n\n constructor(type: string) {\n this.type = type;\n }\n }\n\n export function parse({ type, value }: RawInquiryField): InquiryField | null {\n if (value == null) {\n return null;\n }\n switch (type) {\n case 'integer':\n return new InquiryField.Integer(Number.parseInt(value));\n case 'string':\n return new InquiryField.String(value);\n case 'boolean':\n return new InquiryField.Boolean(JSON.parse(value));\n case 'unknown':\n return new InquiryField.Unknown(value);\n default:\n return new InquiryField.Unknown(type);\n }\n }\n}\n\nexport type Fields = Record<string, InquiryField | null>;\n\nexport namespace Fields {\n export function builder(): Builder {\n return new Fields.Builder();\n }\n\n export class Builder {\n private _fields: Record<string, InquiryField>;\n\n constructor() {\n this._fields = {};\n }\n\n public integer(fieldKey: string, value?: number) {\n this._fields = {\n ...this._fields,\n [fieldKey]: new InquiryField.Integer(value),\n };\n\n return this;\n }\n\n public boolean(fieldKey: string, value?: boolean) {\n this._fields = {\n ...this._fields,\n [fieldKey]: new InquiryField.Boolean(value),\n };\n\n return this;\n }\n\n public string(fieldKey: string, value?: string) {\n this._fields = {\n ...this._fields,\n [fieldKey]: new InquiryField.String(value),\n };\n\n return this;\n }\n\n public build(): Fields {\n return this._fields;\n }\n }\n}\n"]}
|