executor 1.3.0-beta.4 → 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.
Files changed (88) hide show
  1. package/bin/executor +24 -0
  2. package/package.json +6 -20
  3. package/postinstall.mjs +102 -0
  4. package/README.md +0 -395
  5. package/bin/deno-subprocess-worker.mjs +0 -205
  6. package/bin/emscripten-module.wasm +0 -0
  7. package/bin/executor.js +0 -42
  8. package/bin/executor.mjs +0 -367151
  9. package/bin/keyring.linux-x64-gnu-62qs1shy.node +0 -0
  10. package/bin/keyring.linux-x64-musl-n4e0vcy6.node +0 -0
  11. package/bin/sandbox-worker.mjs +0 -5850
  12. package/node_modules/@1password/sdk/README.md +0 -146
  13. package/node_modules/@1password/sdk/dist/client.d.ts +0 -14
  14. package/node_modules/@1password/sdk/dist/client.js +0 -19
  15. package/node_modules/@1password/sdk/dist/client_builder.d.ts +0 -8
  16. package/node_modules/@1password/sdk/dist/client_builder.js +0 -36
  17. package/node_modules/@1password/sdk/dist/configuration.d.ts +0 -23
  18. package/node_modules/@1password/sdk/dist/configuration.js +0 -58
  19. package/node_modules/@1password/sdk/dist/core.d.ts +0 -92
  20. package/node_modules/@1password/sdk/dist/core.js +0 -119
  21. package/node_modules/@1password/sdk/dist/environments.d.ts +0 -19
  22. package/node_modules/@1password/sdk/dist/environments.js +0 -53
  23. package/node_modules/@1password/sdk/dist/errors.d.ts +0 -9
  24. package/node_modules/@1password/sdk/dist/errors.js +0 -36
  25. package/node_modules/@1password/sdk/dist/groups.d.ts +0 -19
  26. package/node_modules/@1password/sdk/dist/groups.js +0 -54
  27. package/node_modules/@1password/sdk/dist/items.d.ts +0 -89
  28. package/node_modules/@1password/sdk/dist/items.js +0 -216
  29. package/node_modules/@1password/sdk/dist/items_files.d.ts +0 -40
  30. package/node_modules/@1password/sdk/dist/items_files.js +0 -116
  31. package/node_modules/@1password/sdk/dist/items_shares.d.ts +0 -32
  32. package/node_modules/@1password/sdk/dist/items_shares.js +0 -95
  33. package/node_modules/@1password/sdk/dist/sdk.d.ts +0 -14
  34. package/node_modules/@1password/sdk/dist/sdk.js +0 -45
  35. package/node_modules/@1password/sdk/dist/secrets.d.ts +0 -36
  36. package/node_modules/@1password/sdk/dist/secrets.js +0 -107
  37. package/node_modules/@1password/sdk/dist/shared_lib_core.d.ts +0 -16
  38. package/node_modules/@1password/sdk/dist/shared_lib_core.js +0 -177
  39. package/node_modules/@1password/sdk/dist/types.d.ts +0 -769
  40. package/node_modules/@1password/sdk/dist/types.js +0 -260
  41. package/node_modules/@1password/sdk/dist/vaults.d.ts +0 -83
  42. package/node_modules/@1password/sdk/dist/vaults.js +0 -209
  43. package/node_modules/@1password/sdk/dist/version.d.ts +0 -2
  44. package/node_modules/@1password/sdk/dist/version.js +0 -6
  45. package/node_modules/@1password/sdk/package.json +0 -47
  46. package/node_modules/@1password/sdk-core/nodejs/core.d.ts +0 -18
  47. package/node_modules/@1password/sdk-core/nodejs/core.js +0 -798
  48. package/node_modules/@1password/sdk-core/nodejs/core_bg.wasm +0 -0
  49. package/node_modules/@1password/sdk-core/nodejs/core_bg.wasm.d.ts +0 -20
  50. package/node_modules/@1password/sdk-core/package.json +0 -16
  51. package/resources/web/assets/c-BIGW1oBm.js +0 -1
  52. package/resources/web/assets/cpp-BRuaLJcg.js +0 -1
  53. package/resources/web/assets/csharp-COcwbKMJ.js +0 -1
  54. package/resources/web/assets/css-DPfMkruS.js +0 -1
  55. package/resources/web/assets/diff-D97Zzqfu.js +0 -1
  56. package/resources/web/assets/dockerfile-BcOcwvcX.js +0 -1
  57. package/resources/web/assets/go-CxLEBnE3.js +0 -1
  58. package/resources/web/assets/graphql-ChdNCCLP.js +0 -1
  59. package/resources/web/assets/highlighted-body-TPN3WLV5-DWag2KgW.js +0 -1
  60. package/resources/web/assets/html-GMplVEZG.js +0 -1
  61. package/resources/web/assets/http-jrhK8wxY.js +0 -1
  62. package/resources/web/assets/index-Bd3QqIqU.js +0 -10
  63. package/resources/web/assets/index-CRuElBS1.js +0 -1
  64. package/resources/web/assets/java-CylS5w8V.js +0 -1
  65. package/resources/web/assets/javascript-wDzz0qaB.js +0 -1
  66. package/resources/web/assets/json-Cp-IABpG.js +0 -1
  67. package/resources/web/assets/jsonc-Des-eS-w.js +0 -1
  68. package/resources/web/assets/jsx-g9-lgVsj.js +0 -1
  69. package/resources/web/assets/kotlin-BdnUsdx6.js +0 -1
  70. package/resources/web/assets/log-2UxHyX5q.js +0 -1
  71. package/resources/web/assets/markdown-Cvjx9yec.js +0 -1
  72. package/resources/web/assets/mermaid-O7DHMXV3-CQK1gbuD.css +0 -1
  73. package/resources/web/assets/mermaid-O7DHMXV3-Dhg9dniF.js +0 -394
  74. package/resources/web/assets/php-Dhbhpdrm.js +0 -1
  75. package/resources/web/assets/proto-C7zT0LnQ.js +0 -1
  76. package/resources/web/assets/python-B6aJPvgy.js +0 -1
  77. package/resources/web/assets/ruby-xesJ3fNi.js +0 -1
  78. package/resources/web/assets/rust-B1yitclQ.js +0 -1
  79. package/resources/web/assets/shellscript-Yzrsuije.js +0 -1
  80. package/resources/web/assets/sql-BLtJtn59.js +0 -1
  81. package/resources/web/assets/swift-D82vCrfD.js +0 -1
  82. package/resources/web/assets/toml-vGWfd6FD.js +0 -1
  83. package/resources/web/assets/tsx-COt5Ahok.js +0 -1
  84. package/resources/web/assets/typescript-BPQ3VLAy.js +0 -1
  85. package/resources/web/assets/vitesse-dark-D0r3Knsf.js +0 -1
  86. package/resources/web/assets/xml-sdJ4AIDG.js +0 -1
  87. package/resources/web/assets/yaml-Buea-lGh.js +0 -1
  88. package/resources/web/index.html +0 -24
@@ -1,146 +0,0 @@
1
- <p align="center">
2
- <a href="https://1password.com">
3
- <h1 align="center">1Password JavaScript SDK</h1>
4
- </a>
5
- </p>
6
-
7
- <p align="center">
8
- <h4 align="center">Build integrations that programmatically access your secrets in 1Password.</h4>
9
- </p>
10
-
11
- <p align="center">
12
- <a href="https://developer.1password.com/docs/sdks/">Documentation</a> | <a href="https://github.com/1Password/onepassword-sdk-js/tree/main/examples">Examples</a>
13
- <br/>
14
-
15
- ---
16
-
17
- ## 🚀 Get started
18
-
19
- To use the 1Password JavaScript SDK in your project:
20
-
21
- 1. [Create a service account](https://my.1password.com/developer-tools/infrastructure-secrets/serviceaccount/?source=github-sdk) and give it the appropriate permissions in the vaults where the items you want to use with the SDK are saved.
22
- 2. Provision your service account token. We recommend provisioning your token from the environment. For example, to export your token to the `OP_SERVICE_ACCOUNT_TOKEN` environment variable:
23
-
24
- **macOS or Linux**
25
-
26
- ```bash
27
- export OP_SERVICE_ACCOUNT_TOKEN=<your-service-account-token>
28
- ```
29
-
30
- **Windows**
31
-
32
- ```powershell
33
- $Env:OP_SERVICE_ACCOUNT_TOKEN = "<your-service-account-token>"
34
- ```
35
-
36
- 3. Install the 1Password JavaScript SDK in your project:
37
-
38
- ```bash
39
- ## NPM
40
- npm install @1password/sdk
41
- ```
42
-
43
- ```bash
44
- ## PNPM
45
- pnpm add @1password/sdk
46
- ```
47
-
48
- ```bash
49
- ## Yarn
50
- yarn add @1password/sdk
51
- ```
52
-
53
- 4. Use the JavaScript SDK in your project:
54
-
55
- ```js
56
- import { createClient } from "@1password/sdk";
57
-
58
- // Creates an authenticated client.
59
- const client = await createClient({
60
- auth: process.env.OP_SERVICE_ACCOUNT_TOKEN,
61
- // Set the following to your own integration name and version.
62
- integrationName: "My 1Password Integration",
63
- integrationVersion: "v1.0.0",
64
- });
65
-
66
- // Fetches a secret.
67
- const secret = await client.secrets.resolve("op://vault/item/field");
68
- ```
69
-
70
- Make sure to use [secret reference URIs](https://developer.1password.com/docs/cli/secret-reference-syntax/) with the syntax `op://vault/item/field` to securely load secrets from 1Password into your code.
71
-
72
- Inside `createClient()`, set `integrationName` to the name of your application and `integrationVersion` to the version of your application.
73
-
74
- ## Supported functionality
75
-
76
- 1Password SDKs are in active development. We're keen to hear what you'd like to see next. Let us know by [upvoting](https://github.com/1Password/onepassword-sdk-js/issues) or [filing](https://github.com/1Password/onepassword-sdk-js/issues/new/choose) an issue.
77
-
78
- ### Item management
79
-
80
- Operations:
81
-
82
- - [x] [Retrieve secrets](https://developer.1password.com/docs/sdks/load-secrets)
83
- - [x] [Retrieve items](https://developer.1password.com/docs/sdks/manage-items#get-an-item)
84
- - [x] [Create items](https://developer.1password.com/docs/sdks/manage-items#create-an-item)
85
- - [x] [Update items](https://developer.1password.com/docs/sdks/manage-items#update-an-item)
86
- - [x] [Delete items](https://developer.1password.com/docs/sdks/manage-items#delete-an-item)
87
- - [x] [Archive items](https://developer.1password.com/docs/sdks/manage-items/#archive-an-item)
88
- - [x] [List items](https://developer.1password.com/docs/sdks/list-vaults-items/)
89
- - [x] [Share items](https://developer.1password.com/docs/sdks/share-items)
90
- - [x] [Generate PIN, random and memorable passwords](https://developer.1password.com/docs/sdks/manage-items#generate-a-password)
91
-
92
- Field types:
93
- - [x] API Keys
94
- - [x] Passwords
95
- - [x] Concealed fields
96
- - [x] Text fields
97
- - [x] Notes
98
- - [x] SSH private keys, public keys, fingerprint and key type
99
- - [x] One-time passwords
100
- - [x] URLs
101
- - [x] Websites (used to suggest and autofill logins)
102
- - [x] Phone numbers
103
- - [x] Credit card types
104
- - [x] Credit card numbers
105
- - [x] Emails
106
- - [x] References to other items
107
- - [x] Address
108
- - [x] Date
109
- - [x] MM/YY
110
- - [x] File attachments and Document items
111
- - [x] Menu
112
- - [ ] Passkeys
113
-
114
- ### Vault management
115
- - [ ] Retrieve vaults
116
- - [ ] Create vaults ([#50](https://github.com/1Password/onepassword-sdk-js/issues/50))
117
- - [ ] Update vaults
118
- - [ ] Delete vaults
119
- - [x] [List vaults](https://developer.1password.com/docs/sdks/list-vaults-items/)
120
-
121
- ### User & access management
122
- - [ ] Provision users
123
- - [ ] Retrieve users
124
- - [ ] List users
125
- - [ ] Suspend users
126
- - [ ] Create groups
127
- - [ ] Update group membership
128
- - [ ] Update vault access & permissions
129
-
130
- ### Compliance & reporting
131
- - [ ] Watchtower insights
132
- - [ ] Travel mode
133
- - [ ] Events. For now, use [1Password Events Reporting API](https://developer.1password.com/docs/events-api/) directly.
134
-
135
- ### Authentication
136
-
137
- - [x] [1Password Service Accounts](https://developer.1password.com/docs/service-accounts/get-started/)
138
- - [ ] User authentication
139
- - [ ] 1Password Connect. For now, use [1Password/connect-sdk-js](https://github.com/1Password/connect-sdk-js).
140
-
141
- ## 📖 Learn more
142
-
143
- - [Load secrets with 1Password SDKs](https://developer.1password.com/docs/sdks/load-secrets)
144
- - [Manage items with 1Password SDKs](https://developer.1password.com/docs/sdks/manage-items)
145
- - [List vaults and items with 1Password SDKs](https://developer.1password.com/docs/sdks/list-vaults-items)
146
- - [1Password SDK concepts](https://developer.1password.com/docs/sdks/concepts)
@@ -1,14 +0,0 @@
1
- import { InnerClient } from "./core.js";
2
- import { SecretsApi } from "./secrets.js";
3
- import { ItemsApi } from "./items.js";
4
- import { VaultsApi } from "./vaults.js";
5
- import { EnvironmentsApi } from "./environments.js";
6
- import { GroupsApi } from "./groups.js";
7
- export declare class Client {
8
- secrets: SecretsApi;
9
- items: ItemsApi;
10
- vaults: VaultsApi;
11
- environments: EnvironmentsApi;
12
- groups: GroupsApi;
13
- constructor(innerClient: InnerClient);
14
- }
@@ -1,19 +0,0 @@
1
- "use strict";
2
- // Code generated by op-codegen - DO NOT EDIT MANUALLY
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.Client = void 0;
5
- const secrets_js_1 = require("./secrets.js");
6
- const items_js_1 = require("./items.js");
7
- const vaults_js_1 = require("./vaults.js");
8
- const environments_js_1 = require("./environments.js");
9
- const groups_js_1 = require("./groups.js");
10
- class Client {
11
- constructor(innerClient) {
12
- this.secrets = new secrets_js_1.Secrets(innerClient);
13
- this.items = new items_js_1.Items(innerClient);
14
- this.vaults = new vaults_js_1.Vaults(innerClient);
15
- this.environments = new environments_js_1.Environments(innerClient);
16
- this.groups = new groups_js_1.Groups(innerClient);
17
- }
18
- }
19
- exports.Client = Client;
@@ -1,8 +0,0 @@
1
- import { SharedCore } from "./core.js";
2
- import { ClientConfiguration } from "./configuration.js";
3
- import { Client } from "./client.js";
4
- /**
5
- * Creates a 1Password SDK client with a given core implementation.
6
- * @returns The authenticated 1Password SDK client.
7
- */
8
- export declare const createClientWithCore: (config: ClientConfiguration, core: SharedCore) => Promise<Client>;
@@ -1,36 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.createClientWithCore = void 0;
13
- const core_js_1 = require("./core.js");
14
- const configuration_js_1 = require("./configuration.js");
15
- const client_js_1 = require("./client.js");
16
- const shared_lib_core_js_1 = require("./shared_lib_core.js");
17
- const finalizationRegistry = new FinalizationRegistry((heldClient) => {
18
- heldClient.core.releaseClient(heldClient.id);
19
- });
20
- /**
21
- * Creates a 1Password SDK client with a given core implementation.
22
- * @returns The authenticated 1Password SDK client.
23
- */
24
- const createClientWithCore = (config, core) => __awaiter(void 0, void 0, void 0, function* () {
25
- const authConfig = (0, configuration_js_1.clientAuthConfig)(config);
26
- if (authConfig.accountName) {
27
- core.setInner(new shared_lib_core_js_1.SharedLibCore(authConfig.accountName));
28
- }
29
- const clientId = yield core.initClient(authConfig);
30
- const inner = new core_js_1.InnerClient(parseInt(clientId, 10), core, authConfig);
31
- const client = new client_js_1.Client(inner);
32
- // Cleans up associated memory from core when client instance goes out of scope.
33
- finalizationRegistry.register(client, inner);
34
- return client;
35
- });
36
- exports.createClientWithCore = createClientWithCore;
@@ -1,23 +0,0 @@
1
- import { ClientAuthConfig } from "./core.js";
2
- export declare const LANGUAGE = "JS";
3
- export declare const VERSION = "0040101";
4
- export interface ClientConfiguration {
5
- auth: Auth;
6
- integrationName: string;
7
- integrationVersion: string;
8
- }
9
- type Auth = string | DesktopAuth;
10
- /**
11
- * Setting that specifies a client should use the desktop app to authenticate. Set accountName to your 1Password account name as shown at the top left sidebar of the app, or your account UUID.
12
- */
13
- export declare class DesktopAuth {
14
- accountName: string;
15
- constructor(accountName: string);
16
- }
17
- /**
18
- * Creates a default client configuration.
19
- * @returns The client configuration to instantiate the client with.
20
- */
21
- export declare const clientAuthConfig: (userConfig: ClientConfiguration) => ClientAuthConfig;
22
- export declare const getOsName: () => string;
23
- export {};
@@ -1,58 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getOsName = exports.clientAuthConfig = exports.DesktopAuth = exports.VERSION = exports.LANGUAGE = void 0;
7
- const os_1 = __importDefault(require("os"));
8
- const version_js_1 = require("./version.js");
9
- exports.LANGUAGE = "JS";
10
- exports.VERSION = version_js_1.SDK_BUILD_NUMBER;
11
- /**
12
- * Setting that specifies a client should use the desktop app to authenticate. Set accountName to your 1Password account name as shown at the top left sidebar of the app, or your account UUID.
13
- */
14
- class DesktopAuth {
15
- constructor(accountName) {
16
- this.accountName = accountName;
17
- }
18
- }
19
- exports.DesktopAuth = DesktopAuth;
20
- /**
21
- * Creates a default client configuration.
22
- * @returns The client configuration to instantiate the client with.
23
- */
24
- const clientAuthConfig = (userConfig) => {
25
- // TODO: Add logic for computing the correct sanitized version value for each platform
26
- const defaultOsVersion = "0.0.0";
27
- let serviceAccountToken;
28
- let accountName;
29
- if (typeof userConfig.auth === "string") {
30
- serviceAccountToken = userConfig.auth;
31
- }
32
- else if (userConfig.auth instanceof DesktopAuth) {
33
- accountName = userConfig.auth.accountName;
34
- }
35
- return {
36
- serviceAccountToken: serviceAccountToken !== null && serviceAccountToken !== void 0 ? serviceAccountToken : "",
37
- accountName,
38
- programmingLanguage: exports.LANGUAGE,
39
- sdkVersion: exports.VERSION,
40
- integrationName: userConfig.integrationName,
41
- integrationVersion: userConfig.integrationVersion,
42
- requestLibraryName: "Fetch API",
43
- requestLibraryVersion: "Fetch API",
44
- os: (0, exports.getOsName)(),
45
- osVersion: defaultOsVersion,
46
- architecture: os_1.default.arch(),
47
- };
48
- };
49
- exports.clientAuthConfig = clientAuthConfig;
50
- const getOsName = () => {
51
- // Only supported on Node.js
52
- const os_name = os_1.default.type().toLowerCase();
53
- if (os_name === "windows_nt") {
54
- return "windows";
55
- }
56
- return os_name;
57
- };
58
- exports.getOsName = getOsName;
@@ -1,92 +0,0 @@
1
- /**
2
- * Exposes the SDK core to the host JS SDK.
3
- */
4
- export interface Core {
5
- /**
6
- * Allocates a new authenticated client and returns its id.
7
- */
8
- initClient(config: string): Promise<string>;
9
- /**
10
- * Calls async business logic from a given client and returns the result.
11
- */
12
- invoke(config: string): Promise<string>;
13
- /**
14
- * Deallocates memory held by the given client in the SDK core when it goes out of scope.
15
- */
16
- releaseClient(clientId: string): void;
17
- }
18
- /**
19
- * Wraps configuration information needed to allocate and authenticate a client instance and sends it to the SDK core.
20
- */
21
- export interface ClientAuthConfig {
22
- programmingLanguage: string;
23
- sdkVersion: string;
24
- integrationName: string;
25
- integrationVersion: string;
26
- requestLibraryName: string;
27
- requestLibraryVersion: string;
28
- os: string;
29
- osVersion: string;
30
- architecture: string;
31
- serviceAccountToken?: string;
32
- accountName?: string;
33
- }
34
- /**
35
- * Contains the information sent to the SDK core when you call (invoke) a function.
36
- */
37
- export interface InvokeConfig {
38
- /**
39
- * Identifies the client instance for which you called the function.
40
- */
41
- invocation: Invocation;
42
- }
43
- /**
44
- * Calls certain logic from the SDK core, with the given parameters.
45
- */
46
- interface Invocation {
47
- /**
48
- * Identifies the client instance for which you called the function.
49
- */
50
- clientId?: number;
51
- parameters: Parameters;
52
- }
53
- export interface Parameters {
54
- /**
55
- * Functionality name
56
- */
57
- name: string;
58
- /**
59
- * Parameters
60
- */
61
- parameters: {
62
- [key: string]: unknown;
63
- };
64
- }
65
- export declare class WasmCore implements Core {
66
- initClient(config: string): Promise<string>;
67
- invoke(config: string): Promise<string>;
68
- releaseClient(clientId: string): void;
69
- }
70
- /**
71
- * An implementation of the `Core` interface that shares resources across all clients.
72
- */
73
- export declare class SharedCore {
74
- private inner;
75
- constructor();
76
- setInner(core: Core): void;
77
- initClient(config: ClientAuthConfig): Promise<string>;
78
- invoke(config: InvokeConfig): Promise<string>;
79
- invoke_sync(config: InvokeConfig): string;
80
- releaseClient(clientId: number): void;
81
- }
82
- /**
83
- * Represents the client instance on which a call is made.
84
- */
85
- export declare class InnerClient {
86
- id: number;
87
- readonly core: SharedCore;
88
- config: ClientAuthConfig;
89
- constructor(id: number, core: SharedCore, config: ClientAuthConfig);
90
- invoke(config: InvokeConfig): Promise<string>;
91
- }
92
- export {};
@@ -1,119 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.InnerClient = exports.SharedCore = exports.WasmCore = void 0;
13
- const sdk_core_1 = require("@1password/sdk-core");
14
- const types_1 = require("./types");
15
- const errors_1 = require("./errors");
16
- // In empirical tests, we determined that maximum message size that can cross the FFI boundary
17
- // is ~64MB. Past this limit, the wasm-bingen FFI will throw an error and the program will crash.
18
- // We set the limit to 50MB to be safe, to be reconsidered upon further testing.
19
- const messageLimit = 50 * 1024 * 1024;
20
- class WasmCore {
21
- initClient(config) {
22
- return __awaiter(this, void 0, void 0, function* () {
23
- try {
24
- return yield (0, sdk_core_1.init_client)(config);
25
- }
26
- catch (e) {
27
- (0, errors_1.throwError)(e);
28
- }
29
- });
30
- }
31
- invoke(config) {
32
- return __awaiter(this, void 0, void 0, function* () {
33
- try {
34
- return yield (0, sdk_core_1.invoke)(config);
35
- }
36
- catch (e) {
37
- (0, errors_1.throwError)(e);
38
- }
39
- });
40
- }
41
- releaseClient(clientId) {
42
- try {
43
- (0, sdk_core_1.release_client)(clientId);
44
- }
45
- catch (e) {
46
- console.warn("failed to release client:", e);
47
- }
48
- }
49
- }
50
- exports.WasmCore = WasmCore;
51
- /**
52
- * An implementation of the `Core` interface that shares resources across all clients.
53
- */
54
- class SharedCore {
55
- constructor() {
56
- this.inner = new WasmCore();
57
- }
58
- setInner(core) {
59
- this.inner = core;
60
- }
61
- initClient(config) {
62
- return __awaiter(this, void 0, void 0, function* () {
63
- const serializedConfig = JSON.stringify(config);
64
- return this.inner.initClient(serializedConfig);
65
- });
66
- }
67
- invoke(config) {
68
- return __awaiter(this, void 0, void 0, function* () {
69
- const serializedConfig = JSON.stringify(config, types_1.ReplacerFunc);
70
- // Encoding to bytes as JS uses UTF-16 under the hood, but the messages
71
- // that are sent across the FFI boundary are encoded in UTF-8.
72
- if (new TextEncoder().encode(serializedConfig).length > messageLimit) {
73
- (0, errors_1.throwError)(`message size exceeds the limit of ${messageLimit} bytes, please contact 1Password at support@1password.com or https://developer.1password.com/joinslack if you need help."`);
74
- }
75
- return this.inner.invoke(serializedConfig);
76
- });
77
- }
78
- invoke_sync(config) {
79
- const serializedConfig = JSON.stringify(config, types_1.ReplacerFunc);
80
- // Encoding to bytes as JS uses UTF-16 under the hood, but the messages
81
- // that are sent across the FFI boundary are encoded in UTF-8.
82
- if (new TextEncoder().encode(serializedConfig).length > messageLimit) {
83
- (0, errors_1.throwError)(`message size exceeds the limit of ${messageLimit} bytes, please contact 1Password at support@1password.com or https://developer.1password.com/joinslack if you need help.`);
84
- }
85
- return (0, sdk_core_1.invoke_sync)(serializedConfig);
86
- }
87
- releaseClient(clientId) {
88
- const serializedId = JSON.stringify(clientId);
89
- this.inner.releaseClient(serializedId);
90
- }
91
- }
92
- exports.SharedCore = SharedCore;
93
- /**
94
- * Represents the client instance on which a call is made.
95
- */
96
- class InnerClient {
97
- constructor(id, core, config) {
98
- this.id = id;
99
- this.core = core;
100
- this.config = config;
101
- }
102
- invoke(config) {
103
- return __awaiter(this, void 0, void 0, function* () {
104
- try {
105
- return yield this.core.invoke(config);
106
- }
107
- catch (err) {
108
- if (err instanceof errors_1.DesktopSessionExpiredError) {
109
- const newId = yield this.core.initClient(this.config);
110
- this.id = parseInt(newId, 10);
111
- config.invocation.clientId = this.id;
112
- return yield this.core.invoke(config);
113
- }
114
- throw err;
115
- }
116
- });
117
- }
118
- }
119
- exports.InnerClient = InnerClient;
@@ -1,19 +0,0 @@
1
- import { InnerClient } from "./core.js";
2
- import { GetVariablesResponse } from "./types.js";
3
- /**
4
- * The Environments API holds all the operations the SDK client can perform on 1Password Environments.
5
- */
6
- export interface EnvironmentsApi {
7
- /**
8
- * Get environment variables belonging to an Environment.
9
- */
10
- getVariables(environmentId: string): Promise<GetVariablesResponse>;
11
- }
12
- export declare class Environments implements EnvironmentsApi {
13
- #private;
14
- constructor(inner: InnerClient);
15
- /**
16
- * Get environment variables belonging to an Environment.
17
- */
18
- getVariables(environmentId: string): Promise<GetVariablesResponse>;
19
- }
@@ -1,53 +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 _Environments_inner;
24
- Object.defineProperty(exports, "__esModule", { value: true });
25
- exports.Environments = void 0;
26
- const types_js_1 = require("./types.js");
27
- class Environments {
28
- constructor(inner) {
29
- _Environments_inner.set(this, void 0);
30
- __classPrivateFieldSet(this, _Environments_inner, inner, "f");
31
- }
32
- /**
33
- * Get environment variables belonging to an Environment.
34
- */
35
- getVariables(environmentId) {
36
- return __awaiter(this, void 0, void 0, function* () {
37
- const invocationConfig = {
38
- invocation: {
39
- clientId: __classPrivateFieldGet(this, _Environments_inner, "f").id,
40
- parameters: {
41
- name: "EnvironmentsGetVariables",
42
- parameters: {
43
- environment_id: environmentId,
44
- },
45
- },
46
- },
47
- };
48
- return JSON.parse(yield __classPrivateFieldGet(this, _Environments_inner, "f").invoke(invocationConfig), types_js_1.ReviverFunc);
49
- });
50
- }
51
- }
52
- exports.Environments = Environments;
53
- _Environments_inner = new WeakMap();
@@ -1,9 +0,0 @@
1
- export declare class DesktopSessionExpiredError extends Error {
2
- message: string;
3
- constructor(message: string);
4
- }
5
- export declare class RateLimitExceededError extends Error {
6
- message: string;
7
- constructor(message: string);
8
- }
9
- export declare const throwError: (errString: string) => never;
@@ -1,36 +0,0 @@
1
- "use strict";
2
- // Code generated by op-codegen - DO NOT EDIT MANUALLY
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.throwError = exports.RateLimitExceededError = exports.DesktopSessionExpiredError = void 0;
5
- class DesktopSessionExpiredError extends Error {
6
- constructor(message) {
7
- super();
8
- this.message = message;
9
- }
10
- }
11
- exports.DesktopSessionExpiredError = DesktopSessionExpiredError;
12
- class RateLimitExceededError extends Error {
13
- constructor(message) {
14
- super();
15
- this.message = message;
16
- }
17
- }
18
- exports.RateLimitExceededError = RateLimitExceededError;
19
- const throwError = (errString) => {
20
- let err;
21
- try {
22
- err = JSON.parse(errString);
23
- }
24
- catch (e) {
25
- throw new Error(errString);
26
- }
27
- switch (err.name) {
28
- case "DesktopSessionExpired":
29
- throw new DesktopSessionExpiredError(err.message);
30
- case "RateLimitExceeded":
31
- throw new RateLimitExceededError(err.message);
32
- default:
33
- throw new Error(err.message);
34
- }
35
- };
36
- exports.throwError = throwError;
@@ -1,19 +0,0 @@
1
- import { InnerClient } from "./core.js";
2
- import { Group, GroupGetParams } from "./types.js";
3
- /**
4
- * The Groups API holds all the operations the SDK client can perform on 1Password groups.
5
- */
6
- export interface GroupsApi {
7
- /**
8
- * Get a group by its ID and parameters.
9
- */
10
- get(groupId: string, groupParams: GroupGetParams): Promise<Group>;
11
- }
12
- export declare class Groups implements GroupsApi {
13
- #private;
14
- constructor(inner: InnerClient);
15
- /**
16
- * Get a group by its ID and parameters.
17
- */
18
- get(groupId: string, groupParams: GroupGetParams): Promise<Group>;
19
- }