@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.
Files changed (144) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +126 -0
  3. package/RNYubikit.podspec +22 -0
  4. package/android/build.gradle +63 -0
  5. package/android/src/main/AndroidManifest.xml +9 -0
  6. package/android/src/main/java/com/yubikit/YubiKitManagerHolder.kt +330 -0
  7. package/android/src/main/java/com/yubikit/YubikitCoreModule.kt +142 -0
  8. package/android/src/main/java/com/yubikit/YubikitFidoModule.kt +418 -0
  9. package/android/src/main/java/com/yubikit/YubikitManagementModule.kt +132 -0
  10. package/android/src/main/java/com/yubikit/YubikitOathModule.kt +224 -0
  11. package/android/src/main/java/com/yubikit/YubikitOpenPgpModule.kt +317 -0
  12. package/android/src/main/java/com/yubikit/YubikitPackage.kt +44 -0
  13. package/android/src/main/java/com/yubikit/YubikitPivModule.kt +310 -0
  14. package/android/src/main/java/com/yubikit/YubikitSupportModule.kt +108 -0
  15. package/android/src/main/java/com/yubikit/YubikitYubiOtpModule.kt +248 -0
  16. package/android/src/main/java/com/yubikit/utils/YubikitUtils.kt +321 -0
  17. package/ios/YubikitCore.h +5 -0
  18. package/ios/YubikitCore.mm +101 -0
  19. package/ios/YubikitDeviceInfoHelper.h +13 -0
  20. package/ios/YubikitDeviceInfoHelper.mm +110 -0
  21. package/ios/YubikitFido.h +5 -0
  22. package/ios/YubikitFido.mm +373 -0
  23. package/ios/YubikitManagement.h +5 -0
  24. package/ios/YubikitManagement.mm +153 -0
  25. package/ios/YubikitManager.h +27 -0
  26. package/ios/YubikitManager.m +169 -0
  27. package/ios/YubikitOath.h +5 -0
  28. package/ios/YubikitOath.mm +583 -0
  29. package/ios/YubikitOpenPgp.h +5 -0
  30. package/ios/YubikitOpenPgp.mm +210 -0
  31. package/ios/YubikitPiv.h +5 -0
  32. package/ios/YubikitPiv.mm +813 -0
  33. package/ios/YubikitSupport.h +5 -0
  34. package/ios/YubikitSupport.mm +58 -0
  35. package/ios/YubikitYubiOtp.h +5 -0
  36. package/ios/YubikitYubiOtp.mm +120 -0
  37. package/lib/module/core.js +34 -0
  38. package/lib/module/core.js.map +1 -0
  39. package/lib/module/fido.js +40 -0
  40. package/lib/module/fido.js.map +1 -0
  41. package/lib/module/hooks/index.js +5 -0
  42. package/lib/module/hooks/index.js.map +1 -0
  43. package/lib/module/hooks/use-yubikey.js +12 -0
  44. package/lib/module/hooks/use-yubikey.js.map +1 -0
  45. package/lib/module/hooks/yubikey-provider.js +85 -0
  46. package/lib/module/hooks/yubikey-provider.js.map +1 -0
  47. package/lib/module/index.js +12 -0
  48. package/lib/module/index.js.map +1 -0
  49. package/lib/module/management.js +17 -0
  50. package/lib/module/management.js.map +1 -0
  51. package/lib/module/oath.js +53 -0
  52. package/lib/module/oath.js.map +1 -0
  53. package/lib/module/openpgp.js +89 -0
  54. package/lib/module/openpgp.js.map +1 -0
  55. package/lib/module/package.json +1 -0
  56. package/lib/module/piv.js +71 -0
  57. package/lib/module/piv.js.map +1 -0
  58. package/lib/module/specs/NativeYubikitCore.js +10 -0
  59. package/lib/module/specs/NativeYubikitCore.js.map +1 -0
  60. package/lib/module/specs/NativeYubikitFido.js +5 -0
  61. package/lib/module/specs/NativeYubikitFido.js.map +1 -0
  62. package/lib/module/specs/NativeYubikitManagement.js +5 -0
  63. package/lib/module/specs/NativeYubikitManagement.js.map +1 -0
  64. package/lib/module/specs/NativeYubikitOath.js +5 -0
  65. package/lib/module/specs/NativeYubikitOath.js.map +1 -0
  66. package/lib/module/specs/NativeYubikitOpenPgp.js +5 -0
  67. package/lib/module/specs/NativeYubikitOpenPgp.js.map +1 -0
  68. package/lib/module/specs/NativeYubikitPiv.js +5 -0
  69. package/lib/module/specs/NativeYubikitPiv.js.map +1 -0
  70. package/lib/module/specs/NativeYubikitSupport.js +5 -0
  71. package/lib/module/specs/NativeYubikitSupport.js.map +1 -0
  72. package/lib/module/specs/NativeYubikitYubiOtp.js +5 -0
  73. package/lib/module/specs/NativeYubikitYubiOtp.js.map +1 -0
  74. package/lib/module/support.js +11 -0
  75. package/lib/module/support.js.map +1 -0
  76. package/lib/module/types.js +2 -0
  77. package/lib/module/types.js.map +1 -0
  78. package/lib/module/yubiotp.js +32 -0
  79. package/lib/module/yubiotp.js.map +1 -0
  80. package/lib/typescript/package.json +1 -0
  81. package/lib/typescript/src/core.d.ts +14 -0
  82. package/lib/typescript/src/core.d.ts.map +1 -0
  83. package/lib/typescript/src/fido.d.ts +24 -0
  84. package/lib/typescript/src/fido.d.ts.map +1 -0
  85. package/lib/typescript/src/hooks/index.d.ts +3 -0
  86. package/lib/typescript/src/hooks/index.d.ts.map +1 -0
  87. package/lib/typescript/src/hooks/use-yubikey.d.ts +3 -0
  88. package/lib/typescript/src/hooks/use-yubikey.d.ts.map +1 -0
  89. package/lib/typescript/src/hooks/yubikey-provider.d.ts +23 -0
  90. package/lib/typescript/src/hooks/yubikey-provider.d.ts.map +1 -0
  91. package/lib/typescript/src/index.d.ts +10 -0
  92. package/lib/typescript/src/index.d.ts.map +1 -0
  93. package/lib/typescript/src/management.d.ts +8 -0
  94. package/lib/typescript/src/management.d.ts.map +1 -0
  95. package/lib/typescript/src/oath.d.ts +20 -0
  96. package/lib/typescript/src/oath.d.ts.map +1 -0
  97. package/lib/typescript/src/openpgp.d.ts +35 -0
  98. package/lib/typescript/src/openpgp.d.ts.map +1 -0
  99. package/lib/typescript/src/piv.d.ts +26 -0
  100. package/lib/typescript/src/piv.d.ts.map +1 -0
  101. package/lib/typescript/src/specs/NativeYubikitCore.d.ts +49 -0
  102. package/lib/typescript/src/specs/NativeYubikitCore.d.ts.map +1 -0
  103. package/lib/typescript/src/specs/NativeYubikitFido.d.ts +121 -0
  104. package/lib/typescript/src/specs/NativeYubikitFido.d.ts.map +1 -0
  105. package/lib/typescript/src/specs/NativeYubikitManagement.d.ts +53 -0
  106. package/lib/typescript/src/specs/NativeYubikitManagement.d.ts.map +1 -0
  107. package/lib/typescript/src/specs/NativeYubikitOath.d.ts +70 -0
  108. package/lib/typescript/src/specs/NativeYubikitOath.d.ts.map +1 -0
  109. package/lib/typescript/src/specs/NativeYubikitOpenPgp.d.ts +53 -0
  110. package/lib/typescript/src/specs/NativeYubikitOpenPgp.d.ts.map +1 -0
  111. package/lib/typescript/src/specs/NativeYubikitPiv.d.ts +47 -0
  112. package/lib/typescript/src/specs/NativeYubikitPiv.d.ts.map +1 -0
  113. package/lib/typescript/src/specs/NativeYubikitSupport.d.ts +49 -0
  114. package/lib/typescript/src/specs/NativeYubikitSupport.d.ts.map +1 -0
  115. package/lib/typescript/src/specs/NativeYubikitYubiOtp.d.ts +45 -0
  116. package/lib/typescript/src/specs/NativeYubikitYubiOtp.d.ts.map +1 -0
  117. package/lib/typescript/src/support.d.ts +6 -0
  118. package/lib/typescript/src/support.d.ts.map +1 -0
  119. package/lib/typescript/src/types.d.ts +293 -0
  120. package/lib/typescript/src/types.d.ts.map +1 -0
  121. package/lib/typescript/src/yubiotp.d.ts +13 -0
  122. package/lib/typescript/src/yubiotp.d.ts.map +1 -0
  123. package/package.json +181 -0
  124. package/src/core.ts +58 -0
  125. package/src/fido.ts +112 -0
  126. package/src/hooks/index.tsx +2 -0
  127. package/src/hooks/use-yubikey.tsx +10 -0
  128. package/src/hooks/yubikey-provider.tsx +146 -0
  129. package/src/index.tsx +10 -0
  130. package/src/management.ts +44 -0
  131. package/src/oath.ts +134 -0
  132. package/src/openpgp.ts +220 -0
  133. package/src/piv.ts +193 -0
  134. package/src/specs/NativeYubikitCore.ts +68 -0
  135. package/src/specs/NativeYubikitFido.ts +149 -0
  136. package/src/specs/NativeYubikitManagement.ts +78 -0
  137. package/src/specs/NativeYubikitOath.ts +110 -0
  138. package/src/specs/NativeYubikitOpenPgp.ts +148 -0
  139. package/src/specs/NativeYubikitPiv.ts +108 -0
  140. package/src/specs/NativeYubikitSupport.ts +61 -0
  141. package/src/specs/NativeYubikitYubiOtp.ts +82 -0
  142. package/src/support.ts +18 -0
  143. package/src/types.ts +404 -0
  144. package/src/yubiotp.ts +96 -0
@@ -0,0 +1,10 @@
1
+ import { useContext } from 'react';
2
+ import { YubiKeyContext, type YubiKeyContextValue } from './yubikey-provider';
3
+
4
+ export function useYubiKey(): YubiKeyContextValue {
5
+ const ctx = useContext(YubiKeyContext);
6
+ if (!ctx) {
7
+ throw new Error('useYubiKey must be used within a <YubiKeyProvider>');
8
+ }
9
+ return ctx;
10
+ }
@@ -0,0 +1,146 @@
1
+ import {
2
+ createContext,
3
+ useCallback,
4
+ useEffect,
5
+ useMemo,
6
+ useRef,
7
+ useState,
8
+ } from 'react';
9
+ import type { ReactNode } from 'react';
10
+ import * as Core from '../core';
11
+ import type {
12
+ NfcConfiguration,
13
+ UsbConfiguration,
14
+ YubiKeyDevice,
15
+ YubiKeyEvent,
16
+ } from '../types';
17
+
18
+ export interface YubiKeyContextValue {
19
+ /** Devices currently attached, most-recently-attached first. */
20
+ devices: YubiKeyDevice[];
21
+ /** The selected device, or the most recently attached one if none was explicitly selected. */
22
+ selectedDevice: YubiKeyDevice | null;
23
+ /** Explicitly select a device by handle, or `null` to fall back to auto-selection. */
24
+ selectDevice: (handle: string | null) => void;
25
+ isUsbDiscovering: boolean;
26
+ isNfcDiscovering: boolean;
27
+ startUsbDiscovery: (config?: UsbConfiguration) => void;
28
+ stopUsbDiscovery: () => void;
29
+ startNfcDiscovery: (config?: NfcConfiguration) => void;
30
+ stopNfcDiscovery: () => void;
31
+ /** The most recent native-side error event, if any. */
32
+ lastError: string | null;
33
+ }
34
+
35
+ export const YubiKeyContext = createContext<YubiKeyContextValue | null>(null);
36
+
37
+ export function YubiKeyProvider({ children }: { children: ReactNode }) {
38
+ const [devices, setDevices] = useState<YubiKeyDevice[]>(() =>
39
+ Core.getDiscoveredDevices()
40
+ );
41
+ const [selectedHandle, setSelectedHandle] = useState<string | null>(null);
42
+ const [isUsbDiscovering, setIsUsbDiscovering] = useState(false);
43
+ const [isNfcDiscovering, setIsNfcDiscovering] = useState(false);
44
+ const [lastError, setLastError] = useState<string | null>(null);
45
+ const isUsbDiscoveringRef = useRef(isUsbDiscovering);
46
+ const isNfcDiscoveringRef = useRef(isNfcDiscovering);
47
+
48
+ useEffect(() => {
49
+ isUsbDiscoveringRef.current = isUsbDiscovering;
50
+ }, [isUsbDiscovering]);
51
+
52
+ useEffect(() => {
53
+ isNfcDiscoveringRef.current = isNfcDiscovering;
54
+ }, [isNfcDiscovering]);
55
+
56
+ useEffect(() => {
57
+ const subscription = Core.addYubiKeyListener((event: YubiKeyEvent) => {
58
+ if (event.type === 'attached') {
59
+ setDevices((prev) => [
60
+ event.device,
61
+ ...prev.filter((d) => d.handle !== event.device.handle),
62
+ ]);
63
+ return;
64
+ }
65
+ if (event.type === 'detached') {
66
+ setDevices((prev) => prev.filter((d) => d.handle !== event.handle));
67
+ setSelectedHandle((prev) => (prev === event.handle ? null : prev));
68
+ return;
69
+ }
70
+ setLastError(event.error);
71
+ });
72
+
73
+ return () => subscription.remove();
74
+ }, []);
75
+
76
+ const startUsbDiscovery = useCallback((config?: UsbConfiguration) => {
77
+ Core.startUsbDiscovery(config);
78
+ setIsUsbDiscovering(true);
79
+ }, []);
80
+
81
+ const stopUsbDiscovery = useCallback(() => {
82
+ Core.stopUsbDiscovery();
83
+ setIsUsbDiscovering(false);
84
+ }, []);
85
+
86
+ const startNfcDiscovery = useCallback((config?: NfcConfiguration) => {
87
+ Core.startNfcDiscovery(config);
88
+ setIsNfcDiscovering(true);
89
+ }, []);
90
+
91
+ const stopNfcDiscovery = useCallback(() => {
92
+ Core.stopNfcDiscovery();
93
+ setIsNfcDiscovering(false);
94
+ }, []);
95
+
96
+ // Discovery is a global, imperative native API (not tied to this component's
97
+ // lifetime by the native side), but leaving it running past the provider that
98
+ // started it would leak a dangling USB/NFC session the app can no longer see.
99
+ useEffect(() => {
100
+ return () => {
101
+ if (isUsbDiscoveringRef.current) Core.stopUsbDiscovery();
102
+ if (isNfcDiscoveringRef.current) Core.stopNfcDiscovery();
103
+ };
104
+ }, []);
105
+
106
+ const selectDevice = useCallback((handle: string | null) => {
107
+ setSelectedHandle(handle);
108
+ }, []);
109
+
110
+ const selectedDevice = useMemo(
111
+ () =>
112
+ devices.find((d) => d.handle === selectedHandle) ?? devices[0] ?? null,
113
+ [devices, selectedHandle]
114
+ );
115
+
116
+ const value = useMemo<YubiKeyContextValue>(
117
+ () => ({
118
+ devices,
119
+ selectedDevice,
120
+ selectDevice,
121
+ isUsbDiscovering,
122
+ isNfcDiscovering,
123
+ startUsbDiscovery,
124
+ stopUsbDiscovery,
125
+ startNfcDiscovery,
126
+ stopNfcDiscovery,
127
+ lastError,
128
+ }),
129
+ [
130
+ devices,
131
+ selectedDevice,
132
+ selectDevice,
133
+ isUsbDiscovering,
134
+ isNfcDiscovering,
135
+ startUsbDiscovery,
136
+ stopUsbDiscovery,
137
+ startNfcDiscovery,
138
+ stopNfcDiscovery,
139
+ lastError,
140
+ ]
141
+ );
142
+
143
+ return (
144
+ <YubiKeyContext.Provider value={value}>{children}</YubiKeyContext.Provider>
145
+ );
146
+ }
package/src/index.tsx ADDED
@@ -0,0 +1,10 @@
1
+ export * from './types';
2
+
3
+ export * as Core from './core';
4
+ export * as Management from './management';
5
+ export * as Oath from './oath';
6
+ export * as Piv from './piv';
7
+ export * as OpenPgp from './openpgp';
8
+ export * as YubiOtp from './yubiotp';
9
+ export * as Fido from './fido';
10
+ export * as Support from './support';
@@ -0,0 +1,44 @@
1
+ import NativeYubikitManagement from './specs/NativeYubikitManagement';
2
+ import type { Base64String, DeviceConfig, DeviceInfo, UsbMode } from './types';
3
+
4
+ export function getDeviceInfo(deviceHandle: string): Promise<DeviceInfo> {
5
+ return NativeYubikitManagement.getDeviceInfo(
6
+ deviceHandle
7
+ ) as Promise<DeviceInfo>;
8
+ }
9
+
10
+ export function updateDeviceConfig(
11
+ deviceHandle: string,
12
+ config: DeviceConfig,
13
+ reboot: boolean,
14
+ currentLockCode?: Base64String,
15
+ newLockCode?: Base64String
16
+ ): Promise<void> {
17
+ return NativeYubikitManagement.updateDeviceConfig(
18
+ deviceHandle,
19
+ config,
20
+ reboot,
21
+ currentLockCode,
22
+ newLockCode
23
+ );
24
+ }
25
+
26
+ export function setMode(
27
+ deviceHandle: string,
28
+ mode: UsbMode,
29
+ chalrespTimeout: number,
30
+ autoejectTimeout: number
31
+ ): Promise<void> {
32
+ return NativeYubikitManagement.setMode(
33
+ deviceHandle,
34
+ mode,
35
+ chalrespTimeout,
36
+ autoejectTimeout
37
+ );
38
+ }
39
+
40
+ export function deviceReset(deviceHandle: string): Promise<void> {
41
+ return NativeYubikitManagement.deviceReset(deviceHandle);
42
+ }
43
+
44
+ export { NativeYubikitManagement };
package/src/oath.ts ADDED
@@ -0,0 +1,134 @@
1
+ import NativeYubikitOath from './specs/NativeYubikitOath';
2
+ import type {
3
+ Base64String,
4
+ Code,
5
+ Credential,
6
+ CredentialData,
7
+ OathCodesResult,
8
+ OathCredentialsResult,
9
+ } from './types';
10
+
11
+ export function getDeviceId(deviceHandle: string): Promise<string> {
12
+ return NativeYubikitOath.getDeviceId(deviceHandle);
13
+ }
14
+
15
+ export function reset(deviceHandle: string): Promise<void> {
16
+ return NativeYubikitOath.reset(deviceHandle);
17
+ }
18
+
19
+ export function isAccessKeySet(deviceHandle: string): Promise<boolean> {
20
+ return NativeYubikitOath.isAccessKeySet(deviceHandle);
21
+ }
22
+
23
+ export function isLocked(deviceHandle: string): Promise<boolean> {
24
+ return NativeYubikitOath.isLocked(deviceHandle);
25
+ }
26
+
27
+ export function unlockWithPassword(
28
+ deviceHandle: string,
29
+ password: string
30
+ ): Promise<boolean> {
31
+ return NativeYubikitOath.unlockWithPassword(deviceHandle, password);
32
+ }
33
+
34
+ export function unlockWithAccessKey(
35
+ deviceHandle: string,
36
+ accessKey: Base64String
37
+ ): Promise<boolean> {
38
+ return NativeYubikitOath.unlockWithAccessKey(deviceHandle, accessKey);
39
+ }
40
+
41
+ export function setPassword(
42
+ deviceHandle: string,
43
+ password: string
44
+ ): Promise<void> {
45
+ return NativeYubikitOath.setPassword(deviceHandle, password);
46
+ }
47
+
48
+ export function setAccessKey(
49
+ deviceHandle: string,
50
+ accessKey: Base64String
51
+ ): Promise<void> {
52
+ return NativeYubikitOath.setAccessKey(deviceHandle, accessKey);
53
+ }
54
+
55
+ export function deleteAccessKey(deviceHandle: string): Promise<void> {
56
+ return NativeYubikitOath.deleteAccessKey(deviceHandle);
57
+ }
58
+
59
+ export function getCredentials(
60
+ deviceHandle: string
61
+ ): Promise<OathCredentialsResult> {
62
+ return NativeYubikitOath.getCredentials(
63
+ deviceHandle
64
+ ) as Promise<OathCredentialsResult>;
65
+ }
66
+
67
+ export function calculateCodes(
68
+ deviceHandle: string,
69
+ timestamp?: number
70
+ ): Promise<OathCodesResult> {
71
+ return NativeYubikitOath.calculateCodes(
72
+ deviceHandle,
73
+ timestamp
74
+ ) as Promise<OathCodesResult>;
75
+ }
76
+
77
+ export function calculateResponse(
78
+ deviceHandle: string,
79
+ credentialId: Base64String,
80
+ challenge: Base64String
81
+ ): Promise<Base64String> {
82
+ return NativeYubikitOath.calculateResponse(
83
+ deviceHandle,
84
+ credentialId,
85
+ challenge
86
+ );
87
+ }
88
+
89
+ export function calculateCode(
90
+ deviceHandle: string,
91
+ credentialId: Base64String,
92
+ timestamp?: number
93
+ ): Promise<Code> {
94
+ return NativeYubikitOath.calculateCode(
95
+ deviceHandle,
96
+ credentialId,
97
+ timestamp
98
+ ) as Promise<Code>;
99
+ }
100
+
101
+ export function putCredential(
102
+ deviceHandle: string,
103
+ credentialData: CredentialData,
104
+ requireTouch: boolean
105
+ ): Promise<Credential> {
106
+ return NativeYubikitOath.putCredential(
107
+ deviceHandle,
108
+ credentialData,
109
+ requireTouch
110
+ ) as Promise<Credential>;
111
+ }
112
+
113
+ export function deleteCredential(
114
+ deviceHandle: string,
115
+ credentialId: Base64String
116
+ ): Promise<void> {
117
+ return NativeYubikitOath.deleteCredential(deviceHandle, credentialId);
118
+ }
119
+
120
+ export function renameCredential(
121
+ deviceHandle: string,
122
+ credentialId: Base64String,
123
+ newAccountName: string,
124
+ newIssuer?: string
125
+ ): Promise<Credential> {
126
+ return NativeYubikitOath.renameCredential(
127
+ deviceHandle,
128
+ credentialId,
129
+ newAccountName,
130
+ newIssuer
131
+ ) as Promise<Credential>;
132
+ }
133
+
134
+ export { NativeYubikitOath };
package/src/openpgp.ts ADDED
@@ -0,0 +1,220 @@
1
+ import NativeYubikitOpenPgp from './specs/NativeYubikitOpenPgp';
2
+ import type {
3
+ Base64String,
4
+ OpenPgpAlgorithmAttributes,
5
+ OpenPgpApplicationRelatedData,
6
+ OpenPgpCurve,
7
+ OpenPgpKeyRef,
8
+ OpenPgpPinPolicy,
9
+ OpenPgpUif,
10
+ Version,
11
+ } from './types';
12
+
13
+ export function getVersion(deviceHandle: string): Promise<Version> {
14
+ return NativeYubikitOpenPgp.getVersion(deviceHandle) as Promise<Version>;
15
+ }
16
+
17
+ export function getApplicationRelatedData(
18
+ deviceHandle: string
19
+ ): Promise<OpenPgpApplicationRelatedData> {
20
+ return NativeYubikitOpenPgp.getApplicationRelatedData(
21
+ deviceHandle
22
+ ) as Promise<OpenPgpApplicationRelatedData>;
23
+ }
24
+
25
+ export function verifyUserPin(
26
+ deviceHandle: string,
27
+ pin: string,
28
+ extended?: boolean
29
+ ): Promise<void> {
30
+ return NativeYubikitOpenPgp.verifyUserPin(deviceHandle, pin, extended);
31
+ }
32
+
33
+ export function verifyAdminPin(
34
+ deviceHandle: string,
35
+ pin: string
36
+ ): Promise<void> {
37
+ return NativeYubikitOpenPgp.verifyAdminPin(deviceHandle, pin);
38
+ }
39
+
40
+ export function unverifyUserPin(deviceHandle: string): Promise<void> {
41
+ return NativeYubikitOpenPgp.unverifyUserPin(deviceHandle);
42
+ }
43
+
44
+ export function unverifyAdminPin(deviceHandle: string): Promise<void> {
45
+ return NativeYubikitOpenPgp.unverifyAdminPin(deviceHandle);
46
+ }
47
+
48
+ export function getSignatureCounter(deviceHandle: string): Promise<number> {
49
+ return NativeYubikitOpenPgp.getSignatureCounter(deviceHandle);
50
+ }
51
+
52
+ export function getChallenge(
53
+ deviceHandle: string,
54
+ length: number
55
+ ): Promise<Base64String> {
56
+ return NativeYubikitOpenPgp.getChallenge(deviceHandle, length);
57
+ }
58
+
59
+ export function reset(deviceHandle: string): Promise<void> {
60
+ return NativeYubikitOpenPgp.reset(deviceHandle);
61
+ }
62
+
63
+ export function setPinAttempts(
64
+ deviceHandle: string,
65
+ userAttempts: number,
66
+ resetAttempts: number,
67
+ adminAttempts: number
68
+ ): Promise<void> {
69
+ return NativeYubikitOpenPgp.setPinAttempts(
70
+ deviceHandle,
71
+ userAttempts,
72
+ resetAttempts,
73
+ adminAttempts
74
+ );
75
+ }
76
+
77
+ export function changeUserPin(
78
+ deviceHandle: string,
79
+ pin: string,
80
+ newPin: string
81
+ ): Promise<void> {
82
+ return NativeYubikitOpenPgp.changeUserPin(deviceHandle, pin, newPin);
83
+ }
84
+
85
+ export function changeAdminPin(
86
+ deviceHandle: string,
87
+ pin: string,
88
+ newPin: string
89
+ ): Promise<void> {
90
+ return NativeYubikitOpenPgp.changeAdminPin(deviceHandle, pin, newPin);
91
+ }
92
+
93
+ export function setSignaturePinPolicy(
94
+ deviceHandle: string,
95
+ policy: OpenPgpPinPolicy
96
+ ): Promise<void> {
97
+ return NativeYubikitOpenPgp.setSignaturePinPolicy(deviceHandle, policy);
98
+ }
99
+
100
+ export function getUif(
101
+ deviceHandle: string,
102
+ keyRef: OpenPgpKeyRef
103
+ ): Promise<OpenPgpUif> {
104
+ return NativeYubikitOpenPgp.getUif(
105
+ deviceHandle,
106
+ keyRef
107
+ ) as Promise<OpenPgpUif>;
108
+ }
109
+
110
+ export function setUif(
111
+ deviceHandle: string,
112
+ keyRef: OpenPgpKeyRef,
113
+ uif: OpenPgpUif
114
+ ): Promise<void> {
115
+ return NativeYubikitOpenPgp.setUif(deviceHandle, keyRef, uif);
116
+ }
117
+
118
+ export function getAlgorithmInformation(
119
+ deviceHandle: string
120
+ ): Promise<
121
+ Array<{ keyRef: OpenPgpKeyRef; attributes: OpenPgpAlgorithmAttributes[] }>
122
+ > {
123
+ return NativeYubikitOpenPgp.getAlgorithmInformation(deviceHandle) as Promise<
124
+ Array<{ keyRef: OpenPgpKeyRef; attributes: OpenPgpAlgorithmAttributes[] }>
125
+ >;
126
+ }
127
+
128
+ export function setAlgorithmAttributes(
129
+ deviceHandle: string,
130
+ keyRef: OpenPgpKeyRef,
131
+ attributes: OpenPgpAlgorithmAttributes
132
+ ): Promise<void> {
133
+ return NativeYubikitOpenPgp.setAlgorithmAttributes(
134
+ deviceHandle,
135
+ keyRef,
136
+ attributes
137
+ );
138
+ }
139
+
140
+ export function getCertificate(
141
+ deviceHandle: string,
142
+ keyRef: OpenPgpKeyRef
143
+ ): Promise<Base64String> {
144
+ return NativeYubikitOpenPgp.getCertificate(deviceHandle, keyRef);
145
+ }
146
+
147
+ export function putCertificate(
148
+ deviceHandle: string,
149
+ keyRef: OpenPgpKeyRef,
150
+ certificate: Base64String
151
+ ): Promise<void> {
152
+ return NativeYubikitOpenPgp.putCertificate(deviceHandle, keyRef, certificate);
153
+ }
154
+
155
+ export function deleteCertificate(
156
+ deviceHandle: string,
157
+ keyRef: OpenPgpKeyRef
158
+ ): Promise<void> {
159
+ return NativeYubikitOpenPgp.deleteCertificate(deviceHandle, keyRef);
160
+ }
161
+
162
+ export function generateRsaKey(
163
+ deviceHandle: string,
164
+ keyRef: OpenPgpKeyRef,
165
+ keySize: number
166
+ ): Promise<Base64String> {
167
+ return NativeYubikitOpenPgp.generateRsaKey(deviceHandle, keyRef, keySize);
168
+ }
169
+
170
+ export function generateEcKey(
171
+ deviceHandle: string,
172
+ keyRef: OpenPgpKeyRef,
173
+ curve: OpenPgpCurve
174
+ ): Promise<Base64String> {
175
+ return NativeYubikitOpenPgp.generateEcKey(deviceHandle, keyRef, curve);
176
+ }
177
+
178
+ export function getPublicKey(
179
+ deviceHandle: string,
180
+ keyRef: OpenPgpKeyRef
181
+ ): Promise<Base64String> {
182
+ return NativeYubikitOpenPgp.getPublicKey(deviceHandle, keyRef);
183
+ }
184
+
185
+ export function deleteKey(
186
+ deviceHandle: string,
187
+ keyRef: OpenPgpKeyRef
188
+ ): Promise<void> {
189
+ return NativeYubikitOpenPgp.deleteKey(deviceHandle, keyRef);
190
+ }
191
+
192
+ export function sign(
193
+ deviceHandle: string,
194
+ payload: Base64String
195
+ ): Promise<Base64String> {
196
+ return NativeYubikitOpenPgp.sign(deviceHandle, payload);
197
+ }
198
+
199
+ export function decrypt(
200
+ deviceHandle: string,
201
+ payload: Base64String
202
+ ): Promise<Base64String> {
203
+ return NativeYubikitOpenPgp.decrypt(deviceHandle, payload);
204
+ }
205
+
206
+ export function authenticate(
207
+ deviceHandle: string,
208
+ payload: Base64String
209
+ ): Promise<Base64String> {
210
+ return NativeYubikitOpenPgp.authenticate(deviceHandle, payload);
211
+ }
212
+
213
+ export function attestKey(
214
+ deviceHandle: string,
215
+ keyRef: OpenPgpKeyRef
216
+ ): Promise<Base64String> {
217
+ return NativeYubikitOpenPgp.attestKey(deviceHandle, keyRef);
218
+ }
219
+
220
+ export { NativeYubikitOpenPgp };