@1password/sdk 0.0.0-credential-broker-dev-preview

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 (44) hide show
  1. package/README.md +220 -0
  2. package/dist/client.d.ts +23 -0
  3. package/dist/client.js +32 -0
  4. package/dist/client_builder.d.ts +18 -0
  5. package/dist/client_builder.js +64 -0
  6. package/dist/configuration.d.ts +33 -0
  7. package/dist/configuration.js +58 -0
  8. package/dist/core.d.ts +115 -0
  9. package/dist/core.js +154 -0
  10. package/dist/credential_broker.d.ts +28 -0
  11. package/dist/credential_broker.js +31 -0
  12. package/dist/credential_broker_access_requests.d.ts +43 -0
  13. package/dist/credential_broker_access_requests.js +78 -0
  14. package/dist/credential_broker_environment_variables.d.ts +33 -0
  15. package/dist/credential_broker_environment_variables.js +58 -0
  16. package/dist/credential_broker_logins.d.ts +38 -0
  17. package/dist/credential_broker_logins.js +77 -0
  18. package/dist/environments.d.ts +82 -0
  19. package/dist/environments.js +132 -0
  20. package/dist/errors.d.ts +13 -0
  21. package/dist/errors.js +45 -0
  22. package/dist/groups.d.ts +19 -0
  23. package/dist/groups.js +54 -0
  24. package/dist/items.d.ts +89 -0
  25. package/dist/items.js +216 -0
  26. package/dist/items_files.d.ts +40 -0
  27. package/dist/items_files.js +116 -0
  28. package/dist/items_shares.d.ts +32 -0
  29. package/dist/items_shares.js +95 -0
  30. package/dist/sdk.d.ts +24 -0
  31. package/dist/sdk.js +57 -0
  32. package/dist/secrets.d.ts +36 -0
  33. package/dist/secrets.js +107 -0
  34. package/dist/shared_lib_core.d.ts +17 -0
  35. package/dist/shared_lib_core.js +183 -0
  36. package/dist/types.d.ts +972 -0
  37. package/dist/types.js +279 -0
  38. package/dist/vaults.d.ts +83 -0
  39. package/dist/vaults.js +209 -0
  40. package/dist/version.d.ts +2 -0
  41. package/dist/version.js +6 -0
  42. package/dist/web.d.ts +11 -0
  43. package/dist/web.js +55 -0
  44. package/package.json +54 -0
package/dist/types.js ADDED
@@ -0,0 +1,279 @@
1
+ "use strict";
2
+ /*
3
+ Generated by typeshare 1.13.4
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
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 = exports.AccessRequestEntryType = exports.AccessRequestState = void 0;
7
+ /** The lifecycle state of an access request. */
8
+ var AccessRequestState;
9
+ (function (AccessRequestState) {
10
+ /** The request is awaiting a decision. */
11
+ AccessRequestState["Pending"] = "pending";
12
+ /** The request was approved and credentials were granted. */
13
+ AccessRequestState["Resolved"] = "resolved";
14
+ /** The request was denied by the user. */
15
+ AccessRequestState["Denied"] = "denied";
16
+ /** The request could not be processed. */
17
+ AccessRequestState["Failed"] = "failed";
18
+ })(AccessRequestState || (exports.AccessRequestState = AccessRequestState = {}));
19
+ /** The credential types an access request entry can ask for. */
20
+ var AccessRequestEntryType;
21
+ (function (AccessRequestEntryType) {
22
+ /** A login credential (username / password / TOTP). */
23
+ AccessRequestEntryType["Login"] = "login";
24
+ })(AccessRequestEntryType || (exports.AccessRequestEntryType = AccessRequestEntryType = {}));
25
+ var GroupType;
26
+ (function (GroupType) {
27
+ /**
28
+ * The owners group, which gives the following permissions:
29
+ * - Do everything the Admin group can do
30
+ * - See every vault other than the personal vaults
31
+ * - Change people's names
32
+ * - See billing
33
+ * - Change billing
34
+ * - Make other people owners
35
+ * - Delete a person
36
+ */
37
+ GroupType["Owners"] = "owners";
38
+ /**
39
+ * The administrators group, which gives the following permissions:
40
+ * - Perform recovery
41
+ * - Create new vaults
42
+ * - Invite new members
43
+ * - See vault metadata, including the vault name and who has access.
44
+ * - Make other people admins
45
+ */
46
+ GroupType["Administrators"] = "administrators";
47
+ /**
48
+ * The recovery group. It contains recovery keysets, and is added to every vault to allow for recovery.
49
+ *
50
+ * No one is added to this.
51
+ */
52
+ GroupType["Recovery"] = "recovery";
53
+ /**
54
+ * The external account managers group or EAM is a mandatory group for managed accounts that has
55
+ * same permissions as the owners.
56
+ */
57
+ GroupType["ExternalAccountManagers"] = "externalAccountManagers";
58
+ /** Members of a team that a user is on. */
59
+ GroupType["TeamMembers"] = "teamMembers";
60
+ /** A custom, user defined group. */
61
+ GroupType["UserDefined"] = "userDefined";
62
+ /** Support for new or renamed group types */
63
+ GroupType["Unsupported"] = "unsupported";
64
+ })(GroupType || (exports.GroupType = GroupType = {}));
65
+ var GroupState;
66
+ (function (GroupState) {
67
+ /** This group is active */
68
+ GroupState["Active"] = "active";
69
+ /** This group has been deleted */
70
+ GroupState["Deleted"] = "deleted";
71
+ /** This group is in an unknown state */
72
+ GroupState["Unsupported"] = "unsupported";
73
+ })(GroupState || (exports.GroupState = GroupState = {}));
74
+ var VaultAccessorType;
75
+ (function (VaultAccessorType) {
76
+ VaultAccessorType["User"] = "user";
77
+ VaultAccessorType["Group"] = "group";
78
+ VaultAccessorType["Broker"] = "broker";
79
+ })(VaultAccessorType || (exports.VaultAccessorType = VaultAccessorType = {}));
80
+ var ItemCategory;
81
+ (function (ItemCategory) {
82
+ ItemCategory["Login"] = "Login";
83
+ ItemCategory["SecureNote"] = "SecureNote";
84
+ ItemCategory["CreditCard"] = "CreditCard";
85
+ ItemCategory["CryptoWallet"] = "CryptoWallet";
86
+ ItemCategory["Identity"] = "Identity";
87
+ ItemCategory["Password"] = "Password";
88
+ ItemCategory["Document"] = "Document";
89
+ ItemCategory["ApiCredentials"] = "ApiCredentials";
90
+ ItemCategory["BankAccount"] = "BankAccount";
91
+ ItemCategory["Database"] = "Database";
92
+ ItemCategory["DriverLicense"] = "DriverLicense";
93
+ ItemCategory["Email"] = "Email";
94
+ ItemCategory["MedicalRecord"] = "MedicalRecord";
95
+ ItemCategory["Membership"] = "Membership";
96
+ ItemCategory["OutdoorLicense"] = "OutdoorLicense";
97
+ ItemCategory["Passport"] = "Passport";
98
+ ItemCategory["Rewards"] = "Rewards";
99
+ ItemCategory["Router"] = "Router";
100
+ ItemCategory["Server"] = "Server";
101
+ ItemCategory["SshKey"] = "SshKey";
102
+ ItemCategory["SocialSecurityNumber"] = "SocialSecurityNumber";
103
+ ItemCategory["SoftwareLicense"] = "SoftwareLicense";
104
+ ItemCategory["Person"] = "Person";
105
+ ItemCategory["Unsupported"] = "Unsupported";
106
+ })(ItemCategory || (exports.ItemCategory = ItemCategory = {}));
107
+ var ItemFieldType;
108
+ (function (ItemFieldType) {
109
+ ItemFieldType["Text"] = "Text";
110
+ ItemFieldType["Concealed"] = "Concealed";
111
+ ItemFieldType["CreditCardType"] = "CreditCardType";
112
+ ItemFieldType["CreditCardNumber"] = "CreditCardNumber";
113
+ ItemFieldType["Phone"] = "Phone";
114
+ ItemFieldType["Url"] = "Url";
115
+ ItemFieldType["Totp"] = "Totp";
116
+ ItemFieldType["Email"] = "Email";
117
+ ItemFieldType["Reference"] = "Reference";
118
+ ItemFieldType["SshKey"] = "SshKey";
119
+ ItemFieldType["Menu"] = "Menu";
120
+ ItemFieldType["MonthYear"] = "MonthYear";
121
+ ItemFieldType["Address"] = "Address";
122
+ ItemFieldType["Date"] = "Date";
123
+ ItemFieldType["Unsupported"] = "Unsupported";
124
+ })(ItemFieldType || (exports.ItemFieldType = ItemFieldType = {}));
125
+ /**
126
+ * Controls the auto-fill behavior of a website.
127
+ *
128
+ *
129
+ * For more information, visit <https://support.1password.com/autofill-behavior/>
130
+ */
131
+ var AutofillBehavior;
132
+ (function (AutofillBehavior) {
133
+ /** Auto-fill any page that’s part of the website, including subdomains */
134
+ AutofillBehavior["AnywhereOnWebsite"] = "AnywhereOnWebsite";
135
+ /** Auto-fill only if the domain (hostname and port) is an exact match. */
136
+ AutofillBehavior["ExactDomain"] = "ExactDomain";
137
+ /** Never auto-fill on this website */
138
+ AutofillBehavior["Never"] = "Never";
139
+ })(AutofillBehavior || (exports.AutofillBehavior = AutofillBehavior = {}));
140
+ /** Represents the state of an item in the SDK. */
141
+ var ItemState;
142
+ (function (ItemState) {
143
+ /** The item is active */
144
+ ItemState["Active"] = "active";
145
+ /** The item is archived meaning it's hidden from regular view and stored in the archive. */
146
+ ItemState["Archived"] = "archived";
147
+ })(ItemState || (exports.ItemState = ItemState = {}));
148
+ /** The valid duration options for sharing an item */
149
+ var ItemShareDuration;
150
+ (function (ItemShareDuration) {
151
+ /** The share will expire in one hour */
152
+ ItemShareDuration["OneHour"] = "OneHour";
153
+ /** The share will expire in one day */
154
+ ItemShareDuration["OneDay"] = "OneDay";
155
+ /** The share will expire in seven days */
156
+ ItemShareDuration["SevenDays"] = "SevenDays";
157
+ /** The share will expire in fourteen days */
158
+ ItemShareDuration["FourteenDays"] = "FourteenDays";
159
+ /** The share will expire in thirty days */
160
+ ItemShareDuration["ThirtyDays"] = "ThirtyDays";
161
+ })(ItemShareDuration || (exports.ItemShareDuration = ItemShareDuration = {}));
162
+ /** The allowed types of item sharing, enforced by account policy */
163
+ var AllowedType;
164
+ (function (AllowedType) {
165
+ /** Allows creating share links with specific recipients */
166
+ AllowedType["Authenticated"] = "Authenticated";
167
+ /** Allows creating public share links */
168
+ AllowedType["Public"] = "Public";
169
+ })(AllowedType || (exports.AllowedType = AllowedType = {}));
170
+ /** The allowed recipient types of item sharing, enforced by account policy */
171
+ var AllowedRecipientType;
172
+ (function (AllowedRecipientType) {
173
+ /** Recipients can be specified by email address */
174
+ AllowedRecipientType["Email"] = "Email";
175
+ /** Recipients can be specified by domain */
176
+ AllowedRecipientType["Domain"] = "Domain";
177
+ })(AllowedRecipientType || (exports.AllowedRecipientType = AllowedRecipientType = {}));
178
+ /** Represents the vault type. */
179
+ var VaultType;
180
+ (function (VaultType) {
181
+ VaultType["Personal"] = "personal";
182
+ VaultType["Everyone"] = "everyone";
183
+ VaultType["Transfer"] = "transfer";
184
+ VaultType["UserCreated"] = "userCreated";
185
+ VaultType["Unsupported"] = "unsupported";
186
+ })(VaultType || (exports.VaultType = VaultType = {}));
187
+ var SeparatorType;
188
+ (function (SeparatorType) {
189
+ /**
190
+ * Randomly selected digits.
191
+ * E.g, "`correct4horse0battery1staple`"
192
+ */
193
+ SeparatorType["Digits"] = "digits";
194
+ /**
195
+ * Randomly selected digits and symbols.
196
+ * This is useful to get word-based passwords to meet complexity requirements
197
+ * E.g, "`correct4horse-battery1staple`"
198
+ */
199
+ SeparatorType["DigitsAndSymbols"] = "digitsAndSymbols";
200
+ /**
201
+ * Spaces, like the original Diceware.
202
+ * Great for mobile keyboards, not so great when people can overhear you type the password.
203
+ * E.g, "`correct horse battery staple`"
204
+ */
205
+ SeparatorType["Spaces"] = "spaces";
206
+ /**
207
+ * Hyphens "`-`".
208
+ * E.g, "`correct-horse-battery-staple`"
209
+ */
210
+ SeparatorType["Hyphens"] = "hyphens";
211
+ /**
212
+ * "`_`".
213
+ * E.g, "`correct_horse_battery_staple`"
214
+ */
215
+ SeparatorType["Underscores"] = "underscores";
216
+ /**
217
+ * Period (full stop) "`.`".
218
+ * E.g, "`correct.horse.battery.staple`"
219
+ */
220
+ SeparatorType["Periods"] = "periods";
221
+ /**
222
+ * Comma "`,`".
223
+ * E.g, "`correct,horse,battery,staple`"
224
+ */
225
+ SeparatorType["Commas"] = "commas";
226
+ })(SeparatorType || (exports.SeparatorType = SeparatorType = {}));
227
+ var WordListType;
228
+ (function (WordListType) {
229
+ /** Agile wordlist */
230
+ WordListType["FullWords"] = "fullWords";
231
+ /** English-like syllables */
232
+ WordListType["Syllables"] = "syllables";
233
+ /** Three (random) letter "words" */
234
+ WordListType["ThreeLetters"] = "threeLetters";
235
+ })(WordListType || (exports.WordListType = WordListType = {}));
236
+ exports.ARCHIVE_ITEMS = 256;
237
+ exports.CREATE_ITEMS = 128;
238
+ exports.DELETE_ITEMS = 512;
239
+ exports.EXPORT_ITEMS = 4194304;
240
+ exports.IMPORT_ITEMS = 2097152;
241
+ exports.MANAGE_VAULT = 2;
242
+ exports.NO_ACCESS = 0;
243
+ exports.PRINT_ITEMS = 8388608;
244
+ exports.READ_ITEMS = 32;
245
+ exports.RECOVER_VAULT = 1;
246
+ exports.REVEAL_ITEM_PASSWORD = 16;
247
+ exports.SEND_ITEMS = 1048576;
248
+ exports.UPDATE_ITEMS = 64;
249
+ exports.UPDATE_ITEM_HISTORY = 1024;
250
+ /**
251
+ * Custom JSON reviver and replacer functions for dynamic data transformation
252
+ * ReviverFunc is used during JSON parsing to detect and transform specific data structures
253
+ * ReplacerFunc is used during JSON serialization to modify certain values before stringifying.
254
+ * These functions allow for flexible encoding and decoding of data, ensuring that complex types are properly handled when converting between TS objects and JSON
255
+ */
256
+ const ReviverFunc = (key, value) => {
257
+ if (typeof value === "string" &&
258
+ /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?Z$/.test(value) &&
259
+ (key === "createdAt" || key === "updatedAt")) {
260
+ return new Date(value);
261
+ }
262
+ if (Array.isArray(value) &&
263
+ value.every((v) => Number.isInteger(v) && v >= 0 && v <= 255) &&
264
+ value.length > 0) {
265
+ return new Uint8Array(value);
266
+ }
267
+ return value;
268
+ };
269
+ exports.ReviverFunc = ReviverFunc;
270
+ const ReplacerFunc = (key, value) => {
271
+ if (value instanceof Date) {
272
+ return value.toISOString();
273
+ }
274
+ if (value instanceof Uint8Array) {
275
+ return Array.from(value);
276
+ }
277
+ return value;
278
+ };
279
+ exports.ReplacerFunc = ReplacerFunc;
@@ -0,0 +1,83 @@
1
+ import { InnerClient } from "./core.js";
2
+ import { GroupAccess, GroupVaultAccess, Vault, VaultCreateParams, VaultGetParams, VaultListParams, VaultOverview, VaultUpdateParams } from "./types.js";
3
+ /**
4
+ * The Vaults API holds all the operations the SDK client can perform on 1Password vaults.
5
+ */
6
+ export interface VaultsApi {
7
+ /**
8
+ * Create a new user vault.
9
+ */
10
+ create(params: VaultCreateParams): Promise<Vault>;
11
+ /**
12
+ * List information about vaults that's configurable based on some input parameters.
13
+ */
14
+ list(params?: VaultListParams): Promise<VaultOverview[]>;
15
+ /**
16
+ * Get an overview of a vault by its ID.
17
+ */
18
+ getOverview(vaultId: string): Promise<VaultOverview>;
19
+ /**
20
+ * Get detailed vault information by vault ID and parameters.
21
+ */
22
+ get(vaultId: string, vaultParams: VaultGetParams): Promise<Vault>;
23
+ /**
24
+ * Update a vault
25
+ */
26
+ update(vaultId: string, params: VaultUpdateParams): Promise<Vault>;
27
+ /**
28
+ * Delete a vault by its ID.
29
+ */
30
+ delete(vaultId: string): Promise<void>;
31
+ /**
32
+ * Grant group permissions to a vault.
33
+ */
34
+ grantGroupPermissions(vaultId: string, groupPermissionsList: GroupAccess[]): Promise<void>;
35
+ /**
36
+ * Update group permissions for vaults.
37
+ */
38
+ updateGroupPermissions(groupPermissionsList: GroupVaultAccess[]): Promise<void>;
39
+ /**
40
+ * Revoke group permissions from a vault.
41
+ */
42
+ revokeGroupPermissions(vaultId: string, groupId: string): Promise<void>;
43
+ }
44
+ export declare class Vaults implements VaultsApi {
45
+ #private;
46
+ constructor(inner: InnerClient);
47
+ /**
48
+ * Create a new user vault.
49
+ */
50
+ create(params: VaultCreateParams): Promise<Vault>;
51
+ /**
52
+ * List information about vaults that's configurable based on some input parameters.
53
+ */
54
+ list(params?: VaultListParams): Promise<VaultOverview[]>;
55
+ /**
56
+ * Get an overview of a vault by its ID.
57
+ */
58
+ getOverview(vaultId: string): Promise<VaultOverview>;
59
+ /**
60
+ * Get detailed vault information by vault ID and parameters.
61
+ */
62
+ get(vaultId: string, vaultParams: VaultGetParams): Promise<Vault>;
63
+ /**
64
+ * Update a vault
65
+ */
66
+ update(vaultId: string, params: VaultUpdateParams): Promise<Vault>;
67
+ /**
68
+ * Delete a vault by its ID.
69
+ */
70
+ delete(vaultId: string): Promise<void>;
71
+ /**
72
+ * Grant group permissions to a vault.
73
+ */
74
+ grantGroupPermissions(vaultId: string, groupPermissionsList: GroupAccess[]): Promise<void>;
75
+ /**
76
+ * Update group permissions for vaults.
77
+ */
78
+ updateGroupPermissions(groupPermissionsList: GroupVaultAccess[]): Promise<void>;
79
+ /**
80
+ * Revoke group permissions from a vault.
81
+ */
82
+ revokeGroupPermissions(vaultId: string, groupId: string): Promise<void>;
83
+ }
package/dist/vaults.js ADDED
@@ -0,0 +1,209 @@
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 _Vaults_inner;
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ exports.Vaults = void 0;
26
+ const types_js_1 = require("./types.js");
27
+ class Vaults {
28
+ constructor(inner) {
29
+ _Vaults_inner.set(this, void 0);
30
+ __classPrivateFieldSet(this, _Vaults_inner, inner, "f");
31
+ }
32
+ /**
33
+ * Create a new user vault.
34
+ */
35
+ create(params) {
36
+ return __awaiter(this, void 0, void 0, function* () {
37
+ const invocationConfig = {
38
+ invocation: {
39
+ clientId: __classPrivateFieldGet(this, _Vaults_inner, "f").id,
40
+ parameters: {
41
+ name: "VaultsCreate",
42
+ parameters: {
43
+ params,
44
+ },
45
+ },
46
+ },
47
+ };
48
+ return JSON.parse(yield __classPrivateFieldGet(this, _Vaults_inner, "f").invoke(invocationConfig), types_js_1.ReviverFunc);
49
+ });
50
+ }
51
+ /**
52
+ * List information about vaults that's configurable based on some input parameters.
53
+ */
54
+ list(params) {
55
+ return __awaiter(this, void 0, void 0, function* () {
56
+ const invocationConfig = {
57
+ invocation: {
58
+ clientId: __classPrivateFieldGet(this, _Vaults_inner, "f").id,
59
+ parameters: {
60
+ name: "VaultsList",
61
+ parameters: {
62
+ params,
63
+ },
64
+ },
65
+ },
66
+ };
67
+ return JSON.parse(yield __classPrivateFieldGet(this, _Vaults_inner, "f").invoke(invocationConfig), types_js_1.ReviverFunc);
68
+ });
69
+ }
70
+ /**
71
+ * Get an overview of a vault by its ID.
72
+ */
73
+ getOverview(vaultId) {
74
+ return __awaiter(this, void 0, void 0, function* () {
75
+ const invocationConfig = {
76
+ invocation: {
77
+ clientId: __classPrivateFieldGet(this, _Vaults_inner, "f").id,
78
+ parameters: {
79
+ name: "VaultsGetOverview",
80
+ parameters: {
81
+ vault_id: vaultId,
82
+ },
83
+ },
84
+ },
85
+ };
86
+ return JSON.parse(yield __classPrivateFieldGet(this, _Vaults_inner, "f").invoke(invocationConfig), types_js_1.ReviverFunc);
87
+ });
88
+ }
89
+ /**
90
+ * Get detailed vault information by vault ID and parameters.
91
+ */
92
+ get(vaultId, vaultParams) {
93
+ return __awaiter(this, void 0, void 0, function* () {
94
+ const invocationConfig = {
95
+ invocation: {
96
+ clientId: __classPrivateFieldGet(this, _Vaults_inner, "f").id,
97
+ parameters: {
98
+ name: "VaultsGet",
99
+ parameters: {
100
+ vault_id: vaultId,
101
+ vault_params: vaultParams,
102
+ },
103
+ },
104
+ },
105
+ };
106
+ return JSON.parse(yield __classPrivateFieldGet(this, _Vaults_inner, "f").invoke(invocationConfig), types_js_1.ReviverFunc);
107
+ });
108
+ }
109
+ /**
110
+ * Update a vault
111
+ */
112
+ update(vaultId, params) {
113
+ return __awaiter(this, void 0, void 0, function* () {
114
+ const invocationConfig = {
115
+ invocation: {
116
+ clientId: __classPrivateFieldGet(this, _Vaults_inner, "f").id,
117
+ parameters: {
118
+ name: "VaultsUpdate",
119
+ parameters: {
120
+ vault_id: vaultId,
121
+ params,
122
+ },
123
+ },
124
+ },
125
+ };
126
+ return JSON.parse(yield __classPrivateFieldGet(this, _Vaults_inner, "f").invoke(invocationConfig), types_js_1.ReviverFunc);
127
+ });
128
+ }
129
+ /**
130
+ * Delete a vault by its ID.
131
+ */
132
+ delete(vaultId) {
133
+ return __awaiter(this, void 0, void 0, function* () {
134
+ const invocationConfig = {
135
+ invocation: {
136
+ clientId: __classPrivateFieldGet(this, _Vaults_inner, "f").id,
137
+ parameters: {
138
+ name: "VaultsDelete",
139
+ parameters: {
140
+ vault_id: vaultId,
141
+ },
142
+ },
143
+ },
144
+ };
145
+ yield __classPrivateFieldGet(this, _Vaults_inner, "f").invoke(invocationConfig);
146
+ });
147
+ }
148
+ /**
149
+ * Grant group permissions to a vault.
150
+ */
151
+ grantGroupPermissions(vaultId, groupPermissionsList) {
152
+ return __awaiter(this, void 0, void 0, function* () {
153
+ const invocationConfig = {
154
+ invocation: {
155
+ clientId: __classPrivateFieldGet(this, _Vaults_inner, "f").id,
156
+ parameters: {
157
+ name: "VaultsGrantGroupPermissions",
158
+ parameters: {
159
+ vault_id: vaultId,
160
+ group_permissions_list: groupPermissionsList,
161
+ },
162
+ },
163
+ },
164
+ };
165
+ yield __classPrivateFieldGet(this, _Vaults_inner, "f").invoke(invocationConfig);
166
+ });
167
+ }
168
+ /**
169
+ * Update group permissions for vaults.
170
+ */
171
+ updateGroupPermissions(groupPermissionsList) {
172
+ return __awaiter(this, void 0, void 0, function* () {
173
+ const invocationConfig = {
174
+ invocation: {
175
+ clientId: __classPrivateFieldGet(this, _Vaults_inner, "f").id,
176
+ parameters: {
177
+ name: "VaultsUpdateGroupPermissions",
178
+ parameters: {
179
+ group_permissions_list: groupPermissionsList,
180
+ },
181
+ },
182
+ },
183
+ };
184
+ yield __classPrivateFieldGet(this, _Vaults_inner, "f").invoke(invocationConfig);
185
+ });
186
+ }
187
+ /**
188
+ * Revoke group permissions from a vault.
189
+ */
190
+ revokeGroupPermissions(vaultId, groupId) {
191
+ return __awaiter(this, void 0, void 0, function* () {
192
+ const invocationConfig = {
193
+ invocation: {
194
+ clientId: __classPrivateFieldGet(this, _Vaults_inner, "f").id,
195
+ parameters: {
196
+ name: "VaultsRevokeGroupPermissions",
197
+ parameters: {
198
+ vault_id: vaultId,
199
+ group_id: groupId,
200
+ },
201
+ },
202
+ },
203
+ };
204
+ yield __classPrivateFieldGet(this, _Vaults_inner, "f").invoke(invocationConfig);
205
+ });
206
+ }
207
+ }
208
+ exports.Vaults = Vaults;
209
+ _Vaults_inner = new WeakMap();
@@ -0,0 +1,2 @@
1
+ export declare const SDK_VERSION = "0.0.0-credential-broker-dev-preview";
2
+ export declare const SDK_BUILD_NUMBER = "0000000";
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SDK_BUILD_NUMBER = exports.SDK_VERSION = void 0;
4
+ exports.SDK_VERSION = "0.0.0-credential-broker-dev-preview";
5
+ exports.SDK_BUILD_NUMBER = "0000000";
6
+ const SDK_CORE_VERSION = "0.0.0-credential-broker-dev-preview";
package/dist/web.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ import { OAuthClient } from "./client.js";
2
+ import { OAuthClientConfiguration } from "./configuration.js";
3
+ export * from "./client.js";
4
+ export * from "./errors.js";
5
+ export * from "./types.js";
6
+ /**
7
+ * Creates a 1Password OAuth client, authenticated with the credentials returned by the OAuth flow.
8
+ * Only the OAuth client is available on the web; the other clients need Node.
9
+ * @returns The authenticated 1Password OAuth client.
10
+ */
11
+ export declare const createOAuthClient: (config: OAuthClientConfiguration) => Promise<OAuthClient>;
package/dist/web.js ADDED
@@ -0,0 +1,55 @@
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
17
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
18
+ return new (P || (P = Promise))(function (resolve, reject) {
19
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
20
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
21
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
22
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
23
+ });
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.createOAuthClient = void 0;
30
+ const core_js_1 = __importDefault(require("@1password/sdk-core/web/core.js"));
31
+ const core_bg_wasm_1 = __importDefault(require("@1password/sdk-core/web/core_bg.wasm"));
32
+ const client_js_1 = require("./client.js");
33
+ const core_js_2 = require("./core.js");
34
+ __exportStar(require("./client.js"), exports);
35
+ __exportStar(require("./errors.js"), exports);
36
+ __exportStar(require("./types.js"), exports);
37
+ const finalizationRegistry = new FinalizationRegistry((heldClient) => {
38
+ heldClient.core.releaseClient(heldClient.id);
39
+ });
40
+ /**
41
+ * Creates a 1Password OAuth client, authenticated with the credentials returned by the OAuth flow.
42
+ * Only the OAuth client is available on the web; the other clients need Node.
43
+ * @returns The authenticated 1Password OAuth client.
44
+ */
45
+ const createOAuthClient = (config) => __awaiter(void 0, void 0, void 0, function* () {
46
+ // Loads the core wasm on the first call; the glue returns early once loaded.
47
+ yield (0, core_js_1.default)(core_bg_wasm_1.default);
48
+ const core = new core_js_2.SharedCore();
49
+ const clientId = yield core.initClient(config);
50
+ const inner = new core_js_2.InnerClient(parseInt(clientId, 10), core);
51
+ const client = new client_js_1.OAuthClient(inner);
52
+ finalizationRegistry.register(client, inner);
53
+ return client;
54
+ });
55
+ exports.createOAuthClient = createOAuthClient;