@1password/sdk 0.1.0-beta.14 → 0.1.0-beta.16
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 +56 -11
- package/dist/client.d.ts +2 -0
- package/dist/client.js +2 -0
- package/dist/configuration.d.ts +1 -1
- package/dist/configuration.js +1 -1
- package/dist/items.d.ts +9 -0
- package/dist/items.js +22 -4
- package/dist/iterator.d.ts +6 -0
- package/dist/iterator.js +32 -0
- package/dist/secrets.js +1 -1
- package/dist/types.d.ts +30 -5
- package/dist/types.js +1 -1
- package/dist/vaults.d.ts +20 -0
- package/dist/vaults.js +48 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.js +6 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -14,17 +14,62 @@
|
|
|
14
14
|
|
|
15
15
|
---
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
1Password SDKs
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
17
|
+
## Supported functionality
|
|
18
|
+
|
|
19
|
+
1Password SDKs are in active development. We're keen to hear what you'd like to see next. Let us know by [upvoting](https://github.com/1Password/onepassword-sdk-js/issues) or [filing](https://github.com/1Password/onepassword-sdk-js/issues/new/choose) an issue.
|
|
20
|
+
|
|
21
|
+
### Item management
|
|
22
|
+
|
|
23
|
+
Operations:
|
|
24
|
+
|
|
25
|
+
- [x] [Retrieve secrets](https://developer.1password.com/docs/sdks/load-secrets)
|
|
26
|
+
- [x] [Retrieve items](https://developer.1password.com/docs/sdks/manage-items#get-an-item)
|
|
27
|
+
- [x] [Create items](https://developer.1password.com/docs/sdks/manage-items#create-an-item)
|
|
28
|
+
- [x] [Update items](https://developer.1password.com/docs/sdks/manage-items#edit-an-item)
|
|
29
|
+
- [x] [Delete items](https://developer.1password.com/docs/sdks/manage-items#delete-an-item)
|
|
30
|
+
- [ ] List items
|
|
31
|
+
- [ ] Add & update tags on items
|
|
32
|
+
|
|
33
|
+
Field types:
|
|
34
|
+
- [x] API Keys
|
|
35
|
+
- [x] Passwords
|
|
36
|
+
- [x] Concealed fields
|
|
37
|
+
- [x] Text fields
|
|
38
|
+
- [x] Notes
|
|
39
|
+
- [x] SSH private keys (partially supported: supported in resolving secret references, not yet supported in item create/get/update)
|
|
40
|
+
- [ ] SSH public keys, fingerprint and key type
|
|
41
|
+
- [ ] One-time passwords \
|
|
42
|
+
- [ ] Files attachments and Document items
|
|
43
|
+
- [x] URLs
|
|
44
|
+
- [x] Credit card number & type
|
|
45
|
+
- [x] Phone numbers
|
|
46
|
+
|
|
47
|
+
### Vault management
|
|
48
|
+
- [ ] Retrieve vaults
|
|
49
|
+
- [ ] Create vaults ([#50](https://github.com/1Password/onepassword-sdk-js/issues/50))
|
|
50
|
+
- [ ] Update vaults
|
|
51
|
+
- [ ] Delete vaults
|
|
52
|
+
- [ ] List vaults
|
|
53
|
+
|
|
54
|
+
### User & access management
|
|
55
|
+
- [ ] Provision users
|
|
56
|
+
- [ ] Retrieve users
|
|
57
|
+
- [ ] List users
|
|
58
|
+
- [ ] Suspend users
|
|
59
|
+
- [ ] Create groups
|
|
60
|
+
- [ ] Update group membership
|
|
61
|
+
- [ ] Update vault access & permissions
|
|
62
|
+
|
|
63
|
+
### Compliance & reporting
|
|
64
|
+
- [ ] Watchtower insights
|
|
65
|
+
- [ ] Travel mode
|
|
66
|
+
- [ ] Events. For now, use [1Password Events Reporting API](https://developer.1password.com/docs/events-api/) directly.
|
|
67
|
+
|
|
68
|
+
### Authentication
|
|
69
|
+
|
|
70
|
+
- [x] [1Password Service Accounts](https://developer.1password.com/docs/service-accounts/get-started/)
|
|
71
|
+
- [ ] User authentication
|
|
72
|
+
- [ ] 1Password Connect. For now, use [1Password/connect-sdk-go](https://github.com/1Password/connect-sdk-go).
|
|
28
73
|
|
|
29
74
|
## 🚀 Get started
|
|
30
75
|
|
package/dist/client.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { InnerClient } from "./core.js";
|
|
2
2
|
import { SecretsApi } from "./secrets.js";
|
|
3
3
|
import { ItemsApi } from "./items.js";
|
|
4
|
+
import { VaultsApi } from "./vaults.js";
|
|
4
5
|
export declare class Client {
|
|
5
6
|
secrets: SecretsApi;
|
|
6
7
|
items: ItemsApi;
|
|
8
|
+
vaults: VaultsApi;
|
|
7
9
|
constructor(innerClient: InnerClient);
|
|
8
10
|
}
|
package/dist/client.js
CHANGED
|
@@ -3,10 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Client = void 0;
|
|
4
4
|
const secrets_js_1 = require("./secrets.js");
|
|
5
5
|
const items_js_1 = require("./items.js");
|
|
6
|
+
const vaults_js_1 = require("./vaults.js");
|
|
6
7
|
class Client {
|
|
7
8
|
constructor(innerClient) {
|
|
8
9
|
this.secrets = new secrets_js_1.SecretsSource(innerClient);
|
|
9
10
|
this.items = new items_js_1.ItemsSource(innerClient);
|
|
11
|
+
this.vaults = new vaults_js_1.VaultsSource(innerClient);
|
|
10
12
|
}
|
|
11
13
|
}
|
|
12
14
|
exports.Client = Client;
|
package/dist/configuration.d.ts
CHANGED
package/dist/configuration.js
CHANGED
|
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.getOsName = exports.clientAuthConfig = exports.VERSION = exports.LANGUAGE = void 0;
|
|
7
7
|
const os_1 = __importDefault(require("os"));
|
|
8
|
-
const version_js_1 = require("
|
|
8
|
+
const version_js_1 = require("./version.js");
|
|
9
9
|
exports.LANGUAGE = "JS";
|
|
10
10
|
exports.VERSION = version_js_1.SDK_BUILD_NUMBER;
|
|
11
11
|
/**
|
package/dist/items.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { InnerClient } from "./core.js";
|
|
2
2
|
import * as types from "./types.js";
|
|
3
|
+
import { SdkIterable } from "./iterator.js";
|
|
3
4
|
/**
|
|
4
5
|
* The Items API holds all operations the SDK client can perform on 1Password items.
|
|
5
6
|
*/
|
|
@@ -20,6 +21,10 @@ export interface ItemsApi {
|
|
|
20
21
|
* Delete an item.
|
|
21
22
|
*/
|
|
22
23
|
delete(vaultId: string, itemId: string): Promise<void>;
|
|
24
|
+
/**
|
|
25
|
+
* List all items
|
|
26
|
+
*/
|
|
27
|
+
listAll(vaultId: string): Promise<SdkIterable<types.ItemOverview>>;
|
|
23
28
|
}
|
|
24
29
|
export declare class ItemsSource implements ItemsApi {
|
|
25
30
|
#private;
|
|
@@ -40,4 +45,8 @@ export declare class ItemsSource implements ItemsApi {
|
|
|
40
45
|
* Delete an item.
|
|
41
46
|
*/
|
|
42
47
|
delete(vaultId: string, itemId: string): Promise<void>;
|
|
48
|
+
/**
|
|
49
|
+
* List all items
|
|
50
|
+
*/
|
|
51
|
+
listAll(vaultId: string): Promise<SdkIterable<types.ItemOverview>>;
|
|
43
52
|
}
|
package/dist/items.js
CHANGED
|
@@ -22,6 +22,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
22
22
|
var _ItemsSource_inner;
|
|
23
23
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
24
|
exports.ItemsSource = void 0;
|
|
25
|
+
const iterator_js_1 = require("./iterator.js");
|
|
25
26
|
class ItemsSource {
|
|
26
27
|
constructor(inner) {
|
|
27
28
|
_ItemsSource_inner.set(this, void 0);
|
|
@@ -35,7 +36,7 @@ class ItemsSource {
|
|
|
35
36
|
const invocationConfig = {
|
|
36
37
|
clientId: __classPrivateFieldGet(this, _ItemsSource_inner, "f").id,
|
|
37
38
|
invocation: {
|
|
38
|
-
name: "
|
|
39
|
+
name: "ItemsCreate",
|
|
39
40
|
parameters: {
|
|
40
41
|
params,
|
|
41
42
|
},
|
|
@@ -52,7 +53,7 @@ class ItemsSource {
|
|
|
52
53
|
const invocationConfig = {
|
|
53
54
|
clientId: __classPrivateFieldGet(this, _ItemsSource_inner, "f").id,
|
|
54
55
|
invocation: {
|
|
55
|
-
name: "
|
|
56
|
+
name: "ItemsGet",
|
|
56
57
|
parameters: {
|
|
57
58
|
vault_id: vaultId,
|
|
58
59
|
item_id: itemId,
|
|
@@ -70,7 +71,7 @@ class ItemsSource {
|
|
|
70
71
|
const invocationConfig = {
|
|
71
72
|
clientId: __classPrivateFieldGet(this, _ItemsSource_inner, "f").id,
|
|
72
73
|
invocation: {
|
|
73
|
-
name: "
|
|
74
|
+
name: "ItemsPut",
|
|
74
75
|
parameters: {
|
|
75
76
|
item,
|
|
76
77
|
},
|
|
@@ -87,7 +88,7 @@ class ItemsSource {
|
|
|
87
88
|
const invocationConfig = {
|
|
88
89
|
clientId: __classPrivateFieldGet(this, _ItemsSource_inner, "f").id,
|
|
89
90
|
invocation: {
|
|
90
|
-
name: "
|
|
91
|
+
name: "ItemsDelete",
|
|
91
92
|
parameters: {
|
|
92
93
|
vault_id: vaultId,
|
|
93
94
|
item_id: itemId,
|
|
@@ -97,6 +98,23 @@ class ItemsSource {
|
|
|
97
98
|
yield __classPrivateFieldGet(this, _ItemsSource_inner, "f").core.invoke(invocationConfig);
|
|
98
99
|
});
|
|
99
100
|
}
|
|
101
|
+
/**
|
|
102
|
+
* List all items
|
|
103
|
+
*/
|
|
104
|
+
listAll(vaultId) {
|
|
105
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
106
|
+
const invocationConfig = {
|
|
107
|
+
clientId: __classPrivateFieldGet(this, _ItemsSource_inner, "f").id,
|
|
108
|
+
invocation: {
|
|
109
|
+
name: "ItemsListAll",
|
|
110
|
+
parameters: {
|
|
111
|
+
vault_id: vaultId,
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
};
|
|
115
|
+
return new iterator_js_1.SdkIterable(JSON.parse(yield __classPrivateFieldGet(this, _ItemsSource_inner, "f").core.invoke(invocationConfig)));
|
|
116
|
+
});
|
|
117
|
+
}
|
|
100
118
|
}
|
|
101
119
|
exports.ItemsSource = ItemsSource;
|
|
102
120
|
_ItemsSource_inner = new WeakMap();
|
package/dist/iterator.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
|
|
3
|
+
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
|
|
4
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
5
|
+
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
6
|
+
return i = {}, verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
7
|
+
function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }
|
|
8
|
+
function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }
|
|
9
|
+
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
|
10
|
+
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
11
|
+
function fulfill(value) { resume("next", value); }
|
|
12
|
+
function reject(value) { resume("throw", value); }
|
|
13
|
+
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
|
14
|
+
};
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.SdkIterable = void 0;
|
|
17
|
+
class SdkIterable {
|
|
18
|
+
constructor(elements) {
|
|
19
|
+
this.elements = elements;
|
|
20
|
+
}
|
|
21
|
+
[Symbol.asyncIterator]() {
|
|
22
|
+
return this.asyncIterator();
|
|
23
|
+
}
|
|
24
|
+
asyncIterator() {
|
|
25
|
+
return __asyncGenerator(this, arguments, function* asyncIterator_1() {
|
|
26
|
+
for (const element of this.elements) {
|
|
27
|
+
yield yield __await(yield __await(Promise.resolve(element)));
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.SdkIterable = SdkIterable;
|
package/dist/secrets.js
CHANGED
package/dist/types.d.ts
CHANGED
|
@@ -47,9 +47,9 @@ export interface ItemField {
|
|
|
47
47
|
/** The field's title */
|
|
48
48
|
title: string;
|
|
49
49
|
/** The ID of the section containing the field. Built-in fields such as usernames and passwords don't require a section. */
|
|
50
|
-
|
|
50
|
+
sectionId?: string;
|
|
51
51
|
/** The field's type */
|
|
52
|
-
|
|
52
|
+
fieldType: ItemFieldType;
|
|
53
53
|
/** The string representation of the field's value */
|
|
54
54
|
value: string;
|
|
55
55
|
/** Field type-specific attributes. */
|
|
@@ -71,23 +71,48 @@ export interface Item {
|
|
|
71
71
|
/** The item's category */
|
|
72
72
|
category: ItemCategory;
|
|
73
73
|
/** The ID of the vault where the item is saved */
|
|
74
|
-
|
|
74
|
+
vaultId: string;
|
|
75
75
|
/** The item's fields */
|
|
76
76
|
fields: ItemField[];
|
|
77
77
|
/** The item's sections */
|
|
78
78
|
sections: ItemSection[];
|
|
79
|
+
/** The item's version */
|
|
80
|
+
version: number;
|
|
79
81
|
}
|
|
80
82
|
export interface ItemCreateParams {
|
|
83
|
+
/** The item's category */
|
|
81
84
|
category: ItemCategory;
|
|
82
|
-
|
|
85
|
+
/** The ID of the vault where the item is saved */
|
|
86
|
+
vaultId: string;
|
|
87
|
+
/** The item's title */
|
|
83
88
|
title: string;
|
|
89
|
+
/** The item's fields */
|
|
84
90
|
fields: ItemField[];
|
|
91
|
+
/** The item's sections */
|
|
85
92
|
sections: ItemSection[];
|
|
86
93
|
}
|
|
94
|
+
/** Represents a decrypted 1Password item. */
|
|
95
|
+
export interface ItemOverview {
|
|
96
|
+
/** The item's ID */
|
|
97
|
+
id: string;
|
|
98
|
+
/** The item's title */
|
|
99
|
+
title: string;
|
|
100
|
+
/** The item's category */
|
|
101
|
+
category: ItemCategory;
|
|
102
|
+
/** The ID of the vault where the item is saved */
|
|
103
|
+
vaultId: string;
|
|
104
|
+
}
|
|
87
105
|
/** Additional attributes for OTP fields. */
|
|
88
106
|
export interface OtpFieldDetails {
|
|
89
107
|
/** The OTP code, if successfully computed */
|
|
90
108
|
code?: string;
|
|
91
109
|
/** The error message, if the OTP code could not be computed */
|
|
92
|
-
|
|
110
|
+
errorMessage?: string;
|
|
111
|
+
}
|
|
112
|
+
/** Represents a decrypted 1Password vault. */
|
|
113
|
+
export interface VaultOverview {
|
|
114
|
+
/** The vault's ID */
|
|
115
|
+
id: string;
|
|
116
|
+
/** The vault's title */
|
|
117
|
+
title: string;
|
|
93
118
|
}
|
package/dist/types.js
CHANGED
package/dist/vaults.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { InnerClient } from "./core.js";
|
|
2
|
+
import * as types from "./types.js";
|
|
3
|
+
import { SdkIterable } from "./iterator.js";
|
|
4
|
+
/**
|
|
5
|
+
* The Vaults API holds all the operations the SDK client can perform on 1Password vaults.
|
|
6
|
+
*/
|
|
7
|
+
export interface VaultsApi {
|
|
8
|
+
/**
|
|
9
|
+
* List all vaults
|
|
10
|
+
*/
|
|
11
|
+
listAll(): Promise<SdkIterable<types.VaultOverview>>;
|
|
12
|
+
}
|
|
13
|
+
export declare class VaultsSource implements VaultsApi {
|
|
14
|
+
#private;
|
|
15
|
+
constructor(inner: InnerClient);
|
|
16
|
+
/**
|
|
17
|
+
* List all vaults
|
|
18
|
+
*/
|
|
19
|
+
listAll(): Promise<SdkIterable<types.VaultOverview>>;
|
|
20
|
+
}
|
package/dist/vaults.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
12
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
13
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
14
|
+
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");
|
|
15
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
16
|
+
};
|
|
17
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
18
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
19
|
+
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");
|
|
20
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
21
|
+
};
|
|
22
|
+
var _VaultsSource_inner;
|
|
23
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
exports.VaultsSource = void 0;
|
|
25
|
+
const iterator_js_1 = require("./iterator.js");
|
|
26
|
+
class VaultsSource {
|
|
27
|
+
constructor(inner) {
|
|
28
|
+
_VaultsSource_inner.set(this, void 0);
|
|
29
|
+
__classPrivateFieldSet(this, _VaultsSource_inner, inner, "f");
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* List all vaults
|
|
33
|
+
*/
|
|
34
|
+
listAll() {
|
|
35
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
36
|
+
const invocationConfig = {
|
|
37
|
+
clientId: __classPrivateFieldGet(this, _VaultsSource_inner, "f").id,
|
|
38
|
+
invocation: {
|
|
39
|
+
name: "VaultsListAll",
|
|
40
|
+
parameters: {},
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
return new iterator_js_1.SdkIterable(JSON.parse(yield __classPrivateFieldGet(this, _VaultsSource_inner, "f").core.invoke(invocationConfig)));
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
exports.VaultsSource = VaultsSource;
|
|
48
|
+
_VaultsSource_inner = new WeakMap();
|
package/dist/version.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@1password/sdk",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.16",
|
|
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.1.0-beta.
|
|
29
|
+
"@1password/sdk-core": "0.1.0-beta.15"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@1password/eslint-config": "^4.0.0",
|