electron-webauthn 0.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.
Files changed (5) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +266 -0
  3. package/index.d.ts +68 -0
  4. package/index.js +316 -0
  5. package/package.json +50 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Evan
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,266 @@
1
+ # electron-webauthn
2
+
3
+ A high-performance, cross-platform WebAuthn/Passkey implementation for Electron applications, built with Rust and native platform APIs.
4
+
5
+ ## Overview
6
+
7
+ This library provides seamless WebAuthn (Web Authentication) and Passkey support for Electron applications across multiple platforms. It leverages native platform authenticators including Touch ID, Face ID, Windows Hello, and security keys to deliver a secure and user-friendly authentication experience.
8
+
9
+ ### Key Features
10
+
11
+ - **Native Platform Integration**: Uses platform-specific APIs for optimal performance and security
12
+ - **Cross-Platform Support**: Works on macOS, Windows, and Linux
13
+ - **WebAuthn Level 2 Compliance**: Full support for the latest WebAuthn specifications
14
+ - **Biometric Authentication**: Touch ID, Face ID, Windows Hello, and Apple Watch support
15
+ - **Secure Enclave Integration**: Hardware-backed key storage on supported platforms
16
+ - **TypeScript Support**: Complete type definitions included
17
+
18
+ ## Requirements
19
+
20
+ ### macOS
21
+
22
+ - **macOS 13+ (Ventura or later)** - Required for ASAuthorization framework
23
+ - Touch ID, Face ID, or Apple Watch for biometric authentication
24
+ - Valid code signing certificate for production use
25
+
26
+ ### Windows
27
+
28
+ - **Windows 10 version 1903+ or Windows 11**
29
+ - Windows Hello capable device (fingerprint, face recognition, or PIN)
30
+
31
+ ### Linux
32
+
33
+ - Modern Linux distribution with WebAuthn support
34
+ - Compatible authenticator device
35
+
36
+ ## Installation
37
+
38
+ ```bash
39
+ npm install electron-webauthn
40
+ # or
41
+ yarn add electron-webauthn
42
+ ```
43
+
44
+ ## Usage
45
+
46
+ ### Basic Registration (Creating a Credential)
47
+
48
+ ```typescript
49
+ import { createCredential } from "electron-webauthn";
50
+
51
+ const options = {
52
+ rp: {
53
+ id: "example.com",
54
+ name: "Example Corp",
55
+ },
56
+ user: {
57
+ id: new Uint8Array([1, 2, 3, 4]),
58
+ name: "user@example.com",
59
+ displayName: "John Doe",
60
+ },
61
+ challenge: new Uint8Array(32), // Generate random 32 bytes
62
+ pubKeyCredParams: [
63
+ { type: "public-key", alg: -7 }, // ES256
64
+ { type: "public-key", alg: -257 }, // RS256
65
+ ],
66
+ authenticatorSelection: {
67
+ authenticatorAttachment: "platform",
68
+ userVerification: "required",
69
+ },
70
+ };
71
+
72
+ try {
73
+ const credential = await createCredential(options);
74
+ console.log("Registration successful:", credential);
75
+ } catch (error) {
76
+ console.error("Registration failed:", error);
77
+ }
78
+ ```
79
+
80
+ ### Basic Authentication (Getting a Credential)
81
+
82
+ ```typescript
83
+ import { getCredential } from "electron-webauthn";
84
+
85
+ const options = {
86
+ rpId: "example.com",
87
+ challenge: new Uint8Array(32), // Generate random 32 bytes
88
+ allowCredentials: [
89
+ {
90
+ type: "public-key",
91
+ id: credentialId, // From previous registration
92
+ },
93
+ ],
94
+ userVerification: "required",
95
+ };
96
+
97
+ try {
98
+ const assertion = await getCredential(options);
99
+ console.log("Authentication successful:", assertion);
100
+ } catch (error) {
101
+ console.error("Authentication failed:", error);
102
+ }
103
+ ```
104
+
105
+ ## Platform Support
106
+
107
+ | Platform | Architecture | Status | Notes |
108
+ | -------- | ------------- | ------ | ------------------------------ |
109
+ | macOS | arm64 | ✅ | Native ASAuthorization support |
110
+ | macOS | x64 | ✅ | Native ASAuthorization support |
111
+ | macOS | universal | ✅ | Universal binary |
112
+ | Windows | x64 | ✅ | Windows Hello integration |
113
+ | Windows | arm64 | ✅ | Windows Hello integration |
114
+ | Windows | ia32 | ✅ | Windows Hello integration |
115
+ | Linux | x64 (GNU) | ✅ | Generic WebAuthn support |
116
+ | Linux | x64 (musl) | ✅ | Alpine Linux compatible |
117
+ | Linux | arm64 (GNU) | ✅ | ARM64 Linux support |
118
+ | Linux | arm64 (musl) | ✅ | ARM64 Alpine support |
119
+ | Linux | riscv64 (GNU) | ✅ | RISC-V architecture |
120
+
121
+ ## macOS Entitlements
122
+
123
+ For macOS applications, you need to include the following entitlements in your `entitlements.plist` file:
124
+
125
+ ```xml
126
+ <?xml version="1.0" encoding="UTF-8"?>
127
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
128
+ <plist version="1.0">
129
+ <dict>
130
+ <!-- Required for WebAuthn/Passkey support -->
131
+ <key>com.apple.developer.authentication-services.autofill-credential-provider</key>
132
+ <true/>
133
+
134
+ <!-- Required for platform authenticator access -->
135
+ <key>com.apple.developer.web-browser</key>
136
+ <true/>
137
+
138
+ <!-- Required for Touch ID/Face ID/Apple Watch access -->
139
+ <key>com.apple.security.device.biometry</key>
140
+ <true/>
141
+
142
+ <!-- Required for keychain access -->
143
+ <key>keychain-access-groups</key>
144
+ <array>
145
+ <string>$(AppIdentifierPrefix)com.yourcompany.yourapp</string>
146
+ </array>
147
+
148
+ <!-- Optional: For network requests to verify credentials -->
149
+ <key>com.apple.security.network.client</key>
150
+ <true/>
151
+ </dict>
152
+ </plist>
153
+ ```
154
+
155
+ ### Electron Builder Configuration
156
+
157
+ If using `electron-builder`, add the entitlements to your `package.json`:
158
+
159
+ ```json
160
+ {
161
+ "build": {
162
+ "mac": {
163
+ "entitlements": "build/entitlements.mac.plist",
164
+ "entitlementsInherit": "build/entitlements.mac.plist",
165
+ "hardenedRuntime": true
166
+ }
167
+ }
168
+ }
169
+ ```
170
+
171
+ ## Development
172
+
173
+ ### Prerequisites
174
+
175
+ - Node.js 16+
176
+ - Rust 1.70+
177
+ - Platform-specific build tools:
178
+ - **macOS**: Xcode Command Line Tools
179
+ - **Windows**: Visual Studio Build Tools
180
+ - **Linux**: build-essential
181
+
182
+ ### Building from Source
183
+
184
+ ```bash
185
+ # Clone the repository
186
+ git clone https://github.com/your-org/electron-webauthn.git
187
+ cd electron-webauthn
188
+
189
+ # Install dependencies
190
+ npm install
191
+
192
+ # Build the native module
193
+ npm run build
194
+
195
+ # Run tests
196
+ npm test
197
+ ```
198
+
199
+ ### Architecture
200
+
201
+ This library uses:
202
+
203
+ - **Rust** for high-performance native implementations
204
+ - **NAPI-RS** for seamless Node.js bindings
205
+ - **Platform-specific APIs**:
206
+ - macOS: ASAuthorization framework
207
+ - Windows: Windows Hello APIs
208
+ - Linux: Generic WebAuthn implementation
209
+
210
+ ## Error Handling
211
+
212
+ The library provides detailed error messages for common scenarios:
213
+
214
+ ```typescript
215
+ try {
216
+ const credential = await createCredential(options);
217
+ } catch (error) {
218
+ switch (error.code) {
219
+ case "NotSupportedError":
220
+ console.log("WebAuthn not supported on this platform");
221
+ break;
222
+ case "SecurityError":
223
+ console.log("Security requirements not met");
224
+ break;
225
+ case "NotAllowedError":
226
+ console.log("User cancelled or timeout occurred");
227
+ break;
228
+ default:
229
+ console.log("Unexpected error:", error.message);
230
+ }
231
+ }
232
+ ```
233
+
234
+ ## Security Considerations
235
+
236
+ - Always validate challenges on your server
237
+ - Use HTTPS in production environments
238
+ - Implement proper CORS policies
239
+ - Store credentials securely on your backend
240
+ - Regularly update the library for security patches
241
+
242
+ ## Contributing
243
+
244
+ We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
245
+
246
+ ### Development Setup
247
+
248
+ 1. Fork the repository
249
+ 2. Create a feature branch
250
+ 3. Make your changes
251
+ 4. Add tests for new functionality
252
+ 5. Submit a pull request
253
+
254
+ ## License
255
+
256
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
257
+
258
+ ## Support
259
+
260
+ - **Issues**: [GitHub Issues](https://github.com/your-org/electron-webauthn/issues)
261
+ - **Documentation**: [API Documentation](https://docs.your-org.com/electron-webauthn)
262
+ - **Community**: [Discussions](https://github.com/your-org/electron-webauthn/discussions)
263
+
264
+ ## Changelog
265
+
266
+ See [CHANGELOG.md](CHANGELOG.md) for a detailed history of changes.
package/index.d.ts ADDED
@@ -0,0 +1,68 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ /* auto-generated by NAPI-RS */
5
+
6
+ export interface PublicKeyCredentialRpEntity {
7
+ id?: string | undefined
8
+ name: string
9
+ }
10
+ export interface PublicKeyCredentialUserEntity {
11
+ id: Buffer
12
+ name: string
13
+ displayName: string
14
+ }
15
+ export interface PublicKeyCredentialParameters {
16
+ type: string
17
+ alg: number
18
+ }
19
+ export interface AuthenticatorSelectionCriteria {
20
+ authenticatorAttachment?: string | undefined
21
+ requireResidentKey?: boolean | undefined
22
+ residentKey?: string | undefined
23
+ userVerification?: string | undefined
24
+ }
25
+ export interface PublicKeyCredentialDescriptor {
26
+ type: string
27
+ id: Buffer
28
+ transports?: Array<string> | undefined
29
+ }
30
+ export interface PublicKeyCredentialCreationOptions {
31
+ rp: PublicKeyCredentialRpEntity
32
+ user: PublicKeyCredentialUserEntity
33
+ challenge: Buffer
34
+ pubKeyCredParams: Array<PublicKeyCredentialParameters>
35
+ timeout?: number | undefined
36
+ excludeCredentials?: Array<PublicKeyCredentialDescriptor> | undefined
37
+ authenticatorSelection?: AuthenticatorSelectionCriteria | undefined
38
+ attestation?: string | undefined
39
+ }
40
+ export interface PublicKeyCredentialRequestOptions {
41
+ challenge: Buffer
42
+ timeout?: number | undefined
43
+ rpId?: string | undefined
44
+ allowCredentials?: Array<PublicKeyCredentialDescriptor> | undefined
45
+ userVerification?: string | undefined
46
+ }
47
+ export interface AuthenticatorAttestationResponse {
48
+ clientDataJson: Buffer
49
+ attestationObject: Buffer
50
+ transports: Array<string>
51
+ }
52
+ export interface AuthenticatorAssertionResponse {
53
+ clientDataJson: Buffer
54
+ authenticatorData: Buffer
55
+ signature: Buffer
56
+ userHandle?: Buffer | undefined
57
+ }
58
+ export interface PublicKeyCredential {
59
+ id: string
60
+ rawId: Buffer
61
+ response: AuthenticatorAttestationResponse | AuthenticatorAssertionResponse
62
+ authenticatorAttachment?: string | undefined
63
+ type: string
64
+ }
65
+ /** Create a new WebAuthn credential */
66
+ export declare function create(options: PublicKeyCredentialCreationOptions): PublicKeyCredential
67
+ /** Get/authenticate with an existing WebAuthn credential */
68
+ export declare function get(options: PublicKeyCredentialRequestOptions): PublicKeyCredential
package/index.js ADDED
@@ -0,0 +1,316 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ /* prettier-ignore */
4
+
5
+ /* auto-generated by NAPI-RS */
6
+
7
+ const { existsSync, readFileSync } = require('fs')
8
+ const { join } = require('path')
9
+
10
+ const { platform, arch } = process
11
+
12
+ let nativeBinding = null
13
+ let localFileExisted = false
14
+ let loadError = null
15
+
16
+ function isMusl() {
17
+ // For Node 10
18
+ if (!process.report || typeof process.report.getReport !== 'function') {
19
+ try {
20
+ const lddPath = require('child_process').execSync('which ldd').toString().trim()
21
+ return readFileSync(lddPath, 'utf8').includes('musl')
22
+ } catch (e) {
23
+ return true
24
+ }
25
+ } else {
26
+ const { glibcVersionRuntime } = process.report.getReport().header
27
+ return !glibcVersionRuntime
28
+ }
29
+ }
30
+
31
+ switch (platform) {
32
+ case 'android':
33
+ switch (arch) {
34
+ case 'arm64':
35
+ localFileExisted = existsSync(join(__dirname, 'electron-webauthn.android-arm64.node'))
36
+ try {
37
+ if (localFileExisted) {
38
+ nativeBinding = require('./electron-webauthn.android-arm64.node')
39
+ } else {
40
+ nativeBinding = require('electron-webauthn-android-arm64')
41
+ }
42
+ } catch (e) {
43
+ loadError = e
44
+ }
45
+ break
46
+ case 'arm':
47
+ localFileExisted = existsSync(join(__dirname, 'electron-webauthn.android-arm-eabi.node'))
48
+ try {
49
+ if (localFileExisted) {
50
+ nativeBinding = require('./electron-webauthn.android-arm-eabi.node')
51
+ } else {
52
+ nativeBinding = require('electron-webauthn-android-arm-eabi')
53
+ }
54
+ } catch (e) {
55
+ loadError = e
56
+ }
57
+ break
58
+ default:
59
+ throw new Error(`Unsupported architecture on Android ${arch}`)
60
+ }
61
+ break
62
+ case 'win32':
63
+ switch (arch) {
64
+ case 'x64':
65
+ localFileExisted = existsSync(
66
+ join(__dirname, 'electron-webauthn.win32-x64-msvc.node')
67
+ )
68
+ try {
69
+ if (localFileExisted) {
70
+ nativeBinding = require('./electron-webauthn.win32-x64-msvc.node')
71
+ } else {
72
+ nativeBinding = require('electron-webauthn-win32-x64-msvc')
73
+ }
74
+ } catch (e) {
75
+ loadError = e
76
+ }
77
+ break
78
+ case 'ia32':
79
+ localFileExisted = existsSync(
80
+ join(__dirname, 'electron-webauthn.win32-ia32-msvc.node')
81
+ )
82
+ try {
83
+ if (localFileExisted) {
84
+ nativeBinding = require('./electron-webauthn.win32-ia32-msvc.node')
85
+ } else {
86
+ nativeBinding = require('electron-webauthn-win32-ia32-msvc')
87
+ }
88
+ } catch (e) {
89
+ loadError = e
90
+ }
91
+ break
92
+ case 'arm64':
93
+ localFileExisted = existsSync(
94
+ join(__dirname, 'electron-webauthn.win32-arm64-msvc.node')
95
+ )
96
+ try {
97
+ if (localFileExisted) {
98
+ nativeBinding = require('./electron-webauthn.win32-arm64-msvc.node')
99
+ } else {
100
+ nativeBinding = require('electron-webauthn-win32-arm64-msvc')
101
+ }
102
+ } catch (e) {
103
+ loadError = e
104
+ }
105
+ break
106
+ default:
107
+ throw new Error(`Unsupported architecture on Windows: ${arch}`)
108
+ }
109
+ break
110
+ case 'darwin':
111
+ localFileExisted = existsSync(join(__dirname, 'electron-webauthn.darwin-universal.node'))
112
+ try {
113
+ if (localFileExisted) {
114
+ nativeBinding = require('./electron-webauthn.darwin-universal.node')
115
+ } else {
116
+ nativeBinding = require('electron-webauthn-darwin-universal')
117
+ }
118
+ break
119
+ } catch {}
120
+ switch (arch) {
121
+ case 'x64':
122
+ localFileExisted = existsSync(join(__dirname, 'electron-webauthn.darwin-x64.node'))
123
+ try {
124
+ if (localFileExisted) {
125
+ nativeBinding = require('./electron-webauthn.darwin-x64.node')
126
+ } else {
127
+ nativeBinding = require('electron-webauthn-darwin-x64')
128
+ }
129
+ } catch (e) {
130
+ loadError = e
131
+ }
132
+ break
133
+ case 'arm64':
134
+ localFileExisted = existsSync(
135
+ join(__dirname, 'electron-webauthn.darwin-arm64.node')
136
+ )
137
+ try {
138
+ if (localFileExisted) {
139
+ nativeBinding = require('./electron-webauthn.darwin-arm64.node')
140
+ } else {
141
+ nativeBinding = require('electron-webauthn-darwin-arm64')
142
+ }
143
+ } catch (e) {
144
+ loadError = e
145
+ }
146
+ break
147
+ default:
148
+ throw new Error(`Unsupported architecture on macOS: ${arch}`)
149
+ }
150
+ break
151
+ case 'freebsd':
152
+ if (arch !== 'x64') {
153
+ throw new Error(`Unsupported architecture on FreeBSD: ${arch}`)
154
+ }
155
+ localFileExisted = existsSync(join(__dirname, 'electron-webauthn.freebsd-x64.node'))
156
+ try {
157
+ if (localFileExisted) {
158
+ nativeBinding = require('./electron-webauthn.freebsd-x64.node')
159
+ } else {
160
+ nativeBinding = require('electron-webauthn-freebsd-x64')
161
+ }
162
+ } catch (e) {
163
+ loadError = e
164
+ }
165
+ break
166
+ case 'linux':
167
+ switch (arch) {
168
+ case 'x64':
169
+ if (isMusl()) {
170
+ localFileExisted = existsSync(
171
+ join(__dirname, 'electron-webauthn.linux-x64-musl.node')
172
+ )
173
+ try {
174
+ if (localFileExisted) {
175
+ nativeBinding = require('./electron-webauthn.linux-x64-musl.node')
176
+ } else {
177
+ nativeBinding = require('electron-webauthn-linux-x64-musl')
178
+ }
179
+ } catch (e) {
180
+ loadError = e
181
+ }
182
+ } else {
183
+ localFileExisted = existsSync(
184
+ join(__dirname, 'electron-webauthn.linux-x64-gnu.node')
185
+ )
186
+ try {
187
+ if (localFileExisted) {
188
+ nativeBinding = require('./electron-webauthn.linux-x64-gnu.node')
189
+ } else {
190
+ nativeBinding = require('electron-webauthn-linux-x64-gnu')
191
+ }
192
+ } catch (e) {
193
+ loadError = e
194
+ }
195
+ }
196
+ break
197
+ case 'arm64':
198
+ if (isMusl()) {
199
+ localFileExisted = existsSync(
200
+ join(__dirname, 'electron-webauthn.linux-arm64-musl.node')
201
+ )
202
+ try {
203
+ if (localFileExisted) {
204
+ nativeBinding = require('./electron-webauthn.linux-arm64-musl.node')
205
+ } else {
206
+ nativeBinding = require('electron-webauthn-linux-arm64-musl')
207
+ }
208
+ } catch (e) {
209
+ loadError = e
210
+ }
211
+ } else {
212
+ localFileExisted = existsSync(
213
+ join(__dirname, 'electron-webauthn.linux-arm64-gnu.node')
214
+ )
215
+ try {
216
+ if (localFileExisted) {
217
+ nativeBinding = require('./electron-webauthn.linux-arm64-gnu.node')
218
+ } else {
219
+ nativeBinding = require('electron-webauthn-linux-arm64-gnu')
220
+ }
221
+ } catch (e) {
222
+ loadError = e
223
+ }
224
+ }
225
+ break
226
+ case 'arm':
227
+ if (isMusl()) {
228
+ localFileExisted = existsSync(
229
+ join(__dirname, 'electron-webauthn.linux-arm-musleabihf.node')
230
+ )
231
+ try {
232
+ if (localFileExisted) {
233
+ nativeBinding = require('./electron-webauthn.linux-arm-musleabihf.node')
234
+ } else {
235
+ nativeBinding = require('electron-webauthn-linux-arm-musleabihf')
236
+ }
237
+ } catch (e) {
238
+ loadError = e
239
+ }
240
+ } else {
241
+ localFileExisted = existsSync(
242
+ join(__dirname, 'electron-webauthn.linux-arm-gnueabihf.node')
243
+ )
244
+ try {
245
+ if (localFileExisted) {
246
+ nativeBinding = require('./electron-webauthn.linux-arm-gnueabihf.node')
247
+ } else {
248
+ nativeBinding = require('electron-webauthn-linux-arm-gnueabihf')
249
+ }
250
+ } catch (e) {
251
+ loadError = e
252
+ }
253
+ }
254
+ break
255
+ case 'riscv64':
256
+ if (isMusl()) {
257
+ localFileExisted = existsSync(
258
+ join(__dirname, 'electron-webauthn.linux-riscv64-musl.node')
259
+ )
260
+ try {
261
+ if (localFileExisted) {
262
+ nativeBinding = require('./electron-webauthn.linux-riscv64-musl.node')
263
+ } else {
264
+ nativeBinding = require('electron-webauthn-linux-riscv64-musl')
265
+ }
266
+ } catch (e) {
267
+ loadError = e
268
+ }
269
+ } else {
270
+ localFileExisted = existsSync(
271
+ join(__dirname, 'electron-webauthn.linux-riscv64-gnu.node')
272
+ )
273
+ try {
274
+ if (localFileExisted) {
275
+ nativeBinding = require('./electron-webauthn.linux-riscv64-gnu.node')
276
+ } else {
277
+ nativeBinding = require('electron-webauthn-linux-riscv64-gnu')
278
+ }
279
+ } catch (e) {
280
+ loadError = e
281
+ }
282
+ }
283
+ break
284
+ case 's390x':
285
+ localFileExisted = existsSync(
286
+ join(__dirname, 'electron-webauthn.linux-s390x-gnu.node')
287
+ )
288
+ try {
289
+ if (localFileExisted) {
290
+ nativeBinding = require('./electron-webauthn.linux-s390x-gnu.node')
291
+ } else {
292
+ nativeBinding = require('electron-webauthn-linux-s390x-gnu')
293
+ }
294
+ } catch (e) {
295
+ loadError = e
296
+ }
297
+ break
298
+ default:
299
+ throw new Error(`Unsupported architecture on Linux: ${arch}`)
300
+ }
301
+ break
302
+ default:
303
+ throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`)
304
+ }
305
+
306
+ if (!nativeBinding) {
307
+ if (loadError) {
308
+ throw loadError
309
+ }
310
+ throw new Error(`Failed to load native binding`)
311
+ }
312
+
313
+ const { create, get } = nativeBinding
314
+
315
+ module.exports.create = create
316
+ module.exports.get = get
package/package.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "electron-webauthn",
3
+ "version": "0.0.1",
4
+ "main": "index.js",
5
+ "types": "index.d.ts",
6
+ "napi": {
7
+ "name": "electron-webauthn",
8
+ "triples": {
9
+ "additional": [
10
+ "aarch64-apple-darwin",
11
+ "aarch64-pc-windows-msvc"
12
+ ]
13
+ }
14
+ },
15
+ "license": "MIT",
16
+ "files": [
17
+ "dist",
18
+ "index.d.ts",
19
+ "index.js"
20
+ ],
21
+ "devDependencies": {
22
+ "@napi-rs/cli": "^2.18.4",
23
+ "ava": "^6.0.1"
24
+ },
25
+ "ava": {
26
+ "timeout": "3m"
27
+ },
28
+ "engines": {
29
+ "node": ">= 10"
30
+ },
31
+ "scripts": {
32
+ "artifacts": "napi artifacts",
33
+ "build": "napi build --platform --release",
34
+ "build:debug": "napi build --platform",
35
+ "prepublishOnly": "napi prepublish -t npm",
36
+ "test": "ava",
37
+ "universal": "napi universal",
38
+ "version": "napi version"
39
+ },
40
+ "packageManager": "yarn@4.9.2",
41
+ "repository": "https://github.com/iamEvanYT/electron-webauthn-native",
42
+ "description": "Add support for WebAuthn for Electron.",
43
+ "optionalDependencies": {
44
+ "electron-webauthn-win32-x64-msvc": "0.0.1",
45
+ "electron-webauthn-darwin-x64": "0.0.1",
46
+ "electron-webauthn-linux-x64-gnu": "0.0.1",
47
+ "electron-webauthn-darwin-arm64": "0.0.1",
48
+ "electron-webauthn-win32-arm64-msvc": "0.0.1"
49
+ }
50
+ }