react-native-persona 1.2.10 → 1.3.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 +25 -0
- package/RNPersonaInquiry.podspec +1 -1
- package/android/README.md +14 -0
- package/android/build.gradle +21 -100
- package/bin/persona-tool +1 -2
- package/lib/commonjs/index.js +477 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/persona-tools/AndroidResourcePrinter.js +694 -0
- package/lib/commonjs/persona-tools/AndroidResourcePrinter.js.map +1 -0
- package/lib/commonjs/persona-tools/Config.js +95 -0
- package/lib/commonjs/persona-tools/Config.js.map +1 -0
- package/lib/commonjs/persona-tools/Theme.js +228 -0
- package/lib/commonjs/persona-tools/Theme.js.map +1 -0
- package/lib/commonjs/persona-tools/index.js +41 -0
- package/lib/commonjs/persona-tools/index.js.map +1 -0
- package/lib/commonjs/persona-tools/prompts.js +48 -0
- package/lib/commonjs/persona-tools/prompts.js.map +1 -0
- package/lib/commonjs/persona-tools/tools/AndroidThemeGenerator.js +112 -0
- package/lib/commonjs/persona-tools/tools/AndroidThemeGenerator.js.map +1 -0
- package/lib/commonjs/persona-tools/tools/IosThemeInstructions.js +50 -0
- package/lib/commonjs/persona-tools/tools/IosThemeInstructions.js.map +1 -0
- package/lib/commonjs/util.js +36 -0
- package/lib/commonjs/util.js.map +1 -0
- package/lib/module/index.js +452 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/persona-tools/AndroidResourcePrinter.js +686 -0
- package/lib/module/persona-tools/AndroidResourcePrinter.js.map +1 -0
- package/lib/module/persona-tools/Config.js +82 -0
- package/lib/module/persona-tools/Config.js.map +1 -0
- package/lib/module/persona-tools/Theme.js +212 -0
- package/lib/module/persona-tools/Theme.js.map +1 -0
- package/lib/module/persona-tools/index.js +33 -0
- package/lib/module/persona-tools/index.js.map +1 -0
- package/lib/module/persona-tools/prompts.js +31 -0
- package/lib/module/persona-tools/prompts.js.map +1 -0
- package/lib/module/persona-tools/tools/AndroidThemeGenerator.js +82 -0
- package/lib/module/persona-tools/tools/AndroidThemeGenerator.js.map +1 -0
- package/lib/module/persona-tools/tools/IosThemeInstructions.js +37 -0
- package/lib/module/persona-tools/tools/IosThemeInstructions.js.map +1 -0
- package/lib/module/util.js +29 -0
- package/lib/module/util.js.map +1 -0
- package/{generatedTypes → lib/typescript}/index.d.ts +67 -3
- package/lib/typescript/persona-tools/AndroidResourcePrinter.d.ts +40 -0
- package/lib/typescript/persona-tools/Config.d.ts +15 -0
- package/lib/typescript/persona-tools/Theme.d.ts +124 -0
- package/lib/typescript/persona-tools/index.d.ts +1 -0
- package/lib/typescript/persona-tools/prompts.d.ts +8 -0
- package/lib/typescript/persona-tools/tools/AndroidThemeGenerator.d.ts +5 -0
- package/lib/typescript/persona-tools/tools/IosThemeInstructions.d.ts +5 -0
- package/lib/typescript/util.d.ts +3 -0
- package/package.json +79 -22
- package/src/index.ts +17 -18
- package/{persona-tools/lib → src/persona-tools}/AndroidResourcePrinter.ts +314 -278
- package/{persona-tools/config.ts → src/persona-tools/Config.ts} +7 -7
- package/src/persona-tools/Theme.ts +262 -0
- package/src/persona-tools/index.ts +30 -0
- package/{persona-tools/lib → src/persona-tools}/prompts.ts +11 -11
- package/{persona-tools → src/persona-tools}/tools/AndroidThemeGenerator.ts +31 -32
- package/{persona-tools → src/persona-tools}/tools/IosThemeInstructions.ts +8 -8
- package/src/util.ts +3 -3
- package/jest.config.js +0 -10
- package/persona-tools/Theme.js +0 -213
- package/persona-tools/Theme.ts +0 -260
- package/persona-tools/config.js +0 -72
- package/persona-tools/index.js +0 -30
- package/persona-tools/index.ts +0 -30
- package/persona-tools/lib/AndroidResourcePrinter.js +0 -832
- package/persona-tools/lib/AndroidResourcePrinter.spec.js +0 -1135
- package/persona-tools/lib/AndroidResourcePrinter.spec.ts +0 -1229
- package/persona-tools/lib/prompts.js +0 -39
- package/persona-tools/tools/AndroidThemeGenerator.js +0 -59
- package/persona-tools/tools/IosThemeInstructions.js +0 -34
- package/src/index.js +0 -307
- package/src/util.js +0 -29
- package/src/util.spec.js +0 -15
- package/src/util.spec.ts +0 -16
- package/tsconfig.json +0 -29
package/package.json
CHANGED
|
@@ -1,57 +1,75 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-persona",
|
|
3
3
|
"title": "React Native Persona",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.3.1",
|
|
5
5
|
"description": "Launch a mobile native implementation of the Persona inquiry flow from React Native.",
|
|
6
|
-
"main": "
|
|
6
|
+
"main": "lib/commonjs/index",
|
|
7
|
+
"module": "lib/module/index",
|
|
8
|
+
"types": "lib/typescript/src/index.d.ts",
|
|
9
|
+
"react-native": "src/index",
|
|
10
|
+
"source": "src/index",
|
|
7
11
|
"bin": {
|
|
8
|
-
"persona-tool": "
|
|
12
|
+
"persona-tool": "bin/persona-tool"
|
|
9
13
|
},
|
|
10
14
|
"scripts": {
|
|
11
|
-
"
|
|
12
|
-
"
|
|
15
|
+
"test": "jest",
|
|
16
|
+
"typescript": "tsc --noEmit",
|
|
17
|
+
"lint": "eslint \"**/*.{js,ts,tsx}\"",
|
|
18
|
+
"prepare": "bob build",
|
|
19
|
+
"example": "yarn --cwd example",
|
|
20
|
+
"pods": "cd example && pod-install --quiet",
|
|
21
|
+
"bootstrap": "yarn example && yarn && yarn pods"
|
|
13
22
|
},
|
|
14
23
|
"files": [
|
|
15
|
-
"android/build.gradle",
|
|
16
|
-
"android/gradle*",
|
|
17
|
-
"android/src",
|
|
18
|
-
"ios",
|
|
19
24
|
"src",
|
|
20
|
-
"
|
|
25
|
+
"lib",
|
|
26
|
+
"android",
|
|
27
|
+
"ios",
|
|
21
28
|
"bin",
|
|
22
|
-
"persona-tools",
|
|
23
29
|
"RNPersonaInquiry.podspec",
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
30
|
+
"!lib/typescript/example",
|
|
31
|
+
"!android/build",
|
|
32
|
+
"!ios/build",
|
|
33
|
+
"!**/__tests__",
|
|
34
|
+
"!**/__fixtures__",
|
|
35
|
+
"!**/__mocks__"
|
|
27
36
|
],
|
|
28
37
|
"keywords": [
|
|
29
|
-
"react-native"
|
|
38
|
+
"react-native",
|
|
39
|
+
"persona",
|
|
40
|
+
"idv"
|
|
30
41
|
],
|
|
31
42
|
"author": {
|
|
32
43
|
"name": "Persona Identities, Inc.",
|
|
33
44
|
"email": "support@withpersona.com"
|
|
34
45
|
},
|
|
46
|
+
"homepage": "https://docs.withpersona.com/docs/react-native-sdk-v1-integration",
|
|
35
47
|
"license": "MIT",
|
|
36
48
|
"licenseFilename": "LICENSE",
|
|
37
49
|
"readmeFilename": "README.md",
|
|
38
50
|
"peerDependencies": {
|
|
39
|
-
"react": "
|
|
40
|
-
"react-native": "
|
|
51
|
+
"react": "*",
|
|
52
|
+
"react-native": "*"
|
|
41
53
|
},
|
|
42
54
|
"devDependencies": {
|
|
55
|
+
"@react-native-community/eslint-config": "^2.0.0",
|
|
43
56
|
"@types/cli-table": "^0.3.0",
|
|
44
57
|
"@types/inquirer": "^6.5.0",
|
|
45
58
|
"@types/jest": "^26.0.14",
|
|
46
59
|
"@types/node": "^13.13.4",
|
|
47
60
|
"@types/object-path": "^0.11.0",
|
|
48
61
|
"@types/react-native": "^0.62.0",
|
|
62
|
+
"eslint": "^7.2.0",
|
|
63
|
+
"eslint-config-prettier": "^7.0.0",
|
|
64
|
+
"eslint-plugin-prettier": "^3.1.3",
|
|
49
65
|
"jest": "^26.6.3",
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"react
|
|
66
|
+
"pod-install": "^0.1.0",
|
|
67
|
+
"prettier": "^2.3.2",
|
|
68
|
+
"react": "16.13.0",
|
|
69
|
+
"react-native": "^0.63.4",
|
|
70
|
+
"react-native-builder-bob": "^0.18.2",
|
|
53
71
|
"ts-jest": "^26.4.4",
|
|
54
|
-
"typescript": "^3.
|
|
72
|
+
"typescript": "^4.3.5"
|
|
55
73
|
},
|
|
56
74
|
"dependencies": {
|
|
57
75
|
"chalk": "^4.0.0",
|
|
@@ -59,8 +77,47 @@
|
|
|
59
77
|
"cosmiconfig": "^6.0.0",
|
|
60
78
|
"inquirer": "^7.1.0",
|
|
61
79
|
"minimist": "^1.2.5",
|
|
62
|
-
"object-path": "^0.11.
|
|
80
|
+
"object-path": "^0.11.8",
|
|
63
81
|
"pkg-up": "^3.1.0",
|
|
64
82
|
"xmlbuilder2": "^2.1.2"
|
|
83
|
+
},
|
|
84
|
+
"jest": {
|
|
85
|
+
"preset": "react-native",
|
|
86
|
+
"modulePathIgnorePatterns": [
|
|
87
|
+
"<rootDir>/example/node_modules",
|
|
88
|
+
"<rootDir>/lib/"
|
|
89
|
+
]
|
|
90
|
+
},
|
|
91
|
+
"eslintConfig": {
|
|
92
|
+
"root": true,
|
|
93
|
+
"extends": [
|
|
94
|
+
"@react-native-community",
|
|
95
|
+
"prettier"
|
|
96
|
+
],
|
|
97
|
+
"rules": {
|
|
98
|
+
"prettier/prettier": [
|
|
99
|
+
"error",
|
|
100
|
+
{
|
|
101
|
+
"quoteProps": "consistent",
|
|
102
|
+
"singleQuote": true,
|
|
103
|
+
"tabWidth": 2,
|
|
104
|
+
"trailingComma": "es5",
|
|
105
|
+
"useTabs": false
|
|
106
|
+
}
|
|
107
|
+
]
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
"eslintIgnore": [
|
|
111
|
+
"node_modules/",
|
|
112
|
+
"lib/"
|
|
113
|
+
],
|
|
114
|
+
"react-native-builder-bob": {
|
|
115
|
+
"source": "src",
|
|
116
|
+
"output": "lib",
|
|
117
|
+
"targets": [
|
|
118
|
+
"commonjs",
|
|
119
|
+
"module",
|
|
120
|
+
"typescript"
|
|
121
|
+
]
|
|
65
122
|
}
|
|
66
123
|
}
|
package/src/index.ts
CHANGED
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
NativeModules,
|
|
3
3
|
NativeEventEmitter,
|
|
4
4
|
EventSubscription,
|
|
5
|
-
} from
|
|
5
|
+
} from 'react-native';
|
|
6
6
|
import { processThemeValues } from './util';
|
|
7
7
|
|
|
8
8
|
const { PersonaInquiry } = NativeModules;
|
|
@@ -12,13 +12,13 @@ const { PersonaInquiry } = NativeModules;
|
|
|
12
12
|
declare const Unique: unique symbol;
|
|
13
13
|
export type Opaque<T, Tag> = T & { [Unique]: Tag };
|
|
14
14
|
|
|
15
|
-
type TemplateId = Opaque<string,
|
|
16
|
-
type InquiryId = Opaque<string,
|
|
17
|
-
type AccountId = Opaque<string,
|
|
15
|
+
type TemplateId = Opaque<string, 'TemplateId'>;
|
|
16
|
+
type InquiryId = Opaque<string, 'InquiryId'>;
|
|
17
|
+
type AccountId = Opaque<string, 'AccountId'>;
|
|
18
18
|
|
|
19
|
-
export class InvalidTemplateId extends Error {
|
|
20
|
-
export class InvalidInquiryId extends Error {
|
|
21
|
-
export class InvalidAccountId extends Error {
|
|
19
|
+
export class InvalidTemplateId extends Error {}
|
|
20
|
+
export class InvalidInquiryId extends Error {}
|
|
21
|
+
export class InvalidAccountId extends Error {}
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* Run validations that the string is in proper Inquiry token format
|
|
@@ -27,7 +27,7 @@ export class InvalidAccountId extends Error { }
|
|
|
27
27
|
* @param candidate
|
|
28
28
|
*/
|
|
29
29
|
function makeInquiryId(candidate: string): InquiryId {
|
|
30
|
-
if (candidate.startsWith(
|
|
30
|
+
if (candidate.startsWith('inq_')) return candidate as InquiryId;
|
|
31
31
|
|
|
32
32
|
throw new InvalidInquiryId(
|
|
33
33
|
`Valid template IDs start with "inq_". Received: ${candidate} `
|
|
@@ -41,7 +41,7 @@ function makeInquiryId(candidate: string): InquiryId {
|
|
|
41
41
|
* @param candidate
|
|
42
42
|
*/
|
|
43
43
|
function makeTemplateId(candidate: string): TemplateId {
|
|
44
|
-
if (candidate.startsWith(
|
|
44
|
+
if (candidate.startsWith('tmpl_') || candidate.startsWith('blu_')) {
|
|
45
45
|
return candidate as TemplateId;
|
|
46
46
|
}
|
|
47
47
|
|
|
@@ -57,7 +57,7 @@ function makeTemplateId(candidate: string): TemplateId {
|
|
|
57
57
|
* @param candidate
|
|
58
58
|
*/
|
|
59
59
|
function makeAccountId(candidate: string): AccountId {
|
|
60
|
-
if (candidate.startsWith(
|
|
60
|
+
if (candidate.startsWith('act_')) {
|
|
61
61
|
return candidate as AccountId;
|
|
62
62
|
}
|
|
63
63
|
|
|
@@ -146,8 +146,8 @@ export namespace Fields {
|
|
|
146
146
|
* on the native side bridge into Kotlin / Swift enums.
|
|
147
147
|
*/
|
|
148
148
|
export enum Environment {
|
|
149
|
-
SANDBOX =
|
|
150
|
-
PRODUCTION =
|
|
149
|
+
SANDBOX = 'sandbox',
|
|
150
|
+
PRODUCTION = 'production',
|
|
151
151
|
}
|
|
152
152
|
|
|
153
153
|
export interface InquiryOptions {
|
|
@@ -278,13 +278,13 @@ export class Inquiry {
|
|
|
278
278
|
|
|
279
279
|
start() {
|
|
280
280
|
this.onSuccessListener = eventEmitter.addListener(
|
|
281
|
-
|
|
281
|
+
'onSuccess',
|
|
282
282
|
({
|
|
283
283
|
inquiryId: inquiryId,
|
|
284
284
|
attributes: attributes,
|
|
285
285
|
}: BridgeOnSuccessCallbackParams) => {
|
|
286
286
|
// Native Brige sends an ISO 8601 Date. Convert this to a JS Date
|
|
287
|
-
if (typeof attributes.birthdate ===
|
|
287
|
+
if (typeof attributes.birthdate === 'string') {
|
|
288
288
|
attributes.birthdate = new Date(attributes.birthdate);
|
|
289
289
|
}
|
|
290
290
|
if (this.onSuccess) this.onSuccess(inquiryId, attributes);
|
|
@@ -292,13 +292,13 @@ export class Inquiry {
|
|
|
292
292
|
}
|
|
293
293
|
);
|
|
294
294
|
|
|
295
|
-
this.onCancelledListener = eventEmitter.addListener(
|
|
295
|
+
this.onCancelledListener = eventEmitter.addListener('onCancelled', () => {
|
|
296
296
|
if (this.onCancelled) this.onCancelled();
|
|
297
297
|
this.clearListeners();
|
|
298
298
|
});
|
|
299
299
|
|
|
300
300
|
this.onFailedListener = eventEmitter.addListener(
|
|
301
|
-
|
|
301
|
+
'onFailed',
|
|
302
302
|
({ inquiryId: inquiryId }: BridgeOnFailedCallbackParams) => {
|
|
303
303
|
if (this.onFailed) this.onFailed(inquiryId);
|
|
304
304
|
this.clearListeners();
|
|
@@ -306,7 +306,7 @@ export class Inquiry {
|
|
|
306
306
|
);
|
|
307
307
|
|
|
308
308
|
this.onErrorListener = eventEmitter.addListener(
|
|
309
|
-
|
|
309
|
+
'onError',
|
|
310
310
|
({ error: errorMessage }: BridgeOnErrorCallbackParams) => {
|
|
311
311
|
if (this.onError) this.onError(new Error(errorMessage));
|
|
312
312
|
this.clearListeners();
|
|
@@ -326,7 +326,6 @@ export class Inquiry {
|
|
|
326
326
|
}
|
|
327
327
|
}
|
|
328
328
|
|
|
329
|
-
|
|
330
329
|
interface NameField {
|
|
331
330
|
first?: string;
|
|
332
331
|
middle?: string;
|