@1password/sdk 0.4.0-beta.1 → 0.4.0-beta.2

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.
@@ -10,6 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.createClientWithCore = void 0;
13
+ const core_js_1 = require("./core.js");
13
14
  const configuration_js_1 = require("./configuration.js");
14
15
  const client_js_1 = require("./client.js");
15
16
  const shared_lib_core_js_1 = require("./shared_lib_core.js");
@@ -26,10 +27,7 @@ const createClientWithCore = (config, core) => __awaiter(void 0, void 0, void 0,
26
27
  core.setInner(new shared_lib_core_js_1.SharedLibCore(authConfig.accountName));
27
28
  }
28
29
  const clientId = yield core.initClient(authConfig);
29
- const inner = {
30
- id: parseInt(clientId, 10),
31
- core,
32
- };
30
+ const inner = new core_js_1.InnerClient(parseInt(clientId, 10), core, authConfig);
33
31
  const client = new client_js_1.Client(inner);
34
32
  // Cleans up associated memory from core when client instance goes out of scope.
35
33
  finalizationRegistry.register(client, inner);
@@ -1,6 +1,6 @@
1
1
  import { ClientAuthConfig } from "./core.js";
2
2
  export declare const LANGUAGE = "JS";
3
- export declare const VERSION = "0040001";
3
+ export declare const VERSION = "0040002";
4
4
  export interface ClientConfiguration {
5
5
  auth: Auth;
6
6
  integrationName: string;
package/dist/core.d.ts CHANGED
@@ -82,8 +82,11 @@ export declare class SharedCore {
82
82
  /**
83
83
  * Represents the client instance on which a call is made.
84
84
  */
85
- export interface InnerClient {
85
+ export declare class InnerClient {
86
86
  id: number;
87
- core: SharedCore;
87
+ readonly core: SharedCore;
88
+ config: ClientAuthConfig;
89
+ constructor(id: number, core: SharedCore, config: ClientAuthConfig);
90
+ invoke(config: InvokeConfig): Promise<string>;
88
91
  }
89
92
  export {};
package/dist/core.js CHANGED
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.SharedCore = exports.WasmCore = void 0;
12
+ exports.InnerClient = exports.SharedCore = exports.WasmCore = void 0;
13
13
  const sdk_core_1 = require("@1password/sdk-core");
14
14
  const types_1 = require("./types");
15
15
  const errors_1 = require("./errors");
@@ -61,12 +61,7 @@ class SharedCore {
61
61
  initClient(config) {
62
62
  return __awaiter(this, void 0, void 0, function* () {
63
63
  const serializedConfig = JSON.stringify(config);
64
- try {
65
- return yield this.inner.initClient(serializedConfig);
66
- }
67
- catch (e) {
68
- (0, errors_1.throwError)(e);
69
- }
64
+ return this.inner.initClient(serializedConfig);
70
65
  });
71
66
  }
72
67
  invoke(config) {
@@ -77,12 +72,7 @@ class SharedCore {
77
72
  if (new TextEncoder().encode(serializedConfig).length > messageLimit) {
78
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."`);
79
74
  }
80
- try {
81
- return yield this.inner.invoke(serializedConfig);
82
- }
83
- catch (e) {
84
- (0, errors_1.throwError)(e);
85
- }
75
+ return this.inner.invoke(serializedConfig);
86
76
  });
87
77
  }
88
78
  invoke_sync(config) {
@@ -92,12 +82,7 @@ class SharedCore {
92
82
  if (new TextEncoder().encode(serializedConfig).length > messageLimit) {
93
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.`);
94
84
  }
95
- try {
96
- return (0, sdk_core_1.invoke_sync)(serializedConfig);
97
- }
98
- catch (e) {
99
- (0, errors_1.throwError)(e);
100
- }
85
+ return (0, sdk_core_1.invoke_sync)(serializedConfig);
101
86
  }
102
87
  releaseClient(clientId) {
103
88
  const serializedId = JSON.stringify(clientId);
@@ -105,3 +90,30 @@ class SharedCore {
105
90
  }
106
91
  }
107
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;
package/dist/errors.d.ts CHANGED
@@ -1,3 +1,7 @@
1
+ export declare class DesktopSessionExpiredError extends Error {
2
+ message: string;
3
+ constructor(message: string);
4
+ }
1
5
  export declare class RateLimitExceededError extends Error {
2
6
  message: string;
3
7
  constructor(message: string);
package/dist/errors.js CHANGED
@@ -1,7 +1,14 @@
1
1
  "use strict";
2
2
  // Code generated by op-codegen - DO NOT EDIT MANUALLY
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.throwError = exports.RateLimitExceededError = void 0;
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;
5
12
  class RateLimitExceededError extends Error {
6
13
  constructor(message) {
7
14
  super();
@@ -18,6 +25,8 @@ const throwError = (errString) => {
18
25
  throw new Error(errString);
19
26
  }
20
27
  switch (err.name) {
28
+ case "DesktopSessionExpired":
29
+ throw new DesktopSessionExpiredError(err.message);
21
30
  case "RateLimitExceeded":
22
31
  throw new RateLimitExceededError(err.message);
23
32
  default:
package/dist/groups.js CHANGED
@@ -43,7 +43,7 @@ class Groups {
43
43
  },
44
44
  },
45
45
  };
46
- return JSON.parse(yield __classPrivateFieldGet(this, _Groups_inner, "f").core.invoke(invocationConfig), types_js_1.ReviverFunc);
46
+ return JSON.parse(yield __classPrivateFieldGet(this, _Groups_inner, "f").invoke(invocationConfig), types_js_1.ReviverFunc);
47
47
  });
48
48
  }
49
49
  }
package/dist/items.js CHANGED
@@ -49,7 +49,7 @@ class Items {
49
49
  },
50
50
  },
51
51
  };
52
- return JSON.parse(yield __classPrivateFieldGet(this, _Items_inner, "f").core.invoke(invocationConfig), types_js_1.ReviverFunc);
52
+ return JSON.parse(yield __classPrivateFieldGet(this, _Items_inner, "f").invoke(invocationConfig), types_js_1.ReviverFunc);
53
53
  });
54
54
  }
55
55
  /**
@@ -69,7 +69,7 @@ class Items {
69
69
  },
70
70
  },
71
71
  };
72
- return JSON.parse(yield __classPrivateFieldGet(this, _Items_inner, "f").core.invoke(invocationConfig), types_js_1.ReviverFunc);
72
+ return JSON.parse(yield __classPrivateFieldGet(this, _Items_inner, "f").invoke(invocationConfig), types_js_1.ReviverFunc);
73
73
  });
74
74
  }
75
75
  /**
@@ -89,7 +89,7 @@ class Items {
89
89
  },
90
90
  },
91
91
  };
92
- return JSON.parse(yield __classPrivateFieldGet(this, _Items_inner, "f").core.invoke(invocationConfig), types_js_1.ReviverFunc);
92
+ return JSON.parse(yield __classPrivateFieldGet(this, _Items_inner, "f").invoke(invocationConfig), types_js_1.ReviverFunc);
93
93
  });
94
94
  }
95
95
  /**
@@ -109,7 +109,7 @@ class Items {
109
109
  },
110
110
  },
111
111
  };
112
- return JSON.parse(yield __classPrivateFieldGet(this, _Items_inner, "f").core.invoke(invocationConfig), types_js_1.ReviverFunc);
112
+ return JSON.parse(yield __classPrivateFieldGet(this, _Items_inner, "f").invoke(invocationConfig), types_js_1.ReviverFunc);
113
113
  });
114
114
  }
115
115
  /**
@@ -128,7 +128,7 @@ class Items {
128
128
  },
129
129
  },
130
130
  };
131
- return JSON.parse(yield __classPrivateFieldGet(this, _Items_inner, "f").core.invoke(invocationConfig), types_js_1.ReviverFunc);
131
+ return JSON.parse(yield __classPrivateFieldGet(this, _Items_inner, "f").invoke(invocationConfig), types_js_1.ReviverFunc);
132
132
  });
133
133
  }
134
134
  /**
@@ -148,7 +148,7 @@ class Items {
148
148
  },
149
149
  },
150
150
  };
151
- yield __classPrivateFieldGet(this, _Items_inner, "f").core.invoke(invocationConfig);
151
+ yield __classPrivateFieldGet(this, _Items_inner, "f").invoke(invocationConfig);
152
152
  });
153
153
  }
154
154
  /**
@@ -168,7 +168,7 @@ class Items {
168
168
  },
169
169
  },
170
170
  };
171
- return JSON.parse(yield __classPrivateFieldGet(this, _Items_inner, "f").core.invoke(invocationConfig), types_js_1.ReviverFunc);
171
+ return JSON.parse(yield __classPrivateFieldGet(this, _Items_inner, "f").invoke(invocationConfig), types_js_1.ReviverFunc);
172
172
  });
173
173
  }
174
174
  /**
@@ -188,7 +188,7 @@ class Items {
188
188
  },
189
189
  },
190
190
  };
191
- yield __classPrivateFieldGet(this, _Items_inner, "f").core.invoke(invocationConfig);
191
+ yield __classPrivateFieldGet(this, _Items_inner, "f").invoke(invocationConfig);
192
192
  });
193
193
  }
194
194
  /**
@@ -208,7 +208,7 @@ class Items {
208
208
  },
209
209
  },
210
210
  };
211
- return JSON.parse(yield __classPrivateFieldGet(this, _Items_inner, "f").core.invoke(invocationConfig), types_js_1.ReviverFunc);
211
+ return JSON.parse(yield __classPrivateFieldGet(this, _Items_inner, "f").invoke(invocationConfig), types_js_1.ReviverFunc);
212
212
  });
213
213
  }
214
214
  }
@@ -46,7 +46,7 @@ class ItemsFiles {
46
46
  },
47
47
  },
48
48
  };
49
- return JSON.parse(yield __classPrivateFieldGet(this, _ItemsFiles_inner, "f").core.invoke(invocationConfig), types_js_1.ReviverFunc);
49
+ return JSON.parse(yield __classPrivateFieldGet(this, _ItemsFiles_inner, "f").invoke(invocationConfig), types_js_1.ReviverFunc);
50
50
  });
51
51
  }
52
52
  /**
@@ -67,7 +67,7 @@ class ItemsFiles {
67
67
  },
68
68
  },
69
69
  };
70
- return JSON.parse(yield __classPrivateFieldGet(this, _ItemsFiles_inner, "f").core.invoke(invocationConfig), types_js_1.ReviverFunc);
70
+ return JSON.parse(yield __classPrivateFieldGet(this, _ItemsFiles_inner, "f").invoke(invocationConfig), types_js_1.ReviverFunc);
71
71
  });
72
72
  }
73
73
  /**
@@ -88,7 +88,7 @@ class ItemsFiles {
88
88
  },
89
89
  },
90
90
  };
91
- return JSON.parse(yield __classPrivateFieldGet(this, _ItemsFiles_inner, "f").core.invoke(invocationConfig), types_js_1.ReviverFunc);
91
+ return JSON.parse(yield __classPrivateFieldGet(this, _ItemsFiles_inner, "f").invoke(invocationConfig), types_js_1.ReviverFunc);
92
92
  });
93
93
  }
94
94
  /**
@@ -108,7 +108,7 @@ class ItemsFiles {
108
108
  },
109
109
  },
110
110
  };
111
- return JSON.parse(yield __classPrivateFieldGet(this, _ItemsFiles_inner, "f").core.invoke(invocationConfig), types_js_1.ReviverFunc);
111
+ return JSON.parse(yield __classPrivateFieldGet(this, _ItemsFiles_inner, "f").invoke(invocationConfig), types_js_1.ReviverFunc);
112
112
  });
113
113
  }
114
114
  }
@@ -46,7 +46,7 @@ class ItemsShares {
46
46
  },
47
47
  },
48
48
  };
49
- return JSON.parse(yield __classPrivateFieldGet(this, _ItemsShares_inner, "f").core.invoke(invocationConfig), types_js_1.ReviverFunc);
49
+ return JSON.parse(yield __classPrivateFieldGet(this, _ItemsShares_inner, "f").invoke(invocationConfig), types_js_1.ReviverFunc);
50
50
  });
51
51
  }
52
52
  /**
@@ -66,7 +66,7 @@ class ItemsShares {
66
66
  },
67
67
  },
68
68
  };
69
- return JSON.parse(yield __classPrivateFieldGet(this, _ItemsShares_inner, "f").core.invoke(invocationConfig), types_js_1.ReviverFunc);
69
+ return JSON.parse(yield __classPrivateFieldGet(this, _ItemsShares_inner, "f").invoke(invocationConfig), types_js_1.ReviverFunc);
70
70
  });
71
71
  }
72
72
  /**
@@ -87,7 +87,7 @@ class ItemsShares {
87
87
  },
88
88
  },
89
89
  };
90
- return JSON.parse(yield __classPrivateFieldGet(this, _ItemsShares_inner, "f").core.invoke(invocationConfig), types_js_1.ReviverFunc);
90
+ return JSON.parse(yield __classPrivateFieldGet(this, _ItemsShares_inner, "f").invoke(invocationConfig), types_js_1.ReviverFunc);
91
91
  });
92
92
  }
93
93
  }
package/dist/secrets.d.ts CHANGED
@@ -2,7 +2,7 @@ import { InnerClient } from "./core.js";
2
2
  import { GeneratePasswordResponse, PasswordRecipe, ResolveAllResponse } from "./types.js";
3
3
  /**
4
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>
5
+ * Use secret reference URIs to securely load secrets from 1Password: `op://<vault-name>/<item-name>[/<section-name>]/<field-name>`
6
6
  */
7
7
  export interface SecretsApi {
8
8
  /**
package/dist/secrets.js CHANGED
@@ -46,7 +46,7 @@ class Secrets {
46
46
  },
47
47
  },
48
48
  };
49
- return JSON.parse(yield __classPrivateFieldGet(this, _Secrets_inner, "f").core.invoke(invocationConfig), types_js_1.ReviverFunc);
49
+ return JSON.parse(yield __classPrivateFieldGet(this, _Secrets_inner, "f").invoke(invocationConfig), types_js_1.ReviverFunc);
50
50
  });
51
51
  }
52
52
  /**
@@ -65,7 +65,7 @@ class Secrets {
65
65
  },
66
66
  },
67
67
  };
68
- return JSON.parse(yield __classPrivateFieldGet(this, _Secrets_inner, "f").core.invoke(invocationConfig), types_js_1.ReviverFunc);
68
+ return JSON.parse(yield __classPrivateFieldGet(this, _Secrets_inner, "f").invoke(invocationConfig), types_js_1.ReviverFunc);
69
69
  });
70
70
  }
71
71
  /**
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
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
+ })();
25
35
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
36
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
37
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -36,6 +46,7 @@ exports.SharedLibCore = void 0;
36
46
  const fs = __importStar(require("fs"));
37
47
  const os = __importStar(require("os"));
38
48
  const path = __importStar(require("path"));
49
+ const errors_1 = require("./errors");
39
50
  /**
40
51
  * Find the 1Password shared lib path by asking an the wasm core synchronously.
41
52
  */
@@ -58,6 +69,14 @@ const find1PasswordLibPath = () => {
58
69
  "/snap/bin/1password/libop_sdk_ipc_client.so",
59
70
  ];
60
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;
61
80
  default:
62
81
  throw new Error(`Unsupported platform: ${platform}`);
63
82
  }
@@ -118,30 +137,23 @@ class SharedLibCore {
118
137
  payload: inputEncoded,
119
138
  };
120
139
  const inputBuf = Buffer.from(JSON.stringify(req), "utf8");
121
- try {
122
- const nativeResponse = yield this.lib.sendMessage(inputBuf);
123
- if (!(nativeResponse instanceof Uint8Array)) {
124
- throw new Error(`Native function returned an unexpected type. Expected Uint8Array, got ${typeof nativeResponse}`);
125
- }
126
- const respString = new TextDecoder().decode(nativeResponse);
127
- const response = JSON.parse(respString);
128
- if (response.success) {
129
- const decodedPayload = Buffer.from(response.payload).toString("utf8");
130
- // On success, the payload is the actual result string
131
- return decodedPayload;
132
- }
133
- else {
134
- // On failure, convert the error payload to a readable string and throw
135
- const errorMessage = Array.isArray(response.payload)
136
- ? String.fromCharCode(...response.payload)
137
- : JSON.stringify(response.payload);
138
- throw new Error(`Native library returned an error: ${errorMessage}`);
139
- }
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;
140
150
  }
141
- catch (e) {
142
- // Catch errors from the native call or from JSON parsing
143
- console.error("An error occurred during the native library call:", e);
144
- throw e;
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);
145
157
  }
146
158
  });
147
159
  }
package/dist/types.d.ts CHANGED
@@ -114,9 +114,28 @@ export interface Group {
114
114
  state: GroupState;
115
115
  vaultAccess?: VaultAccess[];
116
116
  }
117
+ /**
118
+ * Represents a group's access to a 1Password vault.
119
+ * This is used for granting permissions
120
+ */
121
+ export interface GroupAccess {
122
+ /** The group's ID */
123
+ group_id: string;
124
+ /** The group's set of permissions for the vault */
125
+ permissions: number;
126
+ }
117
127
  export interface GroupGetParams {
118
128
  vaultPermissions?: boolean;
119
129
  }
130
+ /** Represents a group's access to a 1Password vault. */
131
+ export interface GroupVaultAccess {
132
+ /** The vault's ID */
133
+ vault_id: string;
134
+ /** The group's ID */
135
+ group_id: string;
136
+ /** The group's set of permissions for the vault */
137
+ permissions: number;
138
+ }
120
139
  export declare enum ItemCategory {
121
140
  Login = "Login",
122
141
  SecureNote = "SecureNote",
@@ -203,7 +222,7 @@ export interface ItemSection {
203
222
  * Controls the auto-fill behavior of a website.
204
223
  *
205
224
  *
206
- * For more information, visit https://support.1password.com/autofill-behavior/
225
+ * For more information, visit <https://support.1password.com/autofill-behavior/>
207
226
  */
208
227
  export declare enum AutofillBehavior {
209
228
  /** Auto-fill any page that’s part of the website, including subdomains */
@@ -221,7 +240,7 @@ export interface Website {
221
240
  /**
222
241
  * The auto-fill behavior of the website
223
242
  *
224
- * For more information, visit https://support.1password.com/autofill-behavior/
243
+ * For more information, visit <https://support.1password.com/autofill-behavior/>
225
244
  */
226
245
  autofillBehavior: AutofillBehavior;
227
246
  }
@@ -703,6 +722,20 @@ export declare enum WordListType {
703
722
  /** Three (random) letter "words" */
704
723
  ThreeLetters = "threeLetters"
705
724
  }
725
+ export declare const ARCHIVE_ITEMS: number;
726
+ export declare const CREATE_ITEMS: number;
727
+ export declare const DELETE_ITEMS: number;
728
+ export declare const EXPORT_ITEMS: number;
729
+ export declare const IMPORT_ITEMS: number;
730
+ export declare const MANAGE_VAULT: number;
731
+ export declare const NO_ACCESS: number;
732
+ export declare const PRINT_ITEMS: number;
733
+ export declare const READ_ITEMS: number;
734
+ export declare const RECOVER_VAULT: number;
735
+ export declare const REVEAL_ITEM_PASSWORD: number;
736
+ export declare const SEND_ITEMS: number;
737
+ export declare const UPDATE_ITEMS: number;
738
+ export declare const UPDATE_ITEM_HISTORY: number;
706
739
  /**
707
740
  * Custom JSON reviver and replacer functions for dynamic data transformation
708
741
  * ReviverFunc is used during JSON parsing to detect and transform specific data structures
package/dist/types.js CHANGED
@@ -3,7 +3,7 @@
3
3
  Generated by typeshare 1.13.2
4
4
  */
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.ReplacerFunc = exports.ReviverFunc = exports.WordListType = exports.SeparatorType = exports.VaultType = exports.AllowedRecipientType = exports.AllowedType = exports.ItemShareDuration = exports.ItemState = exports.AutofillBehavior = exports.ItemFieldType = exports.ItemCategory = exports.VaultAccessorType = exports.GroupState = exports.GroupType = void 0;
6
+ exports.ReplacerFunc = exports.ReviverFunc = exports.UPDATE_ITEM_HISTORY = exports.UPDATE_ITEMS = exports.SEND_ITEMS = exports.REVEAL_ITEM_PASSWORD = exports.RECOVER_VAULT = exports.READ_ITEMS = exports.PRINT_ITEMS = exports.NO_ACCESS = exports.MANAGE_VAULT = exports.IMPORT_ITEMS = exports.EXPORT_ITEMS = exports.DELETE_ITEMS = exports.CREATE_ITEMS = exports.ARCHIVE_ITEMS = exports.WordListType = exports.SeparatorType = exports.VaultType = exports.AllowedRecipientType = exports.AllowedType = exports.ItemShareDuration = exports.ItemState = exports.AutofillBehavior = exports.ItemFieldType = exports.ItemCategory = exports.VaultAccessorType = exports.GroupState = exports.GroupType = void 0;
7
7
  var GroupType;
8
8
  (function (GroupType) {
9
9
  /**
@@ -107,7 +107,7 @@ var ItemFieldType;
107
107
  * Controls the auto-fill behavior of a website.
108
108
  *
109
109
  *
110
- * For more information, visit https://support.1password.com/autofill-behavior/
110
+ * For more information, visit <https://support.1password.com/autofill-behavior/>
111
111
  */
112
112
  var AutofillBehavior;
113
113
  (function (AutofillBehavior) {
@@ -214,6 +214,20 @@ var WordListType;
214
214
  /** Three (random) letter "words" */
215
215
  WordListType["ThreeLetters"] = "threeLetters";
216
216
  })(WordListType || (exports.WordListType = WordListType = {}));
217
+ exports.ARCHIVE_ITEMS = 256;
218
+ exports.CREATE_ITEMS = 128;
219
+ exports.DELETE_ITEMS = 512;
220
+ exports.EXPORT_ITEMS = 4194304;
221
+ exports.IMPORT_ITEMS = 2097152;
222
+ exports.MANAGE_VAULT = 2;
223
+ exports.NO_ACCESS = 0;
224
+ exports.PRINT_ITEMS = 8388608;
225
+ exports.READ_ITEMS = 32;
226
+ exports.RECOVER_VAULT = 1;
227
+ exports.REVEAL_ITEM_PASSWORD = 16;
228
+ exports.SEND_ITEMS = 1048576;
229
+ exports.UPDATE_ITEMS = 64;
230
+ exports.UPDATE_ITEM_HISTORY = 1024;
217
231
  /**
218
232
  * Custom JSON reviver and replacer functions for dynamic data transformation
219
233
  * ReviverFunc is used during JSON parsing to detect and transform specific data structures
package/dist/vaults.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { InnerClient } from "./core.js";
2
- import { Vault, VaultGetParams, VaultListParams, VaultOverview } from "./types.js";
2
+ import { GroupAccess, GroupVaultAccess, Vault, VaultGetParams, VaultListParams, VaultOverview } from "./types.js";
3
3
  /**
4
4
  * The Vaults API holds all the operations the SDK client can perform on 1Password vaults.
5
5
  */
@@ -7,9 +7,12 @@ export interface VaultsApi {
7
7
  /**
8
8
  * List information about vaults that's configurable based on some input parameters.
9
9
  */
10
- list(params?: VaultListParams): Promise<VaultOverview[]>;
10
+ list(params: VaultListParams | undefined): Promise<VaultOverview[]>;
11
11
  getOverview(vaultUuid: string): Promise<VaultOverview>;
12
12
  get(vaultUuid: string, vaultParams: VaultGetParams): Promise<Vault>;
13
+ grantGroupPermissions(vaultId: string, groupPermissionsList: GroupAccess[]): any;
14
+ updateGroupPermissions(groupPermissionsList: GroupVaultAccess[]): any;
15
+ revokeGroupPermissions(vaultId: string, groupId: string): any;
13
16
  }
14
17
  export declare class Vaults implements VaultsApi {
15
18
  #private;
@@ -17,7 +20,10 @@ export declare class Vaults implements VaultsApi {
17
20
  /**
18
21
  * List information about vaults that's configurable based on some input parameters.
19
22
  */
20
- list(params: VaultListParams): Promise<VaultOverview[]>;
23
+ list(params: VaultListParams | undefined): Promise<VaultOverview[]>;
21
24
  getOverview(vaultUuid: string): Promise<VaultOverview>;
22
25
  get(vaultUuid: string, vaultParams: VaultGetParams): Promise<Vault>;
26
+ grantGroupPermissions(vaultId: string, groupPermissionsList: GroupAccess[]): Promise<void>;
27
+ updateGroupPermissions(groupPermissionsList: GroupVaultAccess[]): Promise<void>;
28
+ revokeGroupPermissions(vaultId: string, groupId: string): Promise<void>;
23
29
  }
package/dist/vaults.js CHANGED
@@ -45,7 +45,7 @@ class Vaults {
45
45
  },
46
46
  },
47
47
  };
48
- return JSON.parse(yield __classPrivateFieldGet(this, _Vaults_inner, "f").core.invoke(invocationConfig), types_js_1.ReviverFunc);
48
+ return JSON.parse(yield __classPrivateFieldGet(this, _Vaults_inner, "f").invoke(invocationConfig), types_js_1.ReviverFunc);
49
49
  });
50
50
  }
51
51
  getOverview(vaultUuid) {
@@ -61,7 +61,7 @@ class Vaults {
61
61
  },
62
62
  },
63
63
  };
64
- return JSON.parse(yield __classPrivateFieldGet(this, _Vaults_inner, "f").core.invoke(invocationConfig), types_js_1.ReviverFunc);
64
+ return JSON.parse(yield __classPrivateFieldGet(this, _Vaults_inner, "f").invoke(invocationConfig), types_js_1.ReviverFunc);
65
65
  });
66
66
  }
67
67
  get(vaultUuid, vaultParams) {
@@ -78,7 +78,57 @@ class Vaults {
78
78
  },
79
79
  },
80
80
  };
81
- return JSON.parse(yield __classPrivateFieldGet(this, _Vaults_inner, "f").core.invoke(invocationConfig), types_js_1.ReviverFunc);
81
+ return JSON.parse(yield __classPrivateFieldGet(this, _Vaults_inner, "f").invoke(invocationConfig), types_js_1.ReviverFunc);
82
+ });
83
+ }
84
+ grantGroupPermissions(vaultId, groupPermissionsList) {
85
+ return __awaiter(this, void 0, void 0, function* () {
86
+ const invocationConfig = {
87
+ invocation: {
88
+ clientId: __classPrivateFieldGet(this, _Vaults_inner, "f").id,
89
+ parameters: {
90
+ name: "VaultsGrantGroupPermissions",
91
+ parameters: {
92
+ vault_id: vaultId,
93
+ group_permissions_list: groupPermissionsList,
94
+ },
95
+ },
96
+ },
97
+ };
98
+ yield __classPrivateFieldGet(this, _Vaults_inner, "f").invoke(invocationConfig);
99
+ });
100
+ }
101
+ updateGroupPermissions(groupPermissionsList) {
102
+ return __awaiter(this, void 0, void 0, function* () {
103
+ const invocationConfig = {
104
+ invocation: {
105
+ clientId: __classPrivateFieldGet(this, _Vaults_inner, "f").id,
106
+ parameters: {
107
+ name: "VaultsUpdateGroupPermissions",
108
+ parameters: {
109
+ group_permissions_list: groupPermissionsList,
110
+ },
111
+ },
112
+ },
113
+ };
114
+ yield __classPrivateFieldGet(this, _Vaults_inner, "f").invoke(invocationConfig);
115
+ });
116
+ }
117
+ revokeGroupPermissions(vaultId, groupId) {
118
+ return __awaiter(this, void 0, void 0, function* () {
119
+ const invocationConfig = {
120
+ invocation: {
121
+ clientId: __classPrivateFieldGet(this, _Vaults_inner, "f").id,
122
+ parameters: {
123
+ name: "VaultsRevokeGroupPermissions",
124
+ parameters: {
125
+ vault_id: vaultId,
126
+ group_id: groupId,
127
+ },
128
+ },
129
+ },
130
+ };
131
+ yield __classPrivateFieldGet(this, _Vaults_inner, "f").invoke(invocationConfig);
82
132
  });
83
133
  }
84
134
  }
package/dist/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const SDK_VERSION = "0.4.0-beta.1";
2
- export declare const SDK_BUILD_NUMBER = "0040001";
1
+ export declare const SDK_VERSION = "0.4.0-beta.2";
2
+ export declare const SDK_BUILD_NUMBER = "0040002";
package/dist/version.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SDK_BUILD_NUMBER = exports.SDK_VERSION = void 0;
4
- exports.SDK_VERSION = "0.4.0-beta.1";
5
- exports.SDK_BUILD_NUMBER = "0040001";
6
- const SDK_CORE_VERSION = "0.4.0-beta.1";
4
+ exports.SDK_VERSION = "0.4.0-beta.2";
5
+ exports.SDK_BUILD_NUMBER = "0040002";
6
+ const SDK_CORE_VERSION = "0.4.0-beta.2";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@1password/sdk",
3
- "version": "0.4.0-beta.1",
3
+ "version": "0.4.0-beta.2",
4
4
  "description": "The 1Password JavaScript SDK offers programmatic read access to your secrets in 1Password in an interface native to JavaScript. The SDK currently supports `Node.JS`",
5
5
  "scripts": {
6
6
  "build": "tsc",
@@ -26,7 +26,7 @@
26
26
  "main": "./dist/sdk.js",
27
27
  "types": "./dist/sdk.d.ts",
28
28
  "dependencies": {
29
- "@1password/sdk-core": "0.4.0-beta.1"
29
+ "@1password/sdk-core": "0.4.0-beta.2"
30
30
  },
31
31
  "devDependencies": {
32
32
  "@1password/eslint-config": "^4.0.0",