react-native-persona 2.25.2 → 2.26.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 +1 -1
- package/android/build.gradle +3 -2
- package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +3 -1
- package/android/gradlew +174 -108
- package/android/gradlew.bat +12 -23
- package/android/src/main/java/com/withpersona/sdk2/reactnative/InquiryEventEmitter.java +110 -0
- package/android/src/main/java/com/withpersona/sdk2/reactnative/InquiryUtils.java +301 -0
- package/android/src/main/java/com/withpersona/sdk2/reactnative/PersonaInquiryModule2.java +12 -353
- package/android/src/main/java/com/withpersona/sdk2/reactnative/PersonaInquiryPackage2.java +7 -5
- package/android/src/main/java/com/withpersona/sdk2/reactnative/PersonaInquiryViewManager.java +190 -0
- package/android/src/main/res/values/ids.xml +4 -0
- package/ios/PersonaInquiry-Bridging-Header.h +2 -0
- package/ios/PersonaInquiry.xcodeproj/project.pbxproj +4 -0
- package/ios/PersonaInquiry2.swift +25 -23
- package/ios/PersonaInquiryBridge.m +13 -0
- package/ios/PersonaInquiryViewManager.swift +248 -0
- package/lib/commonjs/PersonaInquiryView.js +69 -0
- package/lib/commonjs/PersonaInquiryView.js.map +1 -0
- package/lib/commonjs/PersonaInquiryViewManager.js +10 -0
- package/lib/commonjs/PersonaInquiryViewManager.js.map +1 -0
- package/lib/commonjs/StepData.js +66 -0
- package/lib/commonjs/StepData.js.map +1 -0
- package/lib/commonjs/callbacks.js +6 -0
- package/lib/commonjs/callbacks.js.map +1 -0
- package/lib/commonjs/index.js +115 -143
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/util.js +71 -0
- package/lib/commonjs/util.js.map +1 -1
- package/lib/module/PersonaInquiryView.js +60 -0
- package/lib/module/PersonaInquiryView.js.map +1 -0
- package/lib/module/PersonaInquiryViewManager.js +5 -0
- package/lib/module/PersonaInquiryViewManager.js.map +1 -0
- package/lib/module/StepData.js +56 -0
- package/lib/module/StepData.js.map +1 -0
- package/lib/module/callbacks.js +2 -0
- package/lib/module/callbacks.js.map +1 -0
- package/lib/module/index.js +38 -142
- package/lib/module/index.js.map +1 -1
- package/lib/module/util.js +67 -0
- package/lib/module/util.js.map +1 -1
- package/lib/typescript/PersonaInquiryView.d.ts +11 -0
- package/lib/typescript/PersonaInquiryViewManager.d.ts +1 -0
- package/lib/typescript/StepData.d.ts +56 -0
- package/lib/typescript/callbacks.d.ts +21 -0
- package/lib/typescript/index.d.ts +26 -68
- package/lib/typescript/util.d.ts +17 -0
- package/package.json +1 -1
- package/src/PersonaInquiryView.tsx +109 -0
- package/src/PersonaInquiryViewManager.ts +5 -0
- package/src/StepData.ts +83 -0
- package/src/callbacks.ts +37 -0
- package/src/index.ts +98 -221
- package/src/util.ts +111 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Fields } from './fields';
|
|
2
|
+
import type { InquiryEvent } from './InquiryEvent';
|
|
3
|
+
import type { StepData } from './StepData';
|
|
4
|
+
export type OnCompleteCallback = (inquiryId: string, status: string, fields: Fields, extraData: ExtraData) => void;
|
|
5
|
+
export type OnCanceledCallback = (inquiryId?: string, sessionToken?: string) => void;
|
|
6
|
+
export type OnErrorCallback = (error: Error, errorCode?: string) => void;
|
|
7
|
+
export type OnEventCallback = (event: InquiryEvent) => void;
|
|
8
|
+
export type OnReadyCallback = () => void;
|
|
9
|
+
export interface ExtraData {
|
|
10
|
+
collectedData: CollectedData | null;
|
|
11
|
+
}
|
|
12
|
+
export interface CollectedData {
|
|
13
|
+
stepData: StepData[];
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Type for collected data that came directly from iOS/Android.
|
|
17
|
+
* Needs to be translated to TS classes before returning.
|
|
18
|
+
*/
|
|
19
|
+
export interface ExternalCollectedData {
|
|
20
|
+
stepData: any[];
|
|
21
|
+
}
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import { Fields } from './fields';
|
|
2
|
-
import
|
|
3
|
-
export { Fields };
|
|
2
|
+
import PersonaInquiryView from './PersonaInquiryView';
|
|
4
3
|
import { Versions } from './versions';
|
|
4
|
+
import type { CollectedData, ExtraData, OnCanceledCallback, OnCompleteCallback, OnErrorCallback, OnEventCallback } from './callbacks';
|
|
5
|
+
import { StepData, Document, UiStepData, SelfieCaptureMethod, SelfieCapture, SelfieStepData, GovernmentIdCaptureFrames, GovernmentIdCaptureSide, GovernmentIdCaptureMethod, GovernmentIdCapture, GovernmentIdStepData, DocumentStepData } from './StepData';
|
|
6
|
+
export { Fields };
|
|
7
|
+
export { PersonaInquiryView };
|
|
5
8
|
export { Versions };
|
|
9
|
+
export { CollectedData, ExtraData, OnCanceledCallback, OnCompleteCallback, OnErrorCallback, OnEventCallback, };
|
|
10
|
+
export { StepData, Document, UiStepData, SelfieCaptureMethod, SelfieCapture, SelfieStepData, GovernmentIdCaptureFrames, GovernmentIdCaptureSide, GovernmentIdCaptureMethod, GovernmentIdCapture, GovernmentIdStepData, DocumentStepData, };
|
|
6
11
|
declare const Unique: unique symbol;
|
|
7
12
|
export type Opaque<T, Tag> = T & {
|
|
8
13
|
[Unique]: Tag;
|
|
@@ -58,72 +63,6 @@ export interface InquiryOptions {
|
|
|
58
63
|
iosThemeObject?: Object | null;
|
|
59
64
|
themeSource?: ThemeSource | null;
|
|
60
65
|
}
|
|
61
|
-
type OnCompleteCallback = (inquiryId: string, status: string, fields: Fields, extraData: ExtraData) => void;
|
|
62
|
-
export interface ExtraData {
|
|
63
|
-
collectedData: CollectedData | null;
|
|
64
|
-
}
|
|
65
|
-
export interface CollectedData {
|
|
66
|
-
stepData: StepData[];
|
|
67
|
-
}
|
|
68
|
-
export interface StepData {
|
|
69
|
-
stepName: string;
|
|
70
|
-
}
|
|
71
|
-
export declare class DocumentStepData implements StepData {
|
|
72
|
-
stepName: string;
|
|
73
|
-
documents: Document[];
|
|
74
|
-
constructor();
|
|
75
|
-
}
|
|
76
|
-
export interface Document {
|
|
77
|
-
absoluteFilePath: string;
|
|
78
|
-
}
|
|
79
|
-
export declare class GovernmentIdStepData implements StepData {
|
|
80
|
-
stepName: string;
|
|
81
|
-
captures: GovernmentIdCapture[];
|
|
82
|
-
constructor();
|
|
83
|
-
}
|
|
84
|
-
export interface GovernmentIdCapture {
|
|
85
|
-
idClass: string;
|
|
86
|
-
captureMethod: GovernmentIdCaptureMethod;
|
|
87
|
-
side: GovernmentIdCaptureSide;
|
|
88
|
-
frames: GovernmentIdCaptureFrames[];
|
|
89
|
-
}
|
|
90
|
-
export declare enum GovernmentIdCaptureMethod {
|
|
91
|
-
Manual = "Manual",
|
|
92
|
-
Auto = "Auto",
|
|
93
|
-
Upload = "Upload"
|
|
94
|
-
}
|
|
95
|
-
export declare enum GovernmentIdCaptureSide {
|
|
96
|
-
Front = "Front",
|
|
97
|
-
Back = "Back"
|
|
98
|
-
}
|
|
99
|
-
export interface GovernmentIdCaptureFrames {
|
|
100
|
-
absoluteFilePath: string;
|
|
101
|
-
}
|
|
102
|
-
export declare class SelfieStepData implements StepData {
|
|
103
|
-
stepName: string;
|
|
104
|
-
centerCapture: SelfieCapture | null;
|
|
105
|
-
leftCapture: SelfieCapture | null;
|
|
106
|
-
rightCapture: SelfieCapture | null;
|
|
107
|
-
constructor();
|
|
108
|
-
}
|
|
109
|
-
export interface SelfieCapture {
|
|
110
|
-
captureMethod: SelfieCaptureMethod;
|
|
111
|
-
absoluteFilePath: string;
|
|
112
|
-
}
|
|
113
|
-
export declare enum SelfieCaptureMethod {
|
|
114
|
-
Manual = "Manual",
|
|
115
|
-
Auto = "Auto"
|
|
116
|
-
}
|
|
117
|
-
export declare class UiStepData implements StepData {
|
|
118
|
-
stepName: string;
|
|
119
|
-
componentParams: {
|
|
120
|
-
[key: string]: any;
|
|
121
|
-
};
|
|
122
|
-
constructor();
|
|
123
|
-
}
|
|
124
|
-
type OnCanceledCallback = (inquiryId?: string, sessionToken?: string) => void;
|
|
125
|
-
type OnErrorCallback = (error: Error, errorCode?: string) => void;
|
|
126
|
-
type OnEventCallback = (event: InquiryEvent) => void;
|
|
127
66
|
export declare class Inquiry {
|
|
128
67
|
templateId?: TemplateId;
|
|
129
68
|
templateVersion?: TemplateVersion;
|
|
@@ -182,6 +121,25 @@ export declare class Inquiry {
|
|
|
182
121
|
*/
|
|
183
122
|
static fromInquiry(inquiryId: string): InquiryBuilder;
|
|
184
123
|
static onEvent(callback: OnEventCallback): void;
|
|
124
|
+
toOptionsJson(): {
|
|
125
|
+
templateId: TemplateId | undefined;
|
|
126
|
+
templateVersion: TemplateVersion | undefined;
|
|
127
|
+
inquiryId: InquiryId | undefined;
|
|
128
|
+
referenceId: string | undefined;
|
|
129
|
+
accountId: AccountId | undefined;
|
|
130
|
+
environment: Environment | undefined;
|
|
131
|
+
environmentId: string | undefined;
|
|
132
|
+
themeSetId: string | undefined;
|
|
133
|
+
sessionToken: string | undefined;
|
|
134
|
+
fields: Fields | null | undefined;
|
|
135
|
+
returnCollectedData: boolean | undefined;
|
|
136
|
+
themeSource: ThemeSource | null | undefined;
|
|
137
|
+
iosTheme: {
|
|
138
|
+
[key: string]: string;
|
|
139
|
+
};
|
|
140
|
+
locale: String | undefined;
|
|
141
|
+
disablePresentationAnimation: Boolean | undefined;
|
|
142
|
+
};
|
|
185
143
|
/**
|
|
186
144
|
* Launch the Persona Inquiry.
|
|
187
145
|
*/
|
package/lib/typescript/util.d.ts
CHANGED
|
@@ -1,3 +1,20 @@
|
|
|
1
|
+
import type { ExternalCollectedData, OnCanceledCallback, OnCompleteCallback, OnErrorCallback, OnReadyCallback } from './callbacks';
|
|
2
|
+
import { RawInquiryField } from './fields';
|
|
1
3
|
export declare function processThemeValues(themeObject: Object): {
|
|
2
4
|
[key: string]: string;
|
|
3
5
|
};
|
|
6
|
+
export declare function callOnCompleteCallback(event: {
|
|
7
|
+
inquiryId: string;
|
|
8
|
+
status: string;
|
|
9
|
+
fields: Record<string, RawInquiryField>;
|
|
10
|
+
collectedData: ExternalCollectedData | null;
|
|
11
|
+
}, callback: OnCompleteCallback | undefined): void;
|
|
12
|
+
export declare function callOnCanceledCallback(event: {
|
|
13
|
+
inquiryId?: string;
|
|
14
|
+
sessionToken?: string;
|
|
15
|
+
}, callback: OnCanceledCallback | undefined): void;
|
|
16
|
+
export declare function callOnErrorCallback(event: {
|
|
17
|
+
debugMessage: string;
|
|
18
|
+
errorCode?: string;
|
|
19
|
+
}, callback: OnErrorCallback | undefined): void;
|
|
20
|
+
export declare function callOnReadyCallback(callback: OnReadyCallback | undefined): void;
|
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.26.0",
|
|
5
5
|
"description": "Launch a mobile native implementation of the Persona inquiry flow from React Native.",
|
|
6
6
|
"homepage": "https://docs.withpersona.com/docs/react-native-sdk-integration",
|
|
7
7
|
"bugs": "https://github.com/persona-id/persona-inquiry-sdk-public",
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import React, { useCallback, useEffect, useRef } from 'react';
|
|
2
|
+
import { findNodeHandle, UIManager } from 'react-native';
|
|
3
|
+
import { PersonaInquiryViewManager } from './PersonaInquiryViewManager';
|
|
4
|
+
import {
|
|
5
|
+
callOnCanceledCallback,
|
|
6
|
+
callOnCompleteCallback,
|
|
7
|
+
callOnErrorCallback,
|
|
8
|
+
callOnReadyCallback,
|
|
9
|
+
} from './util';
|
|
10
|
+
import type {
|
|
11
|
+
OnReadyCallback,
|
|
12
|
+
OnCanceledCallback,
|
|
13
|
+
OnCompleteCallback,
|
|
14
|
+
OnErrorCallback,
|
|
15
|
+
OnEventCallback,
|
|
16
|
+
} from './callbacks';
|
|
17
|
+
import type { InquiryEvent } from './InquiryEvent';
|
|
18
|
+
|
|
19
|
+
const create = (viewId: number | null) => {
|
|
20
|
+
try {
|
|
21
|
+
const viewManagerConfig =
|
|
22
|
+
UIManager.getViewManagerConfig('PersonaInquiryView');
|
|
23
|
+
if (!viewManagerConfig || !viewManagerConfig.Commands) {
|
|
24
|
+
console.error('PersonaInquiryView config not found');
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
UIManager.dispatchViewManagerCommand(
|
|
28
|
+
viewId,
|
|
29
|
+
viewManagerConfig.Commands.create,
|
|
30
|
+
[viewId]
|
|
31
|
+
);
|
|
32
|
+
} catch (error) {
|
|
33
|
+
console.error('Error dispatching create command:', error);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
let onReadyCalled = false;
|
|
38
|
+
let onReadyCallback = () => {};
|
|
39
|
+
export const onPersonaInquiryViewEvent: OnEventCallback = (
|
|
40
|
+
event: InquiryEvent
|
|
41
|
+
) => {
|
|
42
|
+
if (event.type == 'start') {
|
|
43
|
+
onReadyCalled = false;
|
|
44
|
+
} else if (event.type == 'page_change' && !onReadyCalled) {
|
|
45
|
+
onReadyCalled = true;
|
|
46
|
+
|
|
47
|
+
setTimeout(function () {
|
|
48
|
+
onReadyCallback();
|
|
49
|
+
}, 400);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export default function PersonaInquiryView(props: {
|
|
54
|
+
style: any;
|
|
55
|
+
inquiry: any;
|
|
56
|
+
onComplete: OnCompleteCallback;
|
|
57
|
+
onCanceled: OnCanceledCallback;
|
|
58
|
+
onError: OnErrorCallback;
|
|
59
|
+
onReady: OnReadyCallback;
|
|
60
|
+
}) {
|
|
61
|
+
const ref = useRef(null);
|
|
62
|
+
|
|
63
|
+
useEffect(() => {
|
|
64
|
+
const viewId = findNodeHandle(ref.current);
|
|
65
|
+
|
|
66
|
+
onReadyCallback = () => {
|
|
67
|
+
props.onReady();
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
create(viewId);
|
|
71
|
+
}, []);
|
|
72
|
+
|
|
73
|
+
const _onComplete = useCallback(
|
|
74
|
+
(event: any) => {
|
|
75
|
+
callOnCompleteCallback(event.nativeEvent, props.onComplete);
|
|
76
|
+
},
|
|
77
|
+
[props.onComplete]
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
const _onCanceled = useCallback(
|
|
81
|
+
(event: any) => {
|
|
82
|
+
callOnCanceledCallback(event.nativeEvent, props.onCanceled);
|
|
83
|
+
},
|
|
84
|
+
[props.onCanceled]
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
const _onError = useCallback(
|
|
88
|
+
(event: any) => {
|
|
89
|
+
callOnErrorCallback(event.nativeEvent, props.onError);
|
|
90
|
+
},
|
|
91
|
+
[props.onError]
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
const _onReady = useCallback(() => {
|
|
95
|
+
callOnReadyCallback(props.onReady);
|
|
96
|
+
}, [props.onReady]);
|
|
97
|
+
|
|
98
|
+
return (
|
|
99
|
+
<PersonaInquiryViewManager
|
|
100
|
+
style={props.style}
|
|
101
|
+
inquiry={props.inquiry.toOptionsJson()}
|
|
102
|
+
onComplete={_onComplete}
|
|
103
|
+
onCanceled={_onCanceled}
|
|
104
|
+
onError={_onError}
|
|
105
|
+
onReady={_onReady}
|
|
106
|
+
ref={ref}
|
|
107
|
+
/>
|
|
108
|
+
);
|
|
109
|
+
}
|
package/src/StepData.ts
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
export class DocumentStepData implements StepData {
|
|
2
|
+
stepName: string;
|
|
3
|
+
documents: Document[];
|
|
4
|
+
|
|
5
|
+
constructor() {
|
|
6
|
+
this.stepName = '';
|
|
7
|
+
this.documents = [];
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export class GovernmentIdStepData implements StepData {
|
|
12
|
+
stepName: string;
|
|
13
|
+
captures: GovernmentIdCapture[];
|
|
14
|
+
|
|
15
|
+
constructor() {
|
|
16
|
+
this.stepName = '';
|
|
17
|
+
this.captures = [];
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface GovernmentIdCapture {
|
|
22
|
+
idClass: string;
|
|
23
|
+
captureMethod: GovernmentIdCaptureMethod;
|
|
24
|
+
side: GovernmentIdCaptureSide;
|
|
25
|
+
frames: GovernmentIdCaptureFrames[];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export enum GovernmentIdCaptureMethod {
|
|
29
|
+
Manual = 'Manual',
|
|
30
|
+
Auto = 'Auto',
|
|
31
|
+
Upload = 'Upload',
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export enum GovernmentIdCaptureSide {
|
|
35
|
+
Front = 'Front',
|
|
36
|
+
Back = 'Back',
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface GovernmentIdCaptureFrames {
|
|
40
|
+
absoluteFilePath: string;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export class SelfieStepData implements StepData {
|
|
44
|
+
stepName: string;
|
|
45
|
+
centerCapture: SelfieCapture | null;
|
|
46
|
+
leftCapture: SelfieCapture | null;
|
|
47
|
+
rightCapture: SelfieCapture | null;
|
|
48
|
+
|
|
49
|
+
constructor() {
|
|
50
|
+
this.stepName = '';
|
|
51
|
+
this.centerCapture = null;
|
|
52
|
+
this.leftCapture = null;
|
|
53
|
+
this.rightCapture = null;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export interface SelfieCapture {
|
|
58
|
+
captureMethod: SelfieCaptureMethod;
|
|
59
|
+
absoluteFilePath: string;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export enum SelfieCaptureMethod {
|
|
63
|
+
Manual = 'Manual',
|
|
64
|
+
Auto = 'Auto',
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export class UiStepData implements StepData {
|
|
68
|
+
stepName: string;
|
|
69
|
+
componentParams: { [key: string]: any };
|
|
70
|
+
|
|
71
|
+
constructor() {
|
|
72
|
+
this.stepName = '';
|
|
73
|
+
this.componentParams = {};
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export interface Document {
|
|
78
|
+
absoluteFilePath: string;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export interface StepData {
|
|
82
|
+
stepName: string;
|
|
83
|
+
}
|
package/src/callbacks.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { Fields } from './fields';
|
|
2
|
+
import type { InquiryEvent } from './InquiryEvent';
|
|
3
|
+
import type { StepData } from './StepData';
|
|
4
|
+
|
|
5
|
+
export type OnCompleteCallback = (
|
|
6
|
+
inquiryId: string,
|
|
7
|
+
status: string,
|
|
8
|
+
fields: Fields,
|
|
9
|
+
extraData: ExtraData
|
|
10
|
+
) => void;
|
|
11
|
+
|
|
12
|
+
export type OnCanceledCallback = (
|
|
13
|
+
inquiryId?: string,
|
|
14
|
+
sessionToken?: string
|
|
15
|
+
) => void;
|
|
16
|
+
|
|
17
|
+
export type OnErrorCallback = (error: Error, errorCode?: string) => void;
|
|
18
|
+
|
|
19
|
+
export type OnEventCallback = (event: InquiryEvent) => void;
|
|
20
|
+
|
|
21
|
+
export type OnReadyCallback = () => void;
|
|
22
|
+
|
|
23
|
+
export interface ExtraData {
|
|
24
|
+
collectedData: CollectedData | null;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface CollectedData {
|
|
28
|
+
stepData: StepData[];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Type for collected data that came directly from iOS/Android.
|
|
33
|
+
* Needs to be translated to TS classes before returning.
|
|
34
|
+
*/
|
|
35
|
+
export interface ExternalCollectedData {
|
|
36
|
+
stepData: any[];
|
|
37
|
+
}
|