@toothpic.eu/react-native-toothpic-sdk 1.0.7 → 1.0.8
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/ToothpicSdk.podspec
CHANGED
package/android/build.gradle
CHANGED
|
@@ -5,14 +5,6 @@ import com.facebook.react.bridge.Arguments
|
|
|
5
5
|
import com.facebook.react.bridge.Promise
|
|
6
6
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
7
7
|
import com.facebook.react.bridge.ReadableArray
|
|
8
|
-
import com.toothpiclibrary.Error
|
|
9
|
-
import com.toothpiclibrary.GenerateCallback
|
|
10
|
-
import com.toothpiclibrary.GenerationData
|
|
11
|
-
import com.toothpiclibrary.ShootParameters
|
|
12
|
-
import com.toothpiclibrary.SignCallback
|
|
13
|
-
import com.toothpiclibrary.SignatureData
|
|
14
|
-
import com.toothpiclibrary.State
|
|
15
|
-
import com.toothpiclibrary.ToothPicLibrary
|
|
16
8
|
|
|
17
9
|
class ToothpicSdkModule(reactContext: ReactApplicationContext) :
|
|
18
10
|
NativeToothpicSdkSpec(reactContext) {
|
package/package.json
CHANGED
package/src/index.tsx
CHANGED
|
@@ -1,105 +1,61 @@
|
|
|
1
|
-
import { Platform } from 'react-native';
|
|
2
1
|
import { ToothpicSdk } from './NativeToothpicSdk';
|
|
3
2
|
import { ErrorCodes, GenerationData, KeyType, SignatureData, State, ToothPicError } from './types';
|
|
4
3
|
|
|
5
4
|
async function generateCredential(premiumService: boolean, premiumUser: boolean, verifyGeneration: boolean): Promise<GenerationData> {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
return parseGenerationData(map)
|
|
9
|
-
}
|
|
10
|
-
catch (error: any) {
|
|
11
|
-
throw new ToothPicError(error)
|
|
12
|
-
}
|
|
5
|
+
|
|
6
|
+
return parseGenerationData()
|
|
13
7
|
}
|
|
8
|
+
|
|
14
9
|
async function signWithCredential(keyID: string, messageToSign: Uint8Array): Promise<SignatureData> {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return parseSignatureData(map)
|
|
18
|
-
}
|
|
19
|
-
catch (error: any) {
|
|
20
|
-
throw new ToothPicError(error)
|
|
21
|
-
}
|
|
10
|
+
|
|
11
|
+
return parseSignatureData()
|
|
22
12
|
}
|
|
23
13
|
|
|
24
14
|
function getVersion(): Promise<string> {
|
|
25
|
-
return
|
|
15
|
+
return Promise.resolve("");
|
|
26
16
|
}
|
|
27
17
|
|
|
28
|
-
|
|
29
18
|
async function getKeyType(keyID: string): Promise<KeyType> {
|
|
30
|
-
return
|
|
19
|
+
return Promise.resolve(KeyType.TOOTHPIC);
|
|
31
20
|
}
|
|
32
21
|
|
|
33
|
-
|
|
34
|
-
return
|
|
22
|
+
function getPublicKey(keyID: string): Promise<Uint8Array> {
|
|
23
|
+
return Promise.resolve(new Uint8Array());
|
|
35
24
|
}
|
|
36
25
|
|
|
37
26
|
function getKeys(): Promise<Array<string>> {
|
|
38
|
-
return
|
|
27
|
+
return Promise.resolve([]);
|
|
39
28
|
}
|
|
40
29
|
|
|
41
30
|
function isPremiumSupported(): Promise<boolean> {
|
|
42
|
-
|
|
43
|
-
return Promise.resolve(true)
|
|
44
|
-
}
|
|
45
|
-
return ToothpicSdk.isPremiumSupported()
|
|
31
|
+
return Promise.resolve(false);
|
|
46
32
|
}
|
|
47
33
|
|
|
48
34
|
function deleteKey(keyID: string): Promise<boolean> {
|
|
49
|
-
return
|
|
35
|
+
return Promise.resolve(true);
|
|
50
36
|
}
|
|
51
37
|
|
|
52
38
|
function deleteAllKeys(): void {
|
|
53
|
-
|
|
39
|
+
|
|
54
40
|
}
|
|
55
41
|
|
|
56
|
-
function parseGenerationData(
|
|
42
|
+
function parseGenerationData(): GenerationData {
|
|
57
43
|
return {
|
|
58
|
-
keyID:
|
|
59
|
-
publicKey:
|
|
60
|
-
certificate:
|
|
61
|
-
exportedCredential:
|
|
62
|
-
|
|
63
|
-
: undefined,
|
|
64
|
-
shootParameters: json.shootParameters,
|
|
44
|
+
keyID: "",
|
|
45
|
+
publicKey: new Uint8Array(),
|
|
46
|
+
certificate: new Uint8Array(),
|
|
47
|
+
exportedCredential: undefined,
|
|
48
|
+
shootParameters: "",
|
|
65
49
|
};
|
|
66
50
|
}
|
|
67
51
|
|
|
68
|
-
function parseSignatureData(
|
|
52
|
+
function parseSignatureData(): SignatureData {
|
|
69
53
|
return {
|
|
70
|
-
signature:
|
|
71
|
-
shootParameters:
|
|
54
|
+
signature: new Uint8Array(),
|
|
55
|
+
shootParameters: ""
|
|
72
56
|
};
|
|
73
57
|
}
|
|
74
58
|
|
|
75
|
-
|
|
76
|
-
function stringToKeyType(keyType: string): KeyType {
|
|
77
|
-
return KeyType[keyType as keyof typeof KeyType];
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
function uint8ArrayToHex(buffer: Uint8Array): string {
|
|
81
|
-
return [...new Uint8Array(buffer)]
|
|
82
|
-
.map((x) => x.toString(16).padStart(2, "0"))
|
|
83
|
-
.join("");
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
function hexToUint8Array(hexString: string): Uint8Array {
|
|
88
|
-
hexString = hexString.replace(/\s+/g, '');
|
|
89
|
-
|
|
90
|
-
if (hexString.length % 2 !== 0) {
|
|
91
|
-
throw new Error("Hex string must have an even number of characters.");
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
const uint8Array = new Uint8Array(hexString.length / 2);
|
|
95
|
-
|
|
96
|
-
for (let i = 0; i < hexString.length; i += 2) {
|
|
97
|
-
uint8Array[i / 2] = parseInt(hexString.slice(i, i + 2), 16);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
return uint8Array;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
59
|
const onProgress = ToothpicSdk.onProgress
|
|
104
60
|
|
|
105
61
|
export const ToothPicSDK = {
|
package/src/types.ts
CHANGED
|
@@ -28,7 +28,6 @@ export enum ErrorCodes {
|
|
|
28
28
|
ERROR_EVALUATION_EXPIRED = "ERROR_EVALUATION_EXPIRED",
|
|
29
29
|
ERROR_INSUFFICIENT_LUMINOSITY = "ERROR_INSUFFICIENT_LUMINOSITY",
|
|
30
30
|
ERROR_BAD_CREDENTIAL = "ERROR_BAD_CREDENTIAL",
|
|
31
|
-
ERROR_DECRYPTION = "ERROR_DECRYPTION",
|
|
32
31
|
ERROR_GENERIC = "ERROR_GENERIC"
|
|
33
32
|
}
|
|
34
33
|
|
|
@@ -52,10 +51,6 @@ export type State =
|
|
|
52
51
|
|
|
53
52
|
export enum KeyType {
|
|
54
53
|
TOOTHPIC = "TOOTHPIC",
|
|
55
|
-
KEY_STORE = "KEY_STORE",
|
|
56
|
-
SECURE_ENCLAVE = "SECURE_ENCLAVE",
|
|
57
|
-
COMPATIBILITY = "COMPATIBILITY",
|
|
58
|
-
KEY_NOT_FOUND = "KEY_NOT_FOUND"
|
|
59
54
|
}
|
|
60
55
|
|
|
61
56
|
export class ToothPicError extends Error {
|