Skip to content

Commit f150f0b

Browse files
authored
Merge pull request #161 from 1Password/sdk-core/beta/2025-10-29-8ba31b5b
Add vault permission operations for groups: - `grantGroupPermissions` - `updateGroupPermissions` - `revokeGroupPermissions`
2 parents c47aee0 + f467e71 commit f150f0b

File tree

6 files changed

+131
-15
lines changed

6 files changed

+131
-15
lines changed

client/src/secrets.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010

1111
/**
1212
* The Secrets API includes all operations the SDK client can perform on secrets.
13-
* Use secret reference URIs to securely load secrets from 1Password: op://<vault-name>/<item-name>[/<section-name>]/<field-name>
13+
* Use secret reference URIs to securely load secrets from 1Password: `op://<vault-name>/<item-name>[/<section-name>]/<field-name>`
1414
*/
1515
export interface SecretsApi {
1616
/**

client/src/types.ts

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,31 @@ export interface Group {
129129
vaultAccess?: VaultAccess[];
130130
}
131131

132+
/**
133+
* Represents a group's access to a 1Password vault.
134+
* This is used for granting permissions
135+
*/
136+
export interface GroupAccess {
137+
/** The group's ID */
138+
group_id: string;
139+
/** The group's set of permissions for the vault */
140+
permissions: number;
141+
}
142+
132143
export interface GroupGetParams {
133144
vaultPermissions?: boolean;
134145
}
135146

147+
/** Represents a group's access to a 1Password vault. */
148+
export interface GroupVaultAccess {
149+
/** The vault's ID */
150+
vault_id: string;
151+
/** The group's ID */
152+
group_id: string;
153+
/** The group's set of permissions for the vault */
154+
permissions: number;
155+
}
156+
136157
export enum ItemCategory {
137158
Login = "Login",
138159
SecureNote = "SecureNote",
@@ -215,7 +236,7 @@ export interface ItemSection {
215236
* Controls the auto-fill behavior of a website.
216237
*
217238
*
218-
* For more information, visit https://support.1password.com/autofill-behavior/
239+
* For more information, visit <https://support.1password.com/autofill-behavior/>
219240
*/
220241
export enum AutofillBehavior {
221242
/** Auto-fill any page that’s part of the website, including subdomains */
@@ -234,7 +255,7 @@ export interface Website {
234255
/**
235256
* The auto-fill behavior of the website
236257
*
237-
* For more information, visit https://support.1password.com/autofill-behavior/
258+
* For more information, visit <https://support.1password.com/autofill-behavior/>
238259
*/
239260
autofillBehavior: AutofillBehavior;
240261
}
@@ -685,6 +706,20 @@ export enum WordListType {
685706
ThreeLetters = "threeLetters",
686707
}
687708

709+
export const ARCHIVE_ITEMS: number = 256;
710+
export const CREATE_ITEMS: number = 128;
711+
export const DELETE_ITEMS: number = 512;
712+
export const EXPORT_ITEMS: number = 4194304;
713+
export const IMPORT_ITEMS: number = 2097152;
714+
export const MANAGE_VAULT: number = 2;
715+
export const NO_ACCESS: number = 0;
716+
export const PRINT_ITEMS: number = 8388608;
717+
export const READ_ITEMS: number = 32;
718+
export const RECOVER_VAULT: number = 1;
719+
export const REVEAL_ITEM_PASSWORD: number = 16;
720+
export const SEND_ITEMS: number = 1048576;
721+
export const UPDATE_ITEMS: number = 64;
722+
export const UPDATE_ITEM_HISTORY: number = 1024;
688723
/**
689724
* Custom JSON reviver and replacer functions for dynamic data transformation
690725
* ReviverFunc is used during JSON parsing to detect and transform specific data structures

client/src/vaults.ts

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import { InvokeConfig, InnerClient, SharedCore } from "./core.js";
44
import {
5+
GroupAccess,
6+
GroupVaultAccess,
57
Vault,
68
VaultGetParams,
79
VaultListParams,
@@ -21,6 +23,12 @@ export interface VaultsApi {
2123
getOverview(vaultUuid: string): Promise<VaultOverview>;
2224

2325
get(vaultUuid: string, vaultParams: VaultGetParams): Promise<Vault>;
26+
27+
grantGroupPermissions(vaultId: string, groupPermissionsList: GroupAccess[]);
28+
29+
updateGroupPermissions(groupPermissionsList: GroupVaultAccess[]);
30+
31+
revokeGroupPermissions(vaultId: string, groupId: string);
2432
}
2533

2634
export class Vaults implements VaultsApi {
@@ -90,4 +98,56 @@ export class Vaults implements VaultsApi {
9098
ReviverFunc,
9199
) as Vault;
92100
}
101+
102+
public async grantGroupPermissions(
103+
vaultId: string,
104+
groupPermissionsList: GroupAccess[],
105+
) {
106+
const invocationConfig: InvokeConfig = {
107+
invocation: {
108+
clientId: this.#inner.id,
109+
parameters: {
110+
name: "VaultsGrantGroupPermissions",
111+
parameters: {
112+
vault_id: vaultId,
113+
group_permissions_list: groupPermissionsList,
114+
},
115+
},
116+
},
117+
};
118+
await this.#inner.core.invoke(invocationConfig);
119+
}
120+
121+
public async updateGroupPermissions(
122+
groupPermissionsList: GroupVaultAccess[],
123+
) {
124+
const invocationConfig: InvokeConfig = {
125+
invocation: {
126+
clientId: this.#inner.id,
127+
parameters: {
128+
name: "VaultsUpdateGroupPermissions",
129+
parameters: {
130+
group_permissions_list: groupPermissionsList,
131+
},
132+
},
133+
},
134+
};
135+
await this.#inner.core.invoke(invocationConfig);
136+
}
137+
138+
public async revokeGroupPermissions(vaultId: string, groupId: string) {
139+
const invocationConfig: InvokeConfig = {
140+
invocation: {
141+
clientId: this.#inner.id,
142+
parameters: {
143+
name: "VaultsRevokeGroupPermissions",
144+
parameters: {
145+
vault_id: vaultId,
146+
group_id: groupId,
147+
},
148+
},
149+
},
150+
};
151+
await this.#inner.core.invoke(invocationConfig);
152+
}
93153
}

wasm/nodejs/core.js

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ function handleError(f, args) {
3737
}
3838
}
3939

40+
function getArrayU8FromWasm0(ptr, len) {
41+
ptr = ptr >>> 0;
42+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
43+
}
44+
4045
function isLikeNone(x) {
4146
return x === undefined || x === null;
4247
}
@@ -270,15 +275,15 @@ module.exports.release_client = function(client_id) {
270275
};
271276

272277
function __wbg_adapter_30(arg0, arg1) {
273-
wasm._dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h91cc58ee8643efbd(arg0, arg1);
278+
wasm._dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h3aa0e8fb678a82f4(arg0, arg1);
274279
}
275280

276281
function __wbg_adapter_33(arg0, arg1, arg2) {
277-
wasm.closure2333_externref_shim(arg0, arg1, arg2);
282+
wasm.closure2323_externref_shim(arg0, arg1, arg2);
278283
}
279284

280-
function __wbg_adapter_156(arg0, arg1, arg2, arg3) {
281-
wasm.closure2482_externref_shim(arg0, arg1, arg2, arg3);
285+
function __wbg_adapter_160(arg0, arg1, arg2, arg3) {
286+
wasm.closure2472_externref_shim(arg0, arg1, arg2, arg3);
282287
}
283288

284289
const __wbindgen_enum_RequestCache = ["default", "no-store", "reload", "no-cache", "force-cache", "only-if-cached"];
@@ -349,6 +354,11 @@ module.exports.__wbg_getFullYear_17d3c9e4db748eb7 = function(arg0) {
349354
return ret;
350355
};
351356

357+
module.exports.__wbg_getRandomValues_5754b82ca6952f9b = function() { return handleError(function (arg0, arg1, arg2) {
358+
const ret = arg0.getRandomValues(getArrayU8FromWasm0(arg1, arg2));
359+
return ret;
360+
}, arguments) };
361+
352362
module.exports.__wbg_getRandomValues_b8f5dbd5f3995a9e = function() { return handleError(function (arg0, arg1) {
353363
arg0.getRandomValues(arg1);
354364
}, arguments) };
@@ -373,6 +383,17 @@ module.exports.__wbg_headers_9cb51cfd2ac780a4 = function(arg0) {
373383
return ret;
374384
};
375385

386+
module.exports.__wbg_instanceof_Crypto_437466a97e9010b9 = function(arg0) {
387+
let result;
388+
try {
389+
result = arg0 instanceof Crypto;
390+
} catch (_) {
391+
result = false;
392+
}
393+
const ret = result;
394+
return ret;
395+
};
396+
376397
module.exports.__wbg_instanceof_Response_f2cc20d9f7dfd644 = function(arg0) {
377398
let result;
378399
try {
@@ -458,7 +479,7 @@ module.exports.__wbg_new_23a2665fac83c611 = function(arg0, arg1) {
458479
const a = state0.a;
459480
state0.a = 0;
460481
try {
461-
return __wbg_adapter_156(a, state0.b, arg0, arg1);
482+
return __wbg_adapter_160(a, state0.b, arg0, arg1);
462483
} finally {
463484
state0.a = a;
464485
}
@@ -708,13 +729,13 @@ module.exports.__wbindgen_cb_drop = function(arg0) {
708729
return ret;
709730
};
710731

711-
module.exports.__wbindgen_closure_wrapper8484 = function(arg0, arg1, arg2) {
712-
const ret = makeMutClosure(arg0, arg1, 2316, __wbg_adapter_30);
732+
module.exports.__wbindgen_closure_wrapper8680 = function(arg0, arg1, arg2) {
733+
const ret = makeMutClosure(arg0, arg1, 2306, __wbg_adapter_30);
713734
return ret;
714735
};
715736

716-
module.exports.__wbindgen_closure_wrapper8524 = function(arg0, arg1, arg2) {
717-
const ret = makeMutClosure(arg0, arg1, 2334, __wbg_adapter_33);
737+
module.exports.__wbindgen_closure_wrapper8711 = function(arg0, arg1, arg2) {
738+
const ret = makeMutClosure(arg0, arg1, 2324, __wbg_adapter_33);
718739
return ret;
719740
};
720741

wasm/nodejs/core_bg.wasm

139 KB
Binary file not shown.

wasm/nodejs/core_bg.wasm.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) =>
1414
export const __wbindgen_export_5: WebAssembly.Table;
1515
export const __externref_table_dealloc: (a: number) => void;
1616
export const __wbindgen_free: (a: number, b: number, c: number) => void;
17-
export const _dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h91cc58ee8643efbd: (a: number, b: number) => void;
18-
export const closure2333_externref_shim: (a: number, b: number, c: any) => void;
19-
export const closure2482_externref_shim: (a: number, b: number, c: any, d: any) => void;
17+
export const _dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h3aa0e8fb678a82f4: (a: number, b: number) => void;
18+
export const closure2323_externref_shim: (a: number, b: number, c: any) => void;
19+
export const closure2472_externref_shim: (a: number, b: number, c: any, d: any) => void;
2020
export const __wbindgen_start: () => void;

0 commit comments

Comments
 (0)