executor 1.3.0-beta.5 → 1.4.0-beta.1
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/bin/executor +24 -0
- package/package.json +6 -20
- package/postinstall.mjs +102 -0
- package/README.md +0 -395
- package/bin/deno-subprocess-worker.mjs +0 -205
- package/bin/emscripten-module.wasm +0 -0
- package/bin/executor.js +0 -42
- package/bin/executor.mjs +0 -367200
- package/bin/keyring.linux-x64-gnu-62qs1shy.node +0 -0
- package/bin/keyring.linux-x64-musl-n4e0vcy6.node +0 -0
- package/bin/sandbox-worker.mjs +0 -5850
- package/node_modules/@1password/sdk/README.md +0 -146
- package/node_modules/@1password/sdk/dist/client.d.ts +0 -14
- package/node_modules/@1password/sdk/dist/client.js +0 -19
- package/node_modules/@1password/sdk/dist/client_builder.d.ts +0 -8
- package/node_modules/@1password/sdk/dist/client_builder.js +0 -36
- package/node_modules/@1password/sdk/dist/configuration.d.ts +0 -23
- package/node_modules/@1password/sdk/dist/configuration.js +0 -58
- package/node_modules/@1password/sdk/dist/core.d.ts +0 -92
- package/node_modules/@1password/sdk/dist/core.js +0 -119
- package/node_modules/@1password/sdk/dist/environments.d.ts +0 -19
- package/node_modules/@1password/sdk/dist/environments.js +0 -53
- package/node_modules/@1password/sdk/dist/errors.d.ts +0 -9
- package/node_modules/@1password/sdk/dist/errors.js +0 -36
- package/node_modules/@1password/sdk/dist/groups.d.ts +0 -19
- package/node_modules/@1password/sdk/dist/groups.js +0 -54
- package/node_modules/@1password/sdk/dist/items.d.ts +0 -89
- package/node_modules/@1password/sdk/dist/items.js +0 -216
- package/node_modules/@1password/sdk/dist/items_files.d.ts +0 -40
- package/node_modules/@1password/sdk/dist/items_files.js +0 -116
- package/node_modules/@1password/sdk/dist/items_shares.d.ts +0 -32
- package/node_modules/@1password/sdk/dist/items_shares.js +0 -95
- package/node_modules/@1password/sdk/dist/sdk.d.ts +0 -14
- package/node_modules/@1password/sdk/dist/sdk.js +0 -45
- package/node_modules/@1password/sdk/dist/secrets.d.ts +0 -36
- package/node_modules/@1password/sdk/dist/secrets.js +0 -107
- package/node_modules/@1password/sdk/dist/shared_lib_core.d.ts +0 -16
- package/node_modules/@1password/sdk/dist/shared_lib_core.js +0 -177
- package/node_modules/@1password/sdk/dist/types.d.ts +0 -769
- package/node_modules/@1password/sdk/dist/types.js +0 -260
- package/node_modules/@1password/sdk/dist/vaults.d.ts +0 -83
- package/node_modules/@1password/sdk/dist/vaults.js +0 -209
- package/node_modules/@1password/sdk/dist/version.d.ts +0 -2
- package/node_modules/@1password/sdk/dist/version.js +0 -6
- package/node_modules/@1password/sdk/package.json +0 -47
- package/node_modules/@1password/sdk-core/nodejs/core.d.ts +0 -18
- package/node_modules/@1password/sdk-core/nodejs/core.js +0 -798
- package/node_modules/@1password/sdk-core/nodejs/core_bg.wasm +0 -0
- package/node_modules/@1password/sdk-core/nodejs/core_bg.wasm.d.ts +0 -20
- package/node_modules/@1password/sdk-core/package.json +0 -16
- package/resources/web/assets/c-BIGW1oBm.js +0 -1
- package/resources/web/assets/cpp-BRuaLJcg.js +0 -1
- package/resources/web/assets/csharp-COcwbKMJ.js +0 -1
- package/resources/web/assets/css-DPfMkruS.js +0 -1
- package/resources/web/assets/diff-D97Zzqfu.js +0 -1
- package/resources/web/assets/dockerfile-BcOcwvcX.js +0 -1
- package/resources/web/assets/go-CxLEBnE3.js +0 -1
- package/resources/web/assets/graphql-ChdNCCLP.js +0 -1
- package/resources/web/assets/highlighted-body-TPN3WLV5-46YyTVIj.js +0 -1
- package/resources/web/assets/html-GMplVEZG.js +0 -1
- package/resources/web/assets/http-jrhK8wxY.js +0 -1
- package/resources/web/assets/index-CRuElBS1.js +0 -1
- package/resources/web/assets/index-vE9OfFSV.js +0 -10
- package/resources/web/assets/java-CylS5w8V.js +0 -1
- package/resources/web/assets/javascript-wDzz0qaB.js +0 -1
- package/resources/web/assets/json-Cp-IABpG.js +0 -1
- package/resources/web/assets/jsonc-Des-eS-w.js +0 -1
- package/resources/web/assets/jsx-g9-lgVsj.js +0 -1
- package/resources/web/assets/kotlin-BdnUsdx6.js +0 -1
- package/resources/web/assets/log-2UxHyX5q.js +0 -1
- package/resources/web/assets/markdown-Cvjx9yec.js +0 -1
- package/resources/web/assets/mermaid-O7DHMXV3-C705YdCO.js +0 -394
- package/resources/web/assets/mermaid-O7DHMXV3-CQK1gbuD.css +0 -1
- package/resources/web/assets/php-Dhbhpdrm.js +0 -1
- package/resources/web/assets/proto-C7zT0LnQ.js +0 -1
- package/resources/web/assets/python-B6aJPvgy.js +0 -1
- package/resources/web/assets/ruby-xesJ3fNi.js +0 -1
- package/resources/web/assets/rust-B1yitclQ.js +0 -1
- package/resources/web/assets/shellscript-Yzrsuije.js +0 -1
- package/resources/web/assets/sql-BLtJtn59.js +0 -1
- package/resources/web/assets/swift-D82vCrfD.js +0 -1
- package/resources/web/assets/toml-vGWfd6FD.js +0 -1
- package/resources/web/assets/tsx-COt5Ahok.js +0 -1
- package/resources/web/assets/typescript-BPQ3VLAy.js +0 -1
- package/resources/web/assets/vitesse-dark-D0r3Knsf.js +0 -1
- package/resources/web/assets/xml-sdJ4AIDG.js +0 -1
- package/resources/web/assets/yaml-Buea-lGh.js +0 -1
- package/resources/web/index.html +0 -24
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Code generated by op-codegen - DO NOT EDIT MANUALLY
|
|
3
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
-
if (k2 === undefined) k2 = k;
|
|
5
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
-
}
|
|
9
|
-
Object.defineProperty(o, k2, desc);
|
|
10
|
-
}) : (function(o, m, k, k2) {
|
|
11
|
-
if (k2 === undefined) k2 = k;
|
|
12
|
-
o[k2] = m[k];
|
|
13
|
-
}));
|
|
14
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
15
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
16
|
-
};
|
|
17
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
23
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
-
});
|
|
25
|
-
};
|
|
26
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
-
exports.createClient = exports.DesktopAuth = exports.Secrets = exports.DEFAULT_INTEGRATION_VERSION = exports.DEFAULT_INTEGRATION_NAME = void 0;
|
|
28
|
-
const core_js_1 = require("./core.js");
|
|
29
|
-
const client_builder_js_1 = require("./client_builder.js");
|
|
30
|
-
exports.DEFAULT_INTEGRATION_NAME = "Unknown";
|
|
31
|
-
exports.DEFAULT_INTEGRATION_VERSION = "Unknown";
|
|
32
|
-
// auto-generated static exports
|
|
33
|
-
var secrets_js_1 = require("./secrets.js");
|
|
34
|
-
Object.defineProperty(exports, "Secrets", { enumerable: true, get: function () { return secrets_js_1.Secrets; } });
|
|
35
|
-
var configuration_js_1 = require("./configuration.js");
|
|
36
|
-
Object.defineProperty(exports, "DesktopAuth", { enumerable: true, get: function () { return configuration_js_1.DesktopAuth; } });
|
|
37
|
-
__exportStar(require("./client.js"), exports);
|
|
38
|
-
__exportStar(require("./errors.js"), exports);
|
|
39
|
-
__exportStar(require("./types.js"), exports);
|
|
40
|
-
/**
|
|
41
|
-
* Creates a default 1Password SDK client.
|
|
42
|
-
* @returns The authenticated 1Password SDK client.
|
|
43
|
-
*/
|
|
44
|
-
const createClient = (config) => __awaiter(void 0, void 0, void 0, function* () { return (0, client_builder_js_1.createClientWithCore)(config, new core_js_1.SharedCore()); });
|
|
45
|
-
exports.createClient = createClient;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { InnerClient } from "./core.js";
|
|
2
|
-
import { GeneratePasswordResponse, PasswordRecipe, ResolveAllResponse } from "./types.js";
|
|
3
|
-
/**
|
|
4
|
-
* The Secrets API includes all operations the SDK client can perform on secrets.
|
|
5
|
-
* Use secret reference URIs to securely load secrets from 1Password: `op://<vault-name>/<item-name>[/<section-name>]/<field-name>`
|
|
6
|
-
*/
|
|
7
|
-
export interface SecretsApi {
|
|
8
|
-
/**
|
|
9
|
-
* Resolve returns the secret the provided secret reference points to.
|
|
10
|
-
*/
|
|
11
|
-
resolve(secretReference: string): Promise<string>;
|
|
12
|
-
/**
|
|
13
|
-
* Resolve takes in a list of secret references and returns the secrets they point to or errors if any.
|
|
14
|
-
*/
|
|
15
|
-
resolveAll(secretReferences: string[]): Promise<ResolveAllResponse>;
|
|
16
|
-
}
|
|
17
|
-
export declare class Secrets implements SecretsApi {
|
|
18
|
-
#private;
|
|
19
|
-
constructor(inner: InnerClient);
|
|
20
|
-
/**
|
|
21
|
-
* Resolve returns the secret the provided secret reference points to.
|
|
22
|
-
*/
|
|
23
|
-
resolve(secretReference: string): Promise<string>;
|
|
24
|
-
/**
|
|
25
|
-
* Resolve takes in a list of secret references and returns the secrets they point to or errors if any.
|
|
26
|
-
*/
|
|
27
|
-
resolveAll(secretReferences: string[]): Promise<ResolveAllResponse>;
|
|
28
|
-
/**
|
|
29
|
-
* Validate the secret reference to ensure there are no syntax errors.
|
|
30
|
-
*/
|
|
31
|
-
static validateSecretReference(secretReference: string): void;
|
|
32
|
-
/**
|
|
33
|
-
* Generate a password using the provided recipe.
|
|
34
|
-
*/
|
|
35
|
-
static generatePassword(recipe: PasswordRecipe): GeneratePasswordResponse;
|
|
36
|
-
}
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Code generated by op-codegen - DO NOT EDIT MANUALLY
|
|
3
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
4
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
5
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
6
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
7
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
8
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
9
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
10
|
-
});
|
|
11
|
-
};
|
|
12
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
13
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
14
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
15
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
16
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
17
|
-
};
|
|
18
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
19
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
20
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
21
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
22
|
-
};
|
|
23
|
-
var _Secrets_inner;
|
|
24
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.Secrets = void 0;
|
|
26
|
-
const core_js_1 = require("./core.js");
|
|
27
|
-
const types_js_1 = require("./types.js");
|
|
28
|
-
class Secrets {
|
|
29
|
-
constructor(inner) {
|
|
30
|
-
_Secrets_inner.set(this, void 0);
|
|
31
|
-
__classPrivateFieldSet(this, _Secrets_inner, inner, "f");
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Resolve returns the secret the provided secret reference points to.
|
|
35
|
-
*/
|
|
36
|
-
resolve(secretReference) {
|
|
37
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
-
const invocationConfig = {
|
|
39
|
-
invocation: {
|
|
40
|
-
clientId: __classPrivateFieldGet(this, _Secrets_inner, "f").id,
|
|
41
|
-
parameters: {
|
|
42
|
-
name: "SecretsResolve",
|
|
43
|
-
parameters: {
|
|
44
|
-
secret_reference: secretReference,
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
},
|
|
48
|
-
};
|
|
49
|
-
return JSON.parse(yield __classPrivateFieldGet(this, _Secrets_inner, "f").invoke(invocationConfig), types_js_1.ReviverFunc);
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Resolve takes in a list of secret references and returns the secrets they point to or errors if any.
|
|
54
|
-
*/
|
|
55
|
-
resolveAll(secretReferences) {
|
|
56
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
57
|
-
const invocationConfig = {
|
|
58
|
-
invocation: {
|
|
59
|
-
clientId: __classPrivateFieldGet(this, _Secrets_inner, "f").id,
|
|
60
|
-
parameters: {
|
|
61
|
-
name: "SecretsResolveAll",
|
|
62
|
-
parameters: {
|
|
63
|
-
secret_references: secretReferences,
|
|
64
|
-
},
|
|
65
|
-
},
|
|
66
|
-
},
|
|
67
|
-
};
|
|
68
|
-
return JSON.parse(yield __classPrivateFieldGet(this, _Secrets_inner, "f").invoke(invocationConfig), types_js_1.ReviverFunc);
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Validate the secret reference to ensure there are no syntax errors.
|
|
73
|
-
*/
|
|
74
|
-
static validateSecretReference(secretReference) {
|
|
75
|
-
const sharedCore = new core_js_1.SharedCore();
|
|
76
|
-
const invocationConfig = {
|
|
77
|
-
invocation: {
|
|
78
|
-
parameters: {
|
|
79
|
-
name: "ValidateSecretReference",
|
|
80
|
-
parameters: {
|
|
81
|
-
secret_reference: secretReference,
|
|
82
|
-
},
|
|
83
|
-
},
|
|
84
|
-
},
|
|
85
|
-
};
|
|
86
|
-
sharedCore.invoke_sync(invocationConfig);
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Generate a password using the provided recipe.
|
|
90
|
-
*/
|
|
91
|
-
static generatePassword(recipe) {
|
|
92
|
-
const sharedCore = new core_js_1.SharedCore();
|
|
93
|
-
const invocationConfig = {
|
|
94
|
-
invocation: {
|
|
95
|
-
parameters: {
|
|
96
|
-
name: "GeneratePassword",
|
|
97
|
-
parameters: {
|
|
98
|
-
recipe,
|
|
99
|
-
},
|
|
100
|
-
},
|
|
101
|
-
},
|
|
102
|
-
};
|
|
103
|
-
return JSON.parse(sharedCore.invoke_sync(invocationConfig), types_js_1.ReviverFunc);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
exports.Secrets = Secrets;
|
|
107
|
-
_Secrets_inner = new WeakMap();
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { Core } from "./core";
|
|
2
|
-
/**
|
|
3
|
-
* SharedLibCore: wrapper around the dynamically loaded shared library
|
|
4
|
-
*/
|
|
5
|
-
export declare class SharedLibCore implements Core {
|
|
6
|
-
private lib;
|
|
7
|
-
private acccountName;
|
|
8
|
-
constructor(accountName: string);
|
|
9
|
-
/**
|
|
10
|
-
* callSharedLibrary - send string to native function, receive string back.
|
|
11
|
-
*/
|
|
12
|
-
private callSharedLibrary;
|
|
13
|
-
initClient(config: string): Promise<string>;
|
|
14
|
-
invoke(invokeConfigBytes: string): Promise<string>;
|
|
15
|
-
releaseClient(clientId: string): void;
|
|
16
|
-
}
|
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
38
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
39
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
40
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
41
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
|
-
});
|
|
43
|
-
};
|
|
44
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
-
exports.SharedLibCore = void 0;
|
|
46
|
-
const fs = __importStar(require("fs"));
|
|
47
|
-
const os = __importStar(require("os"));
|
|
48
|
-
const path = __importStar(require("path"));
|
|
49
|
-
const errors_1 = require("./errors");
|
|
50
|
-
/**
|
|
51
|
-
* Find the 1Password shared lib path by asking an the wasm core synchronously.
|
|
52
|
-
*/
|
|
53
|
-
const find1PasswordLibPath = () => {
|
|
54
|
-
const platform = os.platform();
|
|
55
|
-
const appRoot = path.dirname(process.execPath);
|
|
56
|
-
let searchPaths = [];
|
|
57
|
-
// Define lists of possible locations for each platform.
|
|
58
|
-
switch (platform) {
|
|
59
|
-
case "darwin": // macOS
|
|
60
|
-
searchPaths = [
|
|
61
|
-
"/Applications/1Password.app/Contents/Frameworks/libop_sdk_ipc_client.dylib",
|
|
62
|
-
path.join(os.homedir(), "/Applications/1Password.app/Contents/Frameworks/libop_sdk_ipc_client.dylib"),
|
|
63
|
-
];
|
|
64
|
-
break;
|
|
65
|
-
case "linux": // Linux
|
|
66
|
-
searchPaths = [
|
|
67
|
-
"/usr/bin/1password/libop_sdk_ipc_client.so",
|
|
68
|
-
"/opt/1Password/libop_sdk_ipc_client.so",
|
|
69
|
-
"/snap/bin/1password/libop_sdk_ipc_client.so",
|
|
70
|
-
];
|
|
71
|
-
break;
|
|
72
|
-
case "win32": // Windows
|
|
73
|
-
searchPaths = [
|
|
74
|
-
path.join(os.homedir(), "/AppData/Local/1Password/op_sdk_ipc_client.dll"),
|
|
75
|
-
"C:/Program Files/1Password/app/8/op_sdk_ipc_client.dll",
|
|
76
|
-
"C:/Program Files (x86)/1Password/app/8/op_sdk_ipc_client.dll",
|
|
77
|
-
path.join(os.homedir(), "/AppData/Local/1Password/app/8/op_sdk_ipc_client.dll"),
|
|
78
|
-
];
|
|
79
|
-
break;
|
|
80
|
-
default:
|
|
81
|
-
throw new Error(`Unsupported platform: ${platform}`);
|
|
82
|
-
}
|
|
83
|
-
// Iterate through the possible paths and return the first one that exists.
|
|
84
|
-
for (const addonPath of searchPaths) {
|
|
85
|
-
if (fs.existsSync(addonPath)) {
|
|
86
|
-
return addonPath;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
// If the loop completes without finding the file, throw an error.
|
|
90
|
-
throw new Error("1Password desktop application not found");
|
|
91
|
-
};
|
|
92
|
-
/**
|
|
93
|
-
* SharedLibCore: wrapper around the dynamically loaded shared library
|
|
94
|
-
*/
|
|
95
|
-
class SharedLibCore {
|
|
96
|
-
constructor(accountName) {
|
|
97
|
-
this.lib = null;
|
|
98
|
-
try {
|
|
99
|
-
const libPath = find1PasswordLibPath();
|
|
100
|
-
const moduleStub = { exports: {} };
|
|
101
|
-
process.dlopen(moduleStub, libPath);
|
|
102
|
-
// Safely check the structure of the loaded module before casting.
|
|
103
|
-
if (typeof moduleStub === "object" &&
|
|
104
|
-
moduleStub !== null &&
|
|
105
|
-
typeof moduleStub.exports === "object" &&
|
|
106
|
-
moduleStub.exports !== null &&
|
|
107
|
-
"sendMessage" in moduleStub.exports &&
|
|
108
|
-
typeof moduleStub.exports.sendMessage ===
|
|
109
|
-
"function") {
|
|
110
|
-
this.lib = moduleStub.exports;
|
|
111
|
-
}
|
|
112
|
-
else {
|
|
113
|
-
throw new Error("Failed to initialize native library: sendMessage function not found on module.");
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
catch (e) {
|
|
117
|
-
console.error("A critical error occurred while loading the native addon:", e);
|
|
118
|
-
this.lib = null;
|
|
119
|
-
}
|
|
120
|
-
this.acccountName = accountName;
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* callSharedLibrary - send string to native function, receive string back.
|
|
124
|
-
*/
|
|
125
|
-
callSharedLibrary(input, operation_type) {
|
|
126
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
127
|
-
if (!this.lib) {
|
|
128
|
-
throw new Error("Native library is not available.");
|
|
129
|
-
}
|
|
130
|
-
if (!input || input.length === 0) {
|
|
131
|
-
throw new Error("internal: empty input");
|
|
132
|
-
}
|
|
133
|
-
const inputEncoded = Buffer.from(input, "utf8").toString("base64");
|
|
134
|
-
const req = {
|
|
135
|
-
account_name: this.acccountName,
|
|
136
|
-
kind: operation_type,
|
|
137
|
-
payload: inputEncoded,
|
|
138
|
-
};
|
|
139
|
-
const inputBuf = Buffer.from(JSON.stringify(req), "utf8");
|
|
140
|
-
const nativeResponse = yield this.lib.sendMessage(inputBuf);
|
|
141
|
-
if (!(nativeResponse instanceof Uint8Array)) {
|
|
142
|
-
throw new Error(`Native function returned an unexpected type. Expected Uint8Array, got ${typeof nativeResponse}`);
|
|
143
|
-
}
|
|
144
|
-
const respString = new TextDecoder().decode(nativeResponse);
|
|
145
|
-
const response = JSON.parse(respString);
|
|
146
|
-
if (response.success) {
|
|
147
|
-
const decodedPayload = Buffer.from(response.payload).toString("utf8");
|
|
148
|
-
// On success, the payload is the actual result string
|
|
149
|
-
return decodedPayload;
|
|
150
|
-
}
|
|
151
|
-
else {
|
|
152
|
-
// On failure, convert the error payload to a readable string and throw
|
|
153
|
-
const errorMessage = Array.isArray(response.payload)
|
|
154
|
-
? String.fromCharCode(...response.payload)
|
|
155
|
-
: JSON.stringify(response.payload);
|
|
156
|
-
(0, errors_1.throwError)(errorMessage);
|
|
157
|
-
}
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
// Core interface implementation
|
|
161
|
-
initClient(config) {
|
|
162
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
163
|
-
return this.callSharedLibrary(config, "init_client");
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
invoke(invokeConfigBytes) {
|
|
167
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
168
|
-
return this.callSharedLibrary(invokeConfigBytes, "invoke");
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
releaseClient(clientId) {
|
|
172
|
-
this.callSharedLibrary(clientId, "release_client").catch((err) => {
|
|
173
|
-
console.warn("failed to release client:", err);
|
|
174
|
-
});
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
exports.SharedLibCore = SharedLibCore;
|