@bitwarden/sdk-internal 0.2.0-main.354 → 0.2.0-main.356

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.
@@ -1216,6 +1216,39 @@ export interface DecryptCipherListResult {
1216
1216
  failures: Cipher[];
1217
1217
  }
1218
1218
 
1219
+ /**
1220
+ * Request to add a cipher.
1221
+ */
1222
+ export interface CipherCreateRequest {
1223
+ organizationId: OrganizationId | undefined;
1224
+ folderId: FolderId | undefined;
1225
+ name: string;
1226
+ notes: string | undefined;
1227
+ favorite: boolean;
1228
+ reprompt: CipherRepromptType;
1229
+ type: CipherViewType;
1230
+ fields: FieldView[];
1231
+ }
1232
+
1233
+ /**
1234
+ * Request to edit a cipher.
1235
+ */
1236
+ export interface CipherEditRequest {
1237
+ id: CipherId;
1238
+ organizationId: OrganizationId | undefined;
1239
+ folderId: FolderId | undefined;
1240
+ favorite: boolean;
1241
+ reprompt: CipherRepromptType;
1242
+ name: string;
1243
+ notes: string | undefined;
1244
+ fields: FieldView[];
1245
+ type: CipherViewType;
1246
+ revisionDate: DateTime<Utc>;
1247
+ archivedDate: DateTime<Utc> | undefined;
1248
+ attachments: AttachmentView[];
1249
+ key: EncString | undefined;
1250
+ }
1251
+
1219
1252
  export interface Field {
1220
1253
  name: EncString | undefined;
1221
1254
  value: EncString | undefined;
@@ -1537,11 +1570,50 @@ export interface Identity {
1537
1570
  licenseNumber: EncString | undefined;
1538
1571
  }
1539
1572
 
1573
+ /**
1574
+ * Represents the inner data of a cipher view.
1575
+ */
1576
+ export type CipherViewType =
1577
+ | { login: LoginView }
1578
+ | { card: CardView }
1579
+ | { identity: IdentityView }
1580
+ | { secureNote: SecureNoteView }
1581
+ | { sshKey: SshKeyView };
1582
+
1540
1583
  export interface CipherPermissions {
1541
1584
  delete: boolean;
1542
1585
  restore: boolean;
1543
1586
  }
1544
1587
 
1588
+ export interface GetCipherError extends Error {
1589
+ name: "GetCipherError";
1590
+ variant: "ItemNotFound" | "Crypto" | "RepositoryError";
1591
+ }
1592
+
1593
+ export function isGetCipherError(error: any): error is GetCipherError;
1594
+
1595
+ export interface EditCipherError extends Error {
1596
+ name: "EditCipherError";
1597
+ variant:
1598
+ | "ItemNotFound"
1599
+ | "Crypto"
1600
+ | "Api"
1601
+ | "VaultParse"
1602
+ | "MissingField"
1603
+ | "NotAuthenticated"
1604
+ | "Repository"
1605
+ | "Uuid";
1606
+ }
1607
+
1608
+ export function isEditCipherError(error: any): error is EditCipherError;
1609
+
1610
+ export interface CreateCipherError extends Error {
1611
+ name: "CreateCipherError";
1612
+ variant: "Crypto" | "Api" | "VaultParse" | "MissingField" | "NotAuthenticated" | "Repository";
1613
+ }
1614
+
1615
+ export function isCreateCipherError(error: any): error is CreateCipherError;
1616
+
1545
1617
  export interface CipherError extends Error {
1546
1618
  name: "CipherError";
1547
1619
  variant: "MissingField" | "Crypto" | "Encrypt" | "AttachmentsWithoutKeys";
@@ -1698,6 +1770,14 @@ export class BitwardenClient {
1698
1770
  export class CiphersClient {
1699
1771
  private constructor();
1700
1772
  free(): void;
1773
+ /**
1774
+ * Create a new [Cipher] and save it to the server.
1775
+ */
1776
+ create(request: CipherCreateRequest): Promise<CipherView>;
1777
+ /**
1778
+ * Edit an existing [Cipher] and save it to the server.
1779
+ */
1780
+ edit(request: CipherEditRequest): Promise<CipherView>;
1701
1781
  encrypt(cipher_view: CipherView): EncryptionContext;
1702
1782
  /**
1703
1783
  * Encrypt a cipher with the provided key. This should only be used when rotating encryption
@@ -775,6 +775,45 @@ module.exports.isCreateFolderError = function (error) {
775
775
  }
776
776
  };
777
777
 
778
+ /**
779
+ * @param {any} error
780
+ * @returns {boolean}
781
+ */
782
+ module.exports.isGetCipherError = function (error) {
783
+ try {
784
+ const ret = wasm.isGetCipherError(addBorrowedObject(error));
785
+ return ret !== 0;
786
+ } finally {
787
+ heap[stack_pointer++] = undefined;
788
+ }
789
+ };
790
+
791
+ /**
792
+ * @param {any} error
793
+ * @returns {boolean}
794
+ */
795
+ module.exports.isEditCipherError = function (error) {
796
+ try {
797
+ const ret = wasm.isEditCipherError(addBorrowedObject(error));
798
+ return ret !== 0;
799
+ } finally {
800
+ heap[stack_pointer++] = undefined;
801
+ }
802
+ };
803
+
804
+ /**
805
+ * @param {any} error
806
+ * @returns {boolean}
807
+ */
808
+ module.exports.isCreateCipherError = function (error) {
809
+ try {
810
+ const ret = wasm.isCreateCipherError(addBorrowedObject(error));
811
+ return ret !== 0;
812
+ } finally {
813
+ heap[stack_pointer++] = undefined;
814
+ }
815
+ };
816
+
778
817
  /**
779
818
  * @param {any} error
780
819
  * @returns {boolean}
@@ -848,7 +887,7 @@ function __wbg_adapter_60(arg0, arg1) {
848
887
  );
849
888
  }
850
889
 
851
- function __wbg_adapter_341(arg0, arg1, arg2, arg3) {
890
+ function __wbg_adapter_346(arg0, arg1, arg2, arg3) {
852
891
  wasm.wasm_bindgen__convert__closures__invoke2_mut__h54a8613170fef18e(
853
892
  arg0,
854
893
  arg1,
@@ -1301,6 +1340,24 @@ class CiphersClient {
1301
1340
  const ptr = this.__destroy_into_raw();
1302
1341
  wasm.__wbg_ciphersclient_free(ptr, 0);
1303
1342
  }
1343
+ /**
1344
+ * Create a new [Cipher] and save it to the server.
1345
+ * @param {CipherCreateRequest} request
1346
+ * @returns {Promise<CipherView>}
1347
+ */
1348
+ create(request) {
1349
+ const ret = wasm.ciphersclient_create(this.__wbg_ptr, addHeapObject(request));
1350
+ return takeObject(ret);
1351
+ }
1352
+ /**
1353
+ * Edit an existing [Cipher] and save it to the server.
1354
+ * @param {CipherEditRequest} request
1355
+ * @returns {Promise<CipherView>}
1356
+ */
1357
+ edit(request) {
1358
+ const ret = wasm.ciphersclient_edit(this.__wbg_ptr, addHeapObject(request));
1359
+ return takeObject(ret);
1360
+ }
1304
1361
  /**
1305
1362
  * @param {CipherView} cipher_view
1306
1363
  * @returns {EncryptionContext}
@@ -4061,7 +4118,7 @@ module.exports.__wbg_call_7cccdd69e0791ae2 = function () {
4061
4118
  }, arguments);
4062
4119
  };
4063
4120
 
4064
- module.exports.__wbg_cipher_3ef84bb81bec347a = function (arg0) {
4121
+ module.exports.__wbg_cipher_bfaa6485361c7193 = function (arg0) {
4065
4122
  const ret = getObject(arg0).cipher;
4066
4123
  return isLikeNone(ret) ? 0 : addHeapObject(ret);
4067
4124
  };
@@ -4141,7 +4198,7 @@ module.exports.__wbg_fetch_509096533071c657 = function (arg0, arg1) {
4141
4198
  return addHeapObject(ret);
4142
4199
  };
4143
4200
 
4144
- module.exports.__wbg_folder_c58043e46963725e = function (arg0) {
4201
+ module.exports.__wbg_folder_ec2d6cb62cd394ea = function (arg0) {
4145
4202
  const ret = getObject(arg0).folder;
4146
4203
  return isLikeNone(ret) ? 0 : addHeapObject(ret);
4147
4204
  };
@@ -4163,7 +4220,14 @@ module.exports.__wbg_getTime_46267b1c24877e30 = function (arg0) {
4163
4220
  return ret;
4164
4221
  };
4165
4222
 
4166
- module.exports.__wbg_get_482497ba509c279f = function () {
4223
+ module.exports.__wbg_get_67b2ba62fc30de12 = function () {
4224
+ return handleError(function (arg0, arg1) {
4225
+ const ret = Reflect.get(getObject(arg0), getObject(arg1));
4226
+ return addHeapObject(ret);
4227
+ }, arguments);
4228
+ };
4229
+
4230
+ module.exports.__wbg_get_6dacbdbec3b2a30b = function () {
4167
4231
  return handleError(function (arg0, arg1, arg2) {
4168
4232
  let deferred0_0;
4169
4233
  let deferred0_1;
@@ -4178,19 +4242,12 @@ module.exports.__wbg_get_482497ba509c279f = function () {
4178
4242
  }, arguments);
4179
4243
  };
4180
4244
 
4181
- module.exports.__wbg_get_67b2ba62fc30de12 = function () {
4182
- return handleError(function (arg0, arg1) {
4183
- const ret = Reflect.get(getObject(arg0), getObject(arg1));
4184
- return addHeapObject(ret);
4185
- }, arguments);
4186
- };
4187
-
4188
4245
  module.exports.__wbg_get_b9b93047fe3cf45b = function (arg0, arg1) {
4189
4246
  const ret = getObject(arg0)[arg1 >>> 0];
4190
4247
  return addHeapObject(ret);
4191
4248
  };
4192
4249
 
4193
- module.exports.__wbg_get_fb2c5abe3ecf4327 = function () {
4250
+ module.exports.__wbg_get_f30d8f791413aaa1 = function () {
4194
4251
  return handleError(function (arg0, arg1, arg2) {
4195
4252
  let deferred0_0;
4196
4253
  let deferred0_1;
@@ -4205,7 +4262,7 @@ module.exports.__wbg_get_fb2c5abe3ecf4327 = function () {
4205
4262
  }, arguments);
4206
4263
  };
4207
4264
 
4208
- module.exports.__wbg_getaccesstoken_9e32a90d6288c168 = function (arg0) {
4265
+ module.exports.__wbg_getaccesstoken_b02a0476dedfb4e3 = function (arg0) {
4209
4266
  const ret = getObject(arg0).get_access_token();
4210
4267
  return addHeapObject(ret);
4211
4268
  };
@@ -4390,14 +4447,14 @@ module.exports.__wbg_length_e2d2a49132c1b256 = function (arg0) {
4390
4447
  return ret;
4391
4448
  };
4392
4449
 
4393
- module.exports.__wbg_list_8e8e87c793258a92 = function () {
4450
+ module.exports.__wbg_list_2c26b179cf05e46b = function () {
4394
4451
  return handleError(function (arg0) {
4395
4452
  const ret = getObject(arg0).list();
4396
4453
  return addHeapObject(ret);
4397
4454
  }, arguments);
4398
4455
  };
4399
4456
 
4400
- module.exports.__wbg_list_b2e76202b8524498 = function () {
4457
+ module.exports.__wbg_list_314b5bbafea38250 = function () {
4401
4458
  return handleError(function (arg0) {
4402
4459
  const ret = getObject(arg0).list();
4403
4460
  return addHeapObject(ret);
@@ -4440,7 +4497,7 @@ module.exports.__wbg_new_23a2665fac83c611 = function (arg0, arg1) {
4440
4497
  const a = state0.a;
4441
4498
  state0.a = 0;
4442
4499
  try {
4443
- return __wbg_adapter_341(a, state0.b, arg0, arg1);
4500
+ return __wbg_adapter_346(a, state0.b, arg0, arg1);
4444
4501
  } finally {
4445
4502
  state0.a = a;
4446
4503
  }
@@ -4598,7 +4655,7 @@ module.exports.__wbg_randomFillSync_ac0988aba3254290 = function () {
4598
4655
  }, arguments);
4599
4656
  };
4600
4657
 
4601
- module.exports.__wbg_remove_1d11b7043a9b2631 = function () {
4658
+ module.exports.__wbg_remove_1053ec403a6c0a33 = function () {
4602
4659
  return handleError(function (arg0, arg1, arg2) {
4603
4660
  let deferred0_0;
4604
4661
  let deferred0_1;
@@ -4613,7 +4670,7 @@ module.exports.__wbg_remove_1d11b7043a9b2631 = function () {
4613
4670
  }, arguments);
4614
4671
  };
4615
4672
 
4616
- module.exports.__wbg_remove_4bdd32ee030cdba5 = function () {
4673
+ module.exports.__wbg_remove_8f22cc225864443a = function () {
4617
4674
  return handleError(function (arg0, arg1, arg2) {
4618
4675
  let deferred0_0;
4619
4676
  let deferred0_1;
@@ -4667,11 +4724,7 @@ module.exports.__wbg_set_3f1d0b984ed272ed = function (arg0, arg1, arg2) {
4667
4724
  getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
4668
4725
  };
4669
4726
 
4670
- module.exports.__wbg_set_65595bdd868b3009 = function (arg0, arg1, arg2) {
4671
- getObject(arg0).set(getObject(arg1), arg2 >>> 0);
4672
- };
4673
-
4674
- module.exports.__wbg_set_77e9220d80206e12 = function () {
4727
+ module.exports.__wbg_set_5737fc6e1e0d1ccc = function () {
4675
4728
  return handleError(function (arg0, arg1, arg2, arg3) {
4676
4729
  let deferred0_0;
4677
4730
  let deferred0_1;
@@ -4686,12 +4739,11 @@ module.exports.__wbg_set_77e9220d80206e12 = function () {
4686
4739
  }, arguments);
4687
4740
  };
4688
4741
 
4689
- module.exports.__wbg_set_8fc6bf8a5b1071d1 = function (arg0, arg1, arg2) {
4690
- const ret = getObject(arg0).set(getObject(arg1), getObject(arg2));
4691
- return addHeapObject(ret);
4742
+ module.exports.__wbg_set_65595bdd868b3009 = function (arg0, arg1, arg2) {
4743
+ getObject(arg0).set(getObject(arg1), arg2 >>> 0);
4692
4744
  };
4693
4745
 
4694
- module.exports.__wbg_set_b2324c129f5cbef0 = function () {
4746
+ module.exports.__wbg_set_74670a99dc6a4654 = function () {
4695
4747
  return handleError(function (arg0, arg1, arg2, arg3) {
4696
4748
  let deferred0_0;
4697
4749
  let deferred0_1;
@@ -4706,6 +4758,11 @@ module.exports.__wbg_set_b2324c129f5cbef0 = function () {
4706
4758
  }, arguments);
4707
4759
  };
4708
4760
 
4761
+ module.exports.__wbg_set_8fc6bf8a5b1071d1 = function (arg0, arg1, arg2) {
4762
+ const ret = getObject(arg0).set(getObject(arg1), getObject(arg2));
4763
+ return addHeapObject(ret);
4764
+ };
4765
+
4709
4766
  module.exports.__wbg_setbody_5923b78a95eedf29 = function (arg0, arg1) {
4710
4767
  getObject(arg0).body = getObject(arg1);
4711
4768
  };
@@ -4926,18 +4983,18 @@ module.exports.__wbindgen_closure_wrapper195 = function (arg0, arg1, arg2) {
4926
4983
  return addHeapObject(ret);
4927
4984
  };
4928
4985
 
4929
- module.exports.__wbindgen_closure_wrapper3849 = function (arg0, arg1, arg2) {
4930
- const ret = makeMutClosure(arg0, arg1, 293, __wbg_adapter_60);
4986
+ module.exports.__wbindgen_closure_wrapper3930 = function (arg0, arg1, arg2) {
4987
+ const ret = makeMutClosure(arg0, arg1, 298, __wbg_adapter_60);
4931
4988
  return addHeapObject(ret);
4932
4989
  };
4933
4990
 
4934
- module.exports.__wbindgen_closure_wrapper6181 = function (arg0, arg1, arg2) {
4935
- const ret = makeMutClosure(arg0, arg1, 319, __wbg_adapter_60);
4991
+ module.exports.__wbindgen_closure_wrapper6403 = function (arg0, arg1, arg2) {
4992
+ const ret = makeMutClosure(arg0, arg1, 324, __wbg_adapter_60);
4936
4993
  return addHeapObject(ret);
4937
4994
  };
4938
4995
 
4939
- module.exports.__wbindgen_closure_wrapper6561 = function (arg0, arg1, arg2) {
4940
- const ret = makeMutClosure(arg0, arg1, 342, __wbg_adapter_54);
4996
+ module.exports.__wbindgen_closure_wrapper6783 = function (arg0, arg1, arg2) {
4997
+ const ret = makeMutClosure(arg0, arg1, 347, __wbg_adapter_54);
4941
4998
  return addHeapObject(ret);
4942
4999
  };
4943
5000
 
@@ -317,6 +317,8 @@ export const attachmentsclient_decrypt_buffer: (
317
317
  e: number,
318
318
  f: number,
319
319
  ) => void;
320
+ export const ciphersclient_create: (a: number, b: number) => number;
321
+ export const ciphersclient_edit: (a: number, b: number) => number;
320
322
  export const ciphersclient_encrypt: (a: number, b: number, c: number) => void;
321
323
  export const ciphersclient_encrypt_cipher_for_rotation: (
322
324
  a: number,
@@ -376,6 +378,9 @@ export const isTotpError: (a: number) => number;
376
378
  export const isGetFolderError: (a: number) => number;
377
379
  export const isEditFolderError: (a: number) => number;
378
380
  export const isCreateFolderError: (a: number) => number;
381
+ export const isGetCipherError: (a: number) => number;
382
+ export const isEditCipherError: (a: number) => number;
383
+ export const isCreateCipherError: (a: number) => number;
379
384
  export const isCipherError: (a: number) => number;
380
385
  export const isDecryptFileError: (a: number) => number;
381
386
  export const isEncryptFileError: (a: number) => number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bitwarden/sdk-internal",
3
- "version": "0.2.0-main.354",
3
+ "version": "0.2.0-main.356",
4
4
  "license": "GPL-3.0",
5
5
  "repository": {
6
6
  "type": "git",