@clerk/electron-passkeys 0.0.1-snapshot.v20260617204522
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/LICENSE +21 -0
- package/README.md +39 -0
- package/index.d.ts +20 -0
- package/index.js +63 -0
- package/package.json +60 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Clerk Inc
|
|
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,39 @@
|
|
|
1
|
+
# @clerk/electron-passkeys
|
|
2
|
+
|
|
3
|
+
Native passkey (WebAuthn) support for [`@clerk/electron`](https://github.com/clerk/javascript/tree/main/packages/electron), used when an Electron window loads a local bundle (`file://` or a custom protocol) and the renderer's built-in WebAuthn cannot satisfy the RP ID's origin checks.
|
|
4
|
+
|
|
5
|
+
> [!WARNING]
|
|
6
|
+
> This package is under active development and is not yet ready for production use.
|
|
7
|
+
|
|
8
|
+
This package is a napi-rs native module loaded in the Electron **main** process by `createClerkBridge({ passkeys: true })` from `@clerk/electron`. You should not need to call it directly.
|
|
9
|
+
|
|
10
|
+
| Platform | Backend | Authenticators |
|
|
11
|
+
| ---------------- | ---------------------------------------------------- | ---------------------------------------- |
|
|
12
|
+
| macOS 12+ | AuthenticationServices (`ASAuthorizationController`) | Touch ID, iCloud Keychain, security keys |
|
|
13
|
+
| Windows 10 1903+ | `webauthn.dll` (Windows WebAuthn API) | Windows Hello, security keys |
|
|
14
|
+
| Linux | — | Not supported (use renderer WebAuthn) |
|
|
15
|
+
|
|
16
|
+
Prebuilt binaries ship as per-platform optional dependencies (`@clerk/electron-passkeys-darwin-arm64`, `-darwin-x64`, `-win32-x64-msvc`, `-win32-arm64-msvc`).
|
|
17
|
+
|
|
18
|
+
## API
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
isAvailable(): boolean;
|
|
22
|
+
capabilities(): { platformAuthenticator: boolean; securityKeys: boolean };
|
|
23
|
+
createCredential(windowHandle: Buffer, optionsJson: string): Promise<string>;
|
|
24
|
+
getCredential(windowHandle: Buffer, optionsJson: string): Promise<string>;
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
`createCredential`/`getCredential` take the window handle from `BrowserWindow#getNativeWindowHandle()` (to anchor the OS dialog) and JSON-encoded WebAuthn options with base64url binary fields. They always resolve with a JSON envelope — `{ ok: true, credential }` or `{ ok: false, error: { code, message } }` with `code` one of `cancelled | invalid_rp | not_supported | timeout | unknown` — and never reject for ceremony failures.
|
|
28
|
+
|
|
29
|
+
## Building from source
|
|
30
|
+
|
|
31
|
+
Requires a Rust toolchain.
|
|
32
|
+
|
|
33
|
+
```sh
|
|
34
|
+
pnpm --filter @clerk/electron-passkeys build
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## License
|
|
38
|
+
|
|
39
|
+
MIT — see [LICENSE](https://github.com/clerk/javascript/blob/main/packages/electron/LICENSE).
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** Whether this platform has a native passkey backend. */
|
|
2
|
+
export function isAvailable(): boolean;
|
|
3
|
+
|
|
4
|
+
export function capabilities(): {
|
|
5
|
+
platformAuthenticator: boolean;
|
|
6
|
+
securityKeys: boolean;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Runs a WebAuthn registration ceremony.
|
|
11
|
+
* `windowHandle` anchors the OS dialog; `optionsJson` is the serialized public key options.
|
|
12
|
+
* Resolves with a JSON result envelope.
|
|
13
|
+
*/
|
|
14
|
+
export function createCredential(windowHandle: Buffer, optionsJson: string): Promise<string>;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Runs a WebAuthn authentication ceremony.
|
|
18
|
+
* Resolves with a JSON result envelope.
|
|
19
|
+
*/
|
|
20
|
+
export function getCredential(windowHandle: Buffer, optionsJson: string): Promise<string>;
|
package/index.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
const { existsSync } = require('node:fs');
|
|
2
|
+
const { join } = require('node:path');
|
|
3
|
+
|
|
4
|
+
const PLATFORM_PACKAGES = {
|
|
5
|
+
'darwin-arm64': '@clerk/electron-passkeys-darwin-arm64',
|
|
6
|
+
'darwin-x64': '@clerk/electron-passkeys-darwin-x64',
|
|
7
|
+
'win32-arm64': '@clerk/electron-passkeys-win32-arm64-msvc',
|
|
8
|
+
'win32-x64': '@clerk/electron-passkeys-win32-x64-msvc',
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
function loadNative() {
|
|
12
|
+
const key = `${process.platform}-${process.arch}`;
|
|
13
|
+
|
|
14
|
+
// Local napi builds land next to this file; napi appends the ABI to the
|
|
15
|
+
// filename on Windows (e.g. electron-passkeys.win32-x64-msvc.node).
|
|
16
|
+
const localKey = process.platform === 'win32' ? `${key}-msvc` : key;
|
|
17
|
+
const localBinary = join(__dirname, `electron-passkeys.${localKey}.node`);
|
|
18
|
+
if (existsSync(localBinary)) {
|
|
19
|
+
return require(localBinary);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const platformPackage = PLATFORM_PACKAGES[key];
|
|
23
|
+
if (platformPackage) {
|
|
24
|
+
try {
|
|
25
|
+
return require(platformPackage);
|
|
26
|
+
} catch {
|
|
27
|
+
// Missing or unloadable optional package: report unsupported.
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const native = loadNative();
|
|
34
|
+
|
|
35
|
+
const notSupportedResult = () =>
|
|
36
|
+
JSON.stringify({
|
|
37
|
+
ok: false,
|
|
38
|
+
error: { code: 'not_supported', message: 'Native passkeys are not supported on this platform.' },
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
module.exports = {
|
|
42
|
+
isAvailable() {
|
|
43
|
+
return !!native && native.isAvailable();
|
|
44
|
+
},
|
|
45
|
+
capabilities() {
|
|
46
|
+
if (!native || !native.isAvailable()) {
|
|
47
|
+
return { platformAuthenticator: false, securityKeys: false };
|
|
48
|
+
}
|
|
49
|
+
return native.capabilities();
|
|
50
|
+
},
|
|
51
|
+
createCredential(windowHandle, optionsJson) {
|
|
52
|
+
if (!native || !native.isAvailable()) {
|
|
53
|
+
return Promise.resolve(notSupportedResult());
|
|
54
|
+
}
|
|
55
|
+
return native.createCredential(windowHandle, optionsJson);
|
|
56
|
+
},
|
|
57
|
+
getCredential(windowHandle, optionsJson) {
|
|
58
|
+
if (!native || !native.isAvailable()) {
|
|
59
|
+
return Promise.resolve(notSupportedResult());
|
|
60
|
+
}
|
|
61
|
+
return native.getCredential(windowHandle, optionsJson);
|
|
62
|
+
},
|
|
63
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@clerk/electron-passkeys",
|
|
3
|
+
"version": "0.0.1-snapshot.v20260617204522",
|
|
4
|
+
"description": "Native passkey (WebAuthn) support for Clerk's Electron SDK",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"clerk",
|
|
7
|
+
"electron",
|
|
8
|
+
"passkeys",
|
|
9
|
+
"webauthn",
|
|
10
|
+
"auth",
|
|
11
|
+
"authentication"
|
|
12
|
+
],
|
|
13
|
+
"homepage": "https://clerk.com/",
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/clerk/javascript/issues"
|
|
16
|
+
},
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://github.com/clerk/javascript.git",
|
|
20
|
+
"directory": "packages/electron-passkeys"
|
|
21
|
+
},
|
|
22
|
+
"license": "MIT",
|
|
23
|
+
"author": "Clerk",
|
|
24
|
+
"main": "index.js",
|
|
25
|
+
"types": "index.d.ts",
|
|
26
|
+
"files": [
|
|
27
|
+
"index.js",
|
|
28
|
+
"index.d.ts"
|
|
29
|
+
],
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@napi-rs/cli": "^3.0.0"
|
|
32
|
+
},
|
|
33
|
+
"optionalDependencies": {
|
|
34
|
+
"@clerk/electron-passkeys-darwin-arm64": "0.0.0",
|
|
35
|
+
"@clerk/electron-passkeys-darwin-x64": "0.0.0",
|
|
36
|
+
"@clerk/electron-passkeys-win32-arm64-msvc": "0.0.0",
|
|
37
|
+
"@clerk/electron-passkeys-win32-x64-msvc": "0.0.0"
|
|
38
|
+
},
|
|
39
|
+
"engines": {
|
|
40
|
+
"node": ">=24.15.0"
|
|
41
|
+
},
|
|
42
|
+
"publishConfig": {
|
|
43
|
+
"access": "public"
|
|
44
|
+
},
|
|
45
|
+
"napi": {
|
|
46
|
+
"binaryName": "electron-passkeys",
|
|
47
|
+
"targets": [
|
|
48
|
+
"aarch64-apple-darwin",
|
|
49
|
+
"x86_64-apple-darwin",
|
|
50
|
+
"x86_64-pc-windows-msvc",
|
|
51
|
+
"aarch64-pc-windows-msvc"
|
|
52
|
+
]
|
|
53
|
+
},
|
|
54
|
+
"scripts": {
|
|
55
|
+
"artifacts": "napi artifacts --output-dir artifacts --npm-dir npm",
|
|
56
|
+
"build": "napi build --platform --release --no-js --dts native.d.ts",
|
|
57
|
+
"build:debug": "napi build --platform --no-js --dts native.d.ts",
|
|
58
|
+
"test": "node --test test/loader.test.cjs"
|
|
59
|
+
}
|
|
60
|
+
}
|