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

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/VERSION CHANGED
@@ -1 +1 @@
1
- 31b18f02ec8f5713133ea67d42993c12c5923782
1
+ 72f4866fdce1eca7f2f5961ed970f9dccec086af
@@ -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();
@@ -834,7 +834,7 @@ export function isEncryptFileError(error) {
834
834
  }
835
835
 
836
836
  function __wbg_adapter_54(arg0, arg1, arg2) {
837
- wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h6a23de37c0a4c025(
837
+ wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hb3d7232059e1cc02(
838
838
  arg0,
839
839
  arg1,
840
840
  addHeapObject(arg2),
@@ -844,7 +844,7 @@ function __wbg_adapter_54(arg0, arg1, arg2) {
844
844
  function __wbg_adapter_57(arg0, arg1, arg2) {
845
845
  try {
846
846
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
847
- wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h3dbaf14f9a6d0ccb(
847
+ wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h0165cee9349ff8be(
848
848
  retptr,
849
849
  arg0,
850
850
  arg1,
@@ -3689,7 +3689,9 @@ const SendAccessClientFinalization =
3689
3689
  typeof FinalizationRegistry === "undefined"
3690
3690
  ? { register: () => {}, unregister: () => {} }
3691
3691
  : new FinalizationRegistry((ptr) => wasm.__wbg_sendaccessclient_free(ptr >>> 0, 1));
3692
-
3692
+ /**
3693
+ * The `SendAccessClient` is used to interact with the Bitwarden API to get send access tokens.
3694
+ */
3693
3695
  export class SendAccessClient {
3694
3696
  static __wrap(ptr) {
3695
3697
  ptr = ptr >>> 0;
@@ -3711,14 +3713,15 @@ export class SendAccessClient {
3711
3713
  wasm.__wbg_sendaccessclient_free(ptr, 0);
3712
3714
  }
3713
3715
  /**
3714
- * Request an access token for the provided send
3715
- * @param {string} request
3716
- * @returns {Promise<string>}
3716
+ * Requests a new send access token.
3717
+ * @param {SendAccessTokenRequest} request
3718
+ * @returns {Promise<SendAccessTokenResponse>}
3717
3719
  */
3718
3720
  request_send_access_token(request) {
3719
- const ptr0 = passStringToWasm0(request, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3720
- const len0 = WASM_VECTOR_LEN;
3721
- const ret = wasm.sendaccessclient_request_send_access_token(this.__wbg_ptr, ptr0, len0);
3721
+ const ret = wasm.sendaccessclient_request_send_access_token(
3722
+ this.__wbg_ptr,
3723
+ addHeapObject(request),
3724
+ );
3722
3725
  return takeObject(ret);
3723
3726
  }
3724
3727
  }
@@ -3955,6 +3958,13 @@ export function __wbg_append_b44785ebeb668479() {
3955
3958
  }, arguments);
3956
3959
  }
3957
3960
 
3961
+ export function __wbg_arrayBuffer_d1b44c4390db422f() {
3962
+ return handleError(function (arg0) {
3963
+ const ret = getObject(arg0).arrayBuffer();
3964
+ return addHeapObject(ret);
3965
+ }, arguments);
3966
+ }
3967
+
3958
3968
  export function __wbg_buffer_609cc3eee51ed158(arg0) {
3959
3969
  const ret = getObject(arg0).buffer;
3960
3970
  return addHeapObject(ret);
@@ -4060,7 +4070,7 @@ export function __wbg_getTime_46267b1c24877e30(arg0) {
4060
4070
  return ret;
4061
4071
  }
4062
4072
 
4063
- export function __wbg_get_484769665c8b04d7() {
4073
+ export function __wbg_get_49542311e2a81a98() {
4064
4074
  return handleError(function (arg0, arg1, arg2) {
4065
4075
  let deferred0_0;
4066
4076
  let deferred0_1;
@@ -4082,12 +4092,7 @@ export function __wbg_get_67b2ba62fc30de12() {
4082
4092
  }, arguments);
4083
4093
  }
4084
4094
 
4085
- export function __wbg_get_b9b93047fe3cf45b(arg0, arg1) {
4086
- const ret = getObject(arg0)[arg1 >>> 0];
4087
- return addHeapObject(ret);
4088
- }
4089
-
4090
- export function __wbg_get_de8d5678adfaf755() {
4095
+ export function __wbg_get_7cd3baf96f56b901() {
4091
4096
  return handleError(function (arg0, arg1, arg2) {
4092
4097
  let deferred0_0;
4093
4098
  let deferred0_1;
@@ -4102,7 +4107,12 @@ export function __wbg_get_de8d5678adfaf755() {
4102
4107
  }, arguments);
4103
4108
  }
4104
4109
 
4105
- export function __wbg_getaccesstoken_96168db7f6c5341e(arg0) {
4110
+ export function __wbg_get_b9b93047fe3cf45b(arg0, arg1) {
4111
+ const ret = getObject(arg0)[arg1 >>> 0];
4112
+ return addHeapObject(ret);
4113
+ }
4114
+
4115
+ export function __wbg_getaccesstoken_387e11ddb4252dd1(arg0) {
4106
4116
  const ret = getObject(arg0).get_access_token();
4107
4117
  return addHeapObject(ret);
4108
4118
  }
@@ -4287,14 +4297,14 @@ export function __wbg_length_e2d2a49132c1b256(arg0) {
4287
4297
  return ret;
4288
4298
  }
4289
4299
 
4290
- export function __wbg_list_8f027b1e8d6eeabd() {
4300
+ export function __wbg_list_40a2f7363ab2d4d4() {
4291
4301
  return handleError(function (arg0) {
4292
4302
  const ret = getObject(arg0).list();
4293
4303
  return addHeapObject(ret);
4294
4304
  }, arguments);
4295
4305
  }
4296
4306
 
4297
- export function __wbg_list_dc4b0ecf24e8c2e6() {
4307
+ export function __wbg_list_47acf4a53dd8f9d8() {
4298
4308
  return handleError(function (arg0) {
4299
4309
  const ret = getObject(arg0).list();
4300
4310
  return addHeapObject(ret);
@@ -4495,7 +4505,7 @@ export function __wbg_randomFillSync_ac0988aba3254290() {
4495
4505
  }, arguments);
4496
4506
  }
4497
4507
 
4498
- export function __wbg_remove_6a18bbab25f54853() {
4508
+ export function __wbg_remove_af11566a70c3a0f4() {
4499
4509
  return handleError(function (arg0, arg1, arg2) {
4500
4510
  let deferred0_0;
4501
4511
  let deferred0_1;
@@ -4510,7 +4520,7 @@ export function __wbg_remove_6a18bbab25f54853() {
4510
4520
  }, arguments);
4511
4521
  }
4512
4522
 
4513
- export function __wbg_remove_a2c151845405193a() {
4523
+ export function __wbg_remove_d06b9ee228be7796() {
4514
4524
  return handleError(function (arg0, arg1, arg2) {
4515
4525
  let deferred0_0;
4516
4526
  let deferred0_1;
@@ -4568,7 +4578,12 @@ export function __wbg_set_65595bdd868b3009(arg0, arg1, arg2) {
4568
4578
  getObject(arg0).set(getObject(arg1), arg2 >>> 0);
4569
4579
  }
4570
4580
 
4571
- export function __wbg_set_8136ddb4c6a06792() {
4581
+ export function __wbg_set_8fc6bf8a5b1071d1(arg0, arg1, arg2) {
4582
+ const ret = getObject(arg0).set(getObject(arg1), getObject(arg2));
4583
+ return addHeapObject(ret);
4584
+ }
4585
+
4586
+ export function __wbg_set_c6d7694b7fe0eb92() {
4572
4587
  return handleError(function (arg0, arg1, arg2, arg3) {
4573
4588
  let deferred0_0;
4574
4589
  let deferred0_1;
@@ -4583,12 +4598,7 @@ export function __wbg_set_8136ddb4c6a06792() {
4583
4598
  }, arguments);
4584
4599
  }
4585
4600
 
4586
- export function __wbg_set_8fc6bf8a5b1071d1(arg0, arg1, arg2) {
4587
- const ret = getObject(arg0).set(getObject(arg1), getObject(arg2));
4588
- return addHeapObject(ret);
4589
- }
4590
-
4591
- export function __wbg_set_951bbfd8bc802f55() {
4601
+ export function __wbg_set_e11802a3a362bb89() {
4592
4602
  return handleError(function (arg0, arg1, arg2, arg3) {
4593
4603
  let deferred0_0;
4594
4604
  let deferred0_1;
@@ -4813,28 +4823,28 @@ export function __wbindgen_cb_drop(arg0) {
4813
4823
  return ret;
4814
4824
  }
4815
4825
 
4816
- export function __wbindgen_closure_wrapper187(arg0, arg1, arg2) {
4826
+ export function __wbindgen_closure_wrapper188(arg0, arg1, arg2) {
4817
4827
  const ret = makeMutClosure(arg0, arg1, 7, __wbg_adapter_54);
4818
4828
  return addHeapObject(ret);
4819
4829
  }
4820
4830
 
4821
- export function __wbindgen_closure_wrapper189(arg0, arg1, arg2) {
4831
+ export function __wbindgen_closure_wrapper190(arg0, arg1, arg2) {
4822
4832
  const ret = makeMutClosure(arg0, arg1, 7, __wbg_adapter_57);
4823
4833
  return addHeapObject(ret);
4824
4834
  }
4825
4835
 
4826
- export function __wbindgen_closure_wrapper3594(arg0, arg1, arg2) {
4827
- const ret = makeMutClosure(arg0, arg1, 290, __wbg_adapter_60);
4836
+ export function __wbindgen_closure_wrapper3761(arg0, arg1, arg2) {
4837
+ const ret = makeMutClosure(arg0, arg1, 294, __wbg_adapter_60);
4828
4838
  return addHeapObject(ret);
4829
4839
  }
4830
4840
 
4831
- export function __wbindgen_closure_wrapper5956(arg0, arg1, arg2) {
4832
- const ret = makeMutClosure(arg0, arg1, 315, __wbg_adapter_60);
4841
+ export function __wbindgen_closure_wrapper6113(arg0, arg1, arg2) {
4842
+ const ret = makeMutClosure(arg0, arg1, 319, __wbg_adapter_60);
4833
4843
  return addHeapObject(ret);
4834
4844
  }
4835
4845
 
4836
- export function __wbindgen_closure_wrapper6337(arg0, arg1, arg2) {
4837
- const ret = makeMutClosure(arg0, arg1, 339, __wbg_adapter_54);
4846
+ export function __wbindgen_closure_wrapper6494(arg0, arg1, arg2) {
4847
+ const ret = makeMutClosure(arg0, arg1, 342, __wbg_adapter_54);
4838
4848
  return addHeapObject(ret);
4839
4849
  }
4840
4850
 
Binary file
@@ -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,