electron-webauthn 1.0.0 → 1.0.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 CHANGED
@@ -28,11 +28,21 @@ This package provides JavaScript bindings to Apple's AuthenticationServices fram
28
28
 
29
29
  ## Installation
30
30
 
31
+ ### Prerequisites
32
+
33
+ - Node.js / Bun
34
+ - Xcode Command Line Tools (Run `xcode-select --install` to install)
35
+ - `pkg-config` from Homebrew (Run `brew install pkgconf` to install)
36
+
37
+ ### Install using npm, bun, pnpm, or yarn
38
+
31
39
  ```bash
32
40
  npm install electron-webauthn
33
41
  # or
34
42
  bun add electron-webauthn
35
43
  # or
44
+ pnpm add electron-webauthn
45
+ # or
36
46
  yarn add electron-webauthn
37
47
  ```
38
48
 
@@ -44,234 +54,15 @@ yarn add electron-webauthn
44
54
 
45
55
  ## Quick Start
46
56
 
47
- > **💡 Drop-in Compatibility:** Simply plug any `publicKeyOptions` from the standard `navigator.credentials.create()` or `navigator.credentials.get()` APIs directly into these functions. They follow the W3C WebAuthn specification exactly.
48
-
49
- ### Creating a Credential (Registration)
50
-
51
- ```typescript
52
- import { createCredential } from "electron-webauthn";
53
- import { BrowserWindow } from "electron";
54
-
55
- // In your Electron main process or preload script
56
- async function register(window: BrowserWindow, challenge: ArrayBuffer) {
57
- // Get the native window handle from your BrowserWindow
58
- const nativeWindowHandle = window.getNativeWindowHandle();
59
-
60
- // Call createCredential with W3C WebAuthn-compliant options
61
- // You can plug any publicKeyOptions from navigator.credentials.create() here
62
- const result = await createCredential(
63
- {
64
- challenge: challenge,
65
- rp: {
66
- name: "Example App",
67
- id: "example.com",
68
- },
69
- user: {
70
- id: new Uint8Array(16), // Random user ID
71
- name: "user@example.com",
72
- displayName: "User Name",
73
- },
74
- pubKeyCredParams: [
75
- { type: "public-key", alg: -7 }, // ES256
76
- { type: "public-key", alg: -257 }, // RS256
77
- ],
78
- timeout: 60000, // Optional: 60 seconds
79
- attestation: "none", // Optional: "none" | "indirect" | "direct"
80
- authenticatorSelection: {
81
- userVerification: "preferred", // Optional: "preferred" | "required" | "discouraged"
82
- residentKey: "preferred", // Optional: "discouraged" | "preferred" | "required"
83
- },
84
- },
85
- {
86
- currentOrigin: "https://example.com",
87
- topFrameOrigin: "https://example.com",
88
- nativeWindowHandle: nativeWindowHandle,
89
- }
90
- );
91
-
92
- if (result.success) {
93
- console.log("Registration successful!");
94
- console.log("Credential ID:", result.data.credentialId);
95
- console.log("Public Key:", result.data.publicKey);
96
- // Result contains base64url-encoded strings ready to send to server
97
- } else {
98
- console.error("Registration failed:", result.error);
99
- }
100
- }
101
- ```
102
-
103
- ### Authenticating with a Credential
104
-
105
- ```typescript
106
- import { getCredential } from "electron-webauthn";
107
- import { BrowserWindow } from "electron";
108
-
109
- // In your Electron main process or preload script
110
- async function authenticate(window: BrowserWindow, challenge: ArrayBuffer) {
111
- // Get the native window handle from your BrowserWindow
112
- const nativeWindowHandle = window.getNativeWindowHandle();
113
-
114
- // Call getCredential with W3C WebAuthn-compliant options
115
- // You can plug any publicKeyOptions from navigator.credentials.get() here
116
- const result = await getCredential(
117
- {
118
- challenge: challenge,
119
- rpId: "example.com",
120
- timeout: 60000, // Optional: 60 seconds
121
- userVerification: "preferred", // Optional: "preferred" | "required" | "discouraged"
122
- allowCredentials: [], // Optional: restrict to specific credentials
123
- },
124
- {
125
- currentOrigin: "https://example.com",
126
- topFrameOrigin: "https://example.com", // Use for iframe support
127
- nativeWindowHandle: nativeWindowHandle,
128
- }
129
- );
130
-
131
- if (result.success) {
132
- console.log("Authentication successful!");
133
- console.log("Credential ID:", result.data.credentialId);
134
- console.log("Signature:", result.data.signature);
135
- // Result contains base64url-encoded strings ready to send to server
136
- } else {
137
- console.error("Authentication failed:", result.error);
138
- }
139
- }
140
- ```
57
+ See the [Quick Start Guide](./docs/quick-start.md) for detailed examples on credential creation and authentication.
141
58
 
142
59
  ## API Reference
143
60
 
144
- ### `createCredential(publicKeyOptions, additionalOptions)`
145
-
146
- Creates and registers a new WebAuthn credential using available platform and cross-platform authenticators.
147
-
148
- **Note:** You can plug any `publicKeyOptions` from the standard `navigator.credentials.create({ publicKey: ... })` directly into this function.
149
-
150
- #### Parameters
151
-
152
- ##### `publicKeyOptions: PublicKeyCredentialCreationOptions`
153
-
154
- Standard W3C WebAuthn credential creation options. See the [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/API/PublicKeyCredentialCreationOptions) for more details.
155
-
156
- ##### `additionalOptions: WebauthnCreateRequestOptions`
157
-
158
- Additional options specific to the Electron environment:
159
-
160
- - **`currentOrigin: string`** (required) - The origin of the requesting document (e.g., "https://example.com")
161
- - **`topFrameOrigin: string | undefined`** - The origin of the top frame (for iframe support). Set to `currentOrigin` if not in an iframe
162
- - **`nativeWindowHandle: Buffer`** (required) - Native window handle from `BrowserWindow.getNativeWindowHandle()`, or a pointer to a NSView object
163
- - **`isPublicSuffix?: (domain: string) => boolean`** - Optional function to check if a domain is a public suffix (e.g., "com", "co.uk"). Strongly recommended for security
164
-
165
- #### Returns
166
-
167
- `Promise<CreateCredentialResult>` - Resolves with the registration result (that you can transform into a `PublicKeyCredential` object) or error
168
-
169
- #### Result Types
170
-
171
- ```typescript
172
- type CreateCredentialResult =
173
- | CreateCredentialSuccessResult
174
- | CreateCredentialErrorResult;
175
-
176
- interface CreateCredentialSuccessResult {
177
- success: true;
178
- data: {
179
- credentialId: string; // Base64url-encoded credential ID
180
- clientDataJSON: string; // Base64url-encoded client data
181
- attestationObject: string; // Base64url-encoded attestation object
182
- authData: string; // Base64url-encoded authenticator data
183
- publicKey: string; // Base64url-encoded public key (COSE format)
184
- publicKeyAlgorithm: number; // COSE algorithm identifier (e.g., -7 for ES256)
185
- transports: string[]; // Available transports (e.g., ["internal", "usb"])
186
- extensions: {
187
- credProps?: {
188
- rk: boolean; // True if credential is a resident key
189
- };
190
- prf?: {
191
- enabled?: boolean; // True if PRF is supported
192
- results?: {
193
- first?: string; // Base64url-encoded PRF output
194
- second?: string; // Base64url-encoded PRF output (if provided)
195
- };
196
- };
197
- largeBlob?: {
198
- supported?: boolean; // True if large blob is supported
199
- };
200
- };
201
- };
202
- }
203
-
204
- interface CreateCredentialErrorResult {
205
- success: false;
206
- error:
207
- | "TypeError"
208
- | "AbortError"
209
- | "NotAllowedError"
210
- | "SecurityError"
211
- | "InvalidStateError";
212
- }
213
- ```
214
-
215
- ### `getCredential(publicKeyOptions, additionalOptions)`
61
+ See the [API Reference](./docs/api-reference.md) for detailed documentation on all available functions and types.
216
62
 
217
- Performs a WebAuthn assertion (authentication) using available platform and cross-platform authenticators.
63
+ ## Advanced Examples
218
64
 
219
- **Note:** You can plug any `publicKeyOptions` from the standard `navigator.credentials.get({ publicKey: ... })` directly into this function.
220
-
221
- #### Parameters
222
-
223
- ##### `publicKeyOptions: PublicKeyCredentialRequestOptions`
224
-
225
- Standard W3C WebAuthn credential request options. See the [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/API/PublicKeyCredentialRequestOptions) for more details.
226
-
227
- ##### `additionalOptions: WebauthnGetRequestOptions`
228
-
229
- Additional options specific to the Electron environment:
230
-
231
- - **`currentOrigin: string`** (required) - The origin of the requesting document (e.g., "https://example.com")
232
- - **`topFrameOrigin: string | undefined`** - The origin of the top frame (for iframe support). Set to `currentOrigin` if not in an iframe
233
- - **`nativeWindowHandle: Buffer`** (required) - Native window handle from `BrowserWindow.getNativeWindowHandle()`, or a pointer to a NSView object
234
- - **`isPublicSuffix?: (domain: string) => boolean`** - Optional function to check if a domain is a public suffix (e.g., "com", "co.uk"). Strongly recommended for security. Use a library like `tldts` for implementation
235
-
236
- #### Returns
237
-
238
- `Promise<GetCredentialResult>` - Resolves with the assertion result (that you can transform into a `PublicKeyCredential` object) or error
239
-
240
- #### Result Types
241
-
242
- ```typescript
243
- type GetCredentialResult =
244
- | GetCredentialSuccessResult
245
- | GetCredentialErrorResult;
246
-
247
- interface GetCredentialSuccessResult {
248
- success: true;
249
- data: {
250
- credentialId: string; // Base64url-encoded credential ID
251
- clientDataJSON: string; // Base64url-encoded client data
252
- authenticatorData: string; // Base64url-encoded authenticator data
253
- signature: string; // Base64url-encoded signature
254
- userHandle: string; // Base64url-encoded user handle
255
- extensions?: {
256
- prf?: {
257
- results?: {
258
- first: string; // Base64url-encoded PRF output
259
- second?: string; // Base64url-encoded PRF output (if provided)
260
- };
261
- };
262
- largeBlob?: {
263
- blob?: string; // Base64url-encoded blob data (if read)
264
- written?: boolean; // True if write succeeded (if write was requested)
265
- };
266
- };
267
- };
268
- }
269
-
270
- interface GetCredentialErrorResult {
271
- success: false;
272
- error: "TypeError" | "AbortError" | "NotAllowedError" | "SecurityError";
273
- }
274
- ```
65
+ See the [Advanced Examples](./docs/advanced-examples.md) for detailed examples on how to use the library with more complex use cases.
275
66
 
276
67
  ## Architecture
277
68
 
@@ -283,417 +74,6 @@ This library implements the W3C WebAuthn standard using Apple's native Authentic
283
74
  - Properly manages WebAuthn extensions (PRF, Large Blob)
284
75
  - Returns base64url-encoded values ready to send to your server for verification
285
76
 
286
- ## Usage Examples
287
-
288
- ### Basic Registration
289
-
290
- ```typescript
291
- import { createCredential } from "electron-webauthn";
292
- import { app, BrowserWindow } from "electron";
293
-
294
- let mainWindow: BrowserWindow;
295
-
296
- app.on("ready", () => {
297
- mainWindow = new BrowserWindow({
298
- width: 800,
299
- height: 600,
300
- webPreferences: {
301
- nodeIntegration: false,
302
- contextIsolation: true,
303
- preload: "./preload.js",
304
- },
305
- });
306
- mainWindow.loadURL("https://myapp.com");
307
- });
308
-
309
- // In your preload script or main process
310
- export async function registerUser(
311
- challenge: ArrayBuffer,
312
- userId: ArrayBuffer,
313
- userName: string,
314
- userDisplayName: string
315
- ) {
316
- const nativeHandle = mainWindow.getNativeWindowHandle();
317
-
318
- const result = await createCredential(
319
- {
320
- challenge: challenge,
321
- rp: {
322
- name: "My App",
323
- id: "myapp.com",
324
- },
325
- user: {
326
- id: userId,
327
- name: userName,
328
- displayName: userDisplayName,
329
- },
330
- pubKeyCredParams: [
331
- { type: "public-key", alg: -7 }, // ES256
332
- { type: "public-key", alg: -257 }, // RS256
333
- ],
334
- authenticatorSelection: {
335
- userVerification: "preferred",
336
- },
337
- },
338
- {
339
- currentOrigin: "https://myapp.com",
340
- topFrameOrigin: "https://myapp.com",
341
- nativeWindowHandle: nativeHandle,
342
- }
343
- );
344
-
345
- return result;
346
- }
347
- ```
348
-
349
- ### Basic Authentication
350
-
351
- ```typescript
352
- import { getCredential } from "electron-webauthn";
353
- import { app, BrowserWindow } from "electron";
354
-
355
- let mainWindow: BrowserWindow;
356
-
357
- app.on("ready", () => {
358
- mainWindow = new BrowserWindow({
359
- width: 800,
360
- height: 600,
361
- webPreferences: {
362
- nodeIntegration: false,
363
- contextIsolation: true,
364
- preload: "./preload.js",
365
- },
366
- });
367
- mainWindow.loadURL("https://myapp.com");
368
- });
369
-
370
- // In your preload script or main process
371
- export async function authenticateUser(challenge: ArrayBuffer) {
372
- const nativeHandle = mainWindow.getNativeWindowHandle();
373
-
374
- const result = await getCredential(
375
- {
376
- challenge: challenge,
377
- rpId: "myapp.com",
378
- userVerification: "preferred",
379
- },
380
- {
381
- currentOrigin: "https://myapp.com",
382
- topFrameOrigin: "https://myapp.com",
383
- nativeWindowHandle: nativeHandle,
384
- }
385
- );
386
-
387
- return result;
388
- }
389
- ```
390
-
391
- ### Restricting to Specific Credentials
392
-
393
- ```typescript
394
- // Only allow specific registered credentials
395
- const result = await getCredential(
396
- {
397
- challenge: challenge,
398
- rpId: "myapp.com",
399
- allowCredentials: [
400
- { type: "public-key", id: credentialId1 },
401
- { type: "public-key", id: credentialId2 },
402
- ],
403
- },
404
- {
405
- currentOrigin: "https://myapp.com",
406
- topFrameOrigin: "https://myapp.com",
407
- nativeWindowHandle: nativeHandle,
408
- }
409
- );
410
- ```
411
-
412
- ### With Required User Verification
413
-
414
- ```typescript
415
- // Require user verification (e.g., for sensitive operations)
416
- const result = await getCredential(
417
- {
418
- challenge: challenge,
419
- rpId: "myapp.com",
420
- userVerification: "required", // Force biometric or PIN
421
- },
422
- {
423
- currentOrigin: "https://myapp.com",
424
- topFrameOrigin: "https://myapp.com",
425
- nativeWindowHandle: nativeHandle,
426
- }
427
- );
428
- ```
429
-
430
- ### Creating Resident Keys (Discoverable Credentials)
431
-
432
- ```typescript
433
- // Create a discoverable credential that can be used without specifying allowCredentials
434
- const result = await createCredential(
435
- {
436
- challenge: challenge,
437
- rp: { name: "My App", id: "myapp.com" },
438
- user: {
439
- id: userId,
440
- name: userName,
441
- displayName: userDisplayName,
442
- },
443
- pubKeyCredParams: [
444
- { type: "public-key", alg: -7 },
445
- { type: "public-key", alg: -257 },
446
- ],
447
- authenticatorSelection: {
448
- residentKey: "required", // Require resident key
449
- userVerification: "required", // Usually combined with resident keys
450
- },
451
- },
452
- {
453
- currentOrigin: "https://myapp.com",
454
- topFrameOrigin: "https://myapp.com",
455
- nativeWindowHandle: nativeHandle,
456
- }
457
- );
458
- ```
459
-
460
- ### Preventing Duplicate Registrations
461
-
462
- ```typescript
463
- // Prevent user from registering the same authenticator multiple times
464
- const result = await createCredential(
465
- {
466
- challenge: challenge,
467
- rp: { name: "My App", id: "myapp.com" },
468
- user: {
469
- id: userId,
470
- name: userName,
471
- displayName: userDisplayName,
472
- },
473
- pubKeyCredParams: [
474
- { type: "public-key", alg: -7 },
475
- { type: "public-key", alg: -257 },
476
- ],
477
- excludeCredentials: [
478
- // List of credentials already registered for this user
479
- { type: "public-key", id: existingCredentialId1 },
480
- { type: "public-key", id: existingCredentialId2 },
481
- ],
482
- },
483
- {
484
- currentOrigin: "https://myapp.com",
485
- topFrameOrigin: "https://myapp.com",
486
- nativeWindowHandle: nativeHandle,
487
- }
488
- );
489
-
490
- // If user tries to use an excluded authenticator, you'll get:
491
- // { success: false, error: "InvalidStateError" }
492
- ```
493
-
494
- ### Creating Credentials with PRF Extension
495
-
496
- ```typescript
497
- // Register a credential with PRF support and immediately evaluate it
498
- const prfSalt = crypto.getRandomValues(new Uint8Array(32));
499
-
500
- const result = await createCredential(
501
- {
502
- challenge: challenge,
503
- rp: { name: "My App", id: "myapp.com" },
504
- user: {
505
- id: userId,
506
- name: userName,
507
- displayName: userDisplayName,
508
- },
509
- pubKeyCredParams: [
510
- { type: "public-key", alg: -7 },
511
- { type: "public-key", alg: -257 },
512
- ],
513
- extensions: {
514
- prf: {
515
- eval: {
516
- first: prfSalt,
517
- },
518
- },
519
- },
520
- },
521
- {
522
- currentOrigin: "https://myapp.com",
523
- topFrameOrigin: "https://myapp.com",
524
- nativeWindowHandle: nativeHandle,
525
- }
526
- );
527
-
528
- if (result.success && result.data.extensions?.prf?.results?.first) {
529
- console.log(
530
- "PRF is supported and evaluated:",
531
- result.data.extensions.prf.results.first
532
- );
533
- // Use this PRF output as an encryption key
534
- }
535
- ```
536
-
537
- ### Using PRF Extension (Authentication)
538
-
539
- The PRF (Pseudo-Random Function) extension allows you to derive cryptographic secrets from credentials:
540
-
541
- ```typescript
542
- // Generate a random salt for PRF
543
- const prfSalt = crypto.getRandomValues(new Uint8Array(32));
544
-
545
- const result = await getCredential(
546
- {
547
- challenge: challenge,
548
- rpId: "myapp.com",
549
- extensions: {
550
- prf: {
551
- eval: {
552
- first: prfSalt,
553
- // second: optionalSecondSalt, // Optional second output
554
- },
555
- },
556
- },
557
- },
558
- {
559
- currentOrigin: "https://myapp.com",
560
- topFrameOrigin: "https://myapp.com",
561
- nativeWindowHandle: nativeHandle,
562
- }
563
- );
564
-
565
- if (result.success && result.data.extensions?.prf?.results) {
566
- const prfOutput = result.data.extensions.prf.results.first;
567
- // Use prfOutput as a cryptographic key for encryption, etc.
568
- console.log("PRF output:", prfOutput);
569
- }
570
- ```
571
-
572
- ### Using PRF with Per-Credential Evaluation
573
-
574
- ```typescript
575
- import { bufferToBase64Url } from "./helpers"; // You'll need to implement this
576
-
577
- const result = await getCredential(
578
- {
579
- challenge: challenge,
580
- rpId: "myapp.com",
581
- allowCredentials: [
582
- { type: "public-key", id: credentialId1 },
583
- { type: "public-key", id: credentialId2 },
584
- ],
585
- extensions: {
586
- prf: {
587
- evalByCredential: {
588
- [bufferToBase64Url(credentialId1)]: {
589
- first: new Uint8Array(32), // Different salt for credential 1
590
- },
591
- [bufferToBase64Url(credentialId2)]: {
592
- first: new Uint8Array(32), // Different salt for credential 2
593
- },
594
- },
595
- },
596
- },
597
- },
598
- {
599
- currentOrigin: "https://myapp.com",
600
- topFrameOrigin: "https://myapp.com",
601
- nativeWindowHandle: nativeHandle,
602
- }
603
- );
604
- ```
605
-
606
- ### Reading and Writing Large Blobs
607
-
608
- ```typescript
609
- // Reading a large blob
610
- const readResult = await getCredential(
611
- {
612
- challenge: challenge,
613
- rpId: "myapp.com",
614
- extensions: {
615
- largeBlob: {
616
- read: true,
617
- },
618
- },
619
- },
620
- {
621
- currentOrigin: "https://myapp.com",
622
- topFrameOrigin: "https://myapp.com",
623
- nativeWindowHandle: nativeHandle,
624
- }
625
- );
626
-
627
- if (readResult.success && readResult.data.extensions?.largeBlob?.blob) {
628
- console.log("Large blob data:", readResult.data.extensions.largeBlob.blob);
629
- }
630
-
631
- // Writing a large blob
632
- const dataToWrite = new TextEncoder().encode("Secret data");
633
- const writeResult = await getCredential(
634
- {
635
- challenge: challenge,
636
- rpId: "myapp.com",
637
- extensions: {
638
- largeBlob: {
639
- write: dataToWrite,
640
- },
641
- },
642
- },
643
- {
644
- currentOrigin: "https://myapp.com",
645
- topFrameOrigin: "https://myapp.com",
646
- nativeWindowHandle: nativeHandle,
647
- }
648
- );
649
-
650
- if (writeResult.success && writeResult.data.extensions?.largeBlob?.written) {
651
- console.log("Large blob written successfully");
652
- }
653
- ```
654
-
655
- ### With Public Suffix List Validation
656
-
657
- For enhanced security, use a public suffix list library like `tldts`:
658
-
659
- ```typescript
660
- import { getPublicSuffix } from "tldts";
661
-
662
- const result = await getCredential(
663
- {
664
- challenge: challenge,
665
- rpId: "myapp.com",
666
- },
667
- {
668
- currentOrigin: "https://myapp.com",
669
- topFrameOrigin: "https://myapp.com",
670
- nativeWindowHandle: nativeHandle,
671
- isPublicSuffix: (domain) => {
672
- const suffix = getPublicSuffix(domain);
673
- return suffix === domain;
674
- },
675
- }
676
- );
677
- ```
678
-
679
- ### Supporting Cross-Origin Iframes
680
-
681
- If your app loads WebAuthn requests from an iframe:
682
-
683
- ```typescript
684
- const result = await getCredential(
685
- {
686
- challenge: challenge,
687
- rpId: "myapp.com",
688
- },
689
- {
690
- currentOrigin: "https://auth.myapp.com", // The iframe's origin
691
- topFrameOrigin: "https://myapp.com", // The parent page's origin
692
- nativeWindowHandle: nativeHandle,
693
- }
694
- );
695
- ```
696
-
697
77
  ## Error Handling
698
78
 
699
79
  Both `createCredential` and `getCredential` functions return a result object with a `success` field. Always check this field:
@@ -778,54 +158,9 @@ console.log("Credential ID:", result.data.credentialId);
778
158
  - ❌ Conditional UI (autofill/conditional mediation)
779
159
  - ❌ Other WebAuthn extensions (credProtect, minPinLength, hmac-secret, etc.)
780
160
 
781
- ## Best Practices
782
-
783
161
  ### Security Recommendations
784
162
 
785
- 1. **Always use HTTPS origins** in production (unless testing on `localhost`)
786
- 2. **Implement public suffix list validation** using `tldts` or similar library
787
- 3. **Validate rpId carefully** - it should match your domain
788
- 4. **Generate strong challenges** - use at least 32 random bytes from a CSPRNG
789
- 5. **Verify assertions on your server** - never trust client-side validation alone
790
- 6. **Store credential public keys securely** - needed for signature verification
791
- 7. **Implement proper timeout handling** - don't leave prompts open indefinitely
792
-
793
- ### Performance Tips
794
-
795
- 1. **Cache native window handles** - no need to get them on every call
796
- 2. **Reuse challenge buffers** when possible
797
- 3. **Set appropriate timeouts** - shorter for better UX, longer for hardware keys
798
- 4. **Handle user cancellation gracefully** - don't retry automatically
799
-
800
- ### TypeScript Types
801
-
802
- This library exports all necessary TypeScript types. Import them for type safety:
803
-
804
- ```typescript
805
- import type {
806
- // Registration types
807
- CreateCredentialResult,
808
- CreateCredentialSuccessData,
809
- PublicKeyCredentialCreationOptions,
810
-
811
- // Authentication types
812
- GetCredentialResult,
813
- GetCredentialSuccessData,
814
- PublicKeyCredentialRequestOptions,
815
-
816
- // Shared types
817
- AuthenticationExtensionsClientInputs,
818
- PRFInput,
819
- } from "electron-webauthn";
820
- ```
821
-
822
- ## Debugging
823
-
824
- Enable detailed logging by checking the console output. The library logs warnings for:
825
-
826
- - PRF extension enabled but no input values provided
827
- - Large blob write enabled but no data provided
828
- - Authorization errors with native error messages
163
+ - **Implement public suffix list validation** using `tldts` or similar library
829
164
 
830
165
  ## Known Limitations
831
166
 
@@ -1,3 +1,4 @@
1
+ export type CreateCredentialErrorCodes = "TypeError" | "AbortError" | "NotAllowedError" | "SecurityError" | "InvalidStateError";
1
2
  export interface CreateCredentialSuccessData {
2
3
  credentialId: string;
3
4
  clientDataJSON: string;
@@ -34,7 +35,7 @@ interface CreateCredentialSuccessResult {
34
35
  }
35
36
  interface CreateCredentialErrorResult {
36
37
  success: false;
37
- error: "TypeError" | "AbortError" | "NotAllowedError" | "SecurityError" | "InvalidStateError";
38
+ error: CreateCredentialErrorCodes;
38
39
  errorObject?: Error;
39
40
  }
40
41
  export type CreateCredentialResult = CreateCredentialSuccessResult | CreateCredentialErrorResult;
@@ -1,3 +1,4 @@
1
+ export type GetCredentialErrorCodes = "TypeError" | "AbortError" | "NotAllowedError" | "SecurityError";
1
2
  export interface GetCredentialSuccessData {
2
3
  credentialId: string;
3
4
  clientDataJSON: string;
@@ -29,7 +30,7 @@ interface GetCredentialSuccessResult {
29
30
  }
30
31
  interface GetCredentialErrorResult {
31
32
  success: false;
32
- error: "TypeError" | "AbortError" | "NotAllowedError" | "SecurityError";
33
+ error: GetCredentialErrorCodes;
33
34
  errorObject?: Error;
34
35
  }
35
36
  export type GetCredentialResult = GetCredentialSuccessResult | GetCredentialErrorResult;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "electron-webauthn",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "repository": "https://github.com/iamEvanYT/electron-webauthn.git",
5
5
  "homepage": "https://github.com/iamEvanYT/electron-webauthn#readme",
6
6
  "description": "Add support for WebAuthn for Electron.",