From 4aaa1bad0d68b0121e5c9640ca3cfe84ccbbbe83 Mon Sep 17 00:00:00 2001 From: Wyatt Mufson Date: Fri, 23 Aug 2024 17:30:03 +0900 Subject: [PATCH] Add os check and fix release yml (#9) * specify prebuild branch * add os check * changeset --- .changeset/purple-houses-hear.md | 5 +++++ .github/workflows/build.yml | 3 ++- README.md | 4 +++- src/index.ts | 13 +++++++++++++ 4 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 .changeset/purple-houses-hear.md diff --git a/.changeset/purple-houses-hear.md b/.changeset/purple-houses-hear.md new file mode 100644 index 0000000..01c406a --- /dev/null +++ b/.changeset/purple-houses-hear.md @@ -0,0 +1,5 @@ +--- +'electron-passkey': patch +--- + +Add check for os to make sure running on macOS diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ff8d460..24151f6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -86,4 +86,5 @@ jobs: tag_name: ${{ env.VERSION }} release_name: ${{ env.VERSION }} draft: false - prerelease: false \ No newline at end of file + prerelease: false + commitish: prebuild \ No newline at end of file diff --git a/README.md b/README.md index 41879c1..e0c32be 100644 --- a/README.md +++ b/README.md @@ -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 @@ -56,4 +56,6 @@ ipcMain.handle('webauthn-get', (event, options) => { ### Deployments +Here is how this repo handles deployments: + ![Deployments](Deployment.png "Deplyoments") \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index 25fb2a5..f81a717 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,5 @@ import { join } from 'node:path'; +import os from 'node:os'; interface PublicKeyCredentialCreationOptions { rp: { @@ -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 } @@ -86,6 +89,11 @@ class Passkey { } handlePasskeyCreate(options: PasskeyOptions): Promise { + 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, ); @@ -99,6 +107,11 @@ class Passkey { } handlePasskeyGet(options: PasskeyOptions): Promise { + 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)); }