Skip to content

Commit

Permalink
Add os check and fix release yml (#9)
Browse files Browse the repository at this point in the history
* specify prebuild branch

* add os check

* changeset
  • Loading branch information
WyattMufson authored Aug 23, 2024
1 parent c3f80ea commit 4aaa1ba
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/purple-houses-hear.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'electron-passkey': patch
---

Add check for os to make sure running on macOS
3 changes: 2 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,5 @@ jobs:
tag_name: ${{ env.VERSION }}
release_name: ${{ env.VERSION }}
draft: false
prerelease: false
prerelease: false
commitish: prebuild
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# electron-passkey

Native module for electron applications to use passkey funcitonality
Native module for electron applications to use passkey funcitonality in macOS apps.

### Usage

Expand Down Expand Up @@ -56,4 +56,6 @@ ipcMain.handle('webauthn-get', (event, options) => {

### Deployments

Here is how this repo handles deployments:

![Deployments](Deployment.png "Deplyoments")
13 changes: 13 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { join } from 'node:path';
import os from 'node:os';

interface PublicKeyCredentialCreationOptions {
rp: {
Expand Down Expand Up @@ -73,6 +74,8 @@ class Passkey {

private handler: any;

private platform = os.platform();

private constructor() {
this.handler = new lib.PasskeyHandler(); // Create an instance of PasskeyHandler
}
Expand All @@ -86,6 +89,11 @@ class Passkey {
}

handlePasskeyCreate(options: PasskeyOptions): Promise<string> {
if (this.platform !== 'darwin') {
throw new Error(
`electron-passkey is meant for macOS only and should NOT be run on ${this.platform}`,
);
}
options.publicKey.challenge = arrayBufferToBase64(
options.publicKey.challenge as ArrayBuffer,
);
Expand All @@ -99,6 +107,11 @@ class Passkey {
}

handlePasskeyGet(options: PasskeyOptions): Promise<string> {
if (this.platform !== 'darwin') {
throw new Error(
`electron-passkey is meant for macOS only and should NOT be run on ${this.platform}`,
);
}
return this.handler.HandlePasskeyGet(JSON.stringify(options));
}

Expand Down

0 comments on commit 4aaa1ba

Please sign in to comment.