electron-webauthn 0.0.11 → 0.0.13

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
@@ -15,6 +15,9 @@ This package provides JavaScript bindings to Apple's AuthenticationServices fram
15
15
  - 🔑 Support for cross-platform authenticators (external security keys)
16
16
  - 📦 TypeScript first with complete type definitions
17
17
  - 🎨 Seamless integration with Electron's native window system
18
+ - 🔐 PRF (Pseudo-Random Function) support for credential assertions
19
+ - 💾 Large Blob support for storing credential-specific data
20
+ - ⚙️ User verification preference configuration (preferred, required, discouraged)
18
21
 
19
22
  ## Installation
20
23
 
@@ -49,8 +52,9 @@ async function authenticate() {
49
52
  const result = await getCredential(
50
53
  "example.com", // Relying Party ID
51
54
  Buffer.from("your-challenge"), // Challenge from server
52
- nativeWindowHandle, // Native window for UI presentation
53
- [] // Optional: allowed credential IDs
55
+ "https://example.com", // Origin
56
+ [], // Optional: allowed credential IDs
57
+ "preferred" // Optional: user verification preference
54
58
  );
55
59
 
56
60
  console.log(result);
@@ -61,12 +65,14 @@ async function authenticate() {
61
65
  // - authenticatorData: Authenticator data (Buffer)
62
66
  // - signature: Assertion signature (Buffer)
63
67
  // - userHandle: User handle (Buffer)
68
+ // - prf: [Buffer | null, Buffer | null] - PRF output (if supported)
69
+ // - largeBlob: Buffer | null - Large blob data (if supported)
64
70
  }
65
71
  ```
66
72
 
67
73
  ## API Reference
68
74
 
69
- ### `getCredential(rpid, challenge, nativeWindowHandle, allowedCredentialIds)`
75
+ ### `getCredential(rpid, challenge, origin, allowedCredentialIds, userVerificationPreference)`
70
76
 
71
77
  Performs a WebAuthn assertion (authentication) using available platform and cross-platform authenticators.
72
78
 
@@ -74,8 +80,12 @@ Performs a WebAuthn assertion (authentication) using available platform and cros
74
80
 
75
81
  - **`rpid: string`** - The Relying Party ID (typically your domain)
76
82
  - **`challenge: Buffer`** - The challenge from your server (32+ bytes recommended)
77
- - **`nativeWindowHandle: Buffer`** - The native window handle from Electron
83
+ - **`origin: string`** - The origin where the credential assertion will be used (e.g., "https://example.com")
78
84
  - **`allowedCredentialIds: Buffer[]`** - Optional array of credential IDs the user can use (empty = all registered credentials)
85
+ - **`userVerificationPreference?: UserVerificationPreference`** - Optional preference for user verification. Can be:
86
+ - `"preferred"` - User verification is preferred but not required (default)
87
+ - `"required"` - User verification is required
88
+ - `"discouraged"` - User verification should be discouraged
79
89
 
80
90
  #### Returns
81
91
 
@@ -91,49 +101,20 @@ interface GetCredentialResult {
91
101
  authenticatorData: Buffer; // Authenticator data from the device
92
102
  signature: Buffer; // Digital signature from the authenticator
93
103
  userHandle: Buffer; // User handle from the credential
104
+ prf: [Buffer | null, Buffer | null]; // PRF output (if supported by authenticator)
105
+ largeBlob: Buffer | null; // Large blob data (if supported by authenticator)
94
106
  }
95
107
  ```
96
108
 
97
- ## Architecture
98
-
99
- ### Package Structure
109
+ #### User Verification Preference Type
100
110
 
111
+ ```typescript
112
+ type UserVerificationPreference = "preferred" | "required" | "discouraged";
101
113
  ```
102
- src/
103
- ├── index.ts # Main export - getCredential function
104
- ├── helpers.ts # Utility functions
105
- ├── objc/
106
- │ ├── authentication-services/ # AuthenticationServices framework bindings
107
- │ │ ├── as-authorization-*.ts # Authorization request/response objects
108
- │ │ ├── enums/ # Enumeration values
109
- │ │ └── index.ts # Exports
110
- │ └── foundation/ # Foundation framework bindings
111
- │ ├── nsdata.ts # NSData (binary data) bindings
112
- │ ├── nsstring.ts # NSString bindings
113
- │ ├── nsarray.ts # NSArray bindings
114
- │ ├── nserror.ts # NSError bindings
115
- │ ├── nsview.ts # NSView bindings
116
- │ ├── nswindow.ts # NSWindow bindings
117
- │ └── index.ts # Exports
118
- └── test/ # Test utilities
119
- ├── index.ts # Test script
120
- ├── window.ts # Test window helpers
121
- └── example.ts # Example usage
122
- ```
123
-
124
- ### Dependencies
125
114
 
126
- - **objc-js** - Native Objective-C bindings for JavaScript
127
- - **TypeScript** - For type checking and compilation
128
-
129
- ## How It Works
115
+ ## Architecture
130
116
 
131
- 1. **Request Creation**: The library creates a `ASAuthorizationPlatformPublicKeyCredentialProvider` with your RP ID
132
- 2. **Request Configuration**: Sets up the challenge and optional allowed credentials list
133
- 3. **Controller Setup**: Creates an `ASAuthorizationController` to manage the authentication flow
134
- 4. **Delegation**: Registers delegates to handle success/error responses from the system
135
- 5. **Presentation**: Shows the native authentication UI in your window
136
- 6. **Result Processing**: Converts Objective-C objects to JavaScript Buffers and returns the assertion data
117
+ This library implements the WebAuthn standard using native APIs. Under the hood it handles all the complexity of macOS's authentication system, so you just call `getCredential()` with your challenge and get back the signed assertion.
137
118
 
138
119
  ## Usage Examples
139
120
 
@@ -155,7 +136,7 @@ app.on("ready", () => {
155
136
  // In your preload script or main process
156
137
  export async function authenticateUser(challenge: Buffer) {
157
138
  const nativeHandle = getPointer(mainWindow.getNativeWindowHandle());
158
- return getCredential("myapp.com", challenge, nativeHandle, []);
139
+ return getCredential("myapp.com", challenge, "https://myapp.com", []);
159
140
  }
160
141
  ```
161
142
 
@@ -166,11 +147,43 @@ export async function authenticateUser(challenge: Buffer) {
166
147
  const result = await getCredential(
167
148
  "myapp.com",
168
149
  challenge,
169
- nativeWindowHandle,
150
+ "https://myapp.com",
170
151
  [credentialId1, credentialId2] // User can only use these credentials
171
152
  );
172
153
  ```
173
154
 
155
+ ### With User Verification Requirement
156
+
157
+ ```typescript
158
+ // Require user verification (e.g., for sensitive operations)
159
+ const result = await getCredential(
160
+ "myapp.com",
161
+ challenge,
162
+ "https://myapp.com",
163
+ [], // No credential restrictions
164
+ "required" // Require user verification (biometric or PIN)
165
+ );
166
+ ```
167
+
168
+ ### Using PRF Output
169
+
170
+ ```typescript
171
+ // Get credential with PRF support
172
+ const result = await getCredential(
173
+ "myapp.com",
174
+ challenge,
175
+ "https://myapp.com",
176
+ []
177
+ );
178
+
179
+ // PRF output is available in the result
180
+ const [prfFirst, prfSecond] = result.prf;
181
+ if (prfFirst) {
182
+ // Use PRF output for additional cryptographic operations
183
+ console.log("PRF first output:", prfFirst);
184
+ }
185
+ ```
186
+
174
187
  ### Server-Side Verification
175
188
 
176
189
  After getting the assertion result, verify it on your server:
@@ -197,7 +210,7 @@ try {
197
210
  const result = await getCredential(
198
211
  "example.com",
199
212
  challenge,
200
- nativeWindowHandle,
213
+ "https://example.com",
201
214
  []
202
215
  );
203
216
  } catch (error) {
@@ -206,51 +219,25 @@ try {
206
219
  }
207
220
  ```
208
221
 
209
- ## Platform Support
210
-
211
- | Platform | Support |
212
- | --------- | ---------------- |
213
- | macOS 12+ | ✅ Full support |
214
- | Windows | ❌ Not supported |
215
- | Linux | ❌ Not supported |
216
- | iOS | ❌ Not supported |
217
-
218
- ## WebAuthn Spec Compliance
219
-
220
- This library implements the WebAuthn Level 2 specification for the assertion (authentication) operation:
221
-
222
- - ✅ Public Key Credential (assertions)
223
- - ✅ Platform authenticators (built-in)
224
- - ✅ Cross-platform authenticators (external)
225
- - ❌ Credential registration (create)
226
- - ℹ️ See [WebAuthn Specification](https://www.w3.org/TR/webauthn-2/)
227
-
228
- ## Development
229
-
230
- ### Building
231
-
232
- ```bash
233
- bun run build
234
- ```
235
-
236
- This compiles TypeScript to JavaScript in the `dist/` directory.
222
+ **Supported:**
237
223
 
238
- ## Contributing
224
+ - ✅ WebAuthn assertions (authentication with existing credentials)
225
+ - ✅ Platform authenticators (Touch ID, Face ID)
226
+ - ✅ PRF (Pseudo-Random Function) output
227
+ - ✅ Large Blob support
239
228
 
240
- Contributions are welcome! Please ensure:
229
+ **Not Supported:**
241
230
 
242
- 1. Code is properly typed with TypeScript
243
- 2. New features include appropriate documentation
244
- 3. Tests pass with `bun run test`
245
- 4. Code builds successfully with `bun run build`
231
+ - Cross-platform authenticators (external security keys)
232
+ - Credential registration (attestation)
233
+ - Discoverable credentials
246
234
 
247
235
  ## License
248
236
 
249
237
  See [LICENSE](./LICENSE) file for details.
250
238
 
251
- ## Related Resources
239
+ ## Resources
252
240
 
253
241
  - [WebAuthn Specification](https://www.w3.org/TR/webauthn-2/)
254
- - [Apple AuthenticationServices Documentation](https://developer.apple.com/documentation/authenticationservices)
255
242
  - [Electron Documentation](https://www.electronjs.org/docs)
256
243
  - [objc-js Library](https://github.com/iamEvanYT/objc-js)
@@ -0,0 +1,5 @@
1
+ import { NobjcObject } from "objc-js";
2
+ export declare function setClientDataHash(self: NobjcObject, clientDataHash: Buffer): void;
3
+ export declare function removeClientDataHash(self: NobjcObject): void;
4
+ export declare const WebauthnGetController: NobjcObject;
5
+ //# sourceMappingURL=get-authorization-controller.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-authorization-controller.d.ts","sourceRoot":"","sources":["../src/get-authorization-controller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,WAAW,EAAc,MAAM,SAAS,CAAC;AAS9D,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,QAG1E;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,WAAW,QAGrD;AAED,eAAO,MAAM,qBAAqB,aAiChC,CAAC"}
@@ -0,0 +1,37 @@
1
+ import { NobjcClass, NobjcObject, getPointer } from "objc-js";
2
+ import { NSDataFromBuffer } from "./objc/foundation/nsdata.js";
3
+ const getControllerState = new Map();
4
+ function getObjectPointerString(self) {
5
+ return getPointer(self).toBase64();
6
+ }
7
+ export function setClientDataHash(self, clientDataHash) {
8
+ const selfPointer = getObjectPointerString(self);
9
+ getControllerState.set(selfPointer, clientDataHash);
10
+ }
11
+ export function removeClientDataHash(self) {
12
+ const selfPointer = getObjectPointerString(self);
13
+ getControllerState.delete(selfPointer);
14
+ }
15
+ export const WebauthnGetController = NobjcClass.define({
16
+ name: "WebauthnGetController",
17
+ superclass: "ASAuthorizationController",
18
+ methods: {
19
+ // This overrides the default implementation of _requestContextWithRequests$error$ to allow us to set the clientDataHash on the assertion options
20
+ _requestContextWithRequests$error$: {
21
+ types: "@@:@^@",
22
+ implementation: (self, requests, outError) => {
23
+ const context = NobjcClass.super(self, "_requestContextWithRequests$error$", requests, outError);
24
+ // Grab the assertion options, set the client data hash, and set a copy of the assertion options back on the context
25
+ const selfPointer = getObjectPointerString(self);
26
+ if (getControllerState.has(selfPointer)) {
27
+ const assertionOptions = context.platformKeyCredentialAssertionOptions();
28
+ const clientDataHash = getControllerState.get(selfPointer);
29
+ assertionOptions.setClientDataHash$(NSDataFromBuffer(clientDataHash));
30
+ context.setPlatformKeyCredentialAssertionOptions$(assertionOptions.copyWithZone$(null));
31
+ }
32
+ return context;
33
+ },
34
+ },
35
+ },
36
+ });
37
+ //# sourceMappingURL=get-authorization-controller.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-authorization-controller.js","sourceRoot":"","sources":["../src/get-authorization-controller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAgB,MAAM,6BAA6B,CAAC;AAE7E,MAAM,kBAAkB,GAAG,IAAI,GAAG,EAAkB,CAAC;AAErD,SAAS,sBAAsB,CAAC,IAAiB;IAC/C,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAC;AACrC,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,IAAiB,EAAE,cAAsB;IACzE,MAAM,WAAW,GAAG,sBAAsB,CAAC,IAAI,CAAC,CAAC;IACjD,kBAAkB,CAAC,GAAG,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC;AACtD,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,IAAiB;IACpD,MAAM,WAAW,GAAG,sBAAsB,CAAC,IAAI,CAAC,CAAC;IACjD,kBAAkB,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;AACzC,CAAC;AAED,MAAM,CAAC,MAAM,qBAAqB,GAAG,UAAU,CAAC,MAAM,CAAC;IACrD,IAAI,EAAE,uBAAuB;IAC7B,UAAU,EAAE,2BAA2B;IACvC,OAAO,EAAE;QACP,iJAAiJ;QACjJ,kCAAkC,EAAE;YAClC,KAAK,EAAE,QAAQ;YACf,cAAc,EAAE,CAAC,IAAS,EAAE,QAAa,EAAE,QAAa,EAAE,EAAE;gBAC1D,MAAM,OAAO,GAAG,UAAU,CAAC,KAAK,CAC9B,IAAI,EACJ,oCAAoC,EACpC,QAAQ,EACR,QAAQ,CACT,CAAC;gBAEF,oHAAoH;gBACpH,MAAM,WAAW,GAAG,sBAAsB,CAAC,IAAI,CAAC,CAAC;gBACjD,IAAI,kBAAkB,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC;oBACxC,MAAM,gBAAgB,GACpB,OAAO,CAAC,qCAAqC,EAAE,CAAC;oBAElD,MAAM,cAAc,GAAG,kBAAkB,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;oBAC3D,gBAAgB,CAAC,kBAAkB,CAAC,gBAAgB,CAAC,cAAc,CAAC,CAAC,CAAC;oBAEtE,OAAO,CAAC,yCAAyC,CAC/C,gBAAgB,CAAC,aAAa,CAAC,IAAI,CAAC,CACrC,CAAC;gBACJ,CAAC;gBAED,OAAO,OAAO,CAAC;YACjB,CAAC;SACF;KACF;CACF,CAAC,CAAC"}
package/dist/helpers.d.ts CHANGED
@@ -17,4 +17,30 @@ export declare function PromiseWithResolvers<T = void>(): {
17
17
  resolve: (value: T | PromiseLike<T>) => void;
18
18
  reject: (reason?: unknown) => void;
19
19
  };
20
+ /**
21
+ * WebAuthn: clientDataHash = SHA-256(clientDataJSON_bytes)
22
+ *
23
+ * - Input must be the exact bytes of CollectedClientData JSON (UTF-8).
24
+ * - Output is 32-byte SHA-256 digest.
25
+ */
26
+ export declare function clientDataJsonBufferToHash(clientDataJSON: Buffer): Buffer;
27
+ /**
28
+ * Serializes an origin according to the HTML specification.
29
+ * Based on https://html.spec.whatwg.org/multipage/browsers.html#ascii-serialisation-of-an-origin
30
+ *
31
+ * @param origin - The origin string to serialize (e.g., "https://example.com:8080")
32
+ * @returns The serialized origin string, or "null" for opaque origins
33
+ *
34
+ * @example
35
+ * ```ts
36
+ * serializeOrigin("https://example.com:443"); // "https://example.com:443"
37
+ * serializeOrigin("http://localhost:8080"); // "http://localhost:8080"
38
+ * serializeOrigin("null"); // "null"
39
+ * ```
40
+ */
41
+ export declare function serializeOrigin(origin: string): string | null;
42
+ /**
43
+ * Convert an ArrayBuffer to a base64url string.
44
+ */
45
+ export declare function bufferToBase64Url(buffer: Buffer): string;
20
46
  //# sourceMappingURL=helpers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,GAAG,IAAI,KAAK;IAChD,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IACpB,OAAO,EAAE,CAAC,KAAK,EAAE,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;IAC7C,MAAM,EAAE,CAAC,MAAM,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;CACpC,CAQA"}
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,GAAG,IAAI,KAAK;IAChD,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IACpB,OAAO,EAAE,CAAC,KAAK,EAAE,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;IAC7C,MAAM,EAAE,CAAC,MAAM,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;CACpC,CAQA;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM,CAWzE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CA+B7D;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAWxD"}
package/dist/helpers.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { createHash } from "crypto";
1
2
  /**
2
3
  * Creates a Promise along with its resolve and reject callbacks.
3
4
  * This is a polyfill for the native Promise.withResolvers() method.
@@ -21,4 +22,74 @@ export function PromiseWithResolvers() {
21
22
  });
22
23
  return { promise, resolve: resolve, reject: reject };
23
24
  }
25
+ /**
26
+ * WebAuthn: clientDataHash = SHA-256(clientDataJSON_bytes)
27
+ *
28
+ * - Input must be the exact bytes of CollectedClientData JSON (UTF-8).
29
+ * - Output is 32-byte SHA-256 digest.
30
+ */
31
+ export function clientDataJsonBufferToHash(clientDataJSON) {
32
+ if (!Buffer.isBuffer(clientDataJSON)) {
33
+ throw new TypeError("clientDataJsonBufferToHash: clientDataJSON must be a Buffer");
34
+ }
35
+ if (clientDataJSON.length === 0) {
36
+ throw new RangeError("clientDataJsonBufferToHash: clientDataJSON is empty");
37
+ }
38
+ return createHash("sha256").update(clientDataJSON).digest();
39
+ }
40
+ /**
41
+ * Serializes an origin according to the HTML specification.
42
+ * Based on https://html.spec.whatwg.org/multipage/browsers.html#ascii-serialisation-of-an-origin
43
+ *
44
+ * @param origin - The origin string to serialize (e.g., "https://example.com:8080")
45
+ * @returns The serialized origin string, or "null" for opaque origins
46
+ *
47
+ * @example
48
+ * ```ts
49
+ * serializeOrigin("https://example.com:443"); // "https://example.com:443"
50
+ * serializeOrigin("http://localhost:8080"); // "http://localhost:8080"
51
+ * serializeOrigin("null"); // "null"
52
+ * ```
53
+ */
54
+ export function serializeOrigin(origin) {
55
+ // If origin is an opaque origin (represented as "null"), return "null"
56
+ if (origin === "null" || !origin) {
57
+ return null;
58
+ }
59
+ try {
60
+ // Parse the origin using URL constructor
61
+ const url = new URL(origin);
62
+ // Build the serialized origin
63
+ let result = url.protocol; // Already includes "://"
64
+ // If protocol doesn't end with "://", ensure it's added
65
+ if (!result.endsWith("://")) {
66
+ result = result.replace(/:$/, "") + "://";
67
+ }
68
+ // Append the host (already serialized by URL)
69
+ result += url.hostname;
70
+ // If port is non-null and non-default, append it
71
+ if (url.port) {
72
+ result += ":" + url.port;
73
+ }
74
+ return result;
75
+ }
76
+ catch (error) {
77
+ // If URL parsing fails, treat as opaque origin
78
+ return null;
79
+ }
80
+ }
81
+ /**
82
+ * Convert an ArrayBuffer to a base64url string.
83
+ */
84
+ export function bufferToBase64Url(buffer) {
85
+ const bytes = new Uint8Array(buffer);
86
+ let binary = "";
87
+ for (let i = 0; i < bytes.length; i++) {
88
+ binary += String.fromCharCode(bytes[i]);
89
+ }
90
+ return btoa(binary)
91
+ .replace(/\+/g, "-")
92
+ .replace(/\//g, "_")
93
+ .replace(/=+$/, "");
94
+ }
24
95
  //# sourceMappingURL=helpers.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,oBAAoB;IAKlC,IAAI,OAA4C,CAAC;IACjD,IAAI,MAAkC,CAAC;IACvC,MAAM,OAAO,GAAG,IAAI,OAAO,CAAI,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;QAC1C,OAAO,GAAG,GAAG,CAAC;QACd,MAAM,GAAG,GAAG,CAAC;IACf,CAAC,CAAC,CAAC;IACH,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAQ,EAAE,MAAM,EAAE,MAAO,EAAE,CAAC;AACzD,CAAC"}
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEpC;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,oBAAoB;IAKlC,IAAI,OAA4C,CAAC;IACjD,IAAI,MAAkC,CAAC;IACvC,MAA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AC;QAEvB,iDAAiD;QACjD,IAAI,GAAG,CAAC,IAAI,EAAE,CAAC;YACb,MAAM,IAAI,GAAG,GAAG,GAAG,CAAC,IAAI,CAAC;QAC3B,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,+CAA+C;QAC/C,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAAc;IAC9C,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC;IACrC,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACtC,MAAM,IAAI,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1C,CAAC;IAED,OAAO,IAAI,CAAC,MAAM,CAAC;SAChB,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;SACnB,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;SACnB,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AACxB,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  type AuthenticatorAttachment = "platform" | "cross-platform";
2
+ export type UserVerificationPreference = "preferred" | "required" | "discouraged";
2
3
  export interface GetCredentialResult {
3
4
  id: Buffer;
4
5
  authenticatorAttachment: AuthenticatorAttachment;
@@ -6,9 +7,9 @@ export interface GetCredentialResult {
6
7
  authenticatorData: Buffer;
7
8
  signature: Buffer;
8
9
  userHandle: Buffer;
9
- prf: [Buffer, Buffer];
10
- largeBlob: Buffer;
10
+ prf: [Buffer | null, Buffer | null];
11
+ largeBlob: Buffer | null;
11
12
  }
12
- declare function getCredential(rpid: string, challenge: Buffer, nativeWindowHandle: Buffer, allowedCredentialIds: Buffer[]): Promise<GetCredentialResult>;
13
+ declare function getCredential(rpid: string, challenge: Buffer, nativeWindowHandle: Buffer, origin: string, allowedCredentialIds: Buffer[], userVerificationPreference?: UserVerificationPreference): Promise<GetCredentialResult>;
13
14
  export { getCredential };
14
15
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAoBA,KAAK,uBAAuB,GAAG,UAAU,GAAG,gBAAgB,CAAC;AAE7D,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,uBAAuB,EAAE,uBAAuB,CAAC;IACjD,cAAc,EAAE,MAAM,CAAC;IACvB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,GAAG,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,iBAAS,aAAa,CACpB,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,EACjB,kBAAkB,EAAE,MAAM,EAC1B,oBAAoB,EAAE,MAAM,EAAE,GAC7B,OAAO,CAAC,mBAAmB,CAAC,CAiG9B;AAED,OAAO,EAAE,aAAa,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AA8BA,KAAK,uBAAuB,GAAG,UAAU,GAAG,gBAAgB,CAAC;AAC7D,MAAM,MAAM,0BAA0B,GAClC,WAAW,GACX,UAAU,GACV,aAAa,CAAC;AAElB,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,uBAAuB,EAAE,uBAAuB,CAAC;IACjD,cAAc,EAAE,MAAM,CAAC;IACvB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,GAAG,EAAE,CAAC,MAAM,GAAG,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC;IACpC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAED,iBAAS,aAAa,CACpB,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,EACjB,kBAAkB,EAAE,MAAM,EAC1B,MAAM,EAAE,MAAM,EACd,oBAAoB,EAAE,MAAM,EAAE,EAC9B,0BAA0B,CAAC,EAAE,0BAA0B,GACtD,OAAO,CAAC,mBAAmB,CAAC,CA6I9B;AAED,OAAO,EAAE,aAAa,EAAE,CAAC"}
package/dist/index.js CHANGED
@@ -1,15 +1,16 @@
1
1
  import { fromPointer } from "objc-js";
2
2
  import { createAuthorizationControllerDelegate } from "./objc/authentication-services/as-authorization-controller-delegate.js";
3
- import { createAuthorizationController } from "./objc/authentication-services/as-authorization-controller.js";
3
+ import { ASAuthorizationController } from "./objc/authentication-services/as-authorization-controller.js";
4
4
  import { createPresentationContextProvider } from "./objc/authentication-services/as-authorization-controller-presentation-context-providing.js";
5
5
  import { createPlatformPublicKeyCredentialProvider } from "./objc/authentication-services/as-authorization-platform-public-key-credential-provider.js";
6
6
  import { createPlatformPublicKeyCredentialDescriptor } from "./objc/authentication-services/as-authorization-platform-public-key-credential-descriptor.js";
7
7
  import { NSArray, NSArrayFromObjects } from "./objc/foundation/nsarray.js";
8
8
  import { bufferFromNSDataDirect, NSDataFromBuffer, } from "./objc/foundation/nsdata.js";
9
9
  import { NSStringFromString } from "./objc/foundation/nsstring.js";
10
- import { PromiseWithResolvers } from "./helpers.js";
10
+ import { bufferToBase64Url, clientDataJsonBufferToHash, PromiseWithResolvers, serializeOrigin, } from "./helpers.js";
11
11
  import { ASAuthorizationPublicKeyCredentialAttachment } from "./objc/authentication-services/enums/as-authorization-public-key-credential-attachment.js";
12
- function getCredential(rpid, challenge, nativeWindowHandle, allowedCredentialIds) {
12
+ import { removeClientDataHash, setClientDataHash, WebauthnGetController, } from "./get-authorization-controller.js";
13
+ function getCredential(rpid, challenge, nativeWindowHandle, origin, allowedCredentialIds, userVerificationPreference) {
13
14
  const { promise, resolve, reject } = PromiseWithResolvers();
14
15
  // Create NS objects
15
16
  const NS_rpID = NSStringFromString(rpid);
@@ -19,9 +20,36 @@ function getCredential(rpid, challenge, nativeWindowHandle, allowedCredentialIds
19
20
  const platformProvider = createPlatformPublicKeyCredentialProvider(NS_rpID);
20
21
  // let platformKeyRequest = platformProvider.createCredentialAssertionRequest(challenge: challenge)
21
22
  const platformKeyRequest = platformProvider.createCredentialAssertionRequestWithChallenge$(NS_challenge);
23
+ // platformKeyRequest.userVerificationPreference = ???
24
+ if (userVerificationPreference === "preferred") {
25
+ platformKeyRequest.setUserVerificationPreference$(NSStringFromString("preferred"));
26
+ }
27
+ else if (userVerificationPreference === "required") {
28
+ platformKeyRequest.setUserVerificationPreference$(NSStringFromString("required"));
29
+ }
30
+ else if (userVerificationPreference === "discouraged") {
31
+ platformKeyRequest.setUserVerificationPreference$(NSStringFromString("discouraged"));
32
+ }
22
33
  // let authController = ASAuthorizationController(authorizationRequests: [platformKeyRequest])
23
34
  const requestsArray = NSArray.arrayWithObject$(platformKeyRequest);
24
- const authController = createAuthorizationController(requestsArray);
35
+ const authController = WebauthnGetController.alloc().initWithAuthorizationRequests$(requestsArray);
36
+ // OLD: const authController = createAuthorizationController(requestsArray);
37
+ // Generate our own client data instead of letting apple generate it
38
+ // This is because apple's client data lack the `crossOrigin` field, which is required by a lot of sites.
39
+ const serializedOrigin = serializeOrigin(origin);
40
+ const clientData = {
41
+ type: "webauthn.get",
42
+ challenge: bufferToBase64Url(challenge),
43
+ origin: serializedOrigin,
44
+ crossOrigin: false,
45
+ };
46
+ const clientDataJSON = JSON.stringify(clientData);
47
+ const clientDataBuffer = Buffer.from(clientDataJSON, "utf-8");
48
+ const clientDataHash = clientDataJsonBufferToHash(clientDataBuffer);
49
+ setClientDataHash(authController, clientDataHash);
50
+ const finished = (_success) => {
51
+ removeClientDataHash(authController);
52
+ };
25
53
  // Set allowed credentials if provided
26
54
  if (allowedCredentialIds.length > 0) {
27
55
  const allowedCredentials = NSArrayFromObjects(allowedCredentialIds.map((id) => createPlatformPublicKeyCredentialDescriptor(NSDataFromBuffer(id))));
@@ -32,7 +60,7 @@ function getCredential(rpid, challenge, nativeWindowHandle, allowedCredentialIds
32
60
  didCompleteWithAuthorization: (_, authorization) => {
33
61
  // Cast to _ASAuthorization to access typed methods
34
62
  const credential = authorization.credential();
35
- console.log("Authorization succeeded:", credential);
63
+ // console.log("Authorization succeeded:", credential);
36
64
  const id_data = credential.credentialID();
37
65
  const id = bufferFromNSDataDirect(id_data);
38
66
  let authenticatorAttachment = "platform";
@@ -41,28 +69,32 @@ function getCredential(rpid, challenge, nativeWindowHandle, allowedCredentialIds
41
69
  authenticatorAttachment = "cross-platform";
42
70
  }
43
71
  const prf = credential.prf();
44
- const prfFirst = prf.first();
45
- const prfSecond = prf.second();
72
+ const prfFirst = prf?.first ? prf.first() : null;
73
+ const prfSecond = prf?.second ? prf.second() : null;
46
74
  resolve({
47
75
  id,
48
76
  authenticatorAttachment,
49
- clientDataJSON: bufferFromNSDataDirect(credential.rawClientDataJSON()),
77
+ clientDataJSON: clientDataBuffer, //bufferFromNSDataDirect(credential.rawClientDataJSON()),
50
78
  authenticatorData: bufferFromNSDataDirect(credential.rawAuthenticatorData()),
51
79
  signature: bufferFromNSDataDirect(credential.signature()),
52
80
  userHandle: bufferFromNSDataDirect(credential.userID()),
53
81
  prf: [
54
- bufferFromNSDataDirect(prfFirst),
55
- bufferFromNSDataDirect(prfSecond),
82
+ prfFirst ? bufferFromNSDataDirect(prfFirst) : null,
83
+ prfSecond ? bufferFromNSDataDirect(prfSecond) : null,
56
84
  ],
57
- largeBlob: bufferFromNSDataDirect(credential.largeBlob().readData()),
85
+ largeBlob: credential.largeBlob()
86
+ ? bufferFromNSDataDirect(credential.largeBlob().readData())
87
+ : null,
58
88
  });
89
+ finished(true);
59
90
  },
60
91
  didCompleteWithError: (_, error) => {
61
92
  // Parse the NSError into a readable format
62
93
  const parsedError = error;
63
94
  const errorMessage = parsedError.localizedDescription().UTF8String();
64
- console.error("Authorization failed:", errorMessage);
95
+ // console.error("Authorization failed:", errorMessage);
65
96
  reject(new Error(errorMessage));
97
+ finished(false);
66
98
  },
67
99
  });
68
100
  authController.setDelegate$(delegate);
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAAE,qCAAqC,EAAE,MAAM,wEAAwE,CAAC;AAC/H,OAAO,EAAE,6BAA6B,EAAE,MAAM,+DAA+D,CAAC;AAC9G,OAAO,EAAE,iCAAiC,EAAE,MAAM,8FAA8F,CAAC;AACjJ,OAAO,EAAE,yCAAyC,EAAE,MAAM,4FAA4F,CAAC;AACvJ,OAAO,EAAE,2CAA2C,EAAE,MAAM,8FAA8F,CAAC;AAG3J,OAAO,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAC3E,OAAO,EAEL,sBAAsB,EACtB,gBAAgB,GACjB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAGnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,4CAA4C,EAAE,MAAM,2FAA2F,CAAC;AAezJ,SAAS,aAAa,CACpB,IAAY,EACZ,SAAiB,EACjB,kBAA0B,EAC1B,oBAA8B;IAE9B,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,GAChC,oBAAoB,EAAuB,CAAC;IAE9C,oBAAoB;IACpB,MAAM,OAAO,GAAG,kBAAkB,CAAC,IAAI,CAAC,CAAC;IAEzC,sDAAsD;IACtD,MAAM,YAAY,GAAG,gBAAgB,CAAC,SAAS,CAAC,CAAC;IA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AC,kBAAkB,CAAuB,CAAC;YACrE,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC;YACjC,OAAO,QAAQ,CAAC;QAClB,CAAC;KACF,CAAC,CAAC;IACH,cAAc,CAAC,+BAA+B,CAAC,2BAA2B,CAAC,CAAC;IAE5E,mCAAmC;IACnC,cAAc,CAAC,eAAe,EAAE,CAAC;IAEjC,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,OAAO,EAAE,aAAa,EAAE,CAAC"}
@@ -4,6 +4,6 @@ import { getCredential } from "../index.js";
4
4
  const window = createEmptyWindow();
5
5
  const nsView = getNativeWindowHandle(window);
6
6
  const nsViewPointer = getPointer(nsView);
7
- const result = getCredential("example.com", Buffer.from("challenge"), nsViewPointer, []);
7
+ const result = getCredential("example.com", Buffer.from("challenge"), nsViewPointer, "https://example.com", []);
8
8
  console.log("Result:", result);
9
9
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/test/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,MAAM,GAAG,iBAAiB,EAAE,CAAC;AACnC,MAAM,MAAM,GAAG,qBAAqB,CAAC,MAAM,CAAC,CAAC;AAC7C,MAAM,aAAa,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC;AAEzC,MAAM,MAAM,GAAG,aAAa,CAC1B,aAAa,EACb,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,EACxB,aAAa,EACb,EAAE,CACH,CAAC;AACF,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/test/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,MAAM,GAAG,iBAAiB,EAAE,CAAC;AACnC,MAAM,MAAM,GAAG,qBAAqB,CAAC,MAAM,CAAC,CAAC;AAC7C,MAAM,aAAa,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC;AAEzC,MAAM,MAAM,GAAG,aAAa,CAC1B,aAAa,EACb,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,EACxB,aAAa,EACb,qBAAqB,EACrB,EAAE,CACH,CAAC;AACF,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "electron-webauthn",
3
- "version": "0.0.11",
3
+ "version": "0.0.13",
4
4
  "repository": "https://github.com/iamEvanYT/electron-webauthn",
5
5
  "description": "Add support for WebAuthn for Electron.",
6
6
  "main": "dist/index.js",
@@ -28,7 +28,7 @@
28
28
  "typescript": "^5"
29
29
  },
30
30
  "dependencies": {
31
- "objc-js": "^0.0.13"
31
+ "objc-js": "^0.0.14"
32
32
  },
33
33
  "trustedDependencies": [
34
34
  "objc-js"