@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.
@@ -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;
@@ -393,6 +393,35 @@ function _assertClass(instance, klass) {
393
393
  throw new Error(`expected instance of ${klass.name}`);
394
394
  }
395
395
  }
396
+ /**
397
+ * Registers a DiscoverHandler so that the client can respond to DiscoverRequests.
398
+ * @param {IpcClient} ipc_client
399
+ * @param {DiscoverResponse} response
400
+ * @returns {Promise<void>}
401
+ */
402
+ module.exports.ipcRegisterDiscoverHandler = function (ipc_client, response) {
403
+ _assertClass(ipc_client, IpcClient);
404
+ const ret = wasm.ipcRegisterDiscoverHandler(ipc_client.__wbg_ptr, addHeapObject(response));
405
+ return takeObject(ret);
406
+ };
407
+
408
+ /**
409
+ * Sends a DiscoverRequest to the specified destination and returns the response.
410
+ * @param {IpcClient} ipc_client
411
+ * @param {Endpoint} destination
412
+ * @param {AbortSignal | null} [abort_signal]
413
+ * @returns {Promise<DiscoverResponse>}
414
+ */
415
+ module.exports.ipcRequestDiscover = function (ipc_client, destination, abort_signal) {
416
+ _assertClass(ipc_client, IpcClient);
417
+ const ret = wasm.ipcRequestDiscover(
418
+ ipc_client.__wbg_ptr,
419
+ addHeapObject(destination),
420
+ isLikeNone(abort_signal) ? 0 : addHeapObject(abort_signal),
421
+ );
422
+ return takeObject(ret);
423
+ };
424
+
396
425
  /**
397
426
  * @param {any} error
398
427
  * @returns {boolean}
@@ -419,6 +448,19 @@ module.exports.isDeserializeError = function (error) {
419
448
  }
420
449
  };
421
450
 
451
+ /**
452
+ * @param {any} error
453
+ * @returns {boolean}
454
+ */
455
+ module.exports.isRequestError = function (error) {
456
+ try {
457
+ const ret = wasm.isRequestError(addBorrowedObject(error));
458
+ return ret !== 0;
459
+ } finally {
460
+ heap[stack_pointer++] = undefined;
461
+ }
462
+ };
463
+
422
464
  /**
423
465
  * @param {any} error
424
466
  * @returns {boolean}
@@ -705,7 +747,7 @@ function __wbg_adapter_56(arg0, arg1, arg2) {
705
747
  );
706
748
  }
707
749
 
708
- function __wbg_adapter_260(arg0, arg1, arg2, arg3) {
750
+ function __wbg_adapter_274(arg0, arg1, arg2, arg3) {
709
751
  wasm.wasm_bindgen__convert__closures__invoke2_mut__h8776500d04a3e634(
710
752
  arg0,
711
753
  arg1,
@@ -1036,6 +1078,14 @@ class BitwardenClient {
1036
1078
  const ret = wasm.bitwardenclient_crypto(this.__wbg_ptr);
1037
1079
  return VaultClient.__wrap(ret);
1038
1080
  }
1081
+ /**
1082
+ * Constructs a specific client for platform-specific functionality
1083
+ * @returns {PlatformClient}
1084
+ */
1085
+ platform() {
1086
+ const ret = wasm.bitwardenclient_platform(this.__wbg_ptr);
1087
+ return PlatformClient.__wrap(ret);
1088
+ }
1039
1089
  /**
1040
1090
  * Constructs a specific client for generating passwords and passphrases
1041
1091
  * @returns {GeneratorClient}
@@ -1979,7 +2029,7 @@ class IpcClientSubscription {
1979
2029
  wasm.__wbg_ipcclientsubscription_free(ptr, 0);
1980
2030
  }
1981
2031
  /**
1982
- * @param {any | null} [abort_signal]
2032
+ * @param {AbortSignal | null} [abort_signal]
1983
2033
  * @returns {Promise<IncomingMessage>}
1984
2034
  */
1985
2035
  receive(abort_signal) {
@@ -2186,6 +2236,41 @@ class OutgoingMessage {
2186
2236
  }
2187
2237
  module.exports.OutgoingMessage = OutgoingMessage;
2188
2238
 
2239
+ const PlatformClientFinalization =
2240
+ typeof FinalizationRegistry === "undefined"
2241
+ ? { register: () => {}, unregister: () => {} }
2242
+ : new FinalizationRegistry((ptr) => wasm.__wbg_platformclient_free(ptr >>> 0, 1));
2243
+
2244
+ class PlatformClient {
2245
+ static __wrap(ptr) {
2246
+ ptr = ptr >>> 0;
2247
+ const obj = Object.create(PlatformClient.prototype);
2248
+ obj.__wbg_ptr = ptr;
2249
+ PlatformClientFinalization.register(obj, obj.__wbg_ptr, obj);
2250
+ return obj;
2251
+ }
2252
+
2253
+ __destroy_into_raw() {
2254
+ const ptr = this.__wbg_ptr;
2255
+ this.__wbg_ptr = 0;
2256
+ PlatformClientFinalization.unregister(this);
2257
+ return ptr;
2258
+ }
2259
+
2260
+ free() {
2261
+ const ptr = this.__destroy_into_raw();
2262
+ wasm.__wbg_platformclient_free(ptr, 0);
2263
+ }
2264
+ /**
2265
+ * @returns {StateClient}
2266
+ */
2267
+ state() {
2268
+ const ret = wasm.bitwardenclient_platform(this.__wbg_ptr);
2269
+ return StateClient.__wrap(ret);
2270
+ }
2271
+ }
2272
+ module.exports.PlatformClient = PlatformClient;
2273
+
2189
2274
  const PureCryptoFinalization =
2190
2275
  typeof FinalizationRegistry === "undefined"
2191
2276
  ? { register: () => {}, unregister: () => {} }
@@ -2941,6 +3026,40 @@ class PureCrypto {
2941
3026
  }
2942
3027
  module.exports.PureCrypto = PureCrypto;
2943
3028
 
3029
+ const StateClientFinalization =
3030
+ typeof FinalizationRegistry === "undefined"
3031
+ ? { register: () => {}, unregister: () => {} }
3032
+ : new FinalizationRegistry((ptr) => wasm.__wbg_stateclient_free(ptr >>> 0, 1));
3033
+
3034
+ class StateClient {
3035
+ static __wrap(ptr) {
3036
+ ptr = ptr >>> 0;
3037
+ const obj = Object.create(StateClient.prototype);
3038
+ obj.__wbg_ptr = ptr;
3039
+ StateClientFinalization.register(obj, obj.__wbg_ptr, obj);
3040
+ return obj;
3041
+ }
3042
+
3043
+ __destroy_into_raw() {
3044
+ const ptr = this.__wbg_ptr;
3045
+ this.__wbg_ptr = 0;
3046
+ StateClientFinalization.unregister(this);
3047
+ return ptr;
3048
+ }
3049
+
3050
+ free() {
3051
+ const ptr = this.__destroy_into_raw();
3052
+ wasm.__wbg_stateclient_free(ptr, 0);
3053
+ }
3054
+ /**
3055
+ * @param {Repository<Cipher>} store
3056
+ */
3057
+ register_cipher_repository(store) {
3058
+ wasm.stateclient_register_cipher_repository(this.__wbg_ptr, addHeapObject(store));
3059
+ }
3060
+ }
3061
+ module.exports.StateClient = StateClient;
3062
+
2944
3063
  const TotpClientFinalization =
2945
3064
  typeof FinalizationRegistry === "undefined"
2946
3065
  ? { register: () => {}, unregister: () => {} }
@@ -3212,6 +3331,21 @@ module.exports.__wbg_get_b9b93047fe3cf45b = function (arg0, arg1) {
3212
3331
  return addHeapObject(ret);
3213
3332
  };
3214
3333
 
3334
+ module.exports.__wbg_get_d80c1589d30c292a = function () {
3335
+ return handleError(function (arg0, arg1, arg2) {
3336
+ let deferred0_0;
3337
+ let deferred0_1;
3338
+ try {
3339
+ deferred0_0 = arg1;
3340
+ deferred0_1 = arg2;
3341
+ const ret = getObject(arg0).get(getStringFromWasm0(arg1, arg2));
3342
+ return addHeapObject(ret);
3343
+ } finally {
3344
+ wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
3345
+ }
3346
+ }, arguments);
3347
+ };
3348
+
3215
3349
  module.exports.__wbg_getwithrefkey_1dc361bd10053bfe = function (arg0, arg1) {
3216
3350
  const ret = getObject(arg0)[getObject(arg1)];
3217
3351
  return addHeapObject(ret);
@@ -3312,6 +3446,13 @@ module.exports.__wbg_length_e2d2a49132c1b256 = function (arg0) {
3312
3446
  return ret;
3313
3447
  };
3314
3448
 
3449
+ module.exports.__wbg_list_d11c20983c361f70 = function () {
3450
+ return handleError(function (arg0) {
3451
+ const ret = getObject(arg0).list();
3452
+ return addHeapObject(ret);
3453
+ }, arguments);
3454
+ };
3455
+
3315
3456
  module.exports.__wbg_log_cad59bb680daec67 = function (arg0, arg1, arg2, arg3) {
3316
3457
  console.log(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
3317
3458
  };
@@ -3340,7 +3481,7 @@ module.exports.__wbg_new_23a2665fac83c611 = function (arg0, arg1) {
3340
3481
  const a = state0.a;
3341
3482
  state0.a = 0;
3342
3483
  try {
3343
- return __wbg_adapter_260(a, state0.b, arg0, arg1);
3484
+ return __wbg_adapter_274(a, state0.b, arg0, arg1);
3344
3485
  } finally {
3345
3486
  state0.a = a;
3346
3487
  }
@@ -3482,6 +3623,21 @@ module.exports.__wbg_randomFillSync_ac0988aba3254290 = function () {
3482
3623
  }, arguments);
3483
3624
  };
3484
3625
 
3626
+ module.exports.__wbg_remove_212f779b207179b5 = function () {
3627
+ return handleError(function (arg0, arg1, arg2) {
3628
+ let deferred0_0;
3629
+ let deferred0_1;
3630
+ try {
3631
+ deferred0_0 = arg1;
3632
+ deferred0_1 = arg2;
3633
+ const ret = getObject(arg0).remove(getStringFromWasm0(arg1, arg2));
3634
+ return addHeapObject(ret);
3635
+ } finally {
3636
+ wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
3637
+ }
3638
+ }, arguments);
3639
+ };
3640
+
3485
3641
  module.exports.__wbg_require_60cc747a6bc5215a = function () {
3486
3642
  return handleError(function () {
3487
3643
  const ret = module.require;
@@ -3518,6 +3674,21 @@ module.exports.__wbg_set_65595bdd868b3009 = function (arg0, arg1, arg2) {
3518
3674
  getObject(arg0).set(getObject(arg1), arg2 >>> 0);
3519
3675
  };
3520
3676
 
3677
+ module.exports.__wbg_set_7f4f0ad9ebd5a35e = function () {
3678
+ return handleError(function (arg0, arg1, arg2, arg3) {
3679
+ let deferred0_0;
3680
+ let deferred0_1;
3681
+ try {
3682
+ deferred0_0 = arg1;
3683
+ deferred0_1 = arg2;
3684
+ const ret = getObject(arg0).set(getStringFromWasm0(arg1, arg2), takeObject(arg3));
3685
+ return addHeapObject(ret);
3686
+ } finally {
3687
+ wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
3688
+ }
3689
+ }, arguments);
3690
+ };
3691
+
3521
3692
  module.exports.__wbg_setbody_5923b78a95eedf29 = function (arg0, arg1) {
3522
3693
  getObject(arg0).body = getObject(arg1);
3523
3694
  };
@@ -3697,18 +3868,18 @@ module.exports.__wbindgen_cb_drop = function (arg0) {
3697
3868
  return ret;
3698
3869
  };
3699
3870
 
3700
- module.exports.__wbindgen_closure_wrapper2485 = function (arg0, arg1, arg2) {
3701
- const ret = makeMutClosure(arg0, arg1, 722, __wbg_adapter_50);
3871
+ module.exports.__wbindgen_closure_wrapper2827 = function (arg0, arg1, arg2) {
3872
+ const ret = makeMutClosure(arg0, arg1, 904, __wbg_adapter_50);
3702
3873
  return addHeapObject(ret);
3703
3874
  };
3704
3875
 
3705
- module.exports.__wbindgen_closure_wrapper3325 = function (arg0, arg1, arg2) {
3706
- const ret = makeMutClosure(arg0, arg1, 806, __wbg_adapter_53);
3876
+ module.exports.__wbindgen_closure_wrapper3667 = function (arg0, arg1, arg2) {
3877
+ const ret = makeMutClosure(arg0, arg1, 988, __wbg_adapter_53);
3707
3878
  return addHeapObject(ret);
3708
3879
  };
3709
3880
 
3710
- module.exports.__wbindgen_closure_wrapper3738 = function (arg0, arg1, arg2) {
3711
- const ret = makeMutClosure(arg0, arg1, 929, __wbg_adapter_56);
3881
+ module.exports.__wbindgen_closure_wrapper4085 = function (arg0, arg1, arg2) {
3882
+ const ret = makeMutClosure(arg0, arg1, 1111, __wbg_adapter_56);
3712
3883
  return addHeapObject(ret);
3713
3884
  };
3714
3885
 
@@ -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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bitwarden/sdk-internal",
3
- "version": "0.2.0-main.211",
3
+ "version": "0.2.0-main.213",
4
4
  "license": "GPL-3.0",
5
5
  "files": [
6
6
  "bitwarden_wasm_internal_bg.js",