@bitwarden/sdk-internal 0.2.0-main.297 → 0.2.0-main.298

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.
@@ -179,6 +179,138 @@ export interface TestError extends Error {
179
179
 
180
180
  export function isTestError(error: any): error is TestError;
181
181
 
182
+ /**
183
+ * Represents the possible, expected errors that can occur when requesting a send access token.
184
+ */
185
+ export type SendAccessTokenApiErrorResponse =
186
+ | {
187
+ error: "invalid_request";
188
+ error_description?: string;
189
+ send_access_error_type?: SendAccessTokenInvalidRequestError;
190
+ }
191
+ | {
192
+ error: "invalid_grant";
193
+ error_description?: string;
194
+ send_access_error_type?: SendAccessTokenInvalidGrantError;
195
+ }
196
+ | { error: "invalid_client"; error_description?: string }
197
+ | { error: "unauthorized_client"; error_description?: string }
198
+ | { error: "unsupported_grant_type"; error_description?: string }
199
+ | { error: "invalid_scope"; error_description?: string }
200
+ | { error: "invalid_target"; error_description?: string };
201
+
202
+ /**
203
+ * Invalid grant errors - typically due to invalid credentials.
204
+ */
205
+ export type SendAccessTokenInvalidGrantError =
206
+ | "send_id_invalid"
207
+ | "password_hash_b64_invalid"
208
+ | "email_invalid"
209
+ | "otp_invalid"
210
+ | "otp_generation_failed"
211
+ | "unknown";
212
+
213
+ /**
214
+ * Invalid request errors - typically due to missing parameters.
215
+ */
216
+ export type SendAccessTokenInvalidRequestError =
217
+ | "send_id_required"
218
+ | "password_hash_b64_required"
219
+ | "email_required"
220
+ | "email_and_otp_required_otp_sent"
221
+ | "unknown";
222
+
223
+ /**
224
+ * Any unexpected error that occurs when making requests to identity. This could be
225
+ * local/transport/decoding failure from the HTTP client (DNS/TLS/connect/read timeout,
226
+ * connection reset, or JSON decode failure on a success response) or non-2xx response with an
227
+ * unexpected body or status. Used when decoding the server\'s error payload into
228
+ * `SendAccessTokenApiErrorResponse` fails, or for 5xx responses where no structured error is
229
+ * available.
230
+ */
231
+ export type UnexpectedIdentityError = string;
232
+
233
+ /**
234
+ * Represents errors that can occur when requesting a send access token.
235
+ * It includes expected and unexpected API errors.
236
+ */
237
+ export type SendAccessTokenError =
238
+ | { kind: "unexpected"; data: UnexpectedIdentityError }
239
+ | { kind: "expected"; data: SendAccessTokenApiErrorResponse };
240
+
241
+ /**
242
+ * A send access token which can be used to access a send.
243
+ */
244
+ export interface SendAccessTokenResponse {
245
+ /**
246
+ * The actual token string.
247
+ */
248
+ token: string;
249
+ /**
250
+ * The timestamp in milliseconds when the token expires.
251
+ */
252
+ expiresAt: number;
253
+ }
254
+
255
+ /**
256
+ * A request structure for requesting a send access token from the API.
257
+ */
258
+ export interface SendAccessTokenRequest {
259
+ /**
260
+ * The id of the send for which the access token is requested.
261
+ */
262
+ sendId: string;
263
+ /**
264
+ * The optional send access credentials.
265
+ */
266
+ sendAccessCredentials?: SendAccessCredentials;
267
+ }
268
+
269
+ /**
270
+ * The credentials used for send access requests.
271
+ */
272
+ export type SendAccessCredentials =
273
+ | SendPasswordCredentials
274
+ | SendEmailCredentials
275
+ | SendEmailOtpCredentials;
276
+
277
+ /**
278
+ * Credentials for getting a send access token using an email and OTP.
279
+ */
280
+ export interface SendEmailOtpCredentials {
281
+ /**
282
+ * The email address to which the OTP will be sent.
283
+ */
284
+ email: string;
285
+ /**
286
+ * The one-time password (OTP) that the user has received via email.
287
+ */
288
+ otp: string;
289
+ }
290
+
291
+ /**
292
+ * Credentials for sending an OTP to the user\'s email address.
293
+ * This is used when the send requires email verification with an OTP.
294
+ */
295
+ export interface SendEmailCredentials {
296
+ /**
297
+ * The email address to which the OTP will be sent.
298
+ */
299
+ email: string;
300
+ }
301
+
302
+ /**
303
+ * Credentials for sending password secured access requests.
304
+ * Clone auto implements the standard lib\'s Clone trait, allowing us to create copies of this
305
+ * struct.
306
+ */
307
+ export interface SendPasswordCredentials {
308
+ /**
309
+ * A Base64-encoded hash of the password protecting the send.
310
+ */
311
+ passwordHashB64: string;
312
+ }
313
+
182
314
  /**
183
315
  * NewType wrapper for `CollectionId`
184
316
  */
@@ -1915,13 +2047,16 @@ export class PureCrypto {
1915
2047
  */
1916
2048
  static derive_kdf_material(password: Uint8Array, salt: Uint8Array, kdf: Kdf): Uint8Array;
1917
2049
  }
2050
+ /**
2051
+ * The `SendAccessClient` is used to interact with the Bitwarden API to get send access tokens.
2052
+ */
1918
2053
  export class SendAccessClient {
1919
2054
  private constructor();
1920
2055
  free(): void;
1921
2056
  /**
1922
- * Request an access token for the provided send
2057
+ * Requests a new send access token.
1923
2058
  */
1924
- request_send_access_token(request: string): Promise<string>;
2059
+ request_send_access_token(request: SendAccessTokenRequest): Promise<SendAccessTokenResponse>;
1925
2060
  }
1926
2061
  export class StateClient {
1927
2062
  private constructor();
@@ -828,7 +828,7 @@ module.exports.isEncryptFileError = function (error) {
828
828
  };
829
829
 
830
830
  function __wbg_adapter_54(arg0, arg1, arg2) {
831
- wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h6a23de37c0a4c025(
831
+ wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hb3d7232059e1cc02(
832
832
  arg0,
833
833
  arg1,
834
834
  addHeapObject(arg2),
@@ -838,7 +838,7 @@ function __wbg_adapter_54(arg0, arg1, arg2) {
838
838
  function __wbg_adapter_57(arg0, arg1, arg2) {
839
839
  try {
840
840
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
841
- wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h3dbaf14f9a6d0ccb(
841
+ wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h0165cee9349ff8be(
842
842
  retptr,
843
843
  arg0,
844
844
  arg1,
@@ -3701,7 +3701,9 @@ const SendAccessClientFinalization =
3701
3701
  typeof FinalizationRegistry === "undefined"
3702
3702
  ? { register: () => {}, unregister: () => {} }
3703
3703
  : new FinalizationRegistry((ptr) => wasm.__wbg_sendaccessclient_free(ptr >>> 0, 1));
3704
-
3704
+ /**
3705
+ * The `SendAccessClient` is used to interact with the Bitwarden API to get send access tokens.
3706
+ */
3705
3707
  class SendAccessClient {
3706
3708
  static __wrap(ptr) {
3707
3709
  ptr = ptr >>> 0;
@@ -3723,14 +3725,15 @@ class SendAccessClient {
3723
3725
  wasm.__wbg_sendaccessclient_free(ptr, 0);
3724
3726
  }
3725
3727
  /**
3726
- * Request an access token for the provided send
3727
- * @param {string} request
3728
- * @returns {Promise<string>}
3728
+ * Requests a new send access token.
3729
+ * @param {SendAccessTokenRequest} request
3730
+ * @returns {Promise<SendAccessTokenResponse>}
3729
3731
  */
3730
3732
  request_send_access_token(request) {
3731
- const ptr0 = passStringToWasm0(request, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3732
- const len0 = WASM_VECTOR_LEN;
3733
- const ret = wasm.sendaccessclient_request_send_access_token(this.__wbg_ptr, ptr0, len0);
3733
+ const ret = wasm.sendaccessclient_request_send_access_token(
3734
+ this.__wbg_ptr,
3735
+ addHeapObject(request),
3736
+ );
3734
3737
  return takeObject(ret);
3735
3738
  }
3736
3739
  }
@@ -3971,6 +3974,13 @@ module.exports.__wbg_append_b44785ebeb668479 = function () {
3971
3974
  }, arguments);
3972
3975
  };
3973
3976
 
3977
+ module.exports.__wbg_arrayBuffer_d1b44c4390db422f = function () {
3978
+ return handleError(function (arg0) {
3979
+ const ret = getObject(arg0).arrayBuffer();
3980
+ return addHeapObject(ret);
3981
+ }, arguments);
3982
+ };
3983
+
3974
3984
  module.exports.__wbg_buffer_609cc3eee51ed158 = function (arg0) {
3975
3985
  const ret = getObject(arg0).buffer;
3976
3986
  return addHeapObject(ret);
@@ -4076,7 +4086,7 @@ module.exports.__wbg_getTime_46267b1c24877e30 = function (arg0) {
4076
4086
  return ret;
4077
4087
  };
4078
4088
 
4079
- module.exports.__wbg_get_484769665c8b04d7 = function () {
4089
+ module.exports.__wbg_get_5954c491716c2aba = function () {
4080
4090
  return handleError(function (arg0, arg1, arg2) {
4081
4091
  let deferred0_0;
4082
4092
  let deferred0_1;
@@ -4103,7 +4113,7 @@ module.exports.__wbg_get_b9b93047fe3cf45b = function (arg0, arg1) {
4103
4113
  return addHeapObject(ret);
4104
4114
  };
4105
4115
 
4106
- module.exports.__wbg_get_de8d5678adfaf755 = function () {
4116
+ module.exports.__wbg_get_f292da1aaf91a9f6 = function () {
4107
4117
  return handleError(function (arg0, arg1, arg2) {
4108
4118
  let deferred0_0;
4109
4119
  let deferred0_1;
@@ -4118,7 +4128,7 @@ module.exports.__wbg_get_de8d5678adfaf755 = function () {
4118
4128
  }, arguments);
4119
4129
  };
4120
4130
 
4121
- module.exports.__wbg_getaccesstoken_96168db7f6c5341e = function (arg0) {
4131
+ module.exports.__wbg_getaccesstoken_83d6cb0a610d80fb = function (arg0) {
4122
4132
  const ret = getObject(arg0).get_access_token();
4123
4133
  return addHeapObject(ret);
4124
4134
  };
@@ -4303,14 +4313,14 @@ module.exports.__wbg_length_e2d2a49132c1b256 = function (arg0) {
4303
4313
  return ret;
4304
4314
  };
4305
4315
 
4306
- module.exports.__wbg_list_8f027b1e8d6eeabd = function () {
4316
+ module.exports.__wbg_list_c75c44aded6fb0ed = function () {
4307
4317
  return handleError(function (arg0) {
4308
4318
  const ret = getObject(arg0).list();
4309
4319
  return addHeapObject(ret);
4310
4320
  }, arguments);
4311
4321
  };
4312
4322
 
4313
- module.exports.__wbg_list_dc4b0ecf24e8c2e6 = function () {
4323
+ module.exports.__wbg_list_f22b3fc3f932db50 = function () {
4314
4324
  return handleError(function (arg0) {
4315
4325
  const ret = getObject(arg0).list();
4316
4326
  return addHeapObject(ret);
@@ -4511,7 +4521,7 @@ module.exports.__wbg_randomFillSync_ac0988aba3254290 = function () {
4511
4521
  }, arguments);
4512
4522
  };
4513
4523
 
4514
- module.exports.__wbg_remove_6a18bbab25f54853 = function () {
4524
+ module.exports.__wbg_remove_2860ca0121286728 = function () {
4515
4525
  return handleError(function (arg0, arg1, arg2) {
4516
4526
  let deferred0_0;
4517
4527
  let deferred0_1;
@@ -4526,7 +4536,7 @@ module.exports.__wbg_remove_6a18bbab25f54853 = function () {
4526
4536
  }, arguments);
4527
4537
  };
4528
4538
 
4529
- module.exports.__wbg_remove_a2c151845405193a = function () {
4539
+ module.exports.__wbg_remove_4b6c3a289bd83e64 = function () {
4530
4540
  return handleError(function (arg0, arg1, arg2) {
4531
4541
  let deferred0_0;
4532
4542
  let deferred0_1;
@@ -4572,19 +4582,7 @@ module.exports.__wbg_setTimeout_ca12ead8b48245e2 = function (arg0, arg1) {
4572
4582
  return addHeapObject(ret);
4573
4583
  };
4574
4584
 
4575
- module.exports.__wbg_set_37837023f3d740e8 = function (arg0, arg1, arg2) {
4576
- getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
4577
- };
4578
-
4579
- module.exports.__wbg_set_3f1d0b984ed272ed = function (arg0, arg1, arg2) {
4580
- getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
4581
- };
4582
-
4583
- module.exports.__wbg_set_65595bdd868b3009 = function (arg0, arg1, arg2) {
4584
- getObject(arg0).set(getObject(arg1), arg2 >>> 0);
4585
- };
4586
-
4587
- module.exports.__wbg_set_8136ddb4c6a06792 = function () {
4585
+ module.exports.__wbg_set_2e736aaa4683c4c3 = function () {
4588
4586
  return handleError(function (arg0, arg1, arg2, arg3) {
4589
4587
  let deferred0_0;
4590
4588
  let deferred0_1;
@@ -4599,12 +4597,24 @@ module.exports.__wbg_set_8136ddb4c6a06792 = function () {
4599
4597
  }, arguments);
4600
4598
  };
4601
4599
 
4600
+ module.exports.__wbg_set_37837023f3d740e8 = function (arg0, arg1, arg2) {
4601
+ getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
4602
+ };
4603
+
4604
+ module.exports.__wbg_set_3f1d0b984ed272ed = function (arg0, arg1, arg2) {
4605
+ getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
4606
+ };
4607
+
4608
+ module.exports.__wbg_set_65595bdd868b3009 = function (arg0, arg1, arg2) {
4609
+ getObject(arg0).set(getObject(arg1), arg2 >>> 0);
4610
+ };
4611
+
4602
4612
  module.exports.__wbg_set_8fc6bf8a5b1071d1 = function (arg0, arg1, arg2) {
4603
4613
  const ret = getObject(arg0).set(getObject(arg1), getObject(arg2));
4604
4614
  return addHeapObject(ret);
4605
4615
  };
4606
4616
 
4607
- module.exports.__wbg_set_951bbfd8bc802f55 = function () {
4617
+ module.exports.__wbg_set_e4e1569b3197663a = function () {
4608
4618
  return handleError(function (arg0, arg1, arg2, arg3) {
4609
4619
  let deferred0_0;
4610
4620
  let deferred0_1;
@@ -4829,28 +4839,28 @@ module.exports.__wbindgen_cb_drop = function (arg0) {
4829
4839
  return ret;
4830
4840
  };
4831
4841
 
4832
- module.exports.__wbindgen_closure_wrapper187 = function (arg0, arg1, arg2) {
4842
+ module.exports.__wbindgen_closure_wrapper188 = function (arg0, arg1, arg2) {
4833
4843
  const ret = makeMutClosure(arg0, arg1, 7, __wbg_adapter_54);
4834
4844
  return addHeapObject(ret);
4835
4845
  };
4836
4846
 
4837
- module.exports.__wbindgen_closure_wrapper189 = function (arg0, arg1, arg2) {
4847
+ module.exports.__wbindgen_closure_wrapper190 = function (arg0, arg1, arg2) {
4838
4848
  const ret = makeMutClosure(arg0, arg1, 7, __wbg_adapter_57);
4839
4849
  return addHeapObject(ret);
4840
4850
  };
4841
4851
 
4842
- module.exports.__wbindgen_closure_wrapper3594 = function (arg0, arg1, arg2) {
4843
- const ret = makeMutClosure(arg0, arg1, 290, __wbg_adapter_60);
4852
+ module.exports.__wbindgen_closure_wrapper3761 = function (arg0, arg1, arg2) {
4853
+ const ret = makeMutClosure(arg0, arg1, 294, __wbg_adapter_60);
4844
4854
  return addHeapObject(ret);
4845
4855
  };
4846
4856
 
4847
- module.exports.__wbindgen_closure_wrapper5956 = function (arg0, arg1, arg2) {
4848
- const ret = makeMutClosure(arg0, arg1, 315, __wbg_adapter_60);
4857
+ module.exports.__wbindgen_closure_wrapper6113 = function (arg0, arg1, arg2) {
4858
+ const ret = makeMutClosure(arg0, arg1, 319, __wbg_adapter_60);
4849
4859
  return addHeapObject(ret);
4850
4860
  };
4851
4861
 
4852
- module.exports.__wbindgen_closure_wrapper6337 = function (arg0, arg1, arg2) {
4853
- const ret = makeMutClosure(arg0, arg1, 339, __wbg_adapter_54);
4862
+ module.exports.__wbindgen_closure_wrapper6494 = function (arg0, arg1, arg2) {
4863
+ const ret = makeMutClosure(arg0, arg1, 342, __wbg_adapter_54);
4854
4864
  return addHeapObject(ret);
4855
4865
  };
4856
4866
 
@@ -175,11 +175,7 @@ export const import_ssh_key: (a: number, b: number, c: number, d: number, e: num
175
175
  export const isTestError: (a: number) => number;
176
176
  export const __wbg_authclient_free: (a: number, b: number) => void;
177
177
  export const authclient_send_access: (a: number) => number;
178
- export const sendaccessclient_request_send_access_token: (
179
- a: number,
180
- b: number,
181
- c: number,
182
- ) => number;
178
+ export const sendaccessclient_request_send_access_token: (a: number, b: number) => number;
183
179
  export const isCollectionDecryptError: (a: number) => number;
184
180
  export const cryptoclient_initialize_user_crypto: (a: number, b: number) => number;
185
181
  export const cryptoclient_initialize_org_crypto: (a: number, b: number) => number;
@@ -398,12 +394,12 @@ export const __wbindgen_exn_store: (a: number) => void;
398
394
  export const __wbindgen_free: (a: number, b: number, c: number) => void;
399
395
  export const __wbindgen_export_4: WebAssembly.Table;
400
396
  export const __wbindgen_add_to_stack_pointer: (a: number) => number;
401
- export const _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h6a23de37c0a4c025: (
397
+ export const _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hb3d7232059e1cc02: (
402
398
  a: number,
403
399
  b: number,
404
400
  c: number,
405
401
  ) => void;
406
- export const _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h3dbaf14f9a6d0ccb: (
402
+ export const _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h0165cee9349ff8be: (
407
403
  a: number,
408
404
  b: number,
409
405
  c: number,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bitwarden/sdk-internal",
3
- "version": "0.2.0-main.297",
3
+ "version": "0.2.0-main.298",
4
4
  "license": "GPL-3.0",
5
5
  "repository": {
6
6
  "type": "git",