From 47828af0cd10cccb4087bcc79c0ced5d77543f7a Mon Sep 17 00:00:00 2001 From: Meow Date: Thu, 4 Dec 2025 20:53:39 -0500 Subject: [PATCH 1/3] feat: custom shared library path --- client/src/client_builder.ts | 4 +++- client/src/configuration.ts | 1 + client/src/shared_lib_core.ts | 10 ++++++---- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/client/src/client_builder.ts b/client/src/client_builder.ts index 5f2a423..0391bca 100644 --- a/client/src/client_builder.ts +++ b/client/src/client_builder.ts @@ -19,7 +19,9 @@ export const createClientWithCore = async ( ): Promise => { const authConfig = clientAuthConfig(config); if (authConfig.accountName) { - core.setInner(new SharedLibCore(authConfig.accountName)); + core.setInner( + new SharedLibCore(authConfig.accountName, config.customSharedLibraryPath), + ); } const clientId = await core.initClient(authConfig); const inner = new InnerClient(parseInt(clientId, 10), core, authConfig); diff --git a/client/src/configuration.ts b/client/src/configuration.ts index 6e08f52..e4eea22 100644 --- a/client/src/configuration.ts +++ b/client/src/configuration.ts @@ -11,6 +11,7 @@ export interface ClientConfiguration { auth: Auth; integrationName: string; integrationVersion: string; + customSharedLibraryPath?: string; } // Sets the authentication method. Use a token as a `string` to authenticate with a service account token. diff --git a/client/src/shared_lib_core.ts b/client/src/shared_lib_core.ts index 780d191..ce0191d 100644 --- a/client/src/shared_lib_core.ts +++ b/client/src/shared_lib_core.ts @@ -8,7 +8,7 @@ import { throwError } from "./errors"; /** * Find the 1Password shared lib path by asking an the wasm core synchronously. */ -const find1PasswordLibPath = (): string => { +const find1PasswordLibPath = (customLocation?: string): string => { const platform: NodeJS.Platform = os.platform(); const appRoot: string = path.dirname(process.execPath); let searchPaths: string[] = []; @@ -47,11 +47,13 @@ const find1PasswordLibPath = (): string => { ), ]; break; - default: throw new Error(`Unsupported platform: ${platform}`); } + if (typeof customLocation == "string" && customLocation.length > 0) + searchPaths.unshift(customLocation); + // Iterate through the possible paths and return the first one that exists. for (const addonPath of searchPaths) { if (fs.existsSync(addonPath)) { @@ -85,9 +87,9 @@ export class SharedLibCore implements Core { private lib: DesktopIPCClient | null = null; private acccountName: string; - public constructor(accountName: string) { + public constructor(accountName: string, libraryPath?: string) { try { - const libPath = find1PasswordLibPath(); + const libPath = find1PasswordLibPath(libraryPath); const moduleStub = { exports: {} }; process.dlopen(moduleStub, libPath); From a7dbc960f3eaa541b307140ac82169dd21b14ce8 Mon Sep 17 00:00:00 2001 From: Meow Date: Thu, 4 Dec 2025 20:55:33 -0500 Subject: [PATCH 2/3] fix: eslint --- client/src/shared_lib_core.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/client/src/shared_lib_core.ts b/client/src/shared_lib_core.ts index ce0191d..0de6b34 100644 --- a/client/src/shared_lib_core.ts +++ b/client/src/shared_lib_core.ts @@ -51,8 +51,9 @@ const find1PasswordLibPath = (customLocation?: string): string => { throw new Error(`Unsupported platform: ${platform}`); } - if (typeof customLocation == "string" && customLocation.length > 0) + if (typeof customLocation === "string" && customLocation.length > 0) { searchPaths.unshift(customLocation); + } // Iterate through the possible paths and return the first one that exists. for (const addonPath of searchPaths) { From 97b56c852f283850d10c17afce7d62a6823bbe2f Mon Sep 17 00:00:00 2001 From: Meow Date: Thu, 4 Dec 2025 21:06:30 -0500 Subject: [PATCH 3/3] fix: naming convention --- client/src/client_builder.ts | 2 +- client/src/configuration.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/client/src/client_builder.ts b/client/src/client_builder.ts index 0391bca..fa9360a 100644 --- a/client/src/client_builder.ts +++ b/client/src/client_builder.ts @@ -20,7 +20,7 @@ export const createClientWithCore = async ( const authConfig = clientAuthConfig(config); if (authConfig.accountName) { core.setInner( - new SharedLibCore(authConfig.accountName, config.customSharedLibraryPath), + new SharedLibCore(authConfig.accountName, config.sharedLibraryPath), ); } const clientId = await core.initClient(authConfig); diff --git a/client/src/configuration.ts b/client/src/configuration.ts index e4eea22..03f1605 100644 --- a/client/src/configuration.ts +++ b/client/src/configuration.ts @@ -11,7 +11,7 @@ export interface ClientConfiguration { auth: Auth; integrationName: string; integrationVersion: string; - customSharedLibraryPath?: string; + sharedLibraryPath?: string; } // Sets the authentication method. Use a token as a `string` to authenticate with a service account token.