@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
package/src/piv.ts
ADDED
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import NativeYubikitPiv from './specs/NativeYubikitPiv';
|
|
2
|
+
import type {
|
|
3
|
+
Base64String,
|
|
4
|
+
PivBioMetadata,
|
|
5
|
+
PivKeyType,
|
|
6
|
+
PivManagementKeyMetadata,
|
|
7
|
+
PivManagementKeyType,
|
|
8
|
+
PivPinMetadata,
|
|
9
|
+
PivPinPolicy,
|
|
10
|
+
PivSlot,
|
|
11
|
+
PivSlotMetadata,
|
|
12
|
+
PivTouchPolicy,
|
|
13
|
+
} from './types';
|
|
14
|
+
|
|
15
|
+
export function reset(deviceHandle: string): Promise<void> {
|
|
16
|
+
return NativeYubikitPiv.reset(deviceHandle);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function getSerialNumber(deviceHandle: string): Promise<number> {
|
|
20
|
+
return NativeYubikitPiv.getSerialNumber(deviceHandle);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function authenticate(
|
|
24
|
+
deviceHandle: string,
|
|
25
|
+
managementKey: Base64String
|
|
26
|
+
): Promise<void> {
|
|
27
|
+
return NativeYubikitPiv.authenticate(deviceHandle, managementKey);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function setManagementKey(
|
|
31
|
+
deviceHandle: string,
|
|
32
|
+
keyType: PivManagementKeyType,
|
|
33
|
+
managementKey: Base64String,
|
|
34
|
+
requireTouch: boolean
|
|
35
|
+
): Promise<void> {
|
|
36
|
+
return NativeYubikitPiv.setManagementKey(
|
|
37
|
+
deviceHandle,
|
|
38
|
+
keyType,
|
|
39
|
+
managementKey,
|
|
40
|
+
requireTouch
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function verifyPin(deviceHandle: string, pin: string): Promise<void> {
|
|
45
|
+
return NativeYubikitPiv.verifyPin(deviceHandle, pin);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function getPinAttempts(deviceHandle: string): Promise<number> {
|
|
49
|
+
return NativeYubikitPiv.getPinAttempts(deviceHandle);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function changePin(
|
|
53
|
+
deviceHandle: string,
|
|
54
|
+
oldPin: string,
|
|
55
|
+
newPin: string
|
|
56
|
+
): Promise<void> {
|
|
57
|
+
return NativeYubikitPiv.changePin(deviceHandle, oldPin, newPin);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function changePuk(
|
|
61
|
+
deviceHandle: string,
|
|
62
|
+
oldPuk: string,
|
|
63
|
+
newPuk: string
|
|
64
|
+
): Promise<void> {
|
|
65
|
+
return NativeYubikitPiv.changePuk(deviceHandle, oldPuk, newPuk);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export function unblockPin(
|
|
69
|
+
deviceHandle: string,
|
|
70
|
+
puk: string,
|
|
71
|
+
newPin: string
|
|
72
|
+
): Promise<void> {
|
|
73
|
+
return NativeYubikitPiv.unblockPin(deviceHandle, puk, newPin);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export function setPinAttempts(
|
|
77
|
+
deviceHandle: string,
|
|
78
|
+
pinAttempts: number,
|
|
79
|
+
pukAttempts: number
|
|
80
|
+
): Promise<void> {
|
|
81
|
+
return NativeYubikitPiv.setPinAttempts(
|
|
82
|
+
deviceHandle,
|
|
83
|
+
pinAttempts,
|
|
84
|
+
pukAttempts
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export function getPinMetadata(deviceHandle: string): Promise<PivPinMetadata> {
|
|
89
|
+
return NativeYubikitPiv.getPinMetadata(
|
|
90
|
+
deviceHandle
|
|
91
|
+
) as Promise<PivPinMetadata>;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export function getPukMetadata(deviceHandle: string): Promise<PivPinMetadata> {
|
|
95
|
+
return NativeYubikitPiv.getPukMetadata(
|
|
96
|
+
deviceHandle
|
|
97
|
+
) as Promise<PivPinMetadata>;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export function getManagementKeyMetadata(
|
|
101
|
+
deviceHandle: string
|
|
102
|
+
): Promise<PivManagementKeyMetadata> {
|
|
103
|
+
return NativeYubikitPiv.getManagementKeyMetadata(
|
|
104
|
+
deviceHandle
|
|
105
|
+
) as Promise<PivManagementKeyMetadata>;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export function getSlotMetadata(
|
|
109
|
+
deviceHandle: string,
|
|
110
|
+
slot: PivSlot
|
|
111
|
+
): Promise<PivSlotMetadata> {
|
|
112
|
+
return NativeYubikitPiv.getSlotMetadata(
|
|
113
|
+
deviceHandle,
|
|
114
|
+
slot
|
|
115
|
+
) as Promise<PivSlotMetadata>;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export function getCertificate(
|
|
119
|
+
deviceHandle: string,
|
|
120
|
+
slot: PivSlot
|
|
121
|
+
): Promise<Base64String> {
|
|
122
|
+
return NativeYubikitPiv.getCertificate(deviceHandle, slot);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export function putCertificate(
|
|
126
|
+
deviceHandle: string,
|
|
127
|
+
slot: PivSlot,
|
|
128
|
+
certificate: Base64String,
|
|
129
|
+
compress?: boolean
|
|
130
|
+
): Promise<void> {
|
|
131
|
+
return NativeYubikitPiv.putCertificate(
|
|
132
|
+
deviceHandle,
|
|
133
|
+
slot,
|
|
134
|
+
certificate,
|
|
135
|
+
compress
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export function deleteCertificate(
|
|
140
|
+
deviceHandle: string,
|
|
141
|
+
slot: PivSlot
|
|
142
|
+
): Promise<void> {
|
|
143
|
+
return NativeYubikitPiv.deleteCertificate(deviceHandle, slot);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export function attestKey(
|
|
147
|
+
deviceHandle: string,
|
|
148
|
+
slot: PivSlot
|
|
149
|
+
): Promise<Base64String> {
|
|
150
|
+
return NativeYubikitPiv.attestKey(deviceHandle, slot);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export function generateKey(
|
|
154
|
+
deviceHandle: string,
|
|
155
|
+
slot: PivSlot,
|
|
156
|
+
keyType: PivKeyType,
|
|
157
|
+
pinPolicy: PivPinPolicy,
|
|
158
|
+
touchPolicy: PivTouchPolicy
|
|
159
|
+
): Promise<Base64String> {
|
|
160
|
+
return NativeYubikitPiv.generateKey(
|
|
161
|
+
deviceHandle,
|
|
162
|
+
slot,
|
|
163
|
+
keyType,
|
|
164
|
+
pinPolicy,
|
|
165
|
+
touchPolicy
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export function deleteKey(deviceHandle: string, slot: PivSlot): Promise<void> {
|
|
170
|
+
return NativeYubikitPiv.deleteKey(deviceHandle, slot);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export function rawSignOrDecrypt(
|
|
174
|
+
deviceHandle: string,
|
|
175
|
+
slot: PivSlot,
|
|
176
|
+
keyType: PivKeyType,
|
|
177
|
+
payload: Base64String
|
|
178
|
+
): Promise<Base64String> {
|
|
179
|
+
return NativeYubikitPiv.rawSignOrDecrypt(
|
|
180
|
+
deviceHandle,
|
|
181
|
+
slot,
|
|
182
|
+
keyType,
|
|
183
|
+
payload
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
export function getBioMetadata(deviceHandle: string): Promise<PivBioMetadata> {
|
|
188
|
+
return NativeYubikitPiv.getBioMetadata(
|
|
189
|
+
deviceHandle
|
|
190
|
+
) as Promise<PivBioMetadata>;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
export { NativeYubikitPiv };
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import {
|
|
2
|
+
TurboModuleRegistry,
|
|
3
|
+
type TurboModule,
|
|
4
|
+
type CodegenTypes,
|
|
5
|
+
} from 'react-native';
|
|
6
|
+
|
|
7
|
+
interface UsbConfiguration {
|
|
8
|
+
handlePermissions?: boolean;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
interface NfcConfiguration {
|
|
12
|
+
timeout?: number;
|
|
13
|
+
disableNfcDiscoverySound?: boolean;
|
|
14
|
+
skipNdefCheck?: boolean;
|
|
15
|
+
handleUnavailableNfc?: boolean;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
interface YubiKeyDevice {
|
|
19
|
+
handle: string;
|
|
20
|
+
transport: 'usb' | 'nfc';
|
|
21
|
+
supportedConnections: string[];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// Codegen doesn't support discriminated union payloads, so every variant's
|
|
25
|
+
// fields are optional here; consumers get the narrower YubiKeyEvent union
|
|
26
|
+
// via Core.addYubiKeyListener instead of calling this event directly.
|
|
27
|
+
interface YubiKeyEventPayload {
|
|
28
|
+
type: 'attached' | 'detached' | 'error';
|
|
29
|
+
device?: YubiKeyDevice;
|
|
30
|
+
handle?: string;
|
|
31
|
+
error?: string;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface Spec extends TurboModule {
|
|
35
|
+
/** Start listening for USB YubiKeys. */
|
|
36
|
+
startUsbDiscovery(config?: UsbConfiguration): void;
|
|
37
|
+
/** Stop listening for USB YubiKeys. */
|
|
38
|
+
stopUsbDiscovery(): void;
|
|
39
|
+
/** Start listening for NFC YubiKeys. */
|
|
40
|
+
startNfcDiscovery(config?: NfcConfiguration): void;
|
|
41
|
+
/** Stop listening for NFC YubiKeys. */
|
|
42
|
+
stopNfcDiscovery(): void;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Request a connection to a discovered device. The promise resolves with a
|
|
46
|
+
* connection handle that can be passed to session modules.
|
|
47
|
+
*/
|
|
48
|
+
requestConnection(
|
|
49
|
+
deviceHandle: string,
|
|
50
|
+
connectionType: string
|
|
51
|
+
): Promise<string>;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Send a raw APDU over a SmartCardConnection and receive the response.
|
|
55
|
+
*/
|
|
56
|
+
sendApdu(connectionHandle: string, apdu: string): Promise<string>;
|
|
57
|
+
|
|
58
|
+
/** Close an opened connection. */
|
|
59
|
+
closeConnection(connectionHandle: string): void;
|
|
60
|
+
|
|
61
|
+
/** List devices currently held by the manager. */
|
|
62
|
+
getDiscoveredDevices(): YubiKeyDevice[];
|
|
63
|
+
|
|
64
|
+
/** Fires on device attach/detach and discovery-connection failures. */
|
|
65
|
+
readonly onYubiKeyEvent: CodegenTypes.EventEmitter<YubiKeyEventPayload>;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export default TurboModuleRegistry.getEnforcing<Spec>('YubikitCore');
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { TurboModuleRegistry, type TurboModule } from 'react-native';
|
|
2
|
+
|
|
3
|
+
interface PublicKeyCredentialRpEntity {
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
interface PublicKeyCredentialUserEntity {
|
|
9
|
+
id: string;
|
|
10
|
+
name: string;
|
|
11
|
+
displayName: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
interface PublicKeyCredentialParameters {
|
|
15
|
+
type: string;
|
|
16
|
+
alg: number;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
interface PublicKeyCredentialCreationOptions {
|
|
20
|
+
rp: PublicKeyCredentialRpEntity;
|
|
21
|
+
user: PublicKeyCredentialUserEntity;
|
|
22
|
+
challenge: string;
|
|
23
|
+
pubKeyCredParams: PublicKeyCredentialParameters[];
|
|
24
|
+
timeout?: number;
|
|
25
|
+
excludeCredentials?: Array<{
|
|
26
|
+
id: string;
|
|
27
|
+
type: string;
|
|
28
|
+
transports?: string[];
|
|
29
|
+
}>;
|
|
30
|
+
authenticatorSelection?: {
|
|
31
|
+
authenticatorAttachment?: string;
|
|
32
|
+
residentKey?: string;
|
|
33
|
+
userVerification?: string;
|
|
34
|
+
};
|
|
35
|
+
attestation?: string;
|
|
36
|
+
extensions?: { [key: string]: unknown };
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
interface PublicKeyCredentialRequestOptions {
|
|
40
|
+
challenge: string;
|
|
41
|
+
timeout?: number;
|
|
42
|
+
rpId?: string;
|
|
43
|
+
allowCredentials?: Array<{
|
|
44
|
+
id: string;
|
|
45
|
+
type: string;
|
|
46
|
+
transports?: string[];
|
|
47
|
+
}>;
|
|
48
|
+
userVerification?: string;
|
|
49
|
+
extensions?: { [key: string]: unknown };
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
interface PublicKeyCredential {
|
|
53
|
+
id: string;
|
|
54
|
+
rawId: string;
|
|
55
|
+
type: 'public-key';
|
|
56
|
+
response: {
|
|
57
|
+
clientDataJSON: string;
|
|
58
|
+
authenticatorData?: string;
|
|
59
|
+
attestationObject?: string;
|
|
60
|
+
signature?: string;
|
|
61
|
+
userHandle?: string;
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
interface Ctap2Info {
|
|
66
|
+
versions: string[];
|
|
67
|
+
extensions?: string[];
|
|
68
|
+
aaguid?: string;
|
|
69
|
+
options?: { [key: string]: boolean };
|
|
70
|
+
maxMsgSize?: number;
|
|
71
|
+
pinUvAuthProtocols?: number[];
|
|
72
|
+
maxCredentialCountInList?: number;
|
|
73
|
+
maxCredentialIdLength?: number;
|
|
74
|
+
transports?: string[];
|
|
75
|
+
algorithms?: Array<{ type: string; alg: number }>;
|
|
76
|
+
maxLargeBlob?: number;
|
|
77
|
+
minPinLength?: number;
|
|
78
|
+
firmwareVersion?: number;
|
|
79
|
+
maxCredBlobLength?: number;
|
|
80
|
+
maxRpidsForMinPinLength?: number;
|
|
81
|
+
preferredPlatformUvAttempts?: number;
|
|
82
|
+
uvModality?: number;
|
|
83
|
+
certifications?: { [key: string]: number };
|
|
84
|
+
remainingDiscoverableCredentials?: number;
|
|
85
|
+
vendorPrototypeConfigCommands?: number[];
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
interface FidoCredentialDescriptor {
|
|
89
|
+
id: string;
|
|
90
|
+
type: string;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
interface FidoCredentialUserEntity {
|
|
94
|
+
id: string;
|
|
95
|
+
name: string;
|
|
96
|
+
displayName: string;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export interface Spec extends TurboModule {
|
|
100
|
+
/** Get CTAP2 authenticator info. */
|
|
101
|
+
getInfo(deviceHandle: string): Promise<Ctap2Info>;
|
|
102
|
+
|
|
103
|
+
/** Perform a WebAuthn registration (makeCredential). */
|
|
104
|
+
makeCredential(
|
|
105
|
+
deviceHandle: string,
|
|
106
|
+
options: PublicKeyCredentialCreationOptions,
|
|
107
|
+
effectiveDomain: string,
|
|
108
|
+
pin?: string,
|
|
109
|
+
enterpriseAttestation?: number
|
|
110
|
+
): Promise<PublicKeyCredential>;
|
|
111
|
+
|
|
112
|
+
/** Perform a WebAuthn authentication (getAssertion). */
|
|
113
|
+
getAssertion(
|
|
114
|
+
deviceHandle: string,
|
|
115
|
+
options: PublicKeyCredentialRequestOptions,
|
|
116
|
+
effectiveDomain: string,
|
|
117
|
+
pin?: string
|
|
118
|
+
): Promise<PublicKeyCredential>;
|
|
119
|
+
|
|
120
|
+
/** Reset the authenticator. */
|
|
121
|
+
reset(deviceHandle: string): Promise<void>;
|
|
122
|
+
|
|
123
|
+
/** Credential management operations (requires PIN). */
|
|
124
|
+
getCredentialCount(deviceHandle: string, pin: string): Promise<number>;
|
|
125
|
+
getRpIdList(deviceHandle: string, pin: string): Promise<string[]>;
|
|
126
|
+
getCredentials(
|
|
127
|
+
deviceHandle: string,
|
|
128
|
+
rpId: string,
|
|
129
|
+
pin: string
|
|
130
|
+
): Promise<
|
|
131
|
+
Array<{
|
|
132
|
+
credential: FidoCredentialDescriptor;
|
|
133
|
+
user: FidoCredentialUserEntity;
|
|
134
|
+
}>
|
|
135
|
+
>;
|
|
136
|
+
deleteCredential(
|
|
137
|
+
deviceHandle: string,
|
|
138
|
+
credential: FidoCredentialDescriptor,
|
|
139
|
+
pin: string
|
|
140
|
+
): Promise<void>;
|
|
141
|
+
updateUserInformation(
|
|
142
|
+
deviceHandle: string,
|
|
143
|
+
credential: FidoCredentialDescriptor,
|
|
144
|
+
user: FidoCredentialUserEntity,
|
|
145
|
+
pin: string
|
|
146
|
+
): Promise<void>;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export default TurboModuleRegistry.getEnforcing<Spec>('YubikitFido');
|
|
@@ -0,0 +1,78 @@
|
|
|
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 metadata from a YubiKey. */
|
|
55
|
+
getDeviceInfo(deviceHandle: string): Promise<DeviceInfo>;
|
|
56
|
+
|
|
57
|
+
/** Update device configuration. */
|
|
58
|
+
updateDeviceConfig(
|
|
59
|
+
deviceHandle: string,
|
|
60
|
+
config: DeviceConfig,
|
|
61
|
+
reboot: boolean,
|
|
62
|
+
currentLockCode?: string,
|
|
63
|
+
newLockCode?: string
|
|
64
|
+
): Promise<void>;
|
|
65
|
+
|
|
66
|
+
/** Set the USB interface mode. */
|
|
67
|
+
setMode(
|
|
68
|
+
deviceHandle: string,
|
|
69
|
+
mode: string,
|
|
70
|
+
chalrespTimeout: number,
|
|
71
|
+
autoejectTimeout: number
|
|
72
|
+
): Promise<void>;
|
|
73
|
+
|
|
74
|
+
/** Reset the device to factory defaults. */
|
|
75
|
+
deviceReset(deviceHandle: string): Promise<void>;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export default TurboModuleRegistry.getEnforcing<Spec>('YubikitManagement');
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { TurboModuleRegistry, type TurboModule } from 'react-native';
|
|
2
|
+
|
|
3
|
+
interface Credential {
|
|
4
|
+
id: string;
|
|
5
|
+
oathType: 'HOTP' | 'TOTP';
|
|
6
|
+
issuer?: string;
|
|
7
|
+
accountName: string;
|
|
8
|
+
period: number;
|
|
9
|
+
touchRequired: boolean;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
interface Code {
|
|
13
|
+
value: string;
|
|
14
|
+
validFrom: number;
|
|
15
|
+
validUntil: number;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
interface CredentialData {
|
|
19
|
+
accountName: string;
|
|
20
|
+
oathType: 'HOTP' | 'TOTP';
|
|
21
|
+
hashAlgorithm: 'SHA1' | 'SHA256' | 'SHA512';
|
|
22
|
+
secret: string;
|
|
23
|
+
digits: number;
|
|
24
|
+
period: number;
|
|
25
|
+
counter: number;
|
|
26
|
+
issuer?: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
interface OathCredentialsResult {
|
|
30
|
+
credentials: Credential[];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
interface OathCodesResult {
|
|
34
|
+
codes: Array<{ credential: Credential; code?: Code }>;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface Spec extends TurboModule {
|
|
38
|
+
/** Get a stable ID for the OATH application on this device. */
|
|
39
|
+
getDeviceId(deviceHandle: string): Promise<string>;
|
|
40
|
+
|
|
41
|
+
/** Reset the OATH application. */
|
|
42
|
+
reset(deviceHandle: string): Promise<void>;
|
|
43
|
+
|
|
44
|
+
/** True if an access key/password is configured. */
|
|
45
|
+
isAccessKeySet(deviceHandle: string): Promise<boolean>;
|
|
46
|
+
|
|
47
|
+
/** True if the session is locked and needs unlock. */
|
|
48
|
+
isLocked(deviceHandle: string): Promise<boolean>;
|
|
49
|
+
|
|
50
|
+
/** Unlock with a password. */
|
|
51
|
+
unlockWithPassword(deviceHandle: string, password: string): Promise<boolean>;
|
|
52
|
+
|
|
53
|
+
/** Unlock with a raw access key. */
|
|
54
|
+
unlockWithAccessKey(
|
|
55
|
+
deviceHandle: string,
|
|
56
|
+
accessKey: string
|
|
57
|
+
): Promise<boolean>;
|
|
58
|
+
|
|
59
|
+
/** Set or change the password used to derive the access key. */
|
|
60
|
+
setPassword(deviceHandle: string, password: string): Promise<void>;
|
|
61
|
+
|
|
62
|
+
/** Set the raw access key directly. */
|
|
63
|
+
setAccessKey(deviceHandle: string, accessKey: string): Promise<void>;
|
|
64
|
+
|
|
65
|
+
/** Remove access key protection. */
|
|
66
|
+
deleteAccessKey(deviceHandle: string): Promise<void>;
|
|
67
|
+
|
|
68
|
+
/** List stored credentials. */
|
|
69
|
+
getCredentials(deviceHandle: string): Promise<OathCredentialsResult>;
|
|
70
|
+
|
|
71
|
+
/** Calculate all TOTP codes for the current time. */
|
|
72
|
+
calculateCodes(
|
|
73
|
+
deviceHandle: string,
|
|
74
|
+
timestamp?: number
|
|
75
|
+
): Promise<OathCodesResult>;
|
|
76
|
+
|
|
77
|
+
/** Calculate a HOTP response for a credential. */
|
|
78
|
+
calculateResponse(
|
|
79
|
+
deviceHandle: string,
|
|
80
|
+
credentialId: string,
|
|
81
|
+
challenge: string
|
|
82
|
+
): Promise<string>;
|
|
83
|
+
|
|
84
|
+
/** Calculate a single TOTP/HOTP code. */
|
|
85
|
+
calculateCode(
|
|
86
|
+
deviceHandle: string,
|
|
87
|
+
credentialId: string,
|
|
88
|
+
timestamp?: number
|
|
89
|
+
): Promise<Code>;
|
|
90
|
+
|
|
91
|
+
/** Add a new credential. */
|
|
92
|
+
putCredential(
|
|
93
|
+
deviceHandle: string,
|
|
94
|
+
credentialData: CredentialData,
|
|
95
|
+
requireTouch: boolean
|
|
96
|
+
): Promise<Credential>;
|
|
97
|
+
|
|
98
|
+
/** Delete a credential by ID. */
|
|
99
|
+
deleteCredential(deviceHandle: string, credentialId: string): Promise<void>;
|
|
100
|
+
|
|
101
|
+
/** Rename a credential by ID. */
|
|
102
|
+
renameCredential(
|
|
103
|
+
deviceHandle: string,
|
|
104
|
+
credentialId: string,
|
|
105
|
+
newAccountName: string,
|
|
106
|
+
newIssuer?: string
|
|
107
|
+
): Promise<Credential>;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export default TurboModuleRegistry.getEnforcing<Spec>('YubikitOath');
|