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.
Files changed (77) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/RNPersonaInquiry.podspec +1 -1
  3. package/android/README.md +14 -0
  4. package/android/build.gradle +21 -100
  5. package/bin/persona-tool +1 -2
  6. package/lib/commonjs/index.js +477 -0
  7. package/lib/commonjs/index.js.map +1 -0
  8. package/lib/commonjs/persona-tools/AndroidResourcePrinter.js +694 -0
  9. package/lib/commonjs/persona-tools/AndroidResourcePrinter.js.map +1 -0
  10. package/lib/commonjs/persona-tools/Config.js +95 -0
  11. package/lib/commonjs/persona-tools/Config.js.map +1 -0
  12. package/lib/commonjs/persona-tools/Theme.js +228 -0
  13. package/lib/commonjs/persona-tools/Theme.js.map +1 -0
  14. package/lib/commonjs/persona-tools/index.js +41 -0
  15. package/lib/commonjs/persona-tools/index.js.map +1 -0
  16. package/lib/commonjs/persona-tools/prompts.js +48 -0
  17. package/lib/commonjs/persona-tools/prompts.js.map +1 -0
  18. package/lib/commonjs/persona-tools/tools/AndroidThemeGenerator.js +112 -0
  19. package/lib/commonjs/persona-tools/tools/AndroidThemeGenerator.js.map +1 -0
  20. package/lib/commonjs/persona-tools/tools/IosThemeInstructions.js +50 -0
  21. package/lib/commonjs/persona-tools/tools/IosThemeInstructions.js.map +1 -0
  22. package/lib/commonjs/util.js +36 -0
  23. package/lib/commonjs/util.js.map +1 -0
  24. package/lib/module/index.js +452 -0
  25. package/lib/module/index.js.map +1 -0
  26. package/lib/module/persona-tools/AndroidResourcePrinter.js +686 -0
  27. package/lib/module/persona-tools/AndroidResourcePrinter.js.map +1 -0
  28. package/lib/module/persona-tools/Config.js +82 -0
  29. package/lib/module/persona-tools/Config.js.map +1 -0
  30. package/lib/module/persona-tools/Theme.js +212 -0
  31. package/lib/module/persona-tools/Theme.js.map +1 -0
  32. package/lib/module/persona-tools/index.js +33 -0
  33. package/lib/module/persona-tools/index.js.map +1 -0
  34. package/lib/module/persona-tools/prompts.js +31 -0
  35. package/lib/module/persona-tools/prompts.js.map +1 -0
  36. package/lib/module/persona-tools/tools/AndroidThemeGenerator.js +82 -0
  37. package/lib/module/persona-tools/tools/AndroidThemeGenerator.js.map +1 -0
  38. package/lib/module/persona-tools/tools/IosThemeInstructions.js +37 -0
  39. package/lib/module/persona-tools/tools/IosThemeInstructions.js.map +1 -0
  40. package/lib/module/util.js +29 -0
  41. package/lib/module/util.js.map +1 -0
  42. package/{generatedTypes → lib/typescript}/index.d.ts +67 -3
  43. package/lib/typescript/persona-tools/AndroidResourcePrinter.d.ts +40 -0
  44. package/lib/typescript/persona-tools/Config.d.ts +15 -0
  45. package/lib/typescript/persona-tools/Theme.d.ts +124 -0
  46. package/lib/typescript/persona-tools/index.d.ts +1 -0
  47. package/lib/typescript/persona-tools/prompts.d.ts +8 -0
  48. package/lib/typescript/persona-tools/tools/AndroidThemeGenerator.d.ts +5 -0
  49. package/lib/typescript/persona-tools/tools/IosThemeInstructions.d.ts +5 -0
  50. package/lib/typescript/util.d.ts +3 -0
  51. package/package.json +79 -22
  52. package/src/index.ts +17 -18
  53. package/{persona-tools/lib → src/persona-tools}/AndroidResourcePrinter.ts +314 -278
  54. package/{persona-tools/config.ts → src/persona-tools/Config.ts} +7 -7
  55. package/src/persona-tools/Theme.ts +262 -0
  56. package/src/persona-tools/index.ts +30 -0
  57. package/{persona-tools/lib → src/persona-tools}/prompts.ts +11 -11
  58. package/{persona-tools → src/persona-tools}/tools/AndroidThemeGenerator.ts +31 -32
  59. package/{persona-tools → src/persona-tools}/tools/IosThemeInstructions.ts +8 -8
  60. package/src/util.ts +3 -3
  61. package/jest.config.js +0 -10
  62. package/persona-tools/Theme.js +0 -213
  63. package/persona-tools/Theme.ts +0 -260
  64. package/persona-tools/config.js +0 -72
  65. package/persona-tools/index.js +0 -30
  66. package/persona-tools/index.ts +0 -30
  67. package/persona-tools/lib/AndroidResourcePrinter.js +0 -832
  68. package/persona-tools/lib/AndroidResourcePrinter.spec.js +0 -1135
  69. package/persona-tools/lib/AndroidResourcePrinter.spec.ts +0 -1229
  70. package/persona-tools/lib/prompts.js +0 -39
  71. package/persona-tools/tools/AndroidThemeGenerator.js +0 -59
  72. package/persona-tools/tools/IosThemeInstructions.js +0 -34
  73. package/src/index.js +0 -307
  74. package/src/util.js +0 -29
  75. package/src/util.spec.js +0 -15
  76. package/src/util.spec.ts +0 -16
  77. 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.2.10",
4
+ "version": "1.3.1",
5
5
  "description": "Launch a mobile native implementation of the Persona inquiry flow from React Native.",
6
- "main": "src/index.js",
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": "./bin/persona-tool"
12
+ "persona-tool": "bin/persona-tool"
9
13
  },
10
14
  "scripts": {
11
- "tsc": "tsc",
12
- "tsc.watch": "tsc --watch"
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
- "generatedTypes",
25
+ "lib",
26
+ "android",
27
+ "ios",
21
28
  "bin",
22
- "persona-tools",
23
29
  "RNPersonaInquiry.podspec",
24
- "jest.config.js",
25
- "tsconfig.json",
26
- "README.md"
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": "^16.9.0",
40
- "react-native": ">=0.62.2"
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
- "prettier": "^2.2.1",
51
- "react": ">=16.9.0",
52
- "react-native": ">=0.62.2",
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.8.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.4",
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 "react-native";
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, "TemplateId">;
16
- type InquiryId = Opaque<string, "InquiryId">;
17
- type AccountId = Opaque<string, "AccountId">;
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("inq_")) return candidate as InquiryId;
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("tmpl_") || candidate.startsWith("blu_")) {
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("act_")) {
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 = "sandbox",
150
- PRODUCTION = "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
- "onSuccess",
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 === "string") {
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("onCancelled", () => {
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
- "onFailed",
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
- "onError",
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;