Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion client/src/client_builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ export const createClientWithCore = async (
): Promise<Client> => {
const authConfig = clientAuthConfig(config);
if (authConfig.accountName) {
core.setInner(new SharedLibCore(authConfig.accountName));
core.setInner(
new SharedLibCore(authConfig.accountName, config.sharedLibraryPath),
);
}
const clientId = await core.initClient(authConfig);
const inner = new InnerClient(parseInt(clientId, 10), core, authConfig);
Expand Down
1 change: 1 addition & 0 deletions client/src/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export interface ClientConfiguration {
auth: Auth;
integrationName: string;
integrationVersion: string;
sharedLibraryPath?: string;
}

// Sets the authentication method. Use a token as a `string` to authenticate with a service account token.
Expand Down
11 changes: 7 additions & 4 deletions client/src/shared_lib_core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[] = [];
Expand Down Expand Up @@ -47,11 +47,14 @@ 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)) {
Expand Down Expand Up @@ -85,9 +88,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);

Expand Down