@doko/react-native-yubikit 0.0.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/LICENSE +20 -0
- package/README.md +126 -0
- package/RNYubikit.podspec +22 -0
- package/android/build.gradle +63 -0
- package/android/src/main/AndroidManifest.xml +9 -0
- package/android/src/main/java/com/yubikit/YubiKitManagerHolder.kt +330 -0
- package/android/src/main/java/com/yubikit/YubikitCoreModule.kt +142 -0
- package/android/src/main/java/com/yubikit/YubikitFidoModule.kt +418 -0
- package/android/src/main/java/com/yubikit/YubikitManagementModule.kt +132 -0
- package/android/src/main/java/com/yubikit/YubikitOathModule.kt +224 -0
- package/android/src/main/java/com/yubikit/YubikitOpenPgpModule.kt +317 -0
- package/android/src/main/java/com/yubikit/YubikitPackage.kt +44 -0
- package/android/src/main/java/com/yubikit/YubikitPivModule.kt +310 -0
- package/android/src/main/java/com/yubikit/YubikitSupportModule.kt +108 -0
- package/android/src/main/java/com/yubikit/YubikitYubiOtpModule.kt +248 -0
- package/android/src/main/java/com/yubikit/utils/YubikitUtils.kt +321 -0
- package/ios/YubikitCore.h +5 -0
- package/ios/YubikitCore.mm +101 -0
- package/ios/YubikitDeviceInfoHelper.h +13 -0
- package/ios/YubikitDeviceInfoHelper.mm +110 -0
- package/ios/YubikitFido.h +5 -0
- package/ios/YubikitFido.mm +373 -0
- package/ios/YubikitManagement.h +5 -0
- package/ios/YubikitManagement.mm +153 -0
- package/ios/YubikitManager.h +27 -0
- package/ios/YubikitManager.m +169 -0
- package/ios/YubikitOath.h +5 -0
- package/ios/YubikitOath.mm +583 -0
- package/ios/YubikitOpenPgp.h +5 -0
- package/ios/YubikitOpenPgp.mm +210 -0
- package/ios/YubikitPiv.h +5 -0
- package/ios/YubikitPiv.mm +813 -0
- package/ios/YubikitSupport.h +5 -0
- package/ios/YubikitSupport.mm +58 -0
- package/ios/YubikitYubiOtp.h +5 -0
- package/ios/YubikitYubiOtp.mm +120 -0
- package/lib/module/core.js +34 -0
- package/lib/module/core.js.map +1 -0
- package/lib/module/fido.js +40 -0
- package/lib/module/fido.js.map +1 -0
- package/lib/module/hooks/index.js +5 -0
- package/lib/module/hooks/index.js.map +1 -0
- package/lib/module/hooks/use-yubikey.js +12 -0
- package/lib/module/hooks/use-yubikey.js.map +1 -0
- package/lib/module/hooks/yubikey-provider.js +85 -0
- package/lib/module/hooks/yubikey-provider.js.map +1 -0
- package/lib/module/index.js +12 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/management.js +17 -0
- package/lib/module/management.js.map +1 -0
- package/lib/module/oath.js +53 -0
- package/lib/module/oath.js.map +1 -0
- package/lib/module/openpgp.js +89 -0
- package/lib/module/openpgp.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/piv.js +71 -0
- package/lib/module/piv.js.map +1 -0
- package/lib/module/specs/NativeYubikitCore.js +10 -0
- package/lib/module/specs/NativeYubikitCore.js.map +1 -0
- package/lib/module/specs/NativeYubikitFido.js +5 -0
- package/lib/module/specs/NativeYubikitFido.js.map +1 -0
- package/lib/module/specs/NativeYubikitManagement.js +5 -0
- package/lib/module/specs/NativeYubikitManagement.js.map +1 -0
- package/lib/module/specs/NativeYubikitOath.js +5 -0
- package/lib/module/specs/NativeYubikitOath.js.map +1 -0
- package/lib/module/specs/NativeYubikitOpenPgp.js +5 -0
- package/lib/module/specs/NativeYubikitOpenPgp.js.map +1 -0
- package/lib/module/specs/NativeYubikitPiv.js +5 -0
- package/lib/module/specs/NativeYubikitPiv.js.map +1 -0
- package/lib/module/specs/NativeYubikitSupport.js +5 -0
- package/lib/module/specs/NativeYubikitSupport.js.map +1 -0
- package/lib/module/specs/NativeYubikitYubiOtp.js +5 -0
- package/lib/module/specs/NativeYubikitYubiOtp.js.map +1 -0
- package/lib/module/support.js +11 -0
- package/lib/module/support.js.map +1 -0
- package/lib/module/types.js +2 -0
- package/lib/module/types.js.map +1 -0
- package/lib/module/yubiotp.js +32 -0
- package/lib/module/yubiotp.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/core.d.ts +14 -0
- package/lib/typescript/src/core.d.ts.map +1 -0
- package/lib/typescript/src/fido.d.ts +24 -0
- package/lib/typescript/src/fido.d.ts.map +1 -0
- package/lib/typescript/src/hooks/index.d.ts +3 -0
- package/lib/typescript/src/hooks/index.d.ts.map +1 -0
- package/lib/typescript/src/hooks/use-yubikey.d.ts +3 -0
- package/lib/typescript/src/hooks/use-yubikey.d.ts.map +1 -0
- package/lib/typescript/src/hooks/yubikey-provider.d.ts +23 -0
- package/lib/typescript/src/hooks/yubikey-provider.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +10 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/management.d.ts +8 -0
- package/lib/typescript/src/management.d.ts.map +1 -0
- package/lib/typescript/src/oath.d.ts +20 -0
- package/lib/typescript/src/oath.d.ts.map +1 -0
- package/lib/typescript/src/openpgp.d.ts +35 -0
- package/lib/typescript/src/openpgp.d.ts.map +1 -0
- package/lib/typescript/src/piv.d.ts +26 -0
- package/lib/typescript/src/piv.d.ts.map +1 -0
- package/lib/typescript/src/specs/NativeYubikitCore.d.ts +49 -0
- package/lib/typescript/src/specs/NativeYubikitCore.d.ts.map +1 -0
- package/lib/typescript/src/specs/NativeYubikitFido.d.ts +121 -0
- package/lib/typescript/src/specs/NativeYubikitFido.d.ts.map +1 -0
- package/lib/typescript/src/specs/NativeYubikitManagement.d.ts +53 -0
- package/lib/typescript/src/specs/NativeYubikitManagement.d.ts.map +1 -0
- package/lib/typescript/src/specs/NativeYubikitOath.d.ts +70 -0
- package/lib/typescript/src/specs/NativeYubikitOath.d.ts.map +1 -0
- package/lib/typescript/src/specs/NativeYubikitOpenPgp.d.ts +53 -0
- package/lib/typescript/src/specs/NativeYubikitOpenPgp.d.ts.map +1 -0
- package/lib/typescript/src/specs/NativeYubikitPiv.d.ts +47 -0
- package/lib/typescript/src/specs/NativeYubikitPiv.d.ts.map +1 -0
- package/lib/typescript/src/specs/NativeYubikitSupport.d.ts +49 -0
- package/lib/typescript/src/specs/NativeYubikitSupport.d.ts.map +1 -0
- package/lib/typescript/src/specs/NativeYubikitYubiOtp.d.ts +45 -0
- package/lib/typescript/src/specs/NativeYubikitYubiOtp.d.ts.map +1 -0
- package/lib/typescript/src/support.d.ts +6 -0
- package/lib/typescript/src/support.d.ts.map +1 -0
- package/lib/typescript/src/types.d.ts +293 -0
- package/lib/typescript/src/types.d.ts.map +1 -0
- package/lib/typescript/src/yubiotp.d.ts +13 -0
- package/lib/typescript/src/yubiotp.d.ts.map +1 -0
- package/package.json +181 -0
- package/src/core.ts +58 -0
- package/src/fido.ts +112 -0
- package/src/hooks/index.tsx +2 -0
- package/src/hooks/use-yubikey.tsx +10 -0
- package/src/hooks/yubikey-provider.tsx +146 -0
- package/src/index.tsx +10 -0
- package/src/management.ts +44 -0
- package/src/oath.ts +134 -0
- package/src/openpgp.ts +220 -0
- package/src/piv.ts +193 -0
- package/src/specs/NativeYubikitCore.ts +68 -0
- package/src/specs/NativeYubikitFido.ts +149 -0
- package/src/specs/NativeYubikitManagement.ts +78 -0
- package/src/specs/NativeYubikitOath.ts +110 -0
- package/src/specs/NativeYubikitOpenPgp.ts +148 -0
- package/src/specs/NativeYubikitPiv.ts +108 -0
- package/src/specs/NativeYubikitSupport.ts +61 -0
- package/src/specs/NativeYubikitYubiOtp.ts +82 -0
- package/src/support.ts +18 -0
- package/src/types.ts +404 -0
- package/src/yubiotp.ts +96 -0
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { TurboModuleRegistry, type TurboModule } from 'react-native';
|
|
2
|
+
|
|
3
|
+
interface Version {
|
|
4
|
+
major: number;
|
|
5
|
+
minor: number;
|
|
6
|
+
micro: number;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
interface OpenPgpAlgorithmAttributes {
|
|
10
|
+
keyRef: 'SIG' | 'DEC' | 'AUT' | 'ATT';
|
|
11
|
+
algorithm: string;
|
|
12
|
+
curve?:
|
|
13
|
+
| 'SECP256R1'
|
|
14
|
+
| 'SECP256K1'
|
|
15
|
+
| 'SECP384R1'
|
|
16
|
+
| 'SECP521R1'
|
|
17
|
+
| 'BrainpoolP256R1'
|
|
18
|
+
| 'BrainpoolP384R1'
|
|
19
|
+
| 'BrainpoolP512R1'
|
|
20
|
+
| 'X25519'
|
|
21
|
+
| 'Ed25519';
|
|
22
|
+
keySize?: number;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
interface OpenPgpApplicationRelatedData {
|
|
26
|
+
aid: string;
|
|
27
|
+
historical: string;
|
|
28
|
+
signatureCounter: number;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface Spec extends TurboModule {
|
|
32
|
+
getVersion(deviceHandle: string): Promise<Version>;
|
|
33
|
+
getApplicationRelatedData(
|
|
34
|
+
deviceHandle: string
|
|
35
|
+
): Promise<OpenPgpApplicationRelatedData>;
|
|
36
|
+
|
|
37
|
+
verifyUserPin(
|
|
38
|
+
deviceHandle: string,
|
|
39
|
+
pin: string,
|
|
40
|
+
extended?: boolean
|
|
41
|
+
): Promise<void>;
|
|
42
|
+
verifyAdminPin(deviceHandle: string, pin: string): Promise<void>;
|
|
43
|
+
unverifyUserPin(deviceHandle: string): Promise<void>;
|
|
44
|
+
unverifyAdminPin(deviceHandle: string): Promise<void>;
|
|
45
|
+
|
|
46
|
+
getSignatureCounter(deviceHandle: string): Promise<number>;
|
|
47
|
+
getChallenge(deviceHandle: string, length: number): Promise<string>;
|
|
48
|
+
|
|
49
|
+
reset(deviceHandle: string): Promise<void>;
|
|
50
|
+
|
|
51
|
+
setPinAttempts(
|
|
52
|
+
deviceHandle: string,
|
|
53
|
+
userAttempts: number,
|
|
54
|
+
resetAttempts: number,
|
|
55
|
+
adminAttempts: number
|
|
56
|
+
): Promise<void>;
|
|
57
|
+
|
|
58
|
+
changeUserPin(
|
|
59
|
+
deviceHandle: string,
|
|
60
|
+
pin: string,
|
|
61
|
+
newPin: string
|
|
62
|
+
): Promise<void>;
|
|
63
|
+
changeAdminPin(
|
|
64
|
+
deviceHandle: string,
|
|
65
|
+
pin: string,
|
|
66
|
+
newPin: string
|
|
67
|
+
): Promise<void>;
|
|
68
|
+
|
|
69
|
+
setSignaturePinPolicy(
|
|
70
|
+
deviceHandle: string,
|
|
71
|
+
policy: 'ALWAYS' | 'ONCE'
|
|
72
|
+
): Promise<void>;
|
|
73
|
+
|
|
74
|
+
getUif(
|
|
75
|
+
deviceHandle: string,
|
|
76
|
+
keyRef: 'SIG' | 'DEC' | 'AUT' | 'ATT'
|
|
77
|
+
): Promise<'OFF' | 'ON' | 'FIXED' | 'CACHED' | 'CACHED_FIXED'>;
|
|
78
|
+
setUif(
|
|
79
|
+
deviceHandle: string,
|
|
80
|
+
keyRef: 'SIG' | 'DEC' | 'AUT' | 'ATT',
|
|
81
|
+
uif: 'OFF' | 'ON' | 'FIXED' | 'CACHED' | 'CACHED_FIXED'
|
|
82
|
+
): Promise<void>;
|
|
83
|
+
|
|
84
|
+
getAlgorithmInformation(deviceHandle: string): Promise<
|
|
85
|
+
Array<{
|
|
86
|
+
keyRef: 'SIG' | 'DEC' | 'AUT' | 'ATT';
|
|
87
|
+
attributes: OpenPgpAlgorithmAttributes[];
|
|
88
|
+
}>
|
|
89
|
+
>;
|
|
90
|
+
|
|
91
|
+
setAlgorithmAttributes(
|
|
92
|
+
deviceHandle: string,
|
|
93
|
+
keyRef: 'SIG' | 'DEC' | 'AUT' | 'ATT',
|
|
94
|
+
attributes: OpenPgpAlgorithmAttributes
|
|
95
|
+
): Promise<void>;
|
|
96
|
+
|
|
97
|
+
getCertificate(
|
|
98
|
+
deviceHandle: string,
|
|
99
|
+
keyRef: 'SIG' | 'DEC' | 'AUT' | 'ATT'
|
|
100
|
+
): Promise<string>;
|
|
101
|
+
putCertificate(
|
|
102
|
+
deviceHandle: string,
|
|
103
|
+
keyRef: 'SIG' | 'DEC' | 'AUT' | 'ATT',
|
|
104
|
+
certificate: string
|
|
105
|
+
): Promise<void>;
|
|
106
|
+
deleteCertificate(
|
|
107
|
+
deviceHandle: string,
|
|
108
|
+
keyRef: 'SIG' | 'DEC' | 'AUT' | 'ATT'
|
|
109
|
+
): Promise<void>;
|
|
110
|
+
|
|
111
|
+
generateRsaKey(
|
|
112
|
+
deviceHandle: string,
|
|
113
|
+
keyRef: 'SIG' | 'DEC' | 'AUT' | 'ATT',
|
|
114
|
+
keySize: number
|
|
115
|
+
): Promise<string>;
|
|
116
|
+
generateEcKey(
|
|
117
|
+
deviceHandle: string,
|
|
118
|
+
keyRef: 'SIG' | 'DEC' | 'AUT' | 'ATT',
|
|
119
|
+
curve:
|
|
120
|
+
| 'SECP256R1'
|
|
121
|
+
| 'SECP256K1'
|
|
122
|
+
| 'SECP384R1'
|
|
123
|
+
| 'SECP521R1'
|
|
124
|
+
| 'BrainpoolP256R1'
|
|
125
|
+
| 'BrainpoolP384R1'
|
|
126
|
+
| 'BrainpoolP512R1'
|
|
127
|
+
| 'X25519'
|
|
128
|
+
| 'Ed25519'
|
|
129
|
+
): Promise<string>;
|
|
130
|
+
getPublicKey(
|
|
131
|
+
deviceHandle: string,
|
|
132
|
+
keyRef: 'SIG' | 'DEC' | 'AUT' | 'ATT'
|
|
133
|
+
): Promise<string>;
|
|
134
|
+
deleteKey(
|
|
135
|
+
deviceHandle: string,
|
|
136
|
+
keyRef: 'SIG' | 'DEC' | 'AUT' | 'ATT'
|
|
137
|
+
): Promise<void>;
|
|
138
|
+
|
|
139
|
+
sign(deviceHandle: string, payload: string): Promise<string>;
|
|
140
|
+
decrypt(deviceHandle: string, payload: string): Promise<string>;
|
|
141
|
+
authenticate(deviceHandle: string, payload: string): Promise<string>;
|
|
142
|
+
attestKey(
|
|
143
|
+
deviceHandle: string,
|
|
144
|
+
keyRef: 'SIG' | 'DEC' | 'AUT' | 'ATT'
|
|
145
|
+
): Promise<string>;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export default TurboModuleRegistry.getEnforcing<Spec>('YubikitOpenPgp');
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { TurboModuleRegistry, type TurboModule } from 'react-native';
|
|
2
|
+
|
|
3
|
+
interface PivPinMetadata {
|
|
4
|
+
attemptsRemaining: number;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
interface PivManagementKeyMetadata {
|
|
8
|
+
keyType: 'TDES' | 'AES128' | 'AES192' | 'AES256';
|
|
9
|
+
defaultValue: boolean;
|
|
10
|
+
touchRequired: boolean;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
interface PivSlotMetadata {
|
|
14
|
+
keyType:
|
|
15
|
+
| 'RSA1024'
|
|
16
|
+
| 'RSA2048'
|
|
17
|
+
| 'RSA3072'
|
|
18
|
+
| 'RSA4096'
|
|
19
|
+
| 'ECCP256'
|
|
20
|
+
| 'ECCP384'
|
|
21
|
+
| 'ED25519'
|
|
22
|
+
| 'X25519';
|
|
23
|
+
pinPolicy:
|
|
24
|
+
| 'DEFAULT'
|
|
25
|
+
| 'NEVER'
|
|
26
|
+
| 'ONCE'
|
|
27
|
+
| 'ALWAYS'
|
|
28
|
+
| 'MATCH_ONCE'
|
|
29
|
+
| 'MATCH_ALWAYS';
|
|
30
|
+
touchPolicy: 'DEFAULT' | 'NEVER' | 'ALWAYS' | 'CACHED';
|
|
31
|
+
generated: boolean;
|
|
32
|
+
publicKey?: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
interface PivBioMetadata {
|
|
36
|
+
attemptsRemaining?: number;
|
|
37
|
+
temporaryPin?: boolean;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface Spec extends TurboModule {
|
|
41
|
+
reset(deviceHandle: string): Promise<void>;
|
|
42
|
+
getSerialNumber(deviceHandle: string): Promise<number>;
|
|
43
|
+
|
|
44
|
+
authenticate(deviceHandle: string, managementKey: string): Promise<void>;
|
|
45
|
+
setManagementKey(
|
|
46
|
+
deviceHandle: string,
|
|
47
|
+
keyType: string,
|
|
48
|
+
managementKey: string,
|
|
49
|
+
requireTouch: boolean
|
|
50
|
+
): Promise<void>;
|
|
51
|
+
|
|
52
|
+
verifyPin(deviceHandle: string, pin: string): Promise<void>;
|
|
53
|
+
getPinAttempts(deviceHandle: string): Promise<number>;
|
|
54
|
+
changePin(
|
|
55
|
+
deviceHandle: string,
|
|
56
|
+
oldPin: string,
|
|
57
|
+
newPin: string
|
|
58
|
+
): Promise<void>;
|
|
59
|
+
changePuk(
|
|
60
|
+
deviceHandle: string,
|
|
61
|
+
oldPuk: string,
|
|
62
|
+
newPuk: string
|
|
63
|
+
): Promise<void>;
|
|
64
|
+
unblockPin(deviceHandle: string, puk: string, newPin: string): Promise<void>;
|
|
65
|
+
setPinAttempts(
|
|
66
|
+
deviceHandle: string,
|
|
67
|
+
pinAttempts: number,
|
|
68
|
+
pukAttempts: number
|
|
69
|
+
): Promise<void>;
|
|
70
|
+
|
|
71
|
+
getPinMetadata(deviceHandle: string): Promise<PivPinMetadata>;
|
|
72
|
+
getPukMetadata(deviceHandle: string): Promise<PivPinMetadata>;
|
|
73
|
+
getManagementKeyMetadata(
|
|
74
|
+
deviceHandle: string
|
|
75
|
+
): Promise<PivManagementKeyMetadata>;
|
|
76
|
+
getSlotMetadata(deviceHandle: string, slot: string): Promise<PivSlotMetadata>;
|
|
77
|
+
|
|
78
|
+
getCertificate(deviceHandle: string, slot: string): Promise<string>;
|
|
79
|
+
putCertificate(
|
|
80
|
+
deviceHandle: string,
|
|
81
|
+
slot: string,
|
|
82
|
+
certificate: string,
|
|
83
|
+
compress?: boolean
|
|
84
|
+
): Promise<void>;
|
|
85
|
+
deleteCertificate(deviceHandle: string, slot: string): Promise<void>;
|
|
86
|
+
attestKey(deviceHandle: string, slot: string): Promise<string>;
|
|
87
|
+
|
|
88
|
+
generateKey(
|
|
89
|
+
deviceHandle: string,
|
|
90
|
+
slot: string,
|
|
91
|
+
keyType: string,
|
|
92
|
+
pinPolicy: string,
|
|
93
|
+
touchPolicy: string
|
|
94
|
+
): Promise<string>;
|
|
95
|
+
|
|
96
|
+
deleteKey(deviceHandle: string, slot: string): Promise<void>;
|
|
97
|
+
|
|
98
|
+
rawSignOrDecrypt(
|
|
99
|
+
deviceHandle: string,
|
|
100
|
+
slot: string,
|
|
101
|
+
keyType: string,
|
|
102
|
+
payload: string
|
|
103
|
+
): Promise<string>;
|
|
104
|
+
|
|
105
|
+
getBioMetadata(deviceHandle: string): Promise<PivBioMetadata>;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export default TurboModuleRegistry.getEnforcing<Spec>('YubikitPiv');
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { TurboModuleRegistry, type TurboModule } from 'react-native';
|
|
2
|
+
|
|
3
|
+
interface Version {
|
|
4
|
+
major: number;
|
|
5
|
+
minor: number;
|
|
6
|
+
micro: number;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
interface DeviceConfig {
|
|
10
|
+
enabledCapabilities?: {
|
|
11
|
+
usb?: number;
|
|
12
|
+
nfc?: number;
|
|
13
|
+
};
|
|
14
|
+
autoEjectTimeout?: number;
|
|
15
|
+
challengeResponseTimeout?: number;
|
|
16
|
+
nfcRestricted?: boolean;
|
|
17
|
+
deviceFlags?: number;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
interface DeviceInfo {
|
|
21
|
+
config?: DeviceConfig;
|
|
22
|
+
serialNumber?: number;
|
|
23
|
+
version: Version;
|
|
24
|
+
versionName: string;
|
|
25
|
+
formFactor:
|
|
26
|
+
| 'UNKNOWN'
|
|
27
|
+
| 'USB_A_KEYCHAIN'
|
|
28
|
+
| 'USB_A_NANO'
|
|
29
|
+
| 'USB_C_KEYCHAIN'
|
|
30
|
+
| 'USB_C_NANO'
|
|
31
|
+
| 'USB_C_LIGHTNING'
|
|
32
|
+
| 'USB_A_BIO'
|
|
33
|
+
| 'USB_C_BIO';
|
|
34
|
+
supportedCapabilities: {
|
|
35
|
+
usb?: number;
|
|
36
|
+
nfc?: number;
|
|
37
|
+
};
|
|
38
|
+
hasTransportUsb: boolean;
|
|
39
|
+
hasTransportNfc: boolean;
|
|
40
|
+
isLocked: boolean;
|
|
41
|
+
isFips: boolean;
|
|
42
|
+
isSky: boolean;
|
|
43
|
+
partNumber?: string;
|
|
44
|
+
fipsCapable: number;
|
|
45
|
+
fipsApproved: number;
|
|
46
|
+
pinComplexity: boolean;
|
|
47
|
+
resetBlocked: number;
|
|
48
|
+
fpsVersion?: Version;
|
|
49
|
+
stmVersion?: Version;
|
|
50
|
+
versionQualifier?: string;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface Spec extends TurboModule {
|
|
54
|
+
/** Read DeviceInfo from any supported connection. */
|
|
55
|
+
readInfo(deviceHandle: string, pid?: number): Promise<DeviceInfo>;
|
|
56
|
+
|
|
57
|
+
/** Get a human-readable name for a YubiKey. */
|
|
58
|
+
getName(info: DeviceInfo, keyType?: string): string;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export default TurboModuleRegistry.getEnforcing<Spec>('YubikitSupport');
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { TurboModuleRegistry, type TurboModule } from 'react-native';
|
|
2
|
+
|
|
3
|
+
interface Version {
|
|
4
|
+
major: number;
|
|
5
|
+
minor: number;
|
|
6
|
+
micro: number;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
interface ConfigurationState {
|
|
10
|
+
slot1Configured: boolean;
|
|
11
|
+
slot2Configured: boolean;
|
|
12
|
+
slot1TouchTriggered: boolean;
|
|
13
|
+
slot2TouchTriggered: boolean;
|
|
14
|
+
ledInverted: boolean;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
interface OtpSlotConfiguration {
|
|
18
|
+
type:
|
|
19
|
+
| 'YubiOtp'
|
|
20
|
+
| 'HOTP'
|
|
21
|
+
| 'HmacSha1'
|
|
22
|
+
| 'StaticPassword'
|
|
23
|
+
| 'StaticTicket'
|
|
24
|
+
| 'Update';
|
|
25
|
+
fixed?: string;
|
|
26
|
+
uid?: string;
|
|
27
|
+
key?: string;
|
|
28
|
+
secret?: string;
|
|
29
|
+
scanCodes?: string;
|
|
30
|
+
digits?: number;
|
|
31
|
+
imf?: number;
|
|
32
|
+
requireTouch?: boolean;
|
|
33
|
+
lt64?: boolean;
|
|
34
|
+
appendCr?: boolean;
|
|
35
|
+
serialApiVisible?: boolean;
|
|
36
|
+
serialUsbVisible?: boolean;
|
|
37
|
+
allowUpdate?: boolean;
|
|
38
|
+
dormant?: boolean;
|
|
39
|
+
invertLed?: boolean;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface Spec extends TurboModule {
|
|
43
|
+
getConfigurationState(deviceHandle: string): Promise<ConfigurationState>;
|
|
44
|
+
getVersion(deviceHandle: string): Promise<Version>;
|
|
45
|
+
getSerialNumber(deviceHandle: string): Promise<number>;
|
|
46
|
+
|
|
47
|
+
swapConfigurations(deviceHandle: string): Promise<void>;
|
|
48
|
+
|
|
49
|
+
deleteConfiguration(
|
|
50
|
+
deviceHandle: string,
|
|
51
|
+
slot: 'ONE' | 'TWO',
|
|
52
|
+
currentAccessCode?: string
|
|
53
|
+
): Promise<void>;
|
|
54
|
+
putConfiguration(
|
|
55
|
+
deviceHandle: string,
|
|
56
|
+
slot: 'ONE' | 'TWO',
|
|
57
|
+
configuration: OtpSlotConfiguration,
|
|
58
|
+
accessCode?: string,
|
|
59
|
+
currentAccessCode?: string
|
|
60
|
+
): Promise<void>;
|
|
61
|
+
updateConfiguration(
|
|
62
|
+
deviceHandle: string,
|
|
63
|
+
slot: 'ONE' | 'TWO',
|
|
64
|
+
configuration: OtpSlotConfiguration,
|
|
65
|
+
accessCode?: string,
|
|
66
|
+
currentAccessCode?: string
|
|
67
|
+
): Promise<void>;
|
|
68
|
+
setNdefConfiguration(
|
|
69
|
+
deviceHandle: string,
|
|
70
|
+
slot: 'ONE' | 'TWO',
|
|
71
|
+
uri?: string,
|
|
72
|
+
currentAccessCode?: string
|
|
73
|
+
): Promise<void>;
|
|
74
|
+
|
|
75
|
+
calculateHmacSha1(
|
|
76
|
+
deviceHandle: string,
|
|
77
|
+
slot: 'ONE' | 'TWO',
|
|
78
|
+
challenge: string
|
|
79
|
+
): Promise<string>;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export default TurboModuleRegistry.getEnforcing<Spec>('YubikitYubiOtp');
|
package/src/support.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import NativeYubikitSupport from './specs/NativeYubikitSupport';
|
|
2
|
+
import type { DeviceInfo, YubiKeyType } from './types';
|
|
3
|
+
|
|
4
|
+
export function readInfo(
|
|
5
|
+
deviceHandle: string,
|
|
6
|
+
pid?: number
|
|
7
|
+
): Promise<DeviceInfo> {
|
|
8
|
+
return NativeYubikitSupport.readInfo(
|
|
9
|
+
deviceHandle,
|
|
10
|
+
pid
|
|
11
|
+
) as Promise<DeviceInfo>;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function getName(info: DeviceInfo, keyType?: YubiKeyType): string {
|
|
15
|
+
return NativeYubikitSupport.getName(info, keyType);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export { NativeYubikitSupport };
|