@trustchex/react-native-sdk 1.163.10 → 1.164.2
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/typescript/src/Shared/EIDReader/tlv/tlvOutputStream.d.ts +2 -2
- package/lib/typescript/src/Shared/EIDReader/tlv/tlvOutputStream.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
|
@@ -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
|
}
|
|
@@ -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"}
|
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
|
}
|