@trustchex/react-native-sdk 1.163.10 → 1.175.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/lib/module/Shared/EIDReader/tlv/tlvInputStream.js +4 -4
- package/lib/module/Shared/EIDReader/tlv/tlvOutputState.js +4 -4
- package/lib/module/Shared/EIDReader/tlv/tlvOutputStream.js +8 -8
- package/lib/module/Trustchex.js +73 -80
- package/lib/typescript/src/Shared/EIDReader/tlv/tlvOutputStream.d.ts +2 -2
- package/lib/typescript/src/Shared/EIDReader/tlv/tlvOutputStream.d.ts.map +1 -1
- package/lib/typescript/src/Trustchex.d.ts +2 -1
- package/lib/typescript/src/Trustchex.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/Shared/EIDReader/tlv/tlvInputStream.ts +4 -4
- package/src/Shared/EIDReader/tlv/tlvOutputState.ts +4 -4
- package/src/Shared/EIDReader/tlv/tlvOutputStream.ts +8 -8
- package/src/Trustchex.tsx +81 -73
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { ByteArrayInputStream } from "../java/byteArrayInputStream.js";
|
|
4
4
|
import { DataInputStream } from "../java/dataInputStream.js";
|
|
5
5
|
import { InputStream } from "../java/inputStream.js";
|
|
6
|
-
import
|
|
6
|
+
import TLVUtil from "./tlv.utils.js";
|
|
7
7
|
import { TLVInputState } from "./tlvInputState.js";
|
|
8
8
|
export class TLVInputStream extends InputStream {
|
|
9
9
|
static MAX_BUFFER_LENGTH = 65535;
|
|
@@ -117,11 +117,11 @@ export class TLVInputStream extends InputStream {
|
|
|
117
117
|
let tag = -1;
|
|
118
118
|
if (this.state.getIsAtStartOfTag()) {} else if (this.state.getIsAtStartOfLength()) {
|
|
119
119
|
await this.readLength();
|
|
120
|
-
if (
|
|
120
|
+
if (TLVUtil.isPrimitive(this.state.getTag())) {
|
|
121
121
|
await this.skipValue();
|
|
122
122
|
}
|
|
123
123
|
} else {
|
|
124
|
-
if (
|
|
124
|
+
if (TLVUtil.isPrimitive(this.state.getTag())) {
|
|
125
125
|
await this.skipValue();
|
|
126
126
|
}
|
|
127
127
|
}
|
|
@@ -129,7 +129,7 @@ export class TLVInputStream extends InputStream {
|
|
|
129
129
|
if (tag === searchTag) {
|
|
130
130
|
return;
|
|
131
131
|
}
|
|
132
|
-
if (
|
|
132
|
+
if (TLVUtil.isPrimitive(tag)) {
|
|
133
133
|
const length = await this.readLength();
|
|
134
134
|
const skippedBytes = await this.skipValue();
|
|
135
135
|
if (skippedBytes >= length) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import TLVUtil from "./tlv.utils.js";
|
|
4
4
|
export class TLVOutputState {
|
|
5
5
|
constructor() {
|
|
6
6
|
this.state = [];
|
|
@@ -56,7 +56,7 @@ export class TLVOutputState {
|
|
|
56
56
|
const obj = new TLVStruct(tag);
|
|
57
57
|
if (this.state.length !== 0) {
|
|
58
58
|
const parent = this.state[this.state.length - 1];
|
|
59
|
-
const tagBytes =
|
|
59
|
+
const tagBytes = TLVUtil.getTagAsBytes(tag);
|
|
60
60
|
parent.write(tagBytes, 0, tagBytes.length);
|
|
61
61
|
}
|
|
62
62
|
this.state.push(obj);
|
|
@@ -83,7 +83,7 @@ export class TLVOutputState {
|
|
|
83
83
|
const obj = this.state.pop();
|
|
84
84
|
if (this.state.length !== 0) {
|
|
85
85
|
const parent = this.state[this.state.length - 1];
|
|
86
|
-
const lengthBytes =
|
|
86
|
+
const lengthBytes = TLVUtil.getLengthAsBytes(length);
|
|
87
87
|
parent.write(lengthBytes, 0, lengthBytes.length);
|
|
88
88
|
}
|
|
89
89
|
if (obj) {
|
|
@@ -102,7 +102,7 @@ export class TLVOutputState {
|
|
|
102
102
|
currentObject.setLength(byteCount);
|
|
103
103
|
if (currentObject.getValueBytesProcessed() === currentObject.getLength()) {
|
|
104
104
|
this.state.pop();
|
|
105
|
-
const lengthBytes =
|
|
105
|
+
const lengthBytes = TLVUtil.getLengthAsBytes(byteCount);
|
|
106
106
|
const value = currentObject.getValue();
|
|
107
107
|
this.updateValueBytesProcessed(lengthBytes, 0, lengthBytes.length);
|
|
108
108
|
this.updateValueBytesProcessed(value, 0, value.length);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { DataOutputStream } from "../java/dataOutputStream.js";
|
|
4
4
|
import { OutputStream } from "../java/outputStream.js";
|
|
5
|
-
import
|
|
5
|
+
import TLVUtil from "./tlv.utils.js";
|
|
6
6
|
import { TLVOutputState } from "./tlvOutputState.js";
|
|
7
7
|
export class TLVOutputStream extends OutputStream {
|
|
8
8
|
constructor(outputStream) {
|
|
@@ -10,20 +10,20 @@ export class TLVOutputStream extends OutputStream {
|
|
|
10
10
|
this.outputStream = outputStream instanceof DataOutputStream ? outputStream : new DataOutputStream(outputStream);
|
|
11
11
|
this.state = new TLVOutputState();
|
|
12
12
|
}
|
|
13
|
-
|
|
13
|
+
writeTag(tag) {
|
|
14
14
|
if (!this.state.getIsAtStartOfTag()) {
|
|
15
15
|
throw new Error('Cannot write tag, still need length');
|
|
16
16
|
}
|
|
17
|
-
const tagAsBytes =
|
|
18
|
-
|
|
17
|
+
const tagAsBytes = TLVUtil.getTagAsBytes(tag);
|
|
18
|
+
this.outputStream.writeBytes(Uint8Array.from(tagAsBytes));
|
|
19
19
|
this.state.setTagProcessed(tag);
|
|
20
20
|
}
|
|
21
|
-
|
|
21
|
+
writeLength(length) {
|
|
22
22
|
if (!this.state.getIsAtStartOfLength()) {
|
|
23
23
|
throw new Error('Cannot write length');
|
|
24
24
|
}
|
|
25
|
-
const lengthAsBytes =
|
|
26
|
-
|
|
25
|
+
const lengthAsBytes = TLVUtil.getLengthAsBytes(length);
|
|
26
|
+
this.outputStream.writeBytes(Uint8Array.from(lengthAsBytes));
|
|
27
27
|
this.state.setLengthProcessed(length);
|
|
28
28
|
}
|
|
29
29
|
writeValue(value) {
|
|
@@ -68,7 +68,7 @@ export class TLVOutputStream extends OutputStream {
|
|
|
68
68
|
const length = bufferedValueBytes.length;
|
|
69
69
|
this.state.updatePreviousLength(length);
|
|
70
70
|
if (this.state.canBeWritten()) {
|
|
71
|
-
const lengthAsBytes =
|
|
71
|
+
const lengthAsBytes = TLVUtil.getLengthAsBytes(length);
|
|
72
72
|
this.outputStream.writeBytes(Uint8Array.from(lengthAsBytes));
|
|
73
73
|
this.outputStream.writeBytes(Uint8Array.from(bufferedValueBytes));
|
|
74
74
|
}
|
package/lib/module/Trustchex.js
CHANGED
|
@@ -1,22 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import React, { useEffect } from 'react';
|
|
3
|
+
import React, { useEffect, useState, useMemo } from 'react';
|
|
4
4
|
import { NavigationContainer } from '@react-navigation/native';
|
|
5
5
|
import { createNativeStackNavigator } from '@react-navigation/native-stack';
|
|
6
|
+
import { View, ActivityIndicator, StyleSheet } from 'react-native';
|
|
7
|
+
import { MD3LightTheme, PaperProvider } from 'react-native-paper';
|
|
8
|
+
import 'react-native-get-random-values';
|
|
6
9
|
import IdentityDocumentEIDScanningScreen from "./Screens/Dynamic/IdentityDocumentEIDScanningScreen.js";
|
|
7
10
|
import IdentityDocumentScanningScreen from "./Screens/Dynamic/IdentityDocumentScanningScreen.js";
|
|
8
11
|
import LivenessDetectionScreen from "./Screens/Dynamic/LivenessDetectionScreen.js";
|
|
9
12
|
import ResultScreen from "./Screens/Static/ResultScreen.js";
|
|
10
13
|
import ContractAcceptanceScreen from "./Screens/Dynamic/ContractAcceptanceScreen.js";
|
|
11
14
|
import VerificationSessionCheckScreen from "./Screens/Static/VerificationSessionCheckScreen.js";
|
|
15
|
+
import QrCodeScanningScreen from "./Screens/Static/QrCodeScanningScreen.js";
|
|
12
16
|
import AppContext from "./Shared/Contexts/AppContext.js";
|
|
13
17
|
import i18n from "./Translation/index.js";
|
|
14
|
-
import { MD3LightTheme, PaperProvider } from 'react-native-paper';
|
|
15
|
-
import 'react-native-get-random-values';
|
|
16
|
-
import QrCodeScanningScreen from "./Screens/Static/QrCodeScanningScreen.js";
|
|
17
18
|
import { initializeTTS } from "./Shared/Libs/tts.utils.js";
|
|
18
19
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
19
20
|
const Stack = createNativeStackNavigator();
|
|
21
|
+
const DEFAULT_BRANDING = {
|
|
22
|
+
logoUrl: '',
|
|
23
|
+
primaryColor: '#000000',
|
|
24
|
+
secondaryColor: '#CCCCCC',
|
|
25
|
+
tertiaryColor: '#FF0000'
|
|
26
|
+
};
|
|
20
27
|
const Trustchex = ({
|
|
21
28
|
baseUrl: propBaseUrl,
|
|
22
29
|
sessionId: propSessionId,
|
|
@@ -25,15 +32,39 @@ const Trustchex = ({
|
|
|
25
32
|
onCompleted,
|
|
26
33
|
onError
|
|
27
34
|
}) => {
|
|
28
|
-
const [baseUrl, setBaseUrl] =
|
|
29
|
-
const [sessionId, setSessionId] =
|
|
30
|
-
const [
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
const [baseUrl, setBaseUrl] = useState(null);
|
|
36
|
+
const [sessionId, setSessionId] = useState(null);
|
|
37
|
+
const [locale, setLocale] = useState(propLocale || i18n.language);
|
|
38
|
+
const branding = useMemo(() => ({
|
|
39
|
+
...DEFAULT_BRANDING,
|
|
40
|
+
...propBranding
|
|
41
|
+
}), [propBranding]);
|
|
42
|
+
const theme = useMemo(() => ({
|
|
43
|
+
...MD3LightTheme,
|
|
44
|
+
colors: {
|
|
45
|
+
...MD3LightTheme.colors,
|
|
46
|
+
primary: branding.primaryColor,
|
|
47
|
+
secondary: branding.secondaryColor,
|
|
48
|
+
tertiary: branding.tertiaryColor
|
|
49
|
+
}
|
|
50
|
+
}), [branding]);
|
|
51
|
+
const contextValue = useMemo(() => ({
|
|
52
|
+
isDemoSession: false,
|
|
53
|
+
baseUrl,
|
|
54
|
+
locale,
|
|
55
|
+
branding,
|
|
56
|
+
identificationInfo: {
|
|
57
|
+
sessionId,
|
|
58
|
+
identificationId: '',
|
|
59
|
+
consent: {
|
|
60
|
+
contractIds: [],
|
|
61
|
+
deviceInfo: ''
|
|
62
|
+
},
|
|
63
|
+
locale: propLocale || i18n.language
|
|
64
|
+
},
|
|
65
|
+
onCompleted,
|
|
66
|
+
onError
|
|
67
|
+
}), [baseUrl, locale, branding, sessionId, propLocale, onCompleted, onError]);
|
|
37
68
|
useEffect(() => {
|
|
38
69
|
initializeTTS();
|
|
39
70
|
}, []);
|
|
@@ -53,97 +84,59 @@ const Trustchex = ({
|
|
|
53
84
|
i18n.changeLanguage(propLocale);
|
|
54
85
|
}
|
|
55
86
|
}, [propLocale]);
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
87
|
+
if (!baseUrl) {
|
|
88
|
+
return /*#__PURE__*/_jsx(View, {
|
|
89
|
+
style: styles.loadingContainer,
|
|
90
|
+
children: /*#__PURE__*/_jsx(ActivityIndicator, {
|
|
91
|
+
size: "large",
|
|
92
|
+
color: branding.primaryColor
|
|
93
|
+
})
|
|
62
94
|
});
|
|
63
|
-
}
|
|
95
|
+
}
|
|
64
96
|
return /*#__PURE__*/_jsx(PaperProvider, {
|
|
65
|
-
theme:
|
|
66
|
-
...MD3LightTheme,
|
|
67
|
-
colors: {
|
|
68
|
-
...MD3LightTheme.colors,
|
|
69
|
-
primary: branding.primaryColor,
|
|
70
|
-
secondary: branding.secondaryColor,
|
|
71
|
-
tertiary: branding.tertiaryColor
|
|
72
|
-
}
|
|
73
|
-
},
|
|
97
|
+
theme: theme,
|
|
74
98
|
children: /*#__PURE__*/_jsx(AppContext.Provider, {
|
|
75
|
-
value:
|
|
76
|
-
isDemoSession: false,
|
|
77
|
-
baseUrl,
|
|
78
|
-
locale,
|
|
79
|
-
branding: {
|
|
80
|
-
primaryColor: branding.primaryColor,
|
|
81
|
-
secondaryColor: branding.secondaryColor,
|
|
82
|
-
tertiaryColor: branding.tertiaryColor,
|
|
83
|
-
logoUrl: branding.logoUrl
|
|
84
|
-
},
|
|
85
|
-
identificationInfo: {
|
|
86
|
-
sessionId: sessionId,
|
|
87
|
-
identificationId: '',
|
|
88
|
-
consent: {
|
|
89
|
-
contractIds: [],
|
|
90
|
-
deviceInfo: ''
|
|
91
|
-
},
|
|
92
|
-
locale: propLocale || i18n.language
|
|
93
|
-
},
|
|
94
|
-
onCompleted,
|
|
95
|
-
onError
|
|
96
|
-
},
|
|
99
|
+
value: contextValue,
|
|
97
100
|
children: /*#__PURE__*/_jsx(NavigationContainer, {
|
|
98
101
|
children: /*#__PURE__*/_jsxs(Stack.Navigator, {
|
|
99
|
-
initialRouteName: "VerificationSessionCheckScreen",
|
|
100
102
|
id: undefined,
|
|
103
|
+
initialRouteName: "VerificationSessionCheckScreen",
|
|
104
|
+
screenOptions: {
|
|
105
|
+
headerShown: false
|
|
106
|
+
},
|
|
101
107
|
children: [/*#__PURE__*/_jsx(Stack.Screen, {
|
|
102
108
|
name: "VerificationSessionCheckScreen",
|
|
103
|
-
component: VerificationSessionCheckScreen
|
|
104
|
-
options: {
|
|
105
|
-
headerShown: false
|
|
106
|
-
}
|
|
109
|
+
component: VerificationSessionCheckScreen
|
|
107
110
|
}), /*#__PURE__*/_jsx(Stack.Screen, {
|
|
108
111
|
name: "ContractAcceptanceScreen",
|
|
109
|
-
component: ContractAcceptanceScreen
|
|
110
|
-
options: {
|
|
111
|
-
headerShown: false
|
|
112
|
-
}
|
|
112
|
+
component: ContractAcceptanceScreen
|
|
113
113
|
}), /*#__PURE__*/_jsx(Stack.Screen, {
|
|
114
114
|
name: "IdentityDocumentScanningScreen",
|
|
115
|
-
component: IdentityDocumentScanningScreen
|
|
116
|
-
options: {
|
|
117
|
-
headerShown: false
|
|
118
|
-
}
|
|
115
|
+
component: IdentityDocumentScanningScreen
|
|
119
116
|
}), /*#__PURE__*/_jsx(Stack.Screen, {
|
|
120
117
|
name: "IdentityDocumentEIDScanningScreen",
|
|
121
|
-
component: IdentityDocumentEIDScanningScreen
|
|
122
|
-
options: {
|
|
123
|
-
headerShown: false
|
|
124
|
-
}
|
|
118
|
+
component: IdentityDocumentEIDScanningScreen
|
|
125
119
|
}), /*#__PURE__*/_jsx(Stack.Screen, {
|
|
126
120
|
name: "LivenessDetectionScreen",
|
|
127
|
-
component: LivenessDetectionScreen
|
|
128
|
-
options: {
|
|
129
|
-
headerShown: false
|
|
130
|
-
}
|
|
121
|
+
component: LivenessDetectionScreen
|
|
131
122
|
}), /*#__PURE__*/_jsx(Stack.Screen, {
|
|
132
123
|
name: "ResultScreen",
|
|
133
|
-
component: ResultScreen
|
|
134
|
-
options: {
|
|
135
|
-
headerShown: false
|
|
136
|
-
}
|
|
124
|
+
component: ResultScreen
|
|
137
125
|
}), /*#__PURE__*/_jsx(Stack.Screen, {
|
|
138
126
|
name: "QrCodeScanningScreen",
|
|
139
|
-
component: QrCodeScanningScreen
|
|
140
|
-
options: {
|
|
141
|
-
headerShown: false
|
|
142
|
-
}
|
|
127
|
+
component: QrCodeScanningScreen
|
|
143
128
|
})]
|
|
144
129
|
})
|
|
145
130
|
})
|
|
146
131
|
})
|
|
147
132
|
});
|
|
148
133
|
};
|
|
134
|
+
const styles = StyleSheet.create({
|
|
135
|
+
loadingContainer: {
|
|
136
|
+
flex: 1,
|
|
137
|
+
justifyContent: 'center',
|
|
138
|
+
alignItems: 'center',
|
|
139
|
+
backgroundColor: 'white'
|
|
140
|
+
}
|
|
141
|
+
});
|
|
149
142
|
export default Trustchex;
|
|
@@ -3,8 +3,8 @@ export declare class TLVOutputStream extends OutputStream {
|
|
|
3
3
|
private outputStream;
|
|
4
4
|
private state;
|
|
5
5
|
constructor(outputStream: OutputStream);
|
|
6
|
-
writeTag(tag: number):
|
|
7
|
-
writeLength(length: number):
|
|
6
|
+
writeTag(tag: number): void;
|
|
7
|
+
writeLength(length: number): void;
|
|
8
8
|
writeValue(value: Uint8Array): void;
|
|
9
9
|
write(b: number): void;
|
|
10
10
|
writeBytes(bytes: Uint8Array): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tlvOutputStream.d.ts","sourceRoot":"","sources":["../../../../../../src/Shared/EIDReader/tlv/tlvOutputStream.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAIpD,qBAAa,eAAgB,SAAQ,YAAY;IAC/C,OAAO,CAAC,YAAY,CAAmB;IACvC,OAAO,CAAC,KAAK,CAAiB;gBAElB,YAAY,EAAE,YAAY;
|
|
1
|
+
{"version":3,"file":"tlvOutputStream.d.ts","sourceRoot":"","sources":["../../../../../../src/Shared/EIDReader/tlv/tlvOutputStream.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAIpD,qBAAa,eAAgB,SAAQ,YAAY;IAC/C,OAAO,CAAC,YAAY,CAAmB;IACvC,OAAO,CAAC,KAAK,CAAiB;gBAElB,YAAY,EAAE,YAAY;IAS/B,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAS3B,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IASxC,UAAU,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI;IAkBnC,KAAK,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI;IAItB,UAAU,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI;IAInC,oBAAoB,CAClB,KAAK,EAAE,UAAU,EACjB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,GACb,IAAI;IAiBP,aAAa,IAAI,IAAI;IAkBrB,KAAK,IAAI,IAAI;IAIb,KAAK,IAAI,IAAI;CAOd"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
import 'react-native-get-random-values';
|
|
2
3
|
interface TrustchexBranding {
|
|
3
4
|
logoUrl?: string;
|
|
@@ -13,6 +14,6 @@ interface TrustchexProps {
|
|
|
13
14
|
onCompleted?: () => void;
|
|
14
15
|
onError?: (error: string) => void;
|
|
15
16
|
}
|
|
16
|
-
declare const Trustchex:
|
|
17
|
+
declare const Trustchex: React.FC<TrustchexProps>;
|
|
17
18
|
export default Trustchex;
|
|
18
19
|
//# sourceMappingURL=Trustchex.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Trustchex.d.ts","sourceRoot":"","sources":["../../../src/Trustchex.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Trustchex.d.ts","sourceRoot":"","sources":["../../../src/Trustchex.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAuC,MAAM,OAAO,CAAC;AAK5D,OAAO,gCAAgC,CAAC;AAexC,UAAU,iBAAiB;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,UAAU,cAAc;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,iBAAiB,CAAC;IAC7B,MAAM,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;IACzB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACnC;AASD,QAAA,MAAM,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CA4HvC,CAAC;AAWF,eAAe,SAAS,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ByteArrayInputStream } from '../java/byteArrayInputStream';
|
|
2
2
|
import { DataInputStream } from '../java/dataInputStream';
|
|
3
3
|
import { InputStream } from '../java/inputStream';
|
|
4
|
-
import
|
|
4
|
+
import TLVUtil from './tlv.utils';
|
|
5
5
|
import { TLVInputState } from './tlvInputState';
|
|
6
6
|
|
|
7
7
|
export class TLVInputStream extends InputStream {
|
|
@@ -132,11 +132,11 @@ export class TLVInputStream extends InputStream {
|
|
|
132
132
|
if (this.state.getIsAtStartOfTag()) {
|
|
133
133
|
} else if (this.state.getIsAtStartOfLength()) {
|
|
134
134
|
await this.readLength();
|
|
135
|
-
if (
|
|
135
|
+
if (TLVUtil.isPrimitive(this.state.getTag())) {
|
|
136
136
|
await this.skipValue();
|
|
137
137
|
}
|
|
138
138
|
} else {
|
|
139
|
-
if (
|
|
139
|
+
if (TLVUtil.isPrimitive(this.state.getTag())) {
|
|
140
140
|
await this.skipValue();
|
|
141
141
|
}
|
|
142
142
|
}
|
|
@@ -144,7 +144,7 @@ export class TLVInputStream extends InputStream {
|
|
|
144
144
|
if (tag === searchTag) {
|
|
145
145
|
return;
|
|
146
146
|
}
|
|
147
|
-
if (
|
|
147
|
+
if (TLVUtil.isPrimitive(tag)) {
|
|
148
148
|
const length = await this.readLength();
|
|
149
149
|
const skippedBytes = await this.skipValue();
|
|
150
150
|
if (skippedBytes >= length) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import TLVUtil from './tlv.utils';
|
|
2
2
|
|
|
3
3
|
export class TLVOutputState {
|
|
4
4
|
private state: TLVStruct[];
|
|
@@ -68,7 +68,7 @@ export class TLVOutputState {
|
|
|
68
68
|
const obj = new TLVStruct(tag);
|
|
69
69
|
if (this.state.length !== 0) {
|
|
70
70
|
const parent = this.state[this.state.length - 1];
|
|
71
|
-
const tagBytes =
|
|
71
|
+
const tagBytes = TLVUtil.getTagAsBytes(tag);
|
|
72
72
|
parent.write(tagBytes, 0, tagBytes.length);
|
|
73
73
|
}
|
|
74
74
|
|
|
@@ -99,7 +99,7 @@ export class TLVOutputState {
|
|
|
99
99
|
const obj = this.state.pop();
|
|
100
100
|
if (this.state.length !== 0) {
|
|
101
101
|
const parent = this.state[this.state.length - 1];
|
|
102
|
-
const lengthBytes =
|
|
102
|
+
const lengthBytes = TLVUtil.getLengthAsBytes(length);
|
|
103
103
|
parent.write(lengthBytes, 0, lengthBytes.length);
|
|
104
104
|
}
|
|
105
105
|
|
|
@@ -125,7 +125,7 @@ export class TLVOutputState {
|
|
|
125
125
|
currentObject.getValueBytesProcessed() === currentObject.getLength()
|
|
126
126
|
) {
|
|
127
127
|
this.state.pop();
|
|
128
|
-
const lengthBytes =
|
|
128
|
+
const lengthBytes = TLVUtil.getLengthAsBytes(byteCount);
|
|
129
129
|
const value = currentObject.getValue();
|
|
130
130
|
this.updateValueBytesProcessed(lengthBytes, 0, lengthBytes.length);
|
|
131
131
|
this.updateValueBytesProcessed(value, 0, value.length);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DataOutputStream } from '../java/dataOutputStream';
|
|
2
2
|
import { OutputStream } from '../java/outputStream';
|
|
3
|
-
import
|
|
3
|
+
import TLVUtil from './tlv.utils';
|
|
4
4
|
import { TLVOutputState } from './tlvOutputState';
|
|
5
5
|
|
|
6
6
|
export class TLVOutputStream extends OutputStream {
|
|
@@ -16,21 +16,21 @@ export class TLVOutputStream extends OutputStream {
|
|
|
16
16
|
this.state = new TLVOutputState();
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
public
|
|
19
|
+
public writeTag(tag: number): void {
|
|
20
20
|
if (!this.state.getIsAtStartOfTag()) {
|
|
21
21
|
throw new Error('Cannot write tag, still need length');
|
|
22
22
|
}
|
|
23
|
-
const tagAsBytes =
|
|
24
|
-
|
|
23
|
+
const tagAsBytes = TLVUtil.getTagAsBytes(tag);
|
|
24
|
+
this.outputStream.writeBytes(Uint8Array.from(tagAsBytes));
|
|
25
25
|
this.state.setTagProcessed(tag);
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
public
|
|
28
|
+
public writeLength(length: number): void {
|
|
29
29
|
if (!this.state.getIsAtStartOfLength()) {
|
|
30
30
|
throw new Error('Cannot write length');
|
|
31
31
|
}
|
|
32
|
-
const lengthAsBytes =
|
|
33
|
-
|
|
32
|
+
const lengthAsBytes = TLVUtil.getLengthAsBytes(length);
|
|
33
|
+
this.outputStream.writeBytes(Uint8Array.from(lengthAsBytes));
|
|
34
34
|
this.state.setLengthProcessed(length);
|
|
35
35
|
}
|
|
36
36
|
|
|
@@ -92,7 +92,7 @@ export class TLVOutputStream extends OutputStream {
|
|
|
92
92
|
const length = bufferedValueBytes.length;
|
|
93
93
|
this.state.updatePreviousLength(length);
|
|
94
94
|
if (this.state.canBeWritten()) {
|
|
95
|
-
const lengthAsBytes =
|
|
95
|
+
const lengthAsBytes = TLVUtil.getLengthAsBytes(length);
|
|
96
96
|
this.outputStream.writeBytes(Uint8Array.from(lengthAsBytes));
|
|
97
97
|
this.outputStream.writeBytes(Uint8Array.from(bufferedValueBytes));
|
|
98
98
|
}
|
package/src/Trustchex.tsx
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
import React, { useEffect } from 'react';
|
|
1
|
+
import React, { useEffect, useState, useMemo } from 'react';
|
|
2
2
|
import { NavigationContainer } from '@react-navigation/native';
|
|
3
3
|
import { createNativeStackNavigator } from '@react-navigation/native-stack';
|
|
4
|
+
import { View, ActivityIndicator, StyleSheet } from 'react-native';
|
|
5
|
+
import { MD3LightTheme, PaperProvider } from 'react-native-paper';
|
|
6
|
+
import 'react-native-get-random-values';
|
|
7
|
+
|
|
4
8
|
import IdentityDocumentEIDScanningScreen from './Screens/Dynamic/IdentityDocumentEIDScanningScreen';
|
|
5
9
|
import IdentityDocumentScanningScreen from './Screens/Dynamic/IdentityDocumentScanningScreen';
|
|
6
10
|
import LivenessDetectionScreen from './Screens/Dynamic/LivenessDetectionScreen';
|
|
7
11
|
import ResultScreen from './Screens/Static/ResultScreen';
|
|
8
12
|
import ContractAcceptanceScreen from './Screens/Dynamic/ContractAcceptanceScreen';
|
|
9
13
|
import VerificationSessionCheckScreen from './Screens/Static/VerificationSessionCheckScreen';
|
|
14
|
+
import QrCodeScanningScreen from './Screens/Static/QrCodeScanningScreen';
|
|
10
15
|
import AppContext from './Shared/Contexts/AppContext';
|
|
11
16
|
import i18n from './Translation';
|
|
12
|
-
import { MD3LightTheme, PaperProvider } from 'react-native-paper';
|
|
13
|
-
import 'react-native-get-random-values';
|
|
14
|
-
import QrCodeScanningScreen from './Screens/Static/QrCodeScanningScreen';
|
|
15
17
|
import { initializeTTS } from './Shared/Libs/tts.utils';
|
|
16
18
|
|
|
17
19
|
const Stack = createNativeStackNavigator();
|
|
@@ -32,24 +34,66 @@ interface TrustchexProps {
|
|
|
32
34
|
onError?: (error: string) => void;
|
|
33
35
|
}
|
|
34
36
|
|
|
35
|
-
const
|
|
37
|
+
const DEFAULT_BRANDING: TrustchexBranding = {
|
|
38
|
+
logoUrl: '',
|
|
39
|
+
primaryColor: '#000000',
|
|
40
|
+
secondaryColor: '#CCCCCC',
|
|
41
|
+
tertiaryColor: '#FF0000',
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const Trustchex: React.FC<TrustchexProps> = ({
|
|
36
45
|
baseUrl: propBaseUrl,
|
|
37
46
|
sessionId: propSessionId,
|
|
38
47
|
branding: propBranding,
|
|
39
48
|
locale: propLocale,
|
|
40
49
|
onCompleted,
|
|
41
50
|
onError,
|
|
42
|
-
}
|
|
43
|
-
const [baseUrl, setBaseUrl] =
|
|
44
|
-
const [sessionId, setSessionId] =
|
|
45
|
-
const [
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
}) => {
|
|
52
|
+
const [baseUrl, setBaseUrl] = useState<string | null>(null);
|
|
53
|
+
const [sessionId, setSessionId] = useState<string | null>(null);
|
|
54
|
+
const [locale, setLocale] = useState(propLocale || i18n.language);
|
|
55
|
+
|
|
56
|
+
const branding = useMemo(
|
|
57
|
+
() => ({
|
|
58
|
+
...DEFAULT_BRANDING,
|
|
59
|
+
...propBranding,
|
|
60
|
+
}),
|
|
61
|
+
[propBranding]
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
const theme = useMemo(
|
|
65
|
+
() => ({
|
|
66
|
+
...MD3LightTheme,
|
|
67
|
+
colors: {
|
|
68
|
+
...MD3LightTheme.colors,
|
|
69
|
+
primary: branding.primaryColor,
|
|
70
|
+
secondary: branding.secondaryColor,
|
|
71
|
+
tertiary: branding.tertiaryColor,
|
|
72
|
+
},
|
|
73
|
+
}),
|
|
74
|
+
[branding]
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
const contextValue = useMemo(
|
|
78
|
+
() => ({
|
|
79
|
+
isDemoSession: false,
|
|
80
|
+
baseUrl,
|
|
81
|
+
locale,
|
|
82
|
+
branding,
|
|
83
|
+
identificationInfo: {
|
|
84
|
+
sessionId,
|
|
85
|
+
identificationId: '',
|
|
86
|
+
consent: {
|
|
87
|
+
contractIds: [],
|
|
88
|
+
deviceInfo: '',
|
|
89
|
+
},
|
|
90
|
+
locale: propLocale || i18n.language,
|
|
91
|
+
},
|
|
92
|
+
onCompleted,
|
|
93
|
+
onError,
|
|
94
|
+
}),
|
|
95
|
+
[baseUrl, locale, branding, sessionId, propLocale, onCompleted, onError]
|
|
96
|
+
);
|
|
53
97
|
|
|
54
98
|
useEffect(() => {
|
|
55
99
|
initializeTTS();
|
|
@@ -74,92 +118,47 @@ const Trustchex = ({
|
|
|
74
118
|
}
|
|
75
119
|
}, [propLocale]);
|
|
76
120
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}, [propBranding]);
|
|
121
|
+
if (!baseUrl) {
|
|
122
|
+
return (
|
|
123
|
+
<View style={styles.loadingContainer}>
|
|
124
|
+
<ActivityIndicator size="large" color={branding.primaryColor} />
|
|
125
|
+
</View>
|
|
126
|
+
);
|
|
127
|
+
}
|
|
85
128
|
|
|
86
129
|
return (
|
|
87
|
-
<PaperProvider
|
|
88
|
-
|
|
89
|
-
...MD3LightTheme,
|
|
90
|
-
colors: {
|
|
91
|
-
...MD3LightTheme.colors,
|
|
92
|
-
primary: branding.primaryColor,
|
|
93
|
-
secondary: branding.secondaryColor,
|
|
94
|
-
tertiary: branding.tertiaryColor,
|
|
95
|
-
},
|
|
96
|
-
}}
|
|
97
|
-
>
|
|
98
|
-
<AppContext.Provider
|
|
99
|
-
value={{
|
|
100
|
-
isDemoSession: false,
|
|
101
|
-
baseUrl,
|
|
102
|
-
locale,
|
|
103
|
-
branding: {
|
|
104
|
-
primaryColor: branding.primaryColor,
|
|
105
|
-
secondaryColor: branding.secondaryColor,
|
|
106
|
-
tertiaryColor: branding.tertiaryColor,
|
|
107
|
-
logoUrl: branding.logoUrl,
|
|
108
|
-
},
|
|
109
|
-
identificationInfo: {
|
|
110
|
-
sessionId: sessionId,
|
|
111
|
-
identificationId: '',
|
|
112
|
-
consent: {
|
|
113
|
-
contractIds: [],
|
|
114
|
-
deviceInfo: '',
|
|
115
|
-
},
|
|
116
|
-
locale: propLocale || i18n.language,
|
|
117
|
-
},
|
|
118
|
-
onCompleted,
|
|
119
|
-
onError,
|
|
120
|
-
}}
|
|
121
|
-
>
|
|
130
|
+
<PaperProvider theme={theme}>
|
|
131
|
+
<AppContext.Provider value={contextValue}>
|
|
122
132
|
<NavigationContainer>
|
|
123
133
|
<Stack.Navigator
|
|
124
|
-
initialRouteName="VerificationSessionCheckScreen"
|
|
125
134
|
id={undefined}
|
|
135
|
+
initialRouteName="VerificationSessionCheckScreen"
|
|
136
|
+
screenOptions={{ headerShown: false }}
|
|
126
137
|
>
|
|
127
138
|
<Stack.Screen
|
|
128
139
|
name="VerificationSessionCheckScreen"
|
|
129
140
|
component={VerificationSessionCheckScreen}
|
|
130
|
-
options={{ headerShown: false }}
|
|
131
141
|
/>
|
|
132
142
|
<Stack.Screen
|
|
133
143
|
name="ContractAcceptanceScreen"
|
|
134
144
|
component={ContractAcceptanceScreen}
|
|
135
|
-
options={{ headerShown: false }}
|
|
136
145
|
/>
|
|
137
146
|
<Stack.Screen
|
|
138
147
|
name="IdentityDocumentScanningScreen"
|
|
139
148
|
component={IdentityDocumentScanningScreen}
|
|
140
|
-
options={{ headerShown: false }}
|
|
141
149
|
/>
|
|
142
150
|
<Stack.Screen
|
|
143
151
|
name="IdentityDocumentEIDScanningScreen"
|
|
144
152
|
component={IdentityDocumentEIDScanningScreen}
|
|
145
|
-
options={{ headerShown: false }}
|
|
146
153
|
/>
|
|
147
154
|
<Stack.Screen
|
|
148
155
|
name="LivenessDetectionScreen"
|
|
149
156
|
component={LivenessDetectionScreen}
|
|
150
|
-
options={{ headerShown: false }}
|
|
151
|
-
/>
|
|
152
|
-
<Stack.Screen
|
|
153
|
-
name="ResultScreen"
|
|
154
|
-
component={ResultScreen}
|
|
155
|
-
options={{ headerShown: false }}
|
|
156
157
|
/>
|
|
158
|
+
<Stack.Screen name="ResultScreen" component={ResultScreen} />
|
|
157
159
|
<Stack.Screen
|
|
158
160
|
name="QrCodeScanningScreen"
|
|
159
161
|
component={QrCodeScanningScreen}
|
|
160
|
-
options={{
|
|
161
|
-
headerShown: false,
|
|
162
|
-
}}
|
|
163
162
|
/>
|
|
164
163
|
</Stack.Navigator>
|
|
165
164
|
</NavigationContainer>
|
|
@@ -168,4 +167,13 @@ const Trustchex = ({
|
|
|
168
167
|
);
|
|
169
168
|
};
|
|
170
169
|
|
|
170
|
+
const styles = StyleSheet.create({
|
|
171
|
+
loadingContainer: {
|
|
172
|
+
flex: 1,
|
|
173
|
+
justifyContent: 'center',
|
|
174
|
+
alignItems: 'center',
|
|
175
|
+
backgroundColor: 'white',
|
|
176
|
+
},
|
|
177
|
+
});
|
|
178
|
+
|
|
171
179
|
export default Trustchex;
|