@1password/sdk 0.2.1 → 0.3.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.
@@ -1,6 +1,6 @@
1
1
  import { ClientAuthConfig } from "./core.js";
2
2
  export declare const LANGUAGE = "JS";
3
- export declare const VERSION = "0020101";
3
+ export declare const VERSION = "0030001";
4
4
  export interface ClientConfiguration {
5
5
  auth: Auth;
6
6
  integrationName: string;
@@ -13,10 +13,11 @@ exports.VERSION = version_js_1.SDK_BUILD_NUMBER;
13
13
  * @returns The client configuration to instantiate the client with.
14
14
  */
15
15
  const clientAuthConfig = (userConfig) => {
16
+ var _a;
16
17
  // TODO: Add logic for computing the correct sanitized version value for each platform
17
18
  const defaultOsVersion = "0.0.0";
18
19
  return {
19
- serviceAccountToken: userConfig.auth,
20
+ serviceAccountToken: (_a = userConfig.auth) !== null && _a !== void 0 ? _a : "",
20
21
  programmingLanguage: exports.LANGUAGE,
21
22
  sdkVersion: exports.VERSION,
22
23
  integrationName: userConfig.integrationName,
package/dist/items.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  import { InnerClient } from "./core.js";
2
- import { SdkIterable } from "./iterator.js";
3
- import { Item, ItemCreateParams, ItemOverview } from "./types.js";
2
+ import { Item, ItemCreateParams, ItemListFilter, ItemOverview } from "./types.js";
4
3
  import { ItemsSharesApi } from "./items_shares.js";
5
4
  import { ItemsFilesApi } from "./items_files.js";
6
5
  /**
@@ -30,9 +29,9 @@ export interface ItemsApi {
30
29
  */
31
30
  archive(vaultId: string, itemId: string): any;
32
31
  /**
33
- * List all items
32
+ * List items based on filters.
34
33
  */
35
- listAll(vaultId: string): Promise<SdkIterable<ItemOverview>>;
34
+ list(vaultId: string, ...filters: ItemListFilter[]): Promise<ItemOverview[]>;
36
35
  }
37
36
  export declare class Items implements ItemsApi {
38
37
  #private;
@@ -60,7 +59,7 @@ export declare class Items implements ItemsApi {
60
59
  */
61
60
  archive(vaultId: string, itemId: string): Promise<void>;
62
61
  /**
63
- * List all items
62
+ * List items based on filters.
64
63
  */
65
- listAll(vaultId: string): Promise<SdkIterable<ItemOverview>>;
64
+ list(vaultId: string, ...filters: ItemListFilter[]): Promise<ItemOverview[]>;
66
65
  }
package/dist/items.js CHANGED
@@ -23,7 +23,6 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
23
23
  var _Items_inner;
24
24
  Object.defineProperty(exports, "__esModule", { value: true });
25
25
  exports.Items = void 0;
26
- const iterator_js_1 = require("./iterator.js");
27
26
  const types_js_1 = require("./types.js");
28
27
  const items_shares_js_1 = require("./items_shares.js");
29
28
  const items_files_js_1 = require("./items_files.js");
@@ -133,22 +132,23 @@ class Items {
133
132
  });
134
133
  }
135
134
  /**
136
- * List all items
135
+ * List items based on filters.
137
136
  */
138
- listAll(vaultId) {
137
+ list(vaultId, ...filters) {
139
138
  return __awaiter(this, void 0, void 0, function* () {
140
139
  const invocationConfig = {
141
140
  invocation: {
142
141
  clientId: __classPrivateFieldGet(this, _Items_inner, "f").id,
143
142
  parameters: {
144
- name: "ItemsListAll",
143
+ name: "ItemsList",
145
144
  parameters: {
146
145
  vault_id: vaultId,
146
+ filters,
147
147
  },
148
148
  },
149
149
  },
150
150
  };
151
- return new iterator_js_1.SdkIterable(JSON.parse(yield __classPrivateFieldGet(this, _Items_inner, "f").core.invoke(invocationConfig), types_js_1.ReviverFunc));
151
+ return JSON.parse(yield __classPrivateFieldGet(this, _Items_inner, "f").core.invoke(invocationConfig), types_js_1.ReviverFunc);
152
152
  });
153
153
  }
154
154
  }
package/dist/types.d.ts CHANGED
@@ -160,7 +160,7 @@ export interface ItemFile {
160
160
  /** the field id where the file should be stored */
161
161
  fieldId: string;
162
162
  }
163
- /** Represents a 1Password item. */
163
+ /** Represents an active 1Password item. */
164
164
  export interface Item {
165
165
  /** The item's ID */
166
166
  id: string;
@@ -213,6 +213,13 @@ export interface ItemCreateParams {
213
213
  /** The document file for the Document item type. Empty when the item isn't of Document type. */
214
214
  document?: DocumentCreateParams;
215
215
  }
216
+ /** Represents the state of an item in the SDK. */
217
+ export declare enum ItemState {
218
+ /** The item is active */
219
+ Active = "active",
220
+ /** The item is archived meaning it's hidden from regular view and stored in the archive. */
221
+ Archived = "archived"
222
+ }
216
223
  /** Represents a decrypted 1Password item overview. */
217
224
  export interface ItemOverview {
218
225
  /** The item's ID */
@@ -231,6 +238,8 @@ export interface ItemOverview {
231
238
  createdAt: Date;
232
239
  /** The time the item was updated at */
233
240
  updatedAt: Date;
241
+ /** Indicates the state of the item */
242
+ state: ItemState;
234
243
  }
235
244
  /** The valid duration options for sharing an item */
236
245
  export declare enum ItemShareDuration {
@@ -437,6 +446,13 @@ export interface VaultOverview {
437
446
  /** The vault's title */
438
447
  title: string;
439
448
  }
449
+ export type ItemListFilter = {
450
+ type: "ByState";
451
+ content: {
452
+ active: boolean;
453
+ archived: boolean;
454
+ };
455
+ };
440
456
  export type PasswordRecipe = {
441
457
  type: "Memorable";
442
458
  parameters: {
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.ReplacerFunc = exports.ReviverFunc = 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.ItemState = exports.AutofillBehavior = exports.ItemFieldType = exports.ItemCategory = void 0;
7
7
  var ItemCategory;
8
8
  (function (ItemCategory) {
9
9
  ItemCategory["Login"] = "Login";
@@ -64,6 +64,14 @@ var AutofillBehavior;
64
64
  /** Never auto-fill on this website */
65
65
  AutofillBehavior["Never"] = "Never";
66
66
  })(AutofillBehavior || (exports.AutofillBehavior = AutofillBehavior = {}));
67
+ /** Represents the state of an item in the SDK. */
68
+ var ItemState;
69
+ (function (ItemState) {
70
+ /** The item is active */
71
+ ItemState["Active"] = "active";
72
+ /** The item is archived meaning it's hidden from regular view and stored in the archive. */
73
+ ItemState["Archived"] = "archived";
74
+ })(ItemState || (exports.ItemState = ItemState = {}));
67
75
  /** The valid duration options for sharing an item */
68
76
  var ItemShareDuration;
69
77
  (function (ItemShareDuration) {
package/dist/vaults.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import { InnerClient } from "./core.js";
2
- import { SdkIterable } from "./iterator.js";
3
2
  import { VaultOverview } from "./types.js";
4
3
  /**
5
4
  * The Vaults API holds all the operations the SDK client can perform on 1Password vaults.
@@ -8,7 +7,7 @@ export interface VaultsApi {
8
7
  /**
9
8
  * List all vaults
10
9
  */
11
- listAll(): Promise<SdkIterable<VaultOverview>>;
10
+ list(): Promise<VaultOverview[]>;
12
11
  }
13
12
  export declare class Vaults implements VaultsApi {
14
13
  #private;
@@ -16,5 +15,5 @@ export declare class Vaults implements VaultsApi {
16
15
  /**
17
16
  * List all vaults
18
17
  */
19
- listAll(): Promise<SdkIterable<VaultOverview>>;
18
+ list(): Promise<VaultOverview[]>;
20
19
  }
package/dist/vaults.js CHANGED
@@ -23,7 +23,6 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
23
23
  var _Vaults_inner;
24
24
  Object.defineProperty(exports, "__esModule", { value: true });
25
25
  exports.Vaults = void 0;
26
- const iterator_js_1 = require("./iterator.js");
27
26
  const types_js_1 = require("./types.js");
28
27
  class Vaults {
29
28
  constructor(inner) {
@@ -33,18 +32,18 @@ class Vaults {
33
32
  /**
34
33
  * List all vaults
35
34
  */
36
- listAll() {
35
+ list() {
37
36
  return __awaiter(this, void 0, void 0, function* () {
38
37
  const invocationConfig = {
39
38
  invocation: {
40
39
  clientId: __classPrivateFieldGet(this, _Vaults_inner, "f").id,
41
40
  parameters: {
42
- name: "VaultsListAll",
41
+ name: "VaultsList",
43
42
  parameters: {},
44
43
  },
45
44
  },
46
45
  };
47
- return new iterator_js_1.SdkIterable(JSON.parse(yield __classPrivateFieldGet(this, _Vaults_inner, "f").core.invoke(invocationConfig), types_js_1.ReviverFunc));
46
+ return JSON.parse(yield __classPrivateFieldGet(this, _Vaults_inner, "f").core.invoke(invocationConfig), types_js_1.ReviverFunc);
48
47
  });
49
48
  }
50
49
  }
package/dist/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const SDK_VERSION = "0.2.1";
2
- export declare const SDK_BUILD_NUMBER = "0020101";
1
+ export declare const SDK_VERSION = "0.3.0";
2
+ export declare const SDK_BUILD_NUMBER = "0030001";
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.2.1";
5
- exports.SDK_BUILD_NUMBER = "0020101";
6
- const SDK_CORE_VERSION = "0.2.1";
4
+ exports.SDK_VERSION = "0.3.0";
5
+ exports.SDK_BUILD_NUMBER = "0030001";
6
+ const SDK_CORE_VERSION = "0.3.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@1password/sdk",
3
- "version": "0.2.1",
3
+ "version": "0.3.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.2.1"
29
+ "@1password/sdk-core": "0.3.0"
30
30
  },
31
31
  "devDependencies": {
32
32
  "@1password/eslint-config": "^4.0.0",
@@ -1,6 +0,0 @@
1
- export declare class SdkIterable<T> implements AsyncIterable<T> {
2
- private readonly elements;
3
- constructor(elements: T[]);
4
- [Symbol.asyncIterator](): AsyncIterator<T>;
5
- private asyncIterator;
6
- }
package/dist/iterator.js DELETED
@@ -1,33 +0,0 @@
1
- "use strict";
2
- // Code generated by op-codegen - DO NOT EDIT MANUALLY
3
- var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
4
- var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
5
- if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
6
- var g = generator.apply(thisArg, _arguments || []), i, q = [];
7
- return i = Object.create((typeof AsyncIterator === "function" ? AsyncIterator : Object).prototype), verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
8
- function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }
9
- 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]); } }
10
- function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
11
- function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
12
- function fulfill(value) { resume("next", value); }
13
- function reject(value) { resume("throw", value); }
14
- function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.SdkIterable = void 0;
18
- class SdkIterable {
19
- constructor(elements) {
20
- this.elements = elements;
21
- }
22
- [Symbol.asyncIterator]() {
23
- return this.asyncIterator();
24
- }
25
- asyncIterator() {
26
- return __asyncGenerator(this, arguments, function* asyncIterator_1() {
27
- for (const element of this.elements) {
28
- yield yield __await(yield __await(Promise.resolve(element)));
29
- }
30
- });
31
- }
32
- }
33
- exports.SdkIterable = SdkIterable;