@1password/sdk 0.1.6 → 0.2.0
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 +8 -6
- package/dist/configuration.d.ts +1 -1
- package/dist/core.d.ts +1 -1
- package/dist/core.js +38 -7
- package/dist/errors.d.ts +5 -0
- package/dist/errors.js +27 -0
- package/dist/items.d.ts +12 -9
- package/dist/items.js +7 -4
- package/dist/items_files.d.ts +40 -0
- package/dist/items_files.js +116 -0
- package/dist/items_shares.d.ts +7 -7
- package/dist/items_shares.js +4 -3
- package/dist/iterator.js +1 -0
- package/dist/sdk.d.ts +1 -0
- package/dist/sdk.js +2 -0
- package/dist/secrets.d.ts +2 -2
- package/dist/secrets.js +3 -2
- package/dist/types.d.ts +58 -0
- package/dist/types.js +20 -1
- package/dist/vaults.d.ts +3 -3
- package/dist/vaults.js +2 -1
- package/dist/version.d.ts +2 -2
- package/dist/version.js +3 -3
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -84,10 +84,10 @@ Operations:
|
|
|
84
84
|
- [x] [Create items](https://developer.1password.com/docs/sdks/manage-items#create-an-item)
|
|
85
85
|
- [x] [Update items](https://developer.1password.com/docs/sdks/manage-items#update-an-item)
|
|
86
86
|
- [x] [Delete items](https://developer.1password.com/docs/sdks/manage-items#delete-an-item)
|
|
87
|
-
- [x] Archive items
|
|
87
|
+
- [x] [Archive items](https://developer.1password.com/docs/sdks/manage-items/#archive-an-item)
|
|
88
88
|
- [x] [List items](https://developer.1password.com/docs/sdks/list-vaults-items/)
|
|
89
|
-
- [x] Share items
|
|
90
|
-
- [x] Generate PIN, random and memorable passwords
|
|
89
|
+
- [x] [Share items](https://developer.1password.com/docs/sdks/share-items) (items with files cannot be shared)
|
|
90
|
+
- [x] [Generate PIN, random and memorable passwords](https://developer.1password.com/docs/sdks/manage-items#generate-a-password)
|
|
91
91
|
|
|
92
92
|
Field types:
|
|
93
93
|
- [x] API Keys
|
|
@@ -95,7 +95,7 @@ Field types:
|
|
|
95
95
|
- [x] Concealed fields
|
|
96
96
|
- [x] Text fields
|
|
97
97
|
- [x] Notes
|
|
98
|
-
- [x] SSH private keys, public keys, fingerprint and key type
|
|
98
|
+
- [x] SSH private keys, public keys, fingerprint and key type
|
|
99
99
|
- [x] One-time passwords
|
|
100
100
|
- [x] URLs
|
|
101
101
|
- [x] Websites (used to suggest and autofill logins)
|
|
@@ -105,8 +105,10 @@ Field types:
|
|
|
105
105
|
- [x] Emails
|
|
106
106
|
- [x] References to other items
|
|
107
107
|
- [ ] Address
|
|
108
|
-
- [ ] Date
|
|
109
|
-
- [
|
|
108
|
+
- [ ] Date
|
|
109
|
+
- [x] MM/YY
|
|
110
|
+
- [x] Files attachments and Document items
|
|
111
|
+
- [x] Menu
|
|
110
112
|
|
|
111
113
|
### Vault management
|
|
112
114
|
- [ ] Retrieve vaults
|
package/dist/configuration.d.ts
CHANGED
package/dist/core.d.ts
CHANGED
|
@@ -69,9 +69,9 @@ export interface Parameters {
|
|
|
69
69
|
* An implementation of the `Core` interface that shares resources across all clients.
|
|
70
70
|
*/
|
|
71
71
|
export declare class SharedCore implements Core {
|
|
72
|
-
invoke_sync(config: InvokeConfig): string;
|
|
73
72
|
initClient(config: ClientAuthConfig): Promise<string>;
|
|
74
73
|
invoke(config: InvokeConfig): Promise<string>;
|
|
74
|
+
invoke_sync(config: InvokeConfig): string;
|
|
75
75
|
releaseClient(clientId: number): void;
|
|
76
76
|
}
|
|
77
77
|
/**
|
package/dist/core.js
CHANGED
|
@@ -11,26 +11,57 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.SharedCore = void 0;
|
|
13
13
|
const sdk_core_1 = require("@1password/sdk-core");
|
|
14
|
+
const types_1 = require("./types");
|
|
15
|
+
const errors_1 = require("./errors");
|
|
16
|
+
// In empirical tests, we determined that maximum message size that can cross the FFI boundary
|
|
17
|
+
// is ~64MB. Past this limit, the wasm-bingen FFI will throw an error and the program will crash.
|
|
18
|
+
// We set the limit to 50MB to be safe, to be reconsidered upon further testing.
|
|
19
|
+
const messageLimit = 50 * 1024 * 1024;
|
|
14
20
|
/**
|
|
15
21
|
* An implementation of the `Core` interface that shares resources across all clients.
|
|
16
22
|
*/
|
|
17
23
|
class SharedCore {
|
|
18
|
-
invoke_sync(config) {
|
|
19
|
-
const serializedConfig = JSON.stringify(config);
|
|
20
|
-
return (0, sdk_core_1.invoke_sync)(serializedConfig);
|
|
21
|
-
}
|
|
22
24
|
initClient(config) {
|
|
23
25
|
return __awaiter(this, void 0, void 0, function* () {
|
|
24
26
|
const serializedConfig = JSON.stringify(config);
|
|
25
|
-
|
|
27
|
+
try {
|
|
28
|
+
return yield (0, sdk_core_1.init_client)(serializedConfig);
|
|
29
|
+
}
|
|
30
|
+
catch (e) {
|
|
31
|
+
(0, errors_1.throwError)(e);
|
|
32
|
+
}
|
|
26
33
|
});
|
|
27
34
|
}
|
|
28
35
|
invoke(config) {
|
|
29
36
|
return __awaiter(this, void 0, void 0, function* () {
|
|
30
|
-
const serializedConfig = JSON.stringify(config);
|
|
31
|
-
|
|
37
|
+
const serializedConfig = JSON.stringify(config, types_1.ReplacerFunc);
|
|
38
|
+
// Encoding to bytes as JS uses UTF-16 under the hood, but the messages
|
|
39
|
+
// that are sent across the FFI boundary are encoded in UTF-8.
|
|
40
|
+
if (new TextEncoder().encode(serializedConfig).length > messageLimit) {
|
|
41
|
+
(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
|
+
}
|
|
43
|
+
try {
|
|
44
|
+
return yield (0, sdk_core_1.invoke)(serializedConfig);
|
|
45
|
+
}
|
|
46
|
+
catch (e) {
|
|
47
|
+
(0, errors_1.throwError)(e);
|
|
48
|
+
}
|
|
32
49
|
});
|
|
33
50
|
}
|
|
51
|
+
invoke_sync(config) {
|
|
52
|
+
const serializedConfig = JSON.stringify(config, types_1.ReplacerFunc);
|
|
53
|
+
// Encoding to bytes as JS uses UTF-16 under the hood, but the messages
|
|
54
|
+
// that are sent across the FFI boundary are encoded in UTF-8.
|
|
55
|
+
if (new TextEncoder().encode(serializedConfig).length > messageLimit) {
|
|
56
|
+
(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.`);
|
|
57
|
+
}
|
|
58
|
+
try {
|
|
59
|
+
return (0, sdk_core_1.invoke_sync)(serializedConfig);
|
|
60
|
+
}
|
|
61
|
+
catch (e) {
|
|
62
|
+
(0, errors_1.throwError)(e);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
34
65
|
releaseClient(clientId) {
|
|
35
66
|
const serializedId = JSON.stringify(clientId);
|
|
36
67
|
(0, sdk_core_1.release_client)(serializedId);
|
package/dist/errors.d.ts
ADDED
package/dist/errors.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Code generated by op-codegen - DO NOT EDIT MANUALLY
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.throwError = exports.RateLimitExceededError = void 0;
|
|
5
|
+
class RateLimitExceededError extends Error {
|
|
6
|
+
constructor(message) {
|
|
7
|
+
super();
|
|
8
|
+
this.message = message;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.RateLimitExceededError = RateLimitExceededError;
|
|
12
|
+
const throwError = (errString) => {
|
|
13
|
+
let err;
|
|
14
|
+
try {
|
|
15
|
+
err = JSON.parse(errString);
|
|
16
|
+
}
|
|
17
|
+
catch (e) {
|
|
18
|
+
throw new Error(errString);
|
|
19
|
+
}
|
|
20
|
+
switch (err.name) {
|
|
21
|
+
case "RateLimitExceeded":
|
|
22
|
+
throw new RateLimitExceededError(err.message);
|
|
23
|
+
default:
|
|
24
|
+
throw new Error(err.message);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
exports.throwError = throwError;
|
package/dist/items.d.ts
CHANGED
|
@@ -1,24 +1,26 @@
|
|
|
1
1
|
import { InnerClient } from "./core.js";
|
|
2
|
-
import * as types from "./types.js";
|
|
3
2
|
import { SdkIterable } from "./iterator.js";
|
|
3
|
+
import { Item, ItemCreateParams, ItemOverview } from "./types.js";
|
|
4
4
|
import { ItemsSharesApi } from "./items_shares.js";
|
|
5
|
+
import { ItemsFilesApi } from "./items_files.js";
|
|
5
6
|
/**
|
|
6
7
|
* The Items API holds all operations the SDK client can perform on 1Password items.
|
|
7
8
|
*/
|
|
8
9
|
export interface ItemsApi {
|
|
9
10
|
shares: ItemsSharesApi;
|
|
11
|
+
files: ItemsFilesApi;
|
|
10
12
|
/**
|
|
11
13
|
* Create a new item.
|
|
12
14
|
*/
|
|
13
|
-
create(params:
|
|
15
|
+
create(params: ItemCreateParams): Promise<Item>;
|
|
14
16
|
/**
|
|
15
17
|
* Get an item by vault and item ID
|
|
16
18
|
*/
|
|
17
|
-
get(vaultId: string, itemId: string): Promise<
|
|
19
|
+
get(vaultId: string, itemId: string): Promise<Item>;
|
|
18
20
|
/**
|
|
19
21
|
* Update an existing item.
|
|
20
22
|
*/
|
|
21
|
-
put(item:
|
|
23
|
+
put(item: Item): Promise<Item>;
|
|
22
24
|
/**
|
|
23
25
|
* Delete an item.
|
|
24
26
|
*/
|
|
@@ -30,24 +32,25 @@ export interface ItemsApi {
|
|
|
30
32
|
/**
|
|
31
33
|
* List all items
|
|
32
34
|
*/
|
|
33
|
-
listAll(vaultId: string): Promise<SdkIterable<
|
|
35
|
+
listAll(vaultId: string): Promise<SdkIterable<ItemOverview>>;
|
|
34
36
|
}
|
|
35
37
|
export declare class Items implements ItemsApi {
|
|
36
38
|
#private;
|
|
37
39
|
shares: ItemsSharesApi;
|
|
40
|
+
files: ItemsFilesApi;
|
|
38
41
|
constructor(inner: InnerClient);
|
|
39
42
|
/**
|
|
40
43
|
* Create a new item.
|
|
41
44
|
*/
|
|
42
|
-
create(params:
|
|
45
|
+
create(params: ItemCreateParams): Promise<Item>;
|
|
43
46
|
/**
|
|
44
47
|
* Get an item by vault and item ID
|
|
45
48
|
*/
|
|
46
|
-
get(vaultId: string, itemId: string): Promise<
|
|
49
|
+
get(vaultId: string, itemId: string): Promise<Item>;
|
|
47
50
|
/**
|
|
48
51
|
* Update an existing item.
|
|
49
52
|
*/
|
|
50
|
-
put(item:
|
|
53
|
+
put(item: Item): Promise<Item>;
|
|
51
54
|
/**
|
|
52
55
|
* Delete an item.
|
|
53
56
|
*/
|
|
@@ -59,5 +62,5 @@ export declare class Items implements ItemsApi {
|
|
|
59
62
|
/**
|
|
60
63
|
* List all items
|
|
61
64
|
*/
|
|
62
|
-
listAll(vaultId: string): Promise<SdkIterable<
|
|
65
|
+
listAll(vaultId: string): Promise<SdkIterable<ItemOverview>>;
|
|
63
66
|
}
|
package/dist/items.js
CHANGED
|
@@ -24,12 +24,15 @@ var _Items_inner;
|
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
25
|
exports.Items = void 0;
|
|
26
26
|
const iterator_js_1 = require("./iterator.js");
|
|
27
|
+
const types_js_1 = require("./types.js");
|
|
27
28
|
const items_shares_js_1 = require("./items_shares.js");
|
|
29
|
+
const items_files_js_1 = require("./items_files.js");
|
|
28
30
|
class Items {
|
|
29
31
|
constructor(inner) {
|
|
30
32
|
_Items_inner.set(this, void 0);
|
|
31
33
|
__classPrivateFieldSet(this, _Items_inner, inner, "f");
|
|
32
34
|
this.shares = new items_shares_js_1.ItemsShares(inner);
|
|
35
|
+
this.files = new items_files_js_1.ItemsFiles(inner);
|
|
33
36
|
}
|
|
34
37
|
/**
|
|
35
38
|
* Create a new item.
|
|
@@ -47,7 +50,7 @@ class Items {
|
|
|
47
50
|
},
|
|
48
51
|
},
|
|
49
52
|
};
|
|
50
|
-
return JSON.parse(yield __classPrivateFieldGet(this, _Items_inner, "f").core.invoke(invocationConfig));
|
|
53
|
+
return JSON.parse(yield __classPrivateFieldGet(this, _Items_inner, "f").core.invoke(invocationConfig), types_js_1.ReviverFunc);
|
|
51
54
|
});
|
|
52
55
|
}
|
|
53
56
|
/**
|
|
@@ -67,7 +70,7 @@ class Items {
|
|
|
67
70
|
},
|
|
68
71
|
},
|
|
69
72
|
};
|
|
70
|
-
return JSON.parse(yield __classPrivateFieldGet(this, _Items_inner, "f").core.invoke(invocationConfig));
|
|
73
|
+
return JSON.parse(yield __classPrivateFieldGet(this, _Items_inner, "f").core.invoke(invocationConfig), types_js_1.ReviverFunc);
|
|
71
74
|
});
|
|
72
75
|
}
|
|
73
76
|
/**
|
|
@@ -86,7 +89,7 @@ class Items {
|
|
|
86
89
|
},
|
|
87
90
|
},
|
|
88
91
|
};
|
|
89
|
-
return JSON.parse(yield __classPrivateFieldGet(this, _Items_inner, "f").core.invoke(invocationConfig));
|
|
92
|
+
return JSON.parse(yield __classPrivateFieldGet(this, _Items_inner, "f").core.invoke(invocationConfig), types_js_1.ReviverFunc);
|
|
90
93
|
});
|
|
91
94
|
}
|
|
92
95
|
/**
|
|
@@ -145,7 +148,7 @@ class Items {
|
|
|
145
148
|
},
|
|
146
149
|
},
|
|
147
150
|
};
|
|
148
|
-
return new iterator_js_1.SdkIterable(JSON.parse(yield __classPrivateFieldGet(this, _Items_inner, "f").core.invoke(invocationConfig)));
|
|
151
|
+
return new iterator_js_1.SdkIterable(JSON.parse(yield __classPrivateFieldGet(this, _Items_inner, "f").core.invoke(invocationConfig), types_js_1.ReviverFunc));
|
|
149
152
|
});
|
|
150
153
|
}
|
|
151
154
|
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { InnerClient } from "./core.js";
|
|
2
|
+
import { DocumentCreateParams, FileAttributes, FileCreateParams, Item } from "./types.js";
|
|
3
|
+
export interface ItemsFilesApi {
|
|
4
|
+
/**
|
|
5
|
+
* Attach files to Items
|
|
6
|
+
*/
|
|
7
|
+
attach(item: Item, fileParams: FileCreateParams): Promise<Item>;
|
|
8
|
+
/**
|
|
9
|
+
* Read file content from the Item
|
|
10
|
+
*/
|
|
11
|
+
read(vaultId: string, itemId: string, attr: FileAttributes): Promise<Uint8Array>;
|
|
12
|
+
/**
|
|
13
|
+
* Delete a field file from Item using the section and field IDs
|
|
14
|
+
*/
|
|
15
|
+
delete(item: Item, sectionId: string, fieldId: string): Promise<Item>;
|
|
16
|
+
/**
|
|
17
|
+
* Replace the document file within a document item
|
|
18
|
+
*/
|
|
19
|
+
replaceDocument(item: Item, docParams: DocumentCreateParams): Promise<Item>;
|
|
20
|
+
}
|
|
21
|
+
export declare class ItemsFiles implements ItemsFilesApi {
|
|
22
|
+
#private;
|
|
23
|
+
constructor(inner: InnerClient);
|
|
24
|
+
/**
|
|
25
|
+
* Attach files to Items
|
|
26
|
+
*/
|
|
27
|
+
attach(item: Item, fileParams: FileCreateParams): Promise<Item>;
|
|
28
|
+
/**
|
|
29
|
+
* Read file content from the Item
|
|
30
|
+
*/
|
|
31
|
+
read(vaultId: string, itemId: string, attr: FileAttributes): Promise<Uint8Array>;
|
|
32
|
+
/**
|
|
33
|
+
* Delete a field file from Item using the section and field IDs
|
|
34
|
+
*/
|
|
35
|
+
delete(item: Item, sectionId: string, fieldId: string): Promise<Item>;
|
|
36
|
+
/**
|
|
37
|
+
* Replace the document file within a document item
|
|
38
|
+
*/
|
|
39
|
+
replaceDocument(item: Item, docParams: DocumentCreateParams): Promise<Item>;
|
|
40
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
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 _ItemsFiles_inner;
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.ItemsFiles = void 0;
|
|
26
|
+
const types_js_1 = require("./types.js");
|
|
27
|
+
class ItemsFiles {
|
|
28
|
+
constructor(inner) {
|
|
29
|
+
_ItemsFiles_inner.set(this, void 0);
|
|
30
|
+
__classPrivateFieldSet(this, _ItemsFiles_inner, inner, "f");
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Attach files to Items
|
|
34
|
+
*/
|
|
35
|
+
attach(item, fileParams) {
|
|
36
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
37
|
+
const invocationConfig = {
|
|
38
|
+
invocation: {
|
|
39
|
+
clientId: __classPrivateFieldGet(this, _ItemsFiles_inner, "f").id,
|
|
40
|
+
parameters: {
|
|
41
|
+
name: "ItemsFilesAttach",
|
|
42
|
+
parameters: {
|
|
43
|
+
item,
|
|
44
|
+
file_params: fileParams,
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
return JSON.parse(yield __classPrivateFieldGet(this, _ItemsFiles_inner, "f").core.invoke(invocationConfig), types_js_1.ReviverFunc);
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Read file content from the Item
|
|
54
|
+
*/
|
|
55
|
+
read(vaultId, itemId, attr) {
|
|
56
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
57
|
+
const invocationConfig = {
|
|
58
|
+
invocation: {
|
|
59
|
+
clientId: __classPrivateFieldGet(this, _ItemsFiles_inner, "f").id,
|
|
60
|
+
parameters: {
|
|
61
|
+
name: "ItemsFilesRead",
|
|
62
|
+
parameters: {
|
|
63
|
+
vault_id: vaultId,
|
|
64
|
+
item_id: itemId,
|
|
65
|
+
attr,
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
return JSON.parse(yield __classPrivateFieldGet(this, _ItemsFiles_inner, "f").core.invoke(invocationConfig), types_js_1.ReviverFunc);
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Delete a field file from Item using the section and field IDs
|
|
75
|
+
*/
|
|
76
|
+
delete(item, sectionId, fieldId) {
|
|
77
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
78
|
+
const invocationConfig = {
|
|
79
|
+
invocation: {
|
|
80
|
+
clientId: __classPrivateFieldGet(this, _ItemsFiles_inner, "f").id,
|
|
81
|
+
parameters: {
|
|
82
|
+
name: "ItemsFilesDelete",
|
|
83
|
+
parameters: {
|
|
84
|
+
item,
|
|
85
|
+
section_id: sectionId,
|
|
86
|
+
field_id: fieldId,
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
return JSON.parse(yield __classPrivateFieldGet(this, _ItemsFiles_inner, "f").core.invoke(invocationConfig), types_js_1.ReviverFunc);
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Replace the document file within a document item
|
|
96
|
+
*/
|
|
97
|
+
replaceDocument(item, docParams) {
|
|
98
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
99
|
+
const invocationConfig = {
|
|
100
|
+
invocation: {
|
|
101
|
+
clientId: __classPrivateFieldGet(this, _ItemsFiles_inner, "f").id,
|
|
102
|
+
parameters: {
|
|
103
|
+
name: "ItemsFilesReplaceDocument",
|
|
104
|
+
parameters: {
|
|
105
|
+
item,
|
|
106
|
+
doc_params: docParams,
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
};
|
|
111
|
+
return JSON.parse(yield __classPrivateFieldGet(this, _ItemsFiles_inner, "f").core.invoke(invocationConfig), types_js_1.ReviverFunc);
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
exports.ItemsFiles = ItemsFiles;
|
|
116
|
+
_ItemsFiles_inner = new WeakMap();
|
package/dist/items_shares.d.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { InnerClient } from "./core.js";
|
|
2
|
-
import
|
|
2
|
+
import { Item, ItemShareAccountPolicy, ItemShareParams, ValidRecipient } from "./types.js";
|
|
3
3
|
export interface ItemsSharesApi {
|
|
4
4
|
/**
|
|
5
5
|
* Get the item sharing policy of your account.
|
|
6
6
|
*/
|
|
7
|
-
getAccountPolicy(vaultId: string, itemId: string): Promise<
|
|
7
|
+
getAccountPolicy(vaultId: string, itemId: string): Promise<ItemShareAccountPolicy>;
|
|
8
8
|
/**
|
|
9
9
|
* Validate the recipients of an item sharing link.
|
|
10
10
|
*/
|
|
11
|
-
validateRecipients(policy:
|
|
11
|
+
validateRecipients(policy: ItemShareAccountPolicy, recipients: string[]): Promise<ValidRecipient[]>;
|
|
12
12
|
/**
|
|
13
13
|
* Create a new item sharing link.
|
|
14
14
|
*/
|
|
15
|
-
create(item:
|
|
15
|
+
create(item: Item, policy: ItemShareAccountPolicy, params: ItemShareParams): Promise<string>;
|
|
16
16
|
}
|
|
17
17
|
export declare class ItemsShares implements ItemsSharesApi {
|
|
18
18
|
#private;
|
|
@@ -20,13 +20,13 @@ export declare class ItemsShares implements ItemsSharesApi {
|
|
|
20
20
|
/**
|
|
21
21
|
* Get the item sharing policy of your account.
|
|
22
22
|
*/
|
|
23
|
-
getAccountPolicy(vaultId: string, itemId: string): Promise<
|
|
23
|
+
getAccountPolicy(vaultId: string, itemId: string): Promise<ItemShareAccountPolicy>;
|
|
24
24
|
/**
|
|
25
25
|
* Validate the recipients of an item sharing link.
|
|
26
26
|
*/
|
|
27
|
-
validateRecipients(policy:
|
|
27
|
+
validateRecipients(policy: ItemShareAccountPolicy, recipients: string[]): Promise<ValidRecipient[]>;
|
|
28
28
|
/**
|
|
29
29
|
* Create a new item sharing link.
|
|
30
30
|
*/
|
|
31
|
-
create(item:
|
|
31
|
+
create(item: Item, policy: ItemShareAccountPolicy, params: ItemShareParams): Promise<string>;
|
|
32
32
|
}
|
package/dist/items_shares.js
CHANGED
|
@@ -23,6 +23,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
23
23
|
var _ItemsShares_inner;
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
25
|
exports.ItemsShares = void 0;
|
|
26
|
+
const types_js_1 = require("./types.js");
|
|
26
27
|
class ItemsShares {
|
|
27
28
|
constructor(inner) {
|
|
28
29
|
_ItemsShares_inner.set(this, void 0);
|
|
@@ -45,7 +46,7 @@ class ItemsShares {
|
|
|
45
46
|
},
|
|
46
47
|
},
|
|
47
48
|
};
|
|
48
|
-
return JSON.parse(yield __classPrivateFieldGet(this, _ItemsShares_inner, "f").core.invoke(invocationConfig));
|
|
49
|
+
return JSON.parse(yield __classPrivateFieldGet(this, _ItemsShares_inner, "f").core.invoke(invocationConfig), types_js_1.ReviverFunc);
|
|
49
50
|
});
|
|
50
51
|
}
|
|
51
52
|
/**
|
|
@@ -65,7 +66,7 @@ class ItemsShares {
|
|
|
65
66
|
},
|
|
66
67
|
},
|
|
67
68
|
};
|
|
68
|
-
return JSON.parse(yield __classPrivateFieldGet(this, _ItemsShares_inner, "f").core.invoke(invocationConfig));
|
|
69
|
+
return JSON.parse(yield __classPrivateFieldGet(this, _ItemsShares_inner, "f").core.invoke(invocationConfig), types_js_1.ReviverFunc);
|
|
69
70
|
});
|
|
70
71
|
}
|
|
71
72
|
/**
|
|
@@ -86,7 +87,7 @@ class ItemsShares {
|
|
|
86
87
|
},
|
|
87
88
|
},
|
|
88
89
|
};
|
|
89
|
-
return JSON.parse(yield __classPrivateFieldGet(this, _ItemsShares_inner, "f").core.invoke(invocationConfig));
|
|
90
|
+
return JSON.parse(yield __classPrivateFieldGet(this, _ItemsShares_inner, "f").core.invoke(invocationConfig), types_js_1.ReviverFunc);
|
|
90
91
|
});
|
|
91
92
|
}
|
|
92
93
|
}
|
package/dist/iterator.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
// Code generated by op-codegen - DO NOT EDIT MANUALLY
|
|
2
3
|
var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
|
|
3
4
|
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
|
|
4
5
|
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
package/dist/sdk.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export declare const DEFAULT_INTEGRATION_NAME = "Unknown";
|
|
|
4
4
|
export declare const DEFAULT_INTEGRATION_VERSION = "Unknown";
|
|
5
5
|
export { Secrets } from "./secrets.js";
|
|
6
6
|
export * from "./client.js";
|
|
7
|
+
export * from "./errors.js";
|
|
7
8
|
export * from "./types.js";
|
|
8
9
|
/**
|
|
9
10
|
* Creates a default 1Password SDK client.
|
package/dist/sdk.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
// Code generated by op-codegen - DO NOT EDIT MANUALLY
|
|
2
3
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
4
|
if (k2 === undefined) k2 = k;
|
|
4
5
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -32,6 +33,7 @@ exports.DEFAULT_INTEGRATION_VERSION = "Unknown";
|
|
|
32
33
|
var secrets_js_1 = require("./secrets.js");
|
|
33
34
|
Object.defineProperty(exports, "Secrets", { enumerable: true, get: function () { return secrets_js_1.Secrets; } });
|
|
34
35
|
__exportStar(require("./client.js"), exports);
|
|
36
|
+
__exportStar(require("./errors.js"), exports);
|
|
35
37
|
__exportStar(require("./types.js"), exports);
|
|
36
38
|
/**
|
|
37
39
|
* Creates a default 1Password SDK client.
|
package/dist/secrets.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { InnerClient } from "./core.js";
|
|
2
|
-
import
|
|
2
|
+
import { GeneratePasswordResponse, PasswordRecipe } from "./types.js";
|
|
3
3
|
/**
|
|
4
4
|
* The Secrets API includes all operations the SDK client can perform on secrets.
|
|
5
5
|
* Use secret reference URIs to securely load secrets from 1Password: op://<vault-name>/<item-name>[/<section-name>]/<field-name>
|
|
@@ -21,5 +21,5 @@ export declare class Secrets implements SecretsApi {
|
|
|
21
21
|
* Validate the secret reference to ensure there are no syntax errors.
|
|
22
22
|
*/
|
|
23
23
|
static validateSecretReference(secretReference: string): void;
|
|
24
|
-
static generatePassword(recipe:
|
|
24
|
+
static generatePassword(recipe: PasswordRecipe): GeneratePasswordResponse;
|
|
25
25
|
}
|
package/dist/secrets.js
CHANGED
|
@@ -24,6 +24,7 @@ var _Secrets_inner;
|
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
25
|
exports.Secrets = void 0;
|
|
26
26
|
const core_js_1 = require("./core.js");
|
|
27
|
+
const types_js_1 = require("./types.js");
|
|
27
28
|
class Secrets {
|
|
28
29
|
constructor(inner) {
|
|
29
30
|
_Secrets_inner.set(this, void 0);
|
|
@@ -45,7 +46,7 @@ class Secrets {
|
|
|
45
46
|
},
|
|
46
47
|
},
|
|
47
48
|
};
|
|
48
|
-
return JSON.parse(yield __classPrivateFieldGet(this, _Secrets_inner, "f").core.invoke(invocationConfig));
|
|
49
|
+
return JSON.parse(yield __classPrivateFieldGet(this, _Secrets_inner, "f").core.invoke(invocationConfig), types_js_1.ReviverFunc);
|
|
49
50
|
});
|
|
50
51
|
}
|
|
51
52
|
/**
|
|
@@ -77,7 +78,7 @@ class Secrets {
|
|
|
77
78
|
},
|
|
78
79
|
},
|
|
79
80
|
};
|
|
80
|
-
return JSON.parse(sharedCore.invoke_sync(invocationConfig));
|
|
81
|
+
return JSON.parse(sharedCore.invoke_sync(invocationConfig), types_js_1.ReviverFunc);
|
|
81
82
|
}
|
|
82
83
|
}
|
|
83
84
|
exports.Secrets = Secrets;
|
package/dist/types.d.ts
CHANGED
|
@@ -1,3 +1,27 @@
|
|
|
1
|
+
export interface DocumentCreateParams {
|
|
2
|
+
/** the name of the file */
|
|
3
|
+
name: string;
|
|
4
|
+
/** the content of the file */
|
|
5
|
+
content: Uint8Array;
|
|
6
|
+
}
|
|
7
|
+
export interface FileAttributes {
|
|
8
|
+
/** The name of the file */
|
|
9
|
+
name: string;
|
|
10
|
+
/** The ID of the file retrieved from the server */
|
|
11
|
+
id: string;
|
|
12
|
+
/** The size of the file in bytes */
|
|
13
|
+
size: number;
|
|
14
|
+
}
|
|
15
|
+
export interface FileCreateParams {
|
|
16
|
+
/** the name of the file */
|
|
17
|
+
name: string;
|
|
18
|
+
/** the content of the file */
|
|
19
|
+
content: Uint8Array;
|
|
20
|
+
/** the section id where the file should be stored */
|
|
21
|
+
sectionId: string;
|
|
22
|
+
/** the field id where the file should be stored */
|
|
23
|
+
fieldId: string;
|
|
24
|
+
}
|
|
1
25
|
/**
|
|
2
26
|
* For future use, if we want to return more information about the generated password.
|
|
3
27
|
* Currently, it only returns the password itself.
|
|
@@ -42,6 +66,9 @@ export declare enum ItemFieldType {
|
|
|
42
66
|
Totp = "Totp",
|
|
43
67
|
Email = "Email",
|
|
44
68
|
Reference = "Reference",
|
|
69
|
+
SshKey = "SshKey",
|
|
70
|
+
Menu = "Menu",
|
|
71
|
+
MonthYear = "MonthYear",
|
|
45
72
|
Unsupported = "Unsupported"
|
|
46
73
|
}
|
|
47
74
|
/** Field type-specific attributes. */
|
|
@@ -50,6 +77,11 @@ export type ItemFieldDetails =
|
|
|
50
77
|
{
|
|
51
78
|
type: "Otp";
|
|
52
79
|
content: OtpFieldDetails;
|
|
80
|
+
}
|
|
81
|
+
/** Computed SSH Key attributes */
|
|
82
|
+
| {
|
|
83
|
+
type: "SshKey";
|
|
84
|
+
content?: SshKeyAttributes;
|
|
53
85
|
};
|
|
54
86
|
/** Represents a field within an item. */
|
|
55
87
|
export interface ItemField {
|
|
@@ -99,6 +131,14 @@ export interface Website {
|
|
|
99
131
|
*/
|
|
100
132
|
autofillBehavior: AutofillBehavior;
|
|
101
133
|
}
|
|
134
|
+
export interface ItemFile {
|
|
135
|
+
/** the attributes of the file */
|
|
136
|
+
attributes: FileAttributes;
|
|
137
|
+
/** the section id where the file should be stored */
|
|
138
|
+
sectionId: string;
|
|
139
|
+
/** the field id where the file should be stored */
|
|
140
|
+
fieldId: string;
|
|
141
|
+
}
|
|
102
142
|
/** Represents a 1Password item. */
|
|
103
143
|
export interface Item {
|
|
104
144
|
/** The item's ID */
|
|
@@ -121,6 +161,10 @@ export interface Item {
|
|
|
121
161
|
websites: Website[];
|
|
122
162
|
/** The item's version */
|
|
123
163
|
version: number;
|
|
164
|
+
/** The item's file fields */
|
|
165
|
+
files: ItemFile[];
|
|
166
|
+
/** The document file for the Document item category */
|
|
167
|
+
document?: FileAttributes;
|
|
124
168
|
}
|
|
125
169
|
export interface ItemCreateParams {
|
|
126
170
|
/** The item's category */
|
|
@@ -139,6 +183,10 @@ export interface ItemCreateParams {
|
|
|
139
183
|
tags?: string[];
|
|
140
184
|
/** The websites used for autofilling for items of the Login and Password categories. */
|
|
141
185
|
websites?: Website[];
|
|
186
|
+
/** The item's files stored as fields */
|
|
187
|
+
files?: FileCreateParams[];
|
|
188
|
+
/** The document file for the Document item category */
|
|
189
|
+
document?: DocumentCreateParams;
|
|
142
190
|
}
|
|
143
191
|
/** Represents a decrypted 1Password item. */
|
|
144
192
|
export interface ItemOverview {
|
|
@@ -231,6 +279,14 @@ export interface OtpFieldDetails {
|
|
|
231
279
|
/** The error message, if the OTP code could not be computed */
|
|
232
280
|
errorMessage?: string;
|
|
233
281
|
}
|
|
282
|
+
export interface SshKeyAttributes {
|
|
283
|
+
/** The public part of the SSH Key */
|
|
284
|
+
publicKey: string;
|
|
285
|
+
/** The fingerprint of the SSH Key */
|
|
286
|
+
fingerprint: string;
|
|
287
|
+
/** The key type ("Ed25519" or "RSA, {length}-bit") */
|
|
288
|
+
keyType: string;
|
|
289
|
+
}
|
|
234
290
|
/** Represents a decrypted 1Password vault. */
|
|
235
291
|
export interface VaultOverview {
|
|
236
292
|
/** The vault's ID */
|
|
@@ -314,3 +370,5 @@ export declare enum WordListType {
|
|
|
314
370
|
/** Three (random) letter "words" */
|
|
315
371
|
ThreeLetters = "threeLetters"
|
|
316
372
|
}
|
|
373
|
+
export declare const ReviverFunc: (key: string, value: unknown) => unknown;
|
|
374
|
+
export declare const ReplacerFunc: (key: string, value: unknown) => unknown;
|
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.WordListType = exports.SeparatorType = exports.AllowedRecipientType = exports.AllowedType = exports.ItemShareDuration = exports.AutofillBehavior = exports.ItemFieldType = exports.ItemCategory = void 0;
|
|
6
|
+
exports.ReplacerFunc = exports.ReviverFunc = exports.WordListType = exports.SeparatorType = exports.AllowedRecipientType = exports.AllowedType = exports.ItemShareDuration = exports.AutofillBehavior = exports.ItemFieldType = exports.ItemCategory = void 0;
|
|
7
7
|
var ItemCategory;
|
|
8
8
|
(function (ItemCategory) {
|
|
9
9
|
ItemCategory["Login"] = "Login";
|
|
@@ -42,6 +42,9 @@ var ItemFieldType;
|
|
|
42
42
|
ItemFieldType["Totp"] = "Totp";
|
|
43
43
|
ItemFieldType["Email"] = "Email";
|
|
44
44
|
ItemFieldType["Reference"] = "Reference";
|
|
45
|
+
ItemFieldType["SshKey"] = "SshKey";
|
|
46
|
+
ItemFieldType["Menu"] = "Menu";
|
|
47
|
+
ItemFieldType["MonthYear"] = "MonthYear";
|
|
45
48
|
ItemFieldType["Unsupported"] = "Unsupported";
|
|
46
49
|
})(ItemFieldType || (exports.ItemFieldType = ItemFieldType = {}));
|
|
47
50
|
/**
|
|
@@ -138,3 +141,19 @@ var WordListType;
|
|
|
138
141
|
/** Three (random) letter "words" */
|
|
139
142
|
WordListType["ThreeLetters"] = "threeLetters";
|
|
140
143
|
})(WordListType || (exports.WordListType = WordListType = {}));
|
|
144
|
+
const ReviverFunc = (key, value) => {
|
|
145
|
+
if (Array.isArray(value) &&
|
|
146
|
+
value.every((v) => Number.isInteger(v) && v >= 0 && v <= 255) &&
|
|
147
|
+
value.length > 0) {
|
|
148
|
+
return new Uint8Array(value);
|
|
149
|
+
}
|
|
150
|
+
return value;
|
|
151
|
+
};
|
|
152
|
+
exports.ReviverFunc = ReviverFunc;
|
|
153
|
+
const ReplacerFunc = (key, value) => {
|
|
154
|
+
if (value instanceof Uint8Array) {
|
|
155
|
+
return Array.from(value);
|
|
156
|
+
}
|
|
157
|
+
return value;
|
|
158
|
+
};
|
|
159
|
+
exports.ReplacerFunc = ReplacerFunc;
|
package/dist/vaults.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { InnerClient } from "./core.js";
|
|
2
|
-
import * as types from "./types.js";
|
|
3
2
|
import { SdkIterable } from "./iterator.js";
|
|
3
|
+
import { VaultOverview } from "./types.js";
|
|
4
4
|
/**
|
|
5
5
|
* The Vaults API holds all the operations the SDK client can perform on 1Password vaults.
|
|
6
6
|
*/
|
|
@@ -8,7 +8,7 @@ export interface VaultsApi {
|
|
|
8
8
|
/**
|
|
9
9
|
* List all vaults
|
|
10
10
|
*/
|
|
11
|
-
listAll(): Promise<SdkIterable<
|
|
11
|
+
listAll(): Promise<SdkIterable<VaultOverview>>;
|
|
12
12
|
}
|
|
13
13
|
export declare class Vaults implements VaultsApi {
|
|
14
14
|
#private;
|
|
@@ -16,5 +16,5 @@ export declare class Vaults implements VaultsApi {
|
|
|
16
16
|
/**
|
|
17
17
|
* List all vaults
|
|
18
18
|
*/
|
|
19
|
-
listAll(): Promise<SdkIterable<
|
|
19
|
+
listAll(): Promise<SdkIterable<VaultOverview>>;
|
|
20
20
|
}
|
package/dist/vaults.js
CHANGED
|
@@ -24,6 +24,7 @@ var _Vaults_inner;
|
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
25
|
exports.Vaults = void 0;
|
|
26
26
|
const iterator_js_1 = require("./iterator.js");
|
|
27
|
+
const types_js_1 = require("./types.js");
|
|
27
28
|
class Vaults {
|
|
28
29
|
constructor(inner) {
|
|
29
30
|
_Vaults_inner.set(this, void 0);
|
|
@@ -43,7 +44,7 @@ class Vaults {
|
|
|
43
44
|
},
|
|
44
45
|
},
|
|
45
46
|
};
|
|
46
|
-
return new iterator_js_1.SdkIterable(JSON.parse(yield __classPrivateFieldGet(this, _Vaults_inner, "f").core.invoke(invocationConfig)));
|
|
47
|
+
return new iterator_js_1.SdkIterable(JSON.parse(yield __classPrivateFieldGet(this, _Vaults_inner, "f").core.invoke(invocationConfig), types_js_1.ReviverFunc));
|
|
47
48
|
});
|
|
48
49
|
}
|
|
49
50
|
}
|
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.2.0";
|
|
2
|
+
export declare const SDK_BUILD_NUMBER = "0020001";
|
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.2.0";
|
|
5
|
+
exports.SDK_BUILD_NUMBER = "0020001";
|
|
6
|
+
const SDK_CORE_VERSION = "0.2.0";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@1password/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
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.2.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@1password/eslint-config": "^4.0.0",
|