@1password/sdk 0.3.0 → 0.4.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/dist/client.d.ts +2 -0
- package/dist/client.js +2 -0
- package/dist/client_builder.d.ts +2 -2
- package/dist/client_builder.js +4 -0
- package/dist/configuration.d.ts +9 -2
- package/dist/configuration.js +20 -3
- package/dist/core.d.ts +15 -10
- package/dist/core.js +41 -4
- package/dist/groups.d.ts +13 -0
- package/dist/groups.js +51 -0
- package/dist/items.d.ts +25 -1
- package/dist/items.js +60 -0
- package/dist/sdk.d.ts +1 -0
- package/dist/sdk.js +3 -1
- package/dist/shared_lib_core.d.ts +16 -0
- package/dist/shared_lib_core.js +165 -0
- package/dist/types.d.ts +181 -7
- package/dist/types.js +64 -1
- package/dist/vaults.d.ts +9 -5
- package/dist/vaults.js +38 -3
- package/dist/version.d.ts +2 -2
- package/dist/version.js +3 -3
- package/package.json +2 -2
package/README.md
CHANGED
package/dist/client.d.ts
CHANGED
|
@@ -2,9 +2,11 @@ import { InnerClient } from "./core.js";
|
|
|
2
2
|
import { SecretsApi } from "./secrets.js";
|
|
3
3
|
import { ItemsApi } from "./items.js";
|
|
4
4
|
import { VaultsApi } from "./vaults.js";
|
|
5
|
+
import { GroupsApi } from "./groups.js";
|
|
5
6
|
export declare class Client {
|
|
6
7
|
secrets: SecretsApi;
|
|
7
8
|
items: ItemsApi;
|
|
8
9
|
vaults: VaultsApi;
|
|
10
|
+
groups: GroupsApi;
|
|
9
11
|
constructor(innerClient: InnerClient);
|
|
10
12
|
}
|
package/dist/client.js
CHANGED
|
@@ -5,11 +5,13 @@ exports.Client = void 0;
|
|
|
5
5
|
const secrets_js_1 = require("./secrets.js");
|
|
6
6
|
const items_js_1 = require("./items.js");
|
|
7
7
|
const vaults_js_1 = require("./vaults.js");
|
|
8
|
+
const groups_js_1 = require("./groups.js");
|
|
8
9
|
class Client {
|
|
9
10
|
constructor(innerClient) {
|
|
10
11
|
this.secrets = new secrets_js_1.Secrets(innerClient);
|
|
11
12
|
this.items = new items_js_1.Items(innerClient);
|
|
12
13
|
this.vaults = new vaults_js_1.Vaults(innerClient);
|
|
14
|
+
this.groups = new groups_js_1.Groups(innerClient);
|
|
13
15
|
}
|
|
14
16
|
}
|
|
15
17
|
exports.Client = Client;
|
package/dist/client_builder.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SharedCore } from "./core.js";
|
|
2
2
|
import { ClientConfiguration } from "./configuration.js";
|
|
3
3
|
import { Client } from "./client.js";
|
|
4
4
|
/**
|
|
5
5
|
* Creates a 1Password SDK client with a given core implementation.
|
|
6
6
|
* @returns The authenticated 1Password SDK client.
|
|
7
7
|
*/
|
|
8
|
-
export declare const createClientWithCore: (config: ClientConfiguration, core:
|
|
8
|
+
export declare const createClientWithCore: (config: ClientConfiguration, core: SharedCore) => Promise<Client>;
|
package/dist/client_builder.js
CHANGED
|
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.createClientWithCore = void 0;
|
|
13
13
|
const configuration_js_1 = require("./configuration.js");
|
|
14
14
|
const client_js_1 = require("./client.js");
|
|
15
|
+
const shared_lib_core_js_1 = require("./shared_lib_core.js");
|
|
15
16
|
const finalizationRegistry = new FinalizationRegistry((heldClient) => {
|
|
16
17
|
heldClient.core.releaseClient(heldClient.id);
|
|
17
18
|
});
|
|
@@ -21,6 +22,9 @@ const finalizationRegistry = new FinalizationRegistry((heldClient) => {
|
|
|
21
22
|
*/
|
|
22
23
|
const createClientWithCore = (config, core) => __awaiter(void 0, void 0, void 0, function* () {
|
|
23
24
|
const authConfig = (0, configuration_js_1.clientAuthConfig)(config);
|
|
25
|
+
if (authConfig.accountName) {
|
|
26
|
+
core.setInner(new shared_lib_core_js_1.SharedLibCore(authConfig.accountName));
|
|
27
|
+
}
|
|
24
28
|
const clientId = yield core.initClient(authConfig);
|
|
25
29
|
const inner = {
|
|
26
30
|
id: parseInt(clientId, 10),
|
package/dist/configuration.d.ts
CHANGED
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
import { ClientAuthConfig } from "./core.js";
|
|
2
2
|
export declare const LANGUAGE = "JS";
|
|
3
|
-
export declare const VERSION = "
|
|
3
|
+
export declare const VERSION = "0040001";
|
|
4
4
|
export interface ClientConfiguration {
|
|
5
5
|
auth: Auth;
|
|
6
6
|
integrationName: string;
|
|
7
7
|
integrationVersion: string;
|
|
8
8
|
}
|
|
9
|
-
type Auth = string;
|
|
9
|
+
type Auth = string | DesktopAuth;
|
|
10
|
+
/**
|
|
11
|
+
* Setting that specifies that a client should use the desktop app to authenticate.
|
|
12
|
+
*/
|
|
13
|
+
export declare class DesktopAuth {
|
|
14
|
+
accountName: string;
|
|
15
|
+
constructor(accountName: string);
|
|
16
|
+
}
|
|
10
17
|
/**
|
|
11
18
|
* Creates a default client configuration.
|
|
12
19
|
* @returns The client configuration to instantiate the client with.
|
package/dist/configuration.js
CHANGED
|
@@ -3,21 +3,38 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getOsName = exports.clientAuthConfig = exports.VERSION = exports.LANGUAGE = void 0;
|
|
6
|
+
exports.getOsName = exports.clientAuthConfig = exports.DesktopAuth = exports.VERSION = exports.LANGUAGE = void 0;
|
|
7
7
|
const os_1 = __importDefault(require("os"));
|
|
8
8
|
const version_js_1 = require("./version.js");
|
|
9
9
|
exports.LANGUAGE = "JS";
|
|
10
10
|
exports.VERSION = version_js_1.SDK_BUILD_NUMBER;
|
|
11
|
+
/**
|
|
12
|
+
* Setting that specifies that a client should use the desktop app to authenticate.
|
|
13
|
+
*/
|
|
14
|
+
class DesktopAuth {
|
|
15
|
+
constructor(accountName) {
|
|
16
|
+
this.accountName = accountName;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.DesktopAuth = DesktopAuth;
|
|
11
20
|
/**
|
|
12
21
|
* Creates a default client configuration.
|
|
13
22
|
* @returns The client configuration to instantiate the client with.
|
|
14
23
|
*/
|
|
15
24
|
const clientAuthConfig = (userConfig) => {
|
|
16
|
-
var _a;
|
|
17
25
|
// TODO: Add logic for computing the correct sanitized version value for each platform
|
|
18
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
|
+
}
|
|
19
35
|
return {
|
|
20
|
-
serviceAccountToken:
|
|
36
|
+
serviceAccountToken: serviceAccountToken !== null && serviceAccountToken !== void 0 ? serviceAccountToken : "",
|
|
37
|
+
accountName,
|
|
21
38
|
programmingLanguage: exports.LANGUAGE,
|
|
22
39
|
sdkVersion: exports.VERSION,
|
|
23
40
|
integrationName: userConfig.integrationName,
|
package/dist/core.d.ts
CHANGED
|
@@ -5,25 +5,20 @@ export interface Core {
|
|
|
5
5
|
/**
|
|
6
6
|
* Allocates a new authenticated client and returns its id.
|
|
7
7
|
*/
|
|
8
|
-
initClient(config:
|
|
8
|
+
initClient(config: string): Promise<string>;
|
|
9
9
|
/**
|
|
10
10
|
* Calls async business logic from a given client and returns the result.
|
|
11
11
|
*/
|
|
12
|
-
invoke(config:
|
|
13
|
-
/**
|
|
14
|
-
* Calls sync business logic from a given client and returns the result.
|
|
15
|
-
*/
|
|
16
|
-
invoke_sync(config: InvokeConfig): string;
|
|
12
|
+
invoke(config: string): Promise<string>;
|
|
17
13
|
/**
|
|
18
14
|
* Deallocates memory held by the given client in the SDK core when it goes out of scope.
|
|
19
15
|
*/
|
|
20
|
-
releaseClient(clientId:
|
|
16
|
+
releaseClient(clientId: string): void;
|
|
21
17
|
}
|
|
22
18
|
/**
|
|
23
19
|
* Wraps configuration information needed to allocate and authenticate a client instance and sends it to the SDK core.
|
|
24
20
|
*/
|
|
25
21
|
export interface ClientAuthConfig {
|
|
26
|
-
serviceAccountToken: string;
|
|
27
22
|
programmingLanguage: string;
|
|
28
23
|
sdkVersion: string;
|
|
29
24
|
integrationName: string;
|
|
@@ -33,6 +28,8 @@ export interface ClientAuthConfig {
|
|
|
33
28
|
os: string;
|
|
34
29
|
osVersion: string;
|
|
35
30
|
architecture: string;
|
|
31
|
+
serviceAccountToken?: string;
|
|
32
|
+
accountName?: string;
|
|
36
33
|
}
|
|
37
34
|
/**
|
|
38
35
|
* Contains the information sent to the SDK core when you call (invoke) a function.
|
|
@@ -65,10 +62,18 @@ export interface Parameters {
|
|
|
65
62
|
[key: string]: unknown;
|
|
66
63
|
};
|
|
67
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
|
+
}
|
|
68
70
|
/**
|
|
69
71
|
* An implementation of the `Core` interface that shares resources across all clients.
|
|
70
72
|
*/
|
|
71
|
-
export declare class SharedCore
|
|
73
|
+
export declare class SharedCore {
|
|
74
|
+
private inner;
|
|
75
|
+
constructor();
|
|
76
|
+
setInner(core: Core): void;
|
|
72
77
|
initClient(config: ClientAuthConfig): Promise<string>;
|
|
73
78
|
invoke(config: InvokeConfig): Promise<string>;
|
|
74
79
|
invoke_sync(config: InvokeConfig): string;
|
|
@@ -79,6 +84,6 @@ export declare class SharedCore implements Core {
|
|
|
79
84
|
*/
|
|
80
85
|
export interface InnerClient {
|
|
81
86
|
id: number;
|
|
82
|
-
core:
|
|
87
|
+
core: SharedCore;
|
|
83
88
|
}
|
|
84
89
|
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 = void 0;
|
|
12
|
+
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");
|
|
@@ -17,15 +17,52 @@ const errors_1 = require("./errors");
|
|
|
17
17
|
// is ~64MB. Past this limit, the wasm-bingen FFI will throw an error and the program will crash.
|
|
18
18
|
// We set the limit to 50MB to be safe, to be reconsidered upon further testing.
|
|
19
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;
|
|
20
51
|
/**
|
|
21
52
|
* An implementation of the `Core` interface that shares resources across all clients.
|
|
22
53
|
*/
|
|
23
54
|
class SharedCore {
|
|
55
|
+
constructor() {
|
|
56
|
+
this.inner = new WasmCore();
|
|
57
|
+
}
|
|
58
|
+
setInner(core) {
|
|
59
|
+
this.inner = core;
|
|
60
|
+
}
|
|
24
61
|
initClient(config) {
|
|
25
62
|
return __awaiter(this, void 0, void 0, function* () {
|
|
26
63
|
const serializedConfig = JSON.stringify(config);
|
|
27
64
|
try {
|
|
28
|
-
return yield
|
|
65
|
+
return yield this.inner.initClient(serializedConfig);
|
|
29
66
|
}
|
|
30
67
|
catch (e) {
|
|
31
68
|
(0, errors_1.throwError)(e);
|
|
@@ -41,7 +78,7 @@ class SharedCore {
|
|
|
41
78
|
(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."`);
|
|
42
79
|
}
|
|
43
80
|
try {
|
|
44
|
-
return yield
|
|
81
|
+
return yield this.inner.invoke(serializedConfig);
|
|
45
82
|
}
|
|
46
83
|
catch (e) {
|
|
47
84
|
(0, errors_1.throwError)(e);
|
|
@@ -64,7 +101,7 @@ class SharedCore {
|
|
|
64
101
|
}
|
|
65
102
|
releaseClient(clientId) {
|
|
66
103
|
const serializedId = JSON.stringify(clientId);
|
|
67
|
-
|
|
104
|
+
this.inner.releaseClient(serializedId);
|
|
68
105
|
}
|
|
69
106
|
}
|
|
70
107
|
exports.SharedCore = SharedCore;
|
package/dist/groups.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
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
|
+
get(groupId: string, groupParams: GroupGetParams): Promise<Group>;
|
|
8
|
+
}
|
|
9
|
+
export declare class Groups implements GroupsApi {
|
|
10
|
+
#private;
|
|
11
|
+
constructor(inner: InnerClient);
|
|
12
|
+
get(groupId: string, groupParams: GroupGetParams): Promise<Group>;
|
|
13
|
+
}
|
package/dist/groups.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
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 _Groups_inner;
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.Groups = void 0;
|
|
26
|
+
const types_js_1 = require("./types.js");
|
|
27
|
+
class Groups {
|
|
28
|
+
constructor(inner) {
|
|
29
|
+
_Groups_inner.set(this, void 0);
|
|
30
|
+
__classPrivateFieldSet(this, _Groups_inner, inner, "f");
|
|
31
|
+
}
|
|
32
|
+
get(groupId, groupParams) {
|
|
33
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
34
|
+
const invocationConfig = {
|
|
35
|
+
invocation: {
|
|
36
|
+
clientId: __classPrivateFieldGet(this, _Groups_inner, "f").id,
|
|
37
|
+
parameters: {
|
|
38
|
+
name: "GroupsGet",
|
|
39
|
+
parameters: {
|
|
40
|
+
group_id: groupId,
|
|
41
|
+
group_params: groupParams,
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
return JSON.parse(yield __classPrivateFieldGet(this, _Groups_inner, "f").core.invoke(invocationConfig), types_js_1.ReviverFunc);
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.Groups = Groups;
|
|
51
|
+
_Groups_inner = new WeakMap();
|
package/dist/items.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { InnerClient } from "./core.js";
|
|
2
|
-
import { Item, ItemCreateParams, ItemListFilter, ItemOverview } from "./types.js";
|
|
2
|
+
import { Item, ItemCreateParams, ItemListFilter, ItemOverview, ItemsDeleteAllResponse, ItemsGetAllResponse, ItemsUpdateAllResponse } from "./types.js";
|
|
3
3
|
import { ItemsSharesApi } from "./items_shares.js";
|
|
4
4
|
import { ItemsFilesApi } from "./items_files.js";
|
|
5
5
|
/**
|
|
@@ -12,10 +12,18 @@ export interface ItemsApi {
|
|
|
12
12
|
* Create a new item.
|
|
13
13
|
*/
|
|
14
14
|
create(params: ItemCreateParams): Promise<Item>;
|
|
15
|
+
/**
|
|
16
|
+
* Create items in batch, within a single vault.
|
|
17
|
+
*/
|
|
18
|
+
createAll(vaultId: string, params: ItemCreateParams[]): Promise<ItemsUpdateAllResponse>;
|
|
15
19
|
/**
|
|
16
20
|
* Get an item by vault and item ID
|
|
17
21
|
*/
|
|
18
22
|
get(vaultId: string, itemId: string): Promise<Item>;
|
|
23
|
+
/**
|
|
24
|
+
* Get items by vault and their item IDs.
|
|
25
|
+
*/
|
|
26
|
+
getAll(vaultId: string, itemIds: string[]): Promise<ItemsGetAllResponse>;
|
|
19
27
|
/**
|
|
20
28
|
* Update an existing item.
|
|
21
29
|
*/
|
|
@@ -24,6 +32,10 @@ export interface ItemsApi {
|
|
|
24
32
|
* Delete an item.
|
|
25
33
|
*/
|
|
26
34
|
delete(vaultId: string, itemId: string): any;
|
|
35
|
+
/**
|
|
36
|
+
* Delete items in batch, within a single vault.
|
|
37
|
+
*/
|
|
38
|
+
deleteAll(vaultId: string, itemIds: string[]): Promise<ItemsDeleteAllResponse>;
|
|
27
39
|
/**
|
|
28
40
|
* Archive an item.
|
|
29
41
|
*/
|
|
@@ -42,10 +54,18 @@ export declare class Items implements ItemsApi {
|
|
|
42
54
|
* Create a new item.
|
|
43
55
|
*/
|
|
44
56
|
create(params: ItemCreateParams): Promise<Item>;
|
|
57
|
+
/**
|
|
58
|
+
* Create items in batch, within a single vault.
|
|
59
|
+
*/
|
|
60
|
+
createAll(vaultId: string, params: ItemCreateParams[]): Promise<ItemsUpdateAllResponse>;
|
|
45
61
|
/**
|
|
46
62
|
* Get an item by vault and item ID
|
|
47
63
|
*/
|
|
48
64
|
get(vaultId: string, itemId: string): Promise<Item>;
|
|
65
|
+
/**
|
|
66
|
+
* Get items by vault and their item IDs.
|
|
67
|
+
*/
|
|
68
|
+
getAll(vaultId: string, itemIds: string[]): Promise<ItemsGetAllResponse>;
|
|
49
69
|
/**
|
|
50
70
|
* Update an existing item.
|
|
51
71
|
*/
|
|
@@ -54,6 +74,10 @@ export declare class Items implements ItemsApi {
|
|
|
54
74
|
* Delete an item.
|
|
55
75
|
*/
|
|
56
76
|
delete(vaultId: string, itemId: string): Promise<void>;
|
|
77
|
+
/**
|
|
78
|
+
* Delete items in batch, within a single vault.
|
|
79
|
+
*/
|
|
80
|
+
deleteAll(vaultId: string, itemIds: string[]): Promise<ItemsDeleteAllResponse>;
|
|
57
81
|
/**
|
|
58
82
|
* Archive an item.
|
|
59
83
|
*/
|
package/dist/items.js
CHANGED
|
@@ -52,6 +52,26 @@ class Items {
|
|
|
52
52
|
return JSON.parse(yield __classPrivateFieldGet(this, _Items_inner, "f").core.invoke(invocationConfig), types_js_1.ReviverFunc);
|
|
53
53
|
});
|
|
54
54
|
}
|
|
55
|
+
/**
|
|
56
|
+
* Create items in batch, within a single vault.
|
|
57
|
+
*/
|
|
58
|
+
createAll(vaultId, params) {
|
|
59
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
60
|
+
const invocationConfig = {
|
|
61
|
+
invocation: {
|
|
62
|
+
clientId: __classPrivateFieldGet(this, _Items_inner, "f").id,
|
|
63
|
+
parameters: {
|
|
64
|
+
name: "ItemsCreateAll",
|
|
65
|
+
parameters: {
|
|
66
|
+
vault_id: vaultId,
|
|
67
|
+
params,
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
return JSON.parse(yield __classPrivateFieldGet(this, _Items_inner, "f").core.invoke(invocationConfig), types_js_1.ReviverFunc);
|
|
73
|
+
});
|
|
74
|
+
}
|
|
55
75
|
/**
|
|
56
76
|
* Get an item by vault and item ID
|
|
57
77
|
*/
|
|
@@ -72,6 +92,26 @@ class Items {
|
|
|
72
92
|
return JSON.parse(yield __classPrivateFieldGet(this, _Items_inner, "f").core.invoke(invocationConfig), types_js_1.ReviverFunc);
|
|
73
93
|
});
|
|
74
94
|
}
|
|
95
|
+
/**
|
|
96
|
+
* Get items by vault and their item IDs.
|
|
97
|
+
*/
|
|
98
|
+
getAll(vaultId, itemIds) {
|
|
99
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
100
|
+
const invocationConfig = {
|
|
101
|
+
invocation: {
|
|
102
|
+
clientId: __classPrivateFieldGet(this, _Items_inner, "f").id,
|
|
103
|
+
parameters: {
|
|
104
|
+
name: "ItemsGetAll",
|
|
105
|
+
parameters: {
|
|
106
|
+
vault_id: vaultId,
|
|
107
|
+
item_ids: itemIds,
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
};
|
|
112
|
+
return JSON.parse(yield __classPrivateFieldGet(this, _Items_inner, "f").core.invoke(invocationConfig), types_js_1.ReviverFunc);
|
|
113
|
+
});
|
|
114
|
+
}
|
|
75
115
|
/**
|
|
76
116
|
* Update an existing item.
|
|
77
117
|
*/
|
|
@@ -111,6 +151,26 @@ class Items {
|
|
|
111
151
|
yield __classPrivateFieldGet(this, _Items_inner, "f").core.invoke(invocationConfig);
|
|
112
152
|
});
|
|
113
153
|
}
|
|
154
|
+
/**
|
|
155
|
+
* Delete items in batch, within a single vault.
|
|
156
|
+
*/
|
|
157
|
+
deleteAll(vaultId, itemIds) {
|
|
158
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
159
|
+
const invocationConfig = {
|
|
160
|
+
invocation: {
|
|
161
|
+
clientId: __classPrivateFieldGet(this, _Items_inner, "f").id,
|
|
162
|
+
parameters: {
|
|
163
|
+
name: "ItemsDeleteAll",
|
|
164
|
+
parameters: {
|
|
165
|
+
vault_id: vaultId,
|
|
166
|
+
item_ids: itemIds,
|
|
167
|
+
},
|
|
168
|
+
},
|
|
169
|
+
},
|
|
170
|
+
};
|
|
171
|
+
return JSON.parse(yield __classPrivateFieldGet(this, _Items_inner, "f").core.invoke(invocationConfig), types_js_1.ReviverFunc);
|
|
172
|
+
});
|
|
173
|
+
}
|
|
114
174
|
/**
|
|
115
175
|
* Archive an item.
|
|
116
176
|
*/
|
package/dist/sdk.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export { Secrets } from "./secrets.js";
|
|
|
6
6
|
export * from "./client.js";
|
|
7
7
|
export * from "./errors.js";
|
|
8
8
|
export * from "./types.js";
|
|
9
|
+
export { DesktopAuth } from "./configuration.js";
|
|
9
10
|
/**
|
|
10
11
|
* Creates a default 1Password SDK client.
|
|
11
12
|
* @returns The authenticated 1Password SDK client.
|
package/dist/sdk.js
CHANGED
|
@@ -24,7 +24,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
24
24
|
});
|
|
25
25
|
};
|
|
26
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
-
exports.createClient = exports.Secrets = exports.DEFAULT_INTEGRATION_VERSION = exports.DEFAULT_INTEGRATION_NAME = void 0;
|
|
27
|
+
exports.createClient = exports.DesktopAuth = exports.Secrets = exports.DEFAULT_INTEGRATION_VERSION = exports.DEFAULT_INTEGRATION_NAME = void 0;
|
|
28
28
|
const core_js_1 = require("./core.js");
|
|
29
29
|
const client_builder_js_1 = require("./client_builder.js");
|
|
30
30
|
exports.DEFAULT_INTEGRATION_NAME = "Unknown";
|
|
@@ -35,6 +35,8 @@ Object.defineProperty(exports, "Secrets", { enumerable: true, get: function () {
|
|
|
35
35
|
__exportStar(require("./client.js"), exports);
|
|
36
36
|
__exportStar(require("./errors.js"), exports);
|
|
37
37
|
__exportStar(require("./types.js"), exports);
|
|
38
|
+
var configuration_js_1 = require("./configuration.js");
|
|
39
|
+
Object.defineProperty(exports, "DesktopAuth", { enumerable: true, get: function () { return configuration_js_1.DesktopAuth; } });
|
|
38
40
|
/**
|
|
39
41
|
* Creates a default 1Password SDK client.
|
|
40
42
|
* @returns The authenticated 1Password SDK client.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Core } from "./core";
|
|
2
|
+
/**
|
|
3
|
+
* SharedLibCore: wrapper around the dynamically loaded shared library
|
|
4
|
+
*/
|
|
5
|
+
export declare class SharedLibCore implements Core {
|
|
6
|
+
private lib;
|
|
7
|
+
private acccountName;
|
|
8
|
+
constructor(accountName: string);
|
|
9
|
+
/**
|
|
10
|
+
* callSharedLibrary - send string to native function, receive string back.
|
|
11
|
+
*/
|
|
12
|
+
private callSharedLibrary;
|
|
13
|
+
initClient(config: string): Promise<string>;
|
|
14
|
+
invoke(invokeConfigBytes: string): Promise<string>;
|
|
15
|
+
releaseClient(clientId: string): void;
|
|
16
|
+
}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (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
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
+
exports.SharedLibCore = void 0;
|
|
36
|
+
const fs = __importStar(require("fs"));
|
|
37
|
+
const os = __importStar(require("os"));
|
|
38
|
+
const path = __importStar(require("path"));
|
|
39
|
+
/**
|
|
40
|
+
* Find the 1Password shared lib path by asking an the wasm core synchronously.
|
|
41
|
+
*/
|
|
42
|
+
const find1PasswordLibPath = () => {
|
|
43
|
+
const platform = os.platform();
|
|
44
|
+
const appRoot = path.dirname(process.execPath);
|
|
45
|
+
let searchPaths = [];
|
|
46
|
+
// Define lists of possible locations for each platform.
|
|
47
|
+
switch (platform) {
|
|
48
|
+
case "darwin": // macOS
|
|
49
|
+
searchPaths = [
|
|
50
|
+
"/Applications/1Password.app/Contents/Frameworks/libop_sdk_ipc_client.dylib",
|
|
51
|
+
path.join(os.homedir(), "/Applications/1Password.app/Contents/Frameworks/libop_sdk_ipc_client.dylib"),
|
|
52
|
+
];
|
|
53
|
+
break;
|
|
54
|
+
case "linux": // Linux
|
|
55
|
+
searchPaths = [
|
|
56
|
+
"/usr/bin/1password/libop_sdk_ipc_client.so",
|
|
57
|
+
"/opt/1Password/libop_sdk_ipc_client.so",
|
|
58
|
+
"/snap/bin/1password/libop_sdk_ipc_client.so",
|
|
59
|
+
];
|
|
60
|
+
break;
|
|
61
|
+
default:
|
|
62
|
+
throw new Error(`Unsupported platform: ${platform}`);
|
|
63
|
+
}
|
|
64
|
+
// Iterate through the possible paths and return the first one that exists.
|
|
65
|
+
for (const addonPath of searchPaths) {
|
|
66
|
+
if (fs.existsSync(addonPath)) {
|
|
67
|
+
return addonPath;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
// If the loop completes without finding the file, throw an error.
|
|
71
|
+
throw new Error("1Password desktop application not found");
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* SharedLibCore: wrapper around the dynamically loaded shared library
|
|
75
|
+
*/
|
|
76
|
+
class SharedLibCore {
|
|
77
|
+
constructor(accountName) {
|
|
78
|
+
this.lib = null;
|
|
79
|
+
try {
|
|
80
|
+
const libPath = find1PasswordLibPath();
|
|
81
|
+
const moduleStub = { exports: {} };
|
|
82
|
+
process.dlopen(moduleStub, libPath);
|
|
83
|
+
// Safely check the structure of the loaded module before casting.
|
|
84
|
+
if (typeof moduleStub === "object" &&
|
|
85
|
+
moduleStub !== null &&
|
|
86
|
+
typeof moduleStub.exports === "object" &&
|
|
87
|
+
moduleStub.exports !== null &&
|
|
88
|
+
"sendMessage" in moduleStub.exports &&
|
|
89
|
+
typeof moduleStub.exports.sendMessage ===
|
|
90
|
+
"function") {
|
|
91
|
+
this.lib = moduleStub.exports;
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
throw new Error("Failed to initialize native library: sendMessage function not found on module.");
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
catch (e) {
|
|
98
|
+
console.error("A critical error occurred while loading the native addon:", e);
|
|
99
|
+
this.lib = null;
|
|
100
|
+
}
|
|
101
|
+
this.acccountName = accountName;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* callSharedLibrary - send string to native function, receive string back.
|
|
105
|
+
*/
|
|
106
|
+
callSharedLibrary(input, operation_type) {
|
|
107
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
108
|
+
if (!this.lib) {
|
|
109
|
+
throw new Error("Native library is not available.");
|
|
110
|
+
}
|
|
111
|
+
if (!input || input.length === 0) {
|
|
112
|
+
throw new Error("internal: empty input");
|
|
113
|
+
}
|
|
114
|
+
const inputEncoded = Buffer.from(input, "utf8").toString("base64");
|
|
115
|
+
const req = {
|
|
116
|
+
account_name: this.acccountName,
|
|
117
|
+
kind: operation_type,
|
|
118
|
+
payload: inputEncoded,
|
|
119
|
+
};
|
|
120
|
+
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
|
+
}
|
|
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;
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
// Core interface implementation
|
|
149
|
+
initClient(config) {
|
|
150
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
151
|
+
return this.callSharedLibrary(config, "init_client");
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
invoke(invokeConfigBytes) {
|
|
155
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
156
|
+
return this.callSharedLibrary(invokeConfigBytes, "invoke");
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
releaseClient(clientId) {
|
|
160
|
+
this.callSharedLibrary(clientId, "release_client").catch((err) => {
|
|
161
|
+
console.warn("failed to release client:", err);
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
exports.SharedLibCore = SharedLibCore;
|
package/dist/types.d.ts
CHANGED
|
@@ -44,6 +44,79 @@ export interface GeneratePasswordResponse {
|
|
|
44
44
|
/** The generated password. */
|
|
45
45
|
password: string;
|
|
46
46
|
}
|
|
47
|
+
export declare enum GroupType {
|
|
48
|
+
/**
|
|
49
|
+
* The owners group, which gives the following permissions:
|
|
50
|
+
* - Do everything the Admin group can do
|
|
51
|
+
* - See every vault other than the personal vaults
|
|
52
|
+
* - Change people's names
|
|
53
|
+
* - See billing
|
|
54
|
+
* - Change billing
|
|
55
|
+
* - Make other people owners
|
|
56
|
+
* - Delete a person
|
|
57
|
+
*/
|
|
58
|
+
Owners = "owners",
|
|
59
|
+
/**
|
|
60
|
+
* The administrators group, which gives the following permissions:
|
|
61
|
+
* - Perform recovery
|
|
62
|
+
* - Create new vaults
|
|
63
|
+
* - Invite new members
|
|
64
|
+
* - See vault metadata, including the vault name and who has access.
|
|
65
|
+
* - Make other people admins
|
|
66
|
+
*/
|
|
67
|
+
Administrators = "administrators",
|
|
68
|
+
/**
|
|
69
|
+
* The recovery group. It contains recovery keysets, and is added to every vault to allow for recovery.
|
|
70
|
+
*
|
|
71
|
+
* No one is added to this.
|
|
72
|
+
*/
|
|
73
|
+
Recovery = "recovery",
|
|
74
|
+
/**
|
|
75
|
+
* The external account managers group or EAM is a mandatory group for managed accounts that has
|
|
76
|
+
* same permissions as the owners.
|
|
77
|
+
*/
|
|
78
|
+
ExternalAccountManagers = "externalAccountManagers",
|
|
79
|
+
/** Members of a team that a user is on. */
|
|
80
|
+
TeamMembers = "teamMembers",
|
|
81
|
+
/** A custom, user defined group. */
|
|
82
|
+
UserDefined = "userDefined",
|
|
83
|
+
/** Support for new or renamed group types */
|
|
84
|
+
Unsupported = "unsupported"
|
|
85
|
+
}
|
|
86
|
+
export declare enum GroupState {
|
|
87
|
+
/** This group is active */
|
|
88
|
+
Active = "active",
|
|
89
|
+
/** This group has been deleted */
|
|
90
|
+
Deleted = "deleted",
|
|
91
|
+
/** This group is in an unknown state */
|
|
92
|
+
Unsupported = "unsupported"
|
|
93
|
+
}
|
|
94
|
+
export declare enum VaultAccessorType {
|
|
95
|
+
User = "user",
|
|
96
|
+
Group = "group"
|
|
97
|
+
}
|
|
98
|
+
/** Represents the vault access information. */
|
|
99
|
+
export interface VaultAccess {
|
|
100
|
+
/** The vault's UUID. */
|
|
101
|
+
vaultUuid: string;
|
|
102
|
+
/** The vault's accessor type. */
|
|
103
|
+
accessorType: VaultAccessorType;
|
|
104
|
+
/** The vault's accessor UUID. */
|
|
105
|
+
accessorUuid: string;
|
|
106
|
+
/** The permissions granted to this vault */
|
|
107
|
+
permissions: number;
|
|
108
|
+
}
|
|
109
|
+
export interface Group {
|
|
110
|
+
id: string;
|
|
111
|
+
title: string;
|
|
112
|
+
description: string;
|
|
113
|
+
groupType: GroupType;
|
|
114
|
+
state: GroupState;
|
|
115
|
+
vaultAccess?: VaultAccess[];
|
|
116
|
+
}
|
|
117
|
+
export interface GroupGetParams {
|
|
118
|
+
vaultPermissions?: boolean;
|
|
119
|
+
}
|
|
47
120
|
export declare enum ItemCategory {
|
|
48
121
|
Login = "Login",
|
|
49
122
|
SecureNote = "SecureNote",
|
|
@@ -331,6 +404,62 @@ export interface ItemShareParams {
|
|
|
331
404
|
/** Whether the item can only be viewed once per recipient */
|
|
332
405
|
oneTimeOnly: boolean;
|
|
333
406
|
}
|
|
407
|
+
export interface Response<T, E> {
|
|
408
|
+
content?: T;
|
|
409
|
+
error?: E;
|
|
410
|
+
}
|
|
411
|
+
export type ItemUpdateFailureReason =
|
|
412
|
+
/** Item update operation failed due to bad user input. */
|
|
413
|
+
{
|
|
414
|
+
type: "itemValidationError";
|
|
415
|
+
message: ErrorMessage;
|
|
416
|
+
}
|
|
417
|
+
/** Item update operation is forbidden, permission issue. Make sure you have the correct permissions to update items in this vault. */
|
|
418
|
+
| {
|
|
419
|
+
type: "itemStatusPermissionError";
|
|
420
|
+
message?: undefined;
|
|
421
|
+
}
|
|
422
|
+
/** Item update operation failed due to incorrect version. */
|
|
423
|
+
| {
|
|
424
|
+
type: "itemStatusIncorrectItemVersion";
|
|
425
|
+
message?: undefined;
|
|
426
|
+
}
|
|
427
|
+
/** Item update operation failed because a file reference didn't match a known file. */
|
|
428
|
+
| {
|
|
429
|
+
type: "itemStatusFileNotFound";
|
|
430
|
+
message?: undefined;
|
|
431
|
+
}
|
|
432
|
+
/** Item update request is too big to be sent to the server. */
|
|
433
|
+
| {
|
|
434
|
+
type: "itemStatusTooBig";
|
|
435
|
+
message?: undefined;
|
|
436
|
+
}
|
|
437
|
+
/** The item was not found */
|
|
438
|
+
| {
|
|
439
|
+
type: "itemNotFound";
|
|
440
|
+
message?: undefined;
|
|
441
|
+
}
|
|
442
|
+
/** Item update operation experienced an internal error. */
|
|
443
|
+
| {
|
|
444
|
+
type: "internal";
|
|
445
|
+
message: ErrorMessage;
|
|
446
|
+
};
|
|
447
|
+
export interface ItemsDeleteAllResponse {
|
|
448
|
+
individualResponses: Record<string, Response<undefined, ItemUpdateFailureReason>>;
|
|
449
|
+
}
|
|
450
|
+
export type ItemsGetAllError = {
|
|
451
|
+
type: "itemNotFound";
|
|
452
|
+
message?: undefined;
|
|
453
|
+
} | {
|
|
454
|
+
type: "internal";
|
|
455
|
+
message: ErrorMessage;
|
|
456
|
+
};
|
|
457
|
+
export interface ItemsGetAllResponse {
|
|
458
|
+
individualResponses: Response<Item, ItemsGetAllError>[];
|
|
459
|
+
}
|
|
460
|
+
export interface ItemsUpdateAllResponse {
|
|
461
|
+
individualResponses: Response<Item, ItemUpdateFailureReason>[];
|
|
462
|
+
}
|
|
334
463
|
/** Additional attributes for OTP fields. */
|
|
335
464
|
export interface OtpFieldDetails {
|
|
336
465
|
/** The OTP code, if successfully computed */
|
|
@@ -338,10 +467,6 @@ export interface OtpFieldDetails {
|
|
|
338
467
|
/** The error message, if the OTP code could not be computed */
|
|
339
468
|
errorMessage?: string;
|
|
340
469
|
}
|
|
341
|
-
export interface Response<T, E> {
|
|
342
|
-
content?: T;
|
|
343
|
-
error?: E;
|
|
344
|
-
}
|
|
345
470
|
export interface ResolvedReference {
|
|
346
471
|
secret: string;
|
|
347
472
|
itemId: string;
|
|
@@ -439,12 +564,61 @@ export interface SshKeyAttributes {
|
|
|
439
564
|
/** The key type ("Ed25519" or "RSA, {length}-bit") */
|
|
440
565
|
keyType: string;
|
|
441
566
|
}
|
|
442
|
-
/** Represents
|
|
567
|
+
/** Represents the vault type. */
|
|
568
|
+
export declare enum VaultType {
|
|
569
|
+
Personal = "personal",
|
|
570
|
+
Everyone = "everyone",
|
|
571
|
+
Transfer = "transfer",
|
|
572
|
+
UserCreated = "userCreated",
|
|
573
|
+
Unsupported = "unsupported"
|
|
574
|
+
}
|
|
575
|
+
/** Represents regular vault information together with the vault's access information. */
|
|
576
|
+
export interface Vault {
|
|
577
|
+
/** The vault's ID. */
|
|
578
|
+
id: string;
|
|
579
|
+
/** The vault's title. */
|
|
580
|
+
title: string;
|
|
581
|
+
/** The description of the vault. */
|
|
582
|
+
description: string;
|
|
583
|
+
/** The type of the vault. */
|
|
584
|
+
vaultType: VaultType;
|
|
585
|
+
/** The number of active items within the vault. */
|
|
586
|
+
activeItemCount: number;
|
|
587
|
+
/** The content version number of the vault. It gets incremented whenever the state of the vault's contents changes (e.g. items from within the vault get created or updated). */
|
|
588
|
+
contentVersion: number;
|
|
589
|
+
/** The attribute version number of the vault. It gets incremented whenever vault presentation information changes, such as its title or icon. */
|
|
590
|
+
attributeVersion: number;
|
|
591
|
+
/** The access information associated with the vault. */
|
|
592
|
+
access?: VaultAccess[];
|
|
593
|
+
}
|
|
594
|
+
/** Represents the possible query parameters used for retrieving extra information about a vault. */
|
|
595
|
+
export interface VaultGetParams {
|
|
596
|
+
/** The vault's accessor params. */
|
|
597
|
+
accessors?: boolean;
|
|
598
|
+
}
|
|
599
|
+
export interface VaultListParams {
|
|
600
|
+
decryptDetails?: boolean;
|
|
601
|
+
}
|
|
602
|
+
/** Holds information about a 1Password Vault. */
|
|
443
603
|
export interface VaultOverview {
|
|
444
|
-
/** The vault's ID */
|
|
604
|
+
/** The vault's ID. */
|
|
445
605
|
id: string;
|
|
446
|
-
/** The vault's title */
|
|
606
|
+
/** The vault's title. */
|
|
447
607
|
title: string;
|
|
608
|
+
/** The description of this vault. */
|
|
609
|
+
description: string;
|
|
610
|
+
/** The type of the vault. */
|
|
611
|
+
vaultType: VaultType;
|
|
612
|
+
/** The number of active items within the vault. */
|
|
613
|
+
activeItemCount: number;
|
|
614
|
+
/** The content version number of the vault. It gets incremented whenever the state of the vault's contents changes (e.g. items from within the vault get created or updated). */
|
|
615
|
+
contentVersion: number;
|
|
616
|
+
/** The attribute version number of the vault. It gets incremented whenever vault presentation information changes, such as its title or icon. */
|
|
617
|
+
attributeVersion: number;
|
|
618
|
+
/** The time the vault was created at */
|
|
619
|
+
createdAt: Date;
|
|
620
|
+
/** The time the vault was updated at */
|
|
621
|
+
updatedAt: Date;
|
|
448
622
|
}
|
|
449
623
|
export type ItemListFilter = {
|
|
450
624
|
type: "ByState";
|
package/dist/types.js
CHANGED
|
@@ -3,7 +3,61 @@
|
|
|
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.AllowedRecipientType = exports.AllowedType = exports.ItemShareDuration = exports.ItemState = exports.AutofillBehavior = exports.ItemFieldType = exports.ItemCategory = void 0;
|
|
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;
|
|
7
|
+
var GroupType;
|
|
8
|
+
(function (GroupType) {
|
|
9
|
+
/**
|
|
10
|
+
* The owners group, which gives the following permissions:
|
|
11
|
+
* - Do everything the Admin group can do
|
|
12
|
+
* - See every vault other than the personal vaults
|
|
13
|
+
* - Change people's names
|
|
14
|
+
* - See billing
|
|
15
|
+
* - Change billing
|
|
16
|
+
* - Make other people owners
|
|
17
|
+
* - Delete a person
|
|
18
|
+
*/
|
|
19
|
+
GroupType["Owners"] = "owners";
|
|
20
|
+
/**
|
|
21
|
+
* The administrators group, which gives the following permissions:
|
|
22
|
+
* - Perform recovery
|
|
23
|
+
* - Create new vaults
|
|
24
|
+
* - Invite new members
|
|
25
|
+
* - See vault metadata, including the vault name and who has access.
|
|
26
|
+
* - Make other people admins
|
|
27
|
+
*/
|
|
28
|
+
GroupType["Administrators"] = "administrators";
|
|
29
|
+
/**
|
|
30
|
+
* The recovery group. It contains recovery keysets, and is added to every vault to allow for recovery.
|
|
31
|
+
*
|
|
32
|
+
* No one is added to this.
|
|
33
|
+
*/
|
|
34
|
+
GroupType["Recovery"] = "recovery";
|
|
35
|
+
/**
|
|
36
|
+
* The external account managers group or EAM is a mandatory group for managed accounts that has
|
|
37
|
+
* same permissions as the owners.
|
|
38
|
+
*/
|
|
39
|
+
GroupType["ExternalAccountManagers"] = "externalAccountManagers";
|
|
40
|
+
/** Members of a team that a user is on. */
|
|
41
|
+
GroupType["TeamMembers"] = "teamMembers";
|
|
42
|
+
/** A custom, user defined group. */
|
|
43
|
+
GroupType["UserDefined"] = "userDefined";
|
|
44
|
+
/** Support for new or renamed group types */
|
|
45
|
+
GroupType["Unsupported"] = "unsupported";
|
|
46
|
+
})(GroupType || (exports.GroupType = GroupType = {}));
|
|
47
|
+
var GroupState;
|
|
48
|
+
(function (GroupState) {
|
|
49
|
+
/** This group is active */
|
|
50
|
+
GroupState["Active"] = "active";
|
|
51
|
+
/** This group has been deleted */
|
|
52
|
+
GroupState["Deleted"] = "deleted";
|
|
53
|
+
/** This group is in an unknown state */
|
|
54
|
+
GroupState["Unsupported"] = "unsupported";
|
|
55
|
+
})(GroupState || (exports.GroupState = GroupState = {}));
|
|
56
|
+
var VaultAccessorType;
|
|
57
|
+
(function (VaultAccessorType) {
|
|
58
|
+
VaultAccessorType["User"] = "user";
|
|
59
|
+
VaultAccessorType["Group"] = "group";
|
|
60
|
+
})(VaultAccessorType || (exports.VaultAccessorType = VaultAccessorType = {}));
|
|
7
61
|
var ItemCategory;
|
|
8
62
|
(function (ItemCategory) {
|
|
9
63
|
ItemCategory["Login"] = "Login";
|
|
@@ -102,6 +156,15 @@ var AllowedRecipientType;
|
|
|
102
156
|
/** Recipients can be specified by domain */
|
|
103
157
|
AllowedRecipientType["Domain"] = "Domain";
|
|
104
158
|
})(AllowedRecipientType || (exports.AllowedRecipientType = AllowedRecipientType = {}));
|
|
159
|
+
/** Represents the vault type. */
|
|
160
|
+
var VaultType;
|
|
161
|
+
(function (VaultType) {
|
|
162
|
+
VaultType["Personal"] = "personal";
|
|
163
|
+
VaultType["Everyone"] = "everyone";
|
|
164
|
+
VaultType["Transfer"] = "transfer";
|
|
165
|
+
VaultType["UserCreated"] = "userCreated";
|
|
166
|
+
VaultType["Unsupported"] = "unsupported";
|
|
167
|
+
})(VaultType || (exports.VaultType = VaultType = {}));
|
|
105
168
|
var SeparatorType;
|
|
106
169
|
(function (SeparatorType) {
|
|
107
170
|
/**
|
package/dist/vaults.d.ts
CHANGED
|
@@ -1,19 +1,23 @@
|
|
|
1
1
|
import { InnerClient } from "./core.js";
|
|
2
|
-
import { VaultOverview } from "./types.js";
|
|
2
|
+
import { 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
|
*/
|
|
6
6
|
export interface VaultsApi {
|
|
7
7
|
/**
|
|
8
|
-
* List
|
|
8
|
+
* List information about vaults that's configurable based on some input parameters.
|
|
9
9
|
*/
|
|
10
|
-
list(): Promise<VaultOverview[]>;
|
|
10
|
+
list(params?: VaultListParams): Promise<VaultOverview[]>;
|
|
11
|
+
getOverview(vaultUuid: string): Promise<VaultOverview>;
|
|
12
|
+
get(vaultUuid: string, vaultParams: VaultGetParams): Promise<Vault>;
|
|
11
13
|
}
|
|
12
14
|
export declare class Vaults implements VaultsApi {
|
|
13
15
|
#private;
|
|
14
16
|
constructor(inner: InnerClient);
|
|
15
17
|
/**
|
|
16
|
-
* List
|
|
18
|
+
* List information about vaults that's configurable based on some input parameters.
|
|
17
19
|
*/
|
|
18
|
-
list(): Promise<VaultOverview[]>;
|
|
20
|
+
list(params: VaultListParams): Promise<VaultOverview[]>;
|
|
21
|
+
getOverview(vaultUuid: string): Promise<VaultOverview>;
|
|
22
|
+
get(vaultUuid: string, vaultParams: VaultGetParams): Promise<Vault>;
|
|
19
23
|
}
|
package/dist/vaults.js
CHANGED
|
@@ -30,16 +30,51 @@ class Vaults {
|
|
|
30
30
|
__classPrivateFieldSet(this, _Vaults_inner, inner, "f");
|
|
31
31
|
}
|
|
32
32
|
/**
|
|
33
|
-
* List
|
|
33
|
+
* List information about vaults that's configurable based on some input parameters.
|
|
34
34
|
*/
|
|
35
|
-
list() {
|
|
35
|
+
list(params) {
|
|
36
36
|
return __awaiter(this, void 0, void 0, function* () {
|
|
37
37
|
const invocationConfig = {
|
|
38
38
|
invocation: {
|
|
39
39
|
clientId: __classPrivateFieldGet(this, _Vaults_inner, "f").id,
|
|
40
40
|
parameters: {
|
|
41
41
|
name: "VaultsList",
|
|
42
|
-
parameters: {
|
|
42
|
+
parameters: {
|
|
43
|
+
params,
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
return JSON.parse(yield __classPrivateFieldGet(this, _Vaults_inner, "f").core.invoke(invocationConfig), types_js_1.ReviverFunc);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
getOverview(vaultUuid) {
|
|
52
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
53
|
+
const invocationConfig = {
|
|
54
|
+
invocation: {
|
|
55
|
+
clientId: __classPrivateFieldGet(this, _Vaults_inner, "f").id,
|
|
56
|
+
parameters: {
|
|
57
|
+
name: "VaultsGetOverview",
|
|
58
|
+
parameters: {
|
|
59
|
+
vault_uuid: vaultUuid,
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
return JSON.parse(yield __classPrivateFieldGet(this, _Vaults_inner, "f").core.invoke(invocationConfig), types_js_1.ReviverFunc);
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
get(vaultUuid, vaultParams) {
|
|
68
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
69
|
+
const invocationConfig = {
|
|
70
|
+
invocation: {
|
|
71
|
+
clientId: __classPrivateFieldGet(this, _Vaults_inner, "f").id,
|
|
72
|
+
parameters: {
|
|
73
|
+
name: "VaultsGet",
|
|
74
|
+
parameters: {
|
|
75
|
+
vault_uuid: vaultUuid,
|
|
76
|
+
vault_params: vaultParams,
|
|
77
|
+
},
|
|
43
78
|
},
|
|
44
79
|
},
|
|
45
80
|
};
|
package/dist/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "0.
|
|
2
|
-
export declare const SDK_BUILD_NUMBER = "
|
|
1
|
+
export declare const SDK_VERSION = "0.4.0-beta.1";
|
|
2
|
+
export declare const SDK_BUILD_NUMBER = "0040001";
|
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.
|
|
5
|
-
exports.SDK_BUILD_NUMBER = "
|
|
6
|
-
const SDK_CORE_VERSION = "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";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@1password/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0-beta.1",
|
|
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.
|
|
29
|
+
"@1password/sdk-core": "0.4.0-beta.1"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@1password/eslint-config": "^4.0.0",
|