electron-webauthn 1.2.0 → 1.3.1
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/README.md +16 -2
- package/dist/index.d.ts +5 -3
- package/dist/index.js +20 -2
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -24,6 +24,7 @@ The root `electron-webauthn` package is a cross-platform shim that lazy-loads `@
|
|
|
24
24
|
- Credential authentication (assertions) with existing credentials
|
|
25
25
|
- Seamless integration with Electron's native window system
|
|
26
26
|
- Passkey listing via `listPasskeys` (macOS 13.3+)
|
|
27
|
+
- Explicit passkey-listing authorization APIs with `getListPasskeyAuthorizationStatus` and `requestListPasskeyAuthorization`
|
|
27
28
|
- PRF (Pseudo-Random Function) extension support
|
|
28
29
|
- Large Blob extension support for reading/writing credential-specific data
|
|
29
30
|
- User verification preference configuration (preferred, required, discouraged)
|
|
@@ -88,7 +89,7 @@ This library implements the W3C WebAuthn standard using Apple's native Authentic
|
|
|
88
89
|
|
|
89
90
|
## Error Handling
|
|
90
91
|
|
|
91
|
-
`createCredential`, `getCredential`, and `listPasskeys` all return a result object with a `success` field. Always check this field:
|
|
92
|
+
`createCredential`, `getCredential`, `getListPasskeyAuthorizationStatus`, `requestListPasskeyAuthorization`, and `listPasskeys` all return a result object with a `success` field. Always check this field:
|
|
92
93
|
|
|
93
94
|
```typescript
|
|
94
95
|
const result = await createCredential(publicKeyOptions, additionalOptions);
|
|
@@ -126,7 +127,14 @@ console.log("Credential ID:", result.data.credentialId);
|
|
|
126
127
|
`listPasskeys` returns an `Error` object (not a string code) when unsuccessful:
|
|
127
128
|
|
|
128
129
|
```typescript
|
|
129
|
-
const
|
|
130
|
+
const permission = await getListPasskeyAuthorizationStatus();
|
|
131
|
+
if (permission.success && permission.status === "notDetermined") {
|
|
132
|
+
await requestListPasskeyAuthorization();
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const result = await listPasskeys("example.com", {
|
|
136
|
+
requestAuthorization: false,
|
|
137
|
+
});
|
|
130
138
|
|
|
131
139
|
if (!result.success) {
|
|
132
140
|
console.error("Failed to list passkeys:", result.error.message);
|
|
@@ -153,6 +161,12 @@ console.log(`Found ${result.credentials.length} passkeys`);
|
|
|
153
161
|
|
|
154
162
|
- **NotAllowedError**: No valid credentials available for the specified rpId
|
|
155
163
|
|
|
164
|
+
#### Passkey Authorization / Listing
|
|
165
|
+
|
|
166
|
+
- **`getListPasskeyAuthorizationStatus()`**: Returns `authorized`, `denied`, or `notDetermined` without prompting
|
|
167
|
+
- **`requestListPasskeyAuthorization()`**: Shows the macOS permission prompt only when the current state is `notDetermined`
|
|
168
|
+
- **`listPasskeys(..., { requestAuthorization: false })`**: Returns an `Error` when permission has not been decided yet instead of triggering the prompt automatically
|
|
169
|
+
|
|
156
170
|
## Feature Support
|
|
157
171
|
|
|
158
172
|
**Currently Supported:**
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import type { CreateCredentialResult, GetCredentialResult, ListPasskeysError, ListPasskeysResult, WebauthnCreateRequestOptions, WebauthnGetRequestOptions, WebauthnModule } from "@electron-webauthn/types";
|
|
2
|
-
export type { CreateCredentialErrorCodes, CreateCredentialResult, CreateCredentialSuccessData, CreateCredentialSuccessResult, CreateCredentialErrorResult, GetCredentialErrorCodes, GetCredentialResult, GetCredentialSuccessData, GetCredentialSuccessResult, GetCredentialErrorResult, ListPasskeysError, ListPasskeysResult, PasskeyCredential, WebauthnCreateRequestOptions, WebauthnGetRequestOptions, WebauthnModule, } from "@electron-webauthn/types";
|
|
1
|
+
import type { CreateCredentialResult, GetCredentialResult, ListPasskeysOptions, ListPasskeysError, ListPasskeysResult, PasskeyAuthorizationError, PasskeyAuthorizationResult, WebauthnCreateRequestOptions, WebauthnGetRequestOptions, WebauthnModule } from "@electron-webauthn/types";
|
|
2
|
+
export type { CreateCredentialErrorCodes, CreateCredentialResult, CreateCredentialSuccessData, CreateCredentialSuccessResult, CreateCredentialErrorResult, GetCredentialErrorCodes, GetCredentialResult, GetCredentialSuccessData, GetCredentialSuccessResult, GetCredentialErrorResult, ListPasskeysOptions, ListPasskeysError, ListPasskeysResult, PasskeyAuthorizationError, PasskeyAuthorizationResult, PasskeyAuthorizationStatus, PasskeyCredential, WebauthnCreateRequestOptions, WebauthnGetRequestOptions, WebauthnModule, } from "@electron-webauthn/types";
|
|
3
3
|
type MacosLoader = () => Promise<WebauthnModule>;
|
|
4
4
|
export declare function createCredential(publicKeyOptions: PublicKeyCredentialCreationOptions | undefined, additionalOptions: WebauthnCreateRequestOptions): Promise<CreateCredentialResult>;
|
|
5
5
|
export declare function getCredential(publicKeyOptions: PublicKeyCredentialRequestOptions | undefined, additionalOptions: WebauthnGetRequestOptions): Promise<GetCredentialResult>;
|
|
6
|
-
export declare function
|
|
6
|
+
export declare function getListPasskeyAuthorizationStatus(): Promise<PasskeyAuthorizationResult | PasskeyAuthorizationError>;
|
|
7
|
+
export declare function requestListPasskeyAuthorization(): Promise<PasskeyAuthorizationResult | PasskeyAuthorizationError>;
|
|
8
|
+
export declare function listPasskeys(relyingPartyId: string, options?: ListPasskeysOptions): Promise<ListPasskeysResult | ListPasskeysError>;
|
|
7
9
|
export declare function __setMacosLoaderForTesting(loader: MacosLoader | null): void;
|
|
8
10
|
export declare function __setPlatformForTesting(platform: NodeJS.Platform | null): void;
|
package/dist/index.js
CHANGED
|
@@ -12,6 +12,10 @@ const unsupportedListResult = {
|
|
|
12
12
|
success: false,
|
|
13
13
|
error: new Error("electron-webauthn is only available on macOS. Install @electron-webauthn/macos on Darwin hosts."),
|
|
14
14
|
};
|
|
15
|
+
const unsupportedPasskeyAuthorizationResult = {
|
|
16
|
+
success: false,
|
|
17
|
+
error: new Error("electron-webauthn is only available on macOS. Install @electron-webauthn/macos on Darwin hosts."),
|
|
18
|
+
};
|
|
15
19
|
let moduleCache = null;
|
|
16
20
|
let modulePromise = null;
|
|
17
21
|
let platformOverride = null;
|
|
@@ -59,12 +63,26 @@ export async function getCredential(publicKeyOptions, additionalOptions) {
|
|
|
59
63
|
}
|
|
60
64
|
return module.getCredential(publicKeyOptions, additionalOptions);
|
|
61
65
|
}
|
|
62
|
-
export async function
|
|
66
|
+
export async function getListPasskeyAuthorizationStatus() {
|
|
67
|
+
const module = await getMacosModule();
|
|
68
|
+
if (!module) {
|
|
69
|
+
return unsupportedPasskeyAuthorizationResult;
|
|
70
|
+
}
|
|
71
|
+
return module.getListPasskeyAuthorizationStatus();
|
|
72
|
+
}
|
|
73
|
+
export async function requestListPasskeyAuthorization() {
|
|
74
|
+
const module = await getMacosModule();
|
|
75
|
+
if (!module) {
|
|
76
|
+
return unsupportedPasskeyAuthorizationResult;
|
|
77
|
+
}
|
|
78
|
+
return module.requestListPasskeyAuthorization();
|
|
79
|
+
}
|
|
80
|
+
export async function listPasskeys(relyingPartyId, options) {
|
|
63
81
|
const module = await getMacosModule();
|
|
64
82
|
if (!module) {
|
|
65
83
|
return unsupportedListResult;
|
|
66
84
|
}
|
|
67
|
-
return module.listPasskeys(relyingPartyId);
|
|
85
|
+
return module.listPasskeys(relyingPartyId, options);
|
|
68
86
|
}
|
|
69
87
|
export function __setMacosLoaderForTesting(loader) {
|
|
70
88
|
macosLoader = loader ?? defaultLoader;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "electron-webauthn",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"repository": "https://github.com/iamEvanYT/electron-webauthn.git",
|
|
5
5
|
"homepage": "https://github.com/iamEvanYT/electron-webauthn#readme",
|
|
6
6
|
"description": "Cross-platform loader for native WebAuthn support on macOS.",
|
|
@@ -32,12 +32,12 @@
|
|
|
32
32
|
"@types/bun": "latest"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
|
-
"typescript": "^
|
|
35
|
+
"typescript": "^6.0.2"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@electron-webauthn/types": "^1.
|
|
38
|
+
"@electron-webauthn/types": "^1.3.0"
|
|
39
39
|
},
|
|
40
40
|
"optionalDependencies": {
|
|
41
|
-
"@electron-webauthn/macos": "^1.
|
|
41
|
+
"@electron-webauthn/macos": "^1.3.0"
|
|
42
42
|
}
|
|
43
43
|
}
|