@bitwarden/sdk-internal 0.2.0-main.211 → 0.2.0-main.213

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
- 6b19644fde7f967df584c825889283795aa521ec
1
+ 025f81899ebb73fd6a24af32e449e38cdb856c71
@@ -1,5 +1,20 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
+ /**
4
+ * Registers a DiscoverHandler so that the client can respond to DiscoverRequests.
5
+ */
6
+ export function ipcRegisterDiscoverHandler(
7
+ ipc_client: IpcClient,
8
+ response: DiscoverResponse,
9
+ ): Promise<void>;
10
+ /**
11
+ * Sends a DiscoverRequest to the specified destination and returns the response.
12
+ */
13
+ export function ipcRequestDiscover(
14
+ ipc_client: IpcClient,
15
+ destination: Endpoint,
16
+ abort_signal?: AbortSignal | null,
17
+ ): Promise<DiscoverResponse>;
3
18
  export function set_log_level(level: LogLevel): void;
4
19
  export function init_sdk(log_level?: LogLevel | null): void;
5
20
  /**
@@ -575,6 +590,10 @@ export interface PassphraseError extends Error {
575
590
 
576
591
  export function isPassphraseError(error: any): error is PassphraseError;
577
592
 
593
+ export interface DiscoverResponse {
594
+ version: string;
595
+ }
596
+
578
597
  export type Endpoint =
579
598
  | { Web: { id: number } }
580
599
  | "BrowserForeground"
@@ -598,6 +617,13 @@ export interface DeserializeError extends Error {
598
617
 
599
618
  export function isDeserializeError(error: any): error is DeserializeError;
600
619
 
620
+ export interface RequestError extends Error {
621
+ name: "RequestError";
622
+ variant: "Subscribe" | "Receive" | "Timeout" | "Send" | "RpcError";
623
+ }
624
+
625
+ export function isRequestError(error: any): error is RequestError;
626
+
601
627
  export interface TypedReceiveError extends Error {
602
628
  name: "TypedReceiveError";
603
629
  variant: "Channel" | "Timeout" | "Cancelled" | "Typing";
@@ -1151,6 +1177,13 @@ export type Utc = unknown;
1151
1177
  */
1152
1178
  export type NonZeroU32 = number;
1153
1179
 
1180
+ export interface Repository<T> {
1181
+ get(id: string): Promise<T | null>;
1182
+ list(): Promise<T[]>;
1183
+ set(id: string, value: T): Promise<void>;
1184
+ remove(id: string): Promise<void>;
1185
+ }
1186
+
1154
1187
  export interface TestError extends Error {
1155
1188
  name: "TestError";
1156
1189
  }
@@ -1181,6 +1214,10 @@ export class BitwardenClient {
1181
1214
  http_get(url: string): Promise<string>;
1182
1215
  crypto(): CryptoClient;
1183
1216
  vault(): VaultClient;
1217
+ /**
1218
+ * Constructs a specific client for platform-specific functionality
1219
+ */
1220
+ platform(): PlatformClient;
1184
1221
  /**
1185
1222
  * Constructs a specific client for generating passwords and passphrases
1186
1223
  */
@@ -1353,7 +1390,7 @@ export class IpcClient {
1353
1390
  export class IpcClientSubscription {
1354
1391
  private constructor();
1355
1392
  free(): void;
1356
- receive(abort_signal?: any | null): Promise<IncomingMessage>;
1393
+ receive(abort_signal?: AbortSignal | null): Promise<IncomingMessage>;
1357
1394
  }
1358
1395
  /**
1359
1396
  * JavaScript implementation of the `CommunicationBackend` trait for IPC communication.
@@ -1385,6 +1422,11 @@ export class OutgoingMessage {
1385
1422
  get topic(): string | undefined;
1386
1423
  set topic(value: string | null | undefined);
1387
1424
  }
1425
+ export class PlatformClient {
1426
+ private constructor();
1427
+ free(): void;
1428
+ state(): StateClient;
1429
+ }
1388
1430
  /**
1389
1431
  * This module represents a stopgap solution to provide access to primitive crypto functions for JS
1390
1432
  * clients. It is not intended to be used outside of the JS clients and this pattern should not be
@@ -1492,6 +1534,11 @@ export class PureCrypto {
1492
1534
  verifying_key: Uint8Array,
1493
1535
  ): Uint8Array;
1494
1536
  }
1537
+ export class StateClient {
1538
+ private constructor();
1539
+ free(): void;
1540
+ register_cipher_repository(store: Repository<Cipher>): void;
1541
+ }
1495
1542
  export class TotpClient {
1496
1543
  private constructor();
1497
1544
  free(): void;
@@ -399,6 +399,35 @@ function _assertClass(instance, klass) {
399
399
  throw new Error(`expected instance of ${klass.name}`);
400
400
  }
401
401
  }
402
+ /**
403
+ * Registers a DiscoverHandler so that the client can respond to DiscoverRequests.
404
+ * @param {IpcClient} ipc_client
405
+ * @param {DiscoverResponse} response
406
+ * @returns {Promise<void>}
407
+ */
408
+ export function ipcRegisterDiscoverHandler(ipc_client, response) {
409
+ _assertClass(ipc_client, IpcClient);
410
+ const ret = wasm.ipcRegisterDiscoverHandler(ipc_client.__wbg_ptr, addHeapObject(response));
411
+ return takeObject(ret);
412
+ }
413
+
414
+ /**
415
+ * Sends a DiscoverRequest to the specified destination and returns the response.
416
+ * @param {IpcClient} ipc_client
417
+ * @param {Endpoint} destination
418
+ * @param {AbortSignal | null} [abort_signal]
419
+ * @returns {Promise<DiscoverResponse>}
420
+ */
421
+ export function ipcRequestDiscover(ipc_client, destination, abort_signal) {
422
+ _assertClass(ipc_client, IpcClient);
423
+ const ret = wasm.ipcRequestDiscover(
424
+ ipc_client.__wbg_ptr,
425
+ addHeapObject(destination),
426
+ isLikeNone(abort_signal) ? 0 : addHeapObject(abort_signal),
427
+ );
428
+ return takeObject(ret);
429
+ }
430
+
402
431
  /**
403
432
  * @param {any} error
404
433
  * @returns {boolean}
@@ -425,6 +454,19 @@ export function isDeserializeError(error) {
425
454
  }
426
455
  }
427
456
 
457
+ /**
458
+ * @param {any} error
459
+ * @returns {boolean}
460
+ */
461
+ export function isRequestError(error) {
462
+ try {
463
+ const ret = wasm.isRequestError(addBorrowedObject(error));
464
+ return ret !== 0;
465
+ } finally {
466
+ heap[stack_pointer++] = undefined;
467
+ }
468
+ }
469
+
428
470
  /**
429
471
  * @param {any} error
430
472
  * @returns {boolean}
@@ -711,7 +753,7 @@ function __wbg_adapter_56(arg0, arg1, arg2) {
711
753
  );
712
754
  }
713
755
 
714
- function __wbg_adapter_260(arg0, arg1, arg2, arg3) {
756
+ function __wbg_adapter_274(arg0, arg1, arg2, arg3) {
715
757
  wasm.wasm_bindgen__convert__closures__invoke2_mut__h8776500d04a3e634(
716
758
  arg0,
717
759
  arg1,
@@ -1041,6 +1083,14 @@ export class BitwardenClient {
1041
1083
  const ret = wasm.bitwardenclient_crypto(this.__wbg_ptr);
1042
1084
  return VaultClient.__wrap(ret);
1043
1085
  }
1086
+ /**
1087
+ * Constructs a specific client for platform-specific functionality
1088
+ * @returns {PlatformClient}
1089
+ */
1090
+ platform() {
1091
+ const ret = wasm.bitwardenclient_platform(this.__wbg_ptr);
1092
+ return PlatformClient.__wrap(ret);
1093
+ }
1044
1094
  /**
1045
1095
  * Constructs a specific client for generating passwords and passphrases
1046
1096
  * @returns {GeneratorClient}
@@ -1976,7 +2026,7 @@ export class IpcClientSubscription {
1976
2026
  wasm.__wbg_ipcclientsubscription_free(ptr, 0);
1977
2027
  }
1978
2028
  /**
1979
- * @param {any | null} [abort_signal]
2029
+ * @param {AbortSignal | null} [abort_signal]
1980
2030
  * @returns {Promise<IncomingMessage>}
1981
2031
  */
1982
2032
  receive(abort_signal) {
@@ -2180,6 +2230,40 @@ export class OutgoingMessage {
2180
2230
  }
2181
2231
  }
2182
2232
 
2233
+ const PlatformClientFinalization =
2234
+ typeof FinalizationRegistry === "undefined"
2235
+ ? { register: () => {}, unregister: () => {} }
2236
+ : new FinalizationRegistry((ptr) => wasm.__wbg_platformclient_free(ptr >>> 0, 1));
2237
+
2238
+ export class PlatformClient {
2239
+ static __wrap(ptr) {
2240
+ ptr = ptr >>> 0;
2241
+ const obj = Object.create(PlatformClient.prototype);
2242
+ obj.__wbg_ptr = ptr;
2243
+ PlatformClientFinalization.register(obj, obj.__wbg_ptr, obj);
2244
+ return obj;
2245
+ }
2246
+
2247
+ __destroy_into_raw() {
2248
+ const ptr = this.__wbg_ptr;
2249
+ this.__wbg_ptr = 0;
2250
+ PlatformClientFinalization.unregister(this);
2251
+ return ptr;
2252
+ }
2253
+
2254
+ free() {
2255
+ const ptr = this.__destroy_into_raw();
2256
+ wasm.__wbg_platformclient_free(ptr, 0);
2257
+ }
2258
+ /**
2259
+ * @returns {StateClient}
2260
+ */
2261
+ state() {
2262
+ const ret = wasm.bitwardenclient_platform(this.__wbg_ptr);
2263
+ return StateClient.__wrap(ret);
2264
+ }
2265
+ }
2266
+
2183
2267
  const PureCryptoFinalization =
2184
2268
  typeof FinalizationRegistry === "undefined"
2185
2269
  ? { register: () => {}, unregister: () => {} }
@@ -2934,6 +3018,39 @@ export class PureCrypto {
2934
3018
  }
2935
3019
  }
2936
3020
 
3021
+ const StateClientFinalization =
3022
+ typeof FinalizationRegistry === "undefined"
3023
+ ? { register: () => {}, unregister: () => {} }
3024
+ : new FinalizationRegistry((ptr) => wasm.__wbg_stateclient_free(ptr >>> 0, 1));
3025
+
3026
+ export class StateClient {
3027
+ static __wrap(ptr) {
3028
+ ptr = ptr >>> 0;
3029
+ const obj = Object.create(StateClient.prototype);
3030
+ obj.__wbg_ptr = ptr;
3031
+ StateClientFinalization.register(obj, obj.__wbg_ptr, obj);
3032
+ return obj;
3033
+ }
3034
+
3035
+ __destroy_into_raw() {
3036
+ const ptr = this.__wbg_ptr;
3037
+ this.__wbg_ptr = 0;
3038
+ StateClientFinalization.unregister(this);
3039
+ return ptr;
3040
+ }
3041
+
3042
+ free() {
3043
+ const ptr = this.__destroy_into_raw();
3044
+ wasm.__wbg_stateclient_free(ptr, 0);
3045
+ }
3046
+ /**
3047
+ * @param {Repository<Cipher>} store
3048
+ */
3049
+ register_cipher_repository(store) {
3050
+ wasm.stateclient_register_cipher_repository(this.__wbg_ptr, addHeapObject(store));
3051
+ }
3052
+ }
3053
+
2937
3054
  const TotpClientFinalization =
2938
3055
  typeof FinalizationRegistry === "undefined"
2939
3056
  ? { register: () => {}, unregister: () => {} }
@@ -3203,6 +3320,21 @@ export function __wbg_get_b9b93047fe3cf45b(arg0, arg1) {
3203
3320
  return addHeapObject(ret);
3204
3321
  }
3205
3322
 
3323
+ export function __wbg_get_d80c1589d30c292a() {
3324
+ return handleError(function (arg0, arg1, arg2) {
3325
+ let deferred0_0;
3326
+ let deferred0_1;
3327
+ try {
3328
+ deferred0_0 = arg1;
3329
+ deferred0_1 = arg2;
3330
+ const ret = getObject(arg0).get(getStringFromWasm0(arg1, arg2));
3331
+ return addHeapObject(ret);
3332
+ } finally {
3333
+ wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
3334
+ }
3335
+ }, arguments);
3336
+ }
3337
+
3206
3338
  export function __wbg_getwithrefkey_1dc361bd10053bfe(arg0, arg1) {
3207
3339
  const ret = getObject(arg0)[getObject(arg1)];
3208
3340
  return addHeapObject(ret);
@@ -3303,6 +3435,13 @@ export function __wbg_length_e2d2a49132c1b256(arg0) {
3303
3435
  return ret;
3304
3436
  }
3305
3437
 
3438
+ export function __wbg_list_d11c20983c361f70() {
3439
+ return handleError(function (arg0) {
3440
+ const ret = getObject(arg0).list();
3441
+ return addHeapObject(ret);
3442
+ }, arguments);
3443
+ }
3444
+
3306
3445
  export function __wbg_log_cad59bb680daec67(arg0, arg1, arg2, arg3) {
3307
3446
  console.log(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
3308
3447
  }
@@ -3331,7 +3470,7 @@ export function __wbg_new_23a2665fac83c611(arg0, arg1) {
3331
3470
  const a = state0.a;
3332
3471
  state0.a = 0;
3333
3472
  try {
3334
- return __wbg_adapter_260(a, state0.b, arg0, arg1);
3473
+ return __wbg_adapter_274(a, state0.b, arg0, arg1);
3335
3474
  } finally {
3336
3475
  state0.a = a;
3337
3476
  }
@@ -3473,6 +3612,21 @@ export function __wbg_randomFillSync_ac0988aba3254290() {
3473
3612
  }, arguments);
3474
3613
  }
3475
3614
 
3615
+ export function __wbg_remove_212f779b207179b5() {
3616
+ return handleError(function (arg0, arg1, arg2) {
3617
+ let deferred0_0;
3618
+ let deferred0_1;
3619
+ try {
3620
+ deferred0_0 = arg1;
3621
+ deferred0_1 = arg2;
3622
+ const ret = getObject(arg0).remove(getStringFromWasm0(arg1, arg2));
3623
+ return addHeapObject(ret);
3624
+ } finally {
3625
+ wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
3626
+ }
3627
+ }, arguments);
3628
+ }
3629
+
3476
3630
  export function __wbg_require_60cc747a6bc5215a() {
3477
3631
  return handleError(function () {
3478
3632
  const ret = module.require;
@@ -3509,6 +3663,21 @@ export function __wbg_set_65595bdd868b3009(arg0, arg1, arg2) {
3509
3663
  getObject(arg0).set(getObject(arg1), arg2 >>> 0);
3510
3664
  }
3511
3665
 
3666
+ export function __wbg_set_7f4f0ad9ebd5a35e() {
3667
+ return handleError(function (arg0, arg1, arg2, arg3) {
3668
+ let deferred0_0;
3669
+ let deferred0_1;
3670
+ try {
3671
+ deferred0_0 = arg1;
3672
+ deferred0_1 = arg2;
3673
+ const ret = getObject(arg0).set(getStringFromWasm0(arg1, arg2), takeObject(arg3));
3674
+ return addHeapObject(ret);
3675
+ } finally {
3676
+ wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
3677
+ }
3678
+ }, arguments);
3679
+ }
3680
+
3512
3681
  export function __wbg_setbody_5923b78a95eedf29(arg0, arg1) {
3513
3682
  getObject(arg0).body = getObject(arg1);
3514
3683
  }
@@ -3688,18 +3857,18 @@ export function __wbindgen_cb_drop(arg0) {
3688
3857
  return ret;
3689
3858
  }
3690
3859
 
3691
- export function __wbindgen_closure_wrapper2485(arg0, arg1, arg2) {
3692
- const ret = makeMutClosure(arg0, arg1, 722, __wbg_adapter_50);
3860
+ export function __wbindgen_closure_wrapper2827(arg0, arg1, arg2) {
3861
+ const ret = makeMutClosure(arg0, arg1, 904, __wbg_adapter_50);
3693
3862
  return addHeapObject(ret);
3694
3863
  }
3695
3864
 
3696
- export function __wbindgen_closure_wrapper3325(arg0, arg1, arg2) {
3697
- const ret = makeMutClosure(arg0, arg1, 806, __wbg_adapter_53);
3865
+ export function __wbindgen_closure_wrapper3667(arg0, arg1, arg2) {
3866
+ const ret = makeMutClosure(arg0, arg1, 988, __wbg_adapter_53);
3698
3867
  return addHeapObject(ret);
3699
3868
  }
3700
3869
 
3701
- export function __wbindgen_closure_wrapper3738(arg0, arg1, arg2) {
3702
- const ret = makeMutClosure(arg0, arg1, 929, __wbg_adapter_56);
3870
+ export function __wbindgen_closure_wrapper4085(arg0, arg1, arg2) {
3871
+ const ret = makeMutClosure(arg0, arg1, 1111, __wbg_adapter_56);
3703
3872
  return addHeapObject(ret);
3704
3873
  }
3705
3874
 
Binary file
@@ -63,6 +63,8 @@ export const __wbg_set_incomingmessage_topic: (a: number, b: number, c: number)
63
63
  export const __wbg_ipccommunicationbackend_free: (a: number, b: number) => void;
64
64
  export const ipccommunicationbackend_new: (a: number) => number;
65
65
  export const ipccommunicationbackend_receive: (a: number, b: number, c: number) => void;
66
+ export const ipcRegisterDiscoverHandler: (a: number, b: number) => number;
67
+ export const ipcRequestDiscover: (a: number, b: number, c: number) => number;
66
68
  export const __wbg_ipcclient_free: (a: number, b: number) => void;
67
69
  export const __wbg_ipcclientsubscription_free: (a: number, b: number) => void;
68
70
  export const ipcclientsubscription_receive: (a: number, b: number) => number;
@@ -90,6 +92,7 @@ export const incomingmessage_new: (
90
92
  export const incomingmessage_parse_payload_as_json: (a: number) => number;
91
93
  export const isChannelError: (a: number) => number;
92
94
  export const isDeserializeError: (a: number) => number;
95
+ export const isRequestError: (a: number) => number;
93
96
  export const isTypedReceiveError: (a: number) => number;
94
97
  export const isReceiveError: (a: number) => number;
95
98
  export const isSubscribeError: (a: number) => number;
@@ -151,8 +154,10 @@ export const bitwardenclient_version: (a: number, b: number) => void;
151
154
  export const bitwardenclient_throw: (a: number, b: number, c: number, d: number) => void;
152
155
  export const bitwardenclient_http_get: (a: number, b: number, c: number) => number;
153
156
  export const bitwardenclient_crypto: (a: number) => number;
157
+ export const bitwardenclient_platform: (a: number) => number;
154
158
  export const set_log_level: (a: number) => void;
155
159
  export const init_sdk: (a: number) => void;
160
+ export const stateclient_register_cipher_repository: (a: number, b: number) => void;
156
161
  export const __wbg_purecrypto_free: (a: number, b: number) => void;
157
162
  export const purecrypto_symmetric_decrypt: (
158
163
  a: number,
@@ -309,6 +314,9 @@ export const purecrypto_unwrap_encapsulation_key: (
309
314
  export const bitwardenclient_vault: (a: number) => number;
310
315
  export const bitwardenclient_generator: (a: number) => number;
311
316
  export const bitwardenclient_exporters: (a: number) => number;
317
+ export const __wbg_stateclient_free: (a: number, b: number) => void;
318
+ export const __wbg_platformclient_free: (a: number, b: number) => void;
319
+ export const platformclient_state: (a: number) => number;
312
320
  export const __wbindgen_malloc: (a: number, b: number) => number;
313
321
  export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
314
322
  export const __wbindgen_exn_store: (a: number) => void;