@1password/sdk 0.2.0 → 0.2.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 CHANGED
@@ -86,7 +86,7 @@ Operations:
86
86
  - [x] [Delete items](https://developer.1password.com/docs/sdks/manage-items#delete-an-item)
87
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](https://developer.1password.com/docs/sdks/share-items) (items with files cannot be shared)
89
+ - [x] [Share items](https://developer.1password.com/docs/sdks/share-items)
90
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:
@@ -104,8 +104,8 @@ Field types:
104
104
  - [x] Credit card numbers
105
105
  - [x] Emails
106
106
  - [x] References to other items
107
- - [ ] Address
108
- - [ ] Date
107
+ - [x] Address
108
+ - [x] Date
109
109
  - [x] MM/YY
110
110
  - [x] Files attachments and Document items
111
111
  - [x] Menu
@@ -1,6 +1,6 @@
1
1
  import { ClientAuthConfig } from "./core.js";
2
2
  export declare const LANGUAGE = "JS";
3
- export declare const VERSION = "0020001";
3
+ export declare const VERSION = "0020101";
4
4
  export interface ClientConfiguration {
5
5
  auth: Auth;
6
6
  integrationName: string;
package/dist/secrets.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { InnerClient } from "./core.js";
2
- import { GeneratePasswordResponse, PasswordRecipe } from "./types.js";
2
+ import { GeneratePasswordResponse, PasswordRecipe, ResolveAllResponse } 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>
@@ -9,6 +9,10 @@ export interface SecretsApi {
9
9
  * Resolve returns the secret the provided secret reference points to.
10
10
  */
11
11
  resolve(secretReference: string): Promise<string>;
12
+ /**
13
+ * Resolve takes in a list of secret references and returns the secrets they point to or errors if any.
14
+ */
15
+ resolveAll(secretReferences: string[]): Promise<ResolveAllResponse>;
12
16
  }
13
17
  export declare class Secrets implements SecretsApi {
14
18
  #private;
@@ -17,6 +21,10 @@ export declare class Secrets implements SecretsApi {
17
21
  * Resolve returns the secret the provided secret reference points to.
18
22
  */
19
23
  resolve(secretReference: string): Promise<string>;
24
+ /**
25
+ * Resolve takes in a list of secret references and returns the secrets they point to or errors if any.
26
+ */
27
+ resolveAll(secretReferences: string[]): Promise<ResolveAllResponse>;
20
28
  /**
21
29
  * Validate the secret reference to ensure there are no syntax errors.
22
30
  */
package/dist/secrets.js CHANGED
@@ -49,6 +49,25 @@ class Secrets {
49
49
  return JSON.parse(yield __classPrivateFieldGet(this, _Secrets_inner, "f").core.invoke(invocationConfig), types_js_1.ReviverFunc);
50
50
  });
51
51
  }
52
+ /**
53
+ * Resolve takes in a list of secret references and returns the secrets they point to or errors if any.
54
+ */
55
+ resolveAll(secretReferences) {
56
+ return __awaiter(this, void 0, void 0, function* () {
57
+ const invocationConfig = {
58
+ invocation: {
59
+ clientId: __classPrivateFieldGet(this, _Secrets_inner, "f").id,
60
+ parameters: {
61
+ name: "SecretsResolveAll",
62
+ parameters: {
63
+ secret_references: secretReferences,
64
+ },
65
+ },
66
+ },
67
+ };
68
+ return JSON.parse(yield __classPrivateFieldGet(this, _Secrets_inner, "f").core.invoke(invocationConfig), types_js_1.ReviverFunc);
69
+ });
70
+ }
52
71
  /**
53
72
  * Validate the secret reference to ensure there are no syntax errors.
54
73
  */
package/dist/types.d.ts CHANGED
@@ -1,7 +1,21 @@
1
+ export type ErrorMessage = string;
2
+ /** Additional attributes for OTP fields. */
3
+ export interface AddressFieldDetails {
4
+ /** The street address */
5
+ street: string;
6
+ /** The city */
7
+ city: string;
8
+ /** The country */
9
+ country: string;
10
+ /** The ZIP code */
11
+ zip: string;
12
+ /** The state */
13
+ state: string;
14
+ }
1
15
  export interface DocumentCreateParams {
2
- /** the name of the file */
16
+ /** The name of the file */
3
17
  name: string;
4
- /** the content of the file */
18
+ /** The content of the file */
5
19
  content: Uint8Array;
6
20
  }
7
21
  export interface FileAttributes {
@@ -13,13 +27,13 @@ export interface FileAttributes {
13
27
  size: number;
14
28
  }
15
29
  export interface FileCreateParams {
16
- /** the name of the file */
30
+ /** The name of the file */
17
31
  name: string;
18
- /** the content of the file */
32
+ /** The content of the file */
19
33
  content: Uint8Array;
20
- /** the section id where the file should be stored */
34
+ /** The section id where the file should be stored */
21
35
  sectionId: string;
22
- /** the field id where the file should be stored */
36
+ /** The field id where the file should be stored */
23
37
  fieldId: string;
24
38
  }
25
39
  /**
@@ -69,6 +83,8 @@ export declare enum ItemFieldType {
69
83
  SshKey = "SshKey",
70
84
  Menu = "Menu",
71
85
  MonthYear = "MonthYear",
86
+ Address = "Address",
87
+ Date = "Date",
72
88
  Unsupported = "Unsupported"
73
89
  }
74
90
  /** Field type-specific attributes. */
@@ -82,6 +98,11 @@ export type ItemFieldDetails =
82
98
  | {
83
99
  type: "SshKey";
84
100
  content?: SshKeyAttributes;
101
+ }
102
+ /** Address components */
103
+ | {
104
+ type: "Address";
105
+ content?: AddressFieldDetails;
85
106
  };
86
107
  /** Represents a field within an item. */
87
108
  export interface ItemField {
@@ -165,6 +186,10 @@ export interface Item {
165
186
  files: ItemFile[];
166
187
  /** The document file for the Document item category */
167
188
  document?: FileAttributes;
189
+ /** The time the item was created at */
190
+ createdAt: Date;
191
+ /** The time the item was updated at */
192
+ updatedAt: Date;
168
193
  }
169
194
  export interface ItemCreateParams {
170
195
  /** The item's category */
@@ -185,10 +210,10 @@ export interface ItemCreateParams {
185
210
  websites?: Website[];
186
211
  /** The item's files stored as fields */
187
212
  files?: FileCreateParams[];
188
- /** The document file for the Document item category */
213
+ /** The document file for the Document item type. Empty when the item isn't of Document type. */
189
214
  document?: DocumentCreateParams;
190
215
  }
191
- /** Represents a decrypted 1Password item. */
216
+ /** Represents a decrypted 1Password item overview. */
192
217
  export interface ItemOverview {
193
218
  /** The item's ID */
194
219
  id: string;
@@ -200,6 +225,12 @@ export interface ItemOverview {
200
225
  vaultId: string;
201
226
  /** The websites used for autofilling for items of the Login and Password categories. */
202
227
  websites: Website[];
228
+ /** The item tags */
229
+ tags: string[];
230
+ /** The time the item was created at */
231
+ createdAt: Date;
232
+ /** The time the item was updated at */
233
+ updatedAt: Date;
203
234
  }
204
235
  /** The valid duration options for sharing an item */
205
236
  export declare enum ItemShareDuration {
@@ -228,6 +259,23 @@ export declare enum AllowedRecipientType {
228
259
  /** Recipients can be specified by domain */
229
260
  Domain = "Domain"
230
261
  }
262
+ /** The file sharing policy */
263
+ export interface ItemShareFiles {
264
+ /** Whether files can be included in item shares */
265
+ allowed: boolean;
266
+ /** The maximum encrypted size (in bytes) an included file can be */
267
+ maxSize: number;
268
+ /** The allowed types of item sharing - either "Authenticated" (share to specific users) or "Public" (share to anyone with a link) */
269
+ allowedTypes?: AllowedType[];
270
+ /** The allowed recipient types of item sharing - either "Email" or "Domain" */
271
+ allowedRecipientTypes?: AllowedRecipientType[];
272
+ /** The maximum duration that an item can be shared for */
273
+ maxExpiry?: ItemShareDuration;
274
+ /** The default duration that an item is shared for */
275
+ defaultExpiry?: ItemShareDuration;
276
+ /** The maximum number of times an item can be viewed. A null value means unlimited views */
277
+ maxViews?: number;
278
+ }
231
279
  /**
232
280
  * The account policy for sharing items, set by your account owner/admin
233
281
  * This policy is enforced server-side when sharing items
@@ -243,6 +291,8 @@ export interface ItemShareAccountPolicy {
243
291
  allowedTypes: AllowedType[];
244
292
  /** The allowed recipient types of item sharing - either "Email" or "Domain" */
245
293
  allowedRecipientTypes: AllowedRecipientType[];
294
+ /** The file sharing policy */
295
+ files: ItemShareFiles;
246
296
  }
247
297
  /** The validated recipient of an item share */
248
298
  export type ValidRecipient =
@@ -279,6 +329,99 @@ export interface OtpFieldDetails {
279
329
  /** The error message, if the OTP code could not be computed */
280
330
  errorMessage?: string;
281
331
  }
332
+ export interface Response<T, E> {
333
+ content?: T;
334
+ error?: E;
335
+ }
336
+ export interface ResolvedReference {
337
+ secret: string;
338
+ itemId: string;
339
+ vaultId: string;
340
+ }
341
+ export type ResolveReferenceError =
342
+ /** Error parsing the secret reference */
343
+ {
344
+ type: "parsing";
345
+ message: ErrorMessage;
346
+ }
347
+ /** The specified reference cannot be found within the item */
348
+ | {
349
+ type: "fieldNotFound";
350
+ message?: undefined;
351
+ }
352
+ /** No vault matched the secret reference query */
353
+ | {
354
+ type: "vaultNotFound";
355
+ message?: undefined;
356
+ }
357
+ /** More than one vault matched the secret reference query */
358
+ | {
359
+ type: "tooManyVaults";
360
+ message?: undefined;
361
+ }
362
+ /** No item matched the secret reference query */
363
+ | {
364
+ type: "itemNotFound";
365
+ message?: undefined;
366
+ }
367
+ /** More than one item matched the secret reference query */
368
+ | {
369
+ type: "tooManyItems";
370
+ message?: undefined;
371
+ }
372
+ /** More than one field matched the provided secret reference */
373
+ | {
374
+ type: "tooManyMatchingFields";
375
+ message?: undefined;
376
+ }
377
+ /** No section found within the item for the provided identifier */
378
+ | {
379
+ type: "noMatchingSections";
380
+ message?: undefined;
381
+ }
382
+ /** Incompatiable TOTP query parameters */
383
+ | {
384
+ type: "incompatibleTOTPQueryParameterField";
385
+ message?: undefined;
386
+ }
387
+ /** The totp was not able to be generated */
388
+ | {
389
+ type: "unableToGenerateTotpCode";
390
+ message: ErrorMessage;
391
+ }
392
+ /** Couldn't find attributes specific to an SSH Key field */
393
+ | {
394
+ type: "sSHKeyMetadataNotFound";
395
+ message?: undefined;
396
+ }
397
+ /** Currently only support text files */
398
+ | {
399
+ type: "unsupportedFileFormat";
400
+ message?: undefined;
401
+ }
402
+ /** Trying to convert a non-private key to a private key format */
403
+ | {
404
+ type: "incompatibleSshKeyQueryParameterField";
405
+ message?: undefined;
406
+ }
407
+ /** Unable to properly parse a private key string to convert to an internal Private Key type */
408
+ | {
409
+ type: "unableToParsePrivateKey";
410
+ message?: undefined;
411
+ }
412
+ /** Unable to format a private key to OpenSSH format */
413
+ | {
414
+ type: "unableToFormatPrivateKeyToOpenSsh";
415
+ message?: undefined;
416
+ }
417
+ /** Other type */
418
+ | {
419
+ type: "other";
420
+ message?: undefined;
421
+ };
422
+ export interface ResolveAllResponse {
423
+ individualResponses: Record<string, Response<ResolvedReference, ResolveReferenceError>>;
424
+ }
282
425
  export interface SshKeyAttributes {
283
426
  /** The public part of the SSH Key */
284
427
  publicKey: string;
@@ -370,5 +513,11 @@ export declare enum WordListType {
370
513
  /** Three (random) letter "words" */
371
514
  ThreeLetters = "threeLetters"
372
515
  }
516
+ /**
517
+ * Custom JSON reviver and replacer functions for dynamic data transformation
518
+ * ReviverFunc is used during JSON parsing to detect and transform specific data structures
519
+ * ReplacerFunc is used during JSON serialization to modify certain values before stringifying.
520
+ * These functions allow for flexible encoding and decoding of data, ensuring that complex types are properly handled when converting between TS objects and JSON
521
+ */
373
522
  export declare const ReviverFunc: (key: string, value: unknown) => unknown;
374
523
  export declare const ReplacerFunc: (key: string, value: unknown) => unknown;
package/dist/types.js CHANGED
@@ -45,6 +45,8 @@ var ItemFieldType;
45
45
  ItemFieldType["SshKey"] = "SshKey";
46
46
  ItemFieldType["Menu"] = "Menu";
47
47
  ItemFieldType["MonthYear"] = "MonthYear";
48
+ ItemFieldType["Address"] = "Address";
49
+ ItemFieldType["Date"] = "Date";
48
50
  ItemFieldType["Unsupported"] = "Unsupported";
49
51
  })(ItemFieldType || (exports.ItemFieldType = ItemFieldType = {}));
50
52
  /**
@@ -141,7 +143,18 @@ var WordListType;
141
143
  /** Three (random) letter "words" */
142
144
  WordListType["ThreeLetters"] = "threeLetters";
143
145
  })(WordListType || (exports.WordListType = WordListType = {}));
146
+ /**
147
+ * Custom JSON reviver and replacer functions for dynamic data transformation
148
+ * ReviverFunc is used during JSON parsing to detect and transform specific data structures
149
+ * ReplacerFunc is used during JSON serialization to modify certain values before stringifying.
150
+ * These functions allow for flexible encoding and decoding of data, ensuring that complex types are properly handled when converting between TS objects and JSON
151
+ */
144
152
  const ReviverFunc = (key, value) => {
153
+ if (typeof value === "string" &&
154
+ /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?Z$/.test(value) &&
155
+ (key === "createdAt" || key === "updatedAt")) {
156
+ return new Date(value);
157
+ }
145
158
  if (Array.isArray(value) &&
146
159
  value.every((v) => Number.isInteger(v) && v >= 0 && v <= 255) &&
147
160
  value.length > 0) {
@@ -151,6 +164,9 @@ const ReviverFunc = (key, value) => {
151
164
  };
152
165
  exports.ReviverFunc = ReviverFunc;
153
166
  const ReplacerFunc = (key, value) => {
167
+ if (value instanceof Date) {
168
+ return value.toISOString();
169
+ }
154
170
  if (value instanceof Uint8Array) {
155
171
  return Array.from(value);
156
172
  }
package/dist/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const SDK_VERSION = "0.2.0";
2
- export declare const SDK_BUILD_NUMBER = "0020001";
1
+ export declare const SDK_VERSION = "0.2.1";
2
+ export declare const SDK_BUILD_NUMBER = "0020101";
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.0";
5
- exports.SDK_BUILD_NUMBER = "0020001";
6
- const SDK_CORE_VERSION = "0.2.0";
4
+ exports.SDK_VERSION = "0.2.1";
5
+ exports.SDK_BUILD_NUMBER = "0020101";
6
+ const SDK_CORE_VERSION = "0.2.1";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@1password/sdk",
3
- "version": "0.2.0",
3
+ "version": "0.2.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.2.0"
29
+ "@1password/sdk-core": "0.2.1"
30
30
  },
31
31
  "devDependencies": {
32
32
  "@1password/eslint-config": "^4.0.0",