@bitwarden/cli
Version:
A secure and free password manager for all of your devices.
1,515 lines (1,418 loc) • 2.98 MB
JavaScript
#!/usr/bin/env node
/******/ (() => { // webpackBootstrap
/******/ "use strict";
/******/ var __webpack_modules__ = ({
/***/ 330:
/***/ ((module) => {
module.exports = /*#__PURE__*/JSON.parse('{"name":"@bitwarden/cli","description":"A secure and free password manager for all of your devices.","version":"2025.8.0","keywords":["bitwarden","password","vault","password manager","cli"],"author":"Bitwarden Inc. <hello@bitwarden.com> (https://bitwarden.com)","homepage":"https://bitwarden.com","repository":{"type":"git","url":"https://github.com/bitwarden/clients"},"license":"SEE LICENSE IN LICENSE.txt","scripts":{"clean":"rimraf dist","build:oss":"cross-env NODE_OPTIONS=\\"--max-old-space-size=8192\\" webpack","build:oss:debug":"npm run build:oss && node --inspect ./build/bw.js","build:oss:watch":"webpack --watch","build:oss:prod":"cross-env NODE_ENV=production webpack","build:oss:prod:watch":"cross-env NODE_ENV=production webpack --watch","debug":"node --inspect ./build/bw.js","publish:npm":"npm run build:oss:prod && npm publish --access public","build:bit":"cross-env NODE_OPTIONS=\\"--max-old-space-size=8192\\" webpack -c ../../bitwarden_license/bit-cli/webpack.config.js","build:bit:debug":"npm run build:bit && node --inspect ./build/bw.js","build:bit:watch":"webpack --watch -c ../../bitwarden_license/bit-cli/webpack.config.js","build:bit:prod":"cross-env NODE_ENV=production npm run build:bit","build:bit:prod:watch":"cross-env NODE_ENV=production npm run build:bit:watch","dist:oss:win":"npm run build:oss:prod && npm run clean && npm run package:oss:win","dist:oss:mac":"npm run build:oss:prod && npm run clean && npm run package:oss:mac","dist:oss:mac-arm64":"npm run build:oss:prod && npm run clean && npm run package:oss:mac-arm64","dist:oss:lin":"npm run build:oss:prod && npm run clean && npm run package:oss:lin","dist:oss:lin-arm64":"npm run build:oss:prod && npm run clean && npm run package:oss:lin-arm64","dist:bit:win":"npm run build:bit:prod && npm run clean && npm run package:bit:win","dist:bit:mac":"npm run build:bit:prod && npm run clean && npm run package:bit:mac","dist:bit:mac-arm64":"npm run build:bit:prod && npm run clean && npm run package:bit:mac-arm64","dist:bit:lin":"npm run build:bit:prod && npm run clean && npm run package:bit:lin","dist:bit:lin-arm64":"npm run build:bit:prod && npm run clean && npm run package:bit:lin-arm64","package:oss:win":"pkg . --targets win-x64 --output ./dist/oss/windows/bw.exe","package:oss:mac":"pkg . --targets macos-x64 --output ./dist/oss/macos/bw","package:oss:mac-arm64":"pkg . --targets macos-arm64 --output ./dist/oss/macos-arm64/bw","package:oss:lin":"pkg . --targets linux-x64 --output ./dist/oss/linux/bw","package:oss:lin-arm64":"pkg . --targets linux-arm64 --output ./dist/oss/linux-arm64/bw","package:bit:win":"pkg . --targets win-x64 --output ./dist/bit/windows/bw.exe","package:bit:mac":"pkg . --targets macos-x64 --output ./dist/bit/macos/bw","package:bit:mac-arm64":"pkg . --targets macos-arm64 --output ./dist/bit/macos-arm64/bw","package:bit:lin":"pkg . --targets linux-x64 --output ./dist/bit/linux/bw","package:bit:lin-arm64":"pkg . --targets linux-arm64 --output ./dist/bit/linux-arm64/bw","test":"jest","test:watch":"jest --watch","test:watch:all":"jest --watchAll"},"bin":{"bw":"build/bw.js"},"pkg":{"assets":["./build/**/*"]},"dependencies":{"@koa/multer":"4.0.0","@koa/router":"13.1.0","big-integer":"1.6.52","browser-hrtime":"1.1.8","chalk":"4.1.2","commander":"11.1.0","core-js":"3.44.0","form-data":"4.0.4","https-proxy-agent":"7.0.6","inquirer":"8.2.6","jsdom":"26.1.0","jszip":"3.10.1","koa":"2.16.1","koa-bodyparser":"4.4.1","koa-json":"2.0.2","lowdb":"1.0.0","lunr":"2.3.9","multer":"1.4.5-lts.2","node-fetch":"2.6.12","node-forge":"1.3.1","open":"10.1.2","papaparse":"5.5.3","proper-lockfile":"4.1.2","rxjs":"7.8.1","semver":"7.7.2","tldts":"7.0.1","zxcvbn":"4.4.2"}}');
/***/ }),
/***/ 414:
/***/ ((module, __webpack_exports__, __webpack_require__) => {
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ $Pc: () => (/* binding */ __wbg_new_8a6f238a6ece86ea),
/* harmony export */ $Uh: () => (/* binding */ __wbg_debug_e17b51583ca6a632),
/* harmony export */ $Xh: () => (/* binding */ __wbg_get_77f31d87a1df92ea),
/* harmony export */ BFX: () => (/* binding */ __wbg_setmode_5dc300b865044b65),
/* harmony export */ BGI: () => (/* binding */ __wbindgen_jsval_eq),
/* harmony export */ BZb: () => (/* binding */ __wbindgen_object_clone_ref),
/* harmony export */ CB9: () => (/* binding */ __wbg_crypto_574e78ad8b13b65f),
/* harmony export */ CF8: () => (/* binding */ __wbg_signal_aaf9ad74119f20a4),
/* harmony export */ DMD: () => (/* binding */ __wbindgen_bigint_get_as_i64),
/* harmony export */ Dn4: () => (/* binding */ __wbg_next_6574e1a8a62d1055),
/* harmony export */ FHK: () => (/* binding */ __wbg_buffer_609cc3eee51ed158),
/* harmony export */ FPO: () => (/* binding */ __wbg_getwithrefkey_1dc361bd10053bfe),
/* harmony export */ Fxh: () => (/* binding */ __wbg_msCrypto_a61aeb35a24c1329),
/* harmony export */ GQG: () => (/* binding */ __wbg_then_44b73946d2fb3e7d),
/* harmony export */ Geh: () => (/* binding */ init_sdk),
/* harmony export */ GuA: () => (/* binding */ __wbindgen_is_string),
/* harmony export */ HBq: () => (/* binding */ __wbg_set_65595bdd868b3009),
/* harmony export */ HSm: () => (/* binding */ __wbg_has_a5ea9117f258a0ec),
/* harmony export */ HtP: () => (/* binding */ __wbg_newwithlength_a381634e90c276d4),
/* harmony export */ HvI: () => (/* binding */ __wbg_ipcclientsubscription_new),
/* harmony export */ Hzn: () => (/* binding */ __wbg_instanceof_Response_f2cc20d9f7dfd644),
/* harmony export */ IEs: () => (/* binding */ PureCrypto),
/* harmony export */ IZ7: () => (/* binding */ __wbg_randomFillSync_ac0988aba3254290),
/* harmony export */ KhK: () => (/* binding */ __wbg_parse_def2e24ef1252aff),
/* harmony export */ KwY: () => (/* binding */ __wbg_versions_c01dfd4722a88165),
/* harmony export */ L1P: () => (/* binding */ __wbg_setvariant_d1d41b778dfe9c17),
/* harmony export */ L3p: () => (/* binding */ __wbg_instanceof_Map_f3469ce2244d2430),
/* harmony export */ LCp: () => (/* binding */ __wbindgen_cb_drop),
/* harmony export */ LMq: () => (/* binding */ __wbg_value_cd1ffa7b1ab794f1),
/* harmony export */ M2: () => (/* binding */ __wbg_new_78feb108b6472713),
/* harmony export */ Moj: () => (/* binding */ __wbg_headers_9cb51cfd2ac780a4),
/* harmony export */ NJs: () => (/* binding */ __wbg_set_3f1d0b984ed272ed),
/* harmony export */ NhE: () => (/* binding */ __wbindgen_boolean_get),
/* harmony export */ Nhd: () => (/* binding */ __wbg_setbody_5923b78a95eedf29),
/* harmony export */ Oyk: () => (/* binding */ __wbg_String_8f0eb39a4a4c2f66),
/* harmony export */ PPV: () => (/* binding */ __wbg_getTime_46267b1c24877e30),
/* harmony export */ PRY: () => (/* binding */ __wbindgen_is_function),
/* harmony export */ PUO: () => (/* binding */ FieldType),
/* harmony export */ Py0: () => (/* binding */ __wbindgen_memory),
/* harmony export */ QRK: () => (/* binding */ __wbindgen_number_new),
/* harmony export */ Qg3: () => (/* binding */ __wbindgen_bigint_from_u64),
/* harmony export */ Qnr: () => (/* binding */ __wbindgen_throw),
/* harmony export */ RG9: () => (/* binding */ __wbg_new_e25e5aab09ff45db),
/* harmony export */ RKd: () => (/* binding */ __wbg_info_033d8b8a0838f1d3),
/* harmony export */ RKz: () => (/* binding */ __wbg_get_b9b93047fe3cf45b),
/* harmony export */ RR8: () => (/* binding */ __wbg_new_018dcc2d6c8c2f6a),
/* harmony export */ RjG: () => (/* binding */ __wbindgen_error_new),
/* harmony export */ Ry: () => (/* binding */ __wbg_length_e2d2a49132c1b256),
/* harmony export */ S9O: () => (/* binding */ __wbindgen_array_push),
/* harmony export */ SJf: () => (/* binding */ __wbg_instanceof_Uint8Array_17156bcf118086a9),
/* harmony export */ St$: () => (/* binding */ __wbg_incomingmessage_new),
/* harmony export */ TOc: () => (/* binding */ __wbg_subarray_aa9065fa9dc5df96),
/* harmony export */ Tbm: () => (/* binding */ __wbg_append_8c7dd8d641a5f01b),
/* harmony export */ Tp3: () => (/* binding */ __wbg_url_ae10c34ca209681d),
/* harmony export */ Tt0: () => (/* binding */ __wbg_send_9b8fc6bb517867dd),
/* harmony export */ U8c: () => (/* binding */ __wbindgen_jsval_loose_eq),
/* harmony export */ VrZ: () => (/* binding */ __wbg_newnoargs_105ed471475aaf50),
/* harmony export */ WYM: () => (/* binding */ __wbg_error_7534b8e9a36f1ab4),
/* harmony export */ WqA: () => (/* binding */ __wbg_append_b2d1fc16de2a0e81),
/* harmony export */ XKx: () => (/* binding */ __wbg_addEventListener_dc3da056b615f634),
/* harmony export */ Xb8: () => (/* binding */ __wbg_done_769e5ede4b31c67b),
/* harmony export */ Y6F: () => (/* binding */ __wbg_stringify_f7ed6987935b4a24),
/* harmony export */ Yb6: () => (/* binding */ __wbg_isSafeInteger_343e2beeeece1bb0),
/* harmony export */ YkQ: () => (/* binding */ __wbindgen_is_bigint),
/* harmony export */ Z87: () => (/* binding */ __wbg_error_80de38b3f7cc3c3c),
/* harmony export */ ZD9: () => (/* binding */ __wbg_warn_aaf1f4664a035bd6),
/* harmony export */ _hX: () => (/* binding */ __wbg_setmethod_3c5280fe5d890842),
/* harmony export */ _mt: () => (/* binding */ __wbg_queueMicrotask_97d92b4fcc8a61c5),
/* harmony export */ a4S: () => (/* binding */ __wbg_settype_39ed370d3edd403c),
/* harmony export */ aIY: () => (/* binding */ __wbg_new_5e0be73521bc8c17),
/* harmony export */ aht: () => (/* binding */ __wbg_clearTimeout_b1115618e821c3b2),
/* harmony export */ bHf: () => (/* binding */ __wbg_remove_232c0f25737701a7),
/* harmony export */ bkt: () => (/* binding */ __wbindgen_object_drop_ref),
/* harmony export */ bz7: () => (/* binding */ __wbg_setTimeout_ca12ead8b48245e2),
/* harmony export */ c6u: () => (/* binding */ __wbg_new_23a2665fac83c611),
/* harmony export */ cVx: () => (/* binding */ __wbg_append_299d5d48292c0495),
/* harmony export */ ce0: () => (/* binding */ __wbindgen_bigint_from_i64),
/* harmony export */ d_N: () => (/* binding */ __wbg_append_b44785ebeb668479),
/* harmony export */ dzD: () => (/* binding */ __wbg_get_67b2ba62fc30de12),
/* harmony export */ e4L: () => (/* binding */ __wbindgen_closure_wrapper3208),
/* harmony export */ eIr: () => (/* binding */ __wbg_length_a446193dc22c12f8),
/* harmony export */ eW0: () => (/* binding */ __wbg_iterator_9a24c88df860dc65),
/* harmony export */ fb$: () => (/* binding */ __wbg_static_accessor_SELF_37c5d418e4bf5819),
/* harmony export */ gGA: () => (/* binding */ __wbg_instanceof_ArrayBuffer_e14585432e3737fc),
/* harmony export */ gHg: () => (/* binding */ __wbg_entries_3265d4158b33e5dc),
/* harmony export */ gMQ: () => (/* binding */ __wbg_abort_775ef1d17fc65868),
/* harmony export */ gRe: () => (/* binding */ __wbg_fetch_509096533071c657),
/* harmony export */ gae: () => (/* binding */ BitwardenClient),
/* harmony export */ gtG: () => (/* binding */ __wbg_text_7805bea50de2af49),
/* harmony export */ hI8: () => (/* binding */ __wbg_newwithbyteoffsetandlength_d97e637ebe145a9a),
/* harmony export */ heb: () => (/* binding */ __wbg_newwithstrandinit_06c535e0a867c635),
/* harmony export */ iAh: () => (/* binding */ __wbg_set_8fc6bf8a5b1071d1),
/* harmony export */ ii7: () => (/* binding */ __wbg_static_accessor_GLOBAL_88a902d13a557d07),
/* harmony export */ jBc: () => (/* binding */ __wbg_get_ecaf289a8aec8475),
/* harmony export */ jph: () => (/* binding */ __wbg_list_c9d3abba8d8c88ea),
/* harmony export */ k2R: () => (/* binding */ __wbg_queueMicrotask_d3219def82552485),
/* harmony export */ kK3: () => (/* binding */ __wbg_status_f6360336ca686bf0),
/* harmony export */ l0x: () => (/* binding */ __wbg_setsignal_75b21ef3a81de905),
/* harmony export */ lIU: () => (/* binding */ __wbg_set_wasm),
/* harmony export */ lU$: () => (/* binding */ __wbg_node_905d3e251edff8a2),
/* harmony export */ mEh: () => (/* binding */ __wbg_require_60cc747a6bc5215a),
/* harmony export */ mMK: () => (/* binding */ __wbindgen_array_new),
/* harmony export */ n8S: () => (/* binding */ __wbg_abort_410ec47a64ac6117),
/* harmony export */ nbv: () => (/* binding */ __wbg_set_ad5361a73c33596d),
/* harmony export */ p0V: () => (/* binding */ __wbg_list_53e12fd77d647b74),
/* harmony export */ p8e: () => (/* binding */ __wbg_set_37837023f3d740e8),
/* harmony export */ qNE: () => (/* binding */ __wbindgen_string_get),
/* harmony export */ qe7: () => (/* binding */ __wbg_newwithu8arraysequenceandoptions_068570c487f69127),
/* harmony export */ qmw: () => (/* binding */ __wbindgen_as_number),
/* harmony export */ qvD: () => (/* binding */ __wbindgen_is_object),
/* harmony export */ rQI: () => (/* binding */ __wbg_log_cad59bb680daec67),
/* harmony export */ rgk: () => (/* binding */ __wbindgen_closure_wrapper5944),
/* harmony export */ rk2: () => (/* binding */ __wbg_setheaders_834c0bdb6a8949ad),
/* harmony export */ rl: () => (/* binding */ __wbindgen_debug_string),
/* harmony export */ s5K: () => (/* binding */ __wbg_getRandomValues_38097e921c2494c3),
/* harmony export */ sWe: () => (/* binding */ __wbindgen_number_get),
/* harmony export */ sgi: () => (/* binding */ __wbg_remove_c4f26348d33b1846),
/* harmony export */ tTc: () => (/* binding */ __wbg_setname_c0e2d6f348c746f4),
/* harmony export */ tZf: () => (/* binding */ __wbg_push_737cfc8c1432c2c6),
/* harmony export */ tff: () => (/* binding */ __wbg_collectionviewnodeitem_new),
/* harmony export */ typ: () => (/* binding */ __wbg_getRandomValues_b8f5dbd5f3995a9e),
/* harmony export */ uod: () => (/* binding */ __wbg_isArray_a1eab7e0d067391b),
/* harmony export */ uw1: () => (/* binding */ __wbg_setcredentials_c3a22f1cd105a2c6),
/* harmony export */ vUM: () => (/* binding */ __wbindgen_is_undefined),
/* harmony export */ vUh: () => (/* binding */ __wbg_new_f24b6d53abe5bc82),
/* harmony export */ vVD: () => (/* binding */ __wbg_new_a12002a7f91c75be),
/* harmony export */ va5: () => (/* binding */ __wbg_new_405e22f390576ce2),
/* harmony export */ w6e: () => (/* binding */ __wbg_static_accessor_GLOBAL_THIS_56578be7e9f832b0),
/* harmony export */ w9h: () => (/* binding */ __wbg_call_7cccdd69e0791ae2),
/* harmony export */ wHY: () => (/* binding */ __wbg_call_672a4d21634d4a24),
/* harmony export */ wJz: () => (/* binding */ __wbg_resolve_4851785c9c5f573d),
/* harmony export */ wSb: () => (/* binding */ __wbg_set_b40fb1eb97baad98),
/* harmony export */ wd3: () => (/* binding */ __wbg_new_c68d7209be747379),
/* harmony export */ x$X: () => (/* binding */ __wbg_stack_0ed75d68575b0f3c),
/* harmony export */ x0C: () => (/* binding */ __wbg_static_accessor_WINDOW_5de37043a91a9c40),
/* harmony export */ x2q: () => (/* binding */ __wbg_process_dc0fbacc7c1c06f7),
/* harmony export */ xV_: () => (/* binding */ __wbg_then_48b406749878a531),
/* harmony export */ yU8: () => (/* binding */ __wbg_new0_f788a2397c7ca929),
/* harmony export */ ycJ: () => (/* binding */ __wbindgen_string_new),
/* harmony export */ you: () => (/* binding */ __wbg_fetch_3afbdcc7ddbf16fe),
/* harmony export */ yqB: () => (/* binding */ __wbg_next_25feadfc0913fea9),
/* harmony export */ yxo: () => (/* binding */ __wbindgen_closure_wrapper5583),
/* harmony export */ z09: () => (/* binding */ __wbg_new_9fd39a253424609a),
/* harmony export */ zEy: () => (/* binding */ __wbindgen_in),
/* harmony export */ znE: () => (/* binding */ __wbg_getaccesstoken_b09e619d7eba8d22)
/* harmony export */ });
/* unused harmony exports set_log_level, generate_ssh_key, import_ssh_key, isTestError, isCollectionDecryptError, isDeriveKeyConnectorError, isEnrollAdminPasswordResetError, isCryptoClientError, isStatefulCryptoError, isEncryptionSettingsError, isCryptoError, isExportError, isUsernameError, isPasswordError, isPassphraseError, ipcRegisterDiscoverHandler, ipcRequestDiscover, isChannelError, isDeserializeError, isRequestError, isTypedReceiveError, isReceiveError, isSubscribeError, isSshKeyExportError, isSshKeyImportError, isKeyGenerationError, isCallError, isDecryptError, isEncryptError, isTotpError, isGetFolderError, isEditFolderError, isCreateFolderError, isCipherError, isDecryptFileError, isEncryptFileError, CardLinkedIdType, CipherRepromptType, CipherType, IdentityLinkedIdType, LogLevel, LoginLinkedIdType, SecureNoteType, UriMatchType, AttachmentsClient, AuthClient, CiphersClient, CollectionViewNodeItem, CollectionViewTree, CollectionsClient, CryptoClient, ExporterClient, FoldersClient, GeneratorClient, IncomingMessage, IpcClient, IpcClientSubscription, IpcCommunicationBackend, OutgoingMessage, PlatformClient, SendAccessClient, StateClient, TotpClient, VaultClient */
/* module decorator */ module = __webpack_require__.hmd(module);
let wasm;
function __wbg_set_wasm(val) {
wasm = val;
}
const heap = new Array(128).fill(undefined);
heap.push(undefined, null, true, false);
function getObject(idx) {
return heap[idx];
}
let WASM_VECTOR_LEN = 0;
let cachedUint8ArrayMemory0 = null;
function getUint8ArrayMemory0() {
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
}
return cachedUint8ArrayMemory0;
}
const lTextEncoder =
typeof TextEncoder === "undefined" ? (0, module.require)("util").TextEncoder : TextEncoder;
let cachedTextEncoder = new lTextEncoder("utf-8");
const encodeString =
typeof cachedTextEncoder.encodeInto === "function"
? function (arg, view) {
return cachedTextEncoder.encodeInto(arg, view);
}
: function (arg, view) {
const buf = cachedTextEncoder.encode(arg);
view.set(buf);
return {
read: arg.length,
written: buf.length,
};
};
function passStringToWasm0(arg, malloc, realloc) {
if (realloc === undefined) {
const buf = cachedTextEncoder.encode(arg);
const ptr = malloc(buf.length, 1) >>> 0;
getUint8ArrayMemory0()
.subarray(ptr, ptr + buf.length)
.set(buf);
WASM_VECTOR_LEN = buf.length;
return ptr;
}
let len = arg.length;
let ptr = malloc(len, 1) >>> 0;
const mem = getUint8ArrayMemory0();
let offset = 0;
for (; offset < len; offset++) {
const code = arg.charCodeAt(offset);
if (code > 0x7f) break;
mem[ptr + offset] = code;
}
if (offset !== len) {
if (offset !== 0) {
arg = arg.slice(offset);
}
ptr = realloc(ptr, len, (len = offset + arg.length * 3), 1) >>> 0;
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
const ret = encodeString(arg, view);
offset += ret.written;
ptr = realloc(ptr, len, offset, 1) >>> 0;
}
WASM_VECTOR_LEN = offset;
return ptr;
}
let cachedDataViewMemory0 = null;
function getDataViewMemory0() {
if (
cachedDataViewMemory0 === null ||
cachedDataViewMemory0.buffer.detached === true ||
(cachedDataViewMemory0.buffer.detached === undefined &&
cachedDataViewMemory0.buffer !== wasm.memory.buffer)
) {
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
}
return cachedDataViewMemory0;
}
const lTextDecoder =
typeof TextDecoder === "undefined" ? (0, module.require)("util").TextDecoder : TextDecoder;
let cachedTextDecoder = new lTextDecoder("utf-8", { ignoreBOM: true, fatal: true });
cachedTextDecoder.decode();
function getStringFromWasm0(ptr, len) {
ptr = ptr >>> 0;
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
}
let heap_next = heap.length;
function addHeapObject(obj) {
if (heap_next === heap.length) heap.push(heap.length + 1);
const idx = heap_next;
heap_next = heap[idx];
heap[idx] = obj;
return idx;
}
function handleError(f, args) {
try {
return f.apply(this, args);
} catch (e) {
wasm.__wbindgen_exn_store(addHeapObject(e));
}
}
function dropObject(idx) {
if (idx < 132) return;
heap[idx] = heap_next;
heap_next = idx;
}
function takeObject(idx) {
const ret = getObject(idx);
dropObject(idx);
return ret;
}
function getArrayU8FromWasm0(ptr, len) {
ptr = ptr >>> 0;
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
}
function isLikeNone(x) {
return x === undefined || x === null;
}
const CLOSURE_DTORS =
typeof FinalizationRegistry === "undefined"
? { register: () => {}, unregister: () => {} }
: new FinalizationRegistry((state) => {
wasm.__wbindgen_export_4.get(state.dtor)(state.a, state.b);
});
function makeMutClosure(arg0, arg1, dtor, f) {
const state = { a: arg0, b: arg1, cnt: 1, dtor };
const real = (...args) => {
// First up with a closure we increment the internal reference
// count. This ensures that the Rust closure environment won't
// be deallocated while we're invoking it.
state.cnt++;
const a = state.a;
state.a = 0;
try {
return f(a, state.b, ...args);
} finally {
if (--state.cnt === 0) {
wasm.__wbindgen_export_4.get(state.dtor)(a, state.b);
CLOSURE_DTORS.unregister(state);
} else {
state.a = a;
}
}
};
real.original = state;
CLOSURE_DTORS.register(real, state, state);
return real;
}
function debugString(val) {
// primitive types
const type = typeof val;
if (type == "number" || type == "boolean" || val == null) {
return `${val}`;
}
if (type == "string") {
return `"${val}"`;
}
if (type == "symbol") {
const description = val.description;
if (description == null) {
return "Symbol";
} else {
return `Symbol(${description})`;
}
}
if (type == "function") {
const name = val.name;
if (typeof name == "string" && name.length > 0) {
return `Function(${name})`;
} else {
return "Function";
}
}
// objects
if (Array.isArray(val)) {
const length = val.length;
let debug = "[";
if (length > 0) {
debug += debugString(val[0]);
}
for (let i = 1; i < length; i++) {
debug += ", " + debugString(val[i]);
}
debug += "]";
return debug;
}
// Test for built-in
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
let className;
if (builtInMatches && builtInMatches.length > 1) {
className = builtInMatches[1];
} else {
// Failed to match the standard '[object ClassName]'
return toString.call(val);
}
if (className == "Object") {
// we're a user defined class or Object
// JSON.stringify avoids problems with cycles, and is generally much
// easier than looping through ownProperties of `val`.
try {
return "Object(" + JSON.stringify(val) + ")";
} catch (_) {
return "Object";
}
}
// errors
if (val instanceof Error) {
return `${val.name}: ${val.message}\n${val.stack}`;
}
// TODO we could test for more things here, like `Set`s and `Map`s.
return className;
}
/**
* @param {LogLevel} level
*/
function set_log_level(level) {
wasm.set_log_level(level);
}
/**
* @param {LogLevel | null} [log_level]
*/
function init_sdk(log_level) {
wasm.init_sdk(isLikeNone(log_level) ? 5 : log_level);
}
function passArray8ToWasm0(arg, malloc) {
const ptr = malloc(arg.length * 1, 1) >>> 0;
getUint8ArrayMemory0().set(arg, ptr / 1);
WASM_VECTOR_LEN = arg.length;
return ptr;
}
/**
* Generate a new SSH key pair
*
* # Arguments
* - `key_algorithm` - The algorithm to use for the key pair
*
* # Returns
* - `Ok(SshKey)` if the key was successfully generated
* - `Err(KeyGenerationError)` if the key could not be generated
* @param {KeyAlgorithm} key_algorithm
* @returns {SshKeyView}
*/
function generate_ssh_key(key_algorithm) {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
wasm.generate_ssh_key(retptr, addHeapObject(key_algorithm));
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
if (r2) {
throw takeObject(r1);
}
return takeObject(r0);
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
}
}
/**
* Convert a PCKS8 or OpenSSH encrypted or unencrypted private key
* to an OpenSSH private key with public key and fingerprint
*
* # Arguments
* - `imported_key` - The private key to convert
* - `password` - The password to use for decrypting the key
*
* # Returns
* - `Ok(SshKey)` if the key was successfully coneverted
* - `Err(PasswordRequired)` if the key is encrypted and no password was provided
* - `Err(WrongPassword)` if the password provided is incorrect
* - `Err(ParsingError)` if the key could not be parsed
* - `Err(UnsupportedKeyType)` if the key type is not supported
* @param {string} imported_key
* @param {string | null} [password]
* @returns {SshKeyView}
*/
function import_ssh_key(imported_key, password) {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
const ptr0 = passStringToWasm0(imported_key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
const len0 = WASM_VECTOR_LEN;
var ptr1 = isLikeNone(password)
? 0
: passStringToWasm0(password, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
var len1 = WASM_VECTOR_LEN;
wasm.import_ssh_key(retptr, ptr0, len0, ptr1, len1);
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
if (r2) {
throw takeObject(r1);
}
return takeObject(r0);
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
}
}
let stack_pointer = 128;
function addBorrowedObject(obj) {
if (stack_pointer == 1) throw new Error("out of js stack");
heap[--stack_pointer] = obj;
return stack_pointer;
}
/**
* @param {any} error
* @returns {boolean}
*/
function isTestError(error) {
try {
const ret = wasm.isTestError(addBorrowedObject(error));
return ret !== 0;
} finally {
heap[stack_pointer++] = undefined;
}
}
/**
* @param {any} error
* @returns {boolean}
*/
function isCollectionDecryptError(error) {
try {
const ret = wasm.isCollectionDecryptError(addBorrowedObject(error));
return ret !== 0;
} finally {
heap[stack_pointer++] = undefined;
}
}
/**
* @param {any} error
* @returns {boolean}
*/
function isDeriveKeyConnectorError(error) {
try {
const ret = wasm.isDeriveKeyConnectorError(addBorrowedObject(error));
return ret !== 0;
} finally {
heap[stack_pointer++] = undefined;
}
}
/**
* @param {any} error
* @returns {boolean}
*/
function isEnrollAdminPasswordResetError(error) {
try {
const ret = wasm.isEnrollAdminPasswordResetError(addBorrowedObject(error));
return ret !== 0;
} finally {
heap[stack_pointer++] = undefined;
}
}
/**
* @param {any} error
* @returns {boolean}
*/
function isCryptoClientError(error) {
try {
const ret = wasm.isCryptoClientError(addBorrowedObject(error));
return ret !== 0;
} finally {
heap[stack_pointer++] = undefined;
}
}
/**
* @param {any} error
* @returns {boolean}
*/
function isStatefulCryptoError(error) {
try {
const ret = wasm.isStatefulCryptoError(addBorrowedObject(error));
return ret !== 0;
} finally {
heap[stack_pointer++] = undefined;
}
}
/**
* @param {any} error
* @returns {boolean}
*/
function isEncryptionSettingsError(error) {
try {
const ret = wasm.isEncryptionSettingsError(addBorrowedObject(error));
return ret !== 0;
} finally {
heap[stack_pointer++] = undefined;
}
}
/**
* @param {any} error
* @returns {boolean}
*/
function isCryptoError(error) {
try {
const ret = wasm.isCryptoError(addBorrowedObject(error));
return ret !== 0;
} finally {
heap[stack_pointer++] = undefined;
}
}
function passArrayJsValueToWasm0(array, malloc) {
const ptr = malloc(array.length * 4, 4) >>> 0;
const mem = getDataViewMemory0();
for (let i = 0; i < array.length; i++) {
mem.setUint32(ptr + 4 * i, addHeapObject(array[i]), true);
}
WASM_VECTOR_LEN = array.length;
return ptr;
}
function getArrayJsValueFromWasm0(ptr, len) {
ptr = ptr >>> 0;
const mem = getDataViewMemory0();
const result = [];
for (let i = ptr; i < ptr + 4 * len; i += 4) {
result.push(takeObject(mem.getUint32(i, true)));
}
return result;
}
/**
* @param {any} error
* @returns {boolean}
*/
function isExportError(error) {
try {
const ret = wasm.isExportError(addBorrowedObject(error));
return ret !== 0;
} finally {
heap[stack_pointer++] = undefined;
}
}
/**
* @param {any} error
* @returns {boolean}
*/
function isUsernameError(error) {
try {
const ret = wasm.isUsernameError(addBorrowedObject(error));
return ret !== 0;
} finally {
heap[stack_pointer++] = undefined;
}
}
/**
* @param {any} error
* @returns {boolean}
*/
function isPasswordError(error) {
try {
const ret = wasm.isPasswordError(addBorrowedObject(error));
return ret !== 0;
} finally {
heap[stack_pointer++] = undefined;
}
}
/**
* @param {any} error
* @returns {boolean}
*/
function isPassphraseError(error) {
try {
const ret = wasm.isPassphraseError(addBorrowedObject(error));
return ret !== 0;
} finally {
heap[stack_pointer++] = undefined;
}
}
function _assertClass(instance, klass) {
if (!(instance instanceof klass)) {
throw new Error(`expected instance of ${klass.name}`);
}
}
/**
* Registers a DiscoverHandler so that the client can respond to DiscoverRequests.
* @param {IpcClient} ipc_client
* @param {DiscoverResponse} response
* @returns {Promise<void>}
*/
function ipcRegisterDiscoverHandler(ipc_client, response) {
_assertClass(ipc_client, IpcClient);
const ret = wasm.ipcRegisterDiscoverHandler(ipc_client.__wbg_ptr, addHeapObject(response));
return takeObject(ret);
}
/**
* Sends a DiscoverRequest to the specified destination and returns the response.
* @param {IpcClient} ipc_client
* @param {Endpoint} destination
* @param {AbortSignal | null} [abort_signal]
* @returns {Promise<DiscoverResponse>}
*/
function ipcRequestDiscover(ipc_client, destination, abort_signal) {
_assertClass(ipc_client, IpcClient);
const ret = wasm.ipcRequestDiscover(
ipc_client.__wbg_ptr,
addHeapObject(destination),
isLikeNone(abort_signal) ? 0 : addHeapObject(abort_signal),
);
return takeObject(ret);
}
/**
* @param {any} error
* @returns {boolean}
*/
function isChannelError(error) {
try {
const ret = wasm.isChannelError(addBorrowedObject(error));
return ret !== 0;
} finally {
heap[stack_pointer++] = undefined;
}
}
/**
* @param {any} error
* @returns {boolean}
*/
function isDeserializeError(error) {
try {
const ret = wasm.isDeserializeError(addBorrowedObject(error));
return ret !== 0;
} finally {
heap[stack_pointer++] = undefined;
}
}
/**
* @param {any} error
* @returns {boolean}
*/
function isRequestError(error) {
try {
const ret = wasm.isRequestError(addBorrowedObject(error));
return ret !== 0;
} finally {
heap[stack_pointer++] = undefined;
}
}
/**
* @param {any} error
* @returns {boolean}
*/
function isTypedReceiveError(error) {
try {
const ret = wasm.isTypedReceiveError(addBorrowedObject(error));
return ret !== 0;
} finally {
heap[stack_pointer++] = undefined;
}
}
/**
* @param {any} error
* @returns {boolean}
*/
function isReceiveError(error) {
try {
const ret = wasm.isReceiveError(addBorrowedObject(error));
return ret !== 0;
} finally {
heap[stack_pointer++] = undefined;
}
}
/**
* @param {any} error
* @returns {boolean}
*/
function isSubscribeError(error) {
try {
const ret = wasm.isSubscribeError(addBorrowedObject(error));
return ret !== 0;
} finally {
heap[stack_pointer++] = undefined;
}
}
/**
* @param {any} error
* @returns {boolean}
*/
function isSshKeyExportError(error) {
try {
const ret = wasm.isSshKeyExportError(addBorrowedObject(error));
return ret !== 0;
} finally {
heap[stack_pointer++] = undefined;
}
}
/**
* @param {any} error
* @returns {boolean}
*/
function isSshKeyImportError(error) {
try {
const ret = wasm.isSshKeyImportError(addBorrowedObject(error));
return ret !== 0;
} finally {
heap[stack_pointer++] = undefined;
}
}
/**
* @param {any} error
* @returns {boolean}
*/
function isKeyGenerationError(error) {
try {
const ret = wasm.isKeyGenerationError(addBorrowedObject(error));
return ret !== 0;
} finally {
heap[stack_pointer++] = undefined;
}
}
/**
* @param {any} error
* @returns {boolean}
*/
function isCallError(error) {
try {
const ret = wasm.isCallError(addBorrowedObject(error));
return ret !== 0;
} finally {
heap[stack_pointer++] = undefined;
}
}
/**
* @param {any} error
* @returns {boolean}
*/
function isDecryptError(error) {
try {
const ret = wasm.isDecryptError(addBorrowedObject(error));
return ret !== 0;
} finally {
heap[stack_pointer++] = undefined;
}
}
/**
* @param {any} error
* @returns {boolean}
*/
function isEncryptError(error) {
try {
const ret = wasm.isEncryptError(addBorrowedObject(error));
return ret !== 0;
} finally {
heap[stack_pointer++] = undefined;
}
}
/**
* @param {any} error
* @returns {boolean}
*/
function isTotpError(error) {
try {
const ret = wasm.isTotpError(addBorrowedObject(error));
return ret !== 0;
} finally {
heap[stack_pointer++] = undefined;
}
}
/**
* @param {any} error
* @returns {boolean}
*/
function isGetFolderError(error) {
try {
const ret = wasm.isGetFolderError(addBorrowedObject(error));
return ret !== 0;
} finally {
heap[stack_pointer++] = undefined;
}
}
/**
* @param {any} error
* @returns {boolean}
*/
function isEditFolderError(error) {
try {
const ret = wasm.isEditFolderError(addBorrowedObject(error));
return ret !== 0;
} finally {
heap[stack_pointer++] = undefined;
}
}
/**
* @param {any} error
* @returns {boolean}
*/
function isCreateFolderError(error) {
try {
const ret = wasm.isCreateFolderError(addBorrowedObject(error));
return ret !== 0;
} finally {
heap[stack_pointer++] = undefined;
}
}
/**
* @param {any} error
* @returns {boolean}
*/
function isCipherError(error) {
try {
const ret = wasm.isCipherError(addBorrowedObject(error));
return ret !== 0;
} finally {
heap[stack_pointer++] = undefined;
}
}
/**
* @param {any} error
* @returns {boolean}
*/
function isDecryptFileError(error) {
try {
const ret = wasm.isDecryptFileError(addBorrowedObject(error));
return ret !== 0;
} finally {
heap[stack_pointer++] = undefined;
}
}
/**
* @param {any} error
* @returns {boolean}
*/
function isEncryptFileError(error) {
try {
const ret = wasm.isEncryptFileError(addBorrowedObject(error));
return ret !== 0;
} finally {
heap[stack_pointer++] = undefined;
}
}
function __wbg_adapter_54(arg0, arg1) {
wasm._dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h091423ccfc08366e(
arg0,
arg1,
);
}
function __wbg_adapter_59(arg0, arg1, arg2) {
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hb3d7232059e1cc02(
arg0,
arg1,
addHeapObject(arg2),
);
}
function __wbg_adapter_322(arg0, arg1, arg2, arg3) {
wasm.wasm_bindgen__convert__closures__invoke2_mut__h54a8613170fef18e(
arg0,
arg1,
addHeapObject(arg2),
addHeapObject(arg3),
);
}
/**
* @enum {300 | 301 | 302 | 303 | 304 | 305}
*/
const CardLinkedIdType = Object.freeze({
CardholderName: 300,
300: "CardholderName",
ExpMonth: 301,
301: "ExpMonth",
ExpYear: 302,
302: "ExpYear",
Code: 303,
303: "Code",
Brand: 304,
304: "Brand",
Number: 305,
305: "Number",
});
/**
* @enum {0 | 1}
*/
const CipherRepromptType = Object.freeze({
None: 0,
0: "None",
Password: 1,
1: "Password",
});
/**
* @enum {1 | 2 | 3 | 4 | 5}
*/
const CipherType = Object.freeze({
Login: 1,
1: "Login",
SecureNote: 2,
2: "SecureNote",
Card: 3,
3: "Card",
Identity: 4,
4: "Identity",
SshKey: 5,
5: "SshKey",
});
/**
* Represents the type of a [FieldView].
* @enum {0 | 1 | 2 | 3}
*/
const FieldType = Object.freeze({
/**
* Text field
*/
Text: 0,
0: "Text",
/**
* Hidden text field
*/
Hidden: 1,
1: "Hidden",
/**
* Boolean field
*/
Boolean: 2,
2: "Boolean",
/**
* Linked field
*/
Linked: 3,
3: "Linked",
});
/**
* @enum {400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418}
*/
const IdentityLinkedIdType = Object.freeze({
Title: 400,
400: "Title",
MiddleName: 401,
401: "MiddleName",
Address1: 402,
402: "Address1",
Address2: 403,
403: "Address2",
Address3: 404,
404: "Address3",
City: 405,
405: "City",
State: 406,
406: "State",
PostalCode: 407,
407: "PostalCode",
Country: 408,
408: "Country",
Company: 409,
409: "Company",
Email: 410,
410: "Email",
Phone: 411,
411: "Phone",
Ssn: 412,
412: "Ssn",
Username: 413,
413: "Username",
PassportNumber: 414,
414: "PassportNumber",
LicenseNumber: 415,
415: "LicenseNumber",
FirstName: 416,
416: "FirstName",
LastName: 417,
417: "LastName",
FullName: 418,
418: "FullName",
});
/**
* @enum {0 | 1 | 2 | 3 | 4}
*/
const LogLevel = Object.freeze({
Trace: 0,
0: "Trace",
Debug: 1,
1: "Debug",
Info: 2,
2: "Info",
Warn: 3,
3: "Warn",
Error: 4,
4: "Error",
});
/**
* @enum {100 | 101}
*/
const LoginLinkedIdType = Object.freeze({
Username: 100,
100: "Username",
Password: 101,
101: "Password",
});
/**
* @enum {0}
*/
const SecureNoteType = Object.freeze({
Generic: 0,
0: "Generic",
});
/**
* @enum {0 | 1 | 2 | 3 | 4 | 5}
*/
const UriMatchType = Object.freeze({
Domain: 0,
0: "Domain",
Host: 1,
1: "Host",
StartsWith: 2,
2: "StartsWith",
Exact: 3,
3: "Exact",
RegularExpression: 4,
4: "RegularExpression",
Never: 5,
5: "Never",
});
const __wbindgen_enum_RequestCredentials = ["omit", "same-origin", "include"];
const __wbindgen_enum_RequestMode = ["same-origin", "no-cors", "cors", "navigate"];
const AttachmentsClientFinalization =
typeof FinalizationRegistry === "undefined"
? { register: () => {}, unregister: () => {} }
: new FinalizationRegistry((ptr) => wasm.__wbg_attachmentsclient_free(ptr >>> 0, 1));
class AttachmentsClient {
static __wrap(ptr) {
ptr = ptr >>> 0;
const obj = Object.create(AttachmentsClient.prototype);
obj.__wbg_ptr = ptr;
AttachmentsClientFinalization.register(obj, obj.__wbg_ptr, obj);
return obj;
}
__destroy_into_raw() {
const ptr = this.__wbg_ptr;
this.__wbg_ptr = 0;
AttachmentsClientFinalization.unregister(this);
return ptr;
}
free() {
const ptr = this.__destroy_into_raw();
wasm.__wbg_attachmentsclient_free(ptr, 0);
}
/**
* @param {Cipher} cipher
* @param {AttachmentView} attachment
* @param {Uint8Array} encrypted_buffer
* @returns {Uint8Array}
*/
decrypt_buffer(cipher, attachment, encrypted_buffer) {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
const ptr0 = passArray8ToWasm0(encrypted_buffer, wasm.__wbindgen_malloc);
const len0 = WASM_VECTOR_LEN;
wasm.attachmentsclient_decrypt_buffer(
retptr,
this.__wbg_ptr,
addHeapObject(cipher),
addHeapObject(attachment),
ptr0,
len0,
);
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
if (r3) {
throw takeObject(r2);
}
var v2 = getArrayU8FromWasm0(r0, r1).slice();
wasm.__wbindgen_free(r0, r1 * 1, 1);
return v2;
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
}
}
}
const AuthClientFinalization =
typeof FinalizationRegistry === "undefined"
? { register: () => {}, unregister: () => {} }
: new FinalizationRegistry((ptr) => wasm.__wbg_authclient_free(ptr >>> 0, 1));
/**
* Subclient containing auth functionality.
*/
class AuthClient {
static __wrap(ptr) {
ptr = ptr >>> 0;
const obj = Object.create(AuthClient.prototype);
obj.__wbg_ptr = ptr;
AuthClientFinalization.register(obj, obj.__wbg_ptr, obj);
return obj;
}
__destroy_into_raw() {
const ptr = this.__wbg_ptr;
this.__wbg_ptr = 0;
AuthClientFinalization.unregister(this);
return ptr;
}
free() {
const ptr = this.__destroy_into_raw();
wasm.__wbg_authclient_free(ptr, 0);
}
/**
* Client for send access functionality
* @returns {SendAccessClient}
*/
send_access() {
const ret = wasm.authclient_send_access(this.__wbg_ptr);
return SendAccessClient.__wrap(ret);
}
}
const BitwardenClientFinalization =
typeof FinalizationRegistry === "undefined"
? { register: () => {}, unregister: () => {} }
: new FinalizationRegistry((ptr) => wasm.__wbg_bitwardenclient_free(ptr >>> 0, 1));
class BitwardenClient {
__destroy_into_raw() {
const ptr = this.__wbg_ptr;
this.__wbg_ptr = 0;
BitwardenClientFinalization.unregister(this);
return ptr;
}
free() {
const ptr = this.__destroy_into_raw();
wasm.__wbg_bitwardenclient_free(ptr, 0);
}
/**
* @param {any} token_provider
* @param {ClientSettings | null} [settings]
*/
constructor(token_provider, settings) {
const ret = wasm.bitwardenclient_new(
addHeapObject(token_provider),
isLikeNone(settings) ? 0 : addHeapObject(settings),
);
this.__wbg_ptr = ret >>> 0;
BitwardenClientFinalization.register(this, this.__wbg_ptr, this);
return this;
}
/**
* Test method, echoes back the input
* @param {string} msg
* @returns {string}
*/
echo(msg) {
let deferred2_0;
let deferred2_1;
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
const ptr0 = passStringToWasm0(msg, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
const len0 = WASM_VECTOR_LEN;
wasm.bitwardenclient_echo(retptr, this.__wbg_ptr, ptr0, len0);
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
deferred2_0 = r0;
deferred2_1 = r1;
return getStringFromWasm0(r0, r1);
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
}
}
/**
* @returns {string}
*/
version() {
let deferred1_0;
let deferred1_1;
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
wasm.bitwardenclient_version(retptr, this.__wbg_ptr);
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
deferred1_0 = r0;
deferred1_1 = r1;
return getStringFromWasm0(r0, r1);
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
}
}
/**
* @param {string} msg
*/
throw(msg) {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
const ptr0 = passStringToWasm0(msg, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
const len0 = WASM_VECTOR_LEN;
wasm.bitwardenclient_throw(retptr, this.__wbg_ptr, ptr0, len0);
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
if (r1) {
throw takeObject(r0);
}
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
}
}
/**
* Test method, calls http endpoint
* @param {string} url
* @returns {Promise<string>}
*/
http_get(url) {
const ptr0 = passStringToWasm0(url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
const len0 = WASM_VECTOR_LEN;
const ret = wasm.bitwardenclient_http_get(this.__wbg_ptr, ptr0, len0);
return takeObject(ret);
}
/**
* Auth related operations.
* @returns {AuthClient}
*/
auth() {
const ret = wasm.bitwardenclient_auth(this.__wbg_ptr);
return AuthClient.__wrap(ret);
}
/**
* @returns {CryptoClient}
*/
crypto() {
const ret = wasm.bitwardenclient_crypto(this.__wbg_ptr);
return CryptoClient.__wrap(ret);
}
/**
* @returns {VaultClient}
*/
vault() {
const ret = wasm.bitwardenclient_vault(this.__wbg_ptr);
return VaultClient.__wrap(ret);
}
/**
* Constructs a specific client for platform-specific functionality
* @returns {PlatformClient}
*/
platform() {
const ret = wasm.bitwardenclient_platform(this.__wbg_ptr);
return PlatformClient.__wrap(ret);
}
/**
* Constructs a specific client for generating passwords and passphrases
* @returns {GeneratorClient}
*/
generator() {
const ret = wasm.bitwardenclient_generator(this.__wbg_ptr);
return GeneratorClient.__wrap(ret);
}
/**
* @returns {ExporterClient}
*/
exporters() {
const ret = wasm.bitwardenclient_exporters(this.__wbg_ptr);
return ExporterClient.__wrap(ret);
}
}
const CiphersClientFinalization =
typeof FinalizationRegistry === "undefined"
? { register: () => {}, unregister: () => {} }
: new FinalizationRegistry((ptr) => wasm.__wbg_ciphersclient_free(ptr >>> 0, 1));
class CiphersClient {
static __wrap(ptr) {
ptr = ptr >>> 0;
const obj = Object.create(CiphersClient.prototype);
obj.__wbg_ptr = ptr;
CiphersClientFinalization.register(obj, obj.__wbg_ptr, obj);
return obj;
}
__destroy_into_raw() {
const ptr = this.__wbg_ptr;
this.__wbg_ptr = 0;
CiphersClientFinalization.unregister(this);
return ptr;
}
free() {
const ptr = this.__destroy_into_raw();
wasm.__wbg_ciphersclient_free(ptr, 0);
}
/**
* @param {CipherView} cipher_view
* @returns {EncryptionContext}
*/
encrypt(cipher_view) {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
wasm.ciphersclient_encrypt(retptr, this.__wbg_ptr, addHeapObject(cipher_view));
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
if (r2) {
throw takeObject(r1);
}
return takeObject(r0);
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
}
}
/**
* Encrypt a cipher with the provided key. This should only be used when rotating encryption
* keys in the Web client.
*
* Until key rotation is fully implemented in the SDK, this method must be provided the new
* symmetric key in base64 format. See PM-23084
*
* If the cipher has a CipherKey, it will be re-encrypted with the new key.
* If the cipher does not have a CipherKey and CipherKeyEncryption is enabled, one will be
* generated using the new key. Otherwise, the cipher's data will be encrypted with the new
* key directly.
* @param {CipherView} cipher_view
* @param {string} new_key_b64
* @returns {EncryptionContext}
*/
encrypt_cipher_for_rotation(cipher_view, new_key_b64) {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
const ptr0 = passStringToWasm0(new_key_b64, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
const len0 = WASM_VECTOR_LEN;
wasm.ciphersclient_encrypt_cipher_for_rotation(
retptr,
this.__wbg_ptr,
addHeapObject(cipher_view),
ptr0,
len0,
);
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
if (r2) {
throw takeObject(r1);
}
return takeObject(r0);
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
}
}
/**
* @param {Cipher} cipher
* @returns {CipherView}
*/
decrypt(cipher) {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
wasm.ciphersclient_decrypt(retptr, this.__wbg_ptr, addHeapObject(cipher));
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
if (r2) {
throw takeObject(r1);
}
return takeObject(r0);
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
}
}
/**
* @param {Cipher[]} ciphers
* @returns {CipherListView[]}
*/
decrypt_list(ciphers) {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
const ptr0 = passArrayJsValueToWasm0(ciphers, wasm.__wbindgen_malloc);
const len0 = WASM_VECTOR_LEN;
wasm.ciphersclient_decrypt_list(retptr, this.__wbg_ptr, ptr0, len0);
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
if (r3) {
throw takeObject(r2);
}
var v2 = getArrayJsValueFromWasm0(r0, r1).slice();
wasm.__wbindgen_free(r0, r1 * 4, 4);
return v2;
} finally {
w