@1password/sdk 0.1.3 → 0.1.5

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 CHANGED
@@ -86,6 +86,7 @@ Operations:
86
86
  - [x] [Delete items](https://developer.1password.com/docs/sdks/manage-items#delete-an-item)
87
87
  - [x] [List items](https://developer.1password.com/docs/sdks/list-vaults-items/)
88
88
  - [x] Add & update tags on items
89
+ - [x] Generate PIN, random and memorable passwords
89
90
 
90
91
  Field types:
91
92
  - [x] API Keys
@@ -100,6 +101,7 @@ Field types:
100
101
  - [x] Websites (used to suggest and autofill logins)
101
102
  - [x] Phone numbers
102
103
  - [x] Credit card types
104
+ - [x] Credit card numbers
103
105
  - [ ] File attachments and Document items
104
106
 
105
107
  ### Vault management
@@ -1,6 +1,6 @@
1
1
  import { ClientAuthConfig } from "./core.js";
2
2
  export declare const LANGUAGE = "JS";
3
- export declare const VERSION = "0010301";
3
+ export declare const VERSION = "0010501";
4
4
  export interface ClientConfiguration {
5
5
  auth: Auth;
6
6
  integrationName: string;
package/dist/core.d.ts CHANGED
@@ -7,9 +7,13 @@ export interface Core {
7
7
  */
8
8
  initClient(config: ClientAuthConfig): Promise<string>;
9
9
  /**
10
- * Calls business logic from a given client and returns the result.
10
+ * Calls async business logic from a given client and returns the result.
11
11
  */
12
12
  invoke(config: InvokeConfig): Promise<string>;
13
+ /**
14
+ * Calls sync business logic from a given client and returns the result.
15
+ */
16
+ invoke_sync(config: InvokeConfig): string;
13
17
  /**
14
18
  * Deallocates memory held by the given client in the SDK core when it goes out of scope.
15
19
  */
@@ -65,6 +69,7 @@ export interface Parameters {
65
69
  * An implementation of the `Core` interface that shares resources across all clients.
66
70
  */
67
71
  export declare class SharedCore implements Core {
72
+ invoke_sync(config: InvokeConfig): string;
68
73
  initClient(config: ClientAuthConfig): Promise<string>;
69
74
  invoke(config: InvokeConfig): Promise<string>;
70
75
  releaseClient(clientId: number): void;
package/dist/core.js CHANGED
@@ -15,6 +15,10 @@ const sdk_core_1 = require("@1password/sdk-core");
15
15
  * An implementation of the `Core` interface that shares resources across all clients.
16
16
  */
17
17
  class SharedCore {
18
+ invoke_sync(config) {
19
+ const serializedConfig = JSON.stringify(config);
20
+ return (0, sdk_core_1.invoke_sync)(serializedConfig);
21
+ }
18
22
  initClient(config) {
19
23
  return __awaiter(this, void 0, void 0, function* () {
20
24
  const serializedConfig = JSON.stringify(config);
package/dist/items.d.ts CHANGED
@@ -20,7 +20,7 @@ export interface ItemsApi {
20
20
  /**
21
21
  * Delete an item.
22
22
  */
23
- delete(vaultId: string, itemId: string): Promise<void>;
23
+ delete(vaultId: string, itemId: string): any;
24
24
  /**
25
25
  * List all items
26
26
  */
package/dist/iterator.js CHANGED
@@ -3,7 +3,7 @@ var __await = (this && this.__await) || function (v) { return this instanceof __
3
3
  var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
4
4
  if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
5
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;
6
+ return i = Object.create((typeof AsyncIterator === "function" ? AsyncIterator : Object).prototype), verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
7
7
  function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }
8
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
9
  function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
package/dist/sdk.js CHANGED
@@ -28,6 +28,7 @@ const core_js_1 = require("./core.js");
28
28
  const client_builder_js_1 = require("./client_builder.js");
29
29
  exports.DEFAULT_INTEGRATION_NAME = "Unknown";
30
30
  exports.DEFAULT_INTEGRATION_VERSION = "Unknown";
31
+ // auto-generated static exports
31
32
  var secrets_js_1 = require("./secrets.js");
32
33
  Object.defineProperty(exports, "Secrets", { enumerable: true, get: function () { return secrets_js_1.Secrets; } });
33
34
  __exportStar(require("./client.js"), exports);
package/dist/secrets.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { InnerClient } from "./core.js";
2
+ import * as types from "./types.js";
2
3
  /**
3
4
  * The Secrets API includes all operations the SDK client can perform on secrets.
4
5
  * Use secret reference URIs to securely load secrets from 1Password: op://<vault-name>/<item-name>[/<section-name>]/<field-name>
@@ -16,4 +17,9 @@ export declare class Secrets implements SecretsApi {
16
17
  * Resolve returns the secret the provided secret reference points to.
17
18
  */
18
19
  resolve(secretReference: string): Promise<string>;
20
+ /**
21
+ * Validate the secret reference to ensure there are no syntax errors.
22
+ */
23
+ static validateSecretReference(secretReference: string): void;
24
+ static generatePassword(recipe: types.PasswordRecipe): types.GeneratePasswordResponse;
19
25
  }
package/dist/secrets.js CHANGED
@@ -23,6 +23,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
23
23
  var _Secrets_inner;
24
24
  Object.defineProperty(exports, "__esModule", { value: true });
25
25
  exports.Secrets = void 0;
26
+ const core_js_1 = require("./core.js");
26
27
  class Secrets {
27
28
  constructor(inner) {
28
29
  _Secrets_inner.set(this, void 0);
@@ -47,6 +48,37 @@ class Secrets {
47
48
  return JSON.parse(yield __classPrivateFieldGet(this, _Secrets_inner, "f").core.invoke(invocationConfig));
48
49
  });
49
50
  }
51
+ /**
52
+ * Validate the secret reference to ensure there are no syntax errors.
53
+ */
54
+ static validateSecretReference(secretReference) {
55
+ const sharedCore = new core_js_1.SharedCore();
56
+ const invocationConfig = {
57
+ invocation: {
58
+ parameters: {
59
+ name: "ValidateSecretReference",
60
+ parameters: {
61
+ secret_reference: secretReference,
62
+ },
63
+ },
64
+ },
65
+ };
66
+ sharedCore.invoke_sync(invocationConfig);
67
+ }
68
+ static generatePassword(recipe) {
69
+ const sharedCore = new core_js_1.SharedCore();
70
+ const invocationConfig = {
71
+ invocation: {
72
+ parameters: {
73
+ name: "GeneratePassword",
74
+ parameters: {
75
+ recipe,
76
+ },
77
+ },
78
+ },
79
+ };
80
+ return JSON.parse(sharedCore.invoke_sync(invocationConfig));
81
+ }
50
82
  }
51
83
  exports.Secrets = Secrets;
52
84
  _Secrets_inner = new WeakMap();
package/dist/types.d.ts CHANGED
@@ -1,3 +1,11 @@
1
+ /**
2
+ * For future use, if we want to return more information about the generated password.
3
+ * Currently, it only returns the password itself.
4
+ */
5
+ export interface GeneratePasswordResponse {
6
+ /** The generated password. */
7
+ password: string;
8
+ }
1
9
  export declare enum ItemCategory {
2
10
  Login = "Login",
3
11
  SecureNote = "SecureNote",
@@ -28,6 +36,7 @@ export declare enum ItemFieldType {
28
36
  Text = "Text",
29
37
  Concealed = "Concealed",
30
38
  CreditCardType = "CreditCardType",
39
+ CreditCardNumber = "CreditCardNumber",
31
40
  Phone = "Phone",
32
41
  Url = "Url",
33
42
  Totp = "Totp",
@@ -152,3 +161,79 @@ export interface VaultOverview {
152
161
  /** The vault's title */
153
162
  title: string;
154
163
  }
164
+ export type PasswordRecipe = {
165
+ type: "Memorable";
166
+ parameters: {
167
+ /** The type of separator between chunks. */
168
+ separatorType: SeparatorType;
169
+ /** Uppercase one randomly selected chunk. */
170
+ capitalize: boolean;
171
+ /** The type of word list used. */
172
+ wordListType: WordListType;
173
+ /** The number of "words" (words or syllables). */
174
+ wordCount: number;
175
+ };
176
+ } | {
177
+ type: "Pin";
178
+ parameters: {
179
+ /** Number of digits in the PIN. */
180
+ length: number;
181
+ };
182
+ } | {
183
+ type: "Random";
184
+ parameters: {
185
+ /** Include at least one digit in the password. */
186
+ includeDigits: boolean;
187
+ /** Include at least one symbol in the password. */
188
+ includeSymbols: boolean;
189
+ /** The length of the password. */
190
+ length: number;
191
+ };
192
+ };
193
+ export declare enum SeparatorType {
194
+ /**
195
+ * Randomly selected digits.
196
+ * E.g, "`correct4horse0battery1staple`"
197
+ */
198
+ Digits = "digits",
199
+ /**
200
+ * Randomly selected digits and symbols.
201
+ * This is useful to get word-based passwords to meet complexity requirements
202
+ * E.g, "`correct4horse-battery1staple`"
203
+ */
204
+ DigitsAndSymbols = "digitsAndSymbols",
205
+ /**
206
+ * Spaces, like the original Diceware.
207
+ * Great for mobile keyboards, not so great when people can overhear you type the password.
208
+ * E.g, "`correct horse battery staple`"
209
+ */
210
+ Spaces = "spaces",
211
+ /**
212
+ * Hyphens "`-`".
213
+ * E.g, "`correct-horse-battery-staple`"
214
+ */
215
+ Hyphens = "hyphens",
216
+ /**
217
+ * "`_`".
218
+ * E.g, "`correct_horse_battery_staple`"
219
+ */
220
+ Underscores = "underscores",
221
+ /**
222
+ * Period (full stop) "`.`".
223
+ * E.g, "`correct.horse.battery.staple`"
224
+ */
225
+ Periods = "periods",
226
+ /**
227
+ * Comma "`,`".
228
+ * E.g, "`correct,horse,battery,staple`"
229
+ */
230
+ Commas = "commas"
231
+ }
232
+ export declare enum WordListType {
233
+ /** Agile wordlist */
234
+ FullWords = "fullWords",
235
+ /** English-like syllables */
236
+ Syllables = "syllables",
237
+ /** Three (random) letter "words" */
238
+ ThreeLetters = "threeLetters"
239
+ }
package/dist/types.js CHANGED
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  /*
3
- Generated by typeshare 1.11.0
3
+ Generated by typeshare 1.12.0
4
4
  */
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.AutofillBehavior = exports.ItemFieldType = exports.ItemCategory = void 0;
6
+ exports.WordListType = exports.SeparatorType = exports.AutofillBehavior = exports.ItemFieldType = exports.ItemCategory = void 0;
7
7
  var ItemCategory;
8
8
  (function (ItemCategory) {
9
9
  ItemCategory["Login"] = "Login";
@@ -36,6 +36,7 @@ var ItemFieldType;
36
36
  ItemFieldType["Text"] = "Text";
37
37
  ItemFieldType["Concealed"] = "Concealed";
38
38
  ItemFieldType["CreditCardType"] = "CreditCardType";
39
+ ItemFieldType["CreditCardNumber"] = "CreditCardNumber";
39
40
  ItemFieldType["Phone"] = "Phone";
40
41
  ItemFieldType["Url"] = "Url";
41
42
  ItemFieldType["Totp"] = "Totp";
@@ -56,3 +57,52 @@ var AutofillBehavior;
56
57
  /** Never auto-fill on this website */
57
58
  AutofillBehavior["Never"] = "Never";
58
59
  })(AutofillBehavior || (exports.AutofillBehavior = AutofillBehavior = {}));
60
+ var SeparatorType;
61
+ (function (SeparatorType) {
62
+ /**
63
+ * Randomly selected digits.
64
+ * E.g, "`correct4horse0battery1staple`"
65
+ */
66
+ SeparatorType["Digits"] = "digits";
67
+ /**
68
+ * Randomly selected digits and symbols.
69
+ * This is useful to get word-based passwords to meet complexity requirements
70
+ * E.g, "`correct4horse-battery1staple`"
71
+ */
72
+ SeparatorType["DigitsAndSymbols"] = "digitsAndSymbols";
73
+ /**
74
+ * Spaces, like the original Diceware.
75
+ * Great for mobile keyboards, not so great when people can overhear you type the password.
76
+ * E.g, "`correct horse battery staple`"
77
+ */
78
+ SeparatorType["Spaces"] = "spaces";
79
+ /**
80
+ * Hyphens "`-`".
81
+ * E.g, "`correct-horse-battery-staple`"
82
+ */
83
+ SeparatorType["Hyphens"] = "hyphens";
84
+ /**
85
+ * "`_`".
86
+ * E.g, "`correct_horse_battery_staple`"
87
+ */
88
+ SeparatorType["Underscores"] = "underscores";
89
+ /**
90
+ * Period (full stop) "`.`".
91
+ * E.g, "`correct.horse.battery.staple`"
92
+ */
93
+ SeparatorType["Periods"] = "periods";
94
+ /**
95
+ * Comma "`,`".
96
+ * E.g, "`correct,horse,battery,staple`"
97
+ */
98
+ SeparatorType["Commas"] = "commas";
99
+ })(SeparatorType || (exports.SeparatorType = SeparatorType = {}));
100
+ var WordListType;
101
+ (function (WordListType) {
102
+ /** Agile wordlist */
103
+ WordListType["FullWords"] = "fullWords";
104
+ /** English-like syllables */
105
+ WordListType["Syllables"] = "syllables";
106
+ /** Three (random) letter "words" */
107
+ WordListType["ThreeLetters"] = "threeLetters";
108
+ })(WordListType || (exports.WordListType = WordListType = {}));
package/dist/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const SDK_VERSION = "0.1.3";
2
- export declare const SDK_BUILD_NUMBER = "0010301";
1
+ export declare const SDK_VERSION = "0.1.5";
2
+ export declare const SDK_BUILD_NUMBER = "0010501";
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.1.3";
5
- exports.SDK_BUILD_NUMBER = "0010301";
6
- const SDK_CORE_VERSION = "0.1.3";
4
+ exports.SDK_VERSION = "0.1.5";
5
+ exports.SDK_BUILD_NUMBER = "0010501";
6
+ const SDK_CORE_VERSION = "0.1.5";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@1password/sdk",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
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.3"
29
+ "@1password/sdk-core": "0.1.5"
30
30
  },
31
31
  "devDependencies": {
32
32
  "@1password/eslint-config": "^4.0.0",