UNPKG

879 kBJavaScriptView Raw
1#!/usr/bin/env node
2/******/ (function(modules) { // webpackBootstrap
3/******/ // The module cache
4/******/ var installedModules = {};
5/******/
6/******/ // The require function
7/******/ function __webpack_require__(moduleId) {
8/******/
9/******/ // Check if module is in cache
10/******/ if(installedModules[moduleId]) {
11/******/ return installedModules[moduleId].exports;
12/******/ }
13/******/ // Create a new module (and put it into the cache)
14/******/ var module = installedModules[moduleId] = {
15/******/ i: moduleId,
16/******/ l: false,
17/******/ exports: {}
18/******/ };
19/******/
20/******/ // Execute the module function
21/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
22/******/
23/******/ // Flag the module as loaded
24/******/ module.l = true;
25/******/
26/******/ // Return the exports of the module
27/******/ return module.exports;
28/******/ }
29/******/
30/******/
31/******/ // expose the modules object (__webpack_modules__)
32/******/ __webpack_require__.m = modules;
33/******/
34/******/ // expose the module cache
35/******/ __webpack_require__.c = installedModules;
36/******/
37/******/ // define getter function for harmony exports
38/******/ __webpack_require__.d = function(exports, name, getter) {
39/******/ if(!__webpack_require__.o(exports, name)) {
40/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
41/******/ }
42/******/ };
43/******/
44/******/ // define __esModule on exports
45/******/ __webpack_require__.r = function(exports) {
46/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
47/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
48/******/ }
49/******/ Object.defineProperty(exports, '__esModule', { value: true });
50/******/ };
51/******/
52/******/ // create a fake namespace object
53/******/ // mode & 1: value is a module id, require it
54/******/ // mode & 2: merge all properties of value into the ns
55/******/ // mode & 4: return value when already ns object
56/******/ // mode & 8|1: behave like require
57/******/ __webpack_require__.t = function(value, mode) {
58/******/ if(mode & 1) value = __webpack_require__(value);
59/******/ if(mode & 8) return value;
60/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
61/******/ var ns = Object.create(null);
62/******/ __webpack_require__.r(ns);
63/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
64/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
65/******/ return ns;
66/******/ };
67/******/
68/******/ // getDefaultExport function for compatibility with non-harmony modules
69/******/ __webpack_require__.n = function(module) {
70/******/ var getter = module && module.__esModule ?
71/******/ function getDefault() { return module['default']; } :
72/******/ function getModuleExports() { return module; };
73/******/ __webpack_require__.d(getter, 'a', getter);
74/******/ return getter;
75/******/ };
76/******/
77/******/ // Object.prototype.hasOwnProperty.call
78/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
79/******/
80/******/ // __webpack_public_path__
81/******/ __webpack_require__.p = "";
82/******/
83/******/
84/******/ // Load entry module and return exports
85/******/ return __webpack_require__(__webpack_require__.s = 21);
86/******/ })
87/************************************************************************/
88/******/ ([
89/* 0 */
90/***/ (function(module, exports) {
91
92module.exports = require("commander");
93
94/***/ }),
95/* 1 */
96/***/ (function(module, exports) {
97
98module.exports = require("path");
99
100/***/ }),
101/* 2 */
102/***/ (function(module, exports) {
103
104module.exports = require("node-forge");
105
106/***/ }),
107/* 3 */
108/***/ (function(module, exports) {
109
110module.exports = require("fs");
111
112/***/ }),
113/* 4 */
114/***/ (function(module, exports) {
115
116module.exports = require("node-fetch");
117
118/***/ }),
119/* 5 */
120/***/ (function(module, exports) {
121
122module.exports = require("inquirer");
123
124/***/ }),
125/* 6 */
126/***/ (function(module, exports) {
127
128module.exports = require("crypto");
129
130/***/ }),
131/* 7 */
132/***/ (function(module, exports) {
133
134module.exports = require("tldjs");
135
136/***/ }),
137/* 8 */
138/***/ (function(module, exports) {
139
140module.exports = require("papaparse");
141
142/***/ }),
143/* 9 */
144/***/ (function(module, exports) {
145
146module.exports = require("lunr");
147
148/***/ }),
149/* 10 */
150/***/ (function(module, exports) {
151
152module.exports = require("chalk");
153
154/***/ }),
155/* 11 */
156/***/ (function(module, exports) {
157
158module.exports = require("lowdb");
159
160/***/ }),
161/* 12 */
162/***/ (function(module, exports) {
163
164module.exports = require("jsdom");
165
166/***/ }),
167/* 13 */
168/***/ (function(module, exports) {
169
170module.exports = require("big-integer");
171
172/***/ }),
173/* 14 */
174/***/ (function(module, exports) {
175
176module.exports = require("lowdb/adapters/FileSync");
177
178/***/ }),
179/* 15 */
180/***/ (function(module, exports) {
181
182module.exports = require("readline");
183
184/***/ }),
185/* 16 */
186/***/ (function(module, exports) {
187
188module.exports = require("form-data");
189
190/***/ }),
191/* 17 */
192/***/ (function(module, exports) {
193
194module.exports = require("https-proxy-agent");
195
196/***/ }),
197/* 18 */
198/***/ (function(module, exports) {
199
200module.exports = require("zxcvbn");
201
202/***/ }),
203/* 19 */
204/***/ (function(module, exports) {
205
206module.exports = require("url");
207
208/***/ }),
209/* 20 */
210/***/ (function(module) {
211
212module.exports = {"name":"@bitwarden/cli","description":"A secure and free password manager for all of your devices.","version":"1.11.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/cli"},"license":"GPL-3.0","scripts":{"sub:init":"git submodule update --init --recursive","sub:update":"git submodule update --remote","sub:pull":"git submodule foreach git pull origin master","clean":"rimraf dist/**/*","symlink:win":"rmdir /S /Q ./jslib && cmd /c mklink /J .\\jslib ..\\jslib","symlink:mac":"npm run symlink:lin","symlink:lin":"rm -rf ./jslib && ln -s ../jslib ./jslib","build":"webpack","build:watch":"webpack --watch","build:prod":"cross-env NODE_ENV=production webpack","build:prod:watch":"cross-env NODE_ENV=production webpack --watch","package":"npm run package:win | npm run package:mac | npm run package:lin","package:win":"pkg . --targets win-x64 --output ./dist/windows/bw.exe","package:mac":"pkg . --targets macos-x64 --output ./dist/macos/bw","package:lin":"pkg . --targets linux-x64 --output ./dist/linux/bw","dist":"npm run build:prod && npm run clean && npm run package","dist:win":"npm run build:prod && npm run clean && npm run package:win","dist:mac":"npm run build:prod && npm run clean && npm run package:mac","dist:lin":"npm run build:prod && npm run clean && npm run package:lin","publish:npm":"npm run build:prod && npm publish --access public","lint":"tslint src/**/*.ts spec/**/*.ts || true","lint:fix":"tslint src/**/*.ts spec/**/*.ts --fix"},"bin":{"bw":"./build/bw.js"},"pkg":{"assets":"./build/**/*"},"devDependencies":{"@types/commander":"^2.12.2","@types/form-data":"^2.2.1","@types/inquirer":"^0.0.43","@types/jsdom":"^12.2.1","@types/lowdb":"^1.0.5","@types/lunr":"^2.3.3","@types/node":"^10.9.4","@types/node-fetch":"^2.1.2","@types/node-forge":"^0.7.5","@types/papaparse":"^4.5.3","@types/tldjs":"^2.3.0","@types/zxcvbn":"4.4.0","clean-webpack-plugin":"^0.1.19","copy-webpack-plugin":"^4.5.2","cross-env":"^5.2.0","pkg":"4.3.4","ts-loader":"^5.3.3","tslint":"^5.12.1","tslint-loader":"^3.5.4","typescript":"3.2.4","webpack":"^4.29.0","webpack-cli":"^3.2.1","webpack-node-externals":"^1.7.2"},"dependencies":{"big-integer":"1.6.36","chalk":"2.4.1","commander":"2.18.0","form-data":"2.3.2","https-proxy-agent":"4.0.0","inquirer":"6.2.0","jsdom":"13.2.0","lowdb":"1.0.0","lunr":"2.3.3","node-fetch":"2.2.0","node-forge":"0.7.6","papaparse":"4.6.0","tldjs":"2.3.1","zxcvbn":"4.4.2"}};
213
214/***/ }),
215/* 21 */
216/***/ (function(module, __webpack_exports__, __webpack_require__) {
217
218"use strict";
219__webpack_require__.r(__webpack_exports__);
220
221// EXTERNAL MODULE: external "fs"
222var external_fs_ = __webpack_require__(3);
223
224// EXTERNAL MODULE: external "jsdom"
225var external_jsdom_ = __webpack_require__(12);
226
227// EXTERNAL MODULE: external "path"
228var external_path_ = __webpack_require__(1);
229
230// CONCATENATED MODULE: ./jslib/src/enums/twoFactorProviderType.ts
231var TwoFactorProviderType;
232(function (TwoFactorProviderType) {
233 TwoFactorProviderType[TwoFactorProviderType["Authenticator"] = 0] = "Authenticator";
234 TwoFactorProviderType[TwoFactorProviderType["Email"] = 1] = "Email";
235 TwoFactorProviderType[TwoFactorProviderType["Duo"] = 2] = "Duo";
236 TwoFactorProviderType[TwoFactorProviderType["Yubikey"] = 3] = "Yubikey";
237 TwoFactorProviderType[TwoFactorProviderType["U2f"] = 4] = "U2f";
238 TwoFactorProviderType[TwoFactorProviderType["Remember"] = 5] = "Remember";
239 TwoFactorProviderType[TwoFactorProviderType["OrganizationDuo"] = 6] = "OrganizationDuo";
240})(TwoFactorProviderType || (TwoFactorProviderType = {}));
241
242// CONCATENATED MODULE: ./jslib/src/models/domain/authResult.ts
243class AuthResult {
244 constructor() {
245 this.twoFactor = false;
246 this.twoFactorProviders = null;
247 }
248}
249
250// CONCATENATED MODULE: ./jslib/src/models/request/deviceRequest.ts
251class DeviceRequest {
252 constructor(appId, platformUtilsService) {
253 this.type = platformUtilsService.getDevice();
254 this.name = platformUtilsService.getDeviceString();
255 this.identifier = appId;
256 this.pushToken = null;
257 }
258}
259
260// CONCATENATED MODULE: ./jslib/src/models/request/keysRequest.ts
261class KeysRequest {
262 constructor(publicKey, encryptedPrivateKey) {
263 this.publicKey = publicKey;
264 this.encryptedPrivateKey = encryptedPrivateKey;
265 }
266}
267
268// CONCATENATED MODULE: ./jslib/src/models/request/preloginRequest.ts
269class PreloginRequest {
270 constructor(email) {
271 this.email = email;
272 }
273}
274
275// CONCATENATED MODULE: ./jslib/src/models/request/tokenRequest.ts
276class TokenRequest {
277 constructor(email, masterPasswordHash, provider, token, remember, device) {
278 this.email = email;
279 this.masterPasswordHash = masterPasswordHash;
280 this.token = token;
281 this.provider = provider;
282 this.remember = remember;
283 this.device = device != null ? device : null;
284 }
285 toIdentityToken(clientId) {
286 const obj = {
287 grant_type: 'password',
288 username: this.email,
289 password: this.masterPasswordHash,
290 scope: 'api offline_access',
291 client_id: clientId,
292 };
293 if (this.device) {
294 obj.deviceType = this.device.type;
295 obj.deviceIdentifier = this.device.identifier;
296 obj.deviceName = this.device.name;
297 // no push tokens for browser apps yet
298 // obj.devicePushToken = this.device.pushToken;
299 }
300 if (this.token && this.provider != null) {
301 obj.twoFactorToken = this.token;
302 obj.twoFactorProvider = this.provider;
303 obj.twoFactorRemember = this.remember ? '1' : '0';
304 }
305 return obj;
306 }
307}
308
309// CONCATENATED MODULE: ./jslib/src/services/auth.service.ts
310var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
311 return new (P || (P = Promise))(function (resolve, reject) {
312 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
313 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
314 function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
315 step((generator = generator.apply(thisArg, _arguments || [])).next());
316 });
317};
318
319
320
321
322
323
324const TwoFactorProviders = {
325 [TwoFactorProviderType.Authenticator]: {
326 type: TwoFactorProviderType.Authenticator,
327 name: null,
328 description: null,
329 priority: 1,
330 sort: 1,
331 premium: false,
332 },
333 [TwoFactorProviderType.Yubikey]: {
334 type: TwoFactorProviderType.Yubikey,
335 name: null,
336 description: null,
337 priority: 3,
338 sort: 2,
339 premium: true,
340 },
341 [TwoFactorProviderType.Duo]: {
342 type: TwoFactorProviderType.Duo,
343 name: 'Duo',
344 description: null,
345 priority: 2,
346 sort: 3,
347 premium: true,
348 },
349 [TwoFactorProviderType.OrganizationDuo]: {
350 type: TwoFactorProviderType.OrganizationDuo,
351 name: 'Duo (Organization)',
352 description: null,
353 priority: 10,
354 sort: 4,
355 premium: false,
356 },
357 [TwoFactorProviderType.U2f]: {
358 type: TwoFactorProviderType.U2f,
359 name: null,
360 description: null,
361 priority: 4,
362 sort: 5,
363 premium: true,
364 },
365 [TwoFactorProviderType.Email]: {
366 type: TwoFactorProviderType.Email,
367 name: null,
368 description: null,
369 priority: 0,
370 sort: 6,
371 premium: false,
372 },
373};
374class auth_service_AuthService {
375 constructor(cryptoService, apiService, userService, tokenService, appIdService, i18nService, platformUtilsService, messagingService, setCryptoKeys = true) {
376 this.cryptoService = cryptoService;
377 this.apiService = apiService;
378 this.userService = userService;
379 this.tokenService = tokenService;
380 this.appIdService = appIdService;
381 this.i18nService = i18nService;
382 this.platformUtilsService = platformUtilsService;
383 this.messagingService = messagingService;
384 this.setCryptoKeys = setCryptoKeys;
385 this.selectedTwoFactorProviderType = null;
386 }
387 init() {
388 TwoFactorProviders[TwoFactorProviderType.Email].name = this.i18nService.t('emailTitle');
389 TwoFactorProviders[TwoFactorProviderType.Email].description = this.i18nService.t('emailDesc');
390 TwoFactorProviders[TwoFactorProviderType.Authenticator].name = this.i18nService.t('authenticatorAppTitle');
391 TwoFactorProviders[TwoFactorProviderType.Authenticator].description =
392 this.i18nService.t('authenticatorAppDesc');
393 TwoFactorProviders[TwoFactorProviderType.Duo].description = this.i18nService.t('duoDesc');
394 TwoFactorProviders[TwoFactorProviderType.OrganizationDuo].name =
395 'Duo (' + this.i18nService.t('organization') + ')';
396 TwoFactorProviders[TwoFactorProviderType.OrganizationDuo].description =
397 this.i18nService.t('duoOrganizationDesc');
398 TwoFactorProviders[TwoFactorProviderType.U2f].name = this.i18nService.t('u2fTitle');
399 TwoFactorProviders[TwoFactorProviderType.U2f].description = this.i18nService.t('u2fDesc');
400 TwoFactorProviders[TwoFactorProviderType.Yubikey].name = this.i18nService.t('yubiKeyTitle');
401 TwoFactorProviders[TwoFactorProviderType.Yubikey].description = this.i18nService.t('yubiKeyDesc');
402 }
403 logIn(email, masterPassword) {
404 return __awaiter(this, void 0, void 0, function* () {
405 this.selectedTwoFactorProviderType = null;
406 const key = yield this.makePreloginKey(masterPassword, email);
407 const hashedPassword = yield this.cryptoService.hashPassword(masterPassword, key);
408 return yield this.logInHelper(email, hashedPassword, key);
409 });
410 }
411 logInTwoFactor(twoFactorProvider, twoFactorToken, remember) {
412 return __awaiter(this, void 0, void 0, function* () {
413 return yield this.logInHelper(this.email, this.masterPasswordHash, this.key, twoFactorProvider, twoFactorToken, remember);
414 });
415 }
416 logInComplete(email, masterPassword, twoFactorProvider, twoFactorToken, remember) {
417 return __awaiter(this, void 0, void 0, function* () {
418 this.selectedTwoFactorProviderType = null;
419 const key = yield this.makePreloginKey(masterPassword, email);
420 const hashedPassword = yield this.cryptoService.hashPassword(masterPassword, key);
421 return yield this.logInHelper(email, hashedPassword, key, twoFactorProvider, twoFactorToken, remember);
422 });
423 }
424 logOut(callback) {
425 callback();
426 this.messagingService.send('loggedOut');
427 }
428 getSupportedTwoFactorProviders(win) {
429 const providers = [];
430 if (this.twoFactorProvidersData == null) {
431 return providers;
432 }
433 if (this.twoFactorProvidersData.has(TwoFactorProviderType.OrganizationDuo) &&
434 this.platformUtilsService.supportsDuo()) {
435 providers.push(TwoFactorProviders[TwoFactorProviderType.OrganizationDuo]);
436 }
437 if (this.twoFactorProvidersData.has(TwoFactorProviderType.Authenticator)) {
438 providers.push(TwoFactorProviders[TwoFactorProviderType.Authenticator]);
439 }
440 if (this.twoFactorProvidersData.has(TwoFactorProviderType.Yubikey)) {
441 providers.push(TwoFactorProviders[TwoFactorProviderType.Yubikey]);
442 }
443 if (this.twoFactorProvidersData.has(TwoFactorProviderType.Duo) && this.platformUtilsService.supportsDuo()) {
444 providers.push(TwoFactorProviders[TwoFactorProviderType.Duo]);
445 }
446 if (this.twoFactorProvidersData.has(TwoFactorProviderType.U2f) && this.platformUtilsService.supportsU2f(win)) {
447 providers.push(TwoFactorProviders[TwoFactorProviderType.U2f]);
448 }
449 if (this.twoFactorProvidersData.has(TwoFactorProviderType.Email)) {
450 providers.push(TwoFactorProviders[TwoFactorProviderType.Email]);
451 }
452 return providers;
453 }
454 getDefaultTwoFactorProvider(u2fSupported) {
455 if (this.twoFactorProvidersData == null) {
456 return null;
457 }
458 if (this.selectedTwoFactorProviderType != null &&
459 this.twoFactorProvidersData.has(this.selectedTwoFactorProviderType)) {
460 return this.selectedTwoFactorProviderType;
461 }
462 let providerType = null;
463 let providerPriority = -1;
464 this.twoFactorProvidersData.forEach((value, type) => {
465 const provider = TwoFactorProviders[type];
466 if (provider != null && provider.priority > providerPriority) {
467 if (type === TwoFactorProviderType.U2f && !u2fSupported) {
468 return;
469 }
470 providerType = type;
471 providerPriority = provider.priority;
472 }
473 });
474 return providerType;
475 }
476 makePreloginKey(masterPassword, email) {
477 return __awaiter(this, void 0, void 0, function* () {
478 email = email.trim().toLowerCase();
479 this.kdf = null;
480 this.kdfIterations = null;
481 try {
482 const preloginResponse = yield this.apiService.postPrelogin(new PreloginRequest(email));
483 if (preloginResponse != null) {
484 this.kdf = preloginResponse.kdf;
485 this.kdfIterations = preloginResponse.kdfIterations;
486 }
487 }
488 catch (e) {
489 if (e == null || e.statusCode !== 404) {
490 throw e;
491 }
492 }
493 return this.cryptoService.makeKey(masterPassword, email, this.kdf, this.kdfIterations);
494 });
495 }
496 logInHelper(email, hashedPassword, key, twoFactorProvider, twoFactorToken, remember) {
497 return __awaiter(this, void 0, void 0, function* () {
498 const storedTwoFactorToken = yield this.tokenService.getTwoFactorToken(email);
499 const appId = yield this.appIdService.getAppId();
500 const deviceRequest = new DeviceRequest(appId, this.platformUtilsService);
501 let request;
502 if (twoFactorToken != null && twoFactorProvider != null) {
503 request = new TokenRequest(email, hashedPassword, twoFactorProvider, twoFactorToken, remember, deviceRequest);
504 }
505 else if (storedTwoFactorToken != null) {
506 request = new TokenRequest(email, hashedPassword, TwoFactorProviderType.Remember, storedTwoFactorToken, false, deviceRequest);
507 }
508 else {
509 request = new TokenRequest(email, hashedPassword, null, null, false, deviceRequest);
510 }
511 const response = yield this.apiService.postIdentityToken(request);
512 this.clearState();
513 const result = new AuthResult();
514 result.twoFactor = !response.accessToken;
515 if (result.twoFactor) {
516 // two factor required
517 const twoFactorResponse = response;
518 this.email = email;
519 this.masterPasswordHash = hashedPassword;
520 this.key = this.setCryptoKeys ? key : null;
521 this.twoFactorProvidersData = twoFactorResponse.twoFactorProviders2;
522 result.twoFactorProviders = twoFactorResponse.twoFactorProviders2;
523 return result;
524 }
525 const tokenResponse = response;
526 if (tokenResponse.twoFactorToken != null) {
527 yield this.tokenService.setTwoFactorToken(tokenResponse.twoFactorToken, email);
528 }
529 yield this.tokenService.setTokens(tokenResponse.accessToken, tokenResponse.refreshToken);
530 yield this.userService.setInformation(this.tokenService.getUserId(), this.tokenService.getEmail(), this.kdf, this.kdfIterations);
531 if (this.setCryptoKeys) {
532 yield this.cryptoService.setKey(key);
533 yield this.cryptoService.setKeyHash(hashedPassword);
534 yield this.cryptoService.setEncKey(tokenResponse.key);
535 // User doesn't have a key pair yet (old account), let's generate one for them
536 if (tokenResponse.privateKey == null) {
537 try {
538 const keyPair = yield this.cryptoService.makeKeyPair();
539 yield this.apiService.postAccountKeys(new KeysRequest(keyPair[0], keyPair[1].encryptedString));
540 tokenResponse.privateKey = keyPair[1].encryptedString;
541 }
542 catch (e) {
543 // tslint:disable-next-line
544 console.error(e);
545 }
546 }
547 yield this.cryptoService.setEncPrivateKey(tokenResponse.privateKey);
548 }
549 this.messagingService.send('loggedIn');
550 return result;
551 });
552 }
553 clearState() {
554 this.email = null;
555 this.masterPasswordHash = null;
556 this.twoFactorProvidersData = null;
557 this.selectedTwoFactorProviderType = null;
558 }
559}
560
561// CONCATENATED MODULE: ./jslib/src/services/i18n.service.ts
562var i18n_service_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
563 return new (P || (P = Promise))(function (resolve, reject) {
564 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
565 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
566 function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
567 step((generator = generator.apply(thisArg, _arguments || [])).next());
568 });
569};
570class i18n_service_I18nService {
571 constructor(systemLanguage, localesDirectory, getLocalesJson) {
572 this.systemLanguage = systemLanguage;
573 this.localesDirectory = localesDirectory;
574 this.getLocalesJson = getLocalesJson;
575 // First locale is the default (English)
576 this.supportedTranslationLocales = ['en'];
577 this.localeNames = new Map([
578 ['af', 'Afrikaans'],
579 ['bg', 'български'],
580 ['ca', 'català'],
581 ['cs', 'čeština'],
582 ['da', 'dansk'],
583 ['de', 'Deutsch'],
584 ['el', 'Ελληνικά'],
585 ['en', 'English'],
586 ['en-GB', 'English (British)'],
587 ['eo', 'Esperanto'],
588 ['es', 'español'],
589 ['et', 'eesti'],
590 ['fa', 'فارسی'],
591 ['fi', 'suomi'],
592 ['fr', 'français'],
593 ['he', 'עברית'],
594 ['hi', 'हिन्दी'],
595 ['hr', 'hrvatski'],
596 ['hu', 'magyar'],
597 ['id', 'Bahasa Indonesia'],
598 ['it', 'italiano'],
599 ['ja', '日本語'],
600 ['ko', '한국어'],
601 ['nb', 'norsk (bokmål)'],
602 ['nl', 'Nederlands'],
603 ['pl', 'polski'],
604 ['pt-BR', 'português do Brasil'],
605 ['pt-PT', 'português'],
606 ['ro', 'română'],
607 ['ru', 'русский'],
608 ['sk', 'slovenčina'],
609 ['sv', 'svenska'],
610 ['th', 'ไทย'],
611 ['tr', 'Türkçe'],
612 ['uk', 'українська'],
613 ['vi', 'Tiếng Việt'],
614 ['zh-CN', '中文(中国大陆)'],
615 ['zh-TW', '中文(台灣)'],
616 ]);
617 this.defaultMessages = {};
618 this.localeMessages = {};
619 this.systemLanguage = systemLanguage.replace('_', '-');
620 }
621 init(locale) {
622 return i18n_service_awaiter(this, void 0, void 0, function* () {
623 if (this.inited) {
624 throw new Error('i18n already initialized.');
625 }
626 if (this.supportedTranslationLocales == null || this.supportedTranslationLocales.length === 0) {
627 throw new Error('supportedTranslationLocales not set.');
628 }
629 this.inited = true;
630 this.locale = this.translationLocale = locale != null ? locale : this.systemLanguage;
631 try {
632 this.collator = new Intl.Collator(this.locale, { numeric: true, sensitivity: 'base' });
633 }
634 catch (_a) {
635 this.collator = null;
636 }
637 if (this.supportedTranslationLocales.indexOf(this.translationLocale) === -1) {
638 this.translationLocale = this.translationLocale.slice(0, 2);
639 if (this.supportedTranslationLocales.indexOf(this.translationLocale) === -1) {
640 this.translationLocale = this.supportedTranslationLocales[0];
641 }
642 }
643 if (this.localesDirectory != null) {
644 yield this.loadMessages(this.translationLocale, this.localeMessages);
645 if (this.translationLocale !== this.supportedTranslationLocales[0]) {
646 yield this.loadMessages(this.supportedTranslationLocales[0], this.defaultMessages);
647 }
648 }
649 });
650 }
651 t(id, p1, p2, p3) {
652 return this.translate(id, p1, p2, p3);
653 }
654 translate(id, p1, p2, p3) {
655 let result;
656 if (this.localeMessages.hasOwnProperty(id) && this.localeMessages[id]) {
657 result = this.localeMessages[id];
658 }
659 else if (this.defaultMessages.hasOwnProperty(id) && this.defaultMessages[id]) {
660 result = this.defaultMessages[id];
661 }
662 else {
663 result = '';
664 }
665 if (result !== '') {
666 if (p1 != null) {
667 result = result.split('__$1__').join(p1);
668 }
669 if (p2 != null) {
670 result = result.split('__$2__').join(p2);
671 }
672 if (p3 != null) {
673 result = result.split('__$3__').join(p3);
674 }
675 }
676 return result;
677 }
678 loadMessages(locale, messagesObj) {
679 return i18n_service_awaiter(this, void 0, void 0, function* () {
680 const formattedLocale = locale.replace('-', '_');
681 const locales = yield this.getLocalesJson(formattedLocale);
682 for (const prop in locales) {
683 if (!locales.hasOwnProperty(prop)) {
684 continue;
685 }
686 messagesObj[prop] = locales[prop].message;
687 if (locales[prop].placeholders) {
688 for (const placeProp in locales[prop].placeholders) {
689 if (!locales[prop].placeholders.hasOwnProperty(placeProp) ||
690 !locales[prop].placeholders[placeProp].content) {
691 continue;
692 }
693 const replaceToken = '\\$' + placeProp.toUpperCase() + '\\$';
694 let replaceContent = locales[prop].placeholders[placeProp].content;
695 if (replaceContent === '$1' || replaceContent === '$2' || replaceContent === '$3') {
696 replaceContent = '__$' + replaceContent + '__';
697 }
698 messagesObj[prop] = messagesObj[prop].replace(new RegExp(replaceToken, 'g'), replaceContent);
699 }
700 }
701 }
702 });
703 }
704}
705
706// CONCATENATED MODULE: ./src/services/i18n.service.ts
707
708
709
710class services_i18n_service_I18nService extends i18n_service_I18nService {
711 constructor(systemLanguage, localesDirectory) {
712 super(systemLanguage, localesDirectory, (formattedLocale) => {
713 const filePath = external_path_["join"](__dirname, this.localesDirectory + '/' + formattedLocale + '/messages.json');
714 const localesJson = external_fs_["readFileSync"](filePath, 'utf8');
715 const locales = JSON.parse(localesJson.replace(/^\uFEFF/, '')); // strip the BOM
716 return Promise.resolve(locales);
717 });
718 this.supportedTranslationLocales = [
719 'en',
720 ];
721 }
722}
723
724// CONCATENATED MODULE: ./jslib/src/models/data/attachmentData.ts
725class AttachmentData {
726 constructor(response) {
727 if (response == null) {
728 return;
729 }
730 this.id = response.id;
731 this.url = response.url;
732 this.fileName = response.fileName;
733 this.key = response.key;
734 this.size = response.size;
735 this.sizeName = response.sizeName;
736 }
737}
738
739// CONCATENATED MODULE: ./jslib/src/models/view/attachmentView.ts
740class AttachmentView {
741 constructor(a) {
742 this.id = null;
743 this.url = null;
744 this.size = null;
745 this.sizeName = null;
746 this.fileName = null;
747 this.key = null;
748 if (!a) {
749 return;
750 }
751 this.id = a.id;
752 this.url = a.url;
753 this.size = a.size;
754 this.sizeName = a.sizeName;
755 }
756 get fileSize() {
757 try {
758 if (this.size != null) {
759 return parseInt(this.size, null);
760 }
761 }
762 catch (_a) { }
763 return 0;
764 }
765}
766
767// CONCATENATED MODULE: ./jslib/src/enums/encryptionType.ts
768var EncryptionType;
769(function (EncryptionType) {
770 EncryptionType[EncryptionType["AesCbc256_B64"] = 0] = "AesCbc256_B64";
771 EncryptionType[EncryptionType["AesCbc128_HmacSha256_B64"] = 1] = "AesCbc128_HmacSha256_B64";
772 EncryptionType[EncryptionType["AesCbc256_HmacSha256_B64"] = 2] = "AesCbc256_HmacSha256_B64";
773 EncryptionType[EncryptionType["Rsa2048_OaepSha256_B64"] = 3] = "Rsa2048_OaepSha256_B64";
774 EncryptionType[EncryptionType["Rsa2048_OaepSha1_B64"] = 4] = "Rsa2048_OaepSha1_B64";
775 EncryptionType[EncryptionType["Rsa2048_OaepSha256_HmacSha256_B64"] = 5] = "Rsa2048_OaepSha256_HmacSha256_B64";
776 EncryptionType[EncryptionType["Rsa2048_OaepSha1_HmacSha256_B64"] = 6] = "Rsa2048_OaepSha1_HmacSha256_B64";
777})(EncryptionType || (EncryptionType = {}));
778
779// EXTERNAL MODULE: external "tldjs"
780var external_tldjs_ = __webpack_require__(7);
781
782// CONCATENATED MODULE: ./jslib/src/misc/utils.ts
783
784// tslint:disable-next-line
785const nodeURL = typeof window === 'undefined' ? __webpack_require__(19) : null;
786class utils_Utils {
787 static init() {
788 if (utils_Utils.inited) {
789 return;
790 }
791 utils_Utils.inited = true;
792 utils_Utils.isNode = typeof process !== 'undefined' && process.release != null &&
793 process.release.name === 'node';
794 utils_Utils.isBrowser = typeof window !== 'undefined';
795 utils_Utils.isNativeScript = !utils_Utils.isNode && !utils_Utils.isBrowser;
796 utils_Utils.isMobileBrowser = utils_Utils.isBrowser && this.isMobile(window);
797 utils_Utils.isAppleMobileBrowser = utils_Utils.isBrowser && this.isAppleMobile(window);
798 utils_Utils.global = utils_Utils.isNativeScript ? global : (utils_Utils.isNode && !utils_Utils.isBrowser ? global : window);
799 }
800 static fromB64ToArray(str) {
801 if (utils_Utils.isNode || utils_Utils.isNativeScript) {
802 return new Uint8Array(Buffer.from(str, 'base64'));
803 }
804 else {
805 const binaryString = window.atob(str);
806 const bytes = new Uint8Array(binaryString.length);
807 for (let i = 0; i < binaryString.length; i++) {
808 bytes[i] = binaryString.charCodeAt(i);
809 }
810 return bytes;
811 }
812 }
813 static fromHexToArray(str) {
814 if (utils_Utils.isNode || utils_Utils.isNativeScript) {
815 return new Uint8Array(Buffer.from(str, 'hex'));
816 }
817 else {
818 const bytes = new Uint8Array(str.length / 2);
819 for (let i = 0; i < str.length; i += 2) {
820 bytes[i / 2] = parseInt(str.substr(i, 2), 16);
821 }
822 return bytes;
823 }
824 }
825 static fromUtf8ToArray(str) {
826 if (utils_Utils.isNode || utils_Utils.isNativeScript) {
827 return new Uint8Array(Buffer.from(str, 'utf8'));
828 }
829 else {
830 const strUtf8 = unescape(encodeURIComponent(str));
831 const arr = new Uint8Array(strUtf8.length);
832 for (let i = 0; i < strUtf8.length; i++) {
833 arr[i] = strUtf8.charCodeAt(i);
834 }
835 return arr;
836 }
837 }
838 static fromByteStringToArray(str) {
839 const arr = new Uint8Array(str.length);
840 for (let i = 0; i < str.length; i++) {
841 arr[i] = str.charCodeAt(i);
842 }
843 return arr;
844 }
845 static fromBufferToB64(buffer) {
846 if (utils_Utils.isNode || utils_Utils.isNativeScript) {
847 return Buffer.from(buffer).toString('base64');
848 }
849 else {
850 let binary = '';
851 const bytes = new Uint8Array(buffer);
852 for (let i = 0; i < bytes.byteLength; i++) {
853 binary += String.fromCharCode(bytes[i]);
854 }
855 return window.btoa(binary);
856 }
857 }
858 static fromBufferToUtf8(buffer) {
859 if (utils_Utils.isNode || utils_Utils.isNativeScript) {
860 return Buffer.from(buffer).toString('utf8');
861 }
862 else {
863 const bytes = new Uint8Array(buffer);
864 const encodedString = String.fromCharCode.apply(null, bytes);
865 return decodeURIComponent(escape(encodedString));
866 }
867 }
868 static fromBufferToByteString(buffer) {
869 return String.fromCharCode.apply(null, new Uint8Array(buffer));
870 }
871 // ref: https://stackoverflow.com/a/40031979/1090359
872 static fromBufferToHex(buffer) {
873 if (utils_Utils.isNode || utils_Utils.isNativeScript) {
874 return Buffer.from(buffer).toString('hex');
875 }
876 else {
877 const bytes = new Uint8Array(buffer);
878 return Array.prototype.map.call(bytes, (x) => ('00' + x.toString(16)).slice(-2)).join('');
879 }
880 }
881 static fromUrlB64ToUtf8(b64Str) {
882 let output = b64Str.replace(/-/g, '+').replace(/_/g, '/');
883 switch (output.length % 4) {
884 case 0:
885 break;
886 case 2:
887 output += '==';
888 break;
889 case 3:
890 output += '=';
891 break;
892 default:
893 throw new Error('Illegal base64url string!');
894 }
895 return utils_Utils.fromB64ToUtf8(output);
896 }
897 static fromB64ToUtf8(b64Str) {
898 if (utils_Utils.isNode || utils_Utils.isNativeScript) {
899 return Buffer.from(b64Str, 'base64').toString('utf8');
900 }
901 else {
902 return decodeURIComponent(escape(window.atob(b64Str)));
903 }
904 }
905 // ref: http://stackoverflow.com/a/2117523/1090359
906 static newGuid() {
907 return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
908 // tslint:disable-next-line
909 const r = Math.random() * 16 | 0;
910 // tslint:disable-next-line
911 const v = c === 'x' ? r : (r & 0x3 | 0x8);
912 return v.toString(16);
913 });
914 }
915 static isGuid(id) {
916 return RegExp(/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/, 'i').test(id);
917 }
918 static getHostname(uriString) {
919 const url = utils_Utils.getUrl(uriString);
920 try {
921 return url != null && url.hostname !== '' ? url.hostname : null;
922 }
923 catch (_a) {
924 return null;
925 }
926 }
927 static getHost(uriString) {
928 const url = utils_Utils.getUrl(uriString);
929 try {
930 return url != null && url.host !== '' ? url.host : null;
931 }
932 catch (_a) {
933 return null;
934 }
935 }
936 static getDomain(uriString) {
937 if (uriString == null) {
938 return null;
939 }
940 uriString = uriString.trim();
941 if (uriString === '') {
942 return null;
943 }
944 if (uriString.startsWith('data:')) {
945 return null;
946 }
947 let httpUrl = uriString.startsWith('http://') || uriString.startsWith('https://');
948 if (!httpUrl && uriString.indexOf('://') < 0 && utils_Utils.tldEndingRegex.test(uriString)) {
949 uriString = 'http://' + uriString;
950 httpUrl = true;
951 }
952 if (httpUrl) {
953 try {
954 const url = utils_Utils.getUrlObject(uriString);
955 if (url.hostname === 'localhost' || utils_Utils.validIpAddress(url.hostname)) {
956 return url.hostname;
957 }
958 const urlDomain = external_tldjs_ != null && external_tldjs_["getDomain"] != null ? external_tldjs_["getDomain"](url.hostname) : null;
959 return urlDomain != null ? urlDomain : url.hostname;
960 }
961 catch (e) { }
962 }
963 const domain = external_tldjs_ != null && external_tldjs_["getDomain"] != null ? external_tldjs_["getDomain"](uriString) : null;
964 if (domain != null) {
965 return domain;
966 }
967 return null;
968 }
969 static getQueryParams(uriString) {
970 const url = utils_Utils.getUrl(uriString);
971 if (url == null || url.search == null || url.search === '') {
972 return null;
973 }
974 const map = new Map();
975 const pairs = (url.search[0] === '?' ? url.search.substr(1) : url.search).split('&');
976 pairs.forEach((pair) => {
977 const parts = pair.split('=');
978 if (parts.length < 1) {
979 return;
980 }
981 map.set(decodeURIComponent(parts[0]).toLowerCase(), parts[1] == null ? '' : decodeURIComponent(parts[1]));
982 });
983 return map;
984 }
985 static getSortFunction(i18nService, prop) {
986 return (a, b) => {
987 if (a[prop] == null && b[prop] != null) {
988 return -1;
989 }
990 if (a[prop] != null && b[prop] == null) {
991 return 1;
992 }
993 if (a[prop] == null && b[prop] == null) {
994 return 0;
995 }
996 return i18nService.collator ? i18nService.collator.compare(a[prop], b[prop]) :
997 a[prop].localeCompare(b[prop]);
998 };
999 }
1000 static isNullOrWhitespace(str) {
1001 return str == null || typeof str !== 'string' || str.trim() === '';
1002 }
1003 static validIpAddress(ipString) {
1004 // tslint:disable-next-line
1005 const ipRegex = /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;
1006 return ipRegex.test(ipString);
1007 }
1008 static isMobile(win) {
1009 let mobile = false;
1010 ((a) => {
1011 // tslint:disable-next-line
1012 if (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0, 4))) {
1013 mobile = true;
1014 }
1015 })(win.navigator.userAgent || win.navigator.vendor || win.opera);
1016 return mobile || win.navigator.userAgent.match(/iPad/i) != null;
1017 }
1018 static isAppleMobile(win) {
1019 return win.navigator.userAgent.match(/iPhone/i) != null || win.navigator.userAgent.match(/iPad/i) != null;
1020 }
1021 static getUrl(uriString) {
1022 if (uriString == null) {
1023 return null;
1024 }
1025 uriString = uriString.trim();
1026 if (uriString === '') {
1027 return null;
1028 }
1029 let url = utils_Utils.getUrlObject(uriString);
1030 if (url == null) {
1031 const hasHttpProtocol = uriString.indexOf('http://') === 0 || uriString.indexOf('https://') === 0;
1032 if (!hasHttpProtocol && uriString.indexOf('.') > -1) {
1033 url = utils_Utils.getUrlObject('http://' + uriString);
1034 }
1035 }
1036 return url;
1037 }
1038 static getUrlObject(uriString) {
1039 try {
1040 if (nodeURL != null) {
1041 return nodeURL.URL ? new nodeURL.URL(uriString) : nodeURL.parse(uriString);
1042 }
1043 else if (typeof URL === 'function') {
1044 return new URL(uriString);
1045 }
1046 else if (window != null) {
1047 const hasProtocol = uriString.indexOf('://') > -1;
1048 if (!hasProtocol && uriString.indexOf('.') > -1) {
1049 uriString = 'http://' + uriString;
1050 }
1051 else if (!hasProtocol) {
1052 return null;
1053 }
1054 const anchor = window.document.createElement('a');
1055 anchor.href = uriString;
1056 return anchor;
1057 }
1058 }
1059 catch (e) { }
1060 return null;
1061 }
1062}
1063utils_Utils.inited = false;
1064utils_Utils.isNativeScript = false;
1065utils_Utils.isNode = false;
1066utils_Utils.isBrowser = true;
1067utils_Utils.isMobileBrowser = false;
1068utils_Utils.isAppleMobileBrowser = false;
1069utils_Utils.global = null;
1070utils_Utils.tldEndingRegex = /.*\.(com|net|org|edu|uk|gov|ca|de|jp|fr|au|ru|ch|io|es|us|co|xyz|info|ly|mil)$/;
1071utils_Utils.init();
1072
1073// CONCATENATED MODULE: ./jslib/src/models/domain/cipherString.ts
1074var cipherString_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
1075 return new (P || (P = Promise))(function (resolve, reject) {
1076 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
1077 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
1078 function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
1079 step((generator = generator.apply(thisArg, _arguments || [])).next());
1080 });
1081};
1082
1083
1084class cipherString_CipherString {
1085 constructor(encryptedStringOrType, data, iv, mac) {
1086 if (data != null) {
1087 // data and header
1088 const encType = encryptedStringOrType;
1089 if (iv != null) {
1090 this.encryptedString = encType + '.' + iv + '|' + data;
1091 }
1092 else {
1093 this.encryptedString = encType + '.' + data;
1094 }
1095 // mac
1096 if (mac != null) {
1097 this.encryptedString += ('|' + mac);
1098 }
1099 this.encryptionType = encType;
1100 this.data = data;
1101 this.iv = iv;
1102 this.mac = mac;
1103 return;
1104 }
1105 this.encryptedString = encryptedStringOrType;
1106 if (!this.encryptedString) {
1107 return;
1108 }
1109 const headerPieces = this.encryptedString.split('.');
1110 let encPieces = null;
1111 if (headerPieces.length === 2) {
1112 try {
1113 this.encryptionType = parseInt(headerPieces[0], null);
1114 encPieces = headerPieces[1].split('|');
1115 }
1116 catch (e) {
1117 return;
1118 }
1119 }
1120 else {
1121 encPieces = this.encryptedString.split('|');
1122 this.encryptionType = encPieces.length === 3 ? EncryptionType.AesCbc128_HmacSha256_B64 :
1123 EncryptionType.AesCbc256_B64;
1124 }
1125 switch (this.encryptionType) {
1126 case EncryptionType.AesCbc128_HmacSha256_B64:
1127 case EncryptionType.AesCbc256_HmacSha256_B64:
1128 if (encPieces.length !== 3) {
1129 return;
1130 }
1131 this.iv = encPieces[0];
1132 this.data = encPieces[1];
1133 this.mac = encPieces[2];
1134 break;
1135 case EncryptionType.AesCbc256_B64:
1136 if (encPieces.length !== 2) {
1137 return;
1138 }
1139 this.iv = encPieces[0];
1140 this.data = encPieces[1];
1141 break;
1142 case EncryptionType.Rsa2048_OaepSha256_B64:
1143 case EncryptionType.Rsa2048_OaepSha1_B64:
1144 if (encPieces.length !== 1) {
1145 return;
1146 }
1147 this.data = encPieces[0];
1148 break;
1149 default:
1150 return;
1151 }
1152 }
1153 decrypt(orgId) {
1154 return cipherString_awaiter(this, void 0, void 0, function* () {
1155 if (this.decryptedValue != null) {
1156 return this.decryptedValue;
1157 }
1158 let cryptoService;
1159 const containerService = utils_Utils.global.bitwardenContainerService;
1160 if (containerService) {
1161 cryptoService = containerService.getCryptoService();
1162 }
1163 else {
1164 throw new Error('global bitwardenContainerService not initialized.');
1165 }
1166 try {
1167 const orgKey = yield cryptoService.getOrgKey(orgId);
1168 this.decryptedValue = yield cryptoService.decryptToUtf8(this, orgKey);
1169 }
1170 catch (e) {
1171 this.decryptedValue = '[error: cannot decrypt]';
1172 }
1173 return this.decryptedValue;
1174 });
1175 }
1176}
1177
1178// CONCATENATED MODULE: ./jslib/src/models/domain/domainBase.ts
1179var domainBase_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
1180 return new (P || (P = Promise))(function (resolve, reject) {
1181 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
1182 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
1183 function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
1184 step((generator = generator.apply(thisArg, _arguments || [])).next());
1185 });
1186};
1187
1188class domainBase_Domain {
1189 buildDomainModel(domain, dataObj, map, alreadyEncrypted, notEncList = []) {
1190 for (const prop in map) {
1191 if (!map.hasOwnProperty(prop)) {
1192 continue;
1193 }
1194 const objProp = dataObj[(map[prop] || prop)];
1195 if (alreadyEncrypted === true || notEncList.indexOf(prop) > -1) {
1196 domain[prop] = objProp ? objProp : null;
1197 }
1198 else {
1199 domain[prop] = objProp ? new cipherString_CipherString(objProp) : null;
1200 }
1201 }
1202 }
1203 buildDataModel(domain, dataObj, map, notCipherStringList = []) {
1204 for (const prop in map) {
1205 if (!map.hasOwnProperty(prop)) {
1206 continue;
1207 }
1208 const objProp = domain[(map[prop] || prop)];
1209 if (notCipherStringList.indexOf(prop) > -1) {
1210 dataObj[prop] = objProp != null ? objProp : null;
1211 }
1212 else {
1213 dataObj[prop] = objProp != null ? objProp.encryptedString : null;
1214 }
1215 }
1216 }
1217 decryptObj(viewModel, map, orgId) {
1218 return domainBase_awaiter(this, void 0, void 0, function* () {
1219 const promises = [];
1220 const self = this;
1221 for (const prop in map) {
1222 if (!map.hasOwnProperty(prop)) {
1223 continue;
1224 }
1225 // tslint:disable-next-line
1226 (function (theProp) {
1227 const p = Promise.resolve().then(() => {
1228 const mapProp = map[theProp] || theProp;
1229 if (self[mapProp]) {
1230 return self[mapProp].decrypt(orgId);
1231 }
1232 return null;
1233 }).then((val) => {
1234 viewModel[theProp] = val;
1235 });
1236 promises.push(p);
1237 })(prop);
1238 }
1239 yield Promise.all(promises);
1240 return viewModel;
1241 });
1242 }
1243}
1244
1245// CONCATENATED MODULE: ./jslib/src/models/domain/symmetricCryptoKey.ts
1246
1247
1248class symmetricCryptoKey_SymmetricCryptoKey {
1249 constructor(key, encType) {
1250 if (key == null) {
1251 throw new Error('Must provide key');
1252 }
1253 if (encType == null) {
1254 if (key.byteLength === 32) {
1255 encType = EncryptionType.AesCbc256_B64;
1256 }
1257 else if (key.byteLength === 64) {
1258 encType = EncryptionType.AesCbc256_HmacSha256_B64;
1259 }
1260 else {
1261 throw new Error('Unable to determine encType.');
1262 }
1263 }
1264 this.key = key;
1265 this.encType = encType;
1266 if (encType === EncryptionType.AesCbc256_B64 && key.byteLength === 32) {
1267 this.encKey = key;
1268 this.macKey = null;
1269 }
1270 else if (encType === EncryptionType.AesCbc128_HmacSha256_B64 && key.byteLength === 32) {
1271 this.encKey = key.slice(0, 16);
1272 this.macKey = key.slice(16, 32);
1273 }
1274 else if (encType === EncryptionType.AesCbc256_HmacSha256_B64 && key.byteLength === 64) {
1275 this.encKey = key.slice(0, 32);
1276 this.macKey = key.slice(32, 64);
1277 }
1278 else {
1279 throw new Error('Unsupported encType/key length.');
1280 }
1281 if (this.key != null) {
1282 this.keyB64 = utils_Utils.fromBufferToB64(this.key);
1283 }
1284 if (this.encKey != null) {
1285 this.encKeyB64 = utils_Utils.fromBufferToB64(this.encKey);
1286 }
1287 if (this.macKey != null) {
1288 this.macKeyB64 = utils_Utils.fromBufferToB64(this.macKey);
1289 }
1290 }
1291}
1292
1293// CONCATENATED MODULE: ./jslib/src/models/domain/attachment.ts
1294var attachment_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
1295 return new (P || (P = Promise))(function (resolve, reject) {
1296 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
1297 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
1298 function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
1299 step((generator = generator.apply(thisArg, _arguments || [])).next());
1300 });
1301};
1302
1303
1304
1305
1306
1307class attachment_Attachment extends domainBase_Domain {
1308 constructor(obj, alreadyEncrypted = false) {
1309 super();
1310 if (obj == null) {
1311 return;
1312 }
1313 this.size = obj.size;
1314 this.buildDomainModel(this, obj, {
1315 id: null,
1316 url: null,
1317 sizeName: null,
1318 fileName: null,
1319 key: null,
1320 }, alreadyEncrypted, ['id', 'url', 'sizeName']);
1321 }
1322 decrypt(orgId) {
1323 return attachment_awaiter(this, void 0, void 0, function* () {
1324 const view = yield this.decryptObj(new AttachmentView(this), {
1325 fileName: null,
1326 }, orgId);
1327 if (this.key != null) {
1328 let cryptoService;
1329 const containerService = utils_Utils.global.bitwardenContainerService;
1330 if (containerService) {
1331 cryptoService = containerService.getCryptoService();
1332 }
1333 else {
1334 throw new Error('global bitwardenContainerService not initialized.');
1335 }
1336 try {
1337 const orgKey = yield cryptoService.getOrgKey(orgId);
1338 const decValue = yield cryptoService.decryptToBytes(this.key, orgKey);
1339 view.key = new symmetricCryptoKey_SymmetricCryptoKey(decValue);
1340 }
1341 catch (e) {
1342 // TODO: error?
1343 }
1344 }
1345 return view;
1346 });
1347 }
1348 toAttachmentData() {
1349 const a = new AttachmentData();
1350 a.size = this.size;
1351 this.buildDataModel(this, a, {
1352 id: null,
1353 url: null,
1354 sizeName: null,
1355 fileName: null,
1356 key: null,
1357 }, ['id', 'url', 'sizeName']);
1358 return a;
1359 }
1360}
1361
1362// CONCATENATED MODULE: ./jslib/src/models/data/cardData.ts
1363class CardData {
1364 constructor(data) {
1365 if (data == null) {
1366 return;
1367 }
1368 this.cardholderName = data.cardholderName;
1369 this.brand = data.brand;
1370 this.number = data.number;
1371 this.expMonth = data.expMonth;
1372 this.expYear = data.expYear;
1373 this.code = data.code;
1374 }
1375}
1376
1377// CONCATENATED MODULE: ./jslib/src/models/view/cardView.ts
1378class CardView {
1379 // tslint:enable
1380 constructor(c) {
1381 this.cardholderName = null;
1382 this.expMonth = null;
1383 this.expYear = null;
1384 this.code = null;
1385 // tslint:disable
1386 this._brand = null;
1387 this._number = null;
1388 this._subTitle = null;
1389 // ctor
1390 }
1391 get maskedCode() {
1392 return this.code != null ? '•'.repeat(this.code.length) : null;
1393 }
1394 get brand() {
1395 return this._brand;
1396 }
1397 set brand(value) {
1398 this._brand = value;
1399 this._subTitle = null;
1400 }
1401 get number() {
1402 return this._number;
1403 }
1404 set number(value) {
1405 this._number = value;
1406 this._subTitle = null;
1407 }
1408 get subTitle() {
1409 if (this._subTitle == null) {
1410 this._subTitle = this.brand;
1411 if (this.number != null && this.number.length >= 4) {
1412 if (this._subTitle != null && this._subTitle !== '') {
1413 this._subTitle += ', ';
1414 }
1415 else {
1416 this._subTitle = '';
1417 }
1418 // Show last 5 on amex, last 4 for all others
1419 const count = this.number.length >= 5 && this.number.match(new RegExp('^3[47]')) != null ? 5 : 4;
1420 this._subTitle += ('*' + this.number.substr(this.number.length - count));
1421 }
1422 }
1423 return this._subTitle;
1424 }
1425 get expiration() {
1426 if (!this.expMonth && !this.expYear) {
1427 return null;
1428 }
1429 let exp = this.expMonth != null ? ('0' + this.expMonth).slice(-2) : '__';
1430 exp += (' / ' + (this.expYear != null ? this.formatYear(this.expYear) : '____'));
1431 return exp;
1432 }
1433 formatYear(year) {
1434 return year.length === 2 ? '20' + year : year;
1435 }
1436}
1437
1438// CONCATENATED MODULE: ./jslib/src/models/domain/card.ts
1439
1440
1441
1442class card_Card extends domainBase_Domain {
1443 constructor(obj, alreadyEncrypted = false) {
1444 super();
1445 if (obj == null) {
1446 return;
1447 }
1448 this.buildDomainModel(this, obj, {
1449 cardholderName: null,
1450 brand: null,
1451 number: null,
1452 expMonth: null,
1453 expYear: null,
1454 code: null,
1455 }, alreadyEncrypted, []);
1456 }
1457 decrypt(orgId) {
1458 return this.decryptObj(new CardView(this), {
1459 cardholderName: null,
1460 brand: null,
1461 number: null,
1462 expMonth: null,
1463 expYear: null,
1464 code: null,
1465 }, orgId);
1466 }
1467 toCardData() {
1468 const c = new CardData();
1469 this.buildDataModel(this, c, {
1470 cardholderName: null,
1471 brand: null,
1472 number: null,
1473 expMonth: null,
1474 expYear: null,
1475 code: null,
1476 });
1477 return c;
1478 }
1479}
1480
1481// CONCATENATED MODULE: ./jslib/src/enums/cipherType.ts
1482var CipherType;
1483(function (CipherType) {
1484 CipherType[CipherType["Login"] = 1] = "Login";
1485 CipherType[CipherType["SecureNote"] = 2] = "SecureNote";
1486 CipherType[CipherType["Card"] = 3] = "Card";
1487 CipherType[CipherType["Identity"] = 4] = "Identity";
1488})(CipherType || (CipherType = {}));
1489
1490// CONCATENATED MODULE: ./jslib/src/models/data/fieldData.ts
1491class FieldData {
1492 constructor(response) {
1493 if (response == null) {
1494 return;
1495 }
1496 this.type = response.type;
1497 this.name = response.name;
1498 this.value = response.value;
1499 }
1500}
1501
1502// CONCATENATED MODULE: ./jslib/src/models/data/identityData.ts
1503class IdentityData {
1504 constructor(data) {
1505 if (data == null) {
1506 return;
1507 }
1508 this.title = data.title;
1509 this.firstName = data.firstName;
1510 this.middleName = data.middleName;
1511 this.lastName = data.lastName;
1512 this.address1 = data.address1;
1513 this.address2 = data.address2;
1514 this.address3 = data.address3;
1515 this.city = data.city;
1516 this.state = data.state;
1517 this.postalCode = data.postalCode;
1518 this.country = data.country;
1519 this.company = data.company;
1520 this.email = data.email;
1521 this.phone = data.phone;
1522 this.ssn = data.ssn;
1523 this.username = data.username;
1524 this.passportNumber = data.passportNumber;
1525 this.licenseNumber = data.licenseNumber;
1526 }
1527}
1528
1529// CONCATENATED MODULE: ./jslib/src/models/data/loginUriData.ts
1530class LoginUriData {
1531 constructor(data) {
1532 this.match = null;
1533 if (data == null) {
1534 return;
1535 }
1536 this.uri = data.uri;
1537 this.match = data.match;
1538 }
1539}
1540
1541// CONCATENATED MODULE: ./jslib/src/models/data/loginData.ts
1542
1543class loginData_LoginData {
1544 constructor(data) {
1545 if (data == null) {
1546 return;
1547 }
1548 this.username = data.username;
1549 this.password = data.password;
1550 this.passwordRevisionDate = data.passwordRevisionDate;
1551 this.totp = data.totp;
1552 if (data.uris) {
1553 this.uris = data.uris.map((u) => new LoginUriData(u));
1554 }
1555 }
1556}
1557
1558// CONCATENATED MODULE: ./jslib/src/models/data/passwordHistoryData.ts
1559class PasswordHistoryData {
1560 constructor(response) {
1561 if (response == null) {
1562 return;
1563 }
1564 this.password = response.password;
1565 this.lastUsedDate = response.lastUsedDate;
1566 }
1567}
1568
1569// CONCATENATED MODULE: ./jslib/src/models/data/secureNoteData.ts
1570class SecureNoteData {
1571 constructor(data) {
1572 if (data == null) {
1573 return;
1574 }
1575 this.type = data.type;
1576 }
1577}
1578
1579// CONCATENATED MODULE: ./jslib/src/models/data/cipherData.ts
1580
1581
1582
1583
1584
1585
1586
1587
1588class cipherData_CipherData {
1589 constructor(response, userId, collectionIds) {
1590 if (response == null) {
1591 return;
1592 }
1593 this.id = response.id;
1594 this.organizationId = response.organizationId;
1595 this.folderId = response.folderId;
1596 this.userId = userId;
1597 this.edit = response.edit;
1598 this.viewPassword = response.viewPassword;
1599 this.organizationUseTotp = response.organizationUseTotp;
1600 this.favorite = response.favorite;
1601 this.revisionDate = response.revisionDate;
1602 this.type = response.type;
1603 this.name = response.name;
1604 this.notes = response.notes;
1605 this.collectionIds = collectionIds != null ? collectionIds : response.collectionIds;
1606 this.deletedDate = response.deletedDate;
1607 switch (this.type) {
1608 case CipherType.Login:
1609 this.login = new loginData_LoginData(response.login);
1610 break;
1611 case CipherType.SecureNote:
1612 this.secureNote = new SecureNoteData(response.secureNote);
1613 break;
1614 case CipherType.Card:
1615 this.card = new CardData(response.card);
1616 break;
1617 case CipherType.Identity:
1618 this.identity = new IdentityData(response.identity);
1619 break;
1620 default:
1621 break;
1622 }
1623 if (response.fields != null) {
1624 this.fields = response.fields.map((f) => new FieldData(f));
1625 }
1626 if (response.attachments != null) {
1627 this.attachments = response.attachments.map((a) => new AttachmentData(a));
1628 }
1629 if (response.passwordHistory != null) {
1630 this.passwordHistory = response.passwordHistory.map((ph) => new PasswordHistoryData(ph));
1631 }
1632 }
1633}
1634
1635// CONCATENATED MODULE: ./jslib/src/models/view/identityView.ts
1636
1637class identityView_IdentityView {
1638 // tslint:enable
1639 constructor(i) {
1640 this.title = null;
1641 this.middleName = null;
1642 this.address1 = null;
1643 this.address2 = null;
1644 this.address3 = null;
1645 this.city = null;
1646 this.state = null;
1647 this.postalCode = null;
1648 this.country = null;
1649 this.company = null;
1650 this.email = null;
1651 this.phone = null;
1652 this.ssn = null;
1653 this.username = null;
1654 this.passportNumber = null;
1655 this.licenseNumber = null;
1656 // tslint:disable
1657 this._firstName = null;
1658 this._lastName = null;
1659 this._subTitle = null;
1660 // ctor
1661 }
1662 get firstName() {
1663 return this._firstName;
1664 }
1665 set firstName(value) {
1666 this._firstName = value;
1667 this._subTitle = null;
1668 }
1669 get lastName() {
1670 return this._lastName;
1671 }
1672 set lastName(value) {
1673 this._lastName = value;
1674 this._subTitle = null;
1675 }
1676 get subTitle() {
1677 if (this._subTitle == null && (this.firstName != null || this.lastName != null)) {
1678 this._subTitle = '';
1679 if (this.firstName != null) {
1680 this._subTitle = this.firstName;
1681 }
1682 if (this.lastName != null) {
1683 if (this._subTitle !== '') {
1684 this._subTitle += ' ';
1685 }
1686 this._subTitle += this.lastName;
1687 }
1688 }
1689 return this._subTitle;
1690 }
1691 get fullName() {
1692 if (this.title != null || this.firstName != null || this.middleName != null || this.lastName != null) {
1693 let name = '';
1694 if (this.title != null) {
1695 name += (this.title + ' ');
1696 }
1697 if (this.firstName != null) {
1698 name += (this.firstName + ' ');
1699 }
1700 if (this.middleName != null) {
1701 name += (this.middleName + ' ');
1702 }
1703 if (this.lastName != null) {
1704 name += this.lastName;
1705 }
1706 return name.trim();
1707 }
1708 return null;
1709 }
1710 get fullAddress() {
1711 let address = this.address1;
1712 if (!utils_Utils.isNullOrWhitespace(this.address2)) {
1713 if (!utils_Utils.isNullOrWhitespace(address)) {
1714 address += ', ';
1715 }
1716 address += this.address2;
1717 }
1718 if (!utils_Utils.isNullOrWhitespace(this.address3)) {
1719 if (!utils_Utils.isNullOrWhitespace(address)) {
1720 address += ', ';
1721 }
1722 address += this.address3;
1723 }
1724 return address;
1725 }
1726 get fullAddressPart2() {
1727 if (this.city == null && this.state == null && this.postalCode == null) {
1728 return null;
1729 }
1730 const city = this.city || '-';
1731 const state = this.state;
1732 const postalCode = this.postalCode || '-';
1733 let addressPart2 = city;
1734 if (!utils_Utils.isNullOrWhitespace(state)) {
1735 addressPart2 += ', ' + state;
1736 }
1737 addressPart2 += ', ' + postalCode;
1738 return addressPart2;
1739 }
1740}
1741
1742// CONCATENATED MODULE: ./jslib/src/models/view/loginView.ts
1743class LoginView {
1744 constructor(l) {
1745 this.username = null;
1746 this.password = null;
1747 this.passwordRevisionDate = null;
1748 this.totp = null;
1749 this.uris = null;
1750 if (!l) {
1751 return;
1752 }
1753 this.passwordRevisionDate = l.passwordRevisionDate;
1754 }
1755 get uri() {
1756 return this.hasUris ? this.uris[0].uri : null;
1757 }
1758 get maskedPassword() {
1759 return this.password != null ? '••••••••' : null;
1760 }
1761 get subTitle() {
1762 return this.username;
1763 }
1764 get canLaunch() {
1765 return this.hasUris && this.uris.some((u) => u.canLaunch);
1766 }
1767 get launchUri() {
1768 if (this.hasUris) {
1769 const uri = this.uris.find((u) => u.canLaunch);
1770 if (uri != null) {
1771 return uri.launchUri;
1772 }
1773 }
1774 return null;
1775 }
1776 get hasUris() {
1777 return this.uris != null && this.uris.length > 0;
1778 }
1779}
1780
1781// CONCATENATED MODULE: ./jslib/src/models/view/secureNoteView.ts
1782class SecureNoteView {
1783 constructor(n) {
1784 this.type = null;
1785 if (!n) {
1786 return;
1787 }
1788 this.type = n.type;
1789 }
1790 get subTitle() {
1791 return null;
1792 }
1793}
1794
1795// CONCATENATED MODULE: ./jslib/src/models/view/cipherView.ts
1796
1797
1798
1799
1800
1801class cipherView_CipherView {
1802 constructor(c) {
1803 this.id = null;
1804 this.organizationId = null;
1805 this.folderId = null;
1806 this.name = null;
1807 this.notes = null;
1808 this.type = null;
1809 this.favorite = false;
1810 this.organizationUseTotp = false;
1811 this.edit = false;
1812 this.viewPassword = true;
1813 this.login = new LoginView();
1814 this.identity = new identityView_IdentityView();
1815 this.card = new CardView();
1816 this.secureNote = new SecureNoteView();
1817 this.attachments = null;
1818 this.fields = null;
1819 this.passwordHistory = null;
1820 this.collectionIds = null;
1821 this.revisionDate = null;
1822 this.deletedDate = null;
1823 if (!c) {
1824 return;
1825 }
1826 this.id = c.id;
1827 this.organizationId = c.organizationId;
1828 this.folderId = c.folderId;
1829 this.favorite = c.favorite;
1830 this.organizationUseTotp = c.organizationUseTotp;
1831 this.edit = c.edit;
1832 this.viewPassword = c.viewPassword;
1833 this.type = c.type;
1834 this.localData = c.localData;
1835 this.collectionIds = c.collectionIds;
1836 this.revisionDate = c.revisionDate;
1837 this.deletedDate = c.deletedDate;
1838 }
1839 get subTitle() {
1840 switch (this.type) {
1841 case CipherType.Login:
1842 return this.login.subTitle;
1843 case CipherType.SecureNote:
1844 return this.secureNote.subTitle;
1845 case CipherType.Card:
1846 return this.card.subTitle;
1847 case CipherType.Identity:
1848 return this.identity.subTitle;
1849 default:
1850 break;
1851 }
1852 return null;
1853 }
1854 get hasPasswordHistory() {
1855 return this.passwordHistory && this.passwordHistory.length > 0;
1856 }
1857 get hasAttachments() {
1858 return this.attachments && this.attachments.length > 0;
1859 }
1860 get hasOldAttachments() {
1861 if (this.hasAttachments) {
1862 for (let i = 0; i < this.attachments.length; i++) {
1863 if (this.attachments[i].key == null) {
1864 return true;
1865 }
1866 }
1867 }
1868 return false;
1869 }
1870 get hasFields() {
1871 return this.fields && this.fields.length > 0;
1872 }
1873 get passwordRevisionDisplayDate() {
1874 if (this.type !== CipherType.Login || this.login == null) {
1875 return null;
1876 }
1877 else if (this.login.password == null || this.login.password === '') {
1878 return null;
1879 }
1880 return this.login.passwordRevisionDate;
1881 }
1882 get isDeleted() {
1883 return this.deletedDate != null;
1884 }
1885}
1886
1887// CONCATENATED MODULE: ./jslib/src/models/view/fieldView.ts
1888class FieldView {
1889 constructor(f) {
1890 this.name = null;
1891 this.value = null;
1892 this.type = null;
1893 this.newField = false; // Marks if the field is new and hasn't been saved
1894 if (!f) {
1895 return;
1896 }
1897 this.type = f.type;
1898 }
1899 get maskedValue() {
1900 return this.value != null ? '••••••••' : null;
1901 }
1902}
1903
1904// CONCATENATED MODULE: ./jslib/src/models/domain/field.ts
1905
1906
1907
1908class field_Field extends domainBase_Domain {
1909 constructor(obj, alreadyEncrypted = false) {
1910 super();
1911 if (obj == null) {
1912 return;
1913 }
1914 this.type = obj.type;
1915 this.buildDomainModel(this, obj, {
1916 name: null,
1917 value: null,
1918 }, alreadyEncrypted, []);
1919 }
1920 decrypt(orgId) {
1921 return this.decryptObj(new FieldView(this), {
1922 name: null,
1923 value: null,
1924 }, orgId);
1925 }
1926 toFieldData() {
1927 const f = new FieldData();
1928 this.buildDataModel(this, f, {
1929 name: null,
1930 value: null,
1931 type: null,
1932 }, ['type']);
1933 return f;
1934 }
1935}
1936
1937// CONCATENATED MODULE: ./jslib/src/models/domain/identity.ts
1938
1939
1940
1941class identity_Identity extends domainBase_Domain {
1942 constructor(obj, alreadyEncrypted = false) {
1943 super();
1944 if (obj == null) {
1945 return;
1946 }
1947 this.buildDomainModel(this, obj, {
1948 title: null,
1949 firstName: null,
1950 middleName: null,
1951 lastName: null,
1952 address1: null,
1953 address2: null,
1954 address3: null,
1955 city: null,
1956 state: null,
1957 postalCode: null,
1958 country: null,
1959 company: null,
1960 email: null,
1961 phone: null,
1962 ssn: null,
1963 username: null,
1964 passportNumber: null,
1965 licenseNumber: null,
1966 }, alreadyEncrypted, []);
1967 }
1968 decrypt(orgId) {
1969 return this.decryptObj(new identityView_IdentityView(this), {
1970 title: null,
1971 firstName: null,
1972 middleName: null,
1973 lastName: null,
1974 address1: null,
1975 address2: null,
1976 address3: null,
1977 city: null,
1978 state: null,
1979 postalCode: null,
1980 country: null,
1981 company: null,
1982 email: null,
1983 phone: null,
1984 ssn: null,
1985 username: null,
1986 passportNumber: null,
1987 licenseNumber: null,
1988 }, orgId);
1989 }
1990 toIdentityData() {
1991 const i = new IdentityData();
1992 this.buildDataModel(this, i, {
1993 title: null,
1994 firstName: null,
1995 middleName: null,
1996 lastName: null,
1997 address1: null,
1998 address2: null,
1999 address3: null,
2000 city: null,
2001 state: null,
2002 postalCode: null,
2003 country: null,
2004 company: null,
2005 email: null,
2006 phone: null,
2007 ssn: null,
2008 username: null,
2009 passportNumber: null,
2010 licenseNumber: null,
2011 });
2012 return i;
2013 }
2014}
2015
2016// CONCATENATED MODULE: ./jslib/src/enums/uriMatchType.ts
2017var UriMatchType;
2018(function (UriMatchType) {
2019 UriMatchType[UriMatchType["Domain"] = 0] = "Domain";
2020 UriMatchType[UriMatchType["Host"] = 1] = "Host";
2021 UriMatchType[UriMatchType["StartsWith"] = 2] = "StartsWith";
2022 UriMatchType[UriMatchType["Exact"] = 3] = "Exact";
2023 UriMatchType[UriMatchType["RegularExpression"] = 4] = "RegularExpression";
2024 UriMatchType[UriMatchType["Never"] = 5] = "Never";
2025})(UriMatchType || (UriMatchType = {}));
2026
2027// CONCATENATED MODULE: ./jslib/src/models/view/loginUriView.ts
2028
2029
2030const CanLaunchWhitelist = [
2031 'https://',
2032 'http://',
2033 'ssh://',
2034 'ftp://',
2035 'sftp://',
2036 'irc://',
2037 'vnc://',
2038 'chrome://',
2039 'iosapp://',
2040 'androidapp://',
2041];
2042class loginUriView_LoginUriView {
2043 // tslint:enable
2044 constructor(u) {
2045 this.match = null;
2046 // tslint:disable
2047 this._uri = null;
2048 this._domain = null;
2049 this._hostname = null;
2050 this._canLaunch = null;
2051 if (!u) {
2052 return;
2053 }
2054 this.match = u.match;
2055 }
2056 get uri() {
2057 return this._uri;
2058 }
2059 set uri(value) {
2060 this._uri = value;
2061 this._domain = null;
2062 this._canLaunch = null;
2063 }
2064 get domain() {
2065 if (this._domain == null && this.uri != null) {
2066 this._domain = utils_Utils.getDomain(this.uri);
2067 if (this._domain === '') {
2068 this._domain = null;
2069 }
2070 }
2071 return this._domain;
2072 }
2073 get hostname() {
2074 if (this.match === UriMatchType.RegularExpression) {
2075 return null;
2076 }
2077 if (this._hostname == null && this.uri != null) {
2078 this._hostname = utils_Utils.getHostname(this.uri);
2079 if (this._hostname === '') {
2080 this._hostname = null;
2081 }
2082 }
2083 return this._hostname;
2084 }
2085 get hostnameOrUri() {
2086 return this.hostname != null ? this.hostname : this.uri;
2087 }
2088 get isWebsite() {
2089 return this.uri != null && (this.uri.indexOf('http://') === 0 || this.uri.indexOf('https://') === 0 ||
2090 (this.uri.indexOf('://') < 0 && utils_Utils.tldEndingRegex.test(this.uri)));
2091 }
2092 get canLaunch() {
2093 if (this._canLaunch != null) {
2094 return this._canLaunch;
2095 }
2096 if (this.uri != null && this.match !== UriMatchType.RegularExpression) {
2097 const uri = this.launchUri;
2098 for (let i = 0; i < CanLaunchWhitelist.length; i++) {
2099 if (uri.indexOf(CanLaunchWhitelist[i]) === 0) {
2100 this._canLaunch = true;
2101 return this._canLaunch;
2102 }
2103 }
2104 }
2105 this._canLaunch = false;
2106 return this._canLaunch;
2107 }
2108 get launchUri() {
2109 return this.uri.indexOf('://') < 0 && utils_Utils.tldEndingRegex.test(this.uri) ? ('http://' + this.uri) : this.uri;
2110 }
2111}
2112
2113// CONCATENATED MODULE: ./jslib/src/models/domain/loginUri.ts
2114
2115
2116
2117class loginUri_LoginUri extends domainBase_Domain {
2118 constructor(obj, alreadyEncrypted = false) {
2119 super();
2120 if (obj == null) {
2121 return;
2122 }
2123 this.match = obj.match;
2124 this.buildDomainModel(this, obj, {
2125 uri: null,
2126 }, alreadyEncrypted, []);
2127 }
2128 decrypt(orgId) {
2129 return this.decryptObj(new loginUriView_LoginUriView(this), {
2130 uri: null,
2131 }, orgId);
2132 }
2133 toLoginUriData() {
2134 const u = new LoginUriData();
2135 this.buildDataModel(this, u, {
2136 uri: null,
2137 }, ['match']);
2138 return u;
2139 }
2140}
2141
2142// CONCATENATED MODULE: ./jslib/src/models/domain/login.ts
2143var login_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
2144 return new (P || (P = Promise))(function (resolve, reject) {
2145 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
2146 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
2147 function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
2148 step((generator = generator.apply(thisArg, _arguments || [])).next());
2149 });
2150};
2151
2152
2153
2154
2155class login_Login extends domainBase_Domain {
2156 constructor(obj, alreadyEncrypted = false) {
2157 super();
2158 if (obj == null) {
2159 return;
2160 }
2161 this.passwordRevisionDate = obj.passwordRevisionDate != null ? new Date(obj.passwordRevisionDate) : null;
2162 this.buildDomainModel(this, obj, {
2163 username: null,
2164 password: null,
2165 totp: null,
2166 }, alreadyEncrypted, []);
2167 if (obj.uris) {
2168 this.uris = [];
2169 obj.uris.forEach((u) => {
2170 this.uris.push(new loginUri_LoginUri(u, alreadyEncrypted));
2171 });
2172 }
2173 }
2174 decrypt(orgId) {
2175 return login_awaiter(this, void 0, void 0, function* () {
2176 const view = yield this.decryptObj(new LoginView(this), {
2177 username: null,
2178 password: null,
2179 totp: null,
2180 }, orgId);
2181 if (this.uris != null) {
2182 view.uris = [];
2183 for (let i = 0; i < this.uris.length; i++) {
2184 const uri = yield this.uris[i].decrypt(orgId);
2185 view.uris.push(uri);
2186 }
2187 }
2188 return view;
2189 });
2190 }
2191 toLoginData() {
2192 const l = new loginData_LoginData();
2193 l.passwordRevisionDate = this.passwordRevisionDate != null ? this.passwordRevisionDate.toISOString() : null;
2194 this.buildDataModel(this, l, {
2195 username: null,
2196 password: null,
2197 totp: null,
2198 });
2199 if (this.uris != null && this.uris.length > 0) {
2200 l.uris = [];
2201 this.uris.forEach((u) => {
2202 l.uris.push(u.toLoginUriData());
2203 });
2204 }
2205 return l;
2206 }
2207}
2208
2209// CONCATENATED MODULE: ./jslib/src/models/view/passwordHistoryView.ts
2210class PasswordHistoryView {
2211 constructor(ph) {
2212 this.password = null;
2213 this.lastUsedDate = null;
2214 if (!ph) {
2215 return;
2216 }
2217 this.lastUsedDate = ph.lastUsedDate;
2218 }
2219}
2220
2221// CONCATENATED MODULE: ./jslib/src/models/domain/password.ts
2222
2223
2224
2225class password_Password extends domainBase_Domain {
2226 constructor(obj, alreadyEncrypted = false) {
2227 super();
2228 if (obj == null) {
2229 return;
2230 }
2231 this.buildDomainModel(this, obj, {
2232 password: null,
2233 }, alreadyEncrypted);
2234 this.lastUsedDate = new Date(obj.lastUsedDate);
2235 }
2236 decrypt(orgId) {
2237 return this.decryptObj(new PasswordHistoryView(this), {
2238 password: null,
2239 }, orgId);
2240 }
2241 toPasswordHistoryData() {
2242 const ph = new PasswordHistoryData();
2243 ph.lastUsedDate = this.lastUsedDate.toISOString();
2244 this.buildDataModel(this, ph, {
2245 password: null,
2246 });
2247 return ph;
2248 }
2249}
2250
2251// CONCATENATED MODULE: ./jslib/src/models/domain/secureNote.ts
2252
2253
2254
2255class secureNote_SecureNote extends domainBase_Domain {
2256 constructor(obj, alreadyEncrypted = false) {
2257 super();
2258 if (obj == null) {
2259 return;
2260 }
2261 this.type = obj.type;
2262 }
2263 decrypt(orgId) {
2264 return Promise.resolve(new SecureNoteView(this));
2265 }
2266 toSecureNoteData() {
2267 const n = new SecureNoteData();
2268 n.type = this.type;
2269 return n;
2270 }
2271}
2272
2273// CONCATENATED MODULE: ./jslib/src/models/domain/cipher.ts
2274var cipher_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
2275 return new (P || (P = Promise))(function (resolve, reject) {
2276 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
2277 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
2278 function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
2279 step((generator = generator.apply(thisArg, _arguments || [])).next());
2280 });
2281};
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293class cipher_Cipher extends domainBase_Domain {
2294 constructor(obj, alreadyEncrypted = false, localData = null) {
2295 super();
2296 if (obj == null) {
2297 return;
2298 }
2299 this.buildDomainModel(this, obj, {
2300 id: null,
2301 userId: null,
2302 organizationId: null,
2303 folderId: null,
2304 name: null,
2305 notes: null,
2306 }, alreadyEncrypted, ['id', 'userId', 'organizationId', 'folderId']);
2307 this.type = obj.type;
2308 this.favorite = obj.favorite;
2309 this.organizationUseTotp = obj.organizationUseTotp;
2310 this.edit = obj.edit;
2311 if (obj.viewPassword != null) {
2312 this.viewPassword = obj.viewPassword;
2313 }
2314 else {
2315 this.viewPassword = true; // Default for already synced Ciphers without viewPassword
2316 }
2317 this.revisionDate = obj.revisionDate != null ? new Date(obj.revisionDate) : null;
2318 this.collectionIds = obj.collectionIds;
2319 this.localData = localData;
2320 this.deletedDate = obj.deletedDate != null ? new Date(obj.deletedDate) : null;
2321 switch (this.type) {
2322 case CipherType.Login:
2323 this.login = new login_Login(obj.login, alreadyEncrypted);
2324 break;
2325 case CipherType.SecureNote:
2326 this.secureNote = new secureNote_SecureNote(obj.secureNote, alreadyEncrypted);
2327 break;
2328 case CipherType.Card:
2329 this.card = new card_Card(obj.card, alreadyEncrypted);
2330 break;
2331 case CipherType.Identity:
2332 this.identity = new identity_Identity(obj.identity, alreadyEncrypted);
2333 break;
2334 default:
2335 break;
2336 }
2337 if (obj.attachments != null) {
2338 this.attachments = obj.attachments.map((a) => new attachment_Attachment(a, alreadyEncrypted));
2339 }
2340 else {
2341 this.attachments = null;
2342 }
2343 if (obj.fields != null) {
2344 this.fields = obj.fields.map((f) => new field_Field(f, alreadyEncrypted));
2345 }
2346 else {
2347 this.fields = null;
2348 }
2349 if (obj.passwordHistory != null) {
2350 this.passwordHistory = obj.passwordHistory.map((ph) => new password_Password(ph, alreadyEncrypted));
2351 }
2352 else {
2353 this.passwordHistory = null;
2354 }
2355 }
2356 decrypt() {
2357 return cipher_awaiter(this, void 0, void 0, function* () {
2358 const model = new cipherView_CipherView(this);
2359 yield this.decryptObj(model, {
2360 name: null,
2361 notes: null,
2362 }, this.organizationId);
2363 switch (this.type) {
2364 case CipherType.Login:
2365 model.login = yield this.login.decrypt(this.organizationId);
2366 break;
2367 case CipherType.SecureNote:
2368 model.secureNote = yield this.secureNote.decrypt(this.organizationId);
2369 break;
2370 case CipherType.Card:
2371 model.card = yield this.card.decrypt(this.organizationId);
2372 break;
2373 case CipherType.Identity:
2374 model.identity = yield this.identity.decrypt(this.organizationId);
2375 break;
2376 default:
2377 break;
2378 }
2379 const orgId = this.organizationId;
2380 if (this.attachments != null && this.attachments.length > 0) {
2381 const attachments = [];
2382 yield this.attachments.reduce((promise, attachment) => {
2383 return promise.then(() => {
2384 return attachment.decrypt(orgId);
2385 }).then((decAttachment) => {
2386 attachments.push(decAttachment);
2387 });
2388 }, Promise.resolve());
2389 model.attachments = attachments;
2390 }
2391 if (this.fields != null && this.fields.length > 0) {
2392 const fields = [];
2393 yield this.fields.reduce((promise, field) => {
2394 return promise.then(() => {
2395 return field.decrypt(orgId);
2396 }).then((decField) => {
2397 fields.push(decField);
2398 });
2399 }, Promise.resolve());
2400 model.fields = fields;
2401 }
2402 if (this.passwordHistory != null && this.passwordHistory.length > 0) {
2403 const passwordHistory = [];
2404 yield this.passwordHistory.reduce((promise, ph) => {
2405 return promise.then(() => {
2406 return ph.decrypt(orgId);
2407 }).then((decPh) => {
2408 passwordHistory.push(decPh);
2409 });
2410 }, Promise.resolve());
2411 model.passwordHistory = passwordHistory;
2412 }
2413 return model;
2414 });
2415 }
2416 toCipherData(userId) {
2417 const c = new cipherData_CipherData();
2418 c.id = this.id;
2419 c.organizationId = this.organizationId;
2420 c.folderId = this.folderId;
2421 c.userId = this.organizationId != null ? userId : null;
2422 c.edit = this.edit;
2423 c.viewPassword = this.viewPassword;
2424 c.organizationUseTotp = this.organizationUseTotp;
2425 c.favorite = this.favorite;
2426 c.revisionDate = this.revisionDate != null ? this.revisionDate.toISOString() : null;
2427 c.type = this.type;
2428 c.collectionIds = this.collectionIds;
2429 c.deletedDate = this.deletedDate != null ? this.deletedDate.toISOString() : null;
2430 this.buildDataModel(this, c, {
2431 name: null,
2432 notes: null,
2433 });
2434 switch (c.type) {
2435 case CipherType.Login:
2436 c.login = this.login.toLoginData();
2437 break;
2438 case CipherType.SecureNote:
2439 c.secureNote = this.secureNote.toSecureNoteData();
2440 break;
2441 case CipherType.Card:
2442 c.card = this.card.toCardData();
2443 break;
2444 case CipherType.Identity:
2445 c.identity = this.identity.toIdentityData();
2446 break;
2447 default:
2448 break;
2449 }
2450 if (this.fields != null) {
2451 c.fields = this.fields.map((f) => f.toFieldData());
2452 }
2453 if (this.attachments != null) {
2454 c.attachments = this.attachments.map((a) => a.toAttachmentData());
2455 }
2456 if (this.passwordHistory != null) {
2457 c.passwordHistory = this.passwordHistory.map((ph) => ph.toPasswordHistoryData());
2458 }
2459 return c;
2460 }
2461}
2462
2463// CONCATENATED MODULE: ./jslib/src/models/view/collectionView.ts
2464
2465class collectionView_CollectionView {
2466 constructor(c) {
2467 this.id = null;
2468 this.organizationId = null;
2469 this.name = null;
2470 this.externalId = null;
2471 this.readOnly = null;
2472 this.hidePasswords = null;
2473 if (!c) {
2474 return;
2475 }
2476 this.id = c.id;
2477 this.organizationId = c.organizationId;
2478 this.externalId = c.externalId;
2479 if (c instanceof collection_Collection) {
2480 this.readOnly = c.readOnly;
2481 this.hidePasswords = c.hidePasswords;
2482 }
2483 }
2484}
2485
2486// CONCATENATED MODULE: ./jslib/src/models/domain/collection.ts
2487
2488
2489class collection_Collection extends domainBase_Domain {
2490 constructor(obj, alreadyEncrypted = false) {
2491 super();
2492 if (obj == null) {
2493 return;
2494 }
2495 this.buildDomainModel(this, obj, {
2496 id: null,
2497 organizationId: null,
2498 name: null,
2499 externalId: null,
2500 readOnly: null,
2501 hidePasswords: null,
2502 }, alreadyEncrypted, ['id', 'organizationId', 'externalId', 'readOnly', 'hidePasswords']);
2503 }
2504 decrypt() {
2505 return this.decryptObj(new collectionView_CollectionView(this), {
2506 name: null,
2507 }, this.organizationId);
2508 }
2509}
2510
2511// CONCATENATED MODULE: ./jslib/src/models/domain/encryptedObject.ts
2512class EncryptedObject {
2513}
2514
2515// CONCATENATED MODULE: ./jslib/src/models/domain/environmentUrls.ts
2516class EnvironmentUrls {
2517}
2518
2519// CONCATENATED MODULE: ./jslib/src/models/view/folderView.ts
2520class FolderView {
2521 constructor(f) {
2522 this.id = null;
2523 this.name = null;
2524 this.revisionDate = null;
2525 if (!f) {
2526 return;
2527 }
2528 this.id = f.id;
2529 this.revisionDate = f.revisionDate;
2530 }
2531}
2532
2533// CONCATENATED MODULE: ./jslib/src/models/domain/folder.ts
2534
2535
2536class folder_Folder extends domainBase_Domain {
2537 constructor(obj, alreadyEncrypted = false) {
2538 super();
2539 if (obj == null) {
2540 return;
2541 }
2542 this.buildDomainModel(this, obj, {
2543 id: null,
2544 name: null,
2545 }, alreadyEncrypted, ['id']);
2546 this.revisionDate = obj.revisionDate != null ? new Date(obj.revisionDate) : null;
2547 }
2548 decrypt() {
2549 return this.decryptObj(new FolderView(this), {
2550 name: null,
2551 }, null);
2552 }
2553}
2554
2555// CONCATENATED MODULE: ./jslib/src/models/domain/generatedPasswordHistory.ts
2556class GeneratedPasswordHistory {
2557 constructor(password, date) {
2558 this.password = password;
2559 this.date = date;
2560 }
2561}
2562
2563// CONCATENATED MODULE: ./jslib/src/models/domain/index.ts
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581// CONCATENATED MODULE: ./src/services/nodeEnvSecureStorage.service.ts
2582var nodeEnvSecureStorage_service_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
2583 return new (P || (P = Promise))(function (resolve, reject) {
2584 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
2585 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
2586 function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
2587 step((generator = generator.apply(thisArg, _arguments || [])).next());
2588 });
2589};
2590
2591
2592class nodeEnvSecureStorage_service_NodeEnvSecureStorageService {
2593 constructor(storageService, cryptoService) {
2594 this.storageService = storageService;
2595 this.cryptoService = cryptoService;
2596 }
2597 get(key) {
2598 return nodeEnvSecureStorage_service_awaiter(this, void 0, void 0, function* () {
2599 const value = yield this.storageService.get(this.makeProtectedStorageKey(key));
2600 if (value == null) {
2601 return null;
2602 }
2603 const obj = yield this.decrypt(value);
2604 return obj;
2605 });
2606 }
2607 save(key, obj) {
2608 return nodeEnvSecureStorage_service_awaiter(this, void 0, void 0, function* () {
2609 if (typeof (obj) !== 'string') {
2610 throw new Error('Only string storage is allowed.');
2611 }
2612 const protectedObj = yield this.encrypt(obj);
2613 yield this.storageService.save(this.makeProtectedStorageKey(key), protectedObj);
2614 });
2615 }
2616 remove(key) {
2617 return this.storageService.remove(this.makeProtectedStorageKey(key));
2618 }
2619 encrypt(plainValue) {
2620 return nodeEnvSecureStorage_service_awaiter(this, void 0, void 0, function* () {
2621 const sessionKey = this.getSessionKey();
2622 if (sessionKey == null) {
2623 throw new Error('No session key available.');
2624 }
2625 const encValue = yield this.cryptoService().encryptToBytes(utils_Utils.fromB64ToArray(plainValue).buffer, sessionKey);
2626 if (encValue == null) {
2627 throw new Error('Value didn\'t encrypt.');
2628 }
2629 return utils_Utils.fromBufferToB64(encValue);
2630 });
2631 }
2632 decrypt(encValue) {
2633 return nodeEnvSecureStorage_service_awaiter(this, void 0, void 0, function* () {
2634 try {
2635 const sessionKey = this.getSessionKey();
2636 if (sessionKey == null) {
2637 return null;
2638 }
2639 const decValue = yield this.cryptoService().decryptFromBytes(utils_Utils.fromB64ToArray(encValue).buffer, sessionKey);
2640 if (decValue == null) {
2641 // tslint:disable-next-line
2642 console.log('Failed to decrypt.');
2643 return null;
2644 }
2645 return utils_Utils.fromBufferToB64(decValue);
2646 }
2647 catch (e) {
2648 // tslint:disable-next-line
2649 console.log('Decrypt error.');
2650 return null;
2651 }
2652 });
2653 }
2654 getSessionKey() {
2655 try {
2656 if (process.env.BW_SESSION != null) {
2657 const sessionBuffer = utils_Utils.fromB64ToArray(process.env.BW_SESSION).buffer;
2658 if (sessionBuffer != null) {
2659 const sessionKey = new symmetricCryptoKey_SymmetricCryptoKey(sessionBuffer);
2660 if (sessionBuffer != null) {
2661 return sessionKey;
2662 }
2663 }
2664 }
2665 }
2666 catch (e) {
2667 // tslint:disable-next-line
2668 console.log('Session key is invalid.');
2669 }
2670 return null;
2671 }
2672 makeProtectedStorageKey(key) {
2673 return '__PROTECTED__' + key;
2674 }
2675}
2676
2677// CONCATENATED MODULE: ./jslib/src/enums/deviceType.ts
2678var DeviceType;
2679(function (DeviceType) {
2680 DeviceType[DeviceType["Android"] = 0] = "Android";
2681 DeviceType[DeviceType["iOS"] = 1] = "iOS";
2682 DeviceType[DeviceType["ChromeExtension"] = 2] = "ChromeExtension";
2683 DeviceType[DeviceType["FirefoxExtension"] = 3] = "FirefoxExtension";
2684 DeviceType[DeviceType["OperaExtension"] = 4] = "OperaExtension";
2685 DeviceType[DeviceType["EdgeExtension"] = 5] = "EdgeExtension";
2686 DeviceType[DeviceType["WindowsDesktop"] = 6] = "WindowsDesktop";
2687 DeviceType[DeviceType["MacOsDesktop"] = 7] = "MacOsDesktop";
2688 DeviceType[DeviceType["LinuxDesktop"] = 8] = "LinuxDesktop";
2689 DeviceType[DeviceType["ChromeBrowser"] = 9] = "ChromeBrowser";
2690 DeviceType[DeviceType["FirefoxBrowser"] = 10] = "FirefoxBrowser";
2691 DeviceType[DeviceType["OperaBrowser"] = 11] = "OperaBrowser";
2692 DeviceType[DeviceType["EdgeBrowser"] = 12] = "EdgeBrowser";
2693 DeviceType[DeviceType["IEBrowser"] = 13] = "IEBrowser";
2694 DeviceType[DeviceType["UnknownBrowser"] = 14] = "UnknownBrowser";
2695 DeviceType[DeviceType["AndroidAmazon"] = 15] = "AndroidAmazon";
2696 DeviceType[DeviceType["UWP"] = 16] = "UWP";
2697 DeviceType[DeviceType["SafariBrowser"] = 17] = "SafariBrowser";
2698 DeviceType[DeviceType["VivaldiBrowser"] = 18] = "VivaldiBrowser";
2699 DeviceType[DeviceType["VivaldiExtension"] = 19] = "VivaldiExtension";
2700 DeviceType[DeviceType["SafariExtension"] = 20] = "SafariExtension";
2701})(DeviceType || (DeviceType = {}));
2702
2703// CONCATENATED MODULE: ./jslib/src/cli/services/cliPlatformUtils.service.ts
2704
2705class cliPlatformUtils_service_CliPlatformUtilsService {
2706 constructor(identityClientId, packageJson) {
2707 this.packageJson = packageJson;
2708 this.deviceCache = null;
2709 this.identityClientId = identityClientId;
2710 }
2711 getDevice() {
2712 if (!this.deviceCache) {
2713 switch (process.platform) {
2714 case 'win32':
2715 this.deviceCache = DeviceType.WindowsDesktop;
2716 break;
2717 case 'darwin':
2718 this.deviceCache = DeviceType.MacOsDesktop;
2719 break;
2720 case 'linux':
2721 default:
2722 this.deviceCache = DeviceType.LinuxDesktop;
2723 break;
2724 }
2725 }
2726 return this.deviceCache;
2727 }
2728 getDeviceString() {
2729 const device = DeviceType[this.getDevice()].toLowerCase();
2730 return device.replace('desktop', '');
2731 }
2732 isFirefox() {
2733 return false;
2734 }
2735 isChrome() {
2736 return false;
2737 }
2738 isEdge() {
2739 return false;
2740 }
2741 isOpera() {
2742 return false;
2743 }
2744 isVivaldi() {
2745 return false;
2746 }
2747 isSafari() {
2748 return false;
2749 }
2750 isIE() {
2751 return false;
2752 }
2753 isMacAppStore() {
2754 return false;
2755 }
2756 analyticsId() {
2757 return null;
2758 }
2759 isViewOpen() {
2760 return Promise.resolve(false);
2761 }
2762 lockTimeout() {
2763 return null;
2764 }
2765 launchUri(uri, options) {
2766 throw new Error('Not implemented.');
2767 }
2768 saveFile(win, blobData, blobOptions, fileName) {
2769 throw new Error('Not implemented.');
2770 }
2771 getApplicationVersion() {
2772 return this.packageJson.version;
2773 }
2774 supportsU2f(win) {
2775 return false;
2776 }
2777 supportsDuo() {
2778 return false;
2779 }
2780 showToast(type, title, text, options) {
2781 throw new Error('Not implemented.');
2782 }
2783 showDialog(text, title, confirmText, cancelText, type) {
2784 throw new Error('Not implemented.');
2785 }
2786 eventTrack(action, label, options) {
2787 throw new Error('Not implemented.');
2788 }
2789 isDev() {
2790 return "production" === 'development';
2791 }
2792 isSelfHost() {
2793 return false;
2794 }
2795 copyToClipboard(text, options) {
2796 throw new Error('Not implemented.');
2797 }
2798 readFromClipboard(options) {
2799 throw new Error('Not implemented.');
2800 }
2801}
2802
2803// CONCATENATED MODULE: ./jslib/src/services/appId.service.ts
2804var appId_service_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
2805 return new (P || (P = Promise))(function (resolve, reject) {
2806 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
2807 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
2808 function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
2809 step((generator = generator.apply(thisArg, _arguments || [])).next());
2810 });
2811};
2812
2813class appId_service_AppIdService {
2814 constructor(storageService) {
2815 this.storageService = storageService;
2816 }
2817 getAppId() {
2818 return this.makeAndGetAppId('appId');
2819 }
2820 getAnonymousAppId() {
2821 return this.makeAndGetAppId('anonymousAppId');
2822 }
2823 makeAndGetAppId(key) {
2824 return appId_service_awaiter(this, void 0, void 0, function* () {
2825 const existingId = yield this.storageService.get(key);
2826 if (existingId != null) {
2827 return existingId;
2828 }
2829 const guid = utils_Utils.newGuid();
2830 yield this.storageService.save(key, guid);
2831 return guid;
2832 });
2833 }
2834}
2835
2836// CONCATENATED MODULE: ./jslib/src/misc/throttle.ts
2837/**
2838 * Use as a Decorator on async functions, it will limit how many times the function can be
2839 * in-flight at a time.
2840 *
2841 * Calls beyond the limit will be queued, and run when one of the active calls finishes
2842 */
2843function throttle(limit, throttleKey) {
2844 return (target, propertyKey, descriptor) => {
2845 const originalMethod = descriptor.value;
2846 const allThrottles = new Map();
2847 const getThrottles = (obj) => {
2848 let throttles = allThrottles.get(obj);
2849 if (throttles != null) {
2850 return throttles;
2851 }
2852 throttles = new Map();
2853 allThrottles.set(obj, throttles);
2854 return throttles;
2855 };
2856 return {
2857 value: function (...args) {
2858 const throttles = getThrottles(this);
2859 const argsThrottleKey = throttleKey(args);
2860 let queue = throttles.get(argsThrottleKey);
2861 if (queue == null) {
2862 queue = [];
2863 throttles.set(argsThrottleKey, queue);
2864 }
2865 return new Promise((resolve, reject) => {
2866 const exec = () => {
2867 const onFinally = () => {
2868 queue.splice(queue.indexOf(exec), 1);
2869 if (queue.length >= limit) {
2870 queue[limit - 1]();
2871 }
2872 else if (queue.length === 0) {
2873 throttles.delete(argsThrottleKey);
2874 if (throttles.size === 0) {
2875 allThrottles.delete(this);
2876 }
2877 }
2878 };
2879 originalMethod.apply(this, args).then((val) => {
2880 onFinally();
2881 return val;
2882 }).catch((err) => {
2883 onFinally();
2884 throw err;
2885 }).then(resolve, reject);
2886 };
2887 queue.push(exec);
2888 if (queue.length <= limit) {
2889 exec();
2890 }
2891 });
2892 },
2893 };
2894 };
2895}
2896
2897// CONCATENATED MODULE: ./jslib/src/services/audit.service.ts
2898var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
2899 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2900 if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
2901 else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2902 return c > 3 && r && Object.defineProperty(target, key, r), r;
2903};
2904var __metadata = (undefined && undefined.__metadata) || function (k, v) {
2905 if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
2906};
2907var audit_service_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
2908 return new (P || (P = Promise))(function (resolve, reject) {
2909 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
2910 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
2911 function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
2912 step((generator = generator.apply(thisArg, _arguments || [])).next());
2913 });
2914};
2915
2916
2917const PwnedPasswordsApi = 'https://api.pwnedpasswords.com/range/';
2918class audit_service_AuditService {
2919 constructor(cryptoFunctionService, apiService) {
2920 this.cryptoFunctionService = cryptoFunctionService;
2921 this.apiService = apiService;
2922 }
2923 passwordLeaked(password) {
2924 return audit_service_awaiter(this, void 0, void 0, function* () {
2925 const hashBytes = yield this.cryptoFunctionService.hash(password, 'sha1');
2926 const hash = utils_Utils.fromBufferToHex(hashBytes).toUpperCase();
2927 const hashStart = hash.substr(0, 5);
2928 const hashEnding = hash.substr(5);
2929 const response = yield this.apiService.nativeFetch(new Request(PwnedPasswordsApi + hashStart));
2930 const leakedHashes = yield response.text();
2931 const match = leakedHashes.split(/\r?\n/).find((v) => {
2932 return v.split(':')[0] === hashEnding;
2933 });
2934 return match != null ? parseInt(match.split(':')[1], 10) : 0;
2935 });
2936 }
2937 breachedAccounts(username) {
2938 return audit_service_awaiter(this, void 0, void 0, function* () {
2939 try {
2940 return yield this.apiService.getHibpBreach(username);
2941 }
2942 catch (e) {
2943 const error = e;
2944 if (error.statusCode === 404) {
2945 return [];
2946 }
2947 throw new Error();
2948 }
2949 });
2950 }
2951}
2952__decorate([
2953 throttle(100, () => 'passwordLeaked'),
2954 __metadata("design:type", Function),
2955 __metadata("design:paramtypes", [String]),
2956 __metadata("design:returntype", Promise)
2957], audit_service_AuditService.prototype, "passwordLeaked", null);
2958
2959// CONCATENATED MODULE: ./jslib/src/enums/fieldType.ts
2960var FieldType;
2961(function (FieldType) {
2962 FieldType[FieldType["Text"] = 0] = "Text";
2963 FieldType[FieldType["Hidden"] = 1] = "Hidden";
2964 FieldType[FieldType["Boolean"] = 2] = "Boolean";
2965})(FieldType || (FieldType = {}));
2966
2967// CONCATENATED MODULE: ./jslib/src/models/request/cipherBulkDeleteRequest.ts
2968class CipherBulkDeleteRequest {
2969 constructor(ids) {
2970 this.ids = ids == null ? [] : ids;
2971 }
2972}
2973
2974// CONCATENATED MODULE: ./jslib/src/models/request/cipherBulkMoveRequest.ts
2975class CipherBulkMoveRequest {
2976 constructor(ids, folderId) {
2977 this.ids = ids == null ? [] : ids;
2978 this.folderId = folderId;
2979 }
2980}
2981
2982// CONCATENATED MODULE: ./jslib/src/models/request/cipherBulkRestoreRequest.ts
2983class CipherBulkRestoreRequest {
2984 constructor(ids) {
2985 this.ids = ids == null ? [] : ids;
2986 }
2987}
2988
2989// CONCATENATED MODULE: ./jslib/src/models/response/baseResponse.ts
2990class BaseResponse {
2991 constructor(response) {
2992 this.response = response;
2993 }
2994 getResponseProperty(propertyName, response = null, exactName = false) {
2995 if (propertyName == null || propertyName === '') {
2996 throw new Error('propertyName must not be null/empty.');
2997 }
2998 if (response == null && this.response != null) {
2999 response = this.response;
3000 }
3001 if (response == null) {
3002 return null;
3003 }
3004 if (!exactName && response[propertyName] === undefined) {
3005 let otherCasePropertyName = null;
3006 if (propertyName.charAt(0) === propertyName.charAt(0).toUpperCase()) {
3007 otherCasePropertyName = propertyName.charAt(0).toLowerCase();
3008 }
3009 else {
3010 otherCasePropertyName = propertyName.charAt(0).toUpperCase();
3011 }
3012 if (propertyName.length > 1) {
3013 otherCasePropertyName += propertyName.slice(1);
3014 }
3015 propertyName = otherCasePropertyName;
3016 if (response[propertyName] === undefined) {
3017 propertyName = propertyName.toLowerCase();
3018 }
3019 if (response[propertyName] === undefined) {
3020 propertyName = propertyName.toUpperCase();
3021 }
3022 }
3023 return response[propertyName];
3024 }
3025}
3026
3027// CONCATENATED MODULE: ./jslib/src/models/api/cardApi.ts
3028
3029class cardApi_CardApi extends BaseResponse {
3030 constructor(data = null) {
3031 super(data);
3032 if (data == null) {
3033 return;
3034 }
3035 this.cardholderName = this.getResponseProperty('CardholderName');
3036 this.brand = this.getResponseProperty('Brand');
3037 this.number = this.getResponseProperty('Number');
3038 this.expMonth = this.getResponseProperty('ExpMonth');
3039 this.expYear = this.getResponseProperty('ExpYear');
3040 this.code = this.getResponseProperty('Code');
3041 }
3042}
3043
3044// CONCATENATED MODULE: ./jslib/src/models/api/fieldApi.ts
3045
3046class fieldApi_FieldApi extends BaseResponse {
3047 constructor(data = null) {
3048 super(data);
3049 if (data == null) {
3050 return;
3051 }
3052 this.type = this.getResponseProperty('Type');
3053 this.name = this.getResponseProperty('Name');
3054 this.value = this.getResponseProperty('Value');
3055 }
3056}
3057
3058// CONCATENATED MODULE: ./jslib/src/models/api/identityApi.ts
3059
3060class identityApi_IdentityApi extends BaseResponse {
3061 constructor(data = null) {
3062 super(data);
3063 if (data == null) {
3064 return;
3065 }
3066 this.title = this.getResponseProperty('Title');
3067 this.firstName = this.getResponseProperty('FirstName');
3068 this.middleName = this.getResponseProperty('MiddleName');
3069 this.lastName = this.getResponseProperty('LastName');
3070 this.address1 = this.getResponseProperty('Address1');
3071 this.address2 = this.getResponseProperty('Address2');
3072 this.address3 = this.getResponseProperty('Address3');
3073 this.city = this.getResponseProperty('City');
3074 this.state = this.getResponseProperty('State');
3075 this.postalCode = this.getResponseProperty('PostalCode');
3076 this.country = this.getResponseProperty('Country');
3077 this.company = this.getResponseProperty('Company');
3078 this.email = this.getResponseProperty('Email');
3079 this.phone = this.getResponseProperty('Phone');
3080 this.ssn = this.getResponseProperty('SSN');
3081 this.username = this.getResponseProperty('Username');
3082 this.passportNumber = this.getResponseProperty('PassportNumber');
3083 this.licenseNumber = this.getResponseProperty('LicenseNumber');
3084 }
3085}
3086
3087// CONCATENATED MODULE: ./jslib/src/models/api/loginUriApi.ts
3088
3089class loginUriApi_LoginUriApi extends BaseResponse {
3090 constructor(data = null) {
3091 super(data);
3092 this.match = null;
3093 if (data == null) {
3094 return;
3095 }
3096 this.uri = this.getResponseProperty('Uri');
3097 const match = this.getResponseProperty('Match');
3098 this.match = match != null ? match : null;
3099 }
3100}
3101
3102// CONCATENATED MODULE: ./jslib/src/models/api/loginApi.ts
3103
3104
3105class loginApi_LoginApi extends BaseResponse {
3106 constructor(data = null) {
3107 super(data);
3108 if (data == null) {
3109 return;
3110 }
3111 this.username = this.getResponseProperty('Username');
3112 this.password = this.getResponseProperty('Password');
3113 this.passwordRevisionDate = this.getResponseProperty('PasswordRevisionDate');
3114 this.totp = this.getResponseProperty('Totp');
3115 const uris = this.getResponseProperty('Uris');
3116 if (uris != null) {
3117 this.uris = uris.map((u) => new loginUriApi_LoginUriApi(u));
3118 }
3119 }
3120}
3121
3122// CONCATENATED MODULE: ./jslib/src/models/api/secureNoteApi.ts
3123
3124class secureNoteApi_SecureNoteApi extends BaseResponse {
3125 constructor(data = null) {
3126 super(data);
3127 if (data == null) {
3128 return;
3129 }
3130 this.type = this.getResponseProperty('Type');
3131 }
3132}
3133
3134// CONCATENATED MODULE: ./jslib/src/models/request/attachmentRequest.ts
3135class AttachmentRequest {
3136}
3137
3138// CONCATENATED MODULE: ./jslib/src/models/request/cipherRequest.ts
3139
3140
3141
3142
3143
3144
3145
3146
3147class cipherRequest_CipherRequest {
3148 constructor(cipher) {
3149 this.type = cipher.type;
3150 this.folderId = cipher.folderId;
3151 this.organizationId = cipher.organizationId;
3152 this.name = cipher.name ? cipher.name.encryptedString : null;
3153 this.notes = cipher.notes ? cipher.notes.encryptedString : null;
3154 this.favorite = cipher.favorite;
3155 switch (this.type) {
3156 case CipherType.Login:
3157 this.login = new loginApi_LoginApi();
3158 this.login.uris = null;
3159 this.login.username = cipher.login.username ? cipher.login.username.encryptedString : null;
3160 this.login.password = cipher.login.password ? cipher.login.password.encryptedString : null;
3161 this.login.passwordRevisionDate = cipher.login.passwordRevisionDate != null ?
3162 cipher.login.passwordRevisionDate.toISOString() : null;
3163 this.login.totp = cipher.login.totp ? cipher.login.totp.encryptedString : null;
3164 if (cipher.login.uris != null) {
3165 this.login.uris = cipher.login.uris.map((u) => {
3166 const uri = new loginUriApi_LoginUriApi();
3167 uri.uri = u.uri != null ? u.uri.encryptedString : null;
3168 uri.match = u.match != null ? u.match : null;
3169 return uri;
3170 });
3171 }
3172 break;
3173 case CipherType.SecureNote:
3174 this.secureNote = new secureNoteApi_SecureNoteApi();
3175 this.secureNote.type = cipher.secureNote.type;
3176 break;
3177 case CipherType.Card:
3178 this.card = new cardApi_CardApi();
3179 this.card.cardholderName = cipher.card.cardholderName != null ?
3180 cipher.card.cardholderName.encryptedString : null;
3181 this.card.brand = cipher.card.brand != null ? cipher.card.brand.encryptedString : null;
3182 this.card.number = cipher.card.number != null ? cipher.card.number.encryptedString : null;
3183 this.card.expMonth = cipher.card.expMonth != null ? cipher.card.expMonth.encryptedString : null;
3184 this.card.expYear = cipher.card.expYear != null ? cipher.card.expYear.encryptedString : null;
3185 this.card.code = cipher.card.code != null ? cipher.card.code.encryptedString : null;
3186 break;
3187 case CipherType.Identity:
3188 this.identity = new identityApi_IdentityApi();
3189 this.identity.title = cipher.identity.title != null ? cipher.identity.title.encryptedString : null;
3190 this.identity.firstName = cipher.identity.firstName != null ?
3191 cipher.identity.firstName.encryptedString : null;
3192 this.identity.middleName = cipher.identity.middleName != null ?
3193 cipher.identity.middleName.encryptedString : null;
3194 this.identity.lastName = cipher.identity.lastName != null ?
3195 cipher.identity.lastName.encryptedString : null;
3196 this.identity.address1 = cipher.identity.address1 != null ?
3197 cipher.identity.address1.encryptedString : null;
3198 this.identity.address2 = cipher.identity.address2 != null ?
3199 cipher.identity.address2.encryptedString : null;
3200 this.identity.address3 = cipher.identity.address3 != null ?
3201 cipher.identity.address3.encryptedString : null;
3202 this.identity.city = cipher.identity.city != null ? cipher.identity.city.encryptedString : null;
3203 this.identity.state = cipher.identity.state != null ? cipher.identity.state.encryptedString : null;
3204 this.identity.postalCode = cipher.identity.postalCode != null ?
3205 cipher.identity.postalCode.encryptedString : null;
3206 this.identity.country = cipher.identity.country != null ?
3207 cipher.identity.country.encryptedString : null;
3208 this.identity.company = cipher.identity.company != null ?
3209 cipher.identity.company.encryptedString : null;
3210 this.identity.email = cipher.identity.email != null ? cipher.identity.email.encryptedString : null;
3211 this.identity.phone = cipher.identity.phone != null ? cipher.identity.phone.encryptedString : null;
3212 this.identity.ssn = cipher.identity.ssn != null ? cipher.identity.ssn.encryptedString : null;
3213 this.identity.username = cipher.identity.username != null ?
3214 cipher.identity.username.encryptedString : null;
3215 this.identity.passportNumber = cipher.identity.passportNumber != null ?
3216 cipher.identity.passportNumber.encryptedString : null;
3217 this.identity.licenseNumber = cipher.identity.licenseNumber != null ?
3218 cipher.identity.licenseNumber.encryptedString : null;
3219 break;
3220 default:
3221 break;
3222 }
3223 if (cipher.fields != null) {
3224 this.fields = cipher.fields.map((f) => {
3225 const field = new fieldApi_FieldApi();
3226 field.type = f.type;
3227 field.name = f.name ? f.name.encryptedString : null;
3228 field.value = f.value ? f.value.encryptedString : null;
3229 return field;
3230 });
3231 }
3232 if (cipher.passwordHistory != null) {
3233 this.passwordHistory = [];
3234 cipher.passwordHistory.forEach((ph) => {
3235 this.passwordHistory.push({
3236 lastUsedDate: ph.lastUsedDate,
3237 password: ph.password ? ph.password.encryptedString : null,
3238 });
3239 });
3240 }
3241 if (cipher.attachments != null) {
3242 this.attachments = {};
3243 this.attachments2 = {};
3244 cipher.attachments.forEach((attachment) => {
3245 const fileName = attachment.fileName ? attachment.fileName.encryptedString : null;
3246 this.attachments[attachment.id] = fileName;
3247 const attachmentRequest = new AttachmentRequest();
3248 attachmentRequest.fileName = fileName;
3249 if (attachment.key != null) {
3250 attachmentRequest.key = attachment.key.encryptedString;
3251 }
3252 this.attachments2[attachment.id] = attachmentRequest;
3253 });
3254 }
3255 }
3256}
3257
3258// CONCATENATED MODULE: ./jslib/src/models/request/cipherWithIdRequest.ts
3259
3260class cipherWithIdRequest_CipherWithIdRequest extends cipherRequest_CipherRequest {
3261 constructor(cipher) {
3262 super(cipher);
3263 this.id = cipher.id;
3264 }
3265}
3266
3267// CONCATENATED MODULE: ./jslib/src/models/request/cipherBulkShareRequest.ts
3268
3269class cipherBulkShareRequest_CipherBulkShareRequest {
3270 constructor(ciphers, collectionIds) {
3271 if (ciphers != null) {
3272 this.ciphers = [];
3273 ciphers.forEach((c) => {
3274 this.ciphers.push(new cipherWithIdRequest_CipherWithIdRequest(c));
3275 });
3276 }
3277 this.collectionIds = collectionIds;
3278 }
3279}
3280
3281// CONCATENATED MODULE: ./jslib/src/models/request/cipherCollectionsRequest.ts
3282class CipherCollectionsRequest {
3283 constructor(collectionIds) {
3284 this.collectionIds = collectionIds == null ? [] : collectionIds;
3285 }
3286}
3287
3288// CONCATENATED MODULE: ./jslib/src/models/request/cipherCreateRequest.ts
3289
3290class cipherCreateRequest_CipherCreateRequest {
3291 constructor(cipher) {
3292 this.cipher = new cipherRequest_CipherRequest(cipher);
3293 this.collectionIds = cipher.collectionIds;
3294 }
3295}
3296
3297// CONCATENATED MODULE: ./jslib/src/models/request/cipherShareRequest.ts
3298
3299class cipherShareRequest_CipherShareRequest {
3300 constructor(cipher) {
3301 this.cipher = new cipherRequest_CipherRequest(cipher);
3302 this.collectionIds = cipher.collectionIds;
3303 }
3304}
3305
3306// CONCATENATED MODULE: ./jslib/src/services/constants.service.ts
3307class ConstantsService {
3308 constructor() {
3309 this.environmentUrlsKey = ConstantsService.environmentUrlsKey;
3310 this.disableGaKey = ConstantsService.disableGaKey;
3311 this.disableAddLoginNotificationKey = ConstantsService.disableAddLoginNotificationKey;
3312 this.disableContextMenuItemKey = ConstantsService.disableContextMenuItemKey;
3313 this.disableFaviconKey = ConstantsService.disableFaviconKey;
3314 this.disableAutoTotpCopyKey = ConstantsService.disableAutoTotpCopyKey;
3315 this.enableAutoFillOnPageLoadKey = ConstantsService.enableAutoFillOnPageLoadKey;
3316 this.vaultTimeoutKey = ConstantsService.vaultTimeoutKey;
3317 this.vaultTimeoutActionKey = ConstantsService.vaultTimeoutActionKey;
3318 this.lastActiveKey = ConstantsService.lastActiveKey;
3319 this.neverDomainsKey = ConstantsService.neverDomainsKey;
3320 this.installedVersionKey = ConstantsService.installedVersionKey;
3321 this.localeKey = ConstantsService.localeKey;
3322 this.themeKey = ConstantsService.themeKey;
3323 this.collapsedGroupingsKey = ConstantsService.collapsedGroupingsKey;
3324 this.autoConfirmFingerprints = ConstantsService.autoConfirmFingerprints;
3325 this.dontShowCardsCurrentTab = ConstantsService.dontShowCardsCurrentTab;
3326 this.dontShowIdentitiesCurrentTab = ConstantsService.dontShowIdentitiesCurrentTab;
3327 this.defaultUriMatch = ConstantsService.defaultUriMatch;
3328 this.pinProtectedKey = ConstantsService.pinProtectedKey;
3329 this.protectedPin = ConstantsService.protectedPin;
3330 this.clearClipboardKey = ConstantsService.clearClipboardKey;
3331 this.eventCollectionKey = ConstantsService.eventCollectionKey;
3332 }
3333}
3334ConstantsService.environmentUrlsKey = 'environmentUrls';
3335ConstantsService.disableGaKey = 'disableGa';
3336ConstantsService.disableAddLoginNotificationKey = 'disableAddLoginNotification';
3337ConstantsService.disableChangedPasswordNotificationKey = 'disableChangedPasswordNotification';
3338ConstantsService.disableContextMenuItemKey = 'disableContextMenuItem';
3339ConstantsService.disableFaviconKey = 'disableFavicon';
3340ConstantsService.disableAutoTotpCopyKey = 'disableAutoTotpCopy';
3341ConstantsService.enableAutoFillOnPageLoadKey = 'enableAutoFillOnPageLoad';
3342ConstantsService.vaultTimeoutKey = 'lockOption';
3343ConstantsService.vaultTimeoutActionKey = 'vaultTimeoutAction';
3344ConstantsService.lastActiveKey = 'lastActive';
3345ConstantsService.neverDomainsKey = 'neverDomains';
3346ConstantsService.installedVersionKey = 'installedVersion';
3347ConstantsService.localeKey = 'locale';
3348ConstantsService.themeKey = 'theme';
3349ConstantsService.collapsedGroupingsKey = 'collapsedGroupings';
3350ConstantsService.autoConfirmFingerprints = 'autoConfirmFingerprints';
3351ConstantsService.dontShowCardsCurrentTab = 'dontShowCardsCurrentTab';
3352ConstantsService.dontShowIdentitiesCurrentTab = 'dontShowIdentitiesCurrentTab';
3353ConstantsService.defaultUriMatch = 'defaultUriMatch';
3354ConstantsService.pinProtectedKey = 'pinProtectedKey';
3355ConstantsService.protectedPin = 'protectedPin';
3356ConstantsService.clearClipboardKey = 'clearClipboardKey';
3357ConstantsService.eventCollectionKey = 'eventCollection';
3358
3359// CONCATENATED MODULE: ./jslib/src/misc/sequentialize.ts
3360/**
3361 * Use as a Decorator on async functions, it will prevent multiple 'active' calls as the same time
3362 *
3363 * If a promise was returned from a previous call to this function, that hasn't yet resolved it will
3364 * be returned, instead of calling the original function again
3365 *
3366 * Results are not cached, once the promise has returned, the next call will result in a fresh call
3367 *
3368 * Read more at https://github.com/bitwarden/jslib/pull/7
3369 */
3370function sequentialize(cacheKey) {
3371 return (target, propertyKey, descriptor) => {
3372 const originalMethod = descriptor.value;
3373 const caches = new Map();
3374 const getCache = (obj) => {
3375 let cache = caches.get(obj);
3376 if (cache != null) {
3377 return cache;
3378 }
3379 cache = new Map();
3380 caches.set(obj, cache);
3381 return cache;
3382 };
3383 return {
3384 value: function (...args) {
3385 const cache = getCache(this);
3386 const argsCacheKey = cacheKey(args);
3387 let response = cache.get(argsCacheKey);
3388 if (response != null) {
3389 return response;
3390 }
3391 const onFinally = () => {
3392 cache.delete(argsCacheKey);
3393 if (cache.size === 0) {
3394 caches.delete(this);
3395 }
3396 };
3397 response = originalMethod.apply(this, args).then((val) => {
3398 onFinally();
3399 return val;
3400 }).catch((err) => {
3401 onFinally();
3402 throw err;
3403 });
3404 cache.set(argsCacheKey, response);
3405 return response;
3406 },
3407 };
3408 };
3409}
3410
3411// CONCATENATED MODULE: ./jslib/src/services/cipher.service.ts
3412var cipher_service_decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
3413 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3414 if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
3415 else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3416 return c > 3 && r && Object.defineProperty(target, key, r), r;
3417};
3418var cipher_service_metadata = (undefined && undefined.__metadata) || function (k, v) {
3419 if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
3420};
3421var cipher_service_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
3422 return new (P || (P = Promise))(function (resolve, reject) {
3423 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
3424 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
3425 function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
3426 step((generator = generator.apply(thisArg, _arguments || [])).next());
3427 });
3428};
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454const Keys = {
3455 ciphersPrefix: 'ciphers_',
3456 localData: 'sitesLocalData',
3457 neverDomains: 'neverDomains',
3458};
3459const DomainMatchBlacklist = new Map([
3460 ['google.com', new Set(['script.google.com'])],
3461]);
3462class cipher_service_CipherService {
3463 constructor(cryptoService, userService, settingsService, apiService, storageService, i18nService, searchService) {
3464 this.cryptoService = cryptoService;
3465 this.userService = userService;
3466 this.settingsService = settingsService;
3467 this.apiService = apiService;
3468 this.storageService = storageService;
3469 this.i18nService = i18nService;
3470 this.searchService = searchService;
3471 }
3472 get decryptedCipherCache() {
3473 return this._decryptedCipherCache;
3474 }
3475 set decryptedCipherCache(value) {
3476 this._decryptedCipherCache = value;
3477 if (this.searchService != null) {
3478 if (value == null) {
3479 this.searchService().clearIndex();
3480 }
3481 else {
3482 this.searchService().indexCiphers();
3483 }
3484 }
3485 }
3486 clearCache() {
3487 this.decryptedCipherCache = null;
3488 }
3489 encrypt(model, key, originalCipher = null) {
3490 return cipher_service_awaiter(this, void 0, void 0, function* () {
3491 // Adjust password history
3492 if (model.id != null) {
3493 if (originalCipher == null) {
3494 originalCipher = yield this.get(model.id);
3495 }
3496 if (originalCipher != null) {
3497 const existingCipher = yield originalCipher.decrypt();
3498 model.passwordHistory = existingCipher.passwordHistory || [];
3499 if (model.type === CipherType.Login && existingCipher.type === CipherType.Login) {
3500 if (existingCipher.login.password != null && existingCipher.login.password !== '' &&
3501 existingCipher.login.password !== model.login.password) {
3502 const ph = new PasswordHistoryView();
3503 ph.password = existingCipher.login.password;
3504 ph.lastUsedDate = model.login.passwordRevisionDate = new Date();
3505 model.passwordHistory.splice(0, 0, ph);
3506 }
3507 else {
3508 model.login.passwordRevisionDate = existingCipher.login.passwordRevisionDate;
3509 }
3510 }
3511 if (existingCipher.hasFields) {
3512 const existingHiddenFields = existingCipher.fields.filter((f) => f.type === FieldType.Hidden &&
3513 f.name != null && f.name !== '' && f.value != null && f.value !== '');
3514 const hiddenFields = model.fields == null ? [] :
3515 model.fields.filter((f) => f.type === FieldType.Hidden && f.name != null && f.name !== '');
3516 existingHiddenFields.forEach((ef) => {
3517 const matchedField = hiddenFields.find((f) => f.name === ef.name);
3518 if (matchedField == null || matchedField.value !== ef.value) {
3519 const ph = new PasswordHistoryView();
3520 ph.password = ef.name + ': ' + ef.value;
3521 ph.lastUsedDate = new Date();
3522 model.passwordHistory.splice(0, 0, ph);
3523 }
3524 });
3525 }
3526 }
3527 if (model.passwordHistory != null && model.passwordHistory.length === 0) {
3528 model.passwordHistory = null;
3529 }
3530 else if (model.passwordHistory != null && model.passwordHistory.length > 5) {
3531 // only save last 5 history
3532 model.passwordHistory = model.passwordHistory.slice(0, 5);
3533 }
3534 }
3535 const cipher = new cipher_Cipher();
3536 cipher.id = model.id;
3537 cipher.folderId = model.folderId;
3538 cipher.favorite = model.favorite;
3539 cipher.organizationId = model.organizationId;
3540 cipher.type = model.type;
3541 cipher.collectionIds = model.collectionIds;
3542 if (key == null && cipher.organizationId != null) {
3543 key = yield this.cryptoService.getOrgKey(cipher.organizationId);
3544 if (key == null) {
3545 throw new Error('Cannot encrypt cipher for organization. No key.');
3546 }
3547 }
3548 yield Promise.all([
3549 this.encryptObjProperty(model, cipher, {
3550 name: null,
3551 notes: null,
3552 }, key),
3553 this.encryptCipherData(cipher, model, key),
3554 this.encryptFields(model.fields, key).then((fields) => {
3555 cipher.fields = fields;
3556 }),
3557 this.encryptPasswordHistories(model.passwordHistory, key).then((ph) => {
3558 cipher.passwordHistory = ph;
3559 }),
3560 this.encryptAttachments(model.attachments, key).then((attachments) => {
3561 cipher.attachments = attachments;
3562 }),
3563 ]);
3564 return cipher;
3565 });
3566 }
3567 encryptAttachments(attachmentsModel, key) {
3568 return cipher_service_awaiter(this, void 0, void 0, function* () {
3569 if (attachmentsModel == null || attachmentsModel.length === 0) {
3570 return null;
3571 }
3572 const promises = [];
3573 const encAttachments = [];
3574 attachmentsModel.forEach((model) => cipher_service_awaiter(this, void 0, void 0, function* () {
3575 const attachment = new attachment_Attachment();
3576 attachment.id = model.id;
3577 attachment.size = model.size;
3578 attachment.sizeName = model.sizeName;
3579 attachment.url = model.url;
3580 const promise = this.encryptObjProperty(model, attachment, {
3581 fileName: null,
3582 }, key).then(() => cipher_service_awaiter(this, void 0, void 0, function* () {
3583 if (model.key != null) {
3584 attachment.key = yield this.cryptoService.encrypt(model.key.key, key);
3585 }
3586 encAttachments.push(attachment);
3587 }));
3588 promises.push(promise);
3589 }));
3590 yield Promise.all(promises);
3591 return encAttachments;
3592 });
3593 }
3594 encryptFields(fieldsModel, key) {
3595 return cipher_service_awaiter(this, void 0, void 0, function* () {
3596 if (!fieldsModel || !fieldsModel.length) {
3597 return null;
3598 }
3599 const self = this;
3600 const encFields = [];
3601 yield fieldsModel.reduce((promise, field) => {
3602 return promise.then(() => {
3603 return self.encryptField(field, key);
3604 }).then((encField) => {
3605 encFields.push(encField);
3606 });
3607 }, Promise.resolve());
3608 return encFields;
3609 });
3610 }
3611 encryptField(fieldModel, key) {
3612 return cipher_service_awaiter(this, void 0, void 0, function* () {
3613 const field = new field_Field();
3614 field.type = fieldModel.type;
3615 // normalize boolean type field values
3616 if (fieldModel.type === FieldType.Boolean && fieldModel.value !== 'true') {
3617 fieldModel.value = 'false';
3618 }
3619 yield this.encryptObjProperty(fieldModel, field, {
3620 name: null,
3621 value: null,
3622 }, key);
3623 return field;
3624 });
3625 }
3626 encryptPasswordHistories(phModels, key) {
3627 return cipher_service_awaiter(this, void 0, void 0, function* () {
3628 if (!phModels || !phModels.length) {
3629 return null;
3630 }
3631 const self = this;
3632 const encPhs = [];
3633 yield phModels.reduce((promise, ph) => {
3634 return promise.then(() => {
3635 return self.encryptPasswordHistory(ph, key);
3636 }).then((encPh) => {
3637 encPhs.push(encPh);
3638 });
3639 }, Promise.resolve());
3640 return encPhs;
3641 });
3642 }
3643 encryptPasswordHistory(phModel, key) {
3644 return cipher_service_awaiter(this, void 0, void 0, function* () {
3645 const ph = new password_Password();
3646 ph.lastUsedDate = phModel.lastUsedDate;
3647 yield this.encryptObjProperty(phModel, ph, {
3648 password: null,
3649 }, key);
3650 return ph;
3651 });
3652 }
3653 get(id) {
3654 return cipher_service_awaiter(this, void 0, void 0, function* () {
3655 const userId = yield this.userService.getUserId();
3656 const localData = yield this.storageService.get(Keys.localData);
3657 const ciphers = yield this.storageService.get(Keys.ciphersPrefix + userId);
3658 if (ciphers == null || !ciphers.hasOwnProperty(id)) {
3659 return null;
3660 }
3661 return new cipher_Cipher(ciphers[id], false, localData ? localData[id] : null);
3662 });
3663 }
3664 getAll() {
3665 return cipher_service_awaiter(this, void 0, void 0, function* () {
3666 const userId = yield this.userService.getUserId();
3667 const localData = yield this.storageService.get(Keys.localData);
3668 const ciphers = yield this.storageService.get(Keys.ciphersPrefix + userId);
3669 const response = [];
3670 for (const id in ciphers) {
3671 if (ciphers.hasOwnProperty(id)) {
3672 response.push(new cipher_Cipher(ciphers[id], false, localData ? localData[id] : null));
3673 }
3674 }
3675 return response;
3676 });
3677 }
3678 getAllDecrypted() {
3679 return cipher_service_awaiter(this, void 0, void 0, function* () {
3680 if (this.decryptedCipherCache != null) {
3681 return this.decryptedCipherCache;
3682 }
3683 const decCiphers = [];
3684 const hasKey = yield this.cryptoService.hasKey();
3685 if (!hasKey) {
3686 throw new Error('No key.');
3687 }
3688 const promises = [];
3689 const ciphers = yield this.getAll();
3690 ciphers.forEach((cipher) => {
3691 promises.push(cipher.decrypt().then((c) => decCiphers.push(c)));
3692 });
3693 yield Promise.all(promises);
3694 decCiphers.sort(this.getLocaleSortingFunction());
3695 this.decryptedCipherCache = decCiphers;
3696 return this.decryptedCipherCache;
3697 });
3698 }
3699 getAllDecryptedForGrouping(groupingId, folder = true) {
3700 return cipher_service_awaiter(this, void 0, void 0, function* () {
3701 const ciphers = yield this.getAllDecrypted();
3702 return ciphers.filter((cipher) => {
3703 if (cipher.isDeleted) {
3704 return false;
3705 }
3706 if (folder && cipher.folderId === groupingId) {
3707 return true;
3708 }
3709 else if (!folder && cipher.collectionIds != null && cipher.collectionIds.indexOf(groupingId) > -1) {
3710 return true;
3711 }
3712 return false;
3713 });
3714 });
3715 }
3716 getAllDecryptedForUrl(url, includeOtherTypes) {
3717 return cipher_service_awaiter(this, void 0, void 0, function* () {
3718 if (url == null && includeOtherTypes == null) {
3719 return Promise.resolve([]);
3720 }
3721 const domain = utils_Utils.getDomain(url);
3722 const eqDomainsPromise = domain == null ? Promise.resolve([]) :
3723 this.settingsService.getEquivalentDomains().then((eqDomains) => {
3724 let matches = [];
3725 eqDomains.forEach((eqDomain) => {
3726 if (eqDomain.length && eqDomain.indexOf(domain) >= 0) {
3727 matches = matches.concat(eqDomain);
3728 }
3729 });
3730 if (!matches.length) {
3731 matches.push(domain);
3732 }
3733 return matches;
3734 });
3735 const result = yield Promise.all([eqDomainsPromise, this.getAllDecrypted()]);
3736 const matchingDomains = result[0];
3737 const ciphers = result[1];
3738 let defaultMatch = yield this.storageService.get(ConstantsService.defaultUriMatch);
3739 if (defaultMatch == null) {
3740 defaultMatch = UriMatchType.Domain;
3741 }
3742 return ciphers.filter((cipher) => {
3743 if (cipher.deletedDate != null) {
3744 return false;
3745 }
3746 if (includeOtherTypes != null && includeOtherTypes.indexOf(cipher.type) > -1) {
3747 return true;
3748 }
3749 if (url != null && cipher.type === CipherType.Login && cipher.login.uris != null) {
3750 for (let i = 0; i < cipher.login.uris.length; i++) {
3751 const u = cipher.login.uris[i];
3752 if (u.uri == null) {
3753 continue;
3754 }
3755 const match = u.match == null ? defaultMatch : u.match;
3756 switch (match) {
3757 case UriMatchType.Domain:
3758 if (domain != null && u.domain != null && matchingDomains.indexOf(u.domain) > -1) {
3759 if (DomainMatchBlacklist.has(u.domain)) {
3760 const domainUrlHost = utils_Utils.getHost(url);
3761 if (!DomainMatchBlacklist.get(u.domain).has(domainUrlHost)) {
3762 return true;
3763 }
3764 }
3765 else {
3766 return true;
3767 }
3768 }
3769 break;
3770 case UriMatchType.Host:
3771 const urlHost = utils_Utils.getHost(url);
3772 if (urlHost != null && urlHost === utils_Utils.getHost(u.uri)) {
3773 return true;
3774 }
3775 break;
3776 case UriMatchType.Exact:
3777 if (url === u.uri) {
3778 return true;
3779 }
3780 break;
3781 case UriMatchType.StartsWith:
3782 if (url.startsWith(u.uri)) {
3783 return true;
3784 }
3785 break;
3786 case UriMatchType.RegularExpression:
3787 try {
3788 const regex = new RegExp(u.uri, 'i');
3789 if (regex.test(url)) {
3790 return true;
3791 }
3792 }
3793 catch (_a) { }
3794 break;
3795 case UriMatchType.Never:
3796 default:
3797 break;
3798 }
3799 }
3800 }
3801 return false;
3802 });
3803 });
3804 }
3805 getAllFromApiForOrganization(organizationId) {
3806 return cipher_service_awaiter(this, void 0, void 0, function* () {
3807 const ciphers = yield this.apiService.getCiphersOrganization(organizationId);
3808 if (ciphers != null && ciphers.data != null && ciphers.data.length) {
3809 const decCiphers = [];
3810 const promises = [];
3811 ciphers.data.forEach((r) => {
3812 const data = new cipherData_CipherData(r);
3813 const cipher = new cipher_Cipher(data);
3814 promises.push(cipher.decrypt().then((c) => decCiphers.push(c)));
3815 });
3816 yield Promise.all(promises);
3817 decCiphers.sort(this.getLocaleSortingFunction());
3818 return decCiphers;
3819 }
3820 else {
3821 return [];
3822 }
3823 });
3824 }
3825 getLastUsedForUrl(url) {
3826 return cipher_service_awaiter(this, void 0, void 0, function* () {
3827 const ciphers = yield this.getAllDecryptedForUrl(url);
3828 if (ciphers.length === 0) {
3829 return null;
3830 }
3831 const sortedCiphers = ciphers.sort(this.sortCiphersByLastUsed);
3832 return sortedCiphers[0];
3833 });
3834 }
3835 updateLastUsedDate(id) {
3836 return cipher_service_awaiter(this, void 0, void 0, function* () {
3837 let ciphersLocalData = yield this.storageService.get(Keys.localData);
3838 if (!ciphersLocalData) {
3839 ciphersLocalData = {};
3840 }
3841 if (ciphersLocalData[id]) {
3842 ciphersLocalData[id].lastUsedDate = new Date().getTime();
3843 }
3844 else {
3845 ciphersLocalData[id] = {
3846 lastUsedDate: new Date().getTime(),
3847 };
3848 }
3849 yield this.storageService.save(Keys.localData, ciphersLocalData);
3850 if (this.decryptedCipherCache == null) {
3851 return;
3852 }
3853 for (let i = 0; i < this.decryptedCipherCache.length; i++) {
3854 const cached = this.decryptedCipherCache[i];
3855 if (cached.id === id) {
3856 cached.localData = ciphersLocalData[id];
3857 break;
3858 }
3859 }
3860 });
3861 }
3862 saveNeverDomain(domain) {
3863 return cipher_service_awaiter(this, void 0, void 0, function* () {
3864 if (domain == null) {
3865 return;
3866 }
3867 let domains = yield this.storageService.get(Keys.neverDomains);
3868 if (!domains) {
3869 domains = {};
3870 }
3871 domains[domain] = null;
3872 yield this.storageService.save(Keys.neverDomains, domains);
3873 });
3874 }
3875 saveWithServer(cipher) {
3876 return cipher_service_awaiter(this, void 0, void 0, function* () {
3877 let response;
3878 if (cipher.id == null) {
3879 if (cipher.collectionIds != null) {
3880 const request = new cipherCreateRequest_CipherCreateRequest(cipher);
3881 response = yield this.apiService.postCipherCreate(request);
3882 }
3883 else {
3884 const request = new cipherRequest_CipherRequest(cipher);
3885 response = yield this.apiService.postCipher(request);
3886 }
3887 cipher.id = response.id;
3888 }
3889 else {
3890 const request = new cipherRequest_CipherRequest(cipher);
3891 response = yield this.apiService.putCipher(cipher.id, request);
3892 }
3893 const userId = yield this.userService.getUserId();
3894 const data = new cipherData_CipherData(response, userId, cipher.collectionIds);
3895 yield this.upsert(data);
3896 });
3897 }
3898 shareWithServer(cipher, organizationId, collectionIds) {
3899 return cipher_service_awaiter(this, void 0, void 0, function* () {
3900 const attachmentPromises = [];
3901 if (cipher.attachments != null) {
3902 cipher.attachments.forEach((attachment) => {
3903 if (attachment.key == null) {
3904 attachmentPromises.push(this.shareAttachmentWithServer(attachment, cipher.id, organizationId));
3905 }
3906 });
3907 }
3908 yield Promise.all(attachmentPromises);
3909 cipher.organizationId = organizationId;
3910 cipher.collectionIds = collectionIds;
3911 const encCipher = yield this.encrypt(cipher);
3912 const request = new cipherShareRequest_CipherShareRequest(encCipher);
3913 const response = yield this.apiService.putShareCipher(cipher.id, request);
3914 const userId = yield this.userService.getUserId();
3915 const data = new cipherData_CipherData(response, userId, collectionIds);
3916 yield this.upsert(data);
3917 });
3918 }
3919 shareManyWithServer(ciphers, organizationId, collectionIds) {
3920 return cipher_service_awaiter(this, void 0, void 0, function* () {
3921 const promises = [];
3922 const encCiphers = [];
3923 for (const cipher of ciphers) {
3924 cipher.organizationId = organizationId;
3925 cipher.collectionIds = collectionIds;
3926 promises.push(this.encrypt(cipher).then((c) => {
3927 encCiphers.push(c);
3928 }));
3929 }
3930 yield Promise.all(promises);
3931 const request = new cipherBulkShareRequest_CipherBulkShareRequest(encCiphers, collectionIds);
3932 yield this.apiService.putShareCiphers(request);
3933 const userId = yield this.userService.getUserId();
3934 yield this.upsert(encCiphers.map((c) => c.toCipherData(userId)));
3935 });
3936 }
3937 saveAttachmentWithServer(cipher, unencryptedFile, admin = false) {
3938 return new Promise((resolve, reject) => {
3939 const reader = new FileReader();
3940 reader.readAsArrayBuffer(unencryptedFile);
3941 reader.onload = (evt) => cipher_service_awaiter(this, void 0, void 0, function* () {
3942 try {
3943 const cData = yield this.saveAttachmentRawWithServer(cipher, unencryptedFile.name, evt.target.result, admin);
3944 resolve(cData);
3945 }
3946 catch (e) {
3947 reject(e);
3948 }
3949 });
3950 reader.onerror = (evt) => {
3951 reject('Error reading file.');
3952 };
3953 });
3954 }
3955 saveAttachmentRawWithServer(cipher, filename, data, admin = false) {
3956 return cipher_service_awaiter(this, void 0, void 0, function* () {
3957 const key = yield this.cryptoService.getOrgKey(cipher.organizationId);
3958 const encFileName = yield this.cryptoService.encrypt(filename, key);
3959 const dataEncKey = yield this.cryptoService.makeEncKey(key);
3960 const encData = yield this.cryptoService.encryptToBytes(data, dataEncKey[0]);
3961 const fd = new FormData();
3962 try {
3963 const blob = new Blob([encData], { type: 'application/octet-stream' });
3964 fd.append('key', dataEncKey[1].encryptedString);
3965 fd.append('data', blob, encFileName.encryptedString);
3966 }
3967 catch (e) {
3968 if (utils_Utils.isNode && !utils_Utils.isBrowser) {
3969 fd.append('key', dataEncKey[1].encryptedString);
3970 fd.append('data', Buffer.from(encData), {
3971 filepath: encFileName.encryptedString,
3972 contentType: 'application/octet-stream',
3973 });
3974 }
3975 else {
3976 throw e;
3977 }
3978 }
3979 let response;
3980 try {
3981 if (admin) {
3982 response = yield this.apiService.postCipherAttachmentAdmin(cipher.id, fd);
3983 }
3984 else {
3985 response = yield this.apiService.postCipherAttachment(cipher.id, fd);
3986 }
3987 }
3988 catch (e) {
3989 throw new Error(e.getSingleMessage());
3990 }
3991 const userId = yield this.userService.getUserId();
3992 const cData = new cipherData_CipherData(response, userId, cipher.collectionIds);
3993 if (!admin) {
3994 yield this.upsert(cData);
3995 }
3996 return new cipher_Cipher(cData);
3997 });
3998 }
3999 saveCollectionsWithServer(cipher) {
4000 return cipher_service_awaiter(this, void 0, void 0, function* () {
4001 const request = new CipherCollectionsRequest(cipher.collectionIds);
4002 yield this.apiService.putCipherCollections(cipher.id, request);
4003 const userId = yield this.userService.getUserId();
4004 const data = cipher.toCipherData(userId);
4005 yield this.upsert(data);
4006 });
4007 }
4008 upsert(cipher) {
4009 return cipher_service_awaiter(this, void 0, void 0, function* () {
4010 const userId = yield this.userService.getUserId();
4011 let ciphers = yield this.storageService.get(Keys.ciphersPrefix + userId);
4012 if (ciphers == null) {
4013 ciphers = {};
4014 }
4015 if (cipher instanceof cipherData_CipherData) {
4016 const c = cipher;
4017 ciphers[c.id] = c;
4018 }
4019 else {
4020 cipher.forEach((c) => {
4021 ciphers[c.id] = c;
4022 });
4023 }
4024 yield this.storageService.save(Keys.ciphersPrefix + userId, ciphers);
4025 this.decryptedCipherCache = null;
4026 });
4027 }
4028 replace(ciphers) {
4029 return cipher_service_awaiter(this, void 0, void 0, function* () {
4030 const userId = yield this.userService.getUserId();
4031 yield this.storageService.save(Keys.ciphersPrefix + userId, ciphers);
4032 this.decryptedCipherCache = null;
4033 });
4034 }
4035 clear(userId) {
4036 return cipher_service_awaiter(this, void 0, void 0, function* () {
4037 yield this.storageService.remove(Keys.ciphersPrefix + userId);
4038 this.clearCache();
4039 });
4040 }
4041 moveManyWithServer(ids, folderId) {
4042 return cipher_service_awaiter(this, void 0, void 0, function* () {
4043 yield this.apiService.putMoveCiphers(new CipherBulkMoveRequest(ids, folderId));
4044 const userId = yield this.userService.getUserId();
4045 let ciphers = yield this.storageService.get(Keys.ciphersPrefix + userId);
4046 if (ciphers == null) {
4047 ciphers = {};
4048 }
4049 ids.forEach((id) => {
4050 if (ciphers.hasOwnProperty(id)) {
4051 ciphers[id].folderId = folderId;
4052 }
4053 });
4054 yield this.storageService.save(Keys.ciphersPrefix + userId, ciphers);
4055 this.decryptedCipherCache = null;
4056 });
4057 }
4058 delete(id) {
4059 return cipher_service_awaiter(this, void 0, void 0, function* () {
4060 const userId = yield this.userService.getUserId();
4061 const ciphers = yield this.storageService.get(Keys.ciphersPrefix + userId);
4062 if (ciphers == null) {
4063 return;
4064 }
4065 if (typeof id === 'string') {
4066 if (ciphers[id] == null) {
4067 return;
4068 }
4069 delete ciphers[id];
4070 }
4071 else {
4072 id.forEach((i) => {
4073 delete ciphers[i];
4074 });
4075 }
4076 yield this.storageService.save(Keys.ciphersPrefix + userId, ciphers);
4077 this.decryptedCipherCache = null;
4078 });
4079 }
4080 deleteWithServer(id) {
4081 return cipher_service_awaiter(this, void 0, void 0, function* () {
4082 yield this.apiService.deleteCipher(id);
4083 yield this.delete(id);
4084 });
4085 }
4086 deleteManyWithServer(ids) {
4087 return cipher_service_awaiter(this, void 0, void 0, function* () {
4088 yield this.apiService.deleteManyCiphers(new CipherBulkDeleteRequest(ids));
4089 yield this.delete(ids);
4090 });
4091 }
4092 deleteAttachment(id, attachmentId) {
4093 return cipher_service_awaiter(this, void 0, void 0, function* () {
4094 const userId = yield this.userService.getUserId();
4095 const ciphers = yield this.storageService.get(Keys.ciphersPrefix + userId);
4096 if (ciphers == null || !ciphers.hasOwnProperty(id) || ciphers[id].attachments == null) {
4097 return;
4098 }
4099 for (let i = 0; i < ciphers[id].attachments.length; i++) {
4100 if (ciphers[id].attachments[i].id === attachmentId) {
4101 ciphers[id].attachments.splice(i, 1);
4102 }
4103 }
4104 yield this.storageService.save(Keys.ciphersPrefix + userId, ciphers);
4105 this.decryptedCipherCache = null;
4106 });
4107 }
4108 deleteAttachmentWithServer(id, attachmentId) {
4109 return cipher_service_awaiter(this, void 0, void 0, function* () {
4110 try {
4111 yield this.apiService.deleteCipherAttachment(id, attachmentId);
4112 }
4113 catch (e) {
4114 return Promise.reject(e.getSingleMessage());
4115 }
4116 yield this.deleteAttachment(id, attachmentId);
4117 });
4118 }
4119 sortCiphersByLastUsed(a, b) {
4120 const aLastUsed = a.localData && a.localData.lastUsedDate ? a.localData.lastUsedDate : null;
4121 const bLastUsed = b.localData && b.localData.lastUsedDate ? b.localData.lastUsedDate : null;
4122 const bothNotNull = aLastUsed != null && bLastUsed != null;
4123 if (bothNotNull && aLastUsed < bLastUsed) {
4124 return 1;
4125 }
4126 if (aLastUsed != null && bLastUsed == null) {
4127 return -1;
4128 }
4129 if (bothNotNull && aLastUsed > bLastUsed) {
4130 return -1;
4131 }
4132 if (bLastUsed != null && aLastUsed == null) {
4133 return 1;
4134 }
4135 return 0;
4136 }
4137 sortCiphersByLastUsedThenName(a, b) {
4138 const result = this.sortCiphersByLastUsed(a, b);
4139 if (result !== 0) {
4140 return result;
4141 }
4142 return this.getLocaleSortingFunction()(a, b);
4143 }
4144 getLocaleSortingFunction() {
4145 return (a, b) => {
4146 let aName = a.name;
4147 let bName = b.name;
4148 if (aName == null && bName != null) {
4149 return -1;
4150 }
4151 if (aName != null && bName == null) {
4152 return 1;
4153 }
4154 if (aName == null && bName == null) {
4155 return 0;
4156 }
4157 const result = this.i18nService.collator ? this.i18nService.collator.compare(aName, bName) :
4158 aName.localeCompare(bName);
4159 if (result !== 0 || a.type !== CipherType.Login || b.type !== CipherType.Login) {
4160 return result;
4161 }
4162 if (a.login.username != null) {
4163 aName += a.login.username;
4164 }
4165 if (b.login.username != null) {
4166 bName += b.login.username;
4167 }
4168 return this.i18nService.collator ? this.i18nService.collator.compare(aName, bName) :
4169 aName.localeCompare(bName);
4170 };
4171 }
4172 softDelete(id) {
4173 return cipher_service_awaiter(this, void 0, void 0, function* () {
4174 const userId = yield this.userService.getUserId();
4175 const ciphers = yield this.storageService.get(Keys.ciphersPrefix + userId);
4176 if (ciphers == null) {
4177 return;
4178 }
4179 const setDeletedDate = (cipherId) => {
4180 if (ciphers[cipherId] == null) {
4181 return;
4182 }
4183 ciphers[cipherId].deletedDate = new Date().toISOString();
4184 };
4185 if (typeof id === 'string') {
4186 setDeletedDate(id);
4187 }
4188 else {
4189 id.forEach(setDeletedDate);
4190 }
4191 yield this.storageService.save(Keys.ciphersPrefix + userId, ciphers);
4192 this.decryptedCipherCache = null;
4193 });
4194 }
4195 softDeleteWithServer(id) {
4196 return cipher_service_awaiter(this, void 0, void 0, function* () {
4197 yield this.apiService.putDeleteCipher(id);
4198 yield this.softDelete(id);
4199 });
4200 }
4201 softDeleteManyWithServer(ids) {
4202 return cipher_service_awaiter(this, void 0, void 0, function* () {
4203 yield this.apiService.putDeleteManyCiphers(new CipherBulkDeleteRequest(ids));
4204 yield this.softDelete(ids);
4205 });
4206 }
4207 restore(id) {
4208 return cipher_service_awaiter(this, void 0, void 0, function* () {
4209 const userId = yield this.userService.getUserId();
4210 const ciphers = yield this.storageService.get(Keys.ciphersPrefix + userId);
4211 if (ciphers == null) {
4212 return;
4213 }
4214 const clearDeletedDate = (cipherId) => {
4215 if (ciphers[cipherId] == null) {
4216 return;
4217 }
4218 ciphers[cipherId].deletedDate = null;
4219 };
4220 if (typeof id === 'string') {
4221 clearDeletedDate(id);
4222 }
4223 else {
4224 id.forEach(clearDeletedDate);
4225 }
4226 yield this.storageService.save(Keys.ciphersPrefix + userId, ciphers);
4227 this.decryptedCipherCache = null;
4228 });
4229 }
4230 restoreWithServer(id) {
4231 return cipher_service_awaiter(this, void 0, void 0, function* () {
4232 yield this.apiService.putRestoreCipher(id);
4233 yield this.restore(id);
4234 });
4235 }
4236 restoreManyWithServer(ids) {
4237 return cipher_service_awaiter(this, void 0, void 0, function* () {
4238 yield this.apiService.putRestoreManyCiphers(new CipherBulkRestoreRequest(ids));
4239 yield this.restore(ids);
4240 });
4241 }
4242 // Helpers
4243 shareAttachmentWithServer(attachmentView, cipherId, organizationId) {
4244 return cipher_service_awaiter(this, void 0, void 0, function* () {
4245 const attachmentResponse = yield this.apiService.nativeFetch(new Request(attachmentView.url, { cache: 'no-store' }));
4246 if (attachmentResponse.status !== 200) {
4247 throw Error('Failed to download attachment: ' + attachmentResponse.status.toString());
4248 }
4249 const buf = yield attachmentResponse.arrayBuffer();
4250 const decBuf = yield this.cryptoService.decryptFromBytes(buf, null);
4251 const key = yield this.cryptoService.getOrgKey(organizationId);
4252 const encFileName = yield this.cryptoService.encrypt(attachmentView.fileName, key);
4253 const dataEncKey = yield this.cryptoService.makeEncKey(key);
4254 const encData = yield this.cryptoService.encryptToBytes(decBuf, dataEncKey[0]);
4255 const fd = new FormData();
4256 try {
4257 const blob = new Blob([encData], { type: 'application/octet-stream' });
4258 fd.append('key', dataEncKey[1].encryptedString);
4259 fd.append('data', blob, encFileName.encryptedString);
4260 }
4261 catch (e) {
4262 if (utils_Utils.isNode && !utils_Utils.isBrowser) {
4263 fd.append('key', dataEncKey[1].encryptedString);
4264 fd.append('data', Buffer.from(encData), {
4265 filepath: encFileName.encryptedString,
4266 contentType: 'application/octet-stream',
4267 });
4268 }
4269 else {
4270 throw e;
4271 }
4272 }
4273 try {
4274 yield this.apiService.postShareCipherAttachment(cipherId, attachmentView.id, fd, organizationId);
4275 }
4276 catch (e) {
4277 throw new Error(e.getSingleMessage());
4278 }
4279 });
4280 }
4281 encryptObjProperty(model, obj, map, key) {
4282 return cipher_service_awaiter(this, void 0, void 0, function* () {
4283 const promises = [];
4284 const self = this;
4285 for (const prop in map) {
4286 if (!map.hasOwnProperty(prop)) {
4287 continue;
4288 }
4289 // tslint:disable-next-line
4290 (function (theProp, theObj) {
4291 const p = Promise.resolve().then(() => {
4292 const modelProp = model[(map[theProp] || theProp)];
4293 if (modelProp && modelProp !== '') {
4294 return self.cryptoService.encrypt(modelProp, key);
4295 }
4296 return null;
4297 }).then((val) => {
4298 theObj[theProp] = val;
4299 });
4300 promises.push(p);
4301 })(prop, obj);
4302 }
4303 yield Promise.all(promises);
4304 });
4305 }
4306 encryptCipherData(cipher, model, key) {
4307 return cipher_service_awaiter(this, void 0, void 0, function* () {
4308 switch (cipher.type) {
4309 case CipherType.Login:
4310 cipher.login = new login_Login();
4311 cipher.login.passwordRevisionDate = model.login.passwordRevisionDate;
4312 yield this.encryptObjProperty(model.login, cipher.login, {
4313 username: null,
4314 password: null,
4315 totp: null,
4316 }, key);
4317 if (model.login.uris != null) {
4318 cipher.login.uris = [];
4319 for (let i = 0; i < model.login.uris.length; i++) {
4320 const loginUri = new loginUri_LoginUri();
4321 loginUri.match = model.login.uris[i].match;
4322 yield this.encryptObjProperty(model.login.uris[i], loginUri, {
4323 uri: null,
4324 }, key);
4325 cipher.login.uris.push(loginUri);
4326 }
4327 }
4328 return;
4329 case CipherType.SecureNote:
4330 cipher.secureNote = new secureNote_SecureNote();
4331 cipher.secureNote.type = model.secureNote.type;
4332 return;
4333 case CipherType.Card:
4334 cipher.card = new card_Card();
4335 yield this.encryptObjProperty(model.card, cipher.card, {
4336 cardholderName: null,
4337 brand: null,
4338 number: null,
4339 expMonth: null,
4340 expYear: null,
4341 code: null,
4342 }, key);
4343 return;
4344 case CipherType.Identity:
4345 cipher.identity = new identity_Identity();
4346 yield this.encryptObjProperty(model.identity, cipher.identity, {
4347 title: null,
4348 firstName: null,
4349 middleName: null,
4350 lastName: null,
4351 address1: null,
4352 address2: null,
4353 address3: null,
4354 city: null,
4355 state: null,
4356 postalCode: null,
4357 country: null,
4358 company: null,
4359 email: null,
4360 phone: null,
4361 ssn: null,
4362 username: null,
4363 passportNumber: null,
4364 licenseNumber: null,
4365 }, key);
4366 return;
4367 default:
4368 throw new Error('Unknown cipher type.');
4369 }
4370 });
4371 }
4372}
4373cipher_service_decorate([
4374 sequentialize(() => 'getAllDecrypted'),
4375 cipher_service_metadata("design:type", Function),
4376 cipher_service_metadata("design:paramtypes", []),
4377 cipher_service_metadata("design:returntype", Promise)
4378], cipher_service_CipherService.prototype, "getAllDecrypted", null);
4379
4380// CONCATENATED MODULE: ./jslib/src/models/data/collectionData.ts
4381class CollectionData {
4382 constructor(response) {
4383 this.id = response.id;
4384 this.organizationId = response.organizationId;
4385 this.name = response.name;
4386 this.externalId = response.externalId;
4387 this.readOnly = response.readOnly;
4388 }
4389}
4390
4391// CONCATENATED MODULE: ./jslib/src/models/domain/treeNode.ts
4392class TreeNode {
4393 constructor(node, name, parent) {
4394 this.children = [];
4395 this.parent = parent;
4396 this.node = node;
4397 this.node.name = name;
4398 }
4399}
4400
4401// CONCATENATED MODULE: ./jslib/src/misc/serviceUtils.ts
4402
4403class serviceUtils_ServiceUtils {
4404 static nestedTraverse(nodeTree, partIndex, parts, obj, parent, delimiter) {
4405 if (parts.length <= partIndex) {
4406 return;
4407 }
4408 const end = partIndex === parts.length - 1;
4409 const partName = parts[partIndex];
4410 for (let i = 0; i < nodeTree.length; i++) {
4411 if (nodeTree[i].node.name !== parts[partIndex]) {
4412 continue;
4413 }
4414 if (end && nodeTree[i].node.id !== obj.id) {
4415 // Another node with the same name.
4416 nodeTree.push(new TreeNode(obj, partName, parent));
4417 return;
4418 }
4419 serviceUtils_ServiceUtils.nestedTraverse(nodeTree[i].children, partIndex + 1, parts, obj, nodeTree[i].node, delimiter);
4420 return;
4421 }
4422 if (nodeTree.filter((n) => n.node.name === partName).length === 0) {
4423 if (end) {
4424 nodeTree.push(new TreeNode(obj, partName, parent));
4425 return;
4426 }
4427 const newPartName = parts[partIndex] + delimiter + parts[partIndex + 1];
4428 serviceUtils_ServiceUtils.nestedTraverse(nodeTree, 0, [newPartName, ...parts.slice(partIndex + 2)], obj, parent, delimiter);
4429 }
4430 }
4431 static getTreeNodeObject(nodeTree, id) {
4432 for (let i = 0; i < nodeTree.length; i++) {
4433 if (nodeTree[i].node.id === id) {
4434 return nodeTree[i];
4435 }
4436 else if (nodeTree[i].children != null) {
4437 const node = serviceUtils_ServiceUtils.getTreeNodeObject(nodeTree[i].children, id);
4438 if (node !== null) {
4439 return node;
4440 }
4441 }
4442 }
4443 return null;
4444 }
4445}
4446
4447// CONCATENATED MODULE: ./jslib/src/services/collection.service.ts
4448var collection_service_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
4449 return new (P || (P = Promise))(function (resolve, reject) {
4450 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
4451 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
4452 function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
4453 step((generator = generator.apply(thisArg, _arguments || [])).next());
4454 });
4455};
4456
4457
4458
4459
4460
4461const collection_service_Keys = {
4462 collectionsPrefix: 'collections_',
4463};
4464const NestingDelimiter = '/';
4465class collection_service_CollectionService {
4466 constructor(cryptoService, userService, storageService, i18nService) {
4467 this.cryptoService = cryptoService;
4468 this.userService = userService;
4469 this.storageService = storageService;
4470 this.i18nService = i18nService;
4471 }
4472 clearCache() {
4473 this.decryptedCollectionCache = null;
4474 }
4475 encrypt(model) {
4476 return collection_service_awaiter(this, void 0, void 0, function* () {
4477 if (model.organizationId == null) {
4478 throw new Error('Collection has no organization id.');
4479 }
4480 const key = yield this.cryptoService.getOrgKey(model.organizationId);
4481 if (key == null) {
4482 throw new Error('No key for this collection\'s organization.');
4483 }
4484 const collection = new collection_Collection();
4485 collection.id = model.id;
4486 collection.organizationId = model.organizationId;
4487 collection.readOnly = model.readOnly;
4488 collection.name = yield this.cryptoService.encrypt(model.name, key);
4489 return collection;
4490 });
4491 }
4492 decryptMany(collections) {
4493 return collection_service_awaiter(this, void 0, void 0, function* () {
4494 if (collections == null) {
4495 return [];
4496 }
4497 const decCollections = [];
4498 const promises = [];
4499 collections.forEach((collection) => {
4500 promises.push(collection.decrypt().then((c) => decCollections.push(c)));
4501 });
4502 yield Promise.all(promises);
4503 return decCollections.sort(utils_Utils.getSortFunction(this.i18nService, 'name'));
4504 });
4505 }
4506 get(id) {
4507 return collection_service_awaiter(this, void 0, void 0, function* () {
4508 const userId = yield this.userService.getUserId();
4509 const collections = yield this.storageService.get(collection_service_Keys.collectionsPrefix + userId);
4510 if (collections == null || !collections.hasOwnProperty(id)) {
4511 return null;
4512 }
4513 return new collection_Collection(collections[id]);
4514 });
4515 }
4516 getAll() {
4517 return collection_service_awaiter(this, void 0, void 0, function* () {
4518 const userId = yield this.userService.getUserId();
4519 const collections = yield this.storageService.get(collection_service_Keys.collectionsPrefix + userId);
4520 const response = [];
4521 for (const id in collections) {
4522 if (collections.hasOwnProperty(id)) {
4523 response.push(new collection_Collection(collections[id]));
4524 }
4525 }
4526 return response;
4527 });
4528 }
4529 getAllDecrypted() {
4530 return collection_service_awaiter(this, void 0, void 0, function* () {
4531 if (this.decryptedCollectionCache != null) {
4532 return this.decryptedCollectionCache;
4533 }
4534 const hasKey = yield this.cryptoService.hasKey();
4535 if (!hasKey) {
4536 throw new Error('No key.');
4537 }
4538 const collections = yield this.getAll();
4539 this.decryptedCollectionCache = yield this.decryptMany(collections);
4540 return this.decryptedCollectionCache;
4541 });
4542 }
4543 getAllNested(collections = null) {
4544 return collection_service_awaiter(this, void 0, void 0, function* () {
4545 if (collections == null) {
4546 collections = yield this.getAllDecrypted();
4547 }
4548 const nodes = [];
4549 collections.forEach((c) => {
4550 const collectionCopy = new collectionView_CollectionView();
4551 collectionCopy.id = c.id;
4552 collectionCopy.organizationId = c.organizationId;
4553 const parts = c.name != null ? c.name.replace(/^\/+|\/+$/g, '').split(NestingDelimiter) : [];
4554 serviceUtils_ServiceUtils.nestedTraverse(nodes, 0, parts, collectionCopy, null, NestingDelimiter);
4555 });
4556 return nodes;
4557 });
4558 }
4559 getNested(id) {
4560 return collection_service_awaiter(this, void 0, void 0, function* () {
4561 const collections = yield this.getAllNested();
4562 return serviceUtils_ServiceUtils.getTreeNodeObject(collections, id);
4563 });
4564 }
4565 upsert(collection) {
4566 return collection_service_awaiter(this, void 0, void 0, function* () {
4567 const userId = yield this.userService.getUserId();
4568 let collections = yield this.storageService.get(collection_service_Keys.collectionsPrefix + userId);
4569 if (collections == null) {
4570 collections = {};
4571 }
4572 if (collection instanceof CollectionData) {
4573 const c = collection;
4574 collections[c.id] = c;
4575 }
4576 else {
4577 collection.forEach((c) => {
4578 collections[c.id] = c;
4579 });
4580 }
4581 yield this.storageService.save(collection_service_Keys.collectionsPrefix + userId, collections);
4582 this.decryptedCollectionCache = null;
4583 });
4584 }
4585 replace(collections) {
4586 return collection_service_awaiter(this, void 0, void 0, function* () {
4587 const userId = yield this.userService.getUserId();
4588 yield this.storageService.save(collection_service_Keys.collectionsPrefix + userId, collections);
4589 this.decryptedCollectionCache = null;
4590 });
4591 }
4592 clear(userId) {
4593 return collection_service_awaiter(this, void 0, void 0, function* () {
4594 yield this.storageService.remove(collection_service_Keys.collectionsPrefix + userId);
4595 this.decryptedCollectionCache = null;
4596 });
4597 }
4598 delete(id) {
4599 return collection_service_awaiter(this, void 0, void 0, function* () {
4600 const userId = yield this.userService.getUserId();
4601 const collections = yield this.storageService.get(collection_service_Keys.collectionsPrefix + userId);
4602 if (collections == null) {
4603 return;
4604 }
4605 if (typeof id === 'string') {
4606 const i = id;
4607 delete collections[id];
4608 }
4609 else {
4610 id.forEach((i) => {
4611 delete collections[i];
4612 });
4613 }
4614 yield this.storageService.save(collection_service_Keys.collectionsPrefix + userId, collections);
4615 this.decryptedCollectionCache = null;
4616 });
4617 }
4618}
4619
4620// CONCATENATED MODULE: ./jslib/src/services/container.service.ts
4621class ContainerService {
4622 constructor(cryptoService) {
4623 this.cryptoService = cryptoService;
4624 }
4625 // deprecated, use attachToGlobal instead
4626 attachToWindow(win) {
4627 this.attachToGlobal(win);
4628 }
4629 attachToGlobal(global) {
4630 if (!global.bitwardenContainerService) {
4631 global.bitwardenContainerService = this;
4632 }
4633 }
4634 getCryptoService() {
4635 return this.cryptoService;
4636 }
4637}
4638
4639// EXTERNAL MODULE: external "big-integer"
4640var external_big_integer_ = __webpack_require__(13);
4641
4642// CONCATENATED MODULE: ./jslib/src/enums/kdfType.ts
4643var KdfType;
4644(function (KdfType) {
4645 KdfType[KdfType["PBKDF2_SHA256"] = 0] = "PBKDF2_SHA256";
4646})(KdfType || (KdfType = {}));
4647
4648// CONCATENATED MODULE: ./jslib/src/misc/wordlist.ts
4649// EFF's Long Wordlist from https://www.eff.org/dice
4650const EEFLongWordList = [
4651 'abacus',
4652 'abdomen',
4653 'abdominal',
4654 'abide',
4655 'abiding',
4656 'ability',
4657 'ablaze',
4658 'able',
4659 'abnormal',
4660 'abrasion',
4661 'abrasive',
4662 'abreast',
4663 'abridge',
4664 'abroad',
4665 'abruptly',
4666 'absence',
4667 'absentee',
4668 'absently',
4669 'absinthe',
4670 'absolute',
4671 'absolve',
4672 'abstain',
4673 'abstract',
4674 'absurd',
4675 'accent',
4676 'acclaim',
4677 'acclimate',
4678 'accompany',
4679 'account',
4680 'accuracy',
4681 'accurate',
4682 'accustom',
4683 'acetone',
4684 'achiness',
4685 'aching',
4686 'acid',
4687 'acorn',
4688 'acquaint',
4689 'acquire',
4690 'acre',
4691 'acrobat',
4692 'acronym',
4693 'acting',
4694 'action',
4695 'activate',
4696 'activator',
4697 'active',
4698 'activism',
4699 'activist',
4700 'activity',
4701 'actress',
4702 'acts',
4703 'acutely',
4704 'acuteness',
4705 'aeration',
4706 'aerobics',
4707 'aerosol',
4708 'aerospace',
4709 'afar',
4710 'affair',
4711 'affected',
4712 'affecting',
4713 'affection',
4714 'affidavit',
4715 'affiliate',
4716 'affirm',
4717 'affix',
4718 'afflicted',
4719 'affluent',
4720 'afford',
4721 'affront',
4722 'aflame',
4723 'afloat',
4724 'aflutter',
4725 'afoot',
4726 'afraid',
4727 'afterglow',
4728 'afterlife',
4729 'aftermath',
4730 'aftermost',
4731 'afternoon',
4732 'aged',
4733 'ageless',
4734 'agency',
4735 'agenda',
4736 'agent',
4737 'aggregate',
4738 'aghast',
4739 'agile',
4740 'agility',
4741 'aging',
4742 'agnostic',
4743 'agonize',
4744 'agonizing',
4745 'agony',
4746 'agreeable',
4747 'agreeably',
4748 'agreed',
4749 'agreeing',
4750 'agreement',
4751 'aground',
4752 'ahead',
4753 'ahoy',
4754 'aide',
4755 'aids',
4756 'aim',
4757 'ajar',
4758 'alabaster',
4759 'alarm',
4760 'albatross',
4761 'album',
4762 'alfalfa',
4763 'algebra',
4764 'algorithm',
4765 'alias',
4766 'alibi',
4767 'alienable',
4768 'alienate',
4769 'aliens',
4770 'alike',
4771 'alive',
4772 'alkaline',
4773 'alkalize',
4774 'almanac',
4775 'almighty',
4776 'almost',
4777 'aloe',
4778 'aloft',
4779 'aloha',
4780 'alone',
4781 'alongside',
4782 'aloof',
4783 'alphabet',
4784 'alright',
4785 'although',
4786 'altitude',
4787 'alto',
4788 'aluminum',
4789 'alumni',
4790 'always',
4791 'amaretto',
4792 'amaze',
4793 'amazingly',
4794 'amber',
4795 'ambiance',
4796 'ambiguity',
4797 'ambiguous',
4798 'ambition',
4799 'ambitious',
4800 'ambulance',
4801 'ambush',
4802 'amendable',
4803 'amendment',
4804 'amends',
4805 'amenity',
4806 'amiable',
4807 'amicably',
4808 'amid',
4809 'amigo',
4810 'amino',
4811 'amiss',
4812 'ammonia',
4813 'ammonium',
4814 'amnesty',
4815 'amniotic',
4816 'among',
4817 'amount',
4818 'amperage',
4819 'ample',
4820 'amplifier',
4821 'amplify',
4822 'amply',
4823 'amuck',
4824 'amulet',
4825 'amusable',
4826 'amused',
4827 'amusement',
4828 'amuser',
4829 'amusing',
4830 'anaconda',
4831 'anaerobic',
4832 'anagram',
4833 'anatomist',
4834 'anatomy',
4835 'anchor',
4836 'anchovy',
4837 'ancient',
4838 'android',
4839 'anemia',
4840 'anemic',
4841 'aneurism',
4842 'anew',
4843 'angelfish',
4844 'angelic',
4845 'anger',
4846 'angled',
4847 'angler',
4848 'angles',
4849 'angling',
4850 'angrily',
4851 'angriness',
4852 'anguished',
4853 'angular',
4854 'animal',
4855 'animate',
4856 'animating',
4857 'animation',
4858 'animator',
4859 'anime',
4860 'animosity',
4861 'ankle',
4862 'annex',
4863 'annotate',
4864 'announcer',
4865 'annoying',
4866 'annually',
4867 'annuity',
4868 'anointer',
4869 'another',
4870 'answering',
4871 'antacid',
4872 'antarctic',
4873 'anteater',
4874 'antelope',
4875 'antennae',
4876 'anthem',
4877 'anthill',
4878 'anthology',
4879 'antibody',
4880 'antics',
4881 'antidote',
4882 'antihero',
4883 'antiquely',
4884 'antiques',
4885 'antiquity',
4886 'antirust',
4887 'antitoxic',
4888 'antitrust',
4889 'antiviral',
4890 'antivirus',
4891 'antler',
4892 'antonym',
4893 'antsy',
4894 'anvil',
4895 'anybody',
4896 'anyhow',
4897 'anymore',
4898 'anyone',
4899 'anyplace',
4900 'anything',
4901 'anytime',
4902 'anyway',
4903 'anywhere',
4904 'aorta',
4905 'apache',
4906 'apostle',
4907 'appealing',
4908 'appear',
4909 'appease',
4910 'appeasing',
4911 'appendage',
4912 'appendix',
4913 'appetite',
4914 'appetizer',
4915 'applaud',
4916 'applause',
4917 'apple',
4918 'appliance',
4919 'applicant',
4920 'applied',
4921 'apply',
4922 'appointee',
4923 'appraisal',
4924 'appraiser',
4925 'apprehend',
4926 'approach',
4927 'approval',
4928 'approve',
4929 'apricot',
4930 'april',
4931 'apron',
4932 'aptitude',
4933 'aptly',
4934 'aqua',
4935 'aqueduct',
4936 'arbitrary',
4937 'arbitrate',
4938 'ardently',
4939 'area',
4940 'arena',
4941 'arguable',
4942 'arguably',
4943 'argue',
4944 'arise',
4945 'armadillo',
4946 'armband',
4947 'armchair',
4948 'armed',
4949 'armful',
4950 'armhole',
4951 'arming',
4952 'armless',
4953 'armoire',
4954 'armored',
4955 'armory',
4956 'armrest',
4957 'army',
4958 'aroma',
4959 'arose',
4960 'around',
4961 'arousal',
4962 'arrange',
4963 'array',
4964 'arrest',
4965 'arrival',
4966 'arrive',
4967 'arrogance',
4968 'arrogant',
4969 'arson',
4970 'art',
4971 'ascend',
4972 'ascension',
4973 'ascent',
4974 'ascertain',
4975 'ashamed',
4976 'ashen',
4977 'ashes',
4978 'ashy',
4979 'aside',
4980 'askew',
4981 'asleep',
4982 'asparagus',
4983 'aspect',
4984 'aspirate',
4985 'aspire',
4986 'aspirin',
4987 'astonish',
4988 'astound',
4989 'astride',
4990 'astrology',
4991 'astronaut',
4992 'astronomy',
4993 'astute',
4994 'atlantic',
4995 'atlas',
4996 'atom',
4997 'atonable',
4998 'atop',
4999 'atrium',
5000 'atrocious',
5001 'atrophy',
5002 'attach',
5003 'attain',
5004 'attempt',
5005 'attendant',
5006 'attendee',
5007 'attention',
5008 'attentive',
5009 'attest',
5010 'attic',
5011 'attire',
5012 'attitude',
5013 'attractor',
5014 'attribute',
5015 'atypical',
5016 'auction',
5017 'audacious',
5018 'audacity',
5019 'audible',
5020 'audibly',
5021 'audience',
5022 'audio',
5023 'audition',
5024 'augmented',
5025 'august',
5026 'authentic',
5027 'author',
5028 'autism',
5029 'autistic',
5030 'autograph',
5031 'automaker',
5032 'automated',
5033 'automatic',
5034 'autopilot',
5035 'available',
5036 'avalanche',
5037 'avatar',
5038 'avenge',
5039 'avenging',
5040 'avenue',
5041 'average',
5042 'aversion',
5043 'avert',
5044 'aviation',
5045 'aviator',
5046 'avid',
5047 'avoid',
5048 'await',
5049 'awaken',
5050 'award',
5051 'aware',
5052 'awhile',
5053 'awkward',
5054 'awning',
5055 'awoke',
5056 'awry',
5057 'axis',
5058 'babble',
5059 'babbling',
5060 'babied',
5061 'baboon',
5062 'backache',
5063 'backboard',
5064 'backboned',
5065 'backdrop',
5066 'backed',
5067 'backer',
5068 'backfield',
5069 'backfire',
5070 'backhand',
5071 'backing',
5072 'backlands',
5073 'backlash',
5074 'backless',
5075 'backlight',
5076 'backlit',
5077 'backlog',
5078 'backpack',
5079 'backpedal',
5080 'backrest',
5081 'backroom',
5082 'backshift',
5083 'backside',
5084 'backslid',
5085 'backspace',
5086 'backspin',
5087 'backstab',
5088 'backstage',
5089 'backtalk',
5090 'backtrack',
5091 'backup',
5092 'backward',
5093 'backwash',
5094 'backwater',
5095 'backyard',
5096 'bacon',
5097 'bacteria',
5098 'bacterium',
5099 'badass',
5100 'badge',
5101 'badland',
5102 'badly',
5103 'badness',
5104 'baffle',
5105 'baffling',
5106 'bagel',
5107 'bagful',
5108 'baggage',
5109 'bagged',
5110 'baggie',
5111 'bagginess',
5112 'bagging',
5113 'baggy',
5114 'bagpipe',
5115 'baguette',
5116 'baked',
5117 'bakery',
5118 'bakeshop',
5119 'baking',
5120 'balance',
5121 'balancing',
5122 'balcony',
5123 'balmy',
5124 'balsamic',
5125 'bamboo',
5126 'banana',
5127 'banish',
5128 'banister',
5129 'banjo',
5130 'bankable',
5131 'bankbook',
5132 'banked',
5133 'banker',
5134 'banking',
5135 'banknote',
5136 'bankroll',
5137 'banner',
5138 'bannister',
5139 'banshee',
5140 'banter',
5141 'barbecue',
5142 'barbed',
5143 'barbell',
5144 'barber',
5145 'barcode',
5146 'barge',
5147 'bargraph',
5148 'barista',
5149 'baritone',
5150 'barley',
5151 'barmaid',
5152 'barman',
5153 'barn',
5154 'barometer',
5155 'barrack',
5156 'barracuda',
5157 'barrel',
5158 'barrette',
5159 'barricade',
5160 'barrier',
5161 'barstool',
5162 'bartender',
5163 'barterer',
5164 'bash',
5165 'basically',
5166 'basics',
5167 'basil',
5168 'basin',
5169 'basis',
5170 'basket',
5171 'batboy',
5172 'batch',
5173 'bath',
5174 'baton',
5175 'bats',
5176 'battalion',
5177 'battered',
5178 'battering',
5179 'battery',
5180 'batting',
5181 'battle',
5182 'bauble',
5183 'bazooka',
5184 'blabber',
5185 'bladder',
5186 'blade',
5187 'blah',
5188 'blame',
5189 'blaming',
5190 'blanching',
5191 'blandness',
5192 'blank',
5193 'blaspheme',
5194 'blasphemy',
5195 'blast',
5196 'blatancy',
5197 'blatantly',
5198 'blazer',
5199 'blazing',
5200 'bleach',
5201 'bleak',
5202 'bleep',
5203 'blemish',
5204 'blend',
5205 'bless',
5206 'blighted',
5207 'blimp',
5208 'bling',
5209 'blinked',
5210 'blinker',
5211 'blinking',
5212 'blinks',
5213 'blip',
5214 'blissful',
5215 'blitz',
5216 'blizzard',
5217 'bloated',
5218 'bloating',
5219 'blob',
5220 'blog',
5221 'bloomers',
5222 'blooming',
5223 'blooper',
5224 'blot',
5225 'blouse',
5226 'blubber',
5227 'bluff',
5228 'bluish',
5229 'blunderer',
5230 'blunt',
5231 'blurb',
5232 'blurred',
5233 'blurry',
5234 'blurt',
5235 'blush',
5236 'blustery',
5237 'boaster',
5238 'boastful',
5239 'boasting',
5240 'boat',
5241 'bobbed',
5242 'bobbing',
5243 'bobble',
5244 'bobcat',
5245 'bobsled',
5246 'bobtail',
5247 'bodacious',
5248 'body',
5249 'bogged',
5250 'boggle',
5251 'bogus',
5252 'boil',
5253 'bok',
5254 'bolster',
5255 'bolt',
5256 'bonanza',
5257 'bonded',
5258 'bonding',
5259 'bondless',
5260 'boned',
5261 'bonehead',
5262 'boneless',
5263 'bonelike',
5264 'boney',
5265 'bonfire',
5266 'bonnet',
5267 'bonsai',
5268 'bonus',
5269 'bony',
5270 'boogeyman',
5271 'boogieman',
5272 'book',
5273 'boondocks',
5274 'booted',
5275 'booth',
5276 'bootie',
5277 'booting',
5278 'bootlace',
5279 'bootleg',
5280 'boots',
5281 'boozy',
5282 'borax',
5283 'boring',
5284 'borough',
5285 'borrower',
5286 'borrowing',
5287 'boss',
5288 'botanical',
5289 'botanist',
5290 'botany',
5291 'botch',
5292 'both',
5293 'bottle',
5294 'bottling',
5295 'bottom',
5296 'bounce',
5297 'bouncing',
5298 'bouncy',
5299 'bounding',
5300 'boundless',
5301 'bountiful',
5302 'bovine',
5303 'boxcar',
5304 'boxer',
5305 'boxing',
5306 'boxlike',
5307 'boxy',
5308 'breach',
5309 'breath',
5310 'breeches',
5311 'breeching',
5312 'breeder',
5313 'breeding',
5314 'breeze',
5315 'breezy',
5316 'brethren',
5317 'brewery',
5318 'brewing',
5319 'briar',
5320 'bribe',
5321 'brick',
5322 'bride',
5323 'bridged',
5324 'brigade',
5325 'bright',
5326 'brilliant',
5327 'brim',
5328 'bring',
5329 'brink',
5330 'brisket',
5331 'briskly',
5332 'briskness',
5333 'bristle',
5334 'brittle',
5335 'broadband',
5336 'broadcast',
5337 'broaden',
5338 'broadly',
5339 'broadness',
5340 'broadside',
5341 'broadways',
5342 'broiler',
5343 'broiling',
5344 'broken',
5345 'broker',
5346 'bronchial',
5347 'bronco',
5348 'bronze',
5349 'bronzing',
5350 'brook',
5351 'broom',
5352 'brought',
5353 'browbeat',
5354 'brownnose',
5355 'browse',
5356 'browsing',
5357 'bruising',
5358 'brunch',
5359 'brunette',
5360 'brunt',
5361 'brush',
5362 'brussels',
5363 'brute',
5364 'brutishly',
5365 'bubble',
5366 'bubbling',
5367 'bubbly',
5368 'buccaneer',
5369 'bucked',
5370 'bucket',
5371 'buckle',
5372 'buckshot',
5373 'buckskin',
5374 'bucktooth',
5375 'buckwheat',
5376 'buddhism',
5377 'buddhist',
5378 'budding',
5379 'buddy',
5380 'budget',
5381 'buffalo',
5382 'buffed',
5383 'buffer',
5384 'buffing',
5385 'buffoon',
5386 'buggy',
5387 'bulb',
5388 'bulge',
5389 'bulginess',
5390 'bulgur',
5391 'bulk',
5392 'bulldog',
5393 'bulldozer',
5394 'bullfight',
5395 'bullfrog',
5396 'bullhorn',
5397 'bullion',
5398 'bullish',
5399 'bullpen',
5400 'bullring',
5401 'bullseye',
5402 'bullwhip',
5403 'bully',
5404 'bunch',
5405 'bundle',
5406 'bungee',
5407 'bunion',
5408 'bunkbed',
5409 'bunkhouse',
5410 'bunkmate',
5411 'bunny',
5412 'bunt',
5413 'busboy',
5414 'bush',
5415 'busily',
5416 'busload',
5417 'bust',
5418 'busybody',
5419 'buzz',
5420 'cabana',
5421 'cabbage',
5422 'cabbie',
5423 'cabdriver',
5424 'cable',
5425 'caboose',
5426 'cache',
5427 'cackle',
5428 'cacti',
5429 'cactus',
5430 'caddie',
5431 'caddy',
5432 'cadet',
5433 'cadillac',
5434 'cadmium',
5435 'cage',
5436 'cahoots',
5437 'cake',
5438 'calamari',
5439 'calamity',
5440 'calcium',
5441 'calculate',
5442 'calculus',
5443 'caliber',
5444 'calibrate',
5445 'calm',
5446 'caloric',
5447 'calorie',
5448 'calzone',
5449 'camcorder',
5450 'cameo',
5451 'camera',
5452 'camisole',
5453 'camper',
5454 'campfire',
5455 'camping',
5456 'campsite',
5457 'campus',
5458 'canal',
5459 'canary',
5460 'cancel',
5461 'candied',
5462 'candle',
5463 'candy',
5464 'cane',
5465 'canine',
5466 'canister',
5467 'cannabis',
5468 'canned',
5469 'canning',
5470 'cannon',
5471 'cannot',
5472 'canola',
5473 'canon',
5474 'canopener',
5475 'canopy',
5476 'canteen',
5477 'canyon',
5478 'capable',
5479 'capably',
5480 'capacity',
5481 'cape',
5482 'capillary',
5483 'capital',
5484 'capitol',
5485 'capped',
5486 'capricorn',
5487 'capsize',
5488 'capsule',
5489 'caption',
5490 'captivate',
5491 'captive',
5492 'captivity',
5493 'capture',
5494 'caramel',
5495 'carat',
5496 'caravan',
5497 'carbon',
5498 'cardboard',
5499 'carded',
5500 'cardiac',
5501 'cardigan',
5502 'cardinal',
5503 'cardstock',
5504 'carefully',
5505 'caregiver',
5506 'careless',
5507 'caress',
5508 'caretaker',
5509 'cargo',
5510 'caring',
5511 'carless',
5512 'carload',
5513 'carmaker',
5514 'carnage',
5515 'carnation',
5516 'carnival',
5517 'carnivore',
5518 'carol',
5519 'carpenter',
5520 'carpentry',
5521 'carpool',
5522 'carport',
5523 'carried',
5524 'carrot',
5525 'carrousel',
5526 'carry',
5527 'cartel',
5528 'cartload',
5529 'carton',
5530 'cartoon',
5531 'cartridge',
5532 'cartwheel',
5533 'carve',
5534 'carving',
5535 'carwash',
5536 'cascade',
5537 'case',
5538 'cash',
5539 'casing',
5540 'casino',
5541 'casket',
5542 'cassette',
5543 'casually',
5544 'casualty',
5545 'catacomb',
5546 'catalog',
5547 'catalyst',
5548 'catalyze',
5549 'catapult',
5550 'cataract',
5551 'catatonic',
5552 'catcall',
5553 'catchable',
5554 'catcher',
5555 'catching',
5556 'catchy',
5557 'caterer',
5558 'catering',
5559 'catfight',
5560 'catfish',
5561 'cathedral',
5562 'cathouse',
5563 'catlike',
5564 'catnap',
5565 'catnip',
5566 'catsup',
5567 'cattail',
5568 'cattishly',
5569 'cattle',
5570 'catty',
5571 'catwalk',
5572 'caucasian',
5573 'caucus',
5574 'causal',
5575 'causation',
5576 'cause',
5577 'causing',
5578 'cauterize',
5579 'caution',
5580 'cautious',
5581 'cavalier',
5582 'cavalry',
5583 'caviar',
5584 'cavity',
5585 'cedar',
5586 'celery',
5587 'celestial',
5588 'celibacy',
5589 'celibate',
5590 'celtic',
5591 'cement',
5592 'census',
5593 'ceramics',
5594 'ceremony',
5595 'certainly',
5596 'certainty',
5597 'certified',
5598 'certify',
5599 'cesarean',
5600 'cesspool',
5601 'chafe',
5602 'chaffing',
5603 'chain',
5604 'chair',
5605 'chalice',
5606 'challenge',
5607 'chamber',
5608 'chamomile',
5609 'champion',
5610 'chance',
5611 'change',
5612 'channel',
5613 'chant',
5614 'chaos',
5615 'chaperone',
5616 'chaplain',
5617 'chapped',
5618 'chaps',
5619 'chapter',
5620 'character',
5621 'charbroil',
5622 'charcoal',
5623 'charger',
5624 'charging',
5625 'chariot',
5626 'charity',
5627 'charm',
5628 'charred',
5629 'charter',
5630 'charting',
5631 'chase',
5632 'chasing',
5633 'chaste',
5634 'chastise',
5635 'chastity',
5636 'chatroom',
5637 'chatter',
5638 'chatting',
5639 'chatty',
5640 'cheating',
5641 'cheddar',
5642 'cheek',
5643 'cheer',
5644 'cheese',
5645 'cheesy',
5646 'chef',
5647 'chemicals',
5648 'chemist',
5649 'chemo',
5650 'cherisher',
5651 'cherub',
5652 'chess',
5653 'chest',
5654 'chevron',
5655 'chevy',
5656 'chewable',
5657 'chewer',
5658 'chewing',
5659 'chewy',
5660 'chief',
5661 'chihuahua',
5662 'childcare',
5663 'childhood',
5664 'childish',
5665 'childless',
5666 'childlike',
5667 'chili',
5668 'chill',
5669 'chimp',
5670 'chip',
5671 'chirping',
5672 'chirpy',
5673 'chitchat',
5674 'chivalry',
5675 'chive',
5676 'chloride',
5677 'chlorine',
5678 'choice',
5679 'chokehold',
5680 'choking',
5681 'chomp',
5682 'chooser',
5683 'choosing',
5684 'choosy',
5685 'chop',
5686 'chosen',
5687 'chowder',
5688 'chowtime',
5689 'chrome',
5690 'chubby',
5691 'chuck',
5692 'chug',
5693 'chummy',
5694 'chump',
5695 'chunk',
5696 'churn',
5697 'chute',
5698 'cider',
5699 'cilantro',
5700 'cinch',
5701 'cinema',
5702 'cinnamon',
5703 'circle',
5704 'circling',
5705 'circular',
5706 'circulate',
5707 'circus',
5708 'citable',
5709 'citadel',
5710 'citation',
5711 'citizen',
5712 'citric',
5713 'citrus',
5714 'city',
5715 'civic',
5716 'civil',
5717 'clad',
5718 'claim',
5719 'clambake',
5720 'clammy',
5721 'clamor',
5722 'clamp',
5723 'clamshell',
5724 'clang',
5725 'clanking',
5726 'clapped',
5727 'clapper',
5728 'clapping',
5729 'clarify',
5730 'clarinet',
5731 'clarity',
5732 'clash',
5733 'clasp',
5734 'class',
5735 'clatter',
5736 'clause',
5737 'clavicle',
5738 'claw',
5739 'clay',
5740 'clean',
5741 'clear',
5742 'cleat',
5743 'cleaver',
5744 'cleft',
5745 'clench',
5746 'clergyman',
5747 'clerical',
5748 'clerk',
5749 'clever',
5750 'clicker',
5751 'client',
5752 'climate',
5753 'climatic',
5754 'cling',
5755 'clinic',
5756 'clinking',
5757 'clip',
5758 'clique',
5759 'cloak',
5760 'clobber',
5761 'clock',
5762 'clone',
5763 'cloning',
5764 'closable',
5765 'closure',
5766 'clothes',
5767 'clothing',
5768 'cloud',
5769 'clover',
5770 'clubbed',
5771 'clubbing',
5772 'clubhouse',
5773 'clump',
5774 'clumsily',
5775 'clumsy',
5776 'clunky',
5777 'clustered',
5778 'clutch',
5779 'clutter',
5780 'coach',
5781 'coagulant',
5782 'coastal',
5783 'coaster',
5784 'coasting',
5785 'coastland',
5786 'coastline',
5787 'coat',
5788 'coauthor',
5789 'cobalt',
5790 'cobbler',
5791 'cobweb',
5792 'cocoa',
5793 'coconut',
5794 'cod',
5795 'coeditor',
5796 'coerce',
5797 'coexist',
5798 'coffee',
5799 'cofounder',
5800 'cognition',
5801 'cognitive',
5802 'cogwheel',
5803 'coherence',
5804 'coherent',
5805 'cohesive',
5806 'coil',
5807 'coke',
5808 'cola',
5809 'cold',
5810 'coleslaw',
5811 'coliseum',
5812 'collage',
5813 'collapse',
5814 'collar',
5815 'collected',
5816 'collector',
5817 'collide',
5818 'collie',
5819 'collision',
5820 'colonial',
5821 'colonist',
5822 'colonize',
5823 'colony',
5824 'colossal',
5825 'colt',
5826 'coma',
5827 'come',
5828 'comfort',
5829 'comfy',
5830 'comic',
5831 'coming',
5832 'comma',
5833 'commence',
5834 'commend',
5835 'comment',
5836 'commerce',
5837 'commode',
5838 'commodity',
5839 'commodore',
5840 'common',
5841 'commotion',
5842 'commute',
5843 'commuting',
5844 'compacted',
5845 'compacter',
5846 'compactly',
5847 'compactor',
5848 'companion',
5849 'company',
5850 'compare',
5851 'compel',
5852 'compile',
5853 'comply',
5854 'component',
5855 'composed',
5856 'composer',
5857 'composite',
5858 'compost',
5859 'composure',
5860 'compound',
5861 'compress',
5862 'comprised',
5863 'computer',
5864 'computing',
5865 'comrade',
5866 'concave',
5867 'conceal',
5868 'conceded',
5869 'concept',
5870 'concerned',
5871 'concert',
5872 'conch',
5873 'concierge',
5874 'concise',
5875 'conclude',
5876 'concrete',
5877 'concur',
5878 'condense',
5879 'condiment',
5880 'condition',
5881 'condone',
5882 'conducive',
5883 'conductor',
5884 'conduit',
5885 'cone',
5886 'confess',
5887 'confetti',
5888 'confidant',
5889 'confident',
5890 'confider',
5891 'confiding',
5892 'configure',
5893 'confined',
5894 'confining',
5895 'confirm',
5896 'conflict',
5897 'conform',
5898 'confound',
5899 'confront',
5900 'confused',
5901 'confusing',
5902 'confusion',
5903 'congenial',
5904 'congested',
5905 'congrats',
5906 'congress',
5907 'conical',
5908 'conjoined',
5909 'conjure',
5910 'conjuror',
5911 'connected',
5912 'connector',
5913 'consensus',
5914 'consent',
5915 'console',
5916 'consoling',
5917 'consonant',
5918 'constable',
5919 'constant',
5920 'constrain',
5921 'constrict',
5922 'construct',
5923 'consult',
5924 'consumer',
5925 'consuming',
5926 'contact',
5927 'container',
5928 'contempt',
5929 'contend',
5930 'contented',
5931 'contently',
5932 'contents',
5933 'contest',
5934 'context',
5935 'contort',
5936 'contour',
5937 'contrite',
5938 'control',
5939 'contusion',
5940 'convene',
5941 'convent',
5942 'copartner',
5943 'cope',
5944 'copied',
5945 'copier',
5946 'copilot',
5947 'coping',
5948 'copious',
5949 'copper',
5950 'copy',
5951 'coral',
5952 'cork',
5953 'cornball',
5954 'cornbread',
5955 'corncob',
5956 'cornea',
5957 'corned',
5958 'corner',
5959 'cornfield',
5960 'cornflake',
5961 'cornhusk',
5962 'cornmeal',
5963 'cornstalk',
5964 'corny',
5965 'coronary',
5966 'coroner',
5967 'corporal',
5968 'corporate',
5969 'corral',
5970 'correct',
5971 'corridor',
5972 'corrode',
5973 'corroding',
5974 'corrosive',
5975 'corsage',
5976 'corset',
5977 'cortex',
5978 'cosigner',
5979 'cosmetics',
5980 'cosmic',
5981 'cosmos',
5982 'cosponsor',
5983 'cost',
5984 'cottage',
5985 'cotton',
5986 'couch',
5987 'cough',
5988 'could',
5989 'countable',
5990 'countdown',
5991 'counting',
5992 'countless',
5993 'country',
5994 'county',
5995 'courier',
5996 'covenant',
5997 'cover',
5998 'coveted',
5999 'coveting',
6000 'coyness',
6001 'cozily',
6002 'coziness',
6003 'cozy',
6004 'crabbing',
6005 'crabgrass',
6006 'crablike',
6007 'crabmeat',
6008 'cradle',
6009 'cradling',
6010 'crafter',
6011 'craftily',
6012 'craftsman',
6013 'craftwork',
6014 'crafty',
6015 'cramp',
6016 'cranberry',
6017 'crane',
6018 'cranial',
6019 'cranium',
6020 'crank',
6021 'crate',
6022 'crave',
6023 'craving',
6024 'crawfish',
6025 'crawlers',
6026 'crawling',
6027 'crayfish',
6028 'crayon',
6029 'crazed',
6030 'crazily',
6031 'craziness',
6032 'crazy',
6033 'creamed',
6034 'creamer',
6035 'creamlike',
6036 'crease',
6037 'creasing',
6038 'creatable',
6039 'create',
6040 'creation',
6041 'creative',
6042 'creature',
6043 'credible',
6044 'credibly',
6045 'credit',
6046 'creed',
6047 'creme',
6048 'creole',
6049 'crepe',
6050 'crept',
6051 'crescent',
6052 'crested',
6053 'cresting',
6054 'crestless',
6055 'crevice',
6056 'crewless',
6057 'crewman',
6058 'crewmate',
6059 'crib',
6060 'cricket',
6061 'cried',
6062 'crier',
6063 'crimp',
6064 'crimson',
6065 'cringe',
6066 'cringing',
6067 'crinkle',
6068 'crinkly',
6069 'crisped',
6070 'crisping',
6071 'crisply',
6072 'crispness',
6073 'crispy',
6074 'criteria',
6075 'critter',
6076 'croak',
6077 'crock',
6078 'crook',
6079 'croon',
6080 'crop',
6081 'cross',
6082 'crouch',
6083 'crouton',
6084 'crowbar',
6085 'crowd',
6086 'crown',
6087 'crucial',
6088 'crudely',
6089 'crudeness',
6090 'cruelly',
6091 'cruelness',
6092 'cruelty',
6093 'crumb',
6094 'crummiest',
6095 'crummy',
6096 'crumpet',
6097 'crumpled',
6098 'cruncher',
6099 'crunching',
6100 'crunchy',
6101 'crusader',
6102 'crushable',
6103 'crushed',
6104 'crusher',
6105 'crushing',
6106 'crust',
6107 'crux',
6108 'crying',
6109 'cryptic',
6110 'crystal',
6111 'cubbyhole',
6112 'cube',
6113 'cubical',
6114 'cubicle',
6115 'cucumber',
6116 'cuddle',
6117 'cuddly',
6118 'cufflink',
6119 'culinary',
6120 'culminate',
6121 'culpable',
6122 'culprit',
6123 'cultivate',
6124 'cultural',
6125 'culture',
6126 'cupbearer',
6127 'cupcake',
6128 'cupid',
6129 'cupped',
6130 'cupping',
6131 'curable',
6132 'curator',
6133 'curdle',
6134 'cure',
6135 'curfew',
6136 'curing',
6137 'curled',
6138 'curler',
6139 'curliness',
6140 'curling',
6141 'curly',
6142 'curry',
6143 'curse',
6144 'cursive',
6145 'cursor',
6146 'curtain',
6147 'curtly',
6148 'curtsy',
6149 'curvature',
6150 'curve',
6151 'curvy',
6152 'cushy',
6153 'cusp',
6154 'cussed',
6155 'custard',
6156 'custodian',
6157 'custody',
6158 'customary',
6159 'customer',
6160 'customize',
6161 'customs',
6162 'cut',
6163 'cycle',
6164 'cyclic',
6165 'cycling',
6166 'cyclist',
6167 'cylinder',
6168 'cymbal',
6169 'cytoplasm',
6170 'cytoplast',
6171 'dab',
6172 'dad',
6173 'daffodil',
6174 'dagger',
6175 'daily',
6176 'daintily',
6177 'dainty',
6178 'dairy',
6179 'daisy',
6180 'dallying',
6181 'dance',
6182 'dancing',
6183 'dandelion',
6184 'dander',
6185 'dandruff',
6186 'dandy',
6187 'danger',
6188 'dangle',
6189 'dangling',
6190 'daredevil',
6191 'dares',
6192 'daringly',
6193 'darkened',
6194 'darkening',
6195 'darkish',
6196 'darkness',
6197 'darkroom',
6198 'darling',
6199 'darn',
6200 'dart',
6201 'darwinism',
6202 'dash',
6203 'dastardly',
6204 'data',
6205 'datebook',
6206 'dating',
6207 'daughter',
6208 'daunting',
6209 'dawdler',
6210 'dawn',
6211 'daybed',
6212 'daybreak',
6213 'daycare',
6214 'daydream',
6215 'daylight',
6216 'daylong',
6217 'dayroom',
6218 'daytime',
6219 'dazzler',
6220 'dazzling',
6221 'deacon',
6222 'deafening',
6223 'deafness',
6224 'dealer',
6225 'dealing',
6226 'dealmaker',
6227 'dealt',
6228 'dean',
6229 'debatable',
6230 'debate',
6231 'debating',
6232 'debit',
6233 'debrief',
6234 'debtless',
6235 'debtor',
6236 'debug',
6237 'debunk',
6238 'decade',
6239 'decaf',
6240 'decal',
6241 'decathlon',
6242 'decay',
6243 'deceased',
6244 'deceit',
6245 'deceiver',
6246 'deceiving',
6247 'december',
6248 'decency',
6249 'decent',
6250 'deception',
6251 'deceptive',
6252 'decibel',
6253 'decidable',
6254 'decimal',
6255 'decimeter',
6256 'decipher',
6257 'deck',
6258 'declared',
6259 'decline',
6260 'decode',
6261 'decompose',
6262 'decorated',
6263 'decorator',
6264 'decoy',
6265 'decrease',
6266 'decree',
6267 'dedicate',
6268 'dedicator',
6269 'deduce',
6270 'deduct',
6271 'deed',
6272 'deem',
6273 'deepen',
6274 'deeply',
6275 'deepness',
6276 'deface',
6277 'defacing',
6278 'defame',
6279 'default',
6280 'defeat',
6281 'defection',
6282 'defective',
6283 'defendant',
6284 'defender',
6285 'defense',
6286 'defensive',
6287 'deferral',
6288 'deferred',
6289 'defiance',
6290 'defiant',
6291 'defile',
6292 'defiling',
6293 'define',
6294 'definite',
6295 'deflate',
6296 'deflation',
6297 'deflator',
6298 'deflected',
6299 'deflector',
6300 'defog',
6301 'deforest',
6302 'defraud',
6303 'defrost',
6304 'deftly',
6305 'defuse',
6306 'defy',
6307 'degraded',
6308 'degrading',
6309 'degrease',
6310 'degree',
6311 'dehydrate',
6312 'deity',
6313 'dejected',
6314 'delay',
6315 'delegate',
6316 'delegator',
6317 'delete',
6318 'deletion',
6319 'delicacy',
6320 'delicate',
6321 'delicious',
6322 'delighted',
6323 'delirious',
6324 'delirium',
6325 'deliverer',
6326 'delivery',
6327 'delouse',
6328 'delta',
6329 'deluge',
6330 'delusion',
6331 'deluxe',
6332 'demanding',
6333 'demeaning',
6334 'demeanor',
6335 'demise',
6336 'democracy',
6337 'democrat',
6338 'demote',
6339 'demotion',
6340 'demystify',
6341 'denatured',
6342 'deniable',
6343 'denial',
6344 'denim',
6345 'denote',
6346 'dense',
6347 'density',
6348 'dental',
6349 'dentist',
6350 'denture',
6351 'deny',
6352 'deodorant',
6353 'deodorize',
6354 'departed',
6355 'departure',
6356 'depict',
6357 'deplete',
6358 'depletion',
6359 'deplored',
6360 'deploy',
6361 'deport',
6362 'depose',
6363 'depraved',
6364 'depravity',
6365 'deprecate',
6366 'depress',
6367 'deprive',
6368 'depth',
6369 'deputize',
6370 'deputy',
6371 'derail',
6372 'deranged',
6373 'derby',
6374 'derived',
6375 'desecrate',
6376 'deserve',
6377 'deserving',
6378 'designate',
6379 'designed',
6380 'designer',
6381 'designing',
6382 'deskbound',
6383 'desktop',
6384 'deskwork',
6385 'desolate',
6386 'despair',
6387 'despise',
6388 'despite',
6389 'destiny',
6390 'destitute',
6391 'destruct',
6392 'detached',
6393 'detail',
6394 'detection',
6395 'detective',
6396 'detector',
6397 'detention',
6398 'detergent',
6399 'detest',
6400 'detonate',
6401 'detonator',
6402 'detoxify',
6403 'detract',
6404 'deuce',
6405 'devalue',
6406 'deviancy',
6407 'deviant',
6408 'deviate',
6409 'deviation',
6410 'deviator',
6411 'device',
6412 'devious',
6413 'devotedly',
6414 'devotee',
6415 'devotion',
6416 'devourer',
6417 'devouring',
6418 'devoutly',
6419 'dexterity',
6420 'dexterous',
6421 'diabetes',
6422 'diabetic',
6423 'diabolic',
6424 'diagnoses',
6425 'diagnosis',
6426 'diagram',
6427 'dial',
6428 'diameter',
6429 'diaper',
6430 'diaphragm',
6431 'diary',
6432 'dice',
6433 'dicing',
6434 'dictate',
6435 'dictation',
6436 'dictator',
6437 'difficult',
6438 'diffused',
6439 'diffuser',
6440 'diffusion',
6441 'diffusive',
6442 'dig',
6443 'dilation',
6444 'diligence',
6445 'diligent',
6446 'dill',
6447 'dilute',
6448 'dime',
6449 'diminish',
6450 'dimly',
6451 'dimmed',
6452 'dimmer',
6453 'dimness',
6454 'dimple',
6455 'diner',
6456 'dingbat',
6457 'dinghy',
6458 'dinginess',
6459 'dingo',
6460 'dingy',
6461 'dining',
6462 'dinner',
6463 'diocese',
6464 'dioxide',
6465 'diploma',
6466 'dipped',
6467 'dipper',
6468 'dipping',
6469 'directed',
6470 'direction',
6471 'directive',
6472 'directly',
6473 'directory',
6474 'direness',
6475 'dirtiness',
6476 'disabled',
6477 'disagree',
6478 'disallow',
6479 'disarm',
6480 'disarray',
6481 'disaster',
6482 'disband',
6483 'disbelief',
6484 'disburse',
6485 'discard',
6486 'discern',
6487 'discharge',
6488 'disclose',
6489 'discolor',
6490 'discount',
6491 'discourse',
6492 'discover',
6493 'discuss',
6494 'disdain',
6495 'disengage',
6496 'disfigure',
6497 'disgrace',
6498 'dish',
6499 'disinfect',
6500 'disjoin',
6501 'disk',
6502 'dislike',
6503 'disliking',
6504 'dislocate',
6505 'dislodge',
6506 'disloyal',
6507 'dismantle',
6508 'dismay',
6509 'dismiss',
6510 'dismount',
6511 'disobey',
6512 'disorder',
6513 'disown',
6514 'disparate',
6515 'disparity',
6516 'dispatch',
6517 'dispense',
6518 'dispersal',
6519 'dispersed',
6520 'disperser',
6521 'displace',
6522 'display',
6523 'displease',
6524 'disposal',
6525 'dispose',
6526 'disprove',
6527 'dispute',
6528 'disregard',
6529 'disrupt',
6530 'dissuade',
6531 'distance',
6532 'distant',
6533 'distaste',
6534 'distill',
6535 'distinct',
6536 'distort',
6537 'distract',
6538 'distress',
6539 'district',
6540 'distrust',
6541 'ditch',
6542 'ditto',
6543 'ditzy',
6544 'dividable',
6545 'divided',
6546 'dividend',
6547 'dividers',
6548 'dividing',
6549 'divinely',
6550 'diving',
6551 'divinity',
6552 'divisible',
6553 'divisibly',
6554 'division',
6555 'divisive',
6556 'divorcee',
6557 'dizziness',
6558 'dizzy',
6559 'doable',
6560 'docile',
6561 'dock',
6562 'doctrine',
6563 'document',
6564 'dodge',
6565 'dodgy',
6566 'doily',
6567 'doing',
6568 'dole',
6569 'dollar',
6570 'dollhouse',
6571 'dollop',
6572 'dolly',
6573 'dolphin',
6574 'domain',
6575 'domelike',
6576 'domestic',
6577 'dominion',
6578 'dominoes',
6579 'donated',
6580 'donation',
6581 'donator',
6582 'donor',
6583 'donut',
6584 'doodle',
6585 'doorbell',
6586 'doorframe',
6587 'doorknob',
6588 'doorman',
6589 'doormat',
6590 'doornail',
6591 'doorpost',
6592 'doorstep',
6593 'doorstop',
6594 'doorway',
6595 'doozy',
6596 'dork',
6597 'dormitory',
6598 'dorsal',
6599 'dosage',
6600 'dose',
6601 'dotted',
6602 'doubling',
6603 'douche',
6604 'dove',
6605 'down',
6606 'dowry',
6607 'doze',
6608 'drab',
6609 'dragging',
6610 'dragonfly',
6611 'dragonish',
6612 'dragster',
6613 'drainable',
6614 'drainage',
6615 'drained',
6616 'drainer',
6617 'drainpipe',
6618 'dramatic',
6619 'dramatize',
6620 'drank',
6621 'drapery',
6622 'drastic',
6623 'draw',
6624 'dreaded',
6625 'dreadful',
6626 'dreadlock',
6627 'dreamboat',
6628 'dreamily',
6629 'dreamland',
6630 'dreamless',
6631 'dreamlike',
6632 'dreamt',
6633 'dreamy',
6634 'drearily',
6635 'dreary',
6636 'drench',
6637 'dress',
6638 'drew',
6639 'dribble',
6640 'dried',
6641 'drier',
6642 'drift',
6643 'driller',
6644 'drilling',
6645 'drinkable',
6646 'drinking',
6647 'dripping',
6648 'drippy',
6649 'drivable',
6650 'driven',
6651 'driver',
6652 'driveway',
6653 'driving',
6654 'drizzle',
6655 'drizzly',
6656 'drone',
6657 'drool',
6658 'droop',
6659 'drop-down',
6660 'dropbox',
6661 'dropkick',
6662 'droplet',
6663 'dropout',
6664 'dropper',
6665 'drove',
6666 'drown',
6667 'drowsily',
6668 'drudge',
6669 'drum',
6670 'dry',
6671 'dubbed',
6672 'dubiously',
6673 'duchess',
6674 'duckbill',
6675 'ducking',
6676 'duckling',
6677 'ducktail',
6678 'ducky',
6679 'duct',
6680 'dude',
6681 'duffel',
6682 'dugout',
6683 'duh',
6684 'duke',
6685 'duller',
6686 'dullness',
6687 'duly',
6688 'dumping',
6689 'dumpling',
6690 'dumpster',
6691 'duo',
6692 'dupe',
6693 'duplex',
6694 'duplicate',
6695 'duplicity',
6696 'durable',
6697 'durably',
6698 'duration',
6699 'duress',
6700 'during',
6701 'dusk',
6702 'dust',
6703 'dutiful',
6704 'duty',
6705 'duvet',
6706 'dwarf',
6707 'dweeb',
6708 'dwelled',
6709 'dweller',
6710 'dwelling',
6711 'dwindle',
6712 'dwindling',
6713 'dynamic',
6714 'dynamite',
6715 'dynasty',
6716 'dyslexia',
6717 'dyslexic',
6718 'each',
6719 'eagle',
6720 'earache',
6721 'eardrum',
6722 'earflap',
6723 'earful',
6724 'earlobe',
6725 'early',
6726 'earmark',
6727 'earmuff',
6728 'earphone',
6729 'earpiece',
6730 'earplugs',
6731 'earring',
6732 'earshot',
6733 'earthen',
6734 'earthlike',
6735 'earthling',
6736 'earthly',
6737 'earthworm',
6738 'earthy',
6739 'earwig',
6740 'easeful',
6741 'easel',
6742 'easiest',
6743 'easily',
6744 'easiness',
6745 'easing',
6746 'eastbound',
6747 'eastcoast',
6748 'easter',
6749 'eastward',
6750 'eatable',
6751 'eaten',
6752 'eatery',
6753 'eating',
6754 'eats',
6755 'ebay',
6756 'ebony',
6757 'ebook',
6758 'ecard',
6759 'eccentric',
6760 'echo',
6761 'eclair',
6762 'eclipse',
6763 'ecologist',
6764 'ecology',
6765 'economic',
6766 'economist',
6767 'economy',
6768 'ecosphere',
6769 'ecosystem',
6770 'edge',
6771 'edginess',
6772 'edging',
6773 'edgy',
6774 'edition',
6775 'editor',
6776 'educated',
6777 'education',
6778 'educator',
6779 'eel',
6780 'effective',
6781 'effects',
6782 'efficient',
6783 'effort',
6784 'eggbeater',
6785 'egging',
6786 'eggnog',
6787 'eggplant',
6788 'eggshell',
6789 'egomaniac',
6790 'egotism',
6791 'egotistic',
6792 'either',
6793 'eject',
6794 'elaborate',
6795 'elastic',
6796 'elated',
6797 'elbow',
6798 'eldercare',
6799 'elderly',
6800 'eldest',
6801 'electable',
6802 'election',
6803 'elective',
6804 'elephant',
6805 'elevate',
6806 'elevating',
6807 'elevation',
6808 'elevator',
6809 'eleven',
6810 'elf',
6811 'eligible',
6812 'eligibly',
6813 'eliminate',
6814 'elite',
6815 'elitism',
6816 'elixir',
6817 'elk',
6818 'ellipse',
6819 'elliptic',
6820 'elm',
6821 'elongated',
6822 'elope',
6823 'eloquence',
6824 'eloquent',
6825 'elsewhere',
6826 'elude',
6827 'elusive',
6828 'elves',
6829 'email',
6830 'embargo',
6831 'embark',
6832 'embassy',
6833 'embattled',
6834 'embellish',
6835 'ember',
6836 'embezzle',
6837 'emblaze',
6838 'emblem',
6839 'embody',
6840 'embolism',
6841 'emboss',
6842 'embroider',
6843 'emcee',
6844 'emerald',
6845 'emergency',
6846 'emission',
6847 'emit',
6848 'emote',
6849 'emoticon',
6850 'emotion',
6851 'empathic',
6852 'empathy',
6853 'emperor',
6854 'emphases',
6855 'emphasis',
6856 'emphasize',
6857 'emphatic',
6858 'empirical',
6859 'employed',
6860 'employee',
6861 'employer',
6862 'emporium',
6863 'empower',
6864 'emptier',
6865 'emptiness',
6866 'empty',
6867 'emu',
6868 'enable',
6869 'enactment',
6870 'enamel',
6871 'enchanted',
6872 'enchilada',
6873 'encircle',
6874 'enclose',
6875 'enclosure',
6876 'encode',
6877 'encore',
6878 'encounter',
6879 'encourage',
6880 'encroach',
6881 'encrust',
6882 'encrypt',
6883 'endanger',
6884 'endeared',
6885 'endearing',
6886 'ended',
6887 'ending',
6888 'endless',
6889 'endnote',
6890 'endocrine',
6891 'endorphin',
6892 'endorse',
6893 'endowment',
6894 'endpoint',
6895 'endurable',
6896 'endurance',
6897 'enduring',
6898 'energetic',
6899 'energize',
6900 'energy',
6901 'enforced',
6902 'enforcer',
6903 'engaged',
6904 'engaging',
6905 'engine',
6906 'engorge',
6907 'engraved',
6908 'engraver',
6909 'engraving',
6910 'engross',
6911 'engulf',
6912 'enhance',
6913 'enigmatic',
6914 'enjoyable',
6915 'enjoyably',
6916 'enjoyer',
6917 'enjoying',
6918 'enjoyment',
6919 'enlarged',
6920 'enlarging',
6921 'enlighten',
6922 'enlisted',
6923 'enquirer',
6924 'enrage',
6925 'enrich',
6926 'enroll',
6927 'enslave',
6928 'ensnare',
6929 'ensure',
6930 'entail',
6931 'entangled',
6932 'entering',
6933 'entertain',
6934 'enticing',
6935 'entire',
6936 'entitle',
6937 'entity',
6938 'entomb',
6939 'entourage',
6940 'entrap',
6941 'entree',
6942 'entrench',
6943 'entrust',
6944 'entryway',
6945 'entwine',
6946 'enunciate',
6947 'envelope',
6948 'enviable',
6949 'enviably',
6950 'envious',
6951 'envision',
6952 'envoy',
6953 'envy',
6954 'enzyme',
6955 'epic',
6956 'epidemic',
6957 'epidermal',
6958 'epidermis',
6959 'epidural',
6960 'epilepsy',
6961 'epileptic',
6962 'epilogue',
6963 'epiphany',
6964 'episode',
6965 'equal',
6966 'equate',
6967 'equation',
6968 'equator',
6969 'equinox',
6970 'equipment',
6971 'equity',
6972 'equivocal',
6973 'eradicate',
6974 'erasable',
6975 'erased',
6976 'eraser',
6977 'erasure',
6978 'ergonomic',
6979 'errand',
6980 'errant',
6981 'erratic',
6982 'error',
6983 'erupt',
6984 'escalate',
6985 'escalator',
6986 'escapable',
6987 'escapade',
6988 'escapist',
6989 'escargot',
6990 'eskimo',
6991 'esophagus',
6992 'espionage',
6993 'espresso',
6994 'esquire',
6995 'essay',
6996 'essence',
6997 'essential',
6998 'establish',
6999 'estate',
7000 'esteemed',
7001 'estimate',
7002 'estimator',
7003 'estranged',
7004 'estrogen',
7005 'etching',
7006 'eternal',
7007 'eternity',
7008 'ethanol',
7009 'ether',
7010 'ethically',
7011 'ethics',
7012 'euphemism',
7013 'evacuate',
7014 'evacuee',
7015 'evade',
7016 'evaluate',
7017 'evaluator',
7018 'evaporate',
7019 'evasion',
7020 'evasive',
7021 'even',
7022 'everglade',
7023 'evergreen',
7024 'everybody',
7025 'everyday',
7026 'everyone',
7027 'evict',
7028 'evidence',
7029 'evident',
7030 'evil',
7031 'evoke',
7032 'evolution',
7033 'evolve',
7034 'exact',
7035 'exalted',
7036 'example',
7037 'excavate',
7038 'excavator',
7039 'exceeding',
7040 'exception',
7041 'excess',
7042 'exchange',
7043 'excitable',
7044 'exciting',
7045 'exclaim',
7046 'exclude',
7047 'excluding',
7048 'exclusion',
7049 'exclusive',
7050 'excretion',
7051 'excretory',
7052 'excursion',
7053 'excusable',
7054 'excusably',
7055 'excuse',
7056 'exemplary',
7057 'exemplify',
7058 'exemption',
7059 'exerciser',
7060 'exert',
7061 'exes',
7062 'exfoliate',
7063 'exhale',
7064 'exhaust',
7065 'exhume',
7066 'exile',
7067 'existing',
7068 'exit',
7069 'exodus',
7070 'exonerate',
7071 'exorcism',
7072 'exorcist',
7073 'expand',
7074 'expanse',
7075 'expansion',
7076 'expansive',
7077 'expectant',
7078 'expedited',
7079 'expediter',
7080 'expel',
7081 'expend',
7082 'expenses',
7083 'expensive',
7084 'expert',
7085 'expire',
7086 'expiring',
7087 'explain',
7088 'expletive',
7089 'explicit',
7090 'explode',
7091 'exploit',
7092 'explore',
7093 'exploring',
7094 'exponent',
7095 'exporter',
7096 'exposable',
7097 'expose',
7098 'exposure',
7099 'express',
7100 'expulsion',
7101 'exquisite',
7102 'extended',
7103 'extending',
7104 'extent',
7105 'extenuate',
7106 'exterior',
7107 'external',
7108 'extinct',
7109 'extortion',
7110 'extradite',
7111 'extras',
7112 'extrovert',
7113 'extrude',
7114 'extruding',
7115 'exuberant',
7116 'fable',
7117 'fabric',
7118 'fabulous',
7119 'facebook',
7120 'facecloth',
7121 'facedown',
7122 'faceless',
7123 'facelift',
7124 'faceplate',
7125 'faceted',
7126 'facial',
7127 'facility',
7128 'facing',
7129 'facsimile',
7130 'faction',
7131 'factoid',
7132 'factor',
7133 'factsheet',
7134 'factual',
7135 'faculty',
7136 'fade',
7137 'fading',
7138 'failing',
7139 'falcon',
7140 'fall',
7141 'false',
7142 'falsify',
7143 'fame',
7144 'familiar',
7145 'family',
7146 'famine',
7147 'famished',
7148 'fanatic',
7149 'fancied',
7150 'fanciness',
7151 'fancy',
7152 'fanfare',
7153 'fang',
7154 'fanning',
7155 'fantasize',
7156 'fantastic',
7157 'fantasy',
7158 'fascism',
7159 'fastball',
7160 'faster',
7161 'fasting',
7162 'fastness',
7163 'faucet',
7164 'favorable',
7165 'favorably',
7166 'favored',
7167 'favoring',
7168 'favorite',
7169 'fax',
7170 'feast',
7171 'federal',
7172 'fedora',
7173 'feeble',
7174 'feed',
7175 'feel',
7176 'feisty',
7177 'feline',
7178 'felt-tip',
7179 'feminine',
7180 'feminism',
7181 'feminist',
7182 'feminize',
7183 'femur',
7184 'fence',
7185 'fencing',
7186 'fender',
7187 'ferment',
7188 'fernlike',
7189 'ferocious',
7190 'ferocity',
7191 'ferret',
7192 'ferris',
7193 'ferry',
7194 'fervor',
7195 'fester',
7196 'festival',
7197 'festive',
7198 'festivity',
7199 'fetal',
7200 'fetch',
7201 'fever',
7202 'fiber',
7203 'fiction',
7204 'fiddle',
7205 'fiddling',
7206 'fidelity',
7207 'fidgeting',
7208 'fidgety',
7209 'fifteen',
7210 'fifth',
7211 'fiftieth',
7212 'fifty',
7213 'figment',
7214 'figure',
7215 'figurine',
7216 'filing',
7217 'filled',
7218 'filler',
7219 'filling',
7220 'film',
7221 'filter',
7222 'filth',
7223 'filtrate',
7224 'finale',
7225 'finalist',
7226 'finalize',
7227 'finally',
7228 'finance',
7229 'financial',
7230 'finch',
7231 'fineness',
7232 'finer',
7233 'finicky',
7234 'finished',
7235 'finisher',
7236 'finishing',
7237 'finite',
7238 'finless',
7239 'finlike',
7240 'fiscally',
7241 'fit',
7242 'five',
7243 'flaccid',
7244 'flagman',
7245 'flagpole',
7246 'flagship',
7247 'flagstick',
7248 'flagstone',
7249 'flail',
7250 'flakily',
7251 'flaky',
7252 'flame',
7253 'flammable',
7254 'flanked',
7255 'flanking',
7256 'flannels',
7257 'flap',
7258 'flaring',
7259 'flashback',
7260 'flashbulb',
7261 'flashcard',
7262 'flashily',
7263 'flashing',
7264 'flashy',
7265 'flask',
7266 'flatbed',
7267 'flatfoot',
7268 'flatly',
7269 'flatness',
7270 'flatten',
7271 'flattered',
7272 'flatterer',
7273 'flattery',
7274 'flattop',
7275 'flatware',
7276 'flatworm',
7277 'flavored',
7278 'flavorful',
7279 'flavoring',
7280 'flaxseed',
7281 'fled',
7282 'fleshed',
7283 'fleshy',
7284 'flick',
7285 'flier',
7286 'flight',
7287 'flinch',
7288 'fling',
7289 'flint',
7290 'flip',
7291 'flirt',
7292 'float',
7293 'flock',
7294 'flogging',
7295 'flop',
7296 'floral',
7297 'florist',
7298 'floss',
7299 'flounder',
7300 'flyable',
7301 'flyaway',
7302 'flyer',
7303 'flying',
7304 'flyover',
7305 'flypaper',
7306 'foam',
7307 'foe',
7308 'fog',
7309 'foil',
7310 'folic',
7311 'folk',
7312 'follicle',
7313 'follow',
7314 'fondling',
7315 'fondly',
7316 'fondness',
7317 'fondue',
7318 'font',
7319 'food',
7320 'fool',
7321 'footage',
7322 'football',
7323 'footbath',
7324 'footboard',
7325 'footer',
7326 'footgear',
7327 'foothill',
7328 'foothold',
7329 'footing',
7330 'footless',
7331 'footman',
7332 'footnote',
7333 'footpad',
7334 'footpath',
7335 'footprint',
7336 'footrest',
7337 'footsie',
7338 'footsore',
7339 'footwear',
7340 'footwork',
7341 'fossil',
7342 'foster',
7343 'founder',
7344 'founding',
7345 'fountain',
7346 'fox',
7347 'foyer',
7348 'fraction',
7349 'fracture',
7350 'fragile',
7351 'fragility',
7352 'fragment',
7353 'fragrance',
7354 'fragrant',
7355 'frail',
7356 'frame',
7357 'framing',
7358 'frantic',
7359 'fraternal',
7360 'frayed',
7361 'fraying',
7362 'frays',
7363 'freckled',
7364 'freckles',
7365 'freebase',
7366 'freebee',
7367 'freebie',
7368 'freedom',
7369 'freefall',
7370 'freehand',
7371 'freeing',
7372 'freeload',
7373 'freely',
7374 'freemason',
7375 'freeness',
7376 'freestyle',
7377 'freeware',
7378 'freeway',
7379 'freewill',
7380 'freezable',
7381 'freezing',
7382 'freight',
7383 'french',
7384 'frenzied',
7385 'frenzy',
7386 'frequency',
7387 'frequent',
7388 'fresh',
7389 'fretful',
7390 'fretted',
7391 'friction',
7392 'friday',
7393 'fridge',
7394 'fried',
7395 'friend',
7396 'frighten',
7397 'frightful',
7398 'frigidity',
7399 'frigidly',
7400 'frill',
7401 'fringe',
7402 'frisbee',
7403 'frisk',
7404 'fritter',
7405 'frivolous',
7406 'frolic',
7407 'from',
7408 'front',
7409 'frostbite',
7410 'frosted',
7411 'frostily',
7412 'frosting',
7413 'frostlike',
7414 'frosty',
7415 'froth',
7416 'frown',
7417 'frozen',
7418 'fructose',
7419 'frugality',
7420 'frugally',
7421 'fruit',
7422 'frustrate',
7423 'frying',
7424 'gab',
7425 'gaffe',
7426 'gag',
7427 'gainfully',
7428 'gaining',
7429 'gains',
7430 'gala',
7431 'gallantly',
7432 'galleria',
7433 'gallery',
7434 'galley',
7435 'gallon',
7436 'gallows',
7437 'gallstone',
7438 'galore',
7439 'galvanize',
7440 'gambling',
7441 'game',
7442 'gaming',
7443 'gamma',
7444 'gander',
7445 'gangly',
7446 'gangrene',
7447 'gangway',
7448 'gap',
7449 'garage',
7450 'garbage',
7451 'garden',
7452 'gargle',
7453 'garland',
7454 'garlic',
7455 'garment',
7456 'garnet',
7457 'garnish',
7458 'garter',
7459 'gas',
7460 'gatherer',
7461 'gathering',
7462 'gating',
7463 'gauging',
7464 'gauntlet',
7465 'gauze',
7466 'gave',
7467 'gawk',
7468 'gazing',
7469 'gear',
7470 'gecko',
7471 'geek',
7472 'geiger',
7473 'gem',
7474 'gender',
7475 'generic',
7476 'generous',
7477 'genetics',
7478 'genre',
7479 'gentile',
7480 'gentleman',
7481 'gently',
7482 'gents',
7483 'geography',
7484 'geologic',
7485 'geologist',
7486 'geology',
7487 'geometric',
7488 'geometry',
7489 'geranium',
7490 'gerbil',
7491 'geriatric',
7492 'germicide',
7493 'germinate',
7494 'germless',
7495 'germproof',
7496 'gestate',
7497 'gestation',
7498 'gesture',
7499 'getaway',
7500 'getting',
7501 'getup',
7502 'giant',
7503 'gibberish',
7504 'giblet',
7505 'giddily',
7506 'giddiness',
7507 'giddy',
7508 'gift',
7509 'gigabyte',
7510 'gigahertz',
7511 'gigantic',
7512 'giggle',
7513 'giggling',
7514 'giggly',
7515 'gigolo',
7516 'gilled',
7517 'gills',
7518 'gimmick',
7519 'girdle',
7520 'giveaway',
7521 'given',
7522 'giver',
7523 'giving',
7524 'gizmo',
7525 'gizzard',
7526 'glacial',
7527 'glacier',
7528 'glade',
7529 'gladiator',
7530 'gladly',
7531 'glamorous',
7532 'glamour',
7533 'glance',
7534 'glancing',
7535 'glandular',
7536 'glare',
7537 'glaring',
7538 'glass',
7539 'glaucoma',
7540 'glazing',
7541 'gleaming',
7542 'gleeful',
7543 'glider',
7544 'gliding',
7545 'glimmer',
7546 'glimpse',
7547 'glisten',
7548 'glitch',
7549 'glitter',
7550 'glitzy',
7551 'gloater',
7552 'gloating',
7553 'gloomily',
7554 'gloomy',
7555 'glorified',
7556 'glorifier',
7557 'glorify',
7558 'glorious',
7559 'glory',
7560 'gloss',
7561 'glove',
7562 'glowing',
7563 'glowworm',
7564 'glucose',
7565 'glue',
7566 'gluten',
7567 'glutinous',
7568 'glutton',
7569 'gnarly',
7570 'gnat',
7571 'goal',
7572 'goatskin',
7573 'goes',
7574 'goggles',
7575 'going',
7576 'goldfish',
7577 'goldmine',
7578 'goldsmith',
7579 'golf',
7580 'goliath',
7581 'gonad',
7582 'gondola',
7583 'gone',
7584 'gong',
7585 'good',
7586 'gooey',
7587 'goofball',
7588 'goofiness',
7589 'goofy',
7590 'google',
7591 'goon',
7592 'gopher',
7593 'gore',
7594 'gorged',
7595 'gorgeous',
7596 'gory',
7597 'gosling',
7598 'gossip',
7599 'gothic',
7600 'gotten',
7601 'gout',
7602 'gown',
7603 'grab',
7604 'graceful',
7605 'graceless',
7606 'gracious',
7607 'gradation',
7608 'graded',
7609 'grader',
7610 'gradient',
7611 'grading',
7612 'gradually',
7613 'graduate',
7614 'graffiti',
7615 'grafted',
7616 'grafting',
7617 'grain',
7618 'granddad',
7619 'grandkid',
7620 'grandly',
7621 'grandma',
7622 'grandpa',
7623 'grandson',
7624 'granite',
7625 'granny',
7626 'granola',
7627 'grant',
7628 'granular',
7629 'grape',
7630 'graph',
7631 'grapple',
7632 'grappling',
7633 'grasp',
7634 'grass',
7635 'gratified',
7636 'gratify',
7637 'grating',
7638 'gratitude',
7639 'gratuity',
7640 'gravel',
7641 'graveness',
7642 'graves',
7643 'graveyard',
7644 'gravitate',
7645 'gravity',
7646 'gravy',
7647 'gray',
7648 'grazing',
7649 'greasily',
7650 'greedily',
7651 'greedless',
7652 'greedy',
7653 'green',
7654 'greeter',
7655 'greeting',
7656 'grew',
7657 'greyhound',
7658 'grid',
7659 'grief',
7660 'grievance',
7661 'grieving',
7662 'grievous',
7663 'grill',
7664 'grimace',
7665 'grimacing',
7666 'grime',
7667 'griminess',
7668 'grimy',
7669 'grinch',
7670 'grinning',
7671 'grip',
7672 'gristle',
7673 'grit',
7674 'groggily',
7675 'groggy',
7676 'groin',
7677 'groom',
7678 'groove',
7679 'grooving',
7680 'groovy',
7681 'grope',
7682 'ground',
7683 'grouped',
7684 'grout',
7685 'grove',
7686 'grower',
7687 'growing',
7688 'growl',
7689 'grub',
7690 'grudge',
7691 'grudging',
7692 'grueling',
7693 'gruffly',
7694 'grumble',
7695 'grumbling',
7696 'grumbly',
7697 'grumpily',
7698 'grunge',
7699 'grunt',
7700 'guacamole',
7701 'guidable',
7702 'guidance',
7703 'guide',
7704 'guiding',
7705 'guileless',
7706 'guise',
7707 'gulf',
7708 'gullible',
7709 'gully',
7710 'gulp',
7711 'gumball',
7712 'gumdrop',
7713 'gumminess',
7714 'gumming',
7715 'gummy',
7716 'gurgle',
7717 'gurgling',
7718 'guru',
7719 'gush',
7720 'gusto',
7721 'gusty',
7722 'gutless',
7723 'guts',
7724 'gutter',
7725 'guy',
7726 'guzzler',
7727 'gyration',
7728 'habitable',
7729 'habitant',
7730 'habitat',
7731 'habitual',
7732 'hacked',
7733 'hacker',
7734 'hacking',
7735 'hacksaw',
7736 'had',
7737 'haggler',
7738 'haiku',
7739 'half',
7740 'halogen',
7741 'halt',
7742 'halved',
7743 'halves',
7744 'hamburger',
7745 'hamlet',
7746 'hammock',
7747 'hamper',
7748 'hamster',
7749 'hamstring',
7750 'handbag',
7751 'handball',
7752 'handbook',
7753 'handbrake',
7754 'handcart',
7755 'handclap',
7756 'handclasp',
7757 'handcraft',
7758 'handcuff',
7759 'handed',
7760 'handful',
7761 'handgrip',
7762 'handgun',
7763 'handheld',
7764 'handiness',
7765 'handiwork',
7766 'handlebar',
7767 'handled',
7768 'handler',
7769 'handling',
7770 'handmade',
7771 'handoff',
7772 'handpick',
7773 'handprint',
7774 'handrail',
7775 'handsaw',
7776 'handset',
7777 'handsfree',
7778 'handshake',
7779 'handstand',
7780 'handwash',
7781 'handwork',
7782 'handwoven',
7783 'handwrite',
7784 'handyman',
7785 'hangnail',
7786 'hangout',
7787 'hangover',
7788 'hangup',
7789 'hankering',
7790 'hankie',
7791 'hanky',
7792 'haphazard',
7793 'happening',
7794 'happier',
7795 'happiest',
7796 'happily',
7797 'happiness',
7798 'happy',
7799 'harbor',
7800 'hardcopy',
7801 'hardcore',
7802 'hardcover',
7803 'harddisk',
7804 'hardened',
7805 'hardener',
7806 'hardening',
7807 'hardhat',
7808 'hardhead',
7809 'hardiness',
7810 'hardly',
7811 'hardness',
7812 'hardship',
7813 'hardware',
7814 'hardwired',
7815 'hardwood',
7816 'hardy',
7817 'harmful',
7818 'harmless',
7819 'harmonica',
7820 'harmonics',
7821 'harmonize',
7822 'harmony',
7823 'harness',
7824 'harpist',
7825 'harsh',
7826 'harvest',
7827 'hash',
7828 'hassle',
7829 'haste',
7830 'hastily',
7831 'hastiness',
7832 'hasty',
7833 'hatbox',
7834 'hatchback',
7835 'hatchery',
7836 'hatchet',
7837 'hatching',
7838 'hatchling',
7839 'hate',
7840 'hatless',
7841 'hatred',
7842 'haunt',
7843 'haven',
7844 'hazard',
7845 'hazelnut',
7846 'hazily',
7847 'haziness',
7848 'hazing',
7849 'hazy',
7850 'headache',
7851 'headband',
7852 'headboard',
7853 'headcount',
7854 'headdress',
7855 'headed',
7856 'header',
7857 'headfirst',
7858 'headgear',
7859 'heading',
7860 'headlamp',
7861 'headless',
7862 'headlock',
7863 'headphone',
7864 'headpiece',
7865 'headrest',
7866 'headroom',
7867 'headscarf',
7868 'headset',
7869 'headsman',
7870 'headstand',
7871 'headstone',
7872 'headway',
7873 'headwear',
7874 'heap',
7875 'heat',
7876 'heave',
7877 'heavily',
7878 'heaviness',
7879 'heaving',
7880 'hedge',
7881 'hedging',
7882 'heftiness',
7883 'hefty',
7884 'helium',
7885 'helmet',
7886 'helper',
7887 'helpful',
7888 'helping',
7889 'helpless',
7890 'helpline',
7891 'hemlock',
7892 'hemstitch',
7893 'hence',
7894 'henchman',
7895 'henna',
7896 'herald',
7897 'herbal',
7898 'herbicide',
7899 'herbs',
7900 'heritage',
7901 'hermit',
7902 'heroics',
7903 'heroism',
7904 'herring',
7905 'herself',
7906 'hertz',
7907 'hesitancy',
7908 'hesitant',
7909 'hesitate',
7910 'hexagon',
7911 'hexagram',
7912 'hubcap',
7913 'huddle',
7914 'huddling',
7915 'huff',
7916 'hug',
7917 'hula',
7918 'hulk',
7919 'hull',
7920 'human',
7921 'humble',
7922 'humbling',
7923 'humbly',
7924 'humid',
7925 'humiliate',
7926 'humility',
7927 'humming',
7928 'hummus',
7929 'humongous',
7930 'humorist',
7931 'humorless',
7932 'humorous',
7933 'humpback',
7934 'humped',
7935 'humvee',
7936 'hunchback',
7937 'hundredth',
7938 'hunger',
7939 'hungrily',
7940 'hungry',
7941 'hunk',
7942 'hunter',
7943 'hunting',
7944 'huntress',
7945 'huntsman',
7946 'hurdle',
7947 'hurled',
7948 'hurler',
7949 'hurling',
7950 'hurray',
7951 'hurricane',
7952 'hurried',
7953 'hurry',
7954 'hurt',
7955 'husband',
7956 'hush',
7957 'husked',
7958 'huskiness',
7959 'hut',
7960 'hybrid',
7961 'hydrant',
7962 'hydrated',
7963 'hydration',
7964 'hydrogen',
7965 'hydroxide',
7966 'hyperlink',
7967 'hypertext',
7968 'hyphen',
7969 'hypnoses',
7970 'hypnosis',
7971 'hypnotic',
7972 'hypnotism',
7973 'hypnotist',
7974 'hypnotize',
7975 'hypocrisy',
7976 'hypocrite',
7977 'ibuprofen',
7978 'ice',
7979 'iciness',
7980 'icing',
7981 'icky',
7982 'icon',
7983 'icy',
7984 'idealism',
7985 'idealist',
7986 'idealize',
7987 'ideally',
7988 'idealness',
7989 'identical',
7990 'identify',
7991 'identity',
7992 'ideology',
7993 'idiocy',
7994 'idiom',
7995 'idly',
7996 'igloo',
7997 'ignition',
7998 'ignore',
7999 'iguana',
8000 'illicitly',
8001 'illusion',
8002 'illusive',
8003 'image',
8004 'imaginary',
8005 'imagines',
8006 'imaging',
8007 'imbecile',
8008 'imitate',
8009 'imitation',
8010 'immature',
8011 'immerse',
8012 'immersion',
8013 'imminent',
8014 'immobile',
8015 'immodest',
8016 'immorally',
8017 'immortal',
8018 'immovable',
8019 'immovably',
8020 'immunity',
8021 'immunize',
8022 'impaired',
8023 'impale',
8024 'impart',
8025 'impatient',
8026 'impeach',
8027 'impeding',
8028 'impending',
8029 'imperfect',
8030 'imperial',
8031 'impish',
8032 'implant',
8033 'implement',
8034 'implicate',
8035 'implicit',
8036 'implode',
8037 'implosion',
8038 'implosive',
8039 'imply',
8040 'impolite',
8041 'important',
8042 'importer',
8043 'impose',
8044 'imposing',
8045 'impotence',
8046 'impotency',
8047 'impotent',
8048 'impound',
8049 'imprecise',
8050 'imprint',
8051 'imprison',
8052 'impromptu',
8053 'improper',
8054 'improve',
8055 'improving',
8056 'improvise',
8057 'imprudent',
8058 'impulse',
8059 'impulsive',
8060 'impure',
8061 'impurity',
8062 'iodine',
8063 'iodize',
8064 'ion',
8065 'ipad',
8066 'iphone',
8067 'ipod',
8068 'irate',
8069 'irk',
8070 'iron',
8071 'irregular',
8072 'irrigate',
8073 'irritable',
8074 'irritably',
8075 'irritant',
8076 'irritate',
8077 'islamic',
8078 'islamist',
8079 'isolated',
8080 'isolating',
8081 'isolation',
8082 'isotope',
8083 'issue',
8084 'issuing',
8085 'italicize',
8086 'italics',
8087 'item',
8088 'itinerary',
8089 'itunes',
8090 'ivory',
8091 'ivy',
8092 'jab',
8093 'jackal',
8094 'jacket',
8095 'jackknife',
8096 'jackpot',
8097 'jailbird',
8098 'jailbreak',
8099 'jailer',
8100 'jailhouse',
8101 'jalapeno',
8102 'jam',
8103 'janitor',
8104 'january',
8105 'jargon',
8106 'jarring',
8107 'jasmine',
8108 'jaundice',
8109 'jaunt',
8110 'java',
8111 'jawed',
8112 'jawless',
8113 'jawline',
8114 'jaws',
8115 'jaybird',
8116 'jaywalker',
8117 'jazz',
8118 'jeep',
8119 'jeeringly',
8120 'jellied',
8121 'jelly',
8122 'jersey',
8123 'jester',
8124 'jet',
8125 'jiffy',
8126 'jigsaw',
8127 'jimmy',
8128 'jingle',
8129 'jingling',
8130 'jinx',
8131 'jitters',
8132 'jittery',
8133 'job',
8134 'jockey',
8135 'jockstrap',
8136 'jogger',
8137 'jogging',
8138 'john',
8139 'joining',
8140 'jokester',
8141 'jokingly',
8142 'jolliness',
8143 'jolly',
8144 'jolt',
8145 'jot',
8146 'jovial',
8147 'joyfully',
8148 'joylessly',
8149 'joyous',
8150 'joyride',
8151 'joystick',
8152 'jubilance',
8153 'jubilant',
8154 'judge',
8155 'judgingly',
8156 'judicial',
8157 'judiciary',
8158 'judo',
8159 'juggle',
8160 'juggling',
8161 'jugular',
8162 'juice',
8163 'juiciness',
8164 'juicy',
8165 'jujitsu',
8166 'jukebox',
8167 'july',
8168 'jumble',
8169 'jumbo',
8170 'jump',
8171 'junction',
8172 'juncture',
8173 'june',
8174 'junior',
8175 'juniper',
8176 'junkie',
8177 'junkman',
8178 'junkyard',
8179 'jurist',
8180 'juror',
8181 'jury',
8182 'justice',
8183 'justifier',
8184 'justify',
8185 'justly',
8186 'justness',
8187 'juvenile',
8188 'kabob',
8189 'kangaroo',
8190 'karaoke',
8191 'karate',
8192 'karma',
8193 'kebab',
8194 'keenly',
8195 'keenness',
8196 'keep',
8197 'keg',
8198 'kelp',
8199 'kennel',
8200 'kept',
8201 'kerchief',
8202 'kerosene',
8203 'kettle',
8204 'kick',
8205 'kiln',
8206 'kilobyte',
8207 'kilogram',
8208 'kilometer',
8209 'kilowatt',
8210 'kilt',
8211 'kimono',
8212 'kindle',
8213 'kindling',
8214 'kindly',
8215 'kindness',
8216 'kindred',
8217 'kinetic',
8218 'kinfolk',
8219 'king',
8220 'kinship',
8221 'kinsman',
8222 'kinswoman',
8223 'kissable',
8224 'kisser',
8225 'kissing',
8226 'kitchen',
8227 'kite',
8228 'kitten',
8229 'kitty',
8230 'kiwi',
8231 'kleenex',
8232 'knapsack',
8233 'knee',
8234 'knelt',
8235 'knickers',
8236 'knoll',
8237 'koala',
8238 'kooky',
8239 'kosher',
8240 'krypton',
8241 'kudos',
8242 'kung',
8243 'labored',
8244 'laborer',
8245 'laboring',
8246 'laborious',
8247 'labrador',
8248 'ladder',
8249 'ladies',
8250 'ladle',
8251 'ladybug',
8252 'ladylike',
8253 'lagged',
8254 'lagging',
8255 'lagoon',
8256 'lair',
8257 'lake',
8258 'lance',
8259 'landed',
8260 'landfall',
8261 'landfill',
8262 'landing',
8263 'landlady',
8264 'landless',
8265 'landline',
8266 'landlord',
8267 'landmark',
8268 'landmass',
8269 'landmine',
8270 'landowner',
8271 'landscape',
8272 'landside',
8273 'landslide',
8274 'language',
8275 'lankiness',
8276 'lanky',
8277 'lantern',
8278 'lapdog',
8279 'lapel',
8280 'lapped',
8281 'lapping',
8282 'laptop',
8283 'lard',
8284 'large',
8285 'lark',
8286 'lash',
8287 'lasso',
8288 'last',
8289 'latch',
8290 'late',
8291 'lather',
8292 'latitude',
8293 'latrine',
8294 'latter',
8295 'latticed',
8296 'launch',
8297 'launder',
8298 'laundry',
8299 'laurel',
8300 'lavender',
8301 'lavish',
8302 'laxative',
8303 'lazily',
8304 'laziness',
8305 'lazy',
8306 'lecturer',
8307 'left',
8308 'legacy',
8309 'legal',
8310 'legend',
8311 'legged',
8312 'leggings',
8313 'legible',
8314 'legibly',
8315 'legislate',
8316 'lego',
8317 'legroom',
8318 'legume',
8319 'legwarmer',
8320 'legwork',
8321 'lemon',
8322 'lend',
8323 'length',
8324 'lens',
8325 'lent',
8326 'leotard',
8327 'lesser',
8328 'letdown',
8329 'lethargic',
8330 'lethargy',
8331 'letter',
8332 'lettuce',
8333 'level',
8334 'leverage',
8335 'levers',
8336 'levitate',
8337 'levitator',
8338 'liability',
8339 'liable',
8340 'liberty',
8341 'librarian',
8342 'library',
8343 'licking',
8344 'licorice',
8345 'lid',
8346 'life',
8347 'lifter',
8348 'lifting',
8349 'liftoff',
8350 'ligament',
8351 'likely',
8352 'likeness',
8353 'likewise',
8354 'liking',
8355 'lilac',
8356 'lilly',
8357 'lily',
8358 'limb',
8359 'limeade',
8360 'limelight',
8361 'limes',
8362 'limit',
8363 'limping',
8364 'limpness',
8365 'line',
8366 'lingo',
8367 'linguini',
8368 'linguist',
8369 'lining',
8370 'linked',
8371 'linoleum',
8372 'linseed',
8373 'lint',
8374 'lion',
8375 'lip',
8376 'liquefy',
8377 'liqueur',
8378 'liquid',
8379 'lisp',
8380 'list',
8381 'litigate',
8382 'litigator',
8383 'litmus',
8384 'litter',
8385 'little',
8386 'livable',
8387 'lived',
8388 'lively',
8389 'liver',
8390 'livestock',
8391 'lividly',
8392 'living',
8393 'lizard',
8394 'lubricant',
8395 'lubricate',
8396 'lucid',
8397 'luckily',
8398 'luckiness',
8399 'luckless',
8400 'lucrative',
8401 'ludicrous',
8402 'lugged',
8403 'lukewarm',
8404 'lullaby',
8405 'lumber',
8406 'luminance',
8407 'luminous',
8408 'lumpiness',
8409 'lumping',
8410 'lumpish',
8411 'lunacy',
8412 'lunar',
8413 'lunchbox',
8414 'luncheon',
8415 'lunchroom',
8416 'lunchtime',
8417 'lung',
8418 'lurch',
8419 'lure',
8420 'luridness',
8421 'lurk',
8422 'lushly',
8423 'lushness',
8424 'luster',
8425 'lustfully',
8426 'lustily',
8427 'lustiness',
8428 'lustrous',
8429 'lusty',
8430 'luxurious',
8431 'luxury',
8432 'lying',
8433 'lyrically',
8434 'lyricism',
8435 'lyricist',
8436 'lyrics',
8437 'macarena',
8438 'macaroni',
8439 'macaw',
8440 'mace',
8441 'machine',
8442 'machinist',
8443 'magazine',
8444 'magenta',
8445 'maggot',
8446 'magical',
8447 'magician',
8448 'magma',
8449 'magnesium',
8450 'magnetic',
8451 'magnetism',
8452 'magnetize',
8453 'magnifier',
8454 'magnify',
8455 'magnitude',
8456 'magnolia',
8457 'mahogany',
8458 'maimed',
8459 'majestic',
8460 'majesty',
8461 'majorette',
8462 'majority',
8463 'makeover',
8464 'maker',
8465 'makeshift',
8466 'making',
8467 'malformed',
8468 'malt',
8469 'mama',
8470 'mammal',
8471 'mammary',
8472 'mammogram',
8473 'manager',
8474 'managing',
8475 'manatee',
8476 'mandarin',
8477 'mandate',
8478 'mandatory',
8479 'mandolin',
8480 'manger',
8481 'mangle',
8482 'mango',
8483 'mangy',
8484 'manhandle',
8485 'manhole',
8486 'manhood',
8487 'manhunt',
8488 'manicotti',
8489 'manicure',
8490 'manifesto',
8491 'manila',
8492 'mankind',
8493 'manlike',
8494 'manliness',
8495 'manly',
8496 'manmade',
8497 'manned',
8498 'mannish',
8499 'manor',
8500 'manpower',
8501 'mantis',
8502 'mantra',
8503 'manual',
8504 'many',
8505 'map',
8506 'marathon',
8507 'marauding',
8508 'marbled',
8509 'marbles',
8510 'marbling',
8511 'march',
8512 'mardi',
8513 'margarine',
8514 'margarita',
8515 'margin',
8516 'marigold',
8517 'marina',
8518 'marine',
8519 'marital',
8520 'maritime',
8521 'marlin',
8522 'marmalade',
8523 'maroon',
8524 'married',
8525 'marrow',
8526 'marry',
8527 'marshland',
8528 'marshy',
8529 'marsupial',
8530 'marvelous',
8531 'marxism',
8532 'mascot',
8533 'masculine',
8534 'mashed',
8535 'mashing',
8536 'massager',
8537 'masses',
8538 'massive',
8539 'mastiff',
8540 'matador',
8541 'matchbook',
8542 'matchbox',
8543 'matcher',
8544 'matching',
8545 'matchless',
8546 'material',
8547 'maternal',
8548 'maternity',
8549 'math',
8550 'mating',
8551 'matriarch',
8552 'matrimony',
8553 'matrix',
8554 'matron',
8555 'matted',
8556 'matter',
8557 'maturely',
8558 'maturing',
8559 'maturity',
8560 'mauve',
8561 'maverick',
8562 'maximize',
8563 'maximum',
8564 'maybe',
8565 'mayday',
8566 'mayflower',
8567 'moaner',
8568 'moaning',
8569 'mobile',
8570 'mobility',
8571 'mobilize',
8572 'mobster',
8573 'mocha',
8574 'mocker',
8575 'mockup',
8576 'modified',
8577 'modify',
8578 'modular',
8579 'modulator',
8580 'module',
8581 'moisten',
8582 'moistness',
8583 'moisture',
8584 'molar',
8585 'molasses',
8586 'mold',
8587 'molecular',
8588 'molecule',
8589 'molehill',
8590 'mollusk',
8591 'mom',
8592 'monastery',
8593 'monday',
8594 'monetary',
8595 'monetize',
8596 'moneybags',
8597 'moneyless',
8598 'moneywise',
8599 'mongoose',
8600 'mongrel',
8601 'monitor',
8602 'monkhood',
8603 'monogamy',
8604 'monogram',
8605 'monologue',
8606 'monopoly',
8607 'monorail',
8608 'monotone',
8609 'monotype',
8610 'monoxide',
8611 'monsieur',
8612 'monsoon',
8613 'monstrous',
8614 'monthly',
8615 'monument',
8616 'moocher',
8617 'moodiness',
8618 'moody',
8619 'mooing',
8620 'moonbeam',
8621 'mooned',
8622 'moonlight',
8623 'moonlike',
8624 'moonlit',
8625 'moonrise',
8626 'moonscape',
8627 'moonshine',
8628 'moonstone',
8629 'moonwalk',
8630 'mop',
8631 'morale',
8632 'morality',
8633 'morally',
8634 'morbidity',
8635 'morbidly',
8636 'morphine',
8637 'morphing',
8638 'morse',
8639 'mortality',
8640 'mortally',
8641 'mortician',
8642 'mortified',
8643 'mortify',
8644 'mortuary',
8645 'mosaic',
8646 'mossy',
8647 'most',
8648 'mothball',
8649 'mothproof',
8650 'motion',
8651 'motivate',
8652 'motivator',
8653 'motive',
8654 'motocross',
8655 'motor',
8656 'motto',
8657 'mountable',
8658 'mountain',
8659 'mounted',
8660 'mounting',
8661 'mourner',
8662 'mournful',
8663 'mouse',
8664 'mousiness',
8665 'moustache',
8666 'mousy',
8667 'mouth',
8668 'movable',
8669 'move',
8670 'movie',
8671 'moving',
8672 'mower',
8673 'mowing',
8674 'much',
8675 'muck',
8676 'mud',
8677 'mug',
8678 'mulberry',
8679 'mulch',
8680 'mule',
8681 'mulled',
8682 'mullets',
8683 'multiple',
8684 'multiply',
8685 'multitask',
8686 'multitude',
8687 'mumble',
8688 'mumbling',
8689 'mumbo',
8690 'mummified',
8691 'mummify',
8692 'mummy',
8693 'mumps',
8694 'munchkin',
8695 'mundane',
8696 'municipal',
8697 'muppet',
8698 'mural',
8699 'murkiness',
8700 'murky',
8701 'murmuring',
8702 'muscular',
8703 'museum',
8704 'mushily',
8705 'mushiness',
8706 'mushroom',
8707 'mushy',
8708 'music',
8709 'musket',
8710 'muskiness',
8711 'musky',
8712 'mustang',
8713 'mustard',
8714 'muster',
8715 'mustiness',
8716 'musty',
8717 'mutable',
8718 'mutate',
8719 'mutation',
8720 'mute',
8721 'mutilated',
8722 'mutilator',
8723 'mutiny',
8724 'mutt',
8725 'mutual',
8726 'muzzle',
8727 'myself',
8728 'myspace',
8729 'mystified',
8730 'mystify',
8731 'myth',
8732 'nacho',
8733 'nag',
8734 'nail',
8735 'name',
8736 'naming',
8737 'nanny',
8738 'nanometer',
8739 'nape',
8740 'napkin',
8741 'napped',
8742 'napping',
8743 'nappy',
8744 'narrow',
8745 'nastily',
8746 'nastiness',
8747 'national',
8748 'native',
8749 'nativity',
8750 'natural',
8751 'nature',
8752 'naturist',
8753 'nautical',
8754 'navigate',
8755 'navigator',
8756 'navy',
8757 'nearby',
8758 'nearest',
8759 'nearly',
8760 'nearness',
8761 'neatly',
8762 'neatness',
8763 'nebula',
8764 'nebulizer',
8765 'nectar',
8766 'negate',
8767 'negation',
8768 'negative',
8769 'neglector',
8770 'negligee',
8771 'negligent',
8772 'negotiate',
8773 'nemeses',
8774 'nemesis',
8775 'neon',
8776 'nephew',
8777 'nerd',
8778 'nervous',
8779 'nervy',
8780 'nest',
8781 'net',
8782 'neurology',
8783 'neuron',
8784 'neurosis',
8785 'neurotic',
8786 'neuter',
8787 'neutron',
8788 'never',
8789 'next',
8790 'nibble',
8791 'nickname',
8792 'nicotine',
8793 'niece',
8794 'nifty',
8795 'nimble',
8796 'nimbly',
8797 'nineteen',
8798 'ninetieth',
8799 'ninja',
8800 'nintendo',
8801 'ninth',
8802 'nuclear',
8803 'nuclei',
8804 'nucleus',
8805 'nugget',
8806 'nullify',
8807 'number',
8808 'numbing',
8809 'numbly',
8810 'numbness',
8811 'numeral',
8812 'numerate',
8813 'numerator',
8814 'numeric',
8815 'numerous',
8816 'nuptials',
8817 'nursery',
8818 'nursing',
8819 'nurture',
8820 'nutcase',
8821 'nutlike',
8822 'nutmeg',
8823 'nutrient',
8824 'nutshell',
8825 'nuttiness',
8826 'nutty',
8827 'nuzzle',
8828 'nylon',
8829 'oaf',
8830 'oak',
8831 'oasis',
8832 'oat',
8833 'obedience',
8834 'obedient',
8835 'obituary',
8836 'object',
8837 'obligate',
8838 'obliged',
8839 'oblivion',
8840 'oblivious',
8841 'oblong',
8842 'obnoxious',
8843 'oboe',
8844 'obscure',
8845 'obscurity',
8846 'observant',
8847 'observer',
8848 'observing',
8849 'obsessed',
8850 'obsession',
8851 'obsessive',
8852 'obsolete',
8853 'obstacle',
8854 'obstinate',
8855 'obstruct',
8856 'obtain',
8857 'obtrusive',
8858 'obtuse',
8859 'obvious',
8860 'occultist',
8861 'occupancy',
8862 'occupant',
8863 'occupier',
8864 'occupy',
8865 'ocean',
8866 'ocelot',
8867 'octagon',
8868 'octane',
8869 'october',
8870 'octopus',
8871 'ogle',
8872 'oil',
8873 'oink',
8874 'ointment',
8875 'okay',
8876 'old',
8877 'olive',
8878 'olympics',
8879 'omega',
8880 'omen',
8881 'ominous',
8882 'omission',
8883 'omit',
8884 'omnivore',
8885 'onboard',
8886 'oncoming',
8887 'ongoing',
8888 'onion',
8889 'online',
8890 'onlooker',
8891 'only',
8892 'onscreen',
8893 'onset',
8894 'onshore',
8895 'onslaught',
8896 'onstage',
8897 'onto',
8898 'onward',
8899 'onyx',
8900 'oops',
8901 'ooze',
8902 'oozy',
8903 'opacity',
8904 'opal',
8905 'open',
8906 'operable',
8907 'operate',
8908 'operating',
8909 'operation',
8910 'operative',
8911 'operator',
8912 'opium',
8913 'opossum',
8914 'opponent',
8915 'oppose',
8916 'opposing',
8917 'opposite',
8918 'oppressed',
8919 'oppressor',
8920 'opt',
8921 'opulently',
8922 'osmosis',
8923 'other',
8924 'otter',
8925 'ouch',
8926 'ought',
8927 'ounce',
8928 'outage',
8929 'outback',
8930 'outbid',
8931 'outboard',
8932 'outbound',
8933 'outbreak',
8934 'outburst',
8935 'outcast',
8936 'outclass',
8937 'outcome',
8938 'outdated',
8939 'outdoors',
8940 'outer',
8941 'outfield',
8942 'outfit',
8943 'outflank',
8944 'outgoing',
8945 'outgrow',
8946 'outhouse',
8947 'outing',
8948 'outlast',
8949 'outlet',
8950 'outline',
8951 'outlook',
8952 'outlying',
8953 'outmatch',
8954 'outmost',
8955 'outnumber',
8956 'outplayed',
8957 'outpost',
8958 'outpour',
8959 'output',
8960 'outrage',
8961 'outrank',
8962 'outreach',
8963 'outright',
8964 'outscore',
8965 'outsell',
8966 'outshine',
8967 'outshoot',
8968 'outsider',
8969 'outskirts',
8970 'outsmart',
8971 'outsource',
8972 'outspoken',
8973 'outtakes',
8974 'outthink',
8975 'outward',
8976 'outweigh',
8977 'outwit',
8978 'oval',
8979 'ovary',
8980 'oven',
8981 'overact',
8982 'overall',
8983 'overarch',
8984 'overbid',
8985 'overbill',
8986 'overbite',
8987 'overblown',
8988 'overboard',
8989 'overbook',
8990 'overbuilt',
8991 'overcast',
8992 'overcoat',
8993 'overcome',
8994 'overcook',
8995 'overcrowd',
8996 'overdraft',
8997 'overdrawn',
8998 'overdress',
8999 'overdrive',
9000 'overdue',
9001 'overeager',
9002 'overeater',
9003 'overexert',
9004 'overfed',
9005 'overfeed',
9006 'overfill',
9007 'overflow',
9008 'overfull',
9009 'overgrown',
9010 'overhand',
9011 'overhang',
9012 'overhaul',
9013 'overhead',
9014 'overhear',
9015 'overheat',
9016 'overhung',
9017 'overjoyed',
9018 'overkill',
9019 'overlabor',
9020 'overlaid',
9021 'overlap',
9022 'overlay',
9023 'overload',
9024 'overlook',
9025 'overlord',
9026 'overlying',
9027 'overnight',
9028 'overpass',
9029 'overpay',
9030 'overplant',
9031 'overplay',
9032 'overpower',
9033 'overprice',
9034 'overrate',
9035 'overreach',
9036 'overreact',
9037 'override',
9038 'overripe',
9039 'overrule',
9040 'overrun',
9041 'overshoot',
9042 'overshot',
9043 'oversight',
9044 'oversized',
9045 'oversleep',
9046 'oversold',
9047 'overspend',
9048 'overstate',
9049 'overstay',
9050 'overstep',
9051 'overstock',
9052 'overstuff',
9053 'oversweet',
9054 'overtake',
9055 'overthrow',
9056 'overtime',
9057 'overtly',
9058 'overtone',
9059 'overture',
9060 'overturn',
9061 'overuse',
9062 'overvalue',
9063 'overview',
9064 'overwrite',
9065 'owl',
9066 'oxford',
9067 'oxidant',
9068 'oxidation',
9069 'oxidize',
9070 'oxidizing',
9071 'oxygen',
9072 'oxymoron',
9073 'oyster',
9074 'ozone',
9075 'paced',
9076 'pacemaker',
9077 'pacific',
9078 'pacifier',
9079 'pacifism',
9080 'pacifist',
9081 'pacify',
9082 'padded',
9083 'padding',
9084 'paddle',
9085 'paddling',
9086 'padlock',
9087 'pagan',
9088 'pager',
9089 'paging',
9090 'pajamas',
9091 'palace',
9092 'palatable',
9093 'palm',
9094 'palpable',
9095 'palpitate',
9096 'paltry',
9097 'pampered',
9098 'pamperer',
9099 'pampers',
9100 'pamphlet',
9101 'panama',
9102 'pancake',
9103 'pancreas',
9104 'panda',
9105 'pandemic',
9106 'pang',
9107 'panhandle',
9108 'panic',
9109 'panning',
9110 'panorama',
9111 'panoramic',
9112 'panther',
9113 'pantomime',
9114 'pantry',
9115 'pants',
9116 'pantyhose',
9117 'paparazzi',
9118 'papaya',
9119 'paper',
9120 'paprika',
9121 'papyrus',
9122 'parabola',
9123 'parachute',
9124 'parade',
9125 'paradox',
9126 'paragraph',
9127 'parakeet',
9128 'paralegal',
9129 'paralyses',
9130 'paralysis',
9131 'paralyze',
9132 'paramedic',
9133 'parameter',
9134 'paramount',
9135 'parasail',
9136 'parasite',
9137 'parasitic',
9138 'parcel',
9139 'parched',
9140 'parchment',
9141 'pardon',
9142 'parish',
9143 'parka',
9144 'parking',
9145 'parkway',
9146 'parlor',
9147 'parmesan',
9148 'parole',
9149 'parrot',
9150 'parsley',
9151 'parsnip',
9152 'partake',
9153 'parted',
9154 'parting',
9155 'partition',
9156 'partly',
9157 'partner',
9158 'partridge',
9159 'party',
9160 'passable',
9161 'passably',
9162 'passage',
9163 'passcode',
9164 'passenger',
9165 'passerby',
9166 'passing',
9167 'passion',
9168 'passive',
9169 'passivism',
9170 'passover',
9171 'passport',
9172 'password',
9173 'pasta',
9174 'pasted',
9175 'pastel',
9176 'pastime',
9177 'pastor',
9178 'pastrami',
9179 'pasture',
9180 'pasty',
9181 'patchwork',
9182 'patchy',
9183 'paternal',
9184 'paternity',
9185 'path',
9186 'patience',
9187 'patient',
9188 'patio',
9189 'patriarch',
9190 'patriot',
9191 'patrol',
9192 'patronage',
9193 'patronize',
9194 'pauper',
9195 'pavement',
9196 'paver',
9197 'pavestone',
9198 'pavilion',
9199 'paving',
9200 'pawing',
9201 'payable',
9202 'payback',
9203 'paycheck',
9204 'payday',
9205 'payee',
9206 'payer',
9207 'paying',
9208 'payment',
9209 'payphone',
9210 'payroll',
9211 'pebble',
9212 'pebbly',
9213 'pecan',
9214 'pectin',
9215 'peculiar',
9216 'peddling',
9217 'pediatric',
9218 'pedicure',
9219 'pedigree',
9220 'pedometer',
9221 'pegboard',
9222 'pelican',
9223 'pellet',
9224 'pelt',
9225 'pelvis',
9226 'penalize',
9227 'penalty',
9228 'pencil',
9229 'pendant',
9230 'pending',
9231 'penholder',
9232 'penknife',
9233 'pennant',
9234 'penniless',
9235 'penny',
9236 'penpal',
9237 'pension',
9238 'pentagon',
9239 'pentagram',
9240 'pep',
9241 'perceive',
9242 'percent',
9243 'perch',
9244 'percolate',
9245 'perennial',
9246 'perfected',
9247 'perfectly',
9248 'perfume',
9249 'periscope',
9250 'perish',
9251 'perjurer',
9252 'perjury',
9253 'perkiness',
9254 'perky',
9255 'perm',
9256 'peroxide',
9257 'perpetual',
9258 'perplexed',
9259 'persecute',
9260 'persevere',
9261 'persuaded',
9262 'persuader',
9263 'pesky',
9264 'peso',
9265 'pessimism',
9266 'pessimist',
9267 'pester',
9268 'pesticide',
9269 'petal',
9270 'petite',
9271 'petition',
9272 'petri',
9273 'petroleum',
9274 'petted',
9275 'petticoat',
9276 'pettiness',
9277 'petty',
9278 'petunia',
9279 'phantom',
9280 'phobia',
9281 'phoenix',
9282 'phonebook',
9283 'phoney',
9284 'phonics',
9285 'phoniness',
9286 'phony',
9287 'phosphate',
9288 'photo',
9289 'phrase',
9290 'phrasing',
9291 'placard',
9292 'placate',
9293 'placidly',
9294 'plank',
9295 'planner',
9296 'plant',
9297 'plasma',
9298 'plaster',
9299 'plastic',
9300 'plated',
9301 'platform',
9302 'plating',
9303 'platinum',
9304 'platonic',
9305 'platter',
9306 'platypus',
9307 'plausible',
9308 'plausibly',
9309 'playable',
9310 'playback',
9311 'player',
9312 'playful',
9313 'playgroup',
9314 'playhouse',
9315 'playing',
9316 'playlist',
9317 'playmaker',
9318 'playmate',
9319 'playoff',
9320 'playpen',
9321 'playroom',
9322 'playset',
9323 'plaything',
9324 'playtime',
9325 'plaza',
9326 'pleading',
9327 'pleat',
9328 'pledge',
9329 'plentiful',
9330 'plenty',
9331 'plethora',
9332 'plexiglas',
9333 'pliable',
9334 'plod',
9335 'plop',
9336 'plot',
9337 'plow',
9338 'ploy',
9339 'pluck',
9340 'plug',
9341 'plunder',
9342 'plunging',
9343 'plural',
9344 'plus',
9345 'plutonium',
9346 'plywood',
9347 'poach',
9348 'pod',
9349 'poem',
9350 'poet',
9351 'pogo',
9352 'pointed',
9353 'pointer',
9354 'pointing',
9355 'pointless',
9356 'pointy',
9357 'poise',
9358 'poison',
9359 'poker',
9360 'poking',
9361 'polar',
9362 'police',
9363 'policy',
9364 'polio',
9365 'polish',
9366 'politely',
9367 'polka',
9368 'polo',
9369 'polyester',
9370 'polygon',
9371 'polygraph',
9372 'polymer',
9373 'poncho',
9374 'pond',
9375 'pony',
9376 'popcorn',
9377 'pope',
9378 'poplar',
9379 'popper',
9380 'poppy',
9381 'popsicle',
9382 'populace',
9383 'popular',
9384 'populate',
9385 'porcupine',
9386 'pork',
9387 'porous',
9388 'porridge',
9389 'portable',
9390 'portal',
9391 'portfolio',
9392 'porthole',
9393 'portion',
9394 'portly',
9395 'portside',
9396 'poser',
9397 'posh',
9398 'posing',
9399 'possible',
9400 'possibly',
9401 'possum',
9402 'postage',
9403 'postal',
9404 'postbox',
9405 'postcard',
9406 'posted',
9407 'poster',
9408 'posting',
9409 'postnasal',
9410 'posture',
9411 'postwar',
9412 'pouch',
9413 'pounce',
9414 'pouncing',
9415 'pound',
9416 'pouring',
9417 'pout',
9418 'powdered',
9419 'powdering',
9420 'powdery',
9421 'power',
9422 'powwow',
9423 'pox',
9424 'praising',
9425 'prance',
9426 'prancing',
9427 'pranker',
9428 'prankish',
9429 'prankster',
9430 'prayer',
9431 'praying',
9432 'preacher',
9433 'preaching',
9434 'preachy',
9435 'preamble',
9436 'precinct',
9437 'precise',
9438 'precision',
9439 'precook',
9440 'precut',
9441 'predator',
9442 'predefine',
9443 'predict',
9444 'preface',
9445 'prefix',
9446 'preflight',
9447 'preformed',
9448 'pregame',
9449 'pregnancy',
9450 'pregnant',
9451 'preheated',
9452 'prelaunch',
9453 'prelaw',
9454 'prelude',
9455 'premiere',
9456 'premises',
9457 'premium',
9458 'prenatal',
9459 'preoccupy',
9460 'preorder',
9461 'prepaid',
9462 'prepay',
9463 'preplan',
9464 'preppy',
9465 'preschool',
9466 'prescribe',
9467 'preseason',
9468 'preset',
9469 'preshow',
9470 'president',
9471 'presoak',
9472 'press',
9473 'presume',
9474 'presuming',
9475 'preteen',
9476 'pretended',
9477 'pretender',
9478 'pretense',
9479 'pretext',
9480 'pretty',
9481 'pretzel',
9482 'prevail',
9483 'prevalent',
9484 'prevent',
9485 'preview',
9486 'previous',
9487 'prewar',
9488 'prewashed',
9489 'prideful',
9490 'pried',
9491 'primal',
9492 'primarily',
9493 'primary',
9494 'primate',
9495 'primer',
9496 'primp',
9497 'princess',
9498 'print',
9499 'prior',
9500 'prism',
9501 'prison',
9502 'prissy',
9503 'pristine',
9504 'privacy',
9505 'private',
9506 'privatize',
9507 'prize',
9508 'proactive',
9509 'probable',
9510 'probably',
9511 'probation',
9512 'probe',
9513 'probing',
9514 'probiotic',
9515 'problem',
9516 'procedure',
9517 'process',
9518 'proclaim',
9519 'procreate',
9520 'procurer',
9521 'prodigal',
9522 'prodigy',
9523 'produce',
9524 'product',
9525 'profane',
9526 'profanity',
9527 'professed',
9528 'professor',
9529 'profile',
9530 'profound',
9531 'profusely',
9532 'progeny',
9533 'prognosis',
9534 'program',
9535 'progress',
9536 'projector',
9537 'prologue',
9538 'prolonged',
9539 'promenade',
9540 'prominent',
9541 'promoter',
9542 'promotion',
9543 'prompter',
9544 'promptly',
9545 'prone',
9546 'prong',
9547 'pronounce',
9548 'pronto',
9549 'proofing',
9550 'proofread',
9551 'proofs',
9552 'propeller',
9553 'properly',
9554 'property',
9555 'proponent',
9556 'proposal',
9557 'propose',
9558 'props',
9559 'prorate',
9560 'protector',
9561 'protegee',
9562 'proton',
9563 'prototype',
9564 'protozoan',
9565 'protract',
9566 'protrude',
9567 'proud',
9568 'provable',
9569 'proved',
9570 'proven',
9571 'provided',
9572 'provider',
9573 'providing',
9574 'province',
9575 'proving',
9576 'provoke',
9577 'provoking',
9578 'provolone',
9579 'prowess',
9580 'prowler',
9581 'prowling',
9582 'proximity',
9583 'proxy',
9584 'prozac',
9585 'prude',
9586 'prudishly',
9587 'prune',
9588 'pruning',
9589 'pry',
9590 'psychic',
9591 'public',
9592 'publisher',
9593 'pucker',
9594 'pueblo',
9595 'pug',
9596 'pull',
9597 'pulmonary',
9598 'pulp',
9599 'pulsate',
9600 'pulse',
9601 'pulverize',
9602 'puma',
9603 'pumice',
9604 'pummel',
9605 'punch',
9606 'punctual',
9607 'punctuate',
9608 'punctured',
9609 'pungent',
9610 'punisher',
9611 'punk',
9612 'pupil',
9613 'puppet',
9614 'puppy',
9615 'purchase',
9616 'pureblood',
9617 'purebred',
9618 'purely',
9619 'pureness',
9620 'purgatory',
9621 'purge',
9622 'purging',
9623 'purifier',
9624 'purify',
9625 'purist',
9626 'puritan',
9627 'purity',
9628 'purple',
9629 'purplish',
9630 'purposely',
9631 'purr',
9632 'purse',
9633 'pursuable',
9634 'pursuant',
9635 'pursuit',
9636 'purveyor',
9637 'pushcart',
9638 'pushchair',
9639 'pusher',
9640 'pushiness',
9641 'pushing',
9642 'pushover',
9643 'pushpin',
9644 'pushup',
9645 'pushy',
9646 'putdown',
9647 'putt',
9648 'puzzle',
9649 'puzzling',
9650 'pyramid',
9651 'pyromania',
9652 'python',
9653 'quack',
9654 'quadrant',
9655 'quail',
9656 'quaintly',
9657 'quake',
9658 'quaking',
9659 'qualified',
9660 'qualifier',
9661 'qualify',
9662 'quality',
9663 'qualm',
9664 'quantum',
9665 'quarrel',
9666 'quarry',
9667 'quartered',
9668 'quarterly',
9669 'quarters',
9670 'quartet',
9671 'quench',
9672 'query',
9673 'quicken',
9674 'quickly',
9675 'quickness',
9676 'quicksand',
9677 'quickstep',
9678 'quiet',
9679 'quill',
9680 'quilt',
9681 'quintet',
9682 'quintuple',
9683 'quirk',
9684 'quit',
9685 'quiver',
9686 'quizzical',
9687 'quotable',
9688 'quotation',
9689 'quote',
9690 'rabid',
9691 'race',
9692 'racing',
9693 'racism',
9694 'rack',
9695 'racoon',
9696 'radar',
9697 'radial',
9698 'radiance',
9699 'radiantly',
9700 'radiated',
9701 'radiation',
9702 'radiator',
9703 'radio',
9704 'radish',
9705 'raffle',
9706 'raft',
9707 'rage',
9708 'ragged',
9709 'raging',
9710 'ragweed',
9711 'raider',
9712 'railcar',
9713 'railing',
9714 'railroad',
9715 'railway',
9716 'raisin',
9717 'rake',
9718 'raking',
9719 'rally',
9720 'ramble',
9721 'rambling',
9722 'ramp',
9723 'ramrod',
9724 'ranch',
9725 'rancidity',
9726 'random',
9727 'ranged',
9728 'ranger',
9729 'ranging',
9730 'ranked',
9731 'ranking',
9732 'ransack',
9733 'ranting',
9734 'rants',
9735 'rare',
9736 'rarity',
9737 'rascal',
9738 'rash',
9739 'rasping',
9740 'ravage',
9741 'raven',
9742 'ravine',
9743 'raving',
9744 'ravioli',
9745 'ravishing',
9746 'reabsorb',
9747 'reach',
9748 'reacquire',
9749 'reaction',
9750 'reactive',
9751 'reactor',
9752 'reaffirm',
9753 'ream',
9754 'reanalyze',
9755 'reappear',
9756 'reapply',
9757 'reappoint',
9758 'reapprove',
9759 'rearrange',
9760 'rearview',
9761 'reason',
9762 'reassign',
9763 'reassure',
9764 'reattach',
9765 'reawake',
9766 'rebalance',
9767 'rebate',
9768 'rebel',
9769 'rebirth',
9770 'reboot',
9771 'reborn',
9772 'rebound',
9773 'rebuff',
9774 'rebuild',
9775 'rebuilt',
9776 'reburial',
9777 'rebuttal',
9778 'recall',
9779 'recant',
9780 'recapture',
9781 'recast',
9782 'recede',
9783 'recent',
9784 'recess',
9785 'recharger',
9786 'recipient',
9787 'recital',
9788 'recite',
9789 'reckless',
9790 'reclaim',
9791 'recliner',
9792 'reclining',
9793 'recluse',
9794 'reclusive',
9795 'recognize',
9796 'recoil',
9797 'recollect',
9798 'recolor',
9799 'reconcile',
9800 'reconfirm',
9801 'reconvene',
9802 'recopy',
9803 'record',
9804 'recount',
9805 'recoup',
9806 'recovery',
9807 'recreate',
9808 'rectal',
9809 'rectangle',
9810 'rectified',
9811 'rectify',
9812 'recycled',
9813 'recycler',
9814 'recycling',
9815 'reemerge',
9816 'reenact',
9817 'reenter',
9818 'reentry',
9819 'reexamine',
9820 'referable',
9821 'referee',
9822 'reference',
9823 'refill',
9824 'refinance',
9825 'refined',
9826 'refinery',
9827 'refining',
9828 'refinish',
9829 'reflected',
9830 'reflector',
9831 'reflex',
9832 'reflux',
9833 'refocus',
9834 'refold',
9835 'reforest',
9836 'reformat',
9837 'reformed',
9838 'reformer',
9839 'reformist',
9840 'refract',
9841 'refrain',
9842 'refreeze',
9843 'refresh',
9844 'refried',
9845 'refueling',
9846 'refund',
9847 'refurbish',
9848 'refurnish',
9849 'refusal',
9850 'refuse',
9851 'refusing',
9852 'refutable',
9853 'refute',
9854 'regain',
9855 'regalia',
9856 'regally',
9857 'reggae',
9858 'regime',
9859 'region',
9860 'register',
9861 'registrar',
9862 'registry',
9863 'regress',
9864 'regretful',
9865 'regroup',
9866 'regular',
9867 'regulate',
9868 'regulator',
9869 'rehab',
9870 'reheat',
9871 'rehire',
9872 'rehydrate',
9873 'reimburse',
9874 'reissue',
9875 'reiterate',
9876 'rejoice',
9877 'rejoicing',
9878 'rejoin',
9879 'rekindle',
9880 'relapse',
9881 'relapsing',
9882 'relatable',
9883 'related',
9884 'relation',
9885 'relative',
9886 'relax',
9887 'relay',
9888 'relearn',
9889 'release',
9890 'relenting',
9891 'reliable',
9892 'reliably',
9893 'reliance',
9894 'reliant',
9895 'relic',
9896 'relieve',
9897 'relieving',
9898 'relight',
9899 'relish',
9900 'relive',
9901 'reload',
9902 'relocate',
9903 'relock',
9904 'reluctant',
9905 'rely',
9906 'remake',
9907 'remark',
9908 'remarry',
9909 'rematch',
9910 'remedial',
9911 'remedy',
9912 'remember',
9913 'reminder',
9914 'remindful',
9915 'remission',
9916 'remix',
9917 'remnant',
9918 'remodeler',
9919 'remold',
9920 'remorse',
9921 'remote',
9922 'removable',
9923 'removal',
9924 'removed',
9925 'remover',
9926 'removing',
9927 'rename',
9928 'renderer',
9929 'rendering',
9930 'rendition',
9931 'renegade',
9932 'renewable',
9933 'renewably',
9934 'renewal',
9935 'renewed',
9936 'renounce',
9937 'renovate',
9938 'renovator',
9939 'rentable',
9940 'rental',
9941 'rented',
9942 'renter',
9943 'reoccupy',
9944 'reoccur',
9945 'reopen',
9946 'reorder',
9947 'repackage',
9948 'repacking',
9949 'repaint',
9950 'repair',
9951 'repave',
9952 'repaying',
9953 'repayment',
9954 'repeal',
9955 'repeated',
9956 'repeater',
9957 'repent',
9958 'rephrase',
9959 'replace',
9960 'replay',
9961 'replica',
9962 'reply',
9963 'reporter',
9964 'repose',
9965 'repossess',
9966 'repost',
9967 'repressed',
9968 'reprimand',
9969 'reprint',
9970 'reprise',
9971 'reproach',
9972 'reprocess',
9973 'reproduce',
9974 'reprogram',
9975 'reps',
9976 'reptile',
9977 'reptilian',
9978 'repugnant',
9979 'repulsion',
9980 'repulsive',
9981 'repurpose',
9982 'reputable',
9983 'reputably',
9984 'request',
9985 'require',
9986 'requisite',
9987 'reroute',
9988 'rerun',
9989 'resale',
9990 'resample',
9991 'rescuer',
9992 'reseal',
9993 'research',
9994 'reselect',
9995 'reseller',
9996 'resemble',
9997 'resend',
9998 'resent',
9999 'reset',
10000 'reshape',
10001 'reshoot',
10002 'reshuffle',
10003 'residence',
10004 'residency',
10005 'resident',
10006 'residual',
10007 'residue',
10008 'resigned',
10009 'resilient',
10010 'resistant',
10011 'resisting',
10012 'resize',
10013 'resolute',
10014 'resolved',
10015 'resonant',
10016 'resonate',
10017 'resort',
10018 'resource',
10019 'respect',
10020 'resubmit',
10021 'result',
10022 'resume',
10023 'resupply',
10024 'resurface',
10025 'resurrect',
10026 'retail',
10027 'retainer',
10028 'retaining',
10029 'retake',
10030 'retaliate',
10031 'retention',
10032 'rethink',
10033 'retinal',
10034 'retired',
10035 'retiree',
10036 'retiring',
10037 'retold',
10038 'retool',
10039 'retorted',
10040 'retouch',
10041 'retrace',
10042 'retract',
10043 'retrain',
10044 'retread',
10045 'retreat',
10046 'retrial',
10047 'retrieval',
10048 'retriever',
10049 'retry',
10050 'return',
10051 'retying',
10052 'retype',
10053 'reunion',
10054 'reunite',
10055 'reusable',
10056 'reuse',
10057 'reveal',
10058 'reveler',
10059 'revenge',
10060 'revenue',
10061 'reverb',
10062 'revered',
10063 'reverence',
10064 'reverend',
10065 'reversal',
10066 'reverse',
10067 'reversing',
10068 'reversion',
10069 'revert',
10070 'revisable',
10071 'revise',
10072 'revision',
10073 'revisit',
10074 'revivable',
10075 'revival',
10076 'reviver',
10077 'reviving',
10078 'revocable',
10079 'revoke',
10080 'revolt',
10081 'revolver',
10082 'revolving',
10083 'reward',
10084 'rewash',
10085 'rewind',
10086 'rewire',
10087 'reword',
10088 'rework',
10089 'rewrap',
10090 'rewrite',
10091 'rhyme',
10092 'ribbon',
10093 'ribcage',
10094 'rice',
10095 'riches',
10096 'richly',
10097 'richness',
10098 'rickety',
10099 'ricotta',
10100 'riddance',
10101 'ridden',
10102 'ride',
10103 'riding',
10104 'rifling',
10105 'rift',
10106 'rigging',
10107 'rigid',
10108 'rigor',
10109 'rimless',
10110 'rimmed',
10111 'rind',
10112 'rink',
10113 'rinse',
10114 'rinsing',
10115 'riot',
10116 'ripcord',
10117 'ripeness',
10118 'ripening',
10119 'ripping',
10120 'ripple',
10121 'rippling',
10122 'riptide',
10123 'rise',
10124 'rising',
10125 'risk',
10126 'risotto',
10127 'ritalin',
10128 'ritzy',
10129 'rival',
10130 'riverbank',
10131 'riverbed',
10132 'riverboat',
10133 'riverside',
10134 'riveter',
10135 'riveting',
10136 'roamer',
10137 'roaming',
10138 'roast',
10139 'robbing',
10140 'robe',
10141 'robin',
10142 'robotics',
10143 'robust',
10144 'rockband',
10145 'rocker',
10146 'rocket',
10147 'rockfish',
10148 'rockiness',
10149 'rocking',
10150 'rocklike',
10151 'rockslide',
10152 'rockstar',
10153 'rocky',
10154 'rogue',
10155 'roman',
10156 'romp',
10157 'rope',
10158 'roping',
10159 'roster',
10160 'rosy',
10161 'rotten',
10162 'rotting',
10163 'rotunda',
10164 'roulette',
10165 'rounding',
10166 'roundish',
10167 'roundness',
10168 'roundup',
10169 'roundworm',
10170 'routine',
10171 'routing',
10172 'rover',
10173 'roving',
10174 'royal',
10175 'rubbed',
10176 'rubber',
10177 'rubbing',
10178 'rubble',
10179 'rubdown',
10180 'ruby',
10181 'ruckus',
10182 'rudder',
10183 'rug',
10184 'ruined',
10185 'rule',
10186 'rumble',
10187 'rumbling',
10188 'rummage',
10189 'rumor',
10190 'runaround',
10191 'rundown',
10192 'runner',
10193 'running',
10194 'runny',
10195 'runt',
10196 'runway',
10197 'rupture',
10198 'rural',
10199 'ruse',
10200 'rush',
10201 'rust',
10202 'rut',
10203 'sabbath',
10204 'sabotage',
10205 'sacrament',
10206 'sacred',
10207 'sacrifice',
10208 'sadden',
10209 'saddlebag',
10210 'saddled',
10211 'saddling',
10212 'sadly',
10213 'sadness',
10214 'safari',
10215 'safeguard',
10216 'safehouse',
10217 'safely',
10218 'safeness',
10219 'saffron',
10220 'saga',
10221 'sage',
10222 'sagging',
10223 'saggy',
10224 'said',
10225 'saint',
10226 'sake',
10227 'salad',
10228 'salami',
10229 'salaried',
10230 'salary',
10231 'saline',
10232 'salon',
10233 'saloon',
10234 'salsa',
10235 'salt',
10236 'salutary',
10237 'salute',
10238 'salvage',
10239 'salvaging',
10240 'salvation',
10241 'same',
10242 'sample',
10243 'sampling',
10244 'sanction',
10245 'sanctity',
10246 'sanctuary',
10247 'sandal',
10248 'sandbag',
10249 'sandbank',
10250 'sandbar',
10251 'sandblast',
10252 'sandbox',
10253 'sanded',
10254 'sandfish',
10255 'sanding',
10256 'sandlot',
10257 'sandpaper',
10258 'sandpit',
10259 'sandstone',
10260 'sandstorm',
10261 'sandworm',
10262 'sandy',
10263 'sanitary',
10264 'sanitizer',
10265 'sank',
10266 'santa',
10267 'sapling',
10268 'sappiness',
10269 'sappy',
10270 'sarcasm',
10271 'sarcastic',
10272 'sardine',
10273 'sash',
10274 'sasquatch',
10275 'sassy',
10276 'satchel',
10277 'satiable',
10278 'satin',
10279 'satirical',
10280 'satisfied',
10281 'satisfy',
10282 'saturate',
10283 'saturday',
10284 'sauciness',
10285 'saucy',
10286 'sauna',
10287 'savage',
10288 'savanna',
10289 'saved',
10290 'savings',
10291 'savior',
10292 'savor',
10293 'saxophone',
10294 'say',
10295 'scabbed',
10296 'scabby',
10297 'scalded',
10298 'scalding',
10299 'scale',
10300 'scaling',
10301 'scallion',
10302 'scallop',
10303 'scalping',
10304 'scam',
10305 'scandal',
10306 'scanner',
10307 'scanning',
10308 'scant',
10309 'scapegoat',
10310 'scarce',
10311 'scarcity',
10312 'scarecrow',
10313 'scared',
10314 'scarf',
10315 'scarily',
10316 'scariness',
10317 'scarring',
10318 'scary',
10319 'scavenger',
10320 'scenic',
10321 'schedule',
10322 'schematic',
10323 'scheme',
10324 'scheming',
10325 'schilling',
10326 'schnapps',
10327 'scholar',
10328 'science',
10329 'scientist',
10330 'scion',
10331 'scoff',
10332 'scolding',
10333 'scone',
10334 'scoop',
10335 'scooter',
10336 'scope',
10337 'scorch',
10338 'scorebook',
10339 'scorecard',
10340 'scored',
10341 'scoreless',
10342 'scorer',
10343 'scoring',
10344 'scorn',
10345 'scorpion',
10346 'scotch',
10347 'scoundrel',
10348 'scoured',
10349 'scouring',
10350 'scouting',
10351 'scouts',
10352 'scowling',
10353 'scrabble',
10354 'scraggly',
10355 'scrambled',
10356 'scrambler',
10357 'scrap',
10358 'scratch',
10359 'scrawny',
10360 'screen',
10361 'scribble',
10362 'scribe',
10363 'scribing',
10364 'scrimmage',
10365 'script',
10366 'scroll',
10367 'scrooge',
10368 'scrounger',
10369 'scrubbed',
10370 'scrubber',
10371 'scruffy',
10372 'scrunch',
10373 'scrutiny',
10374 'scuba',
10375 'scuff',
10376 'sculptor',
10377 'sculpture',
10378 'scurvy',
10379 'scuttle',
10380 'secluded',
10381 'secluding',
10382 'seclusion',
10383 'second',
10384 'secrecy',
10385 'secret',
10386 'sectional',
10387 'sector',
10388 'secular',
10389 'securely',
10390 'security',
10391 'sedan',
10392 'sedate',
10393 'sedation',
10394 'sedative',
10395 'sediment',
10396 'seduce',
10397 'seducing',
10398 'segment',
10399 'seismic',
10400 'seizing',
10401 'seldom',
10402 'selected',
10403 'selection',
10404 'selective',
10405 'selector',
10406 'self',
10407 'seltzer',
10408 'semantic',
10409 'semester',
10410 'semicolon',
10411 'semifinal',
10412 'seminar',
10413 'semisoft',
10414 'semisweet',
10415 'senate',
10416 'senator',
10417 'send',
10418 'senior',
10419 'senorita',
10420 'sensation',
10421 'sensitive',
10422 'sensitize',
10423 'sensually',
10424 'sensuous',
10425 'sepia',
10426 'september',
10427 'septic',
10428 'septum',
10429 'sequel',
10430 'sequence',
10431 'sequester',
10432 'series',
10433 'sermon',
10434 'serotonin',
10435 'serpent',
10436 'serrated',
10437 'serve',
10438 'service',
10439 'serving',
10440 'sesame',
10441 'sessions',
10442 'setback',
10443 'setting',
10444 'settle',
10445 'settling',
10446 'setup',
10447 'sevenfold',
10448 'seventeen',
10449 'seventh',
10450 'seventy',
10451 'severity',
10452 'shabby',
10453 'shack',
10454 'shaded',
10455 'shadily',
10456 'shadiness',
10457 'shading',
10458 'shadow',
10459 'shady',
10460 'shaft',
10461 'shakable',
10462 'shakily',
10463 'shakiness',
10464 'shaking',
10465 'shaky',
10466 'shale',
10467 'shallot',
10468 'shallow',
10469 'shame',
10470 'shampoo',
10471 'shamrock',
10472 'shank',
10473 'shanty',
10474 'shape',
10475 'shaping',
10476 'share',
10477 'sharpener',
10478 'sharper',
10479 'sharpie',
10480 'sharply',
10481 'sharpness',
10482 'shawl',
10483 'sheath',
10484 'shed',
10485 'sheep',
10486 'sheet',
10487 'shelf',
10488 'shell',
10489 'shelter',
10490 'shelve',
10491 'shelving',
10492 'sherry',
10493 'shield',
10494 'shifter',
10495 'shifting',
10496 'shiftless',
10497 'shifty',
10498 'shimmer',
10499 'shimmy',
10500 'shindig',
10501 'shine',
10502 'shingle',
10503 'shininess',
10504 'shining',
10505 'shiny',
10506 'ship',
10507 'shirt',
10508 'shivering',
10509 'shock',
10510 'shone',
10511 'shoplift',
10512 'shopper',
10513 'shopping',
10514 'shoptalk',
10515 'shore',
10516 'shortage',
10517 'shortcake',
10518 'shortcut',
10519 'shorten',
10520 'shorter',
10521 'shorthand',
10522 'shortlist',
10523 'shortly',
10524 'shortness',
10525 'shorts',
10526 'shortwave',
10527 'shorty',
10528 'shout',
10529 'shove',
10530 'showbiz',
10531 'showcase',
10532 'showdown',
10533 'shower',
10534 'showgirl',
10535 'showing',
10536 'showman',
10537 'shown',
10538 'showoff',
10539 'showpiece',
10540 'showplace',
10541 'showroom',
10542 'showy',
10543 'shrank',
10544 'shrapnel',
10545 'shredder',
10546 'shredding',
10547 'shrewdly',
10548 'shriek',
10549 'shrill',
10550 'shrimp',
10551 'shrine',
10552 'shrink',
10553 'shrivel',
10554 'shrouded',
10555 'shrubbery',
10556 'shrubs',
10557 'shrug',
10558 'shrunk',
10559 'shucking',
10560 'shudder',
10561 'shuffle',
10562 'shuffling',
10563 'shun',
10564 'shush',
10565 'shut',
10566 'shy',
10567 'siamese',
10568 'siberian',
10569 'sibling',
10570 'siding',
10571 'sierra',
10572 'siesta',
10573 'sift',
10574 'sighing',
10575 'silenced',
10576 'silencer',
10577 'silent',
10578 'silica',
10579 'silicon',
10580 'silk',
10581 'silliness',
10582 'silly',
10583 'silo',
10584 'silt',
10585 'silver',
10586 'similarly',
10587 'simile',
10588 'simmering',
10589 'simple',
10590 'simplify',
10591 'simply',
10592 'sincere',
10593 'sincerity',
10594 'singer',
10595 'singing',
10596 'single',
10597 'singular',
10598 'sinister',
10599 'sinless',
10600 'sinner',
10601 'sinuous',
10602 'sip',
10603 'siren',
10604 'sister',
10605 'sitcom',
10606 'sitter',
10607 'sitting',
10608 'situated',
10609 'situation',
10610 'sixfold',
10611 'sixteen',
10612 'sixth',
10613 'sixties',
10614 'sixtieth',
10615 'sixtyfold',
10616 'sizable',
10617 'sizably',
10618 'size',
10619 'sizing',
10620 'sizzle',
10621 'sizzling',
10622 'skater',
10623 'skating',
10624 'skedaddle',
10625 'skeletal',
10626 'skeleton',
10627 'skeptic',
10628 'sketch',
10629 'skewed',
10630 'skewer',
10631 'skid',
10632 'skied',
10633 'skier',
10634 'skies',
10635 'skiing',
10636 'skilled',
10637 'skillet',
10638 'skillful',
10639 'skimmed',
10640 'skimmer',
10641 'skimming',
10642 'skimpily',
10643 'skincare',
10644 'skinhead',
10645 'skinless',
10646 'skinning',
10647 'skinny',
10648 'skintight',
10649 'skipper',
10650 'skipping',
10651 'skirmish',
10652 'skirt',
10653 'skittle',
10654 'skydiver',
10655 'skylight',
10656 'skyline',
10657 'skype',
10658 'skyrocket',
10659 'skyward',
10660 'slab',
10661 'slacked',
10662 'slacker',
10663 'slacking',
10664 'slackness',
10665 'slacks',
10666 'slain',
10667 'slam',
10668 'slander',
10669 'slang',
10670 'slapping',
10671 'slapstick',
10672 'slashed',
10673 'slashing',
10674 'slate',
10675 'slather',
10676 'slaw',
10677 'sled',
10678 'sleek',
10679 'sleep',
10680 'sleet',
10681 'sleeve',
10682 'slept',
10683 'sliceable',
10684 'sliced',
10685 'slicer',
10686 'slicing',
10687 'slick',
10688 'slider',
10689 'slideshow',
10690 'sliding',
10691 'slighted',
10692 'slighting',
10693 'slightly',
10694 'slimness',
10695 'slimy',
10696 'slinging',
10697 'slingshot',
10698 'slinky',
10699 'slip',
10700 'slit',
10701 'sliver',
10702 'slobbery',
10703 'slogan',
10704 'sloped',
10705 'sloping',
10706 'sloppily',
10707 'sloppy',
10708 'slot',
10709 'slouching',
10710 'slouchy',
10711 'sludge',
10712 'slug',
10713 'slum',
10714 'slurp',
10715 'slush',
10716 'sly',
10717 'small',
10718 'smartly',
10719 'smartness',
10720 'smasher',
10721 'smashing',
10722 'smashup',
10723 'smell',
10724 'smelting',
10725 'smile',
10726 'smilingly',
10727 'smirk',
10728 'smite',
10729 'smith',
10730 'smitten',
10731 'smock',
10732 'smog',
10733 'smoked',
10734 'smokeless',
10735 'smokiness',
10736 'smoking',
10737 'smoky',
10738 'smolder',
10739 'smooth',
10740 'smother',
10741 'smudge',
10742 'smudgy',
10743 'smuggler',
10744 'smuggling',
10745 'smugly',
10746 'smugness',
10747 'snack',
10748 'snagged',
10749 'snaking',
10750 'snap',
10751 'snare',
10752 'snarl',
10753 'snazzy',
10754 'sneak',
10755 'sneer',
10756 'sneeze',
10757 'sneezing',
10758 'snide',
10759 'sniff',
10760 'snippet',
10761 'snipping',
10762 'snitch',
10763 'snooper',
10764 'snooze',
10765 'snore',
10766 'snoring',
10767 'snorkel',
10768 'snort',
10769 'snout',
10770 'snowbird',
10771 'snowboard',
10772 'snowbound',
10773 'snowcap',
10774 'snowdrift',
10775 'snowdrop',
10776 'snowfall',
10777 'snowfield',
10778 'snowflake',
10779 'snowiness',
10780 'snowless',
10781 'snowman',
10782 'snowplow',
10783 'snowshoe',
10784 'snowstorm',
10785 'snowsuit',
10786 'snowy',
10787 'snub',
10788 'snuff',
10789 'snuggle',
10790 'snugly',
10791 'snugness',
10792 'speak',
10793 'spearfish',
10794 'spearhead',
10795 'spearman',
10796 'spearmint',
10797 'species',
10798 'specimen',
10799 'specked',
10800 'speckled',
10801 'specks',
10802 'spectacle',
10803 'spectator',
10804 'spectrum',
10805 'speculate',
10806 'speech',
10807 'speed',
10808 'spellbind',
10809 'speller',
10810 'spelling',
10811 'spendable',
10812 'spender',
10813 'spending',
10814 'spent',
10815 'spew',
10816 'sphere',
10817 'spherical',
10818 'sphinx',
10819 'spider',
10820 'spied',
10821 'spiffy',
10822 'spill',
10823 'spilt',
10824 'spinach',
10825 'spinal',
10826 'spindle',
10827 'spinner',
10828 'spinning',
10829 'spinout',
10830 'spinster',
10831 'spiny',
10832 'spiral',
10833 'spirited',
10834 'spiritism',
10835 'spirits',
10836 'spiritual',
10837 'splashed',
10838 'splashing',
10839 'splashy',
10840 'splatter',
10841 'spleen',
10842 'splendid',
10843 'splendor',
10844 'splice',
10845 'splicing',
10846 'splinter',
10847 'splotchy',
10848 'splurge',
10849 'spoilage',
10850 'spoiled',
10851 'spoiler',
10852 'spoiling',
10853 'spoils',
10854 'spoken',
10855 'spokesman',
10856 'sponge',
10857 'spongy',
10858 'sponsor',
10859 'spoof',
10860 'spookily',
10861 'spooky',
10862 'spool',
10863 'spoon',
10864 'spore',
10865 'sporting',
10866 'sports',
10867 'sporty',
10868 'spotless',
10869 'spotlight',
10870 'spotted',
10871 'spotter',
10872 'spotting',
10873 'spotty',
10874 'spousal',
10875 'spouse',
10876 'spout',
10877 'sprain',
10878 'sprang',
10879 'sprawl',
10880 'spray',
10881 'spree',
10882 'sprig',
10883 'spring',
10884 'sprinkled',
10885 'sprinkler',
10886 'sprint',
10887 'sprite',
10888 'sprout',
10889 'spruce',
10890 'sprung',
10891 'spry',
10892 'spud',
10893 'spur',
10894 'sputter',
10895 'spyglass',
10896 'squabble',
10897 'squad',
10898 'squall',
10899 'squander',
10900 'squash',
10901 'squatted',
10902 'squatter',
10903 'squatting',
10904 'squeak',
10905 'squealer',
10906 'squealing',
10907 'squeamish',
10908 'squeegee',
10909 'squeeze',
10910 'squeezing',
10911 'squid',
10912 'squiggle',
10913 'squiggly',
10914 'squint',
10915 'squire',
10916 'squirt',
10917 'squishier',
10918 'squishy',
10919 'stability',
10920 'stabilize',
10921 'stable',
10922 'stack',
10923 'stadium',
10924 'staff',
10925 'stage',
10926 'staging',
10927 'stagnant',
10928 'stagnate',
10929 'stainable',
10930 'stained',
10931 'staining',
10932 'stainless',
10933 'stalemate',
10934 'staleness',
10935 'stalling',
10936 'stallion',
10937 'stamina',
10938 'stammer',
10939 'stamp',
10940 'stand',
10941 'stank',
10942 'staple',
10943 'stapling',
10944 'starboard',
10945 'starch',
10946 'stardom',
10947 'stardust',
10948 'starfish',
10949 'stargazer',
10950 'staring',
10951 'stark',
10952 'starless',
10953 'starlet',
10954 'starlight',
10955 'starlit',
10956 'starring',
10957 'starry',
10958 'starship',
10959 'starter',
10960 'starting',
10961 'startle',
10962 'startling',
10963 'startup',
10964 'starved',
10965 'starving',
10966 'stash',
10967 'state',
10968 'static',
10969 'statistic',
10970 'statue',
10971 'stature',
10972 'status',
10973 'statute',
10974 'statutory',
10975 'staunch',
10976 'stays',
10977 'steadfast',
10978 'steadier',
10979 'steadily',
10980 'steadying',
10981 'steam',
10982 'steed',
10983 'steep',
10984 'steerable',
10985 'steering',
10986 'steersman',
10987 'stegosaur',
10988 'stellar',
10989 'stem',
10990 'stench',
10991 'stencil',
10992 'step',
10993 'stereo',
10994 'sterile',
10995 'sterility',
10996 'sterilize',
10997 'sterling',
10998 'sternness',
10999 'sternum',
11000 'stew',
11001 'stick',
11002 'stiffen',
11003 'stiffly',
11004 'stiffness',
11005 'stifle',
11006 'stifling',
11007 'stillness',
11008 'stilt',
11009 'stimulant',
11010 'stimulate',
11011 'stimuli',
11012 'stimulus',
11013 'stinger',
11014 'stingily',
11015 'stinging',
11016 'stingray',
11017 'stingy',
11018 'stinking',
11019 'stinky',
11020 'stipend',
11021 'stipulate',
11022 'stir',
11023 'stitch',
11024 'stock',
11025 'stoic',
11026 'stoke',
11027 'stole',
11028 'stomp',
11029 'stonewall',
11030 'stoneware',
11031 'stonework',
11032 'stoning',
11033 'stony',
11034 'stood',
11035 'stooge',
11036 'stool',
11037 'stoop',
11038 'stoplight',
11039 'stoppable',
11040 'stoppage',
11041 'stopped',
11042 'stopper',
11043 'stopping',
11044 'stopwatch',
11045 'storable',
11046 'storage',
11047 'storeroom',
11048 'storewide',
11049 'storm',
11050 'stout',
11051 'stove',
11052 'stowaway',
11053 'stowing',
11054 'straddle',
11055 'straggler',
11056 'strained',
11057 'strainer',
11058 'straining',
11059 'strangely',
11060 'stranger',
11061 'strangle',
11062 'strategic',
11063 'strategy',
11064 'stratus',
11065 'straw',
11066 'stray',
11067 'streak',
11068 'stream',
11069 'street',
11070 'strength',
11071 'strenuous',
11072 'strep',
11073 'stress',
11074 'stretch',
11075 'strewn',
11076 'stricken',
11077 'strict',
11078 'stride',
11079 'strife',
11080 'strike',
11081 'striking',
11082 'strive',
11083 'striving',
11084 'strobe',
11085 'strode',
11086 'stroller',
11087 'strongbox',
11088 'strongly',
11089 'strongman',
11090 'struck',
11091 'structure',
11092 'strudel',
11093 'struggle',
11094 'strum',
11095 'strung',
11096 'strut',
11097 'stubbed',
11098 'stubble',
11099 'stubbly',
11100 'stubborn',
11101 'stucco',
11102 'stuck',
11103 'student',
11104 'studied',
11105 'studio',
11106 'study',
11107 'stuffed',
11108 'stuffing',
11109 'stuffy',
11110 'stumble',
11111 'stumbling',
11112 'stump',
11113 'stung',
11114 'stunned',
11115 'stunner',
11116 'stunning',
11117 'stunt',
11118 'stupor',
11119 'sturdily',
11120 'sturdy',
11121 'styling',
11122 'stylishly',
11123 'stylist',
11124 'stylized',
11125 'stylus',
11126 'suave',
11127 'subarctic',
11128 'subatomic',
11129 'subdivide',
11130 'subdued',
11131 'subduing',
11132 'subfloor',
11133 'subgroup',
11134 'subheader',
11135 'subject',
11136 'sublease',
11137 'sublet',
11138 'sublevel',
11139 'sublime',
11140 'submarine',
11141 'submerge',
11142 'submersed',
11143 'submitter',
11144 'subpanel',
11145 'subpar',
11146 'subplot',
11147 'subprime',
11148 'subscribe',
11149 'subscript',
11150 'subsector',
11151 'subside',
11152 'subsiding',
11153 'subsidize',
11154 'subsidy',
11155 'subsoil',
11156 'subsonic',
11157 'substance',
11158 'subsystem',
11159 'subtext',
11160 'subtitle',
11161 'subtly',
11162 'subtotal',
11163 'subtract',
11164 'subtype',
11165 'suburb',
11166 'subway',
11167 'subwoofer',
11168 'subzero',
11169 'succulent',
11170 'such',
11171 'suction',
11172 'sudden',
11173 'sudoku',
11174 'suds',
11175 'sufferer',
11176 'suffering',
11177 'suffice',
11178 'suffix',
11179 'suffocate',
11180 'suffrage',
11181 'sugar',
11182 'suggest',
11183 'suing',
11184 'suitable',
11185 'suitably',
11186 'suitcase',
11187 'suitor',
11188 'sulfate',
11189 'sulfide',
11190 'sulfite',
11191 'sulfur',
11192 'sulk',
11193 'sullen',
11194 'sulphate',
11195 'sulphuric',
11196 'sultry',
11197 'superbowl',
11198 'superglue',
11199 'superhero',
11200 'superior',
11201 'superjet',
11202 'superman',
11203 'supermom',
11204 'supernova',
11205 'supervise',
11206 'supper',
11207 'supplier',
11208 'supply',
11209 'support',
11210 'supremacy',
11211 'supreme',
11212 'surcharge',
11213 'surely',
11214 'sureness',
11215 'surface',
11216 'surfacing',
11217 'surfboard',
11218 'surfer',
11219 'surgery',
11220 'surgical',
11221 'surging',
11222 'surname',
11223 'surpass',
11224 'surplus',
11225 'surprise',
11226 'surreal',
11227 'surrender',
11228 'surrogate',
11229 'surround',
11230 'survey',
11231 'survival',
11232 'survive',
11233 'surviving',
11234 'survivor',
11235 'sushi',
11236 'suspect',
11237 'suspend',
11238 'suspense',
11239 'sustained',
11240 'sustainer',
11241 'swab',
11242 'swaddling',
11243 'swagger',
11244 'swampland',
11245 'swan',
11246 'swapping',
11247 'swarm',
11248 'sway',
11249 'swear',
11250 'sweat',
11251 'sweep',
11252 'swell',
11253 'swept',
11254 'swerve',
11255 'swifter',
11256 'swiftly',
11257 'swiftness',
11258 'swimmable',
11259 'swimmer',
11260 'swimming',
11261 'swimsuit',
11262 'swimwear',
11263 'swinger',
11264 'swinging',
11265 'swipe',
11266 'swirl',
11267 'switch',
11268 'swivel',
11269 'swizzle',
11270 'swooned',
11271 'swoop',
11272 'swoosh',
11273 'swore',
11274 'sworn',
11275 'swung',
11276 'sycamore',
11277 'sympathy',
11278 'symphonic',
11279 'symphony',
11280 'symptom',
11281 'synapse',
11282 'syndrome',
11283 'synergy',
11284 'synopses',
11285 'synopsis',
11286 'synthesis',
11287 'synthetic',
11288 'syrup',
11289 'system',
11290 't-shirt',
11291 'tabasco',
11292 'tabby',
11293 'tableful',
11294 'tables',
11295 'tablet',
11296 'tableware',
11297 'tabloid',
11298 'tackiness',
11299 'tacking',
11300 'tackle',
11301 'tackling',
11302 'tacky',
11303 'taco',
11304 'tactful',
11305 'tactical',
11306 'tactics',
11307 'tactile',
11308 'tactless',
11309 'tadpole',
11310 'taekwondo',
11311 'tag',
11312 'tainted',
11313 'take',
11314 'taking',
11315 'talcum',
11316 'talisman',
11317 'tall',
11318 'talon',
11319 'tamale',
11320 'tameness',
11321 'tamer',
11322 'tamper',
11323 'tank',
11324 'tanned',
11325 'tannery',
11326 'tanning',
11327 'tantrum',
11328 'tapeless',
11329 'tapered',
11330 'tapering',
11331 'tapestry',
11332 'tapioca',
11333 'tapping',
11334 'taps',
11335 'tarantula',
11336 'target',
11337 'tarmac',
11338 'tarnish',
11339 'tarot',
11340 'tartar',
11341 'tartly',
11342 'tartness',
11343 'task',
11344 'tassel',
11345 'taste',
11346 'tastiness',
11347 'tasting',
11348 'tasty',
11349 'tattered',
11350 'tattle',
11351 'tattling',
11352 'tattoo',
11353 'taunt',
11354 'tavern',
11355 'thank',
11356 'that',
11357 'thaw',
11358 'theater',
11359 'theatrics',
11360 'thee',
11361 'theft',
11362 'theme',
11363 'theology',
11364 'theorize',
11365 'thermal',
11366 'thermos',
11367 'thesaurus',
11368 'these',
11369 'thesis',
11370 'thespian',
11371 'thicken',
11372 'thicket',
11373 'thickness',
11374 'thieving',
11375 'thievish',
11376 'thigh',
11377 'thimble',
11378 'thing',
11379 'think',
11380 'thinly',
11381 'thinner',
11382 'thinness',
11383 'thinning',
11384 'thirstily',
11385 'thirsting',
11386 'thirsty',
11387 'thirteen',
11388 'thirty',
11389 'thong',
11390 'thorn',
11391 'those',
11392 'thousand',
11393 'thrash',
11394 'thread',
11395 'threaten',
11396 'threefold',
11397 'thrift',
11398 'thrill',
11399 'thrive',
11400 'thriving',
11401 'throat',
11402 'throbbing',
11403 'throng',
11404 'throttle',
11405 'throwaway',
11406 'throwback',
11407 'thrower',
11408 'throwing',
11409 'thud',
11410 'thumb',
11411 'thumping',
11412 'thursday',
11413 'thus',
11414 'thwarting',
11415 'thyself',
11416 'tiara',
11417 'tibia',
11418 'tidal',
11419 'tidbit',
11420 'tidiness',
11421 'tidings',
11422 'tidy',
11423 'tiger',
11424 'tighten',
11425 'tightly',
11426 'tightness',
11427 'tightrope',
11428 'tightwad',
11429 'tigress',
11430 'tile',
11431 'tiling',
11432 'till',
11433 'tilt',
11434 'timid',
11435 'timing',
11436 'timothy',
11437 'tinderbox',
11438 'tinfoil',
11439 'tingle',
11440 'tingling',
11441 'tingly',
11442 'tinker',
11443 'tinkling',
11444 'tinsel',
11445 'tinsmith',
11446 'tint',
11447 'tinwork',
11448 'tiny',
11449 'tipoff',
11450 'tipped',
11451 'tipper',
11452 'tipping',
11453 'tiptoeing',
11454 'tiptop',
11455 'tiring',
11456 'tissue',
11457 'trace',
11458 'tracing',
11459 'track',
11460 'traction',
11461 'tractor',
11462 'trade',
11463 'trading',
11464 'tradition',
11465 'traffic',
11466 'tragedy',
11467 'trailing',
11468 'trailside',
11469 'train',
11470 'traitor',
11471 'trance',
11472 'tranquil',
11473 'transfer',
11474 'transform',
11475 'translate',
11476 'transpire',
11477 'transport',
11478 'transpose',
11479 'trapdoor',
11480 'trapeze',
11481 'trapezoid',
11482 'trapped',
11483 'trapper',
11484 'trapping',
11485 'traps',
11486 'trash',
11487 'travel',
11488 'traverse',
11489 'travesty',
11490 'tray',
11491 'treachery',
11492 'treading',
11493 'treadmill',
11494 'treason',
11495 'treat',
11496 'treble',
11497 'tree',
11498 'trekker',
11499 'tremble',
11500 'trembling',
11501 'tremor',
11502 'trench',
11503 'trend',
11504 'trespass',
11505 'triage',
11506 'trial',
11507 'triangle',
11508 'tribesman',
11509 'tribunal',
11510 'tribune',
11511 'tributary',
11512 'tribute',
11513 'triceps',
11514 'trickery',
11515 'trickily',
11516 'tricking',
11517 'trickle',
11518 'trickster',
11519 'tricky',
11520 'tricolor',
11521 'tricycle',
11522 'trident',
11523 'tried',
11524 'trifle',
11525 'trifocals',
11526 'trillion',
11527 'trilogy',
11528 'trimester',
11529 'trimmer',
11530 'trimming',
11531 'trimness',
11532 'trinity',
11533 'trio',
11534 'tripod',
11535 'tripping',
11536 'triumph',
11537 'trivial',
11538 'trodden',
11539 'trolling',
11540 'trombone',
11541 'trophy',
11542 'tropical',
11543 'tropics',
11544 'trouble',
11545 'troubling',
11546 'trough',
11547 'trousers',
11548 'trout',
11549 'trowel',
11550 'truce',
11551 'truck',
11552 'truffle',
11553 'trump',
11554 'trunks',
11555 'trustable',
11556 'trustee',
11557 'trustful',
11558 'trusting',
11559 'trustless',
11560 'truth',
11561 'try',
11562 'tubby',
11563 'tubeless',
11564 'tubular',
11565 'tucking',
11566 'tuesday',
11567 'tug',
11568 'tuition',
11569 'tulip',
11570 'tumble',
11571 'tumbling',
11572 'tummy',
11573 'turban',
11574 'turbine',
11575 'turbofan',
11576 'turbojet',
11577 'turbulent',
11578 'turf',
11579 'turkey',
11580 'turmoil',
11581 'turret',
11582 'turtle',
11583 'tusk',
11584 'tutor',
11585 'tutu',
11586 'tux',
11587 'tweak',
11588 'tweed',
11589 'tweet',
11590 'tweezers',
11591 'twelve',
11592 'twentieth',
11593 'twenty',
11594 'twerp',
11595 'twice',
11596 'twiddle',
11597 'twiddling',
11598 'twig',
11599 'twilight',
11600 'twine',
11601 'twins',
11602 'twirl',
11603 'twistable',
11604 'twisted',
11605 'twister',
11606 'twisting',
11607 'twisty',
11608 'twitch',
11609 'twitter',
11610 'tycoon',
11611 'tying',
11612 'tyke',
11613 'udder',
11614 'ultimate',
11615 'ultimatum',
11616 'ultra',
11617 'umbilical',
11618 'umbrella',
11619 'umpire',
11620 'unabashed',
11621 'unable',
11622 'unadorned',
11623 'unadvised',
11624 'unafraid',
11625 'unaired',
11626 'unaligned',
11627 'unaltered',
11628 'unarmored',
11629 'unashamed',
11630 'unaudited',
11631 'unawake',
11632 'unaware',
11633 'unbaked',
11634 'unbalance',
11635 'unbeaten',
11636 'unbend',
11637 'unbent',
11638 'unbiased',
11639 'unbitten',
11640 'unblended',
11641 'unblessed',
11642 'unblock',
11643 'unbolted',
11644 'unbounded',
11645 'unboxed',
11646 'unbraided',
11647 'unbridle',
11648 'unbroken',
11649 'unbuckled',
11650 'unbundle',
11651 'unburned',
11652 'unbutton',
11653 'uncanny',
11654 'uncapped',
11655 'uncaring',
11656 'uncertain',
11657 'unchain',
11658 'unchanged',
11659 'uncharted',
11660 'uncheck',
11661 'uncivil',
11662 'unclad',
11663 'unclaimed',
11664 'unclamped',
11665 'unclasp',
11666 'uncle',
11667 'unclip',
11668 'uncloak',
11669 'unclog',
11670 'unclothed',
11671 'uncoated',
11672 'uncoiled',
11673 'uncolored',
11674 'uncombed',
11675 'uncommon',
11676 'uncooked',
11677 'uncork',
11678 'uncorrupt',
11679 'uncounted',
11680 'uncouple',
11681 'uncouth',
11682 'uncover',
11683 'uncross',
11684 'uncrown',
11685 'uncrushed',
11686 'uncured',
11687 'uncurious',
11688 'uncurled',
11689 'uncut',
11690 'undamaged',
11691 'undated',
11692 'undaunted',
11693 'undead',
11694 'undecided',
11695 'undefined',
11696 'underage',
11697 'underarm',
11698 'undercoat',
11699 'undercook',
11700 'undercut',
11701 'underdog',
11702 'underdone',
11703 'underfed',
11704 'underfeed',
11705 'underfoot',
11706 'undergo',
11707 'undergrad',
11708 'underhand',
11709 'underline',
11710 'underling',
11711 'undermine',
11712 'undermost',
11713 'underpaid',
11714 'underpass',
11715 'underpay',
11716 'underrate',
11717 'undertake',
11718 'undertone',
11719 'undertook',
11720 'undertow',
11721 'underuse',
11722 'underwear',
11723 'underwent',
11724 'underwire',
11725 'undesired',
11726 'undiluted',
11727 'undivided',
11728 'undocked',
11729 'undoing',
11730 'undone',
11731 'undrafted',
11732 'undress',
11733 'undrilled',
11734 'undusted',
11735 'undying',
11736 'unearned',
11737 'unearth',
11738 'unease',
11739 'uneasily',
11740 'uneasy',
11741 'uneatable',
11742 'uneaten',
11743 'unedited',
11744 'unelected',
11745 'unending',
11746 'unengaged',
11747 'unenvied',
11748 'unequal',
11749 'unethical',
11750 'uneven',
11751 'unexpired',
11752 'unexposed',
11753 'unfailing',
11754 'unfair',
11755 'unfasten',
11756 'unfazed',
11757 'unfeeling',
11758 'unfiled',
11759 'unfilled',
11760 'unfitted',
11761 'unfitting',
11762 'unfixable',
11763 'unfixed',
11764 'unflawed',
11765 'unfocused',
11766 'unfold',
11767 'unfounded',
11768 'unframed',
11769 'unfreeze',
11770 'unfrosted',
11771 'unfrozen',
11772 'unfunded',
11773 'unglazed',
11774 'ungloved',
11775 'unglue',
11776 'ungodly',
11777 'ungraded',
11778 'ungreased',
11779 'unguarded',
11780 'unguided',
11781 'unhappily',
11782 'unhappy',
11783 'unharmed',
11784 'unhealthy',
11785 'unheard',
11786 'unhearing',
11787 'unheated',
11788 'unhelpful',
11789 'unhidden',
11790 'unhinge',
11791 'unhitched',
11792 'unholy',
11793 'unhook',
11794 'unicorn',
11795 'unicycle',
11796 'unified',
11797 'unifier',
11798 'uniformed',
11799 'uniformly',
11800 'unify',
11801 'unimpeded',
11802 'uninjured',
11803 'uninstall',
11804 'uninsured',
11805 'uninvited',
11806 'union',
11807 'uniquely',
11808 'unisexual',
11809 'unison',
11810 'unissued',
11811 'unit',
11812 'universal',
11813 'universe',
11814 'unjustly',
11815 'unkempt',
11816 'unkind',
11817 'unknotted',
11818 'unknowing',
11819 'unknown',
11820 'unlaced',
11821 'unlatch',
11822 'unlawful',
11823 'unleaded',
11824 'unlearned',
11825 'unleash',
11826 'unless',
11827 'unleveled',
11828 'unlighted',
11829 'unlikable',
11830 'unlimited',
11831 'unlined',
11832 'unlinked',
11833 'unlisted',
11834 'unlit',
11835 'unlivable',
11836 'unloaded',
11837 'unloader',
11838 'unlocked',
11839 'unlocking',
11840 'unlovable',
11841 'unloved',
11842 'unlovely',
11843 'unloving',
11844 'unluckily',
11845 'unlucky',
11846 'unmade',
11847 'unmanaged',
11848 'unmanned',
11849 'unmapped',
11850 'unmarked',
11851 'unmasked',
11852 'unmasking',
11853 'unmatched',
11854 'unmindful',
11855 'unmixable',
11856 'unmixed',
11857 'unmolded',
11858 'unmoral',
11859 'unmovable',
11860 'unmoved',
11861 'unmoving',
11862 'unnamable',
11863 'unnamed',
11864 'unnatural',
11865 'unneeded',
11866 'unnerve',
11867 'unnerving',
11868 'unnoticed',
11869 'unopened',
11870 'unopposed',
11871 'unpack',
11872 'unpadded',
11873 'unpaid',
11874 'unpainted',
11875 'unpaired',
11876 'unpaved',
11877 'unpeeled',
11878 'unpicked',
11879 'unpiloted',
11880 'unpinned',
11881 'unplanned',
11882 'unplanted',
11883 'unpleased',
11884 'unpledged',
11885 'unplowed',
11886 'unplug',
11887 'unpopular',
11888 'unproven',
11889 'unquote',
11890 'unranked',
11891 'unrated',
11892 'unraveled',
11893 'unreached',
11894 'unread',
11895 'unreal',
11896 'unreeling',
11897 'unrefined',
11898 'unrelated',
11899 'unrented',
11900 'unrest',
11901 'unretired',
11902 'unrevised',
11903 'unrigged',
11904 'unripe',
11905 'unrivaled',
11906 'unroasted',
11907 'unrobed',
11908 'unroll',
11909 'unruffled',
11910 'unruly',
11911 'unrushed',
11912 'unsaddle',
11913 'unsafe',
11914 'unsaid',
11915 'unsalted',
11916 'unsaved',
11917 'unsavory',
11918 'unscathed',
11919 'unscented',
11920 'unscrew',
11921 'unsealed',
11922 'unseated',
11923 'unsecured',
11924 'unseeing',
11925 'unseemly',
11926 'unseen',
11927 'unselect',
11928 'unselfish',
11929 'unsent',
11930 'unsettled',
11931 'unshackle',
11932 'unshaken',
11933 'unshaved',
11934 'unshaven',
11935 'unsheathe',
11936 'unshipped',
11937 'unsightly',
11938 'unsigned',
11939 'unskilled',
11940 'unsliced',
11941 'unsmooth',
11942 'unsnap',
11943 'unsocial',
11944 'unsoiled',
11945 'unsold',
11946 'unsolved',
11947 'unsorted',
11948 'unspoiled',
11949 'unspoken',
11950 'unstable',
11951 'unstaffed',
11952 'unstamped',
11953 'unsteady',
11954 'unsterile',
11955 'unstirred',
11956 'unstitch',
11957 'unstopped',
11958 'unstuck',
11959 'unstuffed',
11960 'unstylish',
11961 'unsubtle',
11962 'unsubtly',
11963 'unsuited',
11964 'unsure',
11965 'unsworn',
11966 'untagged',
11967 'untainted',
11968 'untaken',
11969 'untamed',
11970 'untangled',
11971 'untapped',
11972 'untaxed',
11973 'unthawed',
11974 'unthread',
11975 'untidy',
11976 'untie',
11977 'until',
11978 'untimed',
11979 'untimely',
11980 'untitled',
11981 'untoasted',
11982 'untold',
11983 'untouched',
11984 'untracked',
11985 'untrained',
11986 'untreated',
11987 'untried',
11988 'untrimmed',
11989 'untrue',
11990 'untruth',
11991 'unturned',
11992 'untwist',
11993 'untying',
11994 'unusable',
11995 'unused',
11996 'unusual',
11997 'unvalued',
11998 'unvaried',
11999 'unvarying',
12000 'unveiled',
12001 'unveiling',
12002 'unvented',
12003 'unviable',
12004 'unvisited',
12005 'unvocal',
12006 'unwanted',
12007 'unwarlike',
12008 'unwary',
12009 'unwashed',
12010 'unwatched',
12011 'unweave',
12012 'unwed',
12013 'unwelcome',
12014 'unwell',
12015 'unwieldy',
12016 'unwilling',
12017 'unwind',
12018 'unwired',
12019 'unwitting',
12020 'unwomanly',
12021 'unworldly',
12022 'unworn',
12023 'unworried',
12024 'unworthy',
12025 'unwound',
12026 'unwoven',
12027 'unwrapped',
12028 'unwritten',
12029 'unzip',
12030 'upbeat',
12031 'upchuck',
12032 'upcoming',
12033 'upcountry',
12034 'update',
12035 'upfront',
12036 'upgrade',
12037 'upheaval',
12038 'upheld',
12039 'uphill',
12040 'uphold',
12041 'uplifted',
12042 'uplifting',
12043 'upload',
12044 'upon',
12045 'upper',
12046 'upright',
12047 'uprising',
12048 'upriver',
12049 'uproar',
12050 'uproot',
12051 'upscale',
12052 'upside',
12053 'upstage',
12054 'upstairs',
12055 'upstart',
12056 'upstate',
12057 'upstream',
12058 'upstroke',
12059 'upswing',
12060 'uptake',
12061 'uptight',
12062 'uptown',
12063 'upturned',
12064 'upward',
12065 'upwind',
12066 'uranium',
12067 'urban',
12068 'urchin',
12069 'urethane',
12070 'urgency',
12071 'urgent',
12072 'urging',
12073 'urologist',
12074 'urology',
12075 'usable',
12076 'usage',
12077 'useable',
12078 'used',
12079 'uselessly',
12080 'user',
12081 'usher',
12082 'usual',
12083 'utensil',
12084 'utility',
12085 'utilize',
12086 'utmost',
12087 'utopia',
12088 'utter',
12089 'vacancy',
12090 'vacant',
12091 'vacate',
12092 'vacation',
12093 'vagabond',
12094 'vagrancy',
12095 'vagrantly',
12096 'vaguely',
12097 'vagueness',
12098 'valiant',
12099 'valid',
12100 'valium',
12101 'valley',
12102 'valuables',
12103 'value',
12104 'vanilla',
12105 'vanish',
12106 'vanity',
12107 'vanquish',
12108 'vantage',
12109 'vaporizer',
12110 'variable',
12111 'variably',
12112 'varied',
12113 'variety',
12114 'various',
12115 'varmint',
12116 'varnish',
12117 'varsity',
12118 'varying',
12119 'vascular',
12120 'vaseline',
12121 'vastly',
12122 'vastness',
12123 'veal',
12124 'vegan',
12125 'veggie',
12126 'vehicular',
12127 'velcro',
12128 'velocity',
12129 'velvet',
12130 'vendetta',
12131 'vending',
12132 'vendor',
12133 'veneering',
12134 'vengeful',
12135 'venomous',
12136 'ventricle',
12137 'venture',
12138 'venue',
12139 'venus',
12140 'verbalize',
12141 'verbally',
12142 'verbose',
12143 'verdict',
12144 'verify',
12145 'verse',
12146 'version',
12147 'versus',
12148 'vertebrae',
12149 'vertical',
12150 'vertigo',
12151 'very',
12152 'vessel',
12153 'vest',
12154 'veteran',
12155 'veto',
12156 'vexingly',
12157 'viability',
12158 'viable',
12159 'vibes',
12160 'vice',
12161 'vicinity',
12162 'victory',
12163 'video',
12164 'viewable',
12165 'viewer',
12166 'viewing',
12167 'viewless',
12168 'viewpoint',
12169 'vigorous',
12170 'village',
12171 'villain',
12172 'vindicate',
12173 'vineyard',
12174 'vintage',
12175 'violate',
12176 'violation',
12177 'violator',
12178 'violet',
12179 'violin',
12180 'viper',
12181 'viral',
12182 'virtual',
12183 'virtuous',
12184 'virus',
12185 'visa',
12186 'viscosity',
12187 'viscous',
12188 'viselike',
12189 'visible',
12190 'visibly',
12191 'vision',
12192 'visiting',
12193 'visitor',
12194 'visor',
12195 'vista',
12196 'vitality',
12197 'vitalize',
12198 'vitally',
12199 'vitamins',
12200 'vivacious',
12201 'vividly',
12202 'vividness',
12203 'vixen',
12204 'vocalist',
12205 'vocalize',
12206 'vocally',
12207 'vocation',
12208 'voice',
12209 'voicing',
12210 'void',
12211 'volatile',
12212 'volley',
12213 'voltage',
12214 'volumes',
12215 'voter',
12216 'voting',
12217 'voucher',
12218 'vowed',
12219 'vowel',
12220 'voyage',
12221 'wackiness',
12222 'wad',
12223 'wafer',
12224 'waffle',
12225 'waged',
12226 'wager',
12227 'wages',
12228 'waggle',
12229 'wagon',
12230 'wake',
12231 'waking',
12232 'walk',
12233 'walmart',
12234 'walnut',
12235 'walrus',
12236 'waltz',
12237 'wand',
12238 'wannabe',
12239 'wanted',
12240 'wanting',
12241 'wasabi',
12242 'washable',
12243 'washbasin',
12244 'washboard',
12245 'washbowl',
12246 'washcloth',
12247 'washday',
12248 'washed',
12249 'washer',
12250 'washhouse',
12251 'washing',
12252 'washout',
12253 'washroom',
12254 'washstand',
12255 'washtub',
12256 'wasp',
12257 'wasting',
12258 'watch',
12259 'water',
12260 'waviness',
12261 'waving',
12262 'wavy',
12263 'whacking',
12264 'whacky',
12265 'wham',
12266 'wharf',
12267 'wheat',
12268 'whenever',
12269 'whiff',
12270 'whimsical',
12271 'whinny',
12272 'whiny',
12273 'whisking',
12274 'whoever',
12275 'whole',
12276 'whomever',
12277 'whoopee',
12278 'whooping',
12279 'whoops',
12280 'why',
12281 'wick',
12282 'widely',
12283 'widen',
12284 'widget',
12285 'widow',
12286 'width',
12287 'wieldable',
12288 'wielder',
12289 'wife',
12290 'wifi',
12291 'wikipedia',
12292 'wildcard',
12293 'wildcat',
12294 'wilder',
12295 'wildfire',
12296 'wildfowl',
12297 'wildland',
12298 'wildlife',
12299 'wildly',
12300 'wildness',
12301 'willed',
12302 'willfully',
12303 'willing',
12304 'willow',
12305 'willpower',
12306 'wilt',
12307 'wimp',
12308 'wince',
12309 'wincing',
12310 'wind',
12311 'wing',
12312 'winking',
12313 'winner',
12314 'winnings',
12315 'winter',
12316 'wipe',
12317 'wired',
12318 'wireless',
12319 'wiring',
12320 'wiry',
12321 'wisdom',
12322 'wise',
12323 'wish',
12324 'wisplike',
12325 'wispy',
12326 'wistful',
12327 'wizard',
12328 'wobble',
12329 'wobbling',
12330 'wobbly',
12331 'wok',
12332 'wolf',
12333 'wolverine',
12334 'womanhood',
12335 'womankind',
12336 'womanless',
12337 'womanlike',
12338 'womanly',
12339 'womb',
12340 'woof',
12341 'wooing',
12342 'wool',
12343 'woozy',
12344 'word',
12345 'work',
12346 'worried',
12347 'worrier',
12348 'worrisome',
12349 'worry',
12350 'worsening',
12351 'worshiper',
12352 'worst',
12353 'wound',
12354 'woven',
12355 'wow',
12356 'wrangle',
12357 'wrath',
12358 'wreath',
12359 'wreckage',
12360 'wrecker',
12361 'wrecking',
12362 'wrench',
12363 'wriggle',
12364 'wriggly',
12365 'wrinkle',
12366 'wrinkly',
12367 'wrist',
12368 'writing',
12369 'written',
12370 'wrongdoer',
12371 'wronged',
12372 'wrongful',
12373 'wrongly',
12374 'wrongness',
12375 'wrought',
12376 'xbox',
12377 'xerox',
12378 'yahoo',
12379 'yam',
12380 'yanking',
12381 'yapping',
12382 'yard',
12383 'yarn',
12384 'yeah',
12385 'yearbook',
12386 'yearling',
12387 'yearly',
12388 'yearning',
12389 'yeast',
12390 'yelling',
12391 'yelp',
12392 'yen',
12393 'yesterday',
12394 'yiddish',
12395 'yield',
12396 'yin',
12397 'yippee',
12398 'yo-yo',
12399 'yodel',
12400 'yoga',
12401 'yogurt',
12402 'yonder',
12403 'yoyo',
12404 'yummy',
12405 'zap',
12406 'zealous',
12407 'zebra',
12408 'zen',
12409 'zeppelin',
12410 'zero',
12411 'zestfully',
12412 'zesty',
12413 'zigzagged',
12414 'zipfile',
12415 'zipping',
12416 'zippy',
12417 'zips',
12418 'zit',
12419 'zodiac',
12420 'zombie',
12421 'zone',
12422 'zoning',
12423 'zookeeper',
12424 'zoologist',
12425 'zoology',
12426 'zoom',
12427];
12428
12429// CONCATENATED MODULE: ./jslib/src/services/crypto.service.ts
12430var crypto_service_decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
12431 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
12432 if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
12433 else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
12434 return c > 3 && r && Object.defineProperty(target, key, r), r;
12435};
12436var crypto_service_metadata = (undefined && undefined.__metadata) || function (k, v) {
12437 if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
12438};
12439var crypto_service_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
12440 return new (P || (P = Promise))(function (resolve, reject) {
12441 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
12442 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
12443 function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
12444 step((generator = generator.apply(thisArg, _arguments || [])).next());
12445 });
12446};
12447
12448
12449
12450
12451
12452
12453
12454
12455
12456
12457const crypto_service_Keys = {
12458 key: 'key',
12459 encOrgKeys: 'encOrgKeys',
12460 encPrivateKey: 'encPrivateKey',
12461 encKey: 'encKey',
12462 keyHash: 'keyHash',
12463};
12464class crypto_service_CryptoService {
12465 constructor(storageService, secureStorageService, cryptoFunctionService) {
12466 this.storageService = storageService;
12467 this.secureStorageService = secureStorageService;
12468 this.cryptoFunctionService = cryptoFunctionService;
12469 }
12470 setKey(key) {
12471 return crypto_service_awaiter(this, void 0, void 0, function* () {
12472 this.key = key;
12473 const option = yield this.storageService.get(ConstantsService.vaultTimeoutKey);
12474 if (option != null) {
12475 // if we have a lock option set, we do not store the key
12476 return;
12477 }
12478 return this.secureStorageService.save(crypto_service_Keys.key, key.keyB64);
12479 });
12480 }
12481 setKeyHash(keyHash) {
12482 this.keyHash = keyHash;
12483 return this.storageService.save(crypto_service_Keys.keyHash, keyHash);
12484 }
12485 setEncKey(encKey) {
12486 return crypto_service_awaiter(this, void 0, void 0, function* () {
12487 if (encKey == null) {
12488 return;
12489 }
12490 yield this.storageService.save(crypto_service_Keys.encKey, encKey);
12491 this.encKey = null;
12492 });
12493 }
12494 setEncPrivateKey(encPrivateKey) {
12495 return crypto_service_awaiter(this, void 0, void 0, function* () {
12496 if (encPrivateKey == null) {
12497 return;
12498 }
12499 yield this.storageService.save(crypto_service_Keys.encPrivateKey, encPrivateKey);
12500 this.privateKey = null;
12501 });
12502 }
12503 setOrgKeys(orgs) {
12504 const orgKeys = {};
12505 orgs.forEach((org) => {
12506 orgKeys[org.id] = org.key;
12507 });
12508 this.orgKeys = null;
12509 return this.storageService.save(crypto_service_Keys.encOrgKeys, orgKeys);
12510 }
12511 getKey() {
12512 return crypto_service_awaiter(this, void 0, void 0, function* () {
12513 if (this.key != null) {
12514 return this.key;
12515 }
12516 const key = yield this.secureStorageService.get(crypto_service_Keys.key);
12517 if (key != null) {
12518 this.key = new symmetricCryptoKey_SymmetricCryptoKey(utils_Utils.fromB64ToArray(key).buffer);
12519 }
12520 return key == null ? null : this.key;
12521 });
12522 }
12523 getKeyHash() {
12524 return crypto_service_awaiter(this, void 0, void 0, function* () {
12525 if (this.keyHash != null) {
12526 return this.keyHash;
12527 }
12528 const keyHash = yield this.storageService.get(crypto_service_Keys.keyHash);
12529 if (keyHash != null) {
12530 this.keyHash = keyHash;
12531 }
12532 return keyHash == null ? null : this.keyHash;
12533 });
12534 }
12535 getEncKey(key = null) {
12536 return crypto_service_awaiter(this, void 0, void 0, function* () {
12537 if (this.encKey != null) {
12538 return this.encKey;
12539 }
12540 const encKey = yield this.storageService.get(crypto_service_Keys.encKey);
12541 if (encKey == null) {
12542 return null;
12543 }
12544 if (key == null) {
12545 key = yield this.getKey();
12546 }
12547 if (key == null) {
12548 return null;
12549 }
12550 let decEncKey;
12551 const encKeyCipher = new cipherString_CipherString(encKey);
12552 if (encKeyCipher.encryptionType === EncryptionType.AesCbc256_B64) {
12553 decEncKey = yield this.decryptToBytes(encKeyCipher, key);
12554 }
12555 else if (encKeyCipher.encryptionType === EncryptionType.AesCbc256_HmacSha256_B64) {
12556 const newKey = yield this.stretchKey(key);
12557 decEncKey = yield this.decryptToBytes(encKeyCipher, newKey);
12558 }
12559 else {
12560 throw new Error('Unsupported encKey type.');
12561 }
12562 if (decEncKey == null) {
12563 return null;
12564 }
12565 this.encKey = new symmetricCryptoKey_SymmetricCryptoKey(decEncKey);
12566 return this.encKey;
12567 });
12568 }
12569 getPublicKey() {
12570 return crypto_service_awaiter(this, void 0, void 0, function* () {
12571 if (this.publicKey != null) {
12572 return this.publicKey;
12573 }
12574 const privateKey = yield this.getPrivateKey();
12575 if (privateKey == null) {
12576 return null;
12577 }
12578 this.publicKey = yield this.cryptoFunctionService.rsaExtractPublicKey(privateKey);
12579 return this.publicKey;
12580 });
12581 }
12582 getPrivateKey() {
12583 return crypto_service_awaiter(this, void 0, void 0, function* () {
12584 if (this.privateKey != null) {
12585 return this.privateKey;
12586 }
12587 const encPrivateKey = yield this.storageService.get(crypto_service_Keys.encPrivateKey);
12588 if (encPrivateKey == null) {
12589 return null;
12590 }
12591 this.privateKey = yield this.decryptToBytes(new cipherString_CipherString(encPrivateKey), null);
12592 return this.privateKey;
12593 });
12594 }
12595 getFingerprint(userId, publicKey) {
12596 return crypto_service_awaiter(this, void 0, void 0, function* () {
12597 if (publicKey == null) {
12598 publicKey = yield this.getPublicKey();
12599 }
12600 if (publicKey === null) {
12601 throw new Error('No public key available.');
12602 }
12603 const keyFingerprint = yield this.cryptoFunctionService.hash(publicKey, 'sha256');
12604 const userFingerprint = yield this.hkdfExpand(keyFingerprint, utils_Utils.fromUtf8ToArray(userId), 32);
12605 return this.hashPhrase(userFingerprint.buffer);
12606 });
12607 }
12608 getOrgKeys() {
12609 return crypto_service_awaiter(this, void 0, void 0, function* () {
12610 if (this.orgKeys != null && this.orgKeys.size > 0) {
12611 return this.orgKeys;
12612 }
12613 const encOrgKeys = yield this.storageService.get(crypto_service_Keys.encOrgKeys);
12614 if (encOrgKeys == null) {
12615 return null;
12616 }
12617 const orgKeys = new Map();
12618 let setKey = false;
12619 for (const orgId in encOrgKeys) {
12620 if (!encOrgKeys.hasOwnProperty(orgId)) {
12621 continue;
12622 }
12623 const decValue = yield this.rsaDecrypt(encOrgKeys[orgId]);
12624 orgKeys.set(orgId, new symmetricCryptoKey_SymmetricCryptoKey(decValue));
12625 setKey = true;
12626 }
12627 if (setKey) {
12628 this.orgKeys = orgKeys;
12629 }
12630 return this.orgKeys;
12631 });
12632 }
12633 getOrgKey(orgId) {
12634 return crypto_service_awaiter(this, void 0, void 0, function* () {
12635 if (orgId == null) {
12636 return null;
12637 }
12638 const orgKeys = yield this.getOrgKeys();
12639 if (orgKeys == null || !orgKeys.has(orgId)) {
12640 return null;
12641 }
12642 return orgKeys.get(orgId);
12643 });
12644 }
12645 hasKey() {
12646 return crypto_service_awaiter(this, void 0, void 0, function* () {
12647 return (yield this.getKey()) != null;
12648 });
12649 }
12650 hasEncKey() {
12651 return crypto_service_awaiter(this, void 0, void 0, function* () {
12652 const encKey = yield this.storageService.get(crypto_service_Keys.encKey);
12653 return encKey != null;
12654 });
12655 }
12656 clearKey() {
12657 this.key = this.legacyEtmKey = null;
12658 return this.secureStorageService.remove(crypto_service_Keys.key);
12659 }
12660 clearKeyHash() {
12661 this.keyHash = null;
12662 return this.storageService.remove(crypto_service_Keys.keyHash);
12663 }
12664 clearEncKey(memoryOnly) {
12665 this.encKey = null;
12666 if (memoryOnly) {
12667 return Promise.resolve();
12668 }
12669 return this.storageService.remove(crypto_service_Keys.encKey);
12670 }
12671 clearKeyPair(memoryOnly) {
12672 this.privateKey = null;
12673 this.publicKey = null;
12674 if (memoryOnly) {
12675 return Promise.resolve();
12676 }
12677 return this.storageService.remove(crypto_service_Keys.encPrivateKey);
12678 }
12679 clearOrgKeys(memoryOnly) {
12680 this.orgKeys = null;
12681 if (memoryOnly) {
12682 return Promise.resolve();
12683 }
12684 return this.storageService.remove(crypto_service_Keys.encOrgKeys);
12685 }
12686 clearPinProtectedKey() {
12687 return this.storageService.remove(ConstantsService.pinProtectedKey);
12688 }
12689 clearKeys() {
12690 return Promise.all([
12691 this.clearKey(),
12692 this.clearKeyHash(),
12693 this.clearOrgKeys(),
12694 this.clearEncKey(),
12695 this.clearKeyPair(),
12696 this.clearPinProtectedKey(),
12697 ]);
12698 }
12699 toggleKey() {
12700 return crypto_service_awaiter(this, void 0, void 0, function* () {
12701 const key = yield this.getKey();
12702 const option = yield this.storageService.get(ConstantsService.vaultTimeoutKey);
12703 if (option != null || option === 0) {
12704 // if we have a lock option set, clear the key
12705 yield this.clearKey();
12706 this.key = key;
12707 return;
12708 }
12709 yield this.setKey(key);
12710 });
12711 }
12712 makeKey(password, salt, kdf, kdfIterations) {
12713 return crypto_service_awaiter(this, void 0, void 0, function* () {
12714 let key = null;
12715 if (kdf == null || kdf === KdfType.PBKDF2_SHA256) {
12716 if (kdfIterations == null) {
12717 kdfIterations = 5000;
12718 }
12719 else if (kdfIterations < 5000) {
12720 throw new Error('PBKDF2 iteration minimum is 5000.');
12721 }
12722 key = yield this.cryptoFunctionService.pbkdf2(password, salt, 'sha256', kdfIterations);
12723 }
12724 else {
12725 throw new Error('Unknown Kdf.');
12726 }
12727 return new symmetricCryptoKey_SymmetricCryptoKey(key);
12728 });
12729 }
12730 makeKeyFromPin(pin, salt, kdf, kdfIterations, protectedKeyCs = null) {
12731 return crypto_service_awaiter(this, void 0, void 0, function* () {
12732 if (protectedKeyCs == null) {
12733 const pinProtectedKey = yield this.storageService.get(ConstantsService.pinProtectedKey);
12734 if (pinProtectedKey == null) {
12735 throw new Error('No PIN protected key found.');
12736 }
12737 protectedKeyCs = new cipherString_CipherString(pinProtectedKey);
12738 }
12739 const pinKey = yield this.makePinKey(pin, salt, kdf, kdfIterations);
12740 const decKey = yield this.decryptToBytes(protectedKeyCs, pinKey);
12741 return new symmetricCryptoKey_SymmetricCryptoKey(decKey);
12742 });
12743 }
12744 makeShareKey() {
12745 return crypto_service_awaiter(this, void 0, void 0, function* () {
12746 const shareKey = yield this.cryptoFunctionService.randomBytes(64);
12747 const publicKey = yield this.getPublicKey();
12748 const encShareKey = yield this.rsaEncrypt(shareKey, publicKey);
12749 return [encShareKey, new symmetricCryptoKey_SymmetricCryptoKey(shareKey)];
12750 });
12751 }
12752 makeKeyPair(key) {
12753 return crypto_service_awaiter(this, void 0, void 0, function* () {
12754 const keyPair = yield this.cryptoFunctionService.rsaGenerateKeyPair(2048);
12755 const publicB64 = utils_Utils.fromBufferToB64(keyPair[0]);
12756 const privateEnc = yield this.encrypt(keyPair[1], key);
12757 return [publicB64, privateEnc];
12758 });
12759 }
12760 makePinKey(pin, salt, kdf, kdfIterations) {
12761 return crypto_service_awaiter(this, void 0, void 0, function* () {
12762 const pinKey = yield this.makeKey(pin, salt, kdf, kdfIterations);
12763 return yield this.stretchKey(pinKey);
12764 });
12765 }
12766 hashPassword(password, key) {
12767 return crypto_service_awaiter(this, void 0, void 0, function* () {
12768 if (key == null) {
12769 key = yield this.getKey();
12770 }
12771 if (password == null || key == null) {
12772 throw new Error('Invalid parameters.');
12773 }
12774 const hash = yield this.cryptoFunctionService.pbkdf2(key.key, password, 'sha256', 1);
12775 return utils_Utils.fromBufferToB64(hash);
12776 });
12777 }
12778 makeEncKey(key) {
12779 return crypto_service_awaiter(this, void 0, void 0, function* () {
12780 const theKey = yield this.getKeyForEncryption(key);
12781 const encKey = yield this.cryptoFunctionService.randomBytes(64);
12782 return this.buildEncKey(theKey, encKey);
12783 });
12784 }
12785 remakeEncKey(key) {
12786 return crypto_service_awaiter(this, void 0, void 0, function* () {
12787 const encKey = yield this.getEncKey();
12788 return this.buildEncKey(key, encKey.key);
12789 });
12790 }
12791 encrypt(plainValue, key) {
12792 return crypto_service_awaiter(this, void 0, void 0, function* () {
12793 if (plainValue == null) {
12794 return Promise.resolve(null);
12795 }
12796 let plainBuf;
12797 if (typeof (plainValue) === 'string') {
12798 plainBuf = utils_Utils.fromUtf8ToArray(plainValue).buffer;
12799 }
12800 else {
12801 plainBuf = plainValue;
12802 }
12803 const encObj = yield this.aesEncrypt(plainBuf, key);
12804 const iv = utils_Utils.fromBufferToB64(encObj.iv);
12805 const data = utils_Utils.fromBufferToB64(encObj.data);
12806 const mac = encObj.mac != null ? utils_Utils.fromBufferToB64(encObj.mac) : null;
12807 return new cipherString_CipherString(encObj.key.encType, data, iv, mac);
12808 });
12809 }
12810 encryptToBytes(plainValue, key) {
12811 return crypto_service_awaiter(this, void 0, void 0, function* () {
12812 const encValue = yield this.aesEncrypt(plainValue, key);
12813 let macLen = 0;
12814 if (encValue.mac != null) {
12815 macLen = encValue.mac.byteLength;
12816 }
12817 const encBytes = new Uint8Array(1 + encValue.iv.byteLength + macLen + encValue.data.byteLength);
12818 encBytes.set([encValue.key.encType]);
12819 encBytes.set(new Uint8Array(encValue.iv), 1);
12820 if (encValue.mac != null) {
12821 encBytes.set(new Uint8Array(encValue.mac), 1 + encValue.iv.byteLength);
12822 }
12823 encBytes.set(new Uint8Array(encValue.data), 1 + encValue.iv.byteLength + macLen);
12824 return encBytes.buffer;
12825 });
12826 }
12827 rsaEncrypt(data, publicKey) {
12828 return crypto_service_awaiter(this, void 0, void 0, function* () {
12829 if (publicKey == null) {
12830 publicKey = yield this.getPublicKey();
12831 }
12832 if (publicKey == null) {
12833 throw new Error('Public key unavailable.');
12834 }
12835 const encBytes = yield this.cryptoFunctionService.rsaEncrypt(data, publicKey, 'sha1');
12836 return new cipherString_CipherString(EncryptionType.Rsa2048_OaepSha1_B64, utils_Utils.fromBufferToB64(encBytes));
12837 });
12838 }
12839 decryptToBytes(cipherString, key) {
12840 return crypto_service_awaiter(this, void 0, void 0, function* () {
12841 const iv = utils_Utils.fromB64ToArray(cipherString.iv).buffer;
12842 const data = utils_Utils.fromB64ToArray(cipherString.data).buffer;
12843 const mac = cipherString.mac ? utils_Utils.fromB64ToArray(cipherString.mac).buffer : null;
12844 const decipher = yield this.aesDecryptToBytes(cipherString.encryptionType, data, iv, mac, key);
12845 if (decipher == null) {
12846 return null;
12847 }
12848 return decipher;
12849 });
12850 }
12851 decryptToUtf8(cipherString, key) {
12852 return crypto_service_awaiter(this, void 0, void 0, function* () {
12853 return yield this.aesDecryptToUtf8(cipherString.encryptionType, cipherString.data, cipherString.iv, cipherString.mac, key);
12854 });
12855 }
12856 decryptFromBytes(encBuf, key) {
12857 return crypto_service_awaiter(this, void 0, void 0, function* () {
12858 if (encBuf == null) {
12859 throw new Error('no encBuf.');
12860 }
12861 const encBytes = new Uint8Array(encBuf);
12862 const encType = encBytes[0];
12863 let ctBytes = null;
12864 let ivBytes = null;
12865 let macBytes = null;
12866 switch (encType) {
12867 case EncryptionType.AesCbc128_HmacSha256_B64:
12868 case EncryptionType.AesCbc256_HmacSha256_B64:
12869 if (encBytes.length <= 49) { // 1 + 16 + 32 + ctLength
12870 return null;
12871 }
12872 ivBytes = encBytes.slice(1, 17);
12873 macBytes = encBytes.slice(17, 49);
12874 ctBytes = encBytes.slice(49);
12875 break;
12876 case EncryptionType.AesCbc256_B64:
12877 if (encBytes.length <= 17) { // 1 + 16 + ctLength
12878 return null;
12879 }
12880 ivBytes = encBytes.slice(1, 17);
12881 ctBytes = encBytes.slice(17);
12882 break;
12883 default:
12884 return null;
12885 }
12886 return yield this.aesDecryptToBytes(encType, ctBytes.buffer, ivBytes.buffer, macBytes != null ? macBytes.buffer : null, key);
12887 });
12888 }
12889 // EFForg/OpenWireless
12890 // ref https://github.com/EFForg/OpenWireless/blob/master/app/js/diceware.js
12891 randomNumber(min, max) {
12892 return crypto_service_awaiter(this, void 0, void 0, function* () {
12893 let rval = 0;
12894 const range = max - min + 1;
12895 const bitsNeeded = Math.ceil(Math.log2(range));
12896 if (bitsNeeded > 53) {
12897 throw new Error('We cannot generate numbers larger than 53 bits.');
12898 }
12899 const bytesNeeded = Math.ceil(bitsNeeded / 8);
12900 const mask = Math.pow(2, bitsNeeded) - 1;
12901 // 7776 -> (2^13 = 8192) -1 == 8191 or 0x00001111 11111111
12902 // Fill a byte array with N random numbers
12903 const byteArray = new Uint8Array(yield this.cryptoFunctionService.randomBytes(bytesNeeded));
12904 let p = (bytesNeeded - 1) * 8;
12905 for (let i = 0; i < bytesNeeded; i++) {
12906 rval += byteArray[i] * Math.pow(2, p);
12907 p -= 8;
12908 }
12909 // Use & to apply the mask and reduce the number of recursive lookups
12910 // tslint:disable-next-line
12911 rval = rval & mask;
12912 if (rval >= range) {
12913 // Integer out of acceptable range
12914 return this.randomNumber(min, max);
12915 }
12916 // Return an integer that falls within the range
12917 return min + rval;
12918 });
12919 }
12920 // Helpers
12921 aesEncrypt(data, key) {
12922 return crypto_service_awaiter(this, void 0, void 0, function* () {
12923 const obj = new EncryptedObject();
12924 obj.key = yield this.getKeyForEncryption(key);
12925 obj.iv = yield this.cryptoFunctionService.randomBytes(16);
12926 obj.data = yield this.cryptoFunctionService.aesEncrypt(data, obj.iv, obj.key.encKey);
12927 if (obj.key.macKey != null) {
12928 const macData = new Uint8Array(obj.iv.byteLength + obj.data.byteLength);
12929 macData.set(new Uint8Array(obj.iv), 0);
12930 macData.set(new Uint8Array(obj.data), obj.iv.byteLength);
12931 obj.mac = yield this.cryptoFunctionService.hmac(macData.buffer, obj.key.macKey, 'sha256');
12932 }
12933 return obj;
12934 });
12935 }
12936 aesDecryptToUtf8(encType, data, iv, mac, key) {
12937 return crypto_service_awaiter(this, void 0, void 0, function* () {
12938 const keyForEnc = yield this.getKeyForEncryption(key);
12939 const theKey = this.resolveLegacyKey(encType, keyForEnc);
12940 if (theKey.macKey != null && mac == null) {
12941 // tslint:disable-next-line
12942 console.error('mac required.');
12943 return null;
12944 }
12945 if (theKey.encType !== encType) {
12946 // tslint:disable-next-line
12947 console.error('encType unavailable.');
12948 return null;
12949 }
12950 const fastParams = this.cryptoFunctionService.aesDecryptFastParameters(data, iv, mac, theKey);
12951 if (fastParams.macKey != null && fastParams.mac != null) {
12952 const computedMac = yield this.cryptoFunctionService.hmacFast(fastParams.macData, fastParams.macKey, 'sha256');
12953 const macsEqual = yield this.cryptoFunctionService.compareFast(fastParams.mac, computedMac);
12954 if (!macsEqual) {
12955 // tslint:disable-next-line
12956 console.error('mac failed.');
12957 return null;
12958 }
12959 }
12960 return this.cryptoFunctionService.aesDecryptFast(fastParams);
12961 });
12962 }
12963 aesDecryptToBytes(encType, data, iv, mac, key) {
12964 return crypto_service_awaiter(this, void 0, void 0, function* () {
12965 const keyForEnc = yield this.getKeyForEncryption(key);
12966 const theKey = this.resolveLegacyKey(encType, keyForEnc);
12967 if (theKey.macKey != null && mac == null) {
12968 return null;
12969 }
12970 if (theKey.encType !== encType) {
12971 return null;
12972 }
12973 if (theKey.macKey != null && mac != null) {
12974 const macData = new Uint8Array(iv.byteLength + data.byteLength);
12975 macData.set(new Uint8Array(iv), 0);
12976 macData.set(new Uint8Array(data), iv.byteLength);
12977 const computedMac = yield this.cryptoFunctionService.hmac(macData.buffer, theKey.macKey, 'sha256');
12978 if (computedMac === null) {
12979 return null;
12980 }
12981 const macsMatch = yield this.cryptoFunctionService.compare(mac, computedMac);
12982 if (!macsMatch) {
12983 // tslint:disable-next-line
12984 console.error('mac failed.');
12985 return null;
12986 }
12987 }
12988 return yield this.cryptoFunctionService.aesDecrypt(data, iv, theKey.encKey);
12989 });
12990 }
12991 rsaDecrypt(encValue) {
12992 return crypto_service_awaiter(this, void 0, void 0, function* () {
12993 const headerPieces = encValue.split('.');
12994 let encType = null;
12995 let encPieces;
12996 if (headerPieces.length === 1) {
12997 encType = EncryptionType.Rsa2048_OaepSha256_B64;
12998 encPieces = [headerPieces[0]];
12999 }
13000 else if (headerPieces.length === 2) {
13001 try {
13002 encType = parseInt(headerPieces[0], null);
13003 encPieces = headerPieces[1].split('|');
13004 }
13005 catch (e) { }
13006 }
13007 switch (encType) {
13008 case EncryptionType.Rsa2048_OaepSha256_B64:
13009 case EncryptionType.Rsa2048_OaepSha1_B64:
13010 // HmacSha256 types are deprecated
13011 case EncryptionType.Rsa2048_OaepSha256_HmacSha256_B64:
13012 case EncryptionType.Rsa2048_OaepSha1_HmacSha256_B64:
13013 break;
13014 default:
13015 throw new Error('encType unavailable.');
13016 }
13017 if (encPieces == null || encPieces.length <= 0) {
13018 throw new Error('encPieces unavailable.');
13019 }
13020 const data = utils_Utils.fromB64ToArray(encPieces[0]).buffer;
13021 const privateKey = yield this.getPrivateKey();
13022 if (privateKey == null) {
13023 throw new Error('No private key.');
13024 }
13025 let alg = 'sha1';
13026 switch (encType) {
13027 case EncryptionType.Rsa2048_OaepSha256_B64:
13028 case EncryptionType.Rsa2048_OaepSha256_HmacSha256_B64:
13029 alg = 'sha256';
13030 break;
13031 case EncryptionType.Rsa2048_OaepSha1_B64:
13032 case EncryptionType.Rsa2048_OaepSha1_HmacSha256_B64:
13033 break;
13034 default:
13035 throw new Error('encType unavailable.');
13036 }
13037 return this.cryptoFunctionService.rsaDecrypt(data, privateKey, alg);
13038 });
13039 }
13040 getKeyForEncryption(key) {
13041 return crypto_service_awaiter(this, void 0, void 0, function* () {
13042 if (key != null) {
13043 return key;
13044 }
13045 const encKey = yield this.getEncKey();
13046 if (encKey != null) {
13047 return encKey;
13048 }
13049 return yield this.getKey();
13050 });
13051 }
13052 resolveLegacyKey(encType, key) {
13053 if (encType === EncryptionType.AesCbc128_HmacSha256_B64 &&
13054 key.encType === EncryptionType.AesCbc256_B64) {
13055 // Old encrypt-then-mac scheme, make a new key
13056 if (this.legacyEtmKey == null) {
13057 this.legacyEtmKey = new symmetricCryptoKey_SymmetricCryptoKey(key.key, EncryptionType.AesCbc128_HmacSha256_B64);
13058 }
13059 return this.legacyEtmKey;
13060 }
13061 return key;
13062 }
13063 stretchKey(key) {
13064 return crypto_service_awaiter(this, void 0, void 0, function* () {
13065 const newKey = new Uint8Array(64);
13066 newKey.set(yield this.hkdfExpand(key.key, utils_Utils.fromUtf8ToArray('enc'), 32));
13067 newKey.set(yield this.hkdfExpand(key.key, utils_Utils.fromUtf8ToArray('mac'), 32), 32);
13068 return new symmetricCryptoKey_SymmetricCryptoKey(newKey.buffer);
13069 });
13070 }
13071 // ref: https://tools.ietf.org/html/rfc5869
13072 hkdfExpand(prk, info, size) {
13073 return crypto_service_awaiter(this, void 0, void 0, function* () {
13074 const hashLen = 32; // sha256
13075 const okm = new Uint8Array(size);
13076 let previousT = new Uint8Array(0);
13077 const n = Math.ceil(size / hashLen);
13078 for (let i = 0; i < n; i++) {
13079 const t = new Uint8Array(previousT.length + info.length + 1);
13080 t.set(previousT);
13081 t.set(info, previousT.length);
13082 t.set([i + 1], t.length - 1);
13083 previousT = new Uint8Array(yield this.cryptoFunctionService.hmac(t.buffer, prk, 'sha256'));
13084 okm.set(previousT, i * hashLen);
13085 }
13086 return okm;
13087 });
13088 }
13089 hashPhrase(hash, minimumEntropy = 64) {
13090 return crypto_service_awaiter(this, void 0, void 0, function* () {
13091 const entropyPerWord = Math.log(EEFLongWordList.length) / Math.log(2);
13092 let numWords = Math.ceil(minimumEntropy / entropyPerWord);
13093 const hashArr = Array.from(new Uint8Array(hash));
13094 const entropyAvailable = hashArr.length * 4;
13095 if (numWords * entropyPerWord > entropyAvailable) {
13096 throw new Error('Output entropy of hash function is too small');
13097 }
13098 const phrase = [];
13099 let hashNumber = external_big_integer_["fromArray"](hashArr, 256);
13100 while (numWords--) {
13101 const remainder = hashNumber.mod(EEFLongWordList.length);
13102 hashNumber = hashNumber.divide(EEFLongWordList.length);
13103 phrase.push(EEFLongWordList[remainder]);
13104 }
13105 return phrase;
13106 });
13107 }
13108 buildEncKey(key, encKey) {
13109 return crypto_service_awaiter(this, void 0, void 0, function* () {
13110 let encKeyEnc = null;
13111 if (key.key.byteLength === 32) {
13112 const newKey = yield this.stretchKey(key);
13113 encKeyEnc = yield this.encrypt(encKey, newKey);
13114 }
13115 else if (key.key.byteLength === 64) {
13116 encKeyEnc = yield this.encrypt(encKey, key);
13117 }
13118 else {
13119 throw new Error('Invalid key size.');
13120 }
13121 return [new symmetricCryptoKey_SymmetricCryptoKey(encKey), encKeyEnc];
13122 });
13123 }
13124}
13125crypto_service_decorate([
13126 sequentialize(() => 'getEncKey'),
13127 crypto_service_metadata("design:type", Function),
13128 crypto_service_metadata("design:paramtypes", [symmetricCryptoKey_SymmetricCryptoKey]),
13129 crypto_service_metadata("design:returntype", Promise)
13130], crypto_service_CryptoService.prototype, "getEncKey", null);
13131crypto_service_decorate([
13132 sequentialize(() => 'getOrgKeys'),
13133 crypto_service_metadata("design:type", Function),
13134 crypto_service_metadata("design:paramtypes", []),
13135 crypto_service_metadata("design:returntype", Promise)
13136], crypto_service_CryptoService.prototype, "getOrgKeys", null);
13137
13138// CONCATENATED MODULE: ./jslib/src/services/environment.service.ts
13139var environment_service_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
13140 return new (P || (P = Promise))(function (resolve, reject) {
13141 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
13142 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
13143 function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
13144 step((generator = generator.apply(thisArg, _arguments || [])).next());
13145 });
13146};
13147
13148
13149class environment_service_EnvironmentService {
13150 constructor(apiService, storageService, notificationsService) {
13151 this.apiService = apiService;
13152 this.storageService = storageService;
13153 this.notificationsService = notificationsService;
13154 }
13155 getWebVaultUrl() {
13156 if (this.webVaultUrl != null) {
13157 return this.webVaultUrl;
13158 }
13159 else if (this.baseUrl) {
13160 return this.baseUrl;
13161 }
13162 return null;
13163 }
13164 setUrlsFromStorage() {
13165 return environment_service_awaiter(this, void 0, void 0, function* () {
13166 const urlsObj = yield this.storageService.get(ConstantsService.environmentUrlsKey);
13167 const urls = urlsObj || {
13168 base: null,
13169 api: null,
13170 identity: null,
13171 icons: null,
13172 notifications: null,
13173 events: null,
13174 webVault: null,
13175 enterprise: null,
13176 };
13177 const envUrls = new EnvironmentUrls();
13178 if (urls.base) {
13179 this.baseUrl = envUrls.base = urls.base;
13180 this.apiService.setUrls(envUrls);
13181 return;
13182 }
13183 this.webVaultUrl = urls.webVault;
13184 this.apiUrl = envUrls.api = urls.api;
13185 this.identityUrl = envUrls.identity = urls.identity;
13186 this.iconsUrl = urls.icons;
13187 this.notificationsUrl = urls.notifications;
13188 this.eventsUrl = envUrls.events = urls.events;
13189 this.enterpriseUrl = urls.enterprise;
13190 this.apiService.setUrls(envUrls);
13191 });
13192 }
13193 setUrls(urls) {
13194 return environment_service_awaiter(this, void 0, void 0, function* () {
13195 urls.base = this.formatUrl(urls.base);
13196 urls.webVault = this.formatUrl(urls.webVault);
13197 urls.api = this.formatUrl(urls.api);
13198 urls.identity = this.formatUrl(urls.identity);
13199 urls.icons = this.formatUrl(urls.icons);
13200 urls.notifications = this.formatUrl(urls.notifications);
13201 urls.events = this.formatUrl(urls.events);
13202 urls.enterprise = this.formatUrl(urls.enterprise);
13203 yield this.storageService.save(ConstantsService.environmentUrlsKey, {
13204 base: urls.base,
13205 api: urls.api,
13206 identity: urls.identity,
13207 webVault: urls.webVault,
13208 icons: urls.icons,
13209 notifications: urls.notifications,
13210 events: urls.events,
13211 enterprise: urls.enterprise,
13212 });
13213 this.baseUrl = urls.base;
13214 this.webVaultUrl = urls.webVault;
13215 this.apiUrl = urls.api;
13216 this.identityUrl = urls.identity;
13217 this.iconsUrl = urls.icons;
13218 this.notificationsUrl = urls.notifications;
13219 this.eventsUrl = urls.events;
13220 this.enterpriseUrl = urls.enterprise;
13221 const envUrls = new EnvironmentUrls();
13222 if (this.baseUrl) {
13223 envUrls.base = this.baseUrl;
13224 }
13225 else {
13226 envUrls.api = this.apiUrl;
13227 envUrls.identity = this.identityUrl;
13228 envUrls.events = this.eventsUrl;
13229 }
13230 this.apiService.setUrls(envUrls);
13231 if (this.notificationsService != null) {
13232 this.notificationsService.init(this);
13233 }
13234 return urls;
13235 });
13236 }
13237 formatUrl(url) {
13238 if (url == null || url === '') {
13239 return null;
13240 }
13241 url = url.replace(/\/+$/g, '');
13242 if (!url.startsWith('http://') && !url.startsWith('https://')) {
13243 url = 'https://' + url;
13244 }
13245 return url.trim();
13246 }
13247}
13248
13249// EXTERNAL MODULE: external "papaparse"
13250var external_papaparse_ = __webpack_require__(8);
13251
13252// CONCATENATED MODULE: ./jslib/src/models/export/card.ts
13253
13254class export_card_Card {
13255 static template() {
13256 const req = new export_card_Card();
13257 req.cardholderName = 'John Doe';
13258 req.brand = 'visa';
13259 req.number = '4242424242424242';
13260 req.expMonth = '04';
13261 req.expYear = '2023';
13262 req.code = '123';
13263 return req;
13264 }
13265 static toView(req, view = new CardView()) {
13266 view.cardholderName = req.cardholderName;
13267 view.brand = req.brand;
13268 view.number = req.number;
13269 view.expMonth = req.expMonth;
13270 view.expYear = req.expYear;
13271 view.code = req.code;
13272 return view;
13273 }
13274 constructor(o) {
13275 if (o == null) {
13276 return;
13277 }
13278 this.cardholderName = o.cardholderName;
13279 this.brand = o.brand;
13280 this.number = o.number;
13281 this.expMonth = o.expMonth;
13282 this.expYear = o.expYear;
13283 this.code = o.code;
13284 }
13285}
13286
13287// CONCATENATED MODULE: ./jslib/src/models/export/field.ts
13288
13289
13290class export_field_Field {
13291 static template() {
13292 const req = new export_field_Field();
13293 req.name = 'Field name';
13294 req.value = 'Some value';
13295 req.type = FieldType.Text;
13296 return req;
13297 }
13298 static toView(req, view = new FieldView()) {
13299 view.type = req.type;
13300 view.value = req.value;
13301 view.name = req.name;
13302 return view;
13303 }
13304 constructor(o) {
13305 if (o == null) {
13306 return;
13307 }
13308 this.name = o.name;
13309 this.value = o.value;
13310 this.type = o.type;
13311 }
13312}
13313
13314// CONCATENATED MODULE: ./jslib/src/models/export/identity.ts
13315
13316class export_identity_Identity {
13317 static template() {
13318 const req = new export_identity_Identity();
13319 req.title = 'Mr';
13320 req.firstName = 'John';
13321 req.middleName = 'William';
13322 req.lastName = 'Doe';
13323 req.address1 = '123 Any St';
13324 req.address2 = 'Apt #123';
13325 req.address3 = null;
13326 req.city = 'New York';
13327 req.state = 'NY';
13328 req.postalCode = '10001';
13329 req.country = 'US';
13330 req.company = 'Acme Inc.';
13331 req.email = 'john@company.com';
13332 req.phone = '5555551234';
13333 req.ssn = '000-123-4567';
13334 req.username = 'jdoe';
13335 req.passportNumber = 'US-123456789';
13336 req.licenseNumber = 'D123-12-123-12333';
13337 return req;
13338 }
13339 static toView(req, view = new identityView_IdentityView()) {
13340 view.title = req.title;
13341 view.firstName = req.firstName;
13342 view.middleName = req.middleName;
13343 view.lastName = req.lastName;
13344 view.address1 = req.address1;
13345 view.address2 = req.address2;
13346 view.address3 = req.address3;
13347 view.city = req.city;
13348 view.state = req.state;
13349 view.postalCode = req.postalCode;
13350 view.country = req.country;
13351 view.company = req.company;
13352 view.email = req.email;
13353 view.phone = req.phone;
13354 view.ssn = req.ssn;
13355 view.username = req.username;
13356 view.passportNumber = req.passportNumber;
13357 view.licenseNumber = req.licenseNumber;
13358 return view;
13359 }
13360 constructor(o) {
13361 if (o == null) {
13362 return;
13363 }
13364 this.title = o.title;
13365 this.firstName = o.firstName;
13366 this.middleName = o.middleName;
13367 this.lastName = o.lastName;
13368 this.address1 = o.address1;
13369 this.address2 = o.address2;
13370 this.address3 = o.address3;
13371 this.city = o.city;
13372 this.state = o.state;
13373 this.postalCode = o.postalCode;
13374 this.country = o.country;
13375 this.company = o.company;
13376 this.email = o.email;
13377 this.phone = o.phone;
13378 this.ssn = o.ssn;
13379 this.username = o.username;
13380 this.passportNumber = o.passportNumber;
13381 this.licenseNumber = o.licenseNumber;
13382 }
13383}
13384
13385// CONCATENATED MODULE: ./jslib/src/models/export/loginUri.ts
13386
13387class export_loginUri_LoginUri {
13388 constructor(o) {
13389 this.match = null;
13390 if (o == null) {
13391 return;
13392 }
13393 this.uri = o.uri;
13394 this.match = o.match;
13395 }
13396 static template() {
13397 const req = new export_loginUri_LoginUri();
13398 req.uri = 'https://google.com';
13399 req.match = null;
13400 return req;
13401 }
13402 static toView(req, view = new loginUriView_LoginUriView()) {
13403 view.uri = req.uri;
13404 view.match = req.match;
13405 return view;
13406 }
13407}
13408
13409// CONCATENATED MODULE: ./jslib/src/models/export/login.ts
13410
13411
13412class export_login_Login {
13413 static template() {
13414 const req = new export_login_Login();
13415 req.uris = [];
13416 req.username = 'jdoe';
13417 req.password = 'myp@ssword123';
13418 req.totp = 'JBSWY3DPEHPK3PXP';
13419 return req;
13420 }
13421 static toView(req, view = new LoginView()) {
13422 if (req.uris != null) {
13423 view.uris = req.uris.map((u) => export_loginUri_LoginUri.toView(u));
13424 }
13425 view.username = req.username;
13426 view.password = req.password;
13427 view.totp = req.totp;
13428 return view;
13429 }
13430 constructor(o) {
13431 if (o == null) {
13432 return;
13433 }
13434 if (o.uris != null) {
13435 this.uris = o.uris.map((u) => new export_loginUri_LoginUri(u));
13436 }
13437 this.username = o.username;
13438 this.password = o.password;
13439 this.totp = o.totp;
13440 }
13441}
13442
13443// CONCATENATED MODULE: ./jslib/src/enums/secureNoteType.ts
13444var SecureNoteType;
13445(function (SecureNoteType) {
13446 SecureNoteType[SecureNoteType["Generic"] = 0] = "Generic";
13447})(SecureNoteType || (SecureNoteType = {}));
13448
13449// CONCATENATED MODULE: ./jslib/src/models/export/secureNote.ts
13450
13451
13452class export_secureNote_SecureNote {
13453 static template() {
13454 const req = new export_secureNote_SecureNote();
13455 req.type = SecureNoteType.Generic;
13456 return req;
13457 }
13458 static toView(req, view = new SecureNoteView()) {
13459 view.type = req.type;
13460 return view;
13461 }
13462 constructor(o) {
13463 if (o == null) {
13464 return;
13465 }
13466 this.type = o.type;
13467 }
13468}
13469
13470// CONCATENATED MODULE: ./jslib/src/models/export/cipher.ts
13471
13472
13473
13474
13475
13476
13477
13478class export_cipher_Cipher {
13479 static template() {
13480 const req = new export_cipher_Cipher();
13481 req.organizationId = null;
13482 req.folderId = null;
13483 req.type = CipherType.Login;
13484 req.name = 'Item name';
13485 req.notes = 'Some notes about this item.';
13486 req.favorite = false;
13487 req.fields = [];
13488 req.login = null;
13489 req.secureNote = null;
13490 req.card = null;
13491 req.identity = null;
13492 return req;
13493 }
13494 static toView(req, view = new cipherView_CipherView()) {
13495 view.type = req.type;
13496 view.folderId = req.folderId;
13497 if (view.organizationId == null) {
13498 view.organizationId = req.organizationId;
13499 }
13500 view.name = req.name;
13501 view.notes = req.notes;
13502 view.favorite = req.favorite;
13503 if (req.fields != null) {
13504 view.fields = req.fields.map((f) => export_field_Field.toView(f));
13505 }
13506 switch (req.type) {
13507 case CipherType.Login:
13508 view.login = export_login_Login.toView(req.login);
13509 break;
13510 case CipherType.SecureNote:
13511 view.secureNote = export_secureNote_SecureNote.toView(req.secureNote);
13512 break;
13513 case CipherType.Card:
13514 view.card = export_card_Card.toView(req.card);
13515 break;
13516 case CipherType.Identity:
13517 view.identity = export_identity_Identity.toView(req.identity);
13518 break;
13519 }
13520 return view;
13521 }
13522 // Use build method instead of ctor so that we can control order of JSON stringify for pretty print
13523 build(o) {
13524 this.organizationId = o.organizationId;
13525 this.folderId = o.folderId;
13526 this.type = o.type;
13527 this.name = o.name;
13528 this.notes = o.notes;
13529 this.favorite = o.favorite;
13530 if (o.fields != null) {
13531 this.fields = o.fields.map((f) => new export_field_Field(f));
13532 }
13533 switch (o.type) {
13534 case CipherType.Login:
13535 this.login = new export_login_Login(o.login);
13536 break;
13537 case CipherType.SecureNote:
13538 this.secureNote = new export_secureNote_SecureNote(o.secureNote);
13539 break;
13540 case CipherType.Card:
13541 this.card = new export_card_Card(o.card);
13542 break;
13543 case CipherType.Identity:
13544 this.identity = new export_identity_Identity(o.identity);
13545 break;
13546 }
13547 }
13548}
13549
13550// CONCATENATED MODULE: ./jslib/src/models/export/cipherWithIds.ts
13551
13552class cipherWithIds_CipherWithIds extends export_cipher_Cipher {
13553 // Use build method instead of ctor so that we can control order of JSON stringify for pretty print
13554 build(o) {
13555 this.id = o.id;
13556 super.build(o);
13557 this.collectionIds = o.collectionIds;
13558 }
13559}
13560
13561// CONCATENATED MODULE: ./jslib/src/models/export/collection.ts
13562
13563class export_collection_Collection {
13564 static template() {
13565 const req = new export_collection_Collection();
13566 req.organizationId = '00000000-0000-0000-0000-000000000000';
13567 req.name = 'Collection name';
13568 req.externalId = null;
13569 return req;
13570 }
13571 static toView(req, view = new collectionView_CollectionView()) {
13572 view.name = req.name;
13573 view.externalId = req.externalId;
13574 if (view.organizationId == null) {
13575 view.organizationId = req.organizationId;
13576 }
13577 return view;
13578 }
13579 // Use build method instead of ctor so that we can control order of JSON stringify for pretty print
13580 build(o) {
13581 this.organizationId = o.organizationId;
13582 this.name = o.name;
13583 this.externalId = o.externalId;
13584 }
13585}
13586
13587// CONCATENATED MODULE: ./jslib/src/models/export/collectionWithId.ts
13588
13589class collectionWithId_CollectionWithId extends export_collection_Collection {
13590 // Use build method instead of ctor so that we can control order of JSON stringify for pretty print
13591 build(o) {
13592 this.id = o.id;
13593 super.build(o);
13594 }
13595}
13596
13597// CONCATENATED MODULE: ./jslib/src/models/export/folder.ts
13598
13599class export_folder_Folder {
13600 static template() {
13601 const req = new export_folder_Folder();
13602 req.name = 'Folder name';
13603 return req;
13604 }
13605 static toView(req, view = new FolderView()) {
13606 view.name = req.name;
13607 return view;
13608 }
13609 // Use build method instead of ctor so that we can control order of JSON stringify for pretty print
13610 build(o) {
13611 this.name = o.name;
13612 }
13613}
13614
13615// CONCATENATED MODULE: ./jslib/src/models/export/folderWithId.ts
13616
13617class folderWithId_FolderWithId extends export_folder_Folder {
13618 // Use build method instead of ctor so that we can control order of JSON stringify for pretty print
13619 build(o) {
13620 this.id = o.id;
13621 super.build(o);
13622 }
13623}
13624
13625// CONCATENATED MODULE: ./jslib/src/services/export.service.ts
13626var export_service_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
13627 return new (P || (P = Promise))(function (resolve, reject) {
13628 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
13629 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
13630 function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
13631 step((generator = generator.apply(thisArg, _arguments || [])).next());
13632 });
13633};
13634
13635
13636
13637
13638
13639
13640
13641
13642
13643class export_service_ExportService {
13644 constructor(folderService, cipherService, apiService) {
13645 this.folderService = folderService;
13646 this.cipherService = cipherService;
13647 this.apiService = apiService;
13648 }
13649 getExport(format = 'csv') {
13650 return export_service_awaiter(this, void 0, void 0, function* () {
13651 let decFolders = [];
13652 let decCiphers = [];
13653 const promises = [];
13654 promises.push(this.folderService.getAllDecrypted().then((folders) => {
13655 decFolders = folders;
13656 }));
13657 promises.push(this.cipherService.getAllDecrypted().then((ciphers) => {
13658 decCiphers = ciphers;
13659 }));
13660 yield Promise.all(promises);
13661 if (format === 'csv') {
13662 const foldersMap = new Map();
13663 decFolders.forEach((f) => {
13664 if (f.id != null) {
13665 foldersMap.set(f.id, f);
13666 }
13667 });
13668 const exportCiphers = [];
13669 decCiphers.forEach((c) => {
13670 // only export logins and secure notes
13671 if (c.type !== CipherType.Login && c.type !== CipherType.SecureNote) {
13672 return;
13673 }
13674 if (c.organizationId != null) {
13675 return;
13676 }
13677 const cipher = {};
13678 cipher.folder = c.folderId != null && foldersMap.has(c.folderId) ?
13679 foldersMap.get(c.folderId).name : null;
13680 cipher.favorite = c.favorite ? 1 : null;
13681 this.buildCommonCipher(cipher, c);
13682 exportCiphers.push(cipher);
13683 });
13684 return external_papaparse_["unparse"](exportCiphers);
13685 }
13686 else {
13687 const jsonDoc = {
13688 folders: [],
13689 items: [],
13690 };
13691 decFolders.forEach((f) => {
13692 if (f.id == null) {
13693 return;
13694 }
13695 const folder = new folderWithId_FolderWithId();
13696 folder.build(f);
13697 jsonDoc.folders.push(folder);
13698 });
13699 decCiphers.forEach((c) => {
13700 if (c.organizationId != null) {
13701 return;
13702 }
13703 const cipher = new cipherWithIds_CipherWithIds();
13704 cipher.build(c);
13705 cipher.collectionIds = null;
13706 jsonDoc.items.push(cipher);
13707 });
13708 return JSON.stringify(jsonDoc, null, ' ');
13709 }
13710 });
13711 }
13712 getOrganizationExport(organizationId, format = 'csv') {
13713 return export_service_awaiter(this, void 0, void 0, function* () {
13714 const decCollections = [];
13715 const decCiphers = [];
13716 const promises = [];
13717 promises.push(this.apiService.getCollections(organizationId).then((collections) => {
13718 const collectionPromises = [];
13719 if (collections != null && collections.data != null && collections.data.length > 0) {
13720 collections.data.forEach((c) => {
13721 const collection = new collection_Collection(new CollectionData(c));
13722 collectionPromises.push(collection.decrypt().then((decCol) => {
13723 decCollections.push(decCol);
13724 }));
13725 });
13726 }
13727 return Promise.all(collectionPromises);
13728 }));
13729 promises.push(this.apiService.getCiphersOrganization(organizationId).then((ciphers) => {
13730 const cipherPromises = [];
13731 if (ciphers != null && ciphers.data != null && ciphers.data.length > 0) {
13732 ciphers.data.forEach((c) => {
13733 const cipher = new cipher_Cipher(new cipherData_CipherData(c));
13734 cipherPromises.push(cipher.decrypt().then((decCipher) => {
13735 decCiphers.push(decCipher);
13736 }));
13737 });
13738 }
13739 return Promise.all(cipherPromises);
13740 }));
13741 yield Promise.all(promises);
13742 if (format === 'csv') {
13743 const collectionsMap = new Map();
13744 decCollections.forEach((c) => {
13745 collectionsMap.set(c.id, c);
13746 });
13747 const exportCiphers = [];
13748 decCiphers.forEach((c) => {
13749 // only export logins and secure notes
13750 if (c.type !== CipherType.Login && c.type !== CipherType.SecureNote) {
13751 return;
13752 }
13753 const cipher = {};
13754 cipher.collections = [];
13755 if (c.collectionIds != null) {
13756 cipher.collections = c.collectionIds.filter((id) => collectionsMap.has(id))
13757 .map((id) => collectionsMap.get(id).name);
13758 }
13759 this.buildCommonCipher(cipher, c);
13760 exportCiphers.push(cipher);
13761 });
13762 return external_papaparse_["unparse"](exportCiphers);
13763 }
13764 else {
13765 const jsonDoc = {
13766 collections: [],
13767 items: [],
13768 };
13769 decCollections.forEach((c) => {
13770 const collection = new collectionWithId_CollectionWithId();
13771 collection.build(c);
13772 jsonDoc.collections.push(collection);
13773 });
13774 decCiphers.forEach((c) => {
13775 const cipher = new cipherWithIds_CipherWithIds();
13776 cipher.build(c);
13777 jsonDoc.items.push(cipher);
13778 });
13779 return JSON.stringify(jsonDoc, null, ' ');
13780 }
13781 });
13782 }
13783 getFileName(prefix = null, extension = 'csv') {
13784 const now = new Date();
13785 const dateString = now.getFullYear() + '' + this.padNumber(now.getMonth() + 1, 2) + '' + this.padNumber(now.getDate(), 2) +
13786 this.padNumber(now.getHours(), 2) + '' + this.padNumber(now.getMinutes(), 2) +
13787 this.padNumber(now.getSeconds(), 2);
13788 return 'bitwarden' + (prefix ? ('_' + prefix) : '') + '_export_' + dateString + '.' + extension;
13789 }
13790 padNumber(num, width, padCharacter = '0') {
13791 const numString = num.toString();
13792 return numString.length >= width ? numString :
13793 new Array(width - numString.length + 1).join(padCharacter) + numString;
13794 }
13795 buildCommonCipher(cipher, c) {
13796 cipher.type = null;
13797 cipher.name = c.name;
13798 cipher.notes = c.notes;
13799 cipher.fields = null;
13800 // Login props
13801 cipher.login_uri = null;
13802 cipher.login_username = null;
13803 cipher.login_password = null;
13804 cipher.login_totp = null;
13805 if (c.fields) {
13806 c.fields.forEach((f) => {
13807 if (!cipher.fields) {
13808 cipher.fields = '';
13809 }
13810 else {
13811 cipher.fields += '\n';
13812 }
13813 cipher.fields += ((f.name || '') + ': ' + f.value);
13814 });
13815 }
13816 switch (c.type) {
13817 case CipherType.Login:
13818 cipher.type = 'login';
13819 cipher.login_username = c.login.username;
13820 cipher.login_password = c.login.password;
13821 cipher.login_totp = c.login.totp;
13822 if (c.login.uris) {
13823 cipher.login_uri = [];
13824 c.login.uris.forEach((u) => {
13825 cipher.login_uri.push(u.uri);
13826 });
13827 }
13828 break;
13829 case CipherType.SecureNote:
13830 cipher.type = 'note';
13831 break;
13832 default:
13833 return;
13834 }
13835 return cipher;
13836 }
13837}
13838
13839// CONCATENATED MODULE: ./jslib/src/models/data/folderData.ts
13840class FolderData {
13841 constructor(response, userId) {
13842 this.userId = userId;
13843 this.name = response.name;
13844 this.id = response.id;
13845 this.revisionDate = response.revisionDate;
13846 }
13847}
13848
13849// CONCATENATED MODULE: ./jslib/src/models/request/folderRequest.ts
13850class FolderRequest {
13851 constructor(folder) {
13852 this.name = folder.name ? folder.name.encryptedString : null;
13853 }
13854}
13855
13856// CONCATENATED MODULE: ./jslib/src/services/folder.service.ts
13857var folder_service_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
13858 return new (P || (P = Promise))(function (resolve, reject) {
13859 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
13860 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
13861 function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
13862 step((generator = generator.apply(thisArg, _arguments || [])).next());
13863 });
13864};
13865
13866
13867
13868
13869
13870
13871const folder_service_Keys = {
13872 foldersPrefix: 'folders_',
13873 ciphersPrefix: 'ciphers_',
13874};
13875const folder_service_NestingDelimiter = '/';
13876class folder_service_FolderService {
13877 constructor(cryptoService, userService, apiService, storageService, i18nService, cipherService) {
13878 this.cryptoService = cryptoService;
13879 this.userService = userService;
13880 this.apiService = apiService;
13881 this.storageService = storageService;
13882 this.i18nService = i18nService;
13883 this.cipherService = cipherService;
13884 }
13885 clearCache() {
13886 this.decryptedFolderCache = null;
13887 }
13888 encrypt(model, key) {
13889 return folder_service_awaiter(this, void 0, void 0, function* () {
13890 const folder = new folder_Folder();
13891 folder.id = model.id;
13892 folder.name = yield this.cryptoService.encrypt(model.name, key);
13893 return folder;
13894 });
13895 }
13896 get(id) {
13897 return folder_service_awaiter(this, void 0, void 0, function* () {
13898 const userId = yield this.userService.getUserId();
13899 const folders = yield this.storageService.get(folder_service_Keys.foldersPrefix + userId);
13900 if (folders == null || !folders.hasOwnProperty(id)) {
13901 return null;
13902 }
13903 return new folder_Folder(folders[id]);
13904 });
13905 }
13906 getAll() {
13907 return folder_service_awaiter(this, void 0, void 0, function* () {
13908 const userId = yield this.userService.getUserId();
13909 const folders = yield this.storageService.get(folder_service_Keys.foldersPrefix + userId);
13910 const response = [];
13911 for (const id in folders) {
13912 if (folders.hasOwnProperty(id)) {
13913 response.push(new folder_Folder(folders[id]));
13914 }
13915 }
13916 return response;
13917 });
13918 }
13919 getAllDecrypted() {
13920 return folder_service_awaiter(this, void 0, void 0, function* () {
13921 if (this.decryptedFolderCache != null) {
13922 return this.decryptedFolderCache;
13923 }
13924 const hasKey = yield this.cryptoService.hasKey();
13925 if (!hasKey) {
13926 throw new Error('No key.');
13927 }
13928 const decFolders = [];
13929 const promises = [];
13930 const folders = yield this.getAll();
13931 folders.forEach((folder) => {
13932 promises.push(folder.decrypt().then((f) => decFolders.push(f)));
13933 });
13934 yield Promise.all(promises);
13935 decFolders.sort(utils_Utils.getSortFunction(this.i18nService, 'name'));
13936 const noneFolder = new FolderView();
13937 noneFolder.name = this.i18nService.t('noneFolder');
13938 decFolders.push(noneFolder);
13939 this.decryptedFolderCache = decFolders;
13940 return this.decryptedFolderCache;
13941 });
13942 }
13943 getAllNested() {
13944 return folder_service_awaiter(this, void 0, void 0, function* () {
13945 const folders = yield this.getAllDecrypted();
13946 const nodes = [];
13947 folders.forEach((f) => {
13948 const folderCopy = new FolderView();
13949 folderCopy.id = f.id;
13950 folderCopy.revisionDate = f.revisionDate;
13951 const parts = f.name != null ? f.name.replace(/^\/+|\/+$/g, '').split(folder_service_NestingDelimiter) : [];
13952 serviceUtils_ServiceUtils.nestedTraverse(nodes, 0, parts, folderCopy, null, folder_service_NestingDelimiter);
13953 });
13954 return nodes;
13955 });
13956 }
13957 getNested(id) {
13958 return folder_service_awaiter(this, void 0, void 0, function* () {
13959 const folders = yield this.getAllNested();
13960 return serviceUtils_ServiceUtils.getTreeNodeObject(folders, id);
13961 });
13962 }
13963 saveWithServer(folder) {
13964 return folder_service_awaiter(this, void 0, void 0, function* () {
13965 const request = new FolderRequest(folder);
13966 let response;
13967 if (folder.id == null) {
13968 response = yield this.apiService.postFolder(request);
13969 folder.id = response.id;
13970 }
13971 else {
13972 response = yield this.apiService.putFolder(folder.id, request);
13973 }
13974 const userId = yield this.userService.getUserId();
13975 const data = new FolderData(response, userId);
13976 yield this.upsert(data);
13977 });
13978 }
13979 upsert(folder) {
13980 return folder_service_awaiter(this, void 0, void 0, function* () {
13981 const userId = yield this.userService.getUserId();
13982 let folders = yield this.storageService.get(folder_service_Keys.foldersPrefix + userId);
13983 if (folders == null) {
13984 folders = {};
13985 }
13986 if (folder instanceof FolderData) {
13987 const f = folder;
13988 folders[f.id] = f;
13989 }
13990 else {
13991 folder.forEach((f) => {
13992 folders[f.id] = f;
13993 });
13994 }
13995 yield this.storageService.save(folder_service_Keys.foldersPrefix + userId, folders);
13996 this.decryptedFolderCache = null;
13997 });
13998 }
13999 replace(folders) {
14000 return folder_service_awaiter(this, void 0, void 0, function* () {
14001 const userId = yield this.userService.getUserId();
14002 yield this.storageService.save(folder_service_Keys.foldersPrefix + userId, folders);
14003 this.decryptedFolderCache = null;
14004 });
14005 }
14006 clear(userId) {
14007 return folder_service_awaiter(this, void 0, void 0, function* () {
14008 yield this.storageService.remove(folder_service_Keys.foldersPrefix + userId);
14009 this.decryptedFolderCache = null;
14010 });
14011 }
14012 delete(id) {
14013 return folder_service_awaiter(this, void 0, void 0, function* () {
14014 const userId = yield this.userService.getUserId();
14015 const folders = yield this.storageService.get(folder_service_Keys.foldersPrefix + userId);
14016 if (folders == null) {
14017 return;
14018 }
14019 if (typeof id === 'string') {
14020 if (folders[id] == null) {
14021 return;
14022 }
14023 delete folders[id];
14024 }
14025 else {
14026 id.forEach((i) => {
14027 delete folders[i];
14028 });
14029 }
14030 yield this.storageService.save(folder_service_Keys.foldersPrefix + userId, folders);
14031 this.decryptedFolderCache = null;
14032 // Items in a deleted folder are re-assigned to "No Folder"
14033 const ciphers = yield this.storageService.get(folder_service_Keys.ciphersPrefix + userId);
14034 if (ciphers != null) {
14035 const updates = [];
14036 for (const cId in ciphers) {
14037 if (ciphers[cId].folderId === id) {
14038 ciphers[cId].folderId = null;
14039 updates.push(ciphers[cId]);
14040 }
14041 }
14042 if (updates.length > 0) {
14043 this.cipherService.upsert(updates);
14044 }
14045 }
14046 });
14047 }
14048 deleteWithServer(id) {
14049 return folder_service_awaiter(this, void 0, void 0, function* () {
14050 yield this.apiService.deleteFolder(id);
14051 yield this.delete(id);
14052 });
14053 }
14054}
14055
14056// CONCATENATED MODULE: ./jslib/src/models/request/collectionRequest.ts
14057class CollectionRequest {
14058 constructor(collection) {
14059 this.groups = [];
14060 if (collection == null) {
14061 return;
14062 }
14063 this.name = collection.name ? collection.name.encryptedString : null;
14064 this.externalId = collection.externalId;
14065 }
14066}
14067
14068// CONCATENATED MODULE: ./jslib/src/models/request/importCiphersRequest.ts
14069class ImportCiphersRequest {
14070 constructor() {
14071 this.ciphers = [];
14072 this.folders = [];
14073 this.folderRelationships = [];
14074 }
14075}
14076
14077// CONCATENATED MODULE: ./jslib/src/models/request/importOrganizationCiphersRequest.ts
14078class ImportOrganizationCiphersRequest {
14079 constructor() {
14080 this.ciphers = [];
14081 this.collections = [];
14082 this.collectionRelationships = [];
14083 }
14084}
14085
14086// CONCATENATED MODULE: ./jslib/src/models/request/kvpRequest.ts
14087class KvpRequest {
14088 constructor(key, value) {
14089 this.key = key;
14090 this.value = value;
14091 }
14092}
14093
14094// CONCATENATED MODULE: ./jslib/src/importers/baseImporter.ts
14095
14096
14097
14098
14099
14100
14101
14102
14103
14104
14105
14106
14107class baseImporter_BaseImporter {
14108 constructor() {
14109 this.organization = false;
14110 this.newLineRegex = /(?:\r\n|\r|\n)/;
14111 this.passwordFieldNames = [
14112 'password', 'pass word', 'passphrase', 'pass phrase',
14113 'pass', 'code', 'code word', 'codeword',
14114 'secret', 'secret word', 'personpwd',
14115 'key', 'keyword', 'key word', 'keyphrase', 'key phrase',
14116 'form_pw', 'wppassword', 'pin', 'pwd', 'pw', 'pword', 'passwd',
14117 'p', 'serial', 'serial#', 'license key', 'reg #',
14118 // Non-English names
14119 'passwort',
14120 ];
14121 this.usernameFieldNames = [
14122 'user', 'name', 'user name', 'username', 'login name',
14123 'email', 'e-mail', 'id', 'userid', 'user id',
14124 'login', 'form_loginname', 'wpname', 'mail',
14125 'loginid', 'login id', 'log', 'personlogin',
14126 'first name', 'last name', 'card#', 'account #',
14127 'member', 'member #',
14128 // Non-English names
14129 'nom', 'benutzername',
14130 ];
14131 this.notesFieldNames = [
14132 'note', 'notes', 'comment', 'comments', 'memo',
14133 'description', 'free form', 'freeform',
14134 'free text', 'freetext', 'free',
14135 // Non-English names
14136 'kommentar',
14137 ];
14138 this.uriFieldNames = [
14139 'url', 'hyper link', 'hyperlink', 'link',
14140 'host', 'hostname', 'host name', 'server', 'address',
14141 'hyper ref', 'href', 'web', 'website', 'web site', 'site',
14142 'web-site', 'uri',
14143 // Non-English names
14144 'ort', 'adresse',
14145 ];
14146 }
14147 parseXml(data) {
14148 const parser = new DOMParser();
14149 const doc = parser.parseFromString(data, 'application/xml');
14150 return doc != null && doc.querySelector('parsererror') == null ? doc : null;
14151 }
14152 parseCsv(data, header) {
14153 data = this.splitNewLine(data).join('\n').trim();
14154 const result = external_papaparse_["parse"](data, {
14155 header: header,
14156 encoding: 'UTF-8',
14157 skipEmptyLines: false,
14158 });
14159 if (result.errors != null && result.errors.length > 0) {
14160 result.errors.forEach((e) => {
14161 if (e.row != null) {
14162 // tslint:disable-next-line
14163 console.warn('Error parsing row ' + e.row + ': ' + e.message);
14164 }
14165 });
14166 }
14167 return result.data && result.data.length > 0 ? result.data : null;
14168 }
14169 parseSingleRowCsv(rowData) {
14170 if (this.isNullOrWhitespace(rowData)) {
14171 return null;
14172 }
14173 const parsedRow = this.parseCsv(rowData, false);
14174 if (parsedRow != null && parsedRow.length > 0 && parsedRow[0].length > 0) {
14175 return parsedRow[0];
14176 }
14177 return null;
14178 }
14179 makeUriArray(uri) {
14180 if (uri == null) {
14181 return null;
14182 }
14183 if (typeof uri === 'string') {
14184 const loginUri = new loginUriView_LoginUriView();
14185 loginUri.uri = this.fixUri(uri);
14186 if (this.isNullOrWhitespace(loginUri.uri)) {
14187 return null;
14188 }
14189 loginUri.match = null;
14190 return [loginUri];
14191 }
14192 if (uri.length > 0) {
14193 const returnArr = [];
14194 uri.forEach((u) => {
14195 const loginUri = new loginUriView_LoginUriView();
14196 loginUri.uri = this.fixUri(u);
14197 if (this.isNullOrWhitespace(loginUri.uri)) {
14198 return;
14199 }
14200 loginUri.match = null;
14201 returnArr.push(loginUri);
14202 });
14203 return returnArr.length === 0 ? null : returnArr;
14204 }
14205 return null;
14206 }
14207 fixUri(uri) {
14208 if (uri == null) {
14209 return null;
14210 }
14211 uri = uri.trim();
14212 if (uri.indexOf('://') === -1 && uri.indexOf('.') >= 0) {
14213 uri = 'http://' + uri;
14214 }
14215 if (uri.length > 1000) {
14216 return uri.substring(0, 1000);
14217 }
14218 return uri;
14219 }
14220 nameFromUrl(url) {
14221 const hostname = utils_Utils.getHostname(url);
14222 if (this.isNullOrWhitespace(hostname)) {
14223 return null;
14224 }
14225 return hostname.startsWith('www.') ? hostname.replace('www.', '') : hostname;
14226 }
14227 isNullOrWhitespace(str) {
14228 return utils_Utils.isNullOrWhitespace(str);
14229 }
14230 getValueOrDefault(str, defaultValue = null) {
14231 if (this.isNullOrWhitespace(str)) {
14232 return defaultValue;
14233 }
14234 return str;
14235 }
14236 splitNewLine(str) {
14237 return str.split(this.newLineRegex);
14238 }
14239 // ref https://stackoverflow.com/a/5911300
14240 getCardBrand(cardNum) {
14241 if (this.isNullOrWhitespace(cardNum)) {
14242 return null;
14243 }
14244 // Visa
14245 let re = new RegExp('^4');
14246 if (cardNum.match(re) != null) {
14247 return 'Visa';
14248 }
14249 // Mastercard
14250 // Updated for Mastercard 2017 BINs expansion
14251 if (/^(5[1-5][0-9]{14}|2(22[1-9][0-9]{12}|2[3-9][0-9]{13}|[3-6][0-9]{14}|7[0-1][0-9]{13}|720[0-9]{12}))$/
14252 .test(cardNum)) {
14253 return 'Mastercard';
14254 }
14255 // AMEX
14256 re = new RegExp('^3[47]');
14257 if (cardNum.match(re) != null) {
14258 return 'Amex';
14259 }
14260 // Discover
14261 re = new RegExp('^(6011|622(12[6-9]|1[3-9][0-9]|[2-8][0-9]{2}|9[0-1][0-9]|92[0-5]|64[4-9])|65)');
14262 if (cardNum.match(re) != null) {
14263 return 'Discover';
14264 }
14265 // Diners
14266 re = new RegExp('^36');
14267 if (cardNum.match(re) != null) {
14268 return 'Diners Club';
14269 }
14270 // Diners - Carte Blanche
14271 re = new RegExp('^30[0-5]');
14272 if (cardNum.match(re) != null) {
14273 return 'Diners Club';
14274 }
14275 // JCB
14276 re = new RegExp('^35(2[89]|[3-8][0-9])');
14277 if (cardNum.match(re) != null) {
14278 return 'JCB';
14279 }
14280 // Visa Electron
14281 re = new RegExp('^(4026|417500|4508|4844|491(3|7))');
14282 if (cardNum.match(re) != null) {
14283 return 'Visa';
14284 }
14285 return null;
14286 }
14287 setCardExpiration(cipher, expiration) {
14288 if (!this.isNullOrWhitespace(expiration)) {
14289 const parts = expiration.split('/');
14290 if (parts.length === 2) {
14291 let month = null;
14292 let year = null;
14293 if (parts[0].length === 1 || parts[0].length === 2) {
14294 month = parts[0];
14295 if (month.length === 2 && month[0] === '0') {
14296 month = month.substr(1, 1);
14297 }
14298 }
14299 if (parts[1].length === 2 || parts[1].length === 4) {
14300 year = month.length === 2 ? '20' + parts[1] : parts[1];
14301 }
14302 if (month != null && year != null) {
14303 cipher.card.expMonth = month;
14304 cipher.card.expYear = year;
14305 return true;
14306 }
14307 }
14308 }
14309 return false;
14310 }
14311 moveFoldersToCollections(result) {
14312 result.folderRelationships.forEach((r) => result.collectionRelationships.push(r));
14313 result.collections = result.folders.map((f) => {
14314 const collection = new collectionView_CollectionView();
14315 collection.name = f.name;
14316 return collection;
14317 });
14318 result.folderRelationships = [];
14319 result.folders = [];
14320 }
14321 querySelectorDirectChild(parentEl, query) {
14322 const els = this.querySelectorAllDirectChild(parentEl, query);
14323 return els.length === 0 ? null : els[0];
14324 }
14325 querySelectorAllDirectChild(parentEl, query) {
14326 return Array.from(parentEl.querySelectorAll(query)).filter((el) => el.parentNode === parentEl);
14327 }
14328 initLoginCipher() {
14329 const cipher = new cipherView_CipherView();
14330 cipher.favorite = false;
14331 cipher.notes = '';
14332 cipher.fields = [];
14333 cipher.login = new LoginView();
14334 cipher.type = CipherType.Login;
14335 return cipher;
14336 }
14337 cleanupCipher(cipher) {
14338 if (cipher == null) {
14339 return;
14340 }
14341 if (cipher.type !== CipherType.Login) {
14342 cipher.login = null;
14343 }
14344 if (this.isNullOrWhitespace(cipher.name)) {
14345 cipher.name = '--';
14346 }
14347 if (this.isNullOrWhitespace(cipher.notes)) {
14348 cipher.notes = null;
14349 }
14350 else {
14351 cipher.notes = cipher.notes.trim();
14352 }
14353 if (cipher.fields != null && cipher.fields.length === 0) {
14354 cipher.fields = null;
14355 }
14356 }
14357 processKvp(cipher, key, value, type = FieldType.Text) {
14358 if (this.isNullOrWhitespace(value)) {
14359 return;
14360 }
14361 if (this.isNullOrWhitespace(key)) {
14362 key = '';
14363 }
14364 if (value.length > 200 || value.trim().search(this.newLineRegex) > -1) {
14365 if (cipher.notes == null) {
14366 cipher.notes = '';
14367 }
14368 cipher.notes += (key + ': ' + this.splitNewLine(value).join('\n') + '\n');
14369 }
14370 else {
14371 if (cipher.fields == null) {
14372 cipher.fields = [];
14373 }
14374 const field = new FieldView();
14375 field.type = type;
14376 field.name = key;
14377 field.value = value;
14378 cipher.fields.push(field);
14379 }
14380 }
14381 processFolder(result, folderName) {
14382 let folderIndex = result.folders.length;
14383 const hasFolder = !this.isNullOrWhitespace(folderName);
14384 let addFolder = hasFolder;
14385 if (hasFolder) {
14386 for (let i = 0; i < result.folders.length; i++) {
14387 if (result.folders[i].name === folderName) {
14388 addFolder = false;
14389 folderIndex = i;
14390 break;
14391 }
14392 }
14393 }
14394 if (addFolder) {
14395 const f = new FolderView();
14396 f.name = folderName;
14397 result.folders.push(f);
14398 }
14399 if (hasFolder) {
14400 result.folderRelationships.push([result.ciphers.length, folderIndex]);
14401 }
14402 }
14403 convertToNoteIfNeeded(cipher) {
14404 if (cipher.type === CipherType.Login && this.isNullOrWhitespace(cipher.login.username) &&
14405 this.isNullOrWhitespace(cipher.login.password) &&
14406 (cipher.login.uris == null || cipher.login.uris.length === 0)) {
14407 cipher.type = CipherType.SecureNote;
14408 cipher.secureNote = new SecureNoteView();
14409 cipher.secureNote.type = SecureNoteType.Generic;
14410 }
14411 }
14412}
14413
14414// CONCATENATED MODULE: ./jslib/src/models/domain/importResult.ts
14415class ImportResult {
14416 constructor() {
14417 this.success = false;
14418 this.ciphers = [];
14419 this.folders = [];
14420 this.folderRelationships = [];
14421 this.collections = [];
14422 this.collectionRelationships = [];
14423 }
14424}
14425
14426// CONCATENATED MODULE: ./jslib/src/importers/ascendoCsvImporter.ts
14427
14428
14429class ascendoCsvImporter_AscendoCsvImporter extends baseImporter_BaseImporter {
14430 parse(data) {
14431 const result = new ImportResult();
14432 const results = this.parseCsv(data, false);
14433 if (results == null) {
14434 result.success = false;
14435 return result;
14436 }
14437 results.forEach((value) => {
14438 if (value.length < 2) {
14439 return;
14440 }
14441 const cipher = this.initLoginCipher();
14442 cipher.notes = this.getValueOrDefault(value[value.length - 1]);
14443 cipher.name = this.getValueOrDefault(value[0], '--');
14444 if (value.length > 2 && (value.length % 2) === 0) {
14445 for (let i = 0; i < value.length - 2; i += 2) {
14446 const val = value[i + 2];
14447 const field = value[i + 1];
14448 if (this.isNullOrWhitespace(val) || this.isNullOrWhitespace(field)) {
14449 continue;
14450 }
14451 const fieldLower = field.toLowerCase();
14452 if (cipher.login.password == null && this.passwordFieldNames.indexOf(fieldLower) > -1) {
14453 cipher.login.password = this.getValueOrDefault(val);
14454 }
14455 else if (cipher.login.username == null &&
14456 this.usernameFieldNames.indexOf(fieldLower) > -1) {
14457 cipher.login.username = this.getValueOrDefault(val);
14458 }
14459 else if ((cipher.login.uris == null || cipher.login.uris.length === 0) &&
14460 this.uriFieldNames.indexOf(fieldLower) > -1) {
14461 cipher.login.uris = this.makeUriArray(val);
14462 }
14463 else {
14464 this.processKvp(cipher, field, val);
14465 }
14466 }
14467 }
14468 this.convertToNoteIfNeeded(cipher);
14469 this.cleanupCipher(cipher);
14470 result.ciphers.push(cipher);
14471 });
14472 result.success = true;
14473 return result;
14474 }
14475}
14476
14477// CONCATENATED MODULE: ./jslib/src/importers/avastCsvImporter.ts
14478
14479
14480class avastCsvImporter_AvastCsvImporter extends baseImporter_BaseImporter {
14481 parse(data) {
14482 const result = new ImportResult();
14483 const results = this.parseCsv(data, true);
14484 if (results == null) {
14485 result.success = false;
14486 return result;
14487 }
14488 results.forEach((value) => {
14489 const cipher = this.initLoginCipher();
14490 cipher.name = this.getValueOrDefault(value.name);
14491 cipher.login.uris = this.makeUriArray(value.web);
14492 cipher.login.password = this.getValueOrDefault(value.password);
14493 cipher.login.username = this.getValueOrDefault(value.login);
14494 this.cleanupCipher(cipher);
14495 result.ciphers.push(cipher);
14496 });
14497 result.success = true;
14498 return result;
14499 }
14500}
14501
14502// CONCATENATED MODULE: ./jslib/src/importers/avastJsonImporter.ts
14503
14504
14505
14506
14507class avastJsonImporter_AvastJsonImporter extends baseImporter_BaseImporter {
14508 parse(data) {
14509 const result = new ImportResult();
14510 const results = JSON.parse(data);
14511 if (results == null) {
14512 result.success = false;
14513 return result;
14514 }
14515 if (results.logins != null) {
14516 results.logins.forEach((value) => {
14517 const cipher = this.initLoginCipher();
14518 cipher.name = this.getValueOrDefault(value.custName);
14519 cipher.notes = this.getValueOrDefault(value.note);
14520 cipher.login.uris = this.makeUriArray(value.url);
14521 cipher.login.password = this.getValueOrDefault(value.pwd);
14522 cipher.login.username = this.getValueOrDefault(value.loginName);
14523 this.cleanupCipher(cipher);
14524 result.ciphers.push(cipher);
14525 });
14526 }
14527 if (results.notes != null) {
14528 results.notes.forEach((value) => {
14529 const cipher = this.initLoginCipher();
14530 cipher.type = CipherType.SecureNote;
14531 cipher.secureNote.type = SecureNoteType.Generic;
14532 cipher.name = this.getValueOrDefault(value.label);
14533 cipher.notes = this.getValueOrDefault(value.text);
14534 this.cleanupCipher(cipher);
14535 result.ciphers.push(cipher);
14536 });
14537 }
14538 if (results.cards != null) {
14539 results.cards.forEach((value) => {
14540 const cipher = this.initLoginCipher();
14541 cipher.type = CipherType.Card;
14542 cipher.name = this.getValueOrDefault(value.custName);
14543 cipher.notes = this.getValueOrDefault(value.note);
14544 cipher.card.cardholderName = this.getValueOrDefault(value.holderName);
14545 cipher.card.number = this.getValueOrDefault(value.cardNumber);
14546 cipher.card.code = this.getValueOrDefault(value.cvv);
14547 cipher.card.brand = this.getCardBrand(cipher.card.number);
14548 if (value.expirationDate != null) {
14549 if (value.expirationDate.month != null) {
14550 cipher.card.expMonth = value.expirationDate.month + '';
14551 }
14552 if (value.expirationDate.year != null) {
14553 cipher.card.expYear = value.expirationDate.year + '';
14554 }
14555 }
14556 this.cleanupCipher(cipher);
14557 result.ciphers.push(cipher);
14558 });
14559 }
14560 result.success = true;
14561 return result;
14562 }
14563}
14564
14565// CONCATENATED MODULE: ./jslib/src/importers/aviraCsvImporter.ts
14566
14567
14568class aviraCsvImporter_AviraCsvImporter extends baseImporter_BaseImporter {
14569 parse(data) {
14570 const result = new ImportResult();
14571 const results = this.parseCsv(data, true);
14572 if (results == null) {
14573 result.success = false;
14574 return result;
14575 }
14576 results.forEach((value) => {
14577 const cipher = this.initLoginCipher();
14578 cipher.name = this.getValueOrDefault(value.name, this.getValueOrDefault(this.nameFromUrl(value.website), '--'));
14579 cipher.login.uris = this.makeUriArray(value.website);
14580 cipher.login.password = this.getValueOrDefault(value.password);
14581 if (this.isNullOrWhitespace(value.username) && !this.isNullOrWhitespace(value.secondary_username)) {
14582 cipher.login.username = value.secondary_username;
14583 }
14584 else {
14585 cipher.login.username = this.getValueOrDefault(value.username);
14586 cipher.notes = this.getValueOrDefault(value.secondary_username);
14587 }
14588 this.cleanupCipher(cipher);
14589 result.ciphers.push(cipher);
14590 });
14591 result.success = true;
14592 return result;
14593 }
14594}
14595
14596// CONCATENATED MODULE: ./jslib/src/importers/bitwardenCsvImporter.ts
14597
14598
14599
14600
14601
14602
14603
14604
14605
14606
14607class bitwardenCsvImporter_BitwardenCsvImporter extends baseImporter_BaseImporter {
14608 parse(data) {
14609 const result = new ImportResult();
14610 const results = this.parseCsv(data, true);
14611 if (results == null) {
14612 result.success = false;
14613 return result;
14614 }
14615 results.forEach((value) => {
14616 if (this.organization && !this.isNullOrWhitespace(value.collections)) {
14617 const collections = value.collections.split(',');
14618 collections.forEach((col) => {
14619 let addCollection = true;
14620 let collectionIndex = result.collections.length;
14621 for (let i = 0; i < result.collections.length; i++) {
14622 if (result.collections[i].name === col) {
14623 addCollection = false;
14624 collectionIndex = i;
14625 break;
14626 }
14627 }
14628 if (addCollection) {
14629 const collection = new collectionView_CollectionView();
14630 collection.name = col;
14631 result.collections.push(collection);
14632 }
14633 result.collectionRelationships.push([result.ciphers.length, collectionIndex]);
14634 });
14635 }
14636 else if (!this.organization) {
14637 this.processFolder(result, value.folder);
14638 }
14639 const cipher = new cipherView_CipherView();
14640 cipher.favorite = !this.organization && this.getValueOrDefault(value.favorite, '0') !== '0' ? true : false;
14641 cipher.type = CipherType.Login;
14642 cipher.notes = this.getValueOrDefault(value.notes);
14643 cipher.name = this.getValueOrDefault(value.name, '--');
14644 if (!this.isNullOrWhitespace(value.fields)) {
14645 const fields = this.splitNewLine(value.fields);
14646 for (let i = 0; i < fields.length; i++) {
14647 if (this.isNullOrWhitespace(fields[i])) {
14648 continue;
14649 }
14650 const delimPosition = fields[i].lastIndexOf(': ');
14651 if (delimPosition === -1) {
14652 continue;
14653 }
14654 if (cipher.fields == null) {
14655 cipher.fields = [];
14656 }
14657 const field = new FieldView();
14658 field.name = fields[i].substr(0, delimPosition);
14659 field.value = null;
14660 field.type = FieldType.Text;
14661 if (fields[i].length > (delimPosition + 2)) {
14662 field.value = fields[i].substr(delimPosition + 2);
14663 }
14664 cipher.fields.push(field);
14665 }
14666 }
14667 const valueType = value.type != null ? value.type.toLowerCase() : null;
14668 switch (valueType) {
14669 case 'note':
14670 cipher.type = CipherType.SecureNote;
14671 cipher.secureNote = new SecureNoteView();
14672 cipher.secureNote.type = SecureNoteType.Generic;
14673 break;
14674 default:
14675 cipher.type = CipherType.Login;
14676 cipher.login = new LoginView();
14677 cipher.login.totp = this.getValueOrDefault(value.login_totp || value.totp);
14678 cipher.login.username = this.getValueOrDefault(value.login_username || value.username);
14679 cipher.login.password = this.getValueOrDefault(value.login_password || value.password);
14680 const uris = this.parseSingleRowCsv(value.login_uri || value.uri);
14681 cipher.login.uris = this.makeUriArray(uris);
14682 break;
14683 }
14684 result.ciphers.push(cipher);
14685 });
14686 result.success = true;
14687 return result;
14688 }
14689}
14690
14691// CONCATENATED MODULE: ./jslib/src/importers/bitwardenJsonImporter.ts
14692
14693
14694
14695
14696
14697class bitwardenJsonImporter_BitwardenJsonImporter extends baseImporter_BaseImporter {
14698 parse(data) {
14699 const result = new ImportResult();
14700 const results = JSON.parse(data);
14701 if (results == null || results.items == null || results.items.length === 0) {
14702 result.success = false;
14703 return result;
14704 }
14705 const groupingsMap = new Map();
14706 if (this.organization && results.collections != null) {
14707 results.collections.forEach((c) => {
14708 const collection = collectionWithId_CollectionWithId.toView(c);
14709 if (collection != null) {
14710 collection.id = null;
14711 collection.organizationId = null;
14712 groupingsMap.set(c.id, result.collections.length);
14713 result.collections.push(collection);
14714 }
14715 });
14716 }
14717 else if (!this.organization && results.folders != null) {
14718 results.folders.forEach((f) => {
14719 const folder = folderWithId_FolderWithId.toView(f);
14720 if (folder != null) {
14721 folder.id = null;
14722 groupingsMap.set(f.id, result.folders.length);
14723 result.folders.push(folder);
14724 }
14725 });
14726 }
14727 results.items.forEach((c) => {
14728 const cipher = cipherWithIds_CipherWithIds.toView(c);
14729 // reset ids incase they were set for some reason
14730 cipher.id = null;
14731 cipher.folderId = null;
14732 cipher.organizationId = null;
14733 cipher.collectionIds = null;
14734 // make sure password history is limited
14735 if (cipher.passwordHistory != null && cipher.passwordHistory.length > 5) {
14736 cipher.passwordHistory = cipher.passwordHistory.slice(0, 5);
14737 }
14738 if (!this.organization && c.folderId != null && groupingsMap.has(c.folderId)) {
14739 result.folderRelationships.push([result.ciphers.length, groupingsMap.get(c.folderId)]);
14740 }
14741 else if (this.organization && c.collectionIds != null) {
14742 c.collectionIds.forEach((cId) => {
14743 if (groupingsMap.has(cId)) {
14744 result.collectionRelationships.push([result.ciphers.length, groupingsMap.get(cId)]);
14745 }
14746 });
14747 }
14748 this.cleanupCipher(cipher);
14749 result.ciphers.push(cipher);
14750 });
14751 result.success = true;
14752 return result;
14753 }
14754}
14755
14756// CONCATENATED MODULE: ./jslib/src/importers/blackBerryCsvImporter.ts
14757
14758
14759class blackBerryCsvImporter_BlackBerryCsvImporter extends baseImporter_BaseImporter {
14760 parse(data) {
14761 const result = new ImportResult();
14762 const results = this.parseCsv(data, true);
14763 if (results == null) {
14764 result.success = false;
14765 return result;
14766 }
14767 results.forEach((value) => {
14768 if (value.grouping === 'list') {
14769 return;
14770 }
14771 const cipher = this.initLoginCipher();
14772 cipher.favorite = value.fav === '1';
14773 cipher.name = this.getValueOrDefault(value.name);
14774 cipher.notes = this.getValueOrDefault(value.extra);
14775 if (value.grouping !== 'note') {
14776 cipher.login.uris = this.makeUriArray(value.url);
14777 cipher.login.password = this.getValueOrDefault(value.password);
14778 cipher.login.username = this.getValueOrDefault(value.username);
14779 }
14780 this.convertToNoteIfNeeded(cipher);
14781 this.cleanupCipher(cipher);
14782 result.ciphers.push(cipher);
14783 });
14784 result.success = true;
14785 return result;
14786 }
14787}
14788
14789// CONCATENATED MODULE: ./jslib/src/importers/blurCsvImporter.ts
14790
14791
14792class blurCsvImporter_BlurCsvImporter extends baseImporter_BaseImporter {
14793 parse(data) {
14794 const result = new ImportResult();
14795 const results = this.parseCsv(data, true);
14796 if (results == null) {
14797 result.success = false;
14798 return result;
14799 }
14800 results.forEach((value) => {
14801 if (value.label === 'null') {
14802 value.label = null;
14803 }
14804 const cipher = this.initLoginCipher();
14805 cipher.name = this.getValueOrDefault(value.label, this.getValueOrDefault(this.nameFromUrl(value.domain), '--'));
14806 cipher.login.uris = this.makeUriArray(value.domain);
14807 cipher.login.password = this.getValueOrDefault(value.password);
14808 if (this.isNullOrWhitespace(value.email) && !this.isNullOrWhitespace(value.username)) {
14809 cipher.login.username = value.username;
14810 }
14811 else {
14812 cipher.login.username = this.getValueOrDefault(value.email);
14813 cipher.notes = this.getValueOrDefault(value.username);
14814 }
14815 this.cleanupCipher(cipher);
14816 result.ciphers.push(cipher);
14817 });
14818 result.success = true;
14819 return result;
14820 }
14821}
14822
14823// CONCATENATED MODULE: ./jslib/src/importers/buttercupCsvImporter.ts
14824
14825
14826const OfficialProps = [
14827 '!group_id', '!group_name', 'title', 'username', 'password', 'URL', 'id',
14828];
14829class buttercupCsvImporter_ButtercupCsvImporter extends baseImporter_BaseImporter {
14830 parse(data) {
14831 const result = new ImportResult();
14832 const results = this.parseCsv(data, true);
14833 if (results == null) {
14834 result.success = false;
14835 return result;
14836 }
14837 results.forEach((value) => {
14838 this.processFolder(result, this.getValueOrDefault(value['!group_name']));
14839 const cipher = this.initLoginCipher();
14840 cipher.name = this.getValueOrDefault(value.title, '--');
14841 cipher.login.username = this.getValueOrDefault(value.username);
14842 cipher.login.password = this.getValueOrDefault(value.password);
14843 cipher.login.uris = this.makeUriArray(value.URL);
14844 let processingCustomFields = false;
14845 for (const prop in value) {
14846 if (value.hasOwnProperty(prop)) {
14847 if (!processingCustomFields && OfficialProps.indexOf(prop) === -1) {
14848 processingCustomFields = true;
14849 }
14850 if (processingCustomFields) {
14851 this.processKvp(cipher, prop, value[prop]);
14852 }
14853 }
14854 }
14855 this.cleanupCipher(cipher);
14856 result.ciphers.push(cipher);
14857 });
14858 if (this.organization) {
14859 this.moveFoldersToCollections(result);
14860 }
14861 result.success = true;
14862 return result;
14863 }
14864}
14865
14866// CONCATENATED MODULE: ./jslib/src/importers/chromeCsvImporter.ts
14867
14868
14869class chromeCsvImporter_ChromeCsvImporter extends baseImporter_BaseImporter {
14870 parse(data) {
14871 const result = new ImportResult();
14872 const results = this.parseCsv(data, true);
14873 if (results == null) {
14874 result.success = false;
14875 return result;
14876 }
14877 results.forEach((value) => {
14878 const cipher = this.initLoginCipher();
14879 cipher.name = this.getValueOrDefault(value.name, '--');
14880 cipher.login.username = this.getValueOrDefault(value.username);
14881 cipher.login.password = this.getValueOrDefault(value.password);
14882 cipher.login.uris = this.makeUriArray(value.url);
14883 this.cleanupCipher(cipher);
14884 result.ciphers.push(cipher);
14885 });
14886 result.success = true;
14887 return result;
14888 }
14889}
14890
14891// CONCATENATED MODULE: ./jslib/src/importers/clipperzHtmlImporter.ts
14892
14893
14894class clipperzHtmlImporter_ClipperzHtmlImporter extends baseImporter_BaseImporter {
14895 parse(data) {
14896 const result = new ImportResult();
14897 const doc = this.parseXml(data);
14898 if (doc == null) {
14899 result.success = false;
14900 return result;
14901 }
14902 const textarea = doc.querySelector('textarea');
14903 if (textarea == null || this.isNullOrWhitespace(textarea.textContent)) {
14904 result.errorMessage = 'Missing textarea.';
14905 result.success = false;
14906 return result;
14907 }
14908 const entries = JSON.parse(textarea.textContent);
14909 entries.forEach((entry) => {
14910 const cipher = this.initLoginCipher();
14911 if (!this.isNullOrWhitespace(entry.label)) {
14912 cipher.name = entry.label.split(' ')[0];
14913 }
14914 if (entry.data != null && !this.isNullOrWhitespace(entry.data.notes)) {
14915 cipher.notes = entry.data.notes.split('\\n').join('\n');
14916 }
14917 if (entry.currentVersion != null && entry.currentVersion.fields != null) {
14918 for (const property in entry.currentVersion.fields) {
14919 if (!entry.currentVersion.fields.hasOwnProperty(property)) {
14920 continue;
14921 }
14922 const field = entry.currentVersion.fields[property];
14923 const actionType = field.actionType != null ? field.actionType.toLowerCase() : null;
14924 switch (actionType) {
14925 case 'password':
14926 cipher.login.password = this.getValueOrDefault(field.value);
14927 break;
14928 case 'email':
14929 case 'username':
14930 case 'user':
14931 case 'name':
14932 cipher.login.username = this.getValueOrDefault(field.value);
14933 break;
14934 case 'url':
14935 cipher.login.uris = this.makeUriArray(field.value);
14936 break;
14937 default:
14938 const labelLower = field.label != null ? field.label.toLowerCase() : null;
14939 if (cipher.login.password == null && this.passwordFieldNames.indexOf(labelLower) > -1) {
14940 cipher.login.password = this.getValueOrDefault(field.value);
14941 }
14942 else if (cipher.login.username == null &&
14943 this.usernameFieldNames.indexOf(labelLower) > -1) {
14944 cipher.login.username = this.getValueOrDefault(field.value);
14945 }
14946 else if ((cipher.login.uris == null || cipher.login.uris.length === 0) &&
14947 this.uriFieldNames.indexOf(labelLower) > -1) {
14948 cipher.login.uris = this.makeUriArray(field.value);
14949 }
14950 else {
14951 this.processKvp(cipher, field.label, field.value);
14952 }
14953 break;
14954 }
14955 }
14956 }
14957 this.convertToNoteIfNeeded(cipher);
14958 this.cleanupCipher(cipher);
14959 result.ciphers.push(cipher);
14960 });
14961 result.success = true;
14962 return result;
14963 }
14964}
14965
14966// CONCATENATED MODULE: ./jslib/src/importers/codebookCsvImporter.ts
14967
14968
14969class codebookCsvImporter_CodebookCsvImporter extends baseImporter_BaseImporter {
14970 parse(data) {
14971 const result = new ImportResult();
14972 const results = this.parseCsv(data, true);
14973 if (results == null) {
14974 result.success = false;
14975 return result;
14976 }
14977 results.forEach((value) => {
14978 this.processFolder(result, this.getValueOrDefault(value.Category));
14979 const cipher = this.initLoginCipher();
14980 cipher.favorite = this.getValueOrDefault(value.Favorite) === 'True';
14981 cipher.name = this.getValueOrDefault(value.Entry, '--');
14982 cipher.notes = this.getValueOrDefault(value.Note);
14983 cipher.login.username = this.getValueOrDefault(value.Username, value.Email);
14984 cipher.login.password = this.getValueOrDefault(value.Password);
14985 cipher.login.totp = this.getValueOrDefault(value.TOTP);
14986 cipher.login.uris = this.makeUriArray(value.Website);
14987 if (!this.isNullOrWhitespace(value.Username)) {
14988 this.processKvp(cipher, 'Email', value.Email);
14989 }
14990 this.processKvp(cipher, 'Phone', value.Phone);
14991 this.processKvp(cipher, 'PIN', value.PIN);
14992 this.processKvp(cipher, 'Account', value.Account);
14993 this.processKvp(cipher, 'Date', value.Date);
14994 this.convertToNoteIfNeeded(cipher);
14995 this.cleanupCipher(cipher);
14996 result.ciphers.push(cipher);
14997 });
14998 if (this.organization) {
14999 this.moveFoldersToCollections(result);
15000 }
15001 result.success = true;
15002 return result;
15003 }
15004}
15005
15006// CONCATENATED MODULE: ./jslib/src/importers/dashlaneJsonImporter.ts
15007
15008
15009
15010
15011
15012
15013
15014
15015const HandledResults = new Set(['ADDRESS', 'AUTHENTIFIANT', 'BANKSTATEMENT', 'IDCARD', 'IDENTITY',
15016 'PAYMENTMEANS_CREDITCARD', 'PAYMENTMEAN_PAYPAL', 'EMAIL']);
15017class dashlaneJsonImporter_DashlaneJsonImporter extends baseImporter_BaseImporter {
15018 parse(data) {
15019 this.result = new ImportResult();
15020 const results = JSON.parse(data);
15021 if (results == null || results.length === 0) {
15022 this.result.success = false;
15023 return this.result;
15024 }
15025 if (results.ADDRESS != null) {
15026 this.processAddress(results.ADDRESS);
15027 }
15028 if (results.AUTHENTIFIANT != null) {
15029 this.processAuth(results.AUTHENTIFIANT);
15030 }
15031 if (results.BANKSTATEMENT != null) {
15032 this.processNote(results.BANKSTATEMENT, 'BankAccountName');
15033 }
15034 if (results.IDCARD != null) {
15035 this.processNote(results.IDCARD, 'Fullname');
15036 }
15037 if (results.PAYMENTMEANS_CREDITCARD != null) {
15038 this.processCard(results.PAYMENTMEANS_CREDITCARD);
15039 }
15040 if (results.IDENTITY != null) {
15041 this.processIdentity(results.IDENTITY);
15042 }
15043 for (const key in results) {
15044 if (results.hasOwnProperty(key) && !HandledResults.has(key)) {
15045 this.processNote(results[key], null, 'Generic Note');
15046 }
15047 }
15048 this.result.success = true;
15049 return this.result;
15050 }
15051 processAuth(results) {
15052 results.forEach((credential) => {
15053 const cipher = this.initLoginCipher();
15054 cipher.name = this.getValueOrDefault(credential.title);
15055 cipher.login.username = this.getValueOrDefault(credential.login, this.getValueOrDefault(credential.secondaryLogin));
15056 if (this.isNullOrWhitespace(cipher.login.username)) {
15057 cipher.login.username = this.getValueOrDefault(credential.email);
15058 }
15059 else if (!this.isNullOrWhitespace(credential.email)) {
15060 cipher.notes = ('Email: ' + credential.email + '\n');
15061 }
15062 cipher.login.password = this.getValueOrDefault(credential.password);
15063 cipher.login.uris = this.makeUriArray(credential.domain);
15064 cipher.notes += this.getValueOrDefault(credential.note, '');
15065 this.convertToNoteIfNeeded(cipher);
15066 this.cleanupCipher(cipher);
15067 this.result.ciphers.push(cipher);
15068 });
15069 }
15070 processIdentity(results) {
15071 results.forEach((obj) => {
15072 const cipher = new cipherView_CipherView();
15073 cipher.identity = new identityView_IdentityView();
15074 cipher.type = CipherType.Identity;
15075 cipher.name = this.getValueOrDefault(obj.fullName, '');
15076 const nameParts = cipher.name.split(' ');
15077 if (nameParts.length > 0) {
15078 cipher.identity.firstName = this.getValueOrDefault(nameParts[0]);
15079 }
15080 if (nameParts.length === 2) {
15081 cipher.identity.lastName = this.getValueOrDefault(nameParts[1]);
15082 }
15083 else if (nameParts.length === 3) {
15084 cipher.identity.middleName = this.getValueOrDefault(nameParts[1]);
15085 cipher.identity.lastName = this.getValueOrDefault(nameParts[2]);
15086 }
15087 cipher.identity.username = this.getValueOrDefault(obj.pseudo);
15088 this.cleanupCipher(cipher);
15089 this.result.ciphers.push(cipher);
15090 });
15091 }
15092 processAddress(results) {
15093 results.forEach((obj) => {
15094 const cipher = new cipherView_CipherView();
15095 cipher.identity = new identityView_IdentityView();
15096 cipher.type = CipherType.Identity;
15097 cipher.name = this.getValueOrDefault(obj.addressName);
15098 cipher.identity.address1 = this.getValueOrDefault(obj.addressFull);
15099 cipher.identity.city = this.getValueOrDefault(obj.city);
15100 cipher.identity.state = this.getValueOrDefault(obj.state);
15101 cipher.identity.postalCode = this.getValueOrDefault(obj.zipcode);
15102 cipher.identity.country = this.getValueOrDefault(obj.country);
15103 if (cipher.identity.country != null) {
15104 cipher.identity.country = cipher.identity.country.toUpperCase();
15105 }
15106 this.cleanupCipher(cipher);
15107 this.result.ciphers.push(cipher);
15108 });
15109 }
15110 processCard(results) {
15111 results.forEach((obj) => {
15112 const cipher = new cipherView_CipherView();
15113 cipher.card = new CardView();
15114 cipher.type = CipherType.Card;
15115 cipher.name = this.getValueOrDefault(obj.bank);
15116 cipher.card.number = this.getValueOrDefault(obj.cardNumber);
15117 cipher.card.brand = this.getCardBrand(cipher.card.number);
15118 cipher.card.cardholderName = this.getValueOrDefault(obj.owner);
15119 if (!this.isNullOrWhitespace(cipher.card.brand)) {
15120 if (this.isNullOrWhitespace(cipher.name)) {
15121 cipher.name = cipher.card.brand;
15122 }
15123 else {
15124 cipher.name += (' - ' + cipher.card.brand);
15125 }
15126 }
15127 this.cleanupCipher(cipher);
15128 this.result.ciphers.push(cipher);
15129 });
15130 }
15131 processNote(results, nameProperty, name = null) {
15132 results.forEach((obj) => {
15133 const cipher = new cipherView_CipherView();
15134 cipher.secureNote = new SecureNoteView();
15135 cipher.type = CipherType.SecureNote;
15136 cipher.secureNote.type = SecureNoteType.Generic;
15137 if (name != null) {
15138 cipher.name = name;
15139 }
15140 else {
15141 cipher.name = this.getValueOrDefault(obj[nameProperty]);
15142 }
15143 for (const key in obj) {
15144 if (obj.hasOwnProperty(key) && key !== nameProperty) {
15145 this.processKvp(cipher, key, obj[key].toString());
15146 }
15147 }
15148 this.cleanupCipher(cipher);
15149 this.result.ciphers.push(cipher);
15150 });
15151 }
15152}
15153
15154// CONCATENATED MODULE: ./jslib/src/importers/encryptrCsvImporter.ts
15155
15156
15157
15158
15159class encryptrCsvImporter_EncryptrCsvImporter extends baseImporter_BaseImporter {
15160 parse(data) {
15161 const result = new ImportResult();
15162 const results = this.parseCsv(data, true);
15163 if (results == null) {
15164 result.success = false;
15165 return result;
15166 }
15167 results.forEach((value) => {
15168 const cipher = this.initLoginCipher();
15169 cipher.name = this.getValueOrDefault(value.Label, '--');
15170 cipher.notes = this.getValueOrDefault(value.Notes);
15171 const text = this.getValueOrDefault(value.Text);
15172 if (!this.isNullOrWhitespace(text)) {
15173 if (this.isNullOrWhitespace(cipher.notes)) {
15174 cipher.notes = text;
15175 }
15176 else {
15177 cipher.notes += ('\n\n' + text);
15178 }
15179 }
15180 const type = value['Entry Type'];
15181 if (type === 'Password') {
15182 cipher.login.username = this.getValueOrDefault(value.Username);
15183 cipher.login.password = this.getValueOrDefault(value.Password);
15184 cipher.login.uris = this.makeUriArray(value['Site URL']);
15185 }
15186 else if (type === 'Credit Card') {
15187 cipher.type = CipherType.Card;
15188 cipher.card = new CardView();
15189 cipher.card.cardholderName = this.getValueOrDefault(value['Name on card']);
15190 cipher.card.number = this.getValueOrDefault(value['Card Number']);
15191 cipher.card.brand = this.getCardBrand(cipher.card.number);
15192 cipher.card.code = this.getValueOrDefault(value.CVV);
15193 const expiry = this.getValueOrDefault(value.Expiry);
15194 if (!this.isNullOrWhitespace(expiry)) {
15195 const expParts = expiry.split('/');
15196 if (expParts.length > 1) {
15197 cipher.card.expMonth = parseInt(expParts[0], null).toString();
15198 cipher.card.expYear = (2000 + parseInt(expParts[1], null)).toString();
15199 }
15200 }
15201 }
15202 this.convertToNoteIfNeeded(cipher);
15203 this.cleanupCipher(cipher);
15204 result.ciphers.push(cipher);
15205 });
15206 result.success = true;
15207 return result;
15208 }
15209}
15210
15211// CONCATENATED MODULE: ./jslib/src/importers/enpassCsvImporter.ts
15212
15213
15214
15215
15216
15217
15218class enpassCsvImporter_EnpassCsvImporter extends baseImporter_BaseImporter {
15219 parse(data) {
15220 const result = new ImportResult();
15221 const results = this.parseCsv(data, false);
15222 if (results == null) {
15223 result.success = false;
15224 return result;
15225 }
15226 let firstRow = true;
15227 results.forEach((value) => {
15228 if (value.length < 2 || (firstRow && (value[0] === 'Title' || value[0] === 'title'))) {
15229 firstRow = false;
15230 return;
15231 }
15232 const cipher = this.initLoginCipher();
15233 cipher.notes = this.getValueOrDefault(value[value.length - 1]);
15234 cipher.name = this.getValueOrDefault(value[0], '--');
15235 if (value.length === 2 || (!this.containsField(value, 'username') &&
15236 !this.containsField(value, 'password') && !this.containsField(value, 'email') &&
15237 !this.containsField(value, 'url'))) {
15238 cipher.type = CipherType.SecureNote;
15239 cipher.secureNote = new SecureNoteView();
15240 cipher.secureNote.type = SecureNoteType.Generic;
15241 }
15242 if (this.containsField(value, 'cardholder') && this.containsField(value, 'number') &&
15243 this.containsField(value, 'expiry date')) {
15244 cipher.type = CipherType.Card;
15245 cipher.card = new CardView();
15246 }
15247 if (value.length > 2 && (value.length % 2) === 0) {
15248 for (let i = 0; i < value.length - 2; i += 2) {
15249 const fieldValue = value[i + 2];
15250 if (this.isNullOrWhitespace(fieldValue)) {
15251 continue;
15252 }
15253 const fieldName = value[i + 1];
15254 const fieldNameLower = fieldName.toLowerCase();
15255 if (cipher.type === CipherType.Login) {
15256 if (fieldNameLower === 'url' && (cipher.login.uris == null || cipher.login.uris.length === 0)) {
15257 cipher.login.uris = this.makeUriArray(fieldValue);
15258 continue;
15259 }
15260 else if ((fieldNameLower === 'username' || fieldNameLower === 'email') &&
15261 this.isNullOrWhitespace(cipher.login.username)) {
15262 cipher.login.username = fieldValue;
15263 continue;
15264 }
15265 else if (fieldNameLower === 'password' && this.isNullOrWhitespace(cipher.login.password)) {
15266 cipher.login.password = fieldValue;
15267 continue;
15268 }
15269 else if (fieldNameLower === 'totp' && this.isNullOrWhitespace(cipher.login.totp)) {
15270 cipher.login.totp = fieldValue;
15271 continue;
15272 }
15273 }
15274 else if (cipher.type === CipherType.Card) {
15275 if (fieldNameLower === 'cardholder' && this.isNullOrWhitespace(cipher.card.cardholderName)) {
15276 cipher.card.cardholderName = fieldValue;
15277 continue;
15278 }
15279 else if (fieldNameLower === 'number' && this.isNullOrWhitespace(cipher.card.number)) {
15280 cipher.card.number = fieldValue;
15281 cipher.card.brand = this.getCardBrand(fieldValue);
15282 continue;
15283 }
15284 else if (fieldNameLower === 'cvc' && this.isNullOrWhitespace(cipher.card.code)) {
15285 cipher.card.code = fieldValue;
15286 continue;
15287 }
15288 else if (fieldNameLower === 'expiry date' && this.isNullOrWhitespace(cipher.card.expMonth) &&
15289 this.isNullOrWhitespace(cipher.card.expYear)) {
15290 if (this.setCardExpiration(cipher, fieldValue)) {
15291 continue;
15292 }
15293 }
15294 else if (fieldNameLower === 'type') {
15295 // Skip since brand was determined from number above
15296 continue;
15297 }
15298 }
15299 this.processKvp(cipher, fieldName, fieldValue);
15300 }
15301 }
15302 this.cleanupCipher(cipher);
15303 result.ciphers.push(cipher);
15304 });
15305 result.success = true;
15306 return result;
15307 }
15308 containsField(fields, name) {
15309 if (fields == null || name == null) {
15310 return false;
15311 }
15312 return fields.filter((f) => !this.isNullOrWhitespace(f) &&
15313 f.toLowerCase() === name.toLowerCase()).length > 0;
15314 }
15315}
15316
15317// CONCATENATED MODULE: ./jslib/src/importers/enpassJsonImporter.ts
15318
15319
15320
15321
15322
15323
15324class enpassJsonImporter_EnpassJsonImporter extends baseImporter_BaseImporter {
15325 parse(data) {
15326 const result = new ImportResult();
15327 const results = JSON.parse(data);
15328 if (results == null || results.items == null || results.items.length === 0) {
15329 result.success = false;
15330 return result;
15331 }
15332 const foldersMap = new Map();
15333 const foldersIndexMap = new Map();
15334 const folderTree = this.buildFolderTree(results.folders);
15335 this.flattenFolderTree(null, folderTree, foldersMap);
15336 foldersMap.forEach((val, key) => {
15337 foldersIndexMap.set(key, result.folders.length);
15338 const f = new FolderView();
15339 f.name = val;
15340 result.folders.push(f);
15341 });
15342 results.items.forEach((item) => {
15343 if (item.folders != null && item.folders.length > 0 && foldersIndexMap.has(item.folders[0])) {
15344 result.folderRelationships.push([result.ciphers.length, foldersIndexMap.get(item.folders[0])]);
15345 }
15346 const cipher = this.initLoginCipher();
15347 cipher.name = this.getValueOrDefault(item.title);
15348 cipher.favorite = item.favorite > 0;
15349 if (item.template_type != null && item.fields != null && item.fields.length > 0) {
15350 if (item.template_type.indexOf('login.') === 0 || item.template_type.indexOf('password.') === 0) {
15351 this.processLogin(cipher, item.fields);
15352 }
15353 else if (item.template_type.indexOf('creditcard.') === 0) {
15354 this.processCard(cipher, item.fields);
15355 }
15356 else if (item.template_type.indexOf('identity.') < 0 &&
15357 item.fields.some((f) => f.type === 'password' && !this.isNullOrWhitespace(f.value))) {
15358 this.processLogin(cipher, item.fields);
15359 }
15360 else {
15361 this.processNote(cipher, item.fields);
15362 }
15363 }
15364 cipher.notes += ('\n' + this.getValueOrDefault(item.note, ''));
15365 this.convertToNoteIfNeeded(cipher);
15366 this.cleanupCipher(cipher);
15367 result.ciphers.push(cipher);
15368 });
15369 result.success = true;
15370 return result;
15371 }
15372 processLogin(cipher, fields) {
15373 const urls = [];
15374 fields.forEach((field) => {
15375 if (this.isNullOrWhitespace(field.value) || field.type === 'section') {
15376 return;
15377 }
15378 if ((field.type === 'username' || field.type === 'email') &&
15379 this.isNullOrWhitespace(cipher.login.username)) {
15380 cipher.login.username = field.value;
15381 }
15382 else if (field.type === 'password' && this.isNullOrWhitespace(cipher.login.password)) {
15383 cipher.login.password = field.value;
15384 }
15385 else if (field.type === 'totp' && this.isNullOrWhitespace(cipher.login.totp)) {
15386 cipher.login.totp = field.value;
15387 }
15388 else if (field.type === 'url') {
15389 urls.push(field.value);
15390 }
15391 else {
15392 this.processKvp(cipher, field.label, field.value, field.sensitive === 1 ? FieldType.Hidden : FieldType.Text);
15393 }
15394 });
15395 cipher.login.uris = this.makeUriArray(urls);
15396 }
15397 processCard(cipher, fields) {
15398 cipher.card = new CardView();
15399 cipher.type = CipherType.Card;
15400 fields.forEach((field) => {
15401 if (this.isNullOrWhitespace(field.value) || field.type === 'section' || field.type === 'ccType') {
15402 return;
15403 }
15404 if (field.type === 'ccName' && this.isNullOrWhitespace(cipher.card.cardholderName)) {
15405 cipher.card.cardholderName = field.value;
15406 }
15407 else if (field.type === 'ccNumber' && this.isNullOrWhitespace(cipher.card.number)) {
15408 cipher.card.number = field.value;
15409 cipher.card.brand = this.getCardBrand(cipher.card.number);
15410 }
15411 else if (field.type === 'ccCvc' && this.isNullOrWhitespace(cipher.card.code)) {
15412 cipher.card.code = field.value;
15413 }
15414 else if (field.type === 'ccExpiry' && this.isNullOrWhitespace(cipher.card.expYear)) {
15415 if (!this.setCardExpiration(cipher, field.value)) {
15416 this.processKvp(cipher, field.label, field.value, field.sensitive === 1 ? FieldType.Hidden : FieldType.Text);
15417 }
15418 }
15419 else {
15420 this.processKvp(cipher, field.label, field.value, field.sensitive === 1 ? FieldType.Hidden : FieldType.Text);
15421 }
15422 });
15423 }
15424 processNote(cipher, fields) {
15425 fields.forEach((field) => {
15426 if (this.isNullOrWhitespace(field.value) || field.type === 'section') {
15427 return;
15428 }
15429 this.processKvp(cipher, field.label, field.value, field.sensitive === 1 ? FieldType.Hidden : FieldType.Text);
15430 });
15431 }
15432 buildFolderTree(folders) {
15433 if (folders == null) {
15434 return [];
15435 }
15436 const folderTree = [];
15437 const map = new Map([]);
15438 folders.forEach((obj) => {
15439 map.set(obj.uuid, obj);
15440 obj.children = [];
15441 });
15442 folders.forEach((obj) => {
15443 if (obj.parent_uuid != null && obj.parent_uuid !== '' && map.has(obj.parent_uuid)) {
15444 map.get(obj.parent_uuid).children.push(obj);
15445 }
15446 else {
15447 folderTree.push(obj);
15448 }
15449 });
15450 return folderTree;
15451 }
15452 flattenFolderTree(titlePrefix, tree, map) {
15453 if (tree == null) {
15454 return;
15455 }
15456 tree.forEach((f) => {
15457 if (f.title != null && f.title.trim() !== '') {
15458 let title = f.title.trim();
15459 if (titlePrefix != null && titlePrefix.trim() !== '') {
15460 title = titlePrefix + '/' + title;
15461 }
15462 map.set(f.uuid, title);
15463 if (f.children != null && f.children.length !== 0) {
15464 this.flattenFolderTree(title, f.children, map);
15465 }
15466 }
15467 });
15468 }
15469}
15470
15471// CONCATENATED MODULE: ./jslib/src/importers/firefoxCsvImporter.ts
15472
15473
15474class firefoxCsvImporter_FirefoxCsvImporter extends baseImporter_BaseImporter {
15475 parse(data) {
15476 const result = new ImportResult();
15477 const results = this.parseCsv(data, true);
15478 if (results == null) {
15479 result.success = false;
15480 return result;
15481 }
15482 results.forEach((value) => {
15483 const cipher = this.initLoginCipher();
15484 cipher.name = this.getValueOrDefault(this.nameFromUrl(value.hostname), '--');
15485 cipher.login.username = this.getValueOrDefault(value.username);
15486 cipher.login.password = this.getValueOrDefault(value.password);
15487 cipher.login.uris = this.makeUriArray(value.hostname);
15488 this.cleanupCipher(cipher);
15489 result.ciphers.push(cipher);
15490 });
15491 result.success = true;
15492 return result;
15493 }
15494}
15495
15496// CONCATENATED MODULE: ./jslib/src/importers/fsecureFskImporter.ts
15497
15498
15499
15500
15501class fsecureFskImporter_FSecureFskImporter extends baseImporter_BaseImporter {
15502 parse(data) {
15503 const result = new ImportResult();
15504 const results = JSON.parse(data);
15505 if (results == null || results.data == null) {
15506 result.success = false;
15507 return result;
15508 }
15509 for (const key in results.data) {
15510 if (!results.data.hasOwnProperty(key)) {
15511 continue;
15512 }
15513 const value = results.data[key];
15514 const cipher = this.initLoginCipher();
15515 cipher.name = this.getValueOrDefault(value.service);
15516 cipher.notes = this.getValueOrDefault(value.notes);
15517 if (value.style === 'website') {
15518 cipher.login.username = this.getValueOrDefault(value.username);
15519 cipher.login.password = this.getValueOrDefault(value.password);
15520 cipher.login.uris = this.makeUriArray(value.url);
15521 }
15522 else if (value.style === 'creditcard') {
15523 cipher.type = CipherType.Card;
15524 cipher.card = new CardView();
15525 cipher.card.cardholderName = this.getValueOrDefault(value.username);
15526 cipher.card.number = this.getValueOrDefault(value.creditNumber);
15527 cipher.card.brand = this.getCardBrand(cipher.card.number);
15528 cipher.card.code = this.getValueOrDefault(value.creditCvv);
15529 if (!this.isNullOrWhitespace(value.creditExpiry)) {
15530 if (!this.setCardExpiration(cipher, value.creditExpiry)) {
15531 this.processKvp(cipher, 'Expiration', value.creditExpiry);
15532 }
15533 }
15534 if (!this.isNullOrWhitespace(value.password)) {
15535 this.processKvp(cipher, 'PIN', value.password);
15536 }
15537 }
15538 else {
15539 continue;
15540 }
15541 this.convertToNoteIfNeeded(cipher);
15542 this.cleanupCipher(cipher);
15543 result.ciphers.push(cipher);
15544 }
15545 result.success = true;
15546 return result;
15547 }
15548}
15549
15550// CONCATENATED MODULE: ./jslib/src/importers/gnomeJsonImporter.ts
15551
15552
15553class gnomeJsonImporter_GnomeJsonImporter extends baseImporter_BaseImporter {
15554 parse(data) {
15555 const result = new ImportResult();
15556 const results = JSON.parse(data);
15557 if (results == null || Object.keys(results).length === 0) {
15558 result.success = false;
15559 return result;
15560 }
15561 for (const keyRing in results) {
15562 if (!results.hasOwnProperty(keyRing) || this.isNullOrWhitespace(keyRing) ||
15563 results[keyRing].length === 0) {
15564 continue;
15565 }
15566 results[keyRing].forEach((value) => {
15567 if (this.isNullOrWhitespace(value.display_name) || value.display_name.indexOf('http') !== 0) {
15568 return;
15569 }
15570 this.processFolder(result, keyRing);
15571 const cipher = this.initLoginCipher();
15572 cipher.name = value.display_name.replace('http://', '').replace('https://', '');
15573 if (cipher.name.length > 30) {
15574 cipher.name = cipher.name.substring(0, 30);
15575 }
15576 cipher.login.password = this.getValueOrDefault(value.secret);
15577 cipher.login.uris = this.makeUriArray(value.display_name);
15578 if (value.attributes != null) {
15579 cipher.login.username = value.attributes != null ?
15580 this.getValueOrDefault(value.attributes.username_value) : null;
15581 for (const attr in value.attributes) {
15582 if (!value.attributes.hasOwnProperty(attr) || attr === 'username_value' ||
15583 attr === 'xdg:schema') {
15584 continue;
15585 }
15586 this.processKvp(cipher, attr, value.attributes[attr]);
15587 }
15588 }
15589 this.convertToNoteIfNeeded(cipher);
15590 this.cleanupCipher(cipher);
15591 result.ciphers.push(cipher);
15592 });
15593 }
15594 if (this.organization) {
15595 this.moveFoldersToCollections(result);
15596 }
15597 result.success = true;
15598 return result;
15599 }
15600}
15601
15602// CONCATENATED MODULE: ./jslib/src/importers/kasperskyTxtImporter.ts
15603
15604
15605const NotesHeader = 'Notes\n\n';
15606const ApplicationsHeader = 'Applications\n\n';
15607const WebsitesHeader = 'Websites\n\n';
15608const Delimiter = '\n---\n';
15609class kasperskyTxtImporter_KasperskyTxtImporter extends baseImporter_BaseImporter {
15610 parse(data) {
15611 const result = new ImportResult();
15612 let notesData;
15613 let applicationsData;
15614 let websitesData;
15615 let workingData = this.splitNewLine(data).join('\n');
15616 if (workingData.indexOf(NotesHeader) !== -1) {
15617 const parts = workingData.split(NotesHeader);
15618 if (parts.length > 1) {
15619 workingData = parts[0];
15620 notesData = parts[1];
15621 }
15622 }
15623 if (workingData.indexOf(ApplicationsHeader) !== -1) {
15624 const parts = workingData.split(ApplicationsHeader);
15625 if (parts.length > 1) {
15626 workingData = parts[0];
15627 applicationsData = parts[1];
15628 }
15629 }
15630 if (workingData.indexOf(WebsitesHeader) === 0) {
15631 const parts = workingData.split(WebsitesHeader);
15632 if (parts.length > 1) {
15633 workingData = parts[0];
15634 websitesData = parts[1];
15635 }
15636 }
15637 const notes = this.parseDataCategory(notesData);
15638 const applications = this.parseDataCategory(applicationsData);
15639 const websites = this.parseDataCategory(websitesData);
15640 notes.forEach((n) => {
15641 const cipher = this.initLoginCipher();
15642 cipher.name = this.getValueOrDefault(n.get('Name'));
15643 cipher.notes = this.getValueOrDefault(n.get('Text'));
15644 this.cleanupCipher(cipher);
15645 result.ciphers.push(cipher);
15646 });
15647 websites.concat(applications).forEach((w) => {
15648 const cipher = this.initLoginCipher();
15649 const nameKey = w.has('Website name') ? 'Website name' : 'Application';
15650 cipher.name = this.getValueOrDefault(w.get(nameKey), '');
15651 if (!this.isNullOrWhitespace(w.get('Login name'))) {
15652 if (!this.isNullOrWhitespace(cipher.name)) {
15653 cipher.name += ': ';
15654 }
15655 cipher.name += w.get('Login name');
15656 }
15657 cipher.notes = this.getValueOrDefault(w.get('Comment'));
15658 if (w.has('Website URL')) {
15659 cipher.login.uris = this.makeUriArray(w.get('Website URL'));
15660 }
15661 cipher.login.username = this.getValueOrDefault(w.get('Login'));
15662 cipher.login.password = this.getValueOrDefault(w.get('Password'));
15663 this.cleanupCipher(cipher);
15664 result.ciphers.push(cipher);
15665 });
15666 result.success = true;
15667 return result;
15668 }
15669 parseDataCategory(data) {
15670 if (this.isNullOrWhitespace(data) || data.indexOf(Delimiter) === -1) {
15671 return [];
15672 }
15673 const items = [];
15674 data.split(Delimiter).forEach((p) => {
15675 if (p.indexOf('\n') === -1) {
15676 return;
15677 }
15678 const item = new Map();
15679 let itemComment;
15680 let itemCommentKey;
15681 p.split('\n').forEach((l) => {
15682 if (itemComment != null) {
15683 itemComment += ('\n' + l);
15684 return;
15685 }
15686 const colonIndex = l.indexOf(':');
15687 let key;
15688 let val;
15689 if (colonIndex === -1) {
15690 return;
15691 }
15692 else {
15693 key = l.substring(0, colonIndex);
15694 if (l.length > colonIndex + 1) {
15695 val = l.substring(colonIndex + 2);
15696 }
15697 }
15698 if (key != null) {
15699 item.set(key, val);
15700 }
15701 if (key === 'Comment' || key === 'Text') {
15702 itemComment = val;
15703 itemCommentKey = key;
15704 }
15705 });
15706 if (itemComment != null && itemCommentKey != null) {
15707 item.set(itemCommentKey, itemComment);
15708 }
15709 if (item.size === 0) {
15710 return;
15711 }
15712 items.push(item);
15713 });
15714 return items;
15715 }
15716}
15717
15718// CONCATENATED MODULE: ./jslib/src/importers/keepass2XmlImporter.ts
15719
15720
15721
15722
15723class keepass2XmlImporter_KeePass2XmlImporter extends baseImporter_BaseImporter {
15724 constructor() {
15725 super(...arguments);
15726 this.result = new ImportResult();
15727 }
15728 parse(data) {
15729 const doc = this.parseXml(data);
15730 if (doc == null) {
15731 this.result.success = false;
15732 return this.result;
15733 }
15734 const rootGroup = doc.querySelector('KeePassFile > Root > Group');
15735 if (rootGroup == null) {
15736 this.result.errorMessage = 'Missing `KeePassFile > Root > Group` node.';
15737 this.result.success = false;
15738 return this.result;
15739 }
15740 this.traverse(rootGroup, true, '');
15741 if (this.organization) {
15742 this.moveFoldersToCollections(this.result);
15743 }
15744 this.result.success = true;
15745 return this.result;
15746 }
15747 traverse(node, isRootNode, groupPrefixName) {
15748 const folderIndex = this.result.folders.length;
15749 let groupName = groupPrefixName;
15750 if (!isRootNode) {
15751 if (groupName !== '') {
15752 groupName += '/';
15753 }
15754 const nameEl = this.querySelectorDirectChild(node, 'Name');
15755 groupName += nameEl == null ? '-' : nameEl.textContent;
15756 const folder = new FolderView();
15757 folder.name = groupName;
15758 this.result.folders.push(folder);
15759 }
15760 this.querySelectorAllDirectChild(node, 'Entry').forEach((entry) => {
15761 const cipherIndex = this.result.ciphers.length;
15762 const cipher = this.initLoginCipher();
15763 this.querySelectorAllDirectChild(entry, 'String').forEach((entryString) => {
15764 const valueEl = this.querySelectorDirectChild(entryString, 'Value');
15765 const value = valueEl != null ? valueEl.textContent : null;
15766 if (this.isNullOrWhitespace(value)) {
15767 return;
15768 }
15769 const keyEl = this.querySelectorDirectChild(entryString, 'Key');
15770 const key = keyEl != null ? keyEl.textContent : null;
15771 if (key === 'URL') {
15772 cipher.login.uris = this.makeUriArray(value);
15773 }
15774 else if (key === 'UserName') {
15775 cipher.login.username = value;
15776 }
15777 else if (key === 'Password') {
15778 cipher.login.password = value;
15779 }
15780 else if (key === 'Title') {
15781 cipher.name = value;
15782 }
15783 else if (key === 'Notes') {
15784 cipher.notes += (value + '\n');
15785 }
15786 else {
15787 let type = FieldType.Text;
15788 const attrs = valueEl.attributes;
15789 if (attrs.length > 0 && attrs.ProtectInMemory != null &&
15790 attrs.ProtectInMemory.value === 'True') {
15791 type = FieldType.Hidden;
15792 }
15793 this.processKvp(cipher, key, value, type);
15794 }
15795 });
15796 this.cleanupCipher(cipher);
15797 this.result.ciphers.push(cipher);
15798 if (!isRootNode) {
15799 this.result.folderRelationships.push([cipherIndex, folderIndex]);
15800 }
15801 });
15802 this.querySelectorAllDirectChild(node, 'Group').forEach((group) => {
15803 this.traverse(group, false, groupName);
15804 });
15805 }
15806}
15807
15808// CONCATENATED MODULE: ./jslib/src/importers/keepassxCsvImporter.ts
15809
15810
15811class keepassxCsvImporter_KeePassXCsvImporter extends baseImporter_BaseImporter {
15812 parse(data) {
15813 const result = new ImportResult();
15814 const results = this.parseCsv(data, true);
15815 if (results == null) {
15816 result.success = false;
15817 return result;
15818 }
15819 results.forEach((value) => {
15820 if (this.isNullOrWhitespace(value.Title)) {
15821 return;
15822 }
15823 value.Group = !this.isNullOrWhitespace(value.Group) && value.Group.startsWith('Root/') ?
15824 value.Group.replace('Root/', '') : value.Group;
15825 const groupName = !this.isNullOrWhitespace(value.Group) ? value.Group : null;
15826 this.processFolder(result, groupName);
15827 const cipher = this.initLoginCipher();
15828 cipher.notes = this.getValueOrDefault(value.Notes);
15829 cipher.name = this.getValueOrDefault(value.Title, '--');
15830 cipher.login.username = this.getValueOrDefault(value.Username);
15831 cipher.login.password = this.getValueOrDefault(value.Password);
15832 cipher.login.uris = this.makeUriArray(value.URL);
15833 this.cleanupCipher(cipher);
15834 result.ciphers.push(cipher);
15835 });
15836 if (this.organization) {
15837 this.moveFoldersToCollections(result);
15838 }
15839 result.success = true;
15840 return result;
15841 }
15842}
15843
15844// CONCATENATED MODULE: ./jslib/src/importers/keeperCsvImporter.ts
15845
15846
15847class keeperCsvImporter_KeeperCsvImporter extends baseImporter_BaseImporter {
15848 parse(data) {
15849 const result = new ImportResult();
15850 const results = this.parseCsv(data, false);
15851 if (results == null) {
15852 result.success = false;
15853 return result;
15854 }
15855 results.forEach((value) => {
15856 if (value.length < 6) {
15857 return;
15858 }
15859 this.processFolder(result, value[0]);
15860 const cipher = this.initLoginCipher();
15861 cipher.notes = this.getValueOrDefault(value[5]) + '\n';
15862 cipher.name = this.getValueOrDefault(value[1], '--');
15863 cipher.login.username = this.getValueOrDefault(value[2]);
15864 cipher.login.password = this.getValueOrDefault(value[3]);
15865 cipher.login.uris = this.makeUriArray(value[4]);
15866 if (value.length > 7) {
15867 // we have some custom fields.
15868 for (let i = 7; i < value.length; i = i + 2) {
15869 this.processKvp(cipher, value[i], value[i + 1]);
15870 }
15871 }
15872 this.cleanupCipher(cipher);
15873 result.ciphers.push(cipher);
15874 });
15875 if (this.organization) {
15876 this.moveFoldersToCollections(result);
15877 }
15878 result.success = true;
15879 return result;
15880 }
15881}
15882
15883// CONCATENATED MODULE: ./jslib/src/importers/lastpassCsvImporter.ts
15884
15885
15886
15887
15888
15889
15890
15891
15892
15893
15894class lastpassCsvImporter_LastPassCsvImporter extends baseImporter_BaseImporter {
15895 parse(data) {
15896 const result = new ImportResult();
15897 const results = this.parseCsv(data, true);
15898 if (results == null) {
15899 result.success = false;
15900 return result;
15901 }
15902 results.forEach((value, index) => {
15903 const cipherIndex = result.ciphers.length;
15904 let folderIndex = result.folders.length;
15905 let grouping = value.grouping;
15906 if (grouping != null) {
15907 grouping = grouping.replace(/\\/g, '/').replace(/[\x00-\x1F\x7F-\x9F]/g, '');
15908 }
15909 const hasFolder = this.getValueOrDefault(grouping, '(none)') !== '(none)';
15910 let addFolder = hasFolder;
15911 if (hasFolder) {
15912 for (let i = 0; i < result.folders.length; i++) {
15913 if (result.folders[i].name === grouping) {
15914 addFolder = false;
15915 folderIndex = i;
15916 break;
15917 }
15918 }
15919 }
15920 const cipher = this.buildBaseCipher(value);
15921 if (cipher.type === CipherType.Login) {
15922 cipher.notes = this.getValueOrDefault(value.extra);
15923 cipher.login = new LoginView();
15924 cipher.login.uris = this.makeUriArray(value.url);
15925 cipher.login.username = this.getValueOrDefault(value.username);
15926 cipher.login.password = this.getValueOrDefault(value.password);
15927 }
15928 else if (cipher.type === CipherType.SecureNote) {
15929 this.parseSecureNote(value, cipher);
15930 }
15931 else if (cipher.type === CipherType.Card) {
15932 cipher.card = this.parseCard(value);
15933 cipher.notes = this.getValueOrDefault(value.notes);
15934 }
15935 else if (cipher.type === CipherType.Identity) {
15936 cipher.identity = this.parseIdentity(value);
15937 cipher.notes = this.getValueOrDefault(value.notes);
15938 if (!this.isNullOrWhitespace(value.ccnum)) {
15939 // there is a card on this identity too
15940 const cardCipher = this.buildBaseCipher(value);
15941 cardCipher.identity = null;
15942 cardCipher.type = CipherType.Card;
15943 cardCipher.card = this.parseCard(value);
15944 result.ciphers.push(cardCipher);
15945 }
15946 }
15947 result.ciphers.push(cipher);
15948 if (addFolder) {
15949 const f = new FolderView();
15950 f.name = grouping;
15951 result.folders.push(f);
15952 }
15953 if (hasFolder) {
15954 result.folderRelationships.push([cipherIndex, folderIndex]);
15955 }
15956 });
15957 if (this.organization) {
15958 this.moveFoldersToCollections(result);
15959 }
15960 result.success = true;
15961 return result;
15962 }
15963 buildBaseCipher(value) {
15964 const cipher = new cipherView_CipherView();
15965 if (value.hasOwnProperty('profilename') && value.hasOwnProperty('profilelanguage')) {
15966 // form fill
15967 cipher.favorite = false;
15968 cipher.name = this.getValueOrDefault(value.profilename, '--');
15969 cipher.type = CipherType.Card;
15970 if (!this.isNullOrWhitespace(value.title) || !this.isNullOrWhitespace(value.firstname) ||
15971 !this.isNullOrWhitespace(value.lastname) || !this.isNullOrWhitespace(value.address1) ||
15972 !this.isNullOrWhitespace(value.phone) || !this.isNullOrWhitespace(value.username) ||
15973 !this.isNullOrWhitespace(value.email)) {
15974 cipher.type = CipherType.Identity;
15975 }
15976 }
15977 else {
15978 // site or secure note
15979 cipher.favorite = !this.organization && this.getValueOrDefault(value.fav, '0') === '1';
15980 cipher.name = this.getValueOrDefault(value.name, '--');
15981 cipher.type = value.url === 'http://sn' ? CipherType.SecureNote : CipherType.Login;
15982 }
15983 return cipher;
15984 }
15985 parseCard(value) {
15986 const card = new CardView();
15987 card.cardholderName = this.getValueOrDefault(value.ccname);
15988 card.number = this.getValueOrDefault(value.ccnum);
15989 card.code = this.getValueOrDefault(value.cccsc);
15990 card.brand = this.getCardBrand(value.ccnum);
15991 if (!this.isNullOrWhitespace(value.ccexp) && value.ccexp.indexOf('-') > -1) {
15992 const ccexpParts = value.ccexp.split('-');
15993 if (ccexpParts.length > 1) {
15994 card.expYear = ccexpParts[0];
15995 card.expMonth = ccexpParts[1];
15996 if (card.expMonth.length === 2 && card.expMonth[0] === '0') {
15997 card.expMonth = card.expMonth[1];
15998 }
15999 }
16000 }
16001 return card;
16002 }
16003 parseIdentity(value) {
16004 const identity = new identityView_IdentityView();
16005 identity.title = this.getValueOrDefault(value.title);
16006 identity.firstName = this.getValueOrDefault(value.firstname);
16007 identity.middleName = this.getValueOrDefault(value.middlename);
16008 identity.lastName = this.getValueOrDefault(value.lastname);
16009 identity.username = this.getValueOrDefault(value.username);
16010 identity.company = this.getValueOrDefault(value.company);
16011 identity.ssn = this.getValueOrDefault(value.ssn);
16012 identity.address1 = this.getValueOrDefault(value.address1);
16013 identity.address2 = this.getValueOrDefault(value.address2);
16014 identity.address3 = this.getValueOrDefault(value.address3);
16015 identity.city = this.getValueOrDefault(value.city);
16016 identity.state = this.getValueOrDefault(value.state);
16017 identity.postalCode = this.getValueOrDefault(value.zip);
16018 identity.country = this.getValueOrDefault(value.country);
16019 identity.email = this.getValueOrDefault(value.email);
16020 identity.phone = this.getValueOrDefault(value.phone);
16021 if (!this.isNullOrWhitespace(identity.title)) {
16022 identity.title = identity.title.charAt(0).toUpperCase() + identity.title.slice(1);
16023 }
16024 return identity;
16025 }
16026 parseSecureNote(value, cipher) {
16027 const extraParts = this.splitNewLine(value.extra);
16028 let processedNote = false;
16029 if (extraParts.length) {
16030 const typeParts = extraParts[0].split(':');
16031 if (typeParts.length > 1 && typeParts[0] === 'NoteType' &&
16032 (typeParts[1] === 'Credit Card' || typeParts[1] === 'Address')) {
16033 if (typeParts[1] === 'Credit Card') {
16034 const mappedData = this.parseSecureNoteMapping(cipher, extraParts, {
16035 'Number': 'number',
16036 'Name on Card': 'cardholderName',
16037 'Security Code': 'code',
16038 // LP provides date in a format like 'June,2020'
16039 // Store in expMonth, then parse and modify
16040 'Expiration Date': 'expMonth',
16041 });
16042 if (this.isNullOrWhitespace(mappedData.expMonth) || mappedData.expMonth === ',') {
16043 // No expiration data
16044 mappedData.expMonth = undefined;
16045 }
16046 else {
16047 const [monthString, year] = mappedData.expMonth.split(',');
16048 // Parse month name into number
16049 if (!this.isNullOrWhitespace(monthString)) {
16050 const month = new Date(Date.parse(monthString.trim() + ' 1, 2012')).getMonth() + 1;
16051 if (isNaN(month)) {
16052 mappedData.expMonth = undefined;
16053 }
16054 else {
16055 mappedData.expMonth = month.toString();
16056 }
16057 }
16058 else {
16059 mappedData.expMonth = undefined;
16060 }
16061 if (!this.isNullOrWhitespace(year)) {
16062 mappedData.expYear = year;
16063 }
16064 }
16065 cipher.type = CipherType.Card;
16066 cipher.card = mappedData;
16067 }
16068 else if (typeParts[1] === 'Address') {
16069 const mappedData = this.parseSecureNoteMapping(cipher, extraParts, {
16070 'Title': 'title',
16071 'First Name': 'firstName',
16072 'Last Name': 'lastName',
16073 'Middle Name': 'middleName',
16074 'Company': 'company',
16075 'Address 1': 'address1',
16076 'Address 2': 'address2',
16077 'Address 3': 'address3',
16078 'City / Town': 'city',
16079 'State': 'state',
16080 'Zip / Postal Code': 'postalCode',
16081 'Country': 'country',
16082 'Email Address': 'email',
16083 'Username': 'username',
16084 });
16085 cipher.type = CipherType.Identity;
16086 cipher.identity = mappedData;
16087 }
16088 processedNote = true;
16089 }
16090 }
16091 if (!processedNote) {
16092 cipher.secureNote = new SecureNoteView();
16093 cipher.secureNote.type = SecureNoteType.Generic;
16094 cipher.notes = this.getValueOrDefault(value.extra);
16095 }
16096 }
16097 parseSecureNoteMapping(cipher, extraParts, map) {
16098 const dataObj = {};
16099 let processingNotes = false;
16100 extraParts.forEach((extraPart) => {
16101 let key = null;
16102 let val = null;
16103 if (!processingNotes) {
16104 if (this.isNullOrWhitespace(extraPart)) {
16105 return;
16106 }
16107 const colonIndex = extraPart.indexOf(':');
16108 if (colonIndex === -1) {
16109 key = extraPart;
16110 }
16111 else {
16112 key = extraPart.substring(0, colonIndex);
16113 if (extraPart.length > colonIndex) {
16114 val = extraPart.substring(colonIndex + 1);
16115 }
16116 }
16117 if (this.isNullOrWhitespace(key) || this.isNullOrWhitespace(val) || key === 'NoteType') {
16118 return;
16119 }
16120 }
16121 if (processingNotes) {
16122 cipher.notes += ('\n' + extraPart);
16123 }
16124 else if (key === 'Notes') {
16125 if (!this.isNullOrWhitespace(cipher.notes)) {
16126 cipher.notes += ('\n' + val);
16127 }
16128 else {
16129 cipher.notes = val;
16130 }
16131 processingNotes = true;
16132 }
16133 else if (map.hasOwnProperty(key)) {
16134 dataObj[map[key]] = val;
16135 }
16136 else {
16137 this.processKvp(cipher, key, val);
16138 }
16139 });
16140 return dataObj;
16141 }
16142}
16143
16144// CONCATENATED MODULE: ./jslib/src/importers/logMeOnceCsvImporter.ts
16145
16146
16147class logMeOnceCsvImporter_LogMeOnceCsvImporter extends baseImporter_BaseImporter {
16148 parse(data) {
16149 const result = new ImportResult();
16150 const results = this.parseCsv(data, false);
16151 if (results == null) {
16152 result.success = false;
16153 return result;
16154 }
16155 results.forEach((value) => {
16156 if (value.length < 4) {
16157 return;
16158 }
16159 const cipher = this.initLoginCipher();
16160 cipher.name = this.getValueOrDefault(value[0], '--');
16161 cipher.login.username = this.getValueOrDefault(value[2]);
16162 cipher.login.password = this.getValueOrDefault(value[3]);
16163 cipher.login.uris = this.makeUriArray(value[1]);
16164 this.cleanupCipher(cipher);
16165 result.ciphers.push(cipher);
16166 });
16167 result.success = true;
16168 return result;
16169 }
16170}
16171
16172// CONCATENATED MODULE: ./jslib/src/importers/meldiumCsvImporter.ts
16173
16174
16175class meldiumCsvImporter_MeldiumCsvImporter extends baseImporter_BaseImporter {
16176 parse(data) {
16177 const result = new ImportResult();
16178 const results = this.parseCsv(data, true);
16179 if (results == null) {
16180 result.success = false;
16181 return result;
16182 }
16183 results.forEach((value) => {
16184 const cipher = this.initLoginCipher();
16185 cipher.name = this.getValueOrDefault(value.DisplayName, '--');
16186 cipher.notes = this.getValueOrDefault(value.Notes);
16187 cipher.login.username = this.getValueOrDefault(value.UserName);
16188 cipher.login.password = this.getValueOrDefault(value.Password);
16189 cipher.login.uris = this.makeUriArray(value.Url);
16190 this.cleanupCipher(cipher);
16191 result.ciphers.push(cipher);
16192 });
16193 result.success = true;
16194 return result;
16195 }
16196}
16197
16198// CONCATENATED MODULE: ./jslib/src/importers/msecureCsvImporter.ts
16199
16200
16201
16202
16203
16204class msecureCsvImporter_MSecureCsvImporter extends baseImporter_BaseImporter {
16205 parse(data) {
16206 const result = new ImportResult();
16207 const results = this.parseCsv(data, false);
16208 if (results == null) {
16209 result.success = false;
16210 return result;
16211 }
16212 results.forEach((value) => {
16213 if (value.length < 3) {
16214 return;
16215 }
16216 const folderName = this.getValueOrDefault(value[0], 'Unassigned') !== 'Unassigned' ? value[0] : null;
16217 this.processFolder(result, folderName);
16218 const cipher = this.initLoginCipher();
16219 cipher.name = this.getValueOrDefault(value[2], '--');
16220 if (value[1] === 'Web Logins' || value[1] === 'Login') {
16221 cipher.login.uris = this.makeUriArray(value[4]);
16222 cipher.login.username = this.getValueOrDefault(value[5]);
16223 cipher.login.password = this.getValueOrDefault(value[6]);
16224 cipher.notes = !this.isNullOrWhitespace(value[3]) ? value[3].split('\\n').join('\n') : null;
16225 }
16226 else if (value.length > 3) {
16227 cipher.type = CipherType.SecureNote;
16228 cipher.secureNote = new SecureNoteView();
16229 cipher.secureNote.type = SecureNoteType.Generic;
16230 for (let i = 3; i < value.length; i++) {
16231 if (!this.isNullOrWhitespace(value[i])) {
16232 cipher.notes += (value[i] + '\n');
16233 }
16234 }
16235 }
16236 if (!this.isNullOrWhitespace(value[1]) && cipher.type !== CipherType.Login) {
16237 cipher.name = value[1] + ': ' + cipher.name;
16238 }
16239 this.cleanupCipher(cipher);
16240 result.ciphers.push(cipher);
16241 });
16242 if (this.organization) {
16243 this.moveFoldersToCollections(result);
16244 }
16245 result.success = true;
16246 return result;
16247 }
16248}
16249
16250// CONCATENATED MODULE: ./jslib/src/importers/mykiCsvImporter.ts
16251
16252
16253
16254
16255
16256
16257
16258class mykiCsvImporter_MykiCsvImporter extends baseImporter_BaseImporter {
16259 parse(data) {
16260 const result = new ImportResult();
16261 const results = this.parseCsv(data, true);
16262 if (results == null) {
16263 result.success = false;
16264 return result;
16265 }
16266 results.forEach((value) => {
16267 const cipher = this.initLoginCipher();
16268 cipher.name = this.getValueOrDefault(value.nickname, '--');
16269 cipher.notes = this.getValueOrDefault(value.additionalInfo);
16270 if (value.url !== undefined) {
16271 // Accounts
16272 cipher.login.uris = this.makeUriArray(value.url);
16273 cipher.login.username = this.getValueOrDefault(value.username);
16274 cipher.login.password = this.getValueOrDefault(value.password);
16275 cipher.login.totp = this.getValueOrDefault(value.twoFactAuthToken);
16276 }
16277 else if (value.cardNumber !== undefined) {
16278 // Cards
16279 cipher.card = new CardView();
16280 cipher.type = CipherType.Card;
16281 cipher.card.cardholderName = this.getValueOrDefault(value.cardName);
16282 cipher.card.number = this.getValueOrDefault(value.cardNumber);
16283 cipher.card.brand = this.getCardBrand(cipher.card.number);
16284 cipher.card.expMonth = this.getValueOrDefault(value.exp_month);
16285 cipher.card.expYear = this.getValueOrDefault(value.exp_year);
16286 cipher.card.code = this.getValueOrDefault(value.cvv);
16287 }
16288 else if (value.firstName !== undefined) {
16289 // Identities
16290 cipher.identity = new identityView_IdentityView();
16291 cipher.type = CipherType.Identity;
16292 cipher.identity.title = this.getValueOrDefault(value.title);
16293 cipher.identity.firstName = this.getValueOrDefault(value.firstName);
16294 cipher.identity.middleName = this.getValueOrDefault(value.middleName);
16295 cipher.identity.lastName = this.getValueOrDefault(value.lastName);
16296 cipher.identity.phone = this.getValueOrDefault(value.number);
16297 cipher.identity.email = this.getValueOrDefault(value.email);
16298 cipher.identity.address1 = this.getValueOrDefault(value.firstAddressLine);
16299 cipher.identity.address2 = this.getValueOrDefault(value.secondAddressLine);
16300 cipher.identity.city = this.getValueOrDefault(value.city);
16301 cipher.identity.country = this.getValueOrDefault(value.country);
16302 cipher.identity.postalCode = this.getValueOrDefault(value.zipCode);
16303 }
16304 else if (value.content !== undefined) {
16305 // Notes
16306 cipher.secureNote = new SecureNoteView();
16307 cipher.type = CipherType.SecureNote;
16308 cipher.secureNote.type = SecureNoteType.Generic;
16309 cipher.name = this.getValueOrDefault(value.title, '--');
16310 cipher.notes = this.getValueOrDefault(value.content);
16311 }
16312 else {
16313 return;
16314 }
16315 this.cleanupCipher(cipher);
16316 result.ciphers.push(cipher);
16317 });
16318 result.success = true;
16319 return result;
16320 }
16321}
16322
16323// CONCATENATED MODULE: ./jslib/src/importers/onepassword1PifImporter.ts
16324
16325
16326
16327
16328
16329
16330
16331
16332
16333class onepassword1PifImporter_OnePassword1PifImporter extends baseImporter_BaseImporter {
16334 constructor() {
16335 super(...arguments);
16336 this.result = new ImportResult();
16337 }
16338 parse(data) {
16339 data.split(this.newLineRegex).forEach((line) => {
16340 if (this.isNullOrWhitespace(line) || line[0] !== '{') {
16341 return;
16342 }
16343 const item = JSON.parse(line);
16344 if (item.trashed === true) {
16345 return;
16346 }
16347 const cipher = this.initLoginCipher();
16348 if (this.isNullOrWhitespace(item.hmac)) {
16349 this.processStandardItem(item, cipher);
16350 }
16351 else {
16352 this.processWinOpVaultItem(item, cipher);
16353 }
16354 this.convertToNoteIfNeeded(cipher);
16355 this.cleanupCipher(cipher);
16356 this.result.ciphers.push(cipher);
16357 });
16358 this.result.success = true;
16359 return this.result;
16360 }
16361 processWinOpVaultItem(item, cipher) {
16362 if (item.overview != null) {
16363 cipher.name = this.getValueOrDefault(item.overview.title);
16364 if (item.overview.URLs != null) {
16365 const urls = [];
16366 item.overview.URLs.forEach((url) => {
16367 if (!this.isNullOrWhitespace(url.u)) {
16368 urls.push(url.u);
16369 }
16370 });
16371 cipher.login.uris = this.makeUriArray(urls);
16372 }
16373 }
16374 if (item.details != null) {
16375 if (item.details.passwordHistory != null) {
16376 this.parsePasswordHistory(item.details.passwordHistory, cipher);
16377 }
16378 if (!this.isNullOrWhitespace(item.details.ccnum) || !this.isNullOrWhitespace(item.details.cvv)) {
16379 cipher.type = CipherType.Card;
16380 cipher.card = new CardView();
16381 }
16382 else if (!this.isNullOrWhitespace(item.details.firstname) ||
16383 !this.isNullOrWhitespace(item.details.address1)) {
16384 cipher.type = CipherType.Identity;
16385 cipher.identity = new identityView_IdentityView();
16386 }
16387 if (cipher.type === CipherType.Login && !this.isNullOrWhitespace(item.details.password)) {
16388 cipher.login.password = item.details.password;
16389 }
16390 if (!this.isNullOrWhitespace(item.details.notesPlain)) {
16391 cipher.notes = item.details.notesPlain.split(this.newLineRegex).join('\n') + '\n';
16392 }
16393 if (item.details.fields != null) {
16394 this.parseFields(item.details.fields, cipher, 'designation', 'value', 'name');
16395 }
16396 if (item.details.sections != null) {
16397 item.details.sections.forEach((section) => {
16398 if (section.fields != null) {
16399 this.parseFields(section.fields, cipher, 'n', 'v', 't');
16400 }
16401 });
16402 }
16403 }
16404 }
16405 processStandardItem(item, cipher) {
16406 cipher.favorite = item.openContents && item.openContents.faveIndex ? true : false;
16407 cipher.name = this.getValueOrDefault(item.title);
16408 if (item.typeName === 'securenotes.SecureNote') {
16409 cipher.type = CipherType.SecureNote;
16410 cipher.secureNote = new SecureNoteView();
16411 cipher.secureNote.type = SecureNoteType.Generic;
16412 }
16413 else if (item.typeName === 'wallet.financial.CreditCard') {
16414 cipher.type = CipherType.Card;
16415 cipher.card = new CardView();
16416 }
16417 else if (item.typeName === 'identities.Identity') {
16418 cipher.type = CipherType.Identity;
16419 cipher.identity = new identityView_IdentityView();
16420 }
16421 else {
16422 cipher.login.uris = this.makeUriArray(item.location);
16423 }
16424 if (item.secureContents != null) {
16425 if (item.secureContents.passwordHistory != null) {
16426 this.parsePasswordHistory(item.secureContents.passwordHistory, cipher);
16427 }
16428 if (!this.isNullOrWhitespace(item.secureContents.notesPlain)) {
16429 cipher.notes = item.secureContents.notesPlain.split(this.newLineRegex).join('\n') + '\n';
16430 }
16431 if (cipher.type === CipherType.Login) {
16432 if (!this.isNullOrWhitespace(item.secureContents.password)) {
16433 cipher.login.password = item.secureContents.password;
16434 }
16435 if (item.secureContents.URLs != null) {
16436 const urls = [];
16437 item.secureContents.URLs.forEach((u) => {
16438 if (!this.isNullOrWhitespace(u.url)) {
16439 urls.push(u.url);
16440 }
16441 });
16442 if (urls.length > 0) {
16443 cipher.login.uris = this.makeUriArray(urls);
16444 }
16445 }
16446 }
16447 if (item.secureContents.fields != null) {
16448 this.parseFields(item.secureContents.fields, cipher, 'designation', 'value', 'name');
16449 }
16450 if (item.secureContents.sections != null) {
16451 item.secureContents.sections.forEach((section) => {
16452 if (section.fields != null) {
16453 this.parseFields(section.fields, cipher, 'n', 'v', 't');
16454 }
16455 });
16456 }
16457 }
16458 }
16459 parsePasswordHistory(items, cipher) {
16460 const maxSize = items.length > 5 ? 5 : items.length;
16461 cipher.passwordHistory = items
16462 .filter((h) => !this.isNullOrWhitespace(h.value) && h.time != null)
16463 .sort((a, b) => b.time - a.time)
16464 .slice(0, maxSize)
16465 .map((h) => {
16466 const ph = new PasswordHistoryView();
16467 ph.password = h.value;
16468 ph.lastUsedDate = new Date(('' + h.time).length >= 13 ? h.time : h.time * 1000);
16469 return ph;
16470 });
16471 }
16472 parseFields(fields, cipher, designationKey, valueKey, nameKey) {
16473 fields.forEach((field) => {
16474 if (field[valueKey] == null || field[valueKey].toString().trim() === '') {
16475 return;
16476 }
16477 const fieldValue = field[valueKey].toString();
16478 const fieldDesignation = field[designationKey] != null ? field[designationKey].toString() : null;
16479 if (cipher.type === CipherType.Login) {
16480 if (this.isNullOrWhitespace(cipher.login.username) && fieldDesignation === 'username') {
16481 cipher.login.username = fieldValue;
16482 return;
16483 }
16484 else if (this.isNullOrWhitespace(cipher.login.password) && fieldDesignation === 'password') {
16485 cipher.login.password = fieldValue;
16486 return;
16487 }
16488 else if (this.isNullOrWhitespace(cipher.login.totp) && fieldDesignation != null &&
16489 fieldDesignation.startsWith('TOTP_')) {
16490 cipher.login.totp = fieldValue;
16491 return;
16492 }
16493 }
16494 else if (cipher.type === CipherType.Card) {
16495 if (this.isNullOrWhitespace(cipher.card.number) && fieldDesignation === 'ccnum') {
16496 cipher.card.number = fieldValue;
16497 cipher.card.brand = this.getCardBrand(fieldValue);
16498 return;
16499 }
16500 else if (this.isNullOrWhitespace(cipher.card.code) && fieldDesignation === 'cvv') {
16501 cipher.card.code = fieldValue;
16502 return;
16503 }
16504 else if (this.isNullOrWhitespace(cipher.card.cardholderName) && fieldDesignation === 'cardholder') {
16505 cipher.card.cardholderName = fieldValue;
16506 return;
16507 }
16508 else if (this.isNullOrWhitespace(cipher.card.expiration) && fieldDesignation === 'expiry' &&
16509 fieldValue.length === 6) {
16510 cipher.card.expMonth = fieldValue.substr(4, 2);
16511 if (cipher.card.expMonth[0] === '0') {
16512 cipher.card.expMonth = cipher.card.expMonth.substr(1, 1);
16513 }
16514 cipher.card.expYear = fieldValue.substr(0, 4);
16515 return;
16516 }
16517 else if (fieldDesignation === 'type') {
16518 // Skip since brand was determined from number above
16519 return;
16520 }
16521 }
16522 else if (cipher.type === CipherType.Identity) {
16523 const identity = cipher.identity;
16524 if (this.isNullOrWhitespace(identity.firstName) && fieldDesignation === 'firstname') {
16525 identity.firstName = fieldValue;
16526 return;
16527 }
16528 else if (this.isNullOrWhitespace(identity.lastName) && fieldDesignation === 'lastname') {
16529 identity.lastName = fieldValue;
16530 return;
16531 }
16532 else if (this.isNullOrWhitespace(identity.middleName) && fieldDesignation === 'initial') {
16533 identity.middleName = fieldValue;
16534 return;
16535 }
16536 else if (this.isNullOrWhitespace(identity.phone) && fieldDesignation === 'defphone') {
16537 identity.phone = fieldValue;
16538 return;
16539 }
16540 else if (this.isNullOrWhitespace(identity.company) && fieldDesignation === 'company') {
16541 identity.company = fieldValue;
16542 return;
16543 }
16544 else if (this.isNullOrWhitespace(identity.email) && fieldDesignation === 'email') {
16545 identity.email = fieldValue;
16546 return;
16547 }
16548 else if (this.isNullOrWhitespace(identity.username) && fieldDesignation === 'username') {
16549 identity.username = fieldValue;
16550 return;
16551 }
16552 else if (fieldDesignation === 'address') {
16553 // fieldValue is an object casted into a string, so access the plain value instead
16554 const { street, city, country, zip } = field[valueKey];
16555 identity.address1 = this.getValueOrDefault(street);
16556 identity.city = this.getValueOrDefault(city);
16557 if (!this.isNullOrWhitespace(country)) {
16558 identity.country = country.toUpperCase();
16559 }
16560 identity.postalCode = this.getValueOrDefault(zip);
16561 return;
16562 }
16563 }
16564 const fieldName = this.isNullOrWhitespace(field[nameKey]) ? 'no_name' : field[nameKey];
16565 if (fieldName === 'password' && cipher.passwordHistory != null &&
16566 cipher.passwordHistory.some((h) => h.password === fieldValue)) {
16567 return;
16568 }
16569 const fieldType = field.k === 'concealed' ? FieldType.Hidden : FieldType.Text;
16570 this.processKvp(cipher, fieldName, fieldValue, fieldType);
16571 });
16572 }
16573}
16574
16575// CONCATENATED MODULE: ./jslib/src/models/view/view.ts
16576class View {
16577}
16578
16579// CONCATENATED MODULE: ./jslib/src/models/view/index.ts
16580
16581
16582
16583
16584
16585
16586
16587
16588
16589
16590// CONCATENATED MODULE: ./jslib/src/importers/onepasswordWinCsvImporter.ts
16591
16592
16593
16594
16595const IgnoredProperties = ['ainfo', 'autosubmit', 'notesplain', 'ps', 'scope', 'tags', 'title', 'uuid'];
16596class onepasswordWinCsvImporter_OnePasswordWinCsvImporter extends baseImporter_BaseImporter {
16597 parse(data) {
16598 const result = new ImportResult();
16599 const results = this.parseCsv(data, true);
16600 if (results == null) {
16601 result.success = false;
16602 return result;
16603 }
16604 results.forEach((value) => {
16605 if (this.isNullOrWhitespace(this.getProp(value, 'title'))) {
16606 return;
16607 }
16608 const cipher = this.initLoginCipher();
16609 cipher.name = this.getValueOrDefault(this.getProp(value, 'title'), '--');
16610 cipher.notes = this.getValueOrDefault(this.getProp(value, 'notesPlain'), '') + '\n';
16611 if (!this.isNullOrWhitespace(this.getProp(value, 'number')) &&
16612 !this.isNullOrWhitespace(this.getProp(value, 'expiry date'))) {
16613 cipher.type = CipherType.Card;
16614 cipher.card = new CardView();
16615 }
16616 let altUsername = null;
16617 for (const property in value) {
16618 if (!value.hasOwnProperty(property) || this.isNullOrWhitespace(value[property])) {
16619 continue;
16620 }
16621 const lowerProp = property.toLowerCase();
16622 if (cipher.type === CipherType.Login) {
16623 if (this.isNullOrWhitespace(cipher.login.password) && lowerProp === 'password') {
16624 cipher.login.password = value[property];
16625 continue;
16626 }
16627 else if (this.isNullOrWhitespace(cipher.login.username) && lowerProp === 'username') {
16628 cipher.login.username = value[property];
16629 continue;
16630 }
16631 else if ((cipher.login.uris == null || cipher.login.uri.length === 0) && lowerProp === 'urls') {
16632 const urls = value[property].split(this.newLineRegex);
16633 cipher.login.uris = this.makeUriArray(urls);
16634 continue;
16635 }
16636 }
16637 else if (cipher.type === CipherType.Card) {
16638 if (this.isNullOrWhitespace(cipher.card.number) && lowerProp === 'number') {
16639 cipher.card.number = value[property];
16640 cipher.card.brand = this.getCardBrand(this.getProp(value, 'number'));
16641 continue;
16642 }
16643 else if (this.isNullOrWhitespace(cipher.card.code) && lowerProp === 'verification number') {
16644 cipher.card.code = value[property];
16645 continue;
16646 }
16647 else if (this.isNullOrWhitespace(cipher.card.cardholderName) && lowerProp === 'cardholder name') {
16648 cipher.card.cardholderName = value[property];
16649 continue;
16650 }
16651 else if (this.isNullOrWhitespace(cipher.card.expiration) && lowerProp === 'expiry date' &&
16652 value[property].length === 6) {
16653 cipher.card.expMonth = value[property].substr(4, 2);
16654 if (cipher.card.expMonth[0] === '0') {
16655 cipher.card.expMonth = cipher.card.expMonth.substr(1, 1);
16656 }
16657 cipher.card.expYear = value[property].substr(0, 4);
16658 continue;
16659 }
16660 else if (lowerProp === 'type') {
16661 // Skip since brand was determined from number above
16662 continue;
16663 }
16664 }
16665 if (IgnoredProperties.indexOf(lowerProp) === -1 && !lowerProp.startsWith('section:') &&
16666 !lowerProp.startsWith('section ')) {
16667 if (altUsername == null && lowerProp === 'email') {
16668 altUsername = value[property];
16669 }
16670 this.processKvp(cipher, property, value[property]);
16671 }
16672 }
16673 if (cipher.type === CipherType.Login && !this.isNullOrWhitespace(altUsername) &&
16674 this.isNullOrWhitespace(cipher.login.username) && altUsername.indexOf('://') === -1) {
16675 cipher.login.username = altUsername;
16676 }
16677 this.convertToNoteIfNeeded(cipher);
16678 this.cleanupCipher(cipher);
16679 result.ciphers.push(cipher);
16680 });
16681 result.success = true;
16682 return result;
16683 }
16684 getProp(obj, name) {
16685 return obj[name] || obj[name.toUpperCase()];
16686 }
16687}
16688
16689// CONCATENATED MODULE: ./jslib/src/importers/padlockCsvImporter.ts
16690
16691
16692
16693class padlockCsvImporter_PadlockCsvImporter extends baseImporter_BaseImporter {
16694 parse(data) {
16695 const result = new ImportResult();
16696 const results = this.parseCsv(data, false);
16697 if (results == null) {
16698 result.success = false;
16699 return result;
16700 }
16701 let headers = null;
16702 results.forEach((value) => {
16703 if (headers == null) {
16704 headers = value.map((v) => v);
16705 return;
16706 }
16707 if (value.length < 2 || value.length !== headers.length) {
16708 return;
16709 }
16710 if (!this.isNullOrWhitespace(value[1])) {
16711 if (this.organization) {
16712 const tags = value[1].split(',');
16713 tags.forEach((tag) => {
16714 tag = tag.trim();
16715 let addCollection = true;
16716 let collectionIndex = result.collections.length;
16717 for (let i = 0; i < result.collections.length; i++) {
16718 if (result.collections[i].name === tag) {
16719 addCollection = false;
16720 collectionIndex = i;
16721 break;
16722 }
16723 }
16724 if (addCollection) {
16725 const collection = new collectionView_CollectionView();
16726 collection.name = tag;
16727 result.collections.push(collection);
16728 }
16729 result.collectionRelationships.push([result.ciphers.length, collectionIndex]);
16730 });
16731 }
16732 else {
16733 const tags = value[1].split(',');
16734 const tag = tags.length > 0 ? tags[0].trim() : null;
16735 this.processFolder(result, tag);
16736 }
16737 }
16738 const cipher = this.initLoginCipher();
16739 cipher.name = this.getValueOrDefault(value[0], '--');
16740 for (let i = 2; i < value.length; i++) {
16741 const header = headers[i].trim().toLowerCase();
16742 if (this.isNullOrWhitespace(value[i]) || this.isNullOrWhitespace(header)) {
16743 continue;
16744 }
16745 if (this.usernameFieldNames.indexOf(header) > -1) {
16746 cipher.login.username = value[i];
16747 }
16748 else if (this.passwordFieldNames.indexOf(header) > -1) {
16749 cipher.login.password = value[i];
16750 }
16751 else if (this.uriFieldNames.indexOf(header) > -1) {
16752 cipher.login.uris = this.makeUriArray(value[i]);
16753 }
16754 else {
16755 this.processKvp(cipher, headers[i], value[i]);
16756 }
16757 }
16758 this.cleanupCipher(cipher);
16759 result.ciphers.push(cipher);
16760 });
16761 result.success = true;
16762 return result;
16763 }
16764}
16765
16766// CONCATENATED MODULE: ./jslib/src/importers/passkeepCsvImporter.ts
16767
16768
16769class passkeepCsvImporter_PassKeepCsvImporter extends baseImporter_BaseImporter {
16770 parse(data) {
16771 const result = new ImportResult();
16772 const results = this.parseCsv(data, true);
16773 if (results == null) {
16774 result.success = false;
16775 return result;
16776 }
16777 results.forEach((value) => {
16778 this.processFolder(result, this.getValue('category', value));
16779 const cipher = this.initLoginCipher();
16780 cipher.notes = this.getValue('description', value);
16781 cipher.name = this.getValueOrDefault(this.getValue('title', value), '--');
16782 cipher.login.username = this.getValue('username', value);
16783 cipher.login.password = this.getValue('password', value);
16784 cipher.login.uris = this.makeUriArray(this.getValue('site', value));
16785 this.processKvp(cipher, 'Password 2', this.getValue('password2', value));
16786 this.cleanupCipher(cipher);
16787 result.ciphers.push(cipher);
16788 });
16789 if (this.organization) {
16790 this.moveFoldersToCollections(result);
16791 }
16792 result.success = true;
16793 return result;
16794 }
16795 getValue(key, value) {
16796 return this.getValueOrDefault(value[key], this.getValueOrDefault(value[(' ' + key)]));
16797 }
16798}
16799
16800// CONCATENATED MODULE: ./jslib/src/importers/passmanJsonImporter.ts
16801
16802
16803class passmanJsonImporter_PassmanJsonImporter extends baseImporter_BaseImporter {
16804 parse(data) {
16805 const result = new ImportResult();
16806 const results = JSON.parse(data);
16807 if (results == null || results.length === 0) {
16808 result.success = false;
16809 return result;
16810 }
16811 results.forEach((credential) => {
16812 if (credential.tags != null && credential.tags.length > 0) {
16813 const folderName = credential.tags[0].text;
16814 this.processFolder(result, folderName);
16815 }
16816 const cipher = this.initLoginCipher();
16817 cipher.name = credential.label;
16818 cipher.login.username = this.getValueOrDefault(credential.username);
16819 if (this.isNullOrWhitespace(cipher.login.username)) {
16820 cipher.login.username = this.getValueOrDefault(credential.email);
16821 }
16822 else if (!this.isNullOrWhitespace(credential.email)) {
16823 cipher.notes = ('Email: ' + credential.email + '\n');
16824 }
16825 cipher.login.password = this.getValueOrDefault(credential.password);
16826 cipher.login.uris = this.makeUriArray(credential.url);
16827 cipher.notes += this.getValueOrDefault(credential.description, '');
16828 if (credential.otp != null) {
16829 cipher.login.totp = this.getValueOrDefault(credential.otp.secret);
16830 }
16831 if (credential.custom_fields != null) {
16832 credential.custom_fields.forEach((customField) => {
16833 switch (customField.field_type) {
16834 case 'text':
16835 case 'password':
16836 this.processKvp(cipher, customField.label, customField.value);
16837 break;
16838 }
16839 });
16840 }
16841 this.convertToNoteIfNeeded(cipher);
16842 this.cleanupCipher(cipher);
16843 result.ciphers.push(cipher);
16844 });
16845 if (this.organization) {
16846 this.moveFoldersToCollections(result);
16847 }
16848 result.success = true;
16849 return result;
16850 }
16851}
16852
16853// CONCATENATED MODULE: ./jslib/src/importers/passpackCsvImporter.ts
16854
16855
16856
16857class passpackCsvImporter_PasspackCsvImporter extends baseImporter_BaseImporter {
16858 parse(data) {
16859 const result = new ImportResult();
16860 const results = this.parseCsv(data, true);
16861 if (results == null) {
16862 result.success = false;
16863 return result;
16864 }
16865 results.forEach((value) => {
16866 const tagsJson = !this.isNullOrWhitespace(value.Tags) ? JSON.parse(value.Tags) : null;
16867 const tags = tagsJson != null && tagsJson.tags != null && tagsJson.tags.length > 0 ?
16868 tagsJson.tags.map((tagJson) => {
16869 try {
16870 const t = JSON.parse(tagJson);
16871 return this.getValueOrDefault(t.tag);
16872 }
16873 catch (_a) { }
16874 return null;
16875 }).filter((t) => !this.isNullOrWhitespace(t)) : null;
16876 if (this.organization && tags != null && tags.length > 0) {
16877 tags.forEach((tag) => {
16878 let addCollection = true;
16879 let collectionIndex = result.collections.length;
16880 for (let i = 0; i < result.collections.length; i++) {
16881 if (result.collections[i].name === tag) {
16882 addCollection = false;
16883 collectionIndex = i;
16884 break;
16885 }
16886 }
16887 if (addCollection) {
16888 const collection = new collectionView_CollectionView();
16889 collection.name = tag;
16890 result.collections.push(collection);
16891 }
16892 result.collectionRelationships.push([result.ciphers.length, collectionIndex]);
16893 });
16894 }
16895 else if (!this.organization && tags != null && tags.length > 0) {
16896 this.processFolder(result, tags[0]);
16897 }
16898 const cipher = this.initLoginCipher();
16899 cipher.notes = this.getValueOrDefault(value.Notes, '');
16900 cipher.notes += ('\n\n' + this.getValueOrDefault(value['Shared Notes'], '') + '\n');
16901 cipher.name = this.getValueOrDefault(value['Entry Name'], '--');
16902 cipher.login.username = this.getValueOrDefault(value['User ID']);
16903 cipher.login.password = this.getValueOrDefault(value.Password);
16904 cipher.login.uris = this.makeUriArray(value.URL);
16905 if (value.__parsed_extra != null && value.__parsed_extra.length > 0) {
16906 value.__parsed_extra.forEach((extra) => {
16907 if (!this.isNullOrWhitespace(extra)) {
16908 cipher.notes += ('\n' + extra);
16909 }
16910 });
16911 }
16912 const fieldsJson = !this.isNullOrWhitespace(value['Extra Fields']) ?
16913 JSON.parse(value['Extra Fields']) : null;
16914 const fields = fieldsJson != null && fieldsJson.extraFields != null &&
16915 fieldsJson.extraFields.length > 0 ? fieldsJson.extraFields.map((fieldJson) => {
16916 try {
16917 return JSON.parse(fieldJson);
16918 }
16919 catch (_a) { }
16920 return null;
16921 }) : null;
16922 if (fields != null) {
16923 fields.forEach((f) => {
16924 if (f != null) {
16925 this.processKvp(cipher, f.name, f.data);
16926 }
16927 });
16928 }
16929 this.cleanupCipher(cipher);
16930 result.ciphers.push(cipher);
16931 });
16932 result.success = true;
16933 return result;
16934 }
16935}
16936
16937// CONCATENATED MODULE: ./jslib/src/importers/passwordAgentCsvImporter.ts
16938
16939
16940class passwordAgentCsvImporter_PasswordAgentCsvImporter extends baseImporter_BaseImporter {
16941 parse(data) {
16942 const result = new ImportResult();
16943 const results = this.parseCsv(data, false);
16944 if (results == null) {
16945 result.success = false;
16946 return result;
16947 }
16948 let newVersion = true;
16949 results.forEach((value) => {
16950 if (value.length !== 5 && value.length < 9) {
16951 return;
16952 }
16953 const altFormat = value.length === 10 && value[0] === '0';
16954 const cipher = this.initLoginCipher();
16955 cipher.name = this.getValueOrDefault(value[altFormat ? 1 : 0], '--');
16956 cipher.login.username = this.getValueOrDefault(value[altFormat ? 2 : 1]);
16957 cipher.login.password = this.getValueOrDefault(value[altFormat ? 3 : 2]);
16958 if (value.length === 5) {
16959 newVersion = false;
16960 cipher.notes = this.getValueOrDefault(value[4]);
16961 cipher.login.uris = this.makeUriArray(value[3]);
16962 }
16963 else {
16964 const folder = this.getValueOrDefault(value[altFormat ? 9 : 8], '(None)');
16965 let folderName = folder !== '(None)' ? folder.split('\\').join('/') : null;
16966 if (folderName != null) {
16967 folderName = folder.split(' > ').join('/');
16968 folderName = folder.split('>').join('/');
16969 }
16970 this.processFolder(result, folderName);
16971 cipher.notes = this.getValueOrDefault(value[altFormat ? 5 : 3]);
16972 cipher.login.uris = this.makeUriArray(value[4]);
16973 }
16974 this.convertToNoteIfNeeded(cipher);
16975 this.cleanupCipher(cipher);
16976 result.ciphers.push(cipher);
16977 });
16978 if (newVersion && this.organization) {
16979 this.moveFoldersToCollections(result);
16980 }
16981 result.success = true;
16982 return result;
16983 }
16984}
16985
16986// CONCATENATED MODULE: ./jslib/src/importers/passwordBossJsonImporter.ts
16987
16988
16989
16990
16991
16992class passwordBossJsonImporter_PasswordBossJsonImporter extends baseImporter_BaseImporter {
16993 parse(data) {
16994 const result = new ImportResult();
16995 const results = JSON.parse(data);
16996 if (results == null || results.items == null) {
16997 result.success = false;
16998 return result;
16999 }
17000 const foldersMap = new Map();
17001 results.folders.forEach((value) => {
17002 foldersMap.set(value.id, value.name);
17003 });
17004 const foldersIndexMap = new Map();
17005 foldersMap.forEach((val, key) => {
17006 foldersIndexMap.set(key, result.folders.length);
17007 const f = new FolderView();
17008 f.name = val;
17009 result.folders.push(f);
17010 });
17011 results.items.forEach((value) => {
17012 const cipher = this.initLoginCipher();
17013 cipher.name = this.getValueOrDefault(value.name, '--');
17014 cipher.login.uris = this.makeUriArray(value.login_url);
17015 if (value.folder != null && foldersIndexMap.has(value.folder)) {
17016 result.folderRelationships.push([result.ciphers.length, foldersIndexMap.get(value.folder)]);
17017 }
17018 if (value.identifiers == null) {
17019 return;
17020 }
17021 if (!this.isNullOrWhitespace(value.identifiers.notes)) {
17022 cipher.notes = value.identifiers.notes.split('\\r\\n').join('\n').split('\\n').join('\n');
17023 }
17024 if (value.type === 'CreditCard') {
17025 cipher.card = new CardView();
17026 cipher.type = CipherType.Card;
17027 }
17028 for (const property in value.identifiers) {
17029 if (!value.identifiers.hasOwnProperty(property)) {
17030 continue;
17031 }
17032 const valObj = value.identifiers[property];
17033 const val = valObj != null ? valObj.toString() : null;
17034 if (this.isNullOrWhitespace(val) || property === 'notes' || property === 'ignoreItemInSecurityScore') {
17035 continue;
17036 }
17037 if (property === 'custom_fields') {
17038 valObj.forEach((cf) => {
17039 this.processKvp(cipher, cf.name, cf.value);
17040 });
17041 continue;
17042 }
17043 if (cipher.type === CipherType.Card) {
17044 if (property === 'cardNumber') {
17045 cipher.card.number = val;
17046 cipher.card.brand = this.getCardBrand(val);
17047 continue;
17048 }
17049 else if (property === 'nameOnCard') {
17050 cipher.card.cardholderName = val;
17051 continue;
17052 }
17053 else if (property === 'security_code') {
17054 cipher.card.code = val;
17055 continue;
17056 }
17057 else if (property === 'expires') {
17058 try {
17059 const expDate = new Date(val);
17060 cipher.card.expYear = expDate.getFullYear().toString();
17061 cipher.card.expMonth = (expDate.getMonth() + 1).toString();
17062 }
17063 catch (_a) { }
17064 continue;
17065 }
17066 else if (property === 'cardType') {
17067 continue;
17068 }
17069 }
17070 else {
17071 if ((property === 'username' || property === 'email') &&
17072 this.isNullOrWhitespace(cipher.login.username)) {
17073 cipher.login.username = val;
17074 continue;
17075 }
17076 else if (property === 'password') {
17077 cipher.login.password = val;
17078 continue;
17079 }
17080 else if (property === 'totp') {
17081 cipher.login.totp = val;
17082 continue;
17083 }
17084 else if ((cipher.login.uris == null || cipher.login.uris.length === 0) &&
17085 this.uriFieldNames.indexOf(property) > -1) {
17086 cipher.login.uris = this.makeUriArray(val);
17087 continue;
17088 }
17089 }
17090 this.processKvp(cipher, property, val);
17091 }
17092 this.convertToNoteIfNeeded(cipher);
17093 this.cleanupCipher(cipher);
17094 result.ciphers.push(cipher);
17095 });
17096 result.success = true;
17097 return result;
17098 }
17099}
17100
17101// CONCATENATED MODULE: ./jslib/src/importers/passwordDragonXmlImporter.ts
17102
17103
17104class passwordDragonXmlImporter_PasswordDragonXmlImporter extends baseImporter_BaseImporter {
17105 parse(data) {
17106 const result = new ImportResult();
17107 const doc = this.parseXml(data);
17108 if (doc == null) {
17109 result.success = false;
17110 return result;
17111 }
17112 const records = doc.querySelectorAll('PasswordManager > record');
17113 Array.from(records).forEach((record) => {
17114 const category = this.querySelectorDirectChild(record, 'Category');
17115 const categoryText = category != null && !this.isNullOrWhitespace(category.textContent) &&
17116 category.textContent !== 'Unfiled' ? category.textContent : null;
17117 this.processFolder(result, categoryText);
17118 const accountName = this.querySelectorDirectChild(record, 'Account-Name');
17119 const userId = this.querySelectorDirectChild(record, 'User-Id');
17120 const password = this.querySelectorDirectChild(record, 'Password');
17121 const url = this.querySelectorDirectChild(record, 'URL');
17122 const notes = this.querySelectorDirectChild(record, 'Notes');
17123 const cipher = this.initLoginCipher();
17124 cipher.name = accountName != null ? this.getValueOrDefault(accountName.textContent, '--') : '--';
17125 cipher.notes = notes != null ? this.getValueOrDefault(notes.textContent) : '';
17126 cipher.login.username = userId != null ? this.getValueOrDefault(userId.textContent) : null;
17127 cipher.login.password = password != null ? this.getValueOrDefault(password.textContent) : null;
17128 cipher.login.uris = url != null ? this.makeUriArray(url.textContent) : null;
17129 const attributes = [];
17130 for (let i = 1; i <= 10; i++) {
17131 attributes.push('Attribute-' + i);
17132 }
17133 this.querySelectorAllDirectChild(record, attributes.join(',')).forEach((attr) => {
17134 if (this.isNullOrWhitespace(attr.textContent) || attr.textContent === 'null') {
17135 return;
17136 }
17137 this.processKvp(cipher, attr.tagName, attr.textContent);
17138 });
17139 this.cleanupCipher(cipher);
17140 result.ciphers.push(cipher);
17141 });
17142 if (this.organization) {
17143 this.moveFoldersToCollections(result);
17144 }
17145 result.success = true;
17146 return result;
17147 }
17148}
17149
17150// CONCATENATED MODULE: ./jslib/src/importers/passwordSafeXmlImporter.ts
17151
17152
17153class passwordSafeXmlImporter_PasswordSafeXmlImporter extends baseImporter_BaseImporter {
17154 parse(data) {
17155 const result = new ImportResult();
17156 const doc = this.parseXml(data);
17157 if (doc == null) {
17158 result.success = false;
17159 return result;
17160 }
17161 const passwordSafe = doc.querySelector('passwordsafe');
17162 if (passwordSafe == null) {
17163 result.errorMessage = 'Missing `passwordsafe` node.';
17164 result.success = false;
17165 return result;
17166 }
17167 const notesDelimiter = passwordSafe.getAttribute('delimiter');
17168 const entries = doc.querySelectorAll('passwordsafe > entry');
17169 Array.from(entries).forEach((entry) => {
17170 const group = this.querySelectorDirectChild(entry, 'group');
17171 const groupText = group != null && !this.isNullOrWhitespace(group.textContent) ?
17172 group.textContent.split('.').join('/') : null;
17173 this.processFolder(result, groupText);
17174 const title = this.querySelectorDirectChild(entry, 'title');
17175 const username = this.querySelectorDirectChild(entry, 'username');
17176 const email = this.querySelectorDirectChild(entry, 'email');
17177 const password = this.querySelectorDirectChild(entry, 'password');
17178 const url = this.querySelectorDirectChild(entry, 'url');
17179 const notes = this.querySelectorDirectChild(entry, 'notes');
17180 const cipher = this.initLoginCipher();
17181 cipher.name = title != null ? this.getValueOrDefault(title.textContent, '--') : '--';
17182 cipher.notes = notes != null ?
17183 this.getValueOrDefault(notes.textContent, '').split(notesDelimiter).join('\n') : null;
17184 cipher.login.username = username != null ? this.getValueOrDefault(username.textContent) : null;
17185 cipher.login.password = password != null ? this.getValueOrDefault(password.textContent) : null;
17186 cipher.login.uris = url != null ? this.makeUriArray(url.textContent) : null;
17187 if (this.isNullOrWhitespace(cipher.login.username) && email != null) {
17188 cipher.login.username = this.getValueOrDefault(email.textContent);
17189 }
17190 else if (email != null && !this.isNullOrWhitespace(email.textContent)) {
17191 cipher.notes = this.isNullOrWhitespace(cipher.notes) ? 'Email: ' + email.textContent
17192 : (cipher.notes + '\n' + 'Email: ' + email.textContent);
17193 }
17194 this.cleanupCipher(cipher);
17195 result.ciphers.push(cipher);
17196 });
17197 if (this.organization) {
17198 this.moveFoldersToCollections(result);
17199 }
17200 result.success = true;
17201 return result;
17202 }
17203}
17204
17205// CONCATENATED MODULE: ./jslib/src/importers/passwordWalletTxtImporter.ts
17206
17207
17208class passwordWalletTxtImporter_PasswordWalletTxtImporter extends baseImporter_BaseImporter {
17209 parse(data) {
17210 const result = new ImportResult();
17211 const results = this.parseCsv(data, false);
17212 if (results == null) {
17213 result.success = false;
17214 return result;
17215 }
17216 results.forEach((value) => {
17217 if (value.length < 1) {
17218 return;
17219 }
17220 if (value.length > 5) {
17221 this.processFolder(result, value[5]);
17222 }
17223 const cipher = this.initLoginCipher();
17224 cipher.name = this.getValueOrDefault(value[0], '--');
17225 if (value.length > 4) {
17226 cipher.notes = this.getValueOrDefault(value[4], '').split('¬').join('\n');
17227 }
17228 if (value.length > 2) {
17229 cipher.login.username = this.getValueOrDefault(value[2]);
17230 }
17231 if (value.length > 3) {
17232 cipher.login.password = this.getValueOrDefault(value[3]);
17233 }
17234 if (value.length > 1) {
17235 cipher.login.uris = this.makeUriArray(value[1]);
17236 }
17237 this.cleanupCipher(cipher);
17238 result.ciphers.push(cipher);
17239 });
17240 if (this.organization) {
17241 this.moveFoldersToCollections(result);
17242 }
17243 result.success = true;
17244 return result;
17245 }
17246}
17247
17248// CONCATENATED MODULE: ./jslib/src/importers/rememBearCsvImporter.ts
17249
17250
17251
17252
17253class rememBearCsvImporter_RememBearCsvImporter extends baseImporter_BaseImporter {
17254 parse(data) {
17255 const result = new ImportResult();
17256 const results = this.parseCsv(data, true);
17257 if (results == null) {
17258 result.success = false;
17259 return result;
17260 }
17261 results.forEach((value) => {
17262 if (value.trash === 'true') {
17263 return;
17264 }
17265 const cipher = this.initLoginCipher();
17266 cipher.name = this.getValueOrDefault(value.name);
17267 cipher.notes = this.getValueOrDefault(value.notes);
17268 if (value.type === 'LoginItem') {
17269 cipher.login.uris = this.makeUriArray(value.website);
17270 cipher.login.password = this.getValueOrDefault(value.password);
17271 cipher.login.username = this.getValueOrDefault(value.username);
17272 }
17273 else if (value.type === 'CreditCardItem') {
17274 cipher.type = CipherType.Card;
17275 cipher.card = new CardView();
17276 cipher.card.cardholderName = this.getValueOrDefault(value.cardholder);
17277 cipher.card.number = this.getValueOrDefault(value.number);
17278 cipher.card.brand = this.getCardBrand(cipher.card.number);
17279 cipher.card.code = this.getValueOrDefault(value.verification);
17280 try {
17281 const expMonth = this.getValueOrDefault(value.expiryMonth);
17282 if (expMonth != null) {
17283 const expMonthNumber = parseInt(expMonth, null);
17284 if (expMonthNumber != null && expMonthNumber >= 1 && expMonthNumber <= 12) {
17285 cipher.card.expMonth = expMonthNumber.toString();
17286 }
17287 }
17288 }
17289 catch (_a) { }
17290 try {
17291 const expYear = this.getValueOrDefault(value.expiryYear);
17292 if (expYear != null) {
17293 const expYearNumber = parseInt(expYear, null);
17294 if (expYearNumber != null) {
17295 cipher.card.expYear = expYearNumber.toString();
17296 }
17297 }
17298 }
17299 catch (_b) { }
17300 const pin = this.getValueOrDefault(value.pin);
17301 if (pin != null) {
17302 this.processKvp(cipher, 'PIN', pin);
17303 }
17304 const zip = this.getValueOrDefault(value.zipCode);
17305 if (zip != null) {
17306 this.processKvp(cipher, 'Zip Code', zip);
17307 }
17308 }
17309 this.cleanupCipher(cipher);
17310 result.ciphers.push(cipher);
17311 });
17312 result.success = true;
17313 return result;
17314 }
17315}
17316
17317// CONCATENATED MODULE: ./jslib/src/importers/roboformCsvImporter.ts
17318
17319
17320class roboformCsvImporter_RoboFormCsvImporter extends baseImporter_BaseImporter {
17321 parse(data) {
17322 const result = new ImportResult();
17323 const results = this.parseCsv(data, true);
17324 if (results == null) {
17325 result.success = false;
17326 return result;
17327 }
17328 let i = 1;
17329 results.forEach((value) => {
17330 const folder = !this.isNullOrWhitespace(value.Folder) && value.Folder.startsWith('/') ?
17331 value.Folder.replace('/', '') : value.Folder;
17332 const folderName = !this.isNullOrWhitespace(folder) ? folder : null;
17333 this.processFolder(result, folderName);
17334 const cipher = this.initLoginCipher();
17335 cipher.notes = this.getValueOrDefault(value.Note);
17336 cipher.name = this.getValueOrDefault(value.Name, '--');
17337 cipher.login.username = this.getValueOrDefault(value.Login);
17338 cipher.login.password = this.getValueOrDefault(value.Pwd);
17339 cipher.login.uris = this.makeUriArray(value.Url);
17340 if (!this.isNullOrWhitespace(value.Rf_fields)) {
17341 let fields = [value.Rf_fields];
17342 if (value.__parsed_extra != null && value.__parsed_extra.length > 0) {
17343 fields = fields.concat(value.__parsed_extra);
17344 }
17345 fields.forEach((field) => {
17346 const parts = field.split(':');
17347 if (parts.length < 3) {
17348 return;
17349 }
17350 const key = parts[0] === '-no-name-' ? null : parts[0];
17351 const val = parts.length === 4 && parts[2] === 'rck' ? parts[1] : parts[2];
17352 this.processKvp(cipher, key, val);
17353 });
17354 }
17355 this.convertToNoteIfNeeded(cipher);
17356 this.cleanupCipher(cipher);
17357 if (i === results.length && cipher.name === '--' && this.isNullOrWhitespace(cipher.login.password)) {
17358 return;
17359 }
17360 result.ciphers.push(cipher);
17361 i++;
17362 });
17363 if (this.organization) {
17364 this.moveFoldersToCollections(result);
17365 }
17366 result.success = true;
17367 return result;
17368 }
17369}
17370
17371// CONCATENATED MODULE: ./jslib/src/importers/safeInCloudXmlImporter.ts
17372
17373
17374
17375
17376
17377
17378class safeInCloudXmlImporter_SafeInCloudXmlImporter extends baseImporter_BaseImporter {
17379 parse(data) {
17380 const result = new ImportResult();
17381 const doc = this.parseXml(data);
17382 if (doc == null) {
17383 result.success = false;
17384 return result;
17385 }
17386 const db = doc.querySelector('database');
17387 if (db == null) {
17388 result.errorMessage = 'Missing `database` node.';
17389 result.success = false;
17390 return result;
17391 }
17392 const foldersMap = new Map();
17393 Array.from(doc.querySelectorAll('database > label')).forEach((labelEl) => {
17394 const name = labelEl.getAttribute('name');
17395 const id = labelEl.getAttribute('id');
17396 if (!this.isNullOrWhitespace(name) && !this.isNullOrWhitespace(id)) {
17397 foldersMap.set(id, result.folders.length);
17398 const folder = new FolderView();
17399 folder.name = name;
17400 result.folders.push(folder);
17401 }
17402 });
17403 Array.from(doc.querySelectorAll('database > card')).forEach((cardEl) => {
17404 if (cardEl.getAttribute('template') === 'true') {
17405 return;
17406 }
17407 const labelIdEl = this.querySelectorDirectChild(cardEl, 'label_id');
17408 if (labelIdEl != null) {
17409 const labelId = labelIdEl.textContent;
17410 if (!this.isNullOrWhitespace(labelId) && foldersMap.has(labelId)) {
17411 result.folderRelationships.push([result.ciphers.length, foldersMap.get(labelId)]);
17412 }
17413 }
17414 const cipher = this.initLoginCipher();
17415 cipher.name = this.getValueOrDefault(cardEl.getAttribute('title'), '--');
17416 const cardType = cardEl.getAttribute('type');
17417 if (cardType === 'note') {
17418 cipher.type = CipherType.SecureNote;
17419 cipher.secureNote = new SecureNoteView();
17420 cipher.secureNote.type = SecureNoteType.Generic;
17421 }
17422 else {
17423 Array.from(this.querySelectorAllDirectChild(cardEl, 'field')).forEach((fieldEl) => {
17424 const text = fieldEl.textContent;
17425 if (this.isNullOrWhitespace(text)) {
17426 return;
17427 }
17428 const name = fieldEl.getAttribute('name');
17429 const fieldType = this.getValueOrDefault(fieldEl.getAttribute('type'), '').toLowerCase();
17430 if (fieldType === 'login') {
17431 cipher.login.username = text;
17432 }
17433 else if (fieldType === 'password') {
17434 cipher.login.password = text;
17435 }
17436 else if (fieldType === 'one_time_password') {
17437 cipher.login.totp = text;
17438 }
17439 else if (fieldType === 'notes') {
17440 cipher.notes += (text + '\n');
17441 }
17442 else if (fieldType === 'weblogin' || fieldType === 'website') {
17443 cipher.login.uris = this.makeUriArray(text);
17444 }
17445 else {
17446 this.processKvp(cipher, name, text);
17447 }
17448 });
17449 }
17450 Array.from(this.querySelectorAllDirectChild(cardEl, 'notes')).forEach((notesEl) => {
17451 cipher.notes += (notesEl.textContent + '\n');
17452 });
17453 this.cleanupCipher(cipher);
17454 result.ciphers.push(cipher);
17455 });
17456 if (this.organization) {
17457 this.moveFoldersToCollections(result);
17458 }
17459 result.success = true;
17460 return result;
17461 }
17462}
17463
17464// CONCATENATED MODULE: ./jslib/src/importers/saferpassCsvImport.ts
17465
17466
17467class saferpassCsvImport_SaferPassCsvImporter extends baseImporter_BaseImporter {
17468 parse(data) {
17469 const result = new ImportResult();
17470 const results = this.parseCsv(data, true);
17471 if (results == null) {
17472 result.success = false;
17473 return result;
17474 }
17475 results.forEach((value) => {
17476 const cipher = this.initLoginCipher();
17477 cipher.name = this.getValueOrDefault(this.nameFromUrl(value.url), '--');
17478 cipher.notes = this.getValueOrDefault(value.notes);
17479 cipher.login.username = this.getValueOrDefault(value.username);
17480 cipher.login.password = this.getValueOrDefault(value.password);
17481 cipher.login.uris = this.makeUriArray(value.url);
17482 this.cleanupCipher(cipher);
17483 result.ciphers.push(cipher);
17484 });
17485 result.success = true;
17486 return result;
17487 }
17488}
17489
17490// CONCATENATED MODULE: ./jslib/src/importers/secureSafeCsvImporter.ts
17491
17492
17493class secureSafeCsvImporter_SecureSafeCsvImporter extends baseImporter_BaseImporter {
17494 parse(data) {
17495 const result = new ImportResult();
17496 const results = this.parseCsv(data, true);
17497 if (results == null) {
17498 result.success = false;
17499 return result;
17500 }
17501 results.forEach((value) => {
17502 const cipher = this.initLoginCipher();
17503 cipher.name = this.getValueOrDefault(value.Title);
17504 cipher.notes = this.getValueOrDefault(value.Comment);
17505 cipher.login.uris = this.makeUriArray(value.Url);
17506 cipher.login.password = this.getValueOrDefault(value.Password);
17507 cipher.login.username = this.getValueOrDefault(value.Username);
17508 this.cleanupCipher(cipher);
17509 result.ciphers.push(cipher);
17510 });
17511 result.success = true;
17512 return result;
17513 }
17514}
17515
17516// CONCATENATED MODULE: ./jslib/src/importers/splashIdCsvImporter.ts
17517
17518
17519class splashIdCsvImporter_SplashIdCsvImporter extends baseImporter_BaseImporter {
17520 parse(data) {
17521 const result = new ImportResult();
17522 const results = this.parseCsv(data, false);
17523 if (results == null) {
17524 result.success = false;
17525 return result;
17526 }
17527 results.forEach((value) => {
17528 if (value.length < 3) {
17529 return;
17530 }
17531 this.processFolder(result, this.getValueOrDefault(value[value.length - 1]));
17532 const cipher = this.initLoginCipher();
17533 cipher.notes = this.getValueOrDefault(value[value.length - 2], '');
17534 cipher.name = this.getValueOrDefault(value[1], '--');
17535 if (value[0] === 'Web Logins' || value[0] === 'Servers' || value[0] === 'Email Accounts') {
17536 cipher.login.username = this.getValueOrDefault(value[2]);
17537 cipher.login.password = this.getValueOrDefault(value[3]);
17538 cipher.login.uris = this.makeUriArray(value[4]);
17539 this.parseFieldsToNotes(cipher, 5, value);
17540 }
17541 else {
17542 this.parseFieldsToNotes(cipher, 2, value);
17543 }
17544 this.convertToNoteIfNeeded(cipher);
17545 this.cleanupCipher(cipher);
17546 result.ciphers.push(cipher);
17547 });
17548 if (this.organization) {
17549 this.moveFoldersToCollections(result);
17550 }
17551 result.success = true;
17552 return result;
17553 }
17554 parseFieldsToNotes(cipher, startIndex, value) {
17555 // last 3 rows do not get parsed
17556 for (let i = startIndex; i < value.length - 3; i++) {
17557 if (this.isNullOrWhitespace(value[i])) {
17558 continue;
17559 }
17560 cipher.notes += (value[i] + '\n');
17561 }
17562 }
17563}
17564
17565// CONCATENATED MODULE: ./jslib/src/importers/stickyPasswordXmlImporter.ts
17566
17567
17568class stickyPasswordXmlImporter_StickyPasswordXmlImporter extends baseImporter_BaseImporter {
17569 parse(data) {
17570 const result = new ImportResult();
17571 const doc = this.parseXml(data);
17572 if (doc == null) {
17573 result.success = false;
17574 return result;
17575 }
17576 const loginNodes = doc.querySelectorAll('root > Database > Logins > Login');
17577 Array.from(loginNodes).forEach((loginNode) => {
17578 const accountId = loginNode.getAttribute('ID');
17579 if (this.isNullOrWhitespace(accountId)) {
17580 return;
17581 }
17582 const usernameText = loginNode.getAttribute('Name');
17583 const passwordText = loginNode.getAttribute('Password');
17584 let titleText = null;
17585 let linkText = null;
17586 let notesText = null;
17587 let groupId = null;
17588 let groupText = null;
17589 const accountLogin = doc.querySelector('root > Database > Accounts > Account > ' +
17590 'LoginLinks > Login[SourceLoginID="' + accountId + '"]');
17591 if (accountLogin != null) {
17592 const account = accountLogin.parentElement.parentElement;
17593 if (account != null) {
17594 titleText = account.getAttribute('Name');
17595 linkText = account.getAttribute('Link');
17596 groupId = account.getAttribute('ParentID');
17597 notesText = account.getAttribute('Comments');
17598 if (!this.isNullOrWhitespace(notesText)) {
17599 notesText = notesText.split('/n').join('\n');
17600 }
17601 }
17602 }
17603 if (!this.isNullOrWhitespace(groupId)) {
17604 groupText = this.buildGroupText(doc, groupId, '');
17605 this.processFolder(result, groupText);
17606 }
17607 const cipher = this.initLoginCipher();
17608 cipher.name = this.getValueOrDefault(titleText, '--');
17609 cipher.notes = this.getValueOrDefault(notesText);
17610 cipher.login.username = this.getValueOrDefault(usernameText);
17611 cipher.login.password = this.getValueOrDefault(passwordText);
17612 cipher.login.uris = this.makeUriArray(linkText);
17613 this.cleanupCipher(cipher);
17614 result.ciphers.push(cipher);
17615 });
17616 if (this.organization) {
17617 this.moveFoldersToCollections(result);
17618 }
17619 result.success = true;
17620 return result;
17621 }
17622 buildGroupText(doc, groupId, groupText) {
17623 const group = doc.querySelector('root > Database > Groups > Group[ID="' + groupId + '"]');
17624 if (group == null) {
17625 return groupText;
17626 }
17627 if (!this.isNullOrWhitespace(groupText)) {
17628 groupText = '/' + groupText;
17629 }
17630 groupText = group.getAttribute('Name') + groupText;
17631 return this.buildGroupText(doc, group.getAttribute('ParentID'), groupText);
17632 }
17633}
17634
17635// CONCATENATED MODULE: ./jslib/src/importers/truekeyCsvImporter.ts
17636
17637
17638
17639
17640
17641
17642const PropertiesToIgnore = ['kind', 'autologin', 'favorite', 'hexcolor', 'protectedwithpassword', 'subdomainonly',
17643 'type', 'tk_export_version', 'note', 'title', 'document_content',
17644];
17645class truekeyCsvImporter_TrueKeyCsvImporter extends baseImporter_BaseImporter {
17646 parse(data) {
17647 const result = new ImportResult();
17648 const results = this.parseCsv(data, true);
17649 if (results == null) {
17650 result.success = false;
17651 return result;
17652 }
17653 results.forEach((value) => {
17654 const cipher = this.initLoginCipher();
17655 cipher.favorite = this.getValueOrDefault(value.favorite, '').toLowerCase() === 'true';
17656 cipher.name = this.getValueOrDefault(value.name, '--');
17657 cipher.notes = this.getValueOrDefault(value.memo, '');
17658 cipher.login.username = this.getValueOrDefault(value.login);
17659 cipher.login.password = this.getValueOrDefault(value.password);
17660 cipher.login.uris = this.makeUriArray(value.url);
17661 if (value.kind !== 'login') {
17662 cipher.name = this.getValueOrDefault(value.title, '--');
17663 cipher.notes = this.getValueOrDefault(value.note, '');
17664 }
17665 if (value.kind === 'cc') {
17666 cipher.type = CipherType.Card;
17667 cipher.card = new CardView();
17668 cipher.card.cardholderName = this.getValueOrDefault(value.cardholder);
17669 cipher.card.number = this.getValueOrDefault(value.number);
17670 cipher.card.brand = this.getCardBrand(cipher.card.number);
17671 if (!this.isNullOrWhitespace(value.expiryDate)) {
17672 try {
17673 const expDate = new Date(value.expiryDate);
17674 cipher.card.expYear = expDate.getFullYear().toString();
17675 cipher.card.expMonth = (expDate.getMonth() + 1).toString();
17676 }
17677 catch (_a) { }
17678 }
17679 }
17680 else if (value.kind !== 'login') {
17681 cipher.type = CipherType.SecureNote;
17682 cipher.secureNote = new SecureNoteView();
17683 cipher.secureNote.type = SecureNoteType.Generic;
17684 if (!this.isNullOrWhitespace(cipher.notes)) {
17685 cipher.notes = this.getValueOrDefault(value.document_content, '');
17686 }
17687 for (const property in value) {
17688 if (value.hasOwnProperty(property) && PropertiesToIgnore.indexOf(property.toLowerCase()) < 0 &&
17689 !this.isNullOrWhitespace(value[property])) {
17690 this.processKvp(cipher, property, value[property]);
17691 }
17692 }
17693 }
17694 this.cleanupCipher(cipher);
17695 result.ciphers.push(cipher);
17696 });
17697 result.success = true;
17698 return result;
17699 }
17700}
17701
17702// CONCATENATED MODULE: ./jslib/src/importers/upmCsvImporter.ts
17703
17704
17705class upmCsvImporter_UpmCsvImporter extends baseImporter_BaseImporter {
17706 parse(data) {
17707 const result = new ImportResult();
17708 const results = this.parseCsv(data, false);
17709 if (results == null) {
17710 result.success = false;
17711 return result;
17712 }
17713 results.forEach((value) => {
17714 if (value.length !== 5) {
17715 return;
17716 }
17717 const cipher = this.initLoginCipher();
17718 cipher.name = this.getValueOrDefault(value[0], '--');
17719 cipher.notes = this.getValueOrDefault(value[4]);
17720 cipher.login.username = this.getValueOrDefault(value[1]);
17721 cipher.login.password = this.getValueOrDefault(value[2]);
17722 cipher.login.uris = this.makeUriArray(value[3]);
17723 this.cleanupCipher(cipher);
17724 result.ciphers.push(cipher);
17725 });
17726 result.success = true;
17727 return result;
17728 }
17729}
17730
17731// CONCATENATED MODULE: ./jslib/src/importers/zohoVaultCsvImporter.ts
17732
17733
17734class zohoVaultCsvImporter_ZohoVaultCsvImporter extends baseImporter_BaseImporter {
17735 parse(data) {
17736 const result = new ImportResult();
17737 const results = this.parseCsv(data, true);
17738 if (results == null) {
17739 result.success = false;
17740 return result;
17741 }
17742 results.forEach((value) => {
17743 if (this.isNullOrWhitespace(value['Password Name']) && this.isNullOrWhitespace(value['Secret Name'])) {
17744 return;
17745 }
17746 this.processFolder(result, this.getValueOrDefault(value.ChamberName));
17747 const cipher = this.initLoginCipher();
17748 cipher.favorite = this.getValueOrDefault(value.Favorite, '0') === '1';
17749 cipher.notes = this.getValueOrDefault(value.Notes);
17750 cipher.name = this.getValueOrDefault(value['Password Name'], this.getValueOrDefault(value['Secret Name'], '--'));
17751 cipher.login.uris = this.makeUriArray(this.getValueOrDefault(value['Password URL'], this.getValueOrDefault(value['Secret URL'])));
17752 this.parseData(cipher, value.SecretData);
17753 this.parseData(cipher, value.CustomData);
17754 this.convertToNoteIfNeeded(cipher);
17755 this.cleanupCipher(cipher);
17756 result.ciphers.push(cipher);
17757 });
17758 if (this.organization) {
17759 this.moveFoldersToCollections(result);
17760 }
17761 result.success = true;
17762 return result;
17763 }
17764 parseData(cipher, data) {
17765 if (this.isNullOrWhitespace(data)) {
17766 return;
17767 }
17768 const dataLines = this.splitNewLine(data);
17769 dataLines.forEach((line) => {
17770 const delimPosition = line.indexOf(':');
17771 if (delimPosition < 0) {
17772 return;
17773 }
17774 const field = line.substring(0, delimPosition);
17775 const value = line.length > delimPosition ? line.substring(delimPosition + 1) : null;
17776 if (this.isNullOrWhitespace(field) || this.isNullOrWhitespace(value) || field === 'SecretType') {
17777 return;
17778 }
17779 const fieldLower = field.toLowerCase();
17780 if (cipher.login.username == null && this.usernameFieldNames.indexOf(fieldLower) > -1) {
17781 cipher.login.username = value;
17782 }
17783 else if (cipher.login.password == null && this.passwordFieldNames.indexOf(fieldLower) > -1) {
17784 cipher.login.password = value;
17785 }
17786 else {
17787 this.processKvp(cipher, field, value);
17788 }
17789 });
17790 }
17791}
17792
17793// CONCATENATED MODULE: ./jslib/src/services/import.service.ts
17794var import_service_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
17795 return new (P || (P = Promise))(function (resolve, reject) {
17796 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17797 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
17798 function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
17799 step((generator = generator.apply(thisArg, _arguments || [])).next());
17800 });
17801};
17802
17803
17804
17805
17806
17807
17808
17809
17810
17811
17812
17813
17814
17815
17816
17817
17818
17819
17820
17821
17822
17823
17824
17825
17826
17827
17828
17829
17830
17831
17832
17833
17834
17835
17836
17837
17838
17839
17840
17841
17842
17843
17844
17845
17846
17847
17848
17849
17850
17851
17852
17853
17854
17855
17856
17857
17858
17859class import_service_ImportService {
17860 constructor(cipherService, folderService, apiService, i18nService, collectionService) {
17861 this.cipherService = cipherService;
17862 this.folderService = folderService;
17863 this.apiService = apiService;
17864 this.i18nService = i18nService;
17865 this.collectionService = collectionService;
17866 this.featuredImportOptions = [
17867 { id: 'bitwardenjson', name: 'Bitwarden (json)' },
17868 { id: 'bitwardencsv', name: 'Bitwarden (csv)' },
17869 { id: 'lastpasscsv', name: 'LastPass (csv)' },
17870 { id: 'chromecsv', name: 'Chrome (csv)' },
17871 { id: 'firefoxcsv', name: 'Firefox (csv)' },
17872 { id: 'keepass2xml', name: 'KeePass 2 (xml)' },
17873 { id: '1password1pif', name: '1Password (1pif)' },
17874 { id: 'dashlanejson', name: 'Dashlane (json)' },
17875 ];
17876 this.regularImportOptions = [
17877 { id: 'keepassxcsv', name: 'KeePassX (csv)' },
17878 { id: '1passwordwincsv', name: '1Password 6 and 7 Windows (csv)' },
17879 { id: 'roboformcsv', name: 'RoboForm (csv)' },
17880 { id: 'keepercsv', name: 'Keeper (csv)' },
17881 { id: 'enpasscsv', name: 'Enpass (csv)' },
17882 { id: 'enpassjson', name: 'Enpass (json)' },
17883 { id: 'safeincloudxml', name: 'SafeInCloud (xml)' },
17884 { id: 'pwsafexml', name: 'Password Safe (xml)' },
17885 { id: 'stickypasswordxml', name: 'Sticky Password (xml)' },
17886 { id: 'msecurecsv', name: 'mSecure (csv)' },
17887 { id: 'truekeycsv', name: 'True Key (csv)' },
17888 { id: 'passwordbossjson', name: 'Password Boss (json)' },
17889 { id: 'zohovaultcsv', name: 'Zoho Vault (csv)' },
17890 { id: 'splashidcsv', name: 'SplashID (csv)' },
17891 { id: 'passworddragonxml', name: 'Password Dragon (xml)' },
17892 { id: 'padlockcsv', name: 'Padlock (csv)' },
17893 { id: 'passboltcsv', name: 'Passbolt (csv)' },
17894 { id: 'clipperzhtml', name: 'Clipperz (html)' },
17895 { id: 'aviracsv', name: 'Avira (csv)' },
17896 { id: 'saferpasscsv', name: 'SaferPass (csv)' },
17897 { id: 'upmcsv', name: 'Universal Password Manager (csv)' },
17898 { id: 'ascendocsv', name: 'Ascendo DataVault (csv)' },
17899 { id: 'meldiumcsv', name: 'Meldium (csv)' },
17900 { id: 'passkeepcsv', name: 'PassKeep (csv)' },
17901 { id: 'operacsv', name: 'Opera (csv)' },
17902 { id: 'vivaldicsv', name: 'Vivaldi (csv)' },
17903 { id: 'gnomejson', name: 'GNOME Passwords and Keys/Seahorse (json)' },
17904 { id: 'blurcsv', name: 'Blur (csv)' },
17905 { id: 'passwordagentcsv', name: 'Password Agent (csv)' },
17906 { id: 'passpackcsv', name: 'Passpack (csv)' },
17907 { id: 'passmanjson', name: 'Passman (json)' },
17908 { id: 'avastcsv', name: 'Avast Passwords (csv)' },
17909 { id: 'avastjson', name: 'Avast Passwords (json)' },
17910 { id: 'fsecurefsk', name: 'F-Secure KEY (fsk)' },
17911 { id: 'kasperskytxt', name: 'Kaspersky Password Manager (txt)' },
17912 { id: 'remembearcsv', name: 'RememBear (csv)' },
17913 { id: 'passwordwallettxt', name: 'PasswordWallet (txt)' },
17914 { id: 'mykicsv', name: 'Myki (csv)' },
17915 { id: 'securesafecsv', name: 'SecureSafe (csv)' },
17916 { id: 'logmeoncecsv', name: 'LogMeOnce (csv)' },
17917 { id: 'blackberrycsv', name: 'BlackBerry Password Keeper (csv)' },
17918 { id: 'buttercupcsv', name: 'Buttercup (csv)' },
17919 { id: 'codebookcsv', name: 'Codebook (csv)' },
17920 { id: 'encryptrcsv', name: 'Encryptr (csv)' },
17921 ];
17922 }
17923 getImportOptions() {
17924 return this.featuredImportOptions.concat(this.regularImportOptions);
17925 }
17926 import(importer, fileContents, organizationId = null) {
17927 return import_service_awaiter(this, void 0, void 0, function* () {
17928 const importResult = yield importer.parse(fileContents);
17929 if (importResult.success) {
17930 if (importResult.folders.length === 0 && importResult.ciphers.length === 0) {
17931 return new Error(this.i18nService.t('importNothingError'));
17932 }
17933 else if (importResult.ciphers.length > 0) {
17934 const halfway = Math.floor(importResult.ciphers.length / 2);
17935 const last = importResult.ciphers.length - 1;
17936 if (this.badData(importResult.ciphers[0]) &&
17937 this.badData(importResult.ciphers[halfway]) &&
17938 this.badData(importResult.ciphers[last])) {
17939 return new Error(this.i18nService.t('importFormatError'));
17940 }
17941 }
17942 yield this.postImport(importResult, organizationId);
17943 return null;
17944 }
17945 else {
17946 return new Error(this.i18nService.t('importFormatError'));
17947 }
17948 });
17949 }
17950 getImporter(format, organization = false) {
17951 const importer = this.getImporterInstance(format);
17952 if (importer == null) {
17953 return null;
17954 }
17955 importer.organization = organization;
17956 return importer;
17957 }
17958 getImporterInstance(format) {
17959 if (format == null || format === '') {
17960 return null;
17961 }
17962 switch (format) {
17963 case 'bitwardencsv':
17964 return new bitwardenCsvImporter_BitwardenCsvImporter();
17965 case 'bitwardenjson':
17966 return new bitwardenJsonImporter_BitwardenJsonImporter();
17967 case 'lastpasscsv':
17968 case 'passboltcsv':
17969 return new lastpassCsvImporter_LastPassCsvImporter();
17970 case 'keepassxcsv':
17971 return new keepassxCsvImporter_KeePassXCsvImporter();
17972 case 'aviracsv':
17973 return new aviraCsvImporter_AviraCsvImporter();
17974 case 'blurcsv':
17975 return new blurCsvImporter_BlurCsvImporter();
17976 case 'safeincloudxml':
17977 return new safeInCloudXmlImporter_SafeInCloudXmlImporter();
17978 case 'padlockcsv':
17979 return new padlockCsvImporter_PadlockCsvImporter();
17980 case 'keepass2xml':
17981 return new keepass2XmlImporter_KeePass2XmlImporter();
17982 case 'chromecsv':
17983 case 'operacsv':
17984 case 'vivaldicsv':
17985 return new chromeCsvImporter_ChromeCsvImporter();
17986 case 'firefoxcsv':
17987 return new firefoxCsvImporter_FirefoxCsvImporter();
17988 case 'upmcsv':
17989 return new upmCsvImporter_UpmCsvImporter();
17990 case 'saferpasscsv':
17991 return new saferpassCsvImport_SaferPassCsvImporter();
17992 case 'meldiumcsv':
17993 return new meldiumCsvImporter_MeldiumCsvImporter();
17994 case '1password1pif':
17995 return new onepassword1PifImporter_OnePassword1PifImporter();
17996 case '1passwordwincsv':
17997 return new onepasswordWinCsvImporter_OnePasswordWinCsvImporter();
17998 case 'keepercsv':
17999 return new keeperCsvImporter_KeeperCsvImporter();
18000 case 'passworddragonxml':
18001 return new passwordDragonXmlImporter_PasswordDragonXmlImporter();
18002 case 'enpasscsv':
18003 return new enpassCsvImporter_EnpassCsvImporter();
18004 case 'enpassjson':
18005 return new enpassJsonImporter_EnpassJsonImporter();
18006 case 'pwsafexml':
18007 return new passwordSafeXmlImporter_PasswordSafeXmlImporter();
18008 case 'dashlanejson':
18009 return new dashlaneJsonImporter_DashlaneJsonImporter();
18010 case 'msecurecsv':
18011 return new msecureCsvImporter_MSecureCsvImporter();
18012 case 'stickypasswordxml':
18013 return new stickyPasswordXmlImporter_StickyPasswordXmlImporter();
18014 case 'truekeycsv':
18015 return new truekeyCsvImporter_TrueKeyCsvImporter();
18016 case 'clipperzhtml':
18017 return new clipperzHtmlImporter_ClipperzHtmlImporter();
18018 case 'roboformcsv':
18019 return new roboformCsvImporter_RoboFormCsvImporter();
18020 case 'ascendocsv':
18021 return new ascendoCsvImporter_AscendoCsvImporter();
18022 case 'passwordbossjson':
18023 return new passwordBossJsonImporter_PasswordBossJsonImporter();
18024 case 'zohovaultcsv':
18025 return new zohoVaultCsvImporter_ZohoVaultCsvImporter();
18026 case 'splashidcsv':
18027 return new splashIdCsvImporter_SplashIdCsvImporter();
18028 case 'passkeepcsv':
18029 return new passkeepCsvImporter_PassKeepCsvImporter();
18030 case 'gnomejson':
18031 return new gnomeJsonImporter_GnomeJsonImporter();
18032 case 'passwordagentcsv':
18033 return new passwordAgentCsvImporter_PasswordAgentCsvImporter();
18034 case 'passpackcsv':
18035 return new passpackCsvImporter_PasspackCsvImporter();
18036 case 'passmanjson':
18037 return new passmanJsonImporter_PassmanJsonImporter();
18038 case 'avastcsv':
18039 return new avastCsvImporter_AvastCsvImporter();
18040 case 'avastjson':
18041 return new avastJsonImporter_AvastJsonImporter();
18042 case 'fsecurefsk':
18043 return new fsecureFskImporter_FSecureFskImporter();
18044 case 'kasperskytxt':
18045 return new kasperskyTxtImporter_KasperskyTxtImporter();
18046 case 'remembearcsv':
18047 return new rememBearCsvImporter_RememBearCsvImporter();
18048 case 'passwordwallettxt':
18049 return new passwordWalletTxtImporter_PasswordWalletTxtImporter();
18050 case 'mykicsv':
18051 return new mykiCsvImporter_MykiCsvImporter();
18052 case 'securesafecsv':
18053 return new secureSafeCsvImporter_SecureSafeCsvImporter();
18054 case 'logmeoncecsv':
18055 return new logMeOnceCsvImporter_LogMeOnceCsvImporter();
18056 case 'blackberrycsv':
18057 return new blackBerryCsvImporter_BlackBerryCsvImporter();
18058 case 'buttercupcsv':
18059 return new buttercupCsvImporter_ButtercupCsvImporter();
18060 case 'codebookcsv':
18061 return new codebookCsvImporter_CodebookCsvImporter();
18062 case 'encryptrcsv':
18063 return new encryptrCsvImporter_EncryptrCsvImporter();
18064 default:
18065 return null;
18066 }
18067 }
18068 postImport(importResult, organizationId = null) {
18069 return import_service_awaiter(this, void 0, void 0, function* () {
18070 if (organizationId == null) {
18071 const request = new ImportCiphersRequest();
18072 for (let i = 0; i < importResult.ciphers.length; i++) {
18073 const c = yield this.cipherService.encrypt(importResult.ciphers[i]);
18074 request.ciphers.push(new cipherRequest_CipherRequest(c));
18075 }
18076 if (importResult.folders != null) {
18077 for (let i = 0; i < importResult.folders.length; i++) {
18078 const f = yield this.folderService.encrypt(importResult.folders[i]);
18079 request.folders.push(new FolderRequest(f));
18080 }
18081 }
18082 if (importResult.folderRelationships != null) {
18083 importResult.folderRelationships.forEach((r) => request.folderRelationships.push(new KvpRequest(r[0], r[1])));
18084 }
18085 return yield this.apiService.postImportCiphers(request);
18086 }
18087 else {
18088 const request = new ImportOrganizationCiphersRequest();
18089 for (let i = 0; i < importResult.ciphers.length; i++) {
18090 importResult.ciphers[i].organizationId = organizationId;
18091 const c = yield this.cipherService.encrypt(importResult.ciphers[i]);
18092 request.ciphers.push(new cipherRequest_CipherRequest(c));
18093 }
18094 if (importResult.collections != null) {
18095 for (let i = 0; i < importResult.collections.length; i++) {
18096 importResult.collections[i].organizationId = organizationId;
18097 const c = yield this.collectionService.encrypt(importResult.collections[i]);
18098 request.collections.push(new CollectionRequest(c));
18099 }
18100 }
18101 if (importResult.collectionRelationships != null) {
18102 importResult.collectionRelationships.forEach((r) => request.collectionRelationships.push(new KvpRequest(r[0], r[1])));
18103 }
18104 return yield this.apiService.postImportOrganizationCiphers(organizationId, request);
18105 }
18106 });
18107 }
18108 badData(c) {
18109 return (c.name == null || c.name === '--') &&
18110 (c.type === CipherType.Login && c.login != null && utils_Utils.isNullOrWhitespace(c.login.password));
18111 }
18112}
18113
18114// EXTERNAL MODULE: external "lowdb"
18115var external_lowdb_ = __webpack_require__(11);
18116
18117// EXTERNAL MODULE: external "lowdb/adapters/FileSync"
18118var FileSync_ = __webpack_require__(14);
18119
18120// EXTERNAL MODULE: external "readline"
18121var external_readline_ = __webpack_require__(15);
18122
18123// CONCATENATED MODULE: ./jslib/src/misc/nodeUtils.ts
18124
18125
18126
18127class nodeUtils_NodeUtils {
18128 static mkdirpSync(targetDir, mode = '700', relative = false, relativeDir = null) {
18129 const initialDir = external_path_["isAbsolute"](targetDir) ? external_path_["sep"] : '';
18130 const baseDir = relative ? (relativeDir != null ? relativeDir : __dirname) : '.';
18131 targetDir.split(external_path_["sep"]).reduce((parentDir, childDir) => {
18132 const dir = external_path_["resolve"](baseDir, parentDir, childDir);
18133 if (!external_fs_["existsSync"](dir)) {
18134 external_fs_["mkdirSync"](dir, mode);
18135 }
18136 return dir;
18137 }, initialDir);
18138 }
18139 static readFirstLine(fileName) {
18140 return new Promise((resolve, reject) => {
18141 const readStream = external_fs_["createReadStream"](fileName, { encoding: 'utf8' });
18142 const readInterface = external_readline_["createInterface"](readStream);
18143 readInterface
18144 .on('line', (line) => {
18145 readStream.close();
18146 resolve(line);
18147 })
18148 .on('error', (err) => reject(err));
18149 });
18150 }
18151}
18152
18153// CONCATENATED MODULE: ./jslib/src/services/lowdbStorage.service.ts
18154
18155
18156
18157
18158
18159
18160class lowdbStorage_service_LowdbStorageService {
18161 constructor(defaults, dir, allowCache = false) {
18162 this.allowCache = allowCache;
18163 this.defaults = defaults;
18164 let adapter;
18165 if (utils_Utils.isNode && dir != null) {
18166 if (!external_fs_["existsSync"](dir)) {
18167 nodeUtils_NodeUtils.mkdirpSync(dir, '700');
18168 }
18169 this.dataFilePath = external_path_["join"](dir, 'data.json');
18170 adapter = new FileSync_(this.dataFilePath);
18171 }
18172 try {
18173 this.db = external_lowdb_(adapter);
18174 }
18175 catch (e) {
18176 if (e instanceof SyntaxError) {
18177 adapter.write({});
18178 this.db = external_lowdb_(adapter);
18179 }
18180 else {
18181 throw e;
18182 }
18183 }
18184 }
18185 init() {
18186 if (this.defaults != null) {
18187 this.readForNoCache();
18188 this.db.defaults(this.defaults).write();
18189 }
18190 }
18191 get(key) {
18192 this.readForNoCache();
18193 const val = this.db.get(key).value();
18194 if (val == null) {
18195 return Promise.resolve(null);
18196 }
18197 return Promise.resolve(val);
18198 }
18199 save(key, obj) {
18200 this.readForNoCache();
18201 this.db.set(key, obj).write();
18202 return Promise.resolve();
18203 }
18204 remove(key) {
18205 this.readForNoCache();
18206 this.db.unset(key).write();
18207 return Promise.resolve();
18208 }
18209 readForNoCache() {
18210 if (!this.allowCache) {
18211 this.db.read();
18212 }
18213 }
18214}
18215
18216// EXTERNAL MODULE: external "form-data"
18217var external_form_data_ = __webpack_require__(16);
18218
18219// EXTERNAL MODULE: external "https-proxy-agent"
18220var external_https_proxy_agent_ = __webpack_require__(17);
18221
18222// EXTERNAL MODULE: external "node-fetch"
18223var external_node_fetch_ = __webpack_require__(4);
18224var external_node_fetch_default = /*#__PURE__*/__webpack_require__.n(external_node_fetch_);
18225
18226// CONCATENATED MODULE: ./jslib/src/models/response/apiKeyResponse.ts
18227
18228class apiKeyResponse_ApiKeyResponse extends BaseResponse {
18229 constructor(response) {
18230 super(response);
18231 this.apiKey = this.getResponseProperty('ApiKey');
18232 }
18233}
18234
18235// CONCATENATED MODULE: ./jslib/src/models/response/billingResponse.ts
18236
18237class billingResponse_BillingResponse extends BaseResponse {
18238 constructor(response) {
18239 super(response);
18240 this.invoices = [];
18241 this.transactions = [];
18242 this.balance = this.getResponseProperty('Balance');
18243 const paymentSource = this.getResponseProperty('PaymentSource');
18244 const transactions = this.getResponseProperty('Transactions');
18245 const invoices = this.getResponseProperty('Invoices');
18246 this.paymentSource = paymentSource == null ? null : new billingResponse_BillingSourceResponse(paymentSource);
18247 if (transactions != null) {
18248 this.transactions = transactions.map((t) => new billingResponse_BillingTransactionResponse(t));
18249 }
18250 if (invoices != null) {
18251 this.invoices = invoices.map((i) => new billingResponse_BillingInvoiceResponse(i));
18252 }
18253 }
18254}
18255class billingResponse_BillingSourceResponse extends BaseResponse {
18256 constructor(response) {
18257 super(response);
18258 this.type = this.getResponseProperty('Type');
18259 this.cardBrand = this.getResponseProperty('CardBrand');
18260 this.description = this.getResponseProperty('Description');
18261 this.needsVerification = this.getResponseProperty('NeedsVerification');
18262 }
18263}
18264class billingResponse_BillingInvoiceResponse extends BaseResponse {
18265 constructor(response) {
18266 super(response);
18267 this.url = this.getResponseProperty('Url');
18268 this.pdfUrl = this.getResponseProperty('PdfUrl');
18269 this.number = this.getResponseProperty('Number');
18270 this.paid = this.getResponseProperty('Paid');
18271 this.date = this.getResponseProperty('Date');
18272 this.amount = this.getResponseProperty('Amount');
18273 }
18274}
18275class billingResponse_BillingTransactionResponse extends BaseResponse {
18276 constructor(response) {
18277 super(response);
18278 this.createdDate = this.getResponseProperty('CreatedDate');
18279 this.amount = this.getResponseProperty('Amount');
18280 this.refunded = this.getResponseProperty('Refunded');
18281 this.partiallyRefunded = this.getResponseProperty('PartiallyRefunded');
18282 this.refundedAmount = this.getResponseProperty('RefundedAmount');
18283 this.type = this.getResponseProperty('Type');
18284 this.paymentMethodType = this.getResponseProperty('PaymentMethodType');
18285 this.details = this.getResponseProperty('Details');
18286 }
18287}
18288
18289// CONCATENATED MODULE: ./jslib/src/models/response/breachAccountResponse.ts
18290
18291class breachAccountResponse_BreachAccountResponse extends BaseResponse {
18292 constructor(response) {
18293 super(response);
18294 this.addedDate = this.getResponseProperty('AddedDate');
18295 this.breachDate = this.getResponseProperty('BreachDate');
18296 this.dataClasses = this.getResponseProperty('DataClasses');
18297 this.description = this.getResponseProperty('Description');
18298 this.domain = this.getResponseProperty('Domain');
18299 this.isActive = this.getResponseProperty('IsActive');
18300 this.isVerified = this.getResponseProperty('IsVerified');
18301 this.logoPath = this.getResponseProperty('LogoPath');
18302 this.modifiedDate = this.getResponseProperty('ModifiedDate');
18303 this.name = this.getResponseProperty('Name');
18304 this.pwnCount = this.getResponseProperty('PwnCount');
18305 this.title = this.getResponseProperty('Title');
18306 }
18307}
18308
18309// CONCATENATED MODULE: ./jslib/src/models/response/attachmentResponse.ts
18310
18311class attachmentResponse_AttachmentResponse extends BaseResponse {
18312 constructor(response) {
18313 super(response);
18314 this.id = this.getResponseProperty('Id');
18315 this.url = this.getResponseProperty('Url');
18316 this.fileName = this.getResponseProperty('FileName');
18317 this.key = this.getResponseProperty('Key');
18318 this.size = this.getResponseProperty('Size');
18319 this.sizeName = this.getResponseProperty('SizeName');
18320 }
18321}
18322
18323// CONCATENATED MODULE: ./jslib/src/models/response/passwordHistoryResponse.ts
18324
18325class passwordHistoryResponse_PasswordHistoryResponse extends BaseResponse {
18326 constructor(response) {
18327 super(response);
18328 this.password = this.getResponseProperty('Password');
18329 this.lastUsedDate = this.getResponseProperty('LastUsedDate');
18330 }
18331}
18332
18333// CONCATENATED MODULE: ./jslib/src/models/response/cipherResponse.ts
18334
18335
18336
18337
18338
18339
18340
18341
18342class cipherResponse_CipherResponse extends BaseResponse {
18343 constructor(response) {
18344 super(response);
18345 this.id = this.getResponseProperty('Id');
18346 this.organizationId = this.getResponseProperty('OrganizationId');
18347 this.folderId = this.getResponseProperty('FolderId') || null;
18348 this.type = this.getResponseProperty('Type');
18349 this.name = this.getResponseProperty('Name');
18350 this.notes = this.getResponseProperty('Notes');
18351 this.favorite = this.getResponseProperty('Favorite') || false;
18352 this.edit = !!this.getResponseProperty('Edit');
18353 if (this.getResponseProperty('ViewPassword') == null) {
18354 this.viewPassword = true;
18355 }
18356 else {
18357 this.viewPassword = this.getResponseProperty('ViewPassword');
18358 }
18359 this.organizationUseTotp = this.getResponseProperty('OrganizationUseTotp');
18360 this.revisionDate = this.getResponseProperty('RevisionDate');
18361 this.collectionIds = this.getResponseProperty('CollectionIds');
18362 this.deletedDate = this.getResponseProperty('DeletedDate');
18363 const login = this.getResponseProperty('Login');
18364 if (login != null) {
18365 this.login = new loginApi_LoginApi(login);
18366 }
18367 const card = this.getResponseProperty('Card');
18368 if (card != null) {
18369 this.card = new cardApi_CardApi(card);
18370 }
18371 const identity = this.getResponseProperty('Identity');
18372 if (identity != null) {
18373 this.identity = new identityApi_IdentityApi(identity);
18374 }
18375 const secureNote = this.getResponseProperty('SecureNote');
18376 if (secureNote != null) {
18377 this.secureNote = new secureNoteApi_SecureNoteApi(secureNote);
18378 }
18379 const fields = this.getResponseProperty('Fields');
18380 if (fields != null) {
18381 this.fields = fields.map((f) => new fieldApi_FieldApi(f));
18382 }
18383 const attachments = this.getResponseProperty('Attachments');
18384 if (attachments != null) {
18385 this.attachments = attachments.map((a) => new attachmentResponse_AttachmentResponse(a));
18386 }
18387 const passwordHistory = this.getResponseProperty('PasswordHistory');
18388 if (passwordHistory != null) {
18389 this.passwordHistory = passwordHistory.map((h) => new passwordHistoryResponse_PasswordHistoryResponse(h));
18390 }
18391 }
18392}
18393
18394// CONCATENATED MODULE: ./jslib/src/models/response/selectionReadOnlyResponse.ts
18395
18396class selectionReadOnlyResponse_SelectionReadOnlyResponse extends BaseResponse {
18397 constructor(response) {
18398 super(response);
18399 this.id = this.getResponseProperty('Id');
18400 this.readOnly = this.getResponseProperty('ReadOnly');
18401 this.hidePasswords = this.getResponseProperty('HidePasswords');
18402 }
18403}
18404
18405// CONCATENATED MODULE: ./jslib/src/models/response/collectionResponse.ts
18406
18407
18408class collectionResponse_CollectionResponse extends BaseResponse {
18409 constructor(response) {
18410 super(response);
18411 this.id = this.getResponseProperty('Id');
18412 this.organizationId = this.getResponseProperty('OrganizationId');
18413 this.name = this.getResponseProperty('Name');
18414 this.externalId = this.getResponseProperty('ExternalId');
18415 }
18416}
18417class CollectionDetailsResponse extends collectionResponse_CollectionResponse {
18418 constructor(response) {
18419 super(response);
18420 this.readOnly = this.getResponseProperty('ReadOnly') || false;
18421 }
18422}
18423class collectionResponse_CollectionGroupDetailsResponse extends collectionResponse_CollectionResponse {
18424 constructor(response) {
18425 super(response);
18426 this.groups = [];
18427 const groups = this.getResponseProperty('Groups');
18428 if (groups != null) {
18429 this.groups = groups.map((g) => new selectionReadOnlyResponse_SelectionReadOnlyResponse(g));
18430 }
18431 }
18432}
18433
18434// CONCATENATED MODULE: ./jslib/src/models/response/globalDomainResponse.ts
18435
18436class globalDomainResponse_GlobalDomainResponse extends BaseResponse {
18437 constructor(response) {
18438 super(response);
18439 this.type = this.getResponseProperty('Type');
18440 this.domains = this.getResponseProperty('Domains');
18441 this.excluded = this.getResponseProperty('Excluded');
18442 }
18443}
18444
18445// CONCATENATED MODULE: ./jslib/src/models/response/domainsResponse.ts
18446
18447
18448class domainsResponse_DomainsResponse extends BaseResponse {
18449 constructor(response) {
18450 super(response);
18451 this.globalEquivalentDomains = [];
18452 this.equivalentDomains = this.getResponseProperty('EquivalentDomains');
18453 const globalEquivalentDomains = this.getResponseProperty('GlobalEquivalentDomains');
18454 if (globalEquivalentDomains != null) {
18455 this.globalEquivalentDomains = globalEquivalentDomains.map((d) => new globalDomainResponse_GlobalDomainResponse(d));
18456 }
18457 else {
18458 this.globalEquivalentDomains = [];
18459 }
18460 }
18461}
18462
18463// CONCATENATED MODULE: ./jslib/src/models/response/errorResponse.ts
18464
18465class errorResponse_ErrorResponse extends BaseResponse {
18466 constructor(response, status, identityResponse) {
18467 super(response);
18468 let errorModel = null;
18469 if (response != null) {
18470 const responseErrorModel = this.getResponseProperty('ErrorModel');
18471 if (responseErrorModel && identityResponse) {
18472 errorModel = responseErrorModel;
18473 }
18474 else {
18475 errorModel = response;
18476 }
18477 }
18478 if (errorModel) {
18479 this.message = this.getResponseProperty('Message', errorModel);
18480 this.validationErrors = this.getResponseProperty('ValidationErrors', errorModel);
18481 }
18482 else {
18483 if (status === 429) {
18484 this.message = 'Rate limit exceeded. Try again later.';
18485 }
18486 }
18487 this.statusCode = status;
18488 }
18489 getSingleMessage() {
18490 if (this.validationErrors == null) {
18491 return this.message;
18492 }
18493 for (const key in this.validationErrors) {
18494 if (!this.validationErrors.hasOwnProperty(key)) {
18495 continue;
18496 }
18497 if (this.validationErrors[key].length) {
18498 return this.validationErrors[key][0];
18499 }
18500 }
18501 return this.message;
18502 }
18503 getAllMessages() {
18504 const messages = [];
18505 if (this.validationErrors == null) {
18506 return messages;
18507 }
18508 for (const key in this.validationErrors) {
18509 if (!this.validationErrors.hasOwnProperty(key)) {
18510 continue;
18511 }
18512 this.validationErrors[key].forEach((item) => {
18513 let prefix = '';
18514 if (key.indexOf('[') > -1 && key.indexOf(']') > -1) {
18515 const lastSep = key.lastIndexOf('.');
18516 prefix = key.substr(0, lastSep > -1 ? lastSep : key.length) + ': ';
18517 }
18518 messages.push(prefix + item);
18519 });
18520 }
18521 return messages;
18522 }
18523}
18524
18525// CONCATENATED MODULE: ./jslib/src/models/response/eventResponse.ts
18526
18527class eventResponse_EventResponse extends BaseResponse {
18528 constructor(response) {
18529 super(response);
18530 this.type = this.getResponseProperty('Type');
18531 this.userId = this.getResponseProperty('UserId');
18532 this.organizationId = this.getResponseProperty('OrganizationId');
18533 this.cipherId = this.getResponseProperty('CipherId');
18534 this.collectionId = this.getResponseProperty('CollectionId');
18535 this.groupId = this.getResponseProperty('GroupId');
18536 this.organizationUserId = this.getResponseProperty('OrganizationUserId');
18537 this.actingUserId = this.getResponseProperty('ActingUserId');
18538 this.date = this.getResponseProperty('Date');
18539 this.deviceType = this.getResponseProperty('DeviceType');
18540 this.ipAddress = this.getResponseProperty('IpAddress');
18541 }
18542}
18543
18544// CONCATENATED MODULE: ./jslib/src/models/response/folderResponse.ts
18545
18546class folderResponse_FolderResponse extends BaseResponse {
18547 constructor(response) {
18548 super(response);
18549 this.id = this.getResponseProperty('Id');
18550 this.name = this.getResponseProperty('Name');
18551 this.revisionDate = this.getResponseProperty('RevisionDate');
18552 }
18553}
18554
18555// CONCATENATED MODULE: ./jslib/src/models/response/groupResponse.ts
18556
18557
18558class groupResponse_GroupResponse extends BaseResponse {
18559 constructor(response) {
18560 super(response);
18561 this.id = this.getResponseProperty('Id');
18562 this.organizationId = this.getResponseProperty('OrganizationId');
18563 this.name = this.getResponseProperty('Name');
18564 this.accessAll = this.getResponseProperty('AccessAll');
18565 this.externalId = this.getResponseProperty('ExternalId');
18566 }
18567}
18568class groupResponse_GroupDetailsResponse extends groupResponse_GroupResponse {
18569 constructor(response) {
18570 super(response);
18571 this.collections = [];
18572 const collections = this.getResponseProperty('Collections');
18573 if (collections != null) {
18574 this.collections = collections.map((c) => new selectionReadOnlyResponse_SelectionReadOnlyResponse(c));
18575 }
18576 }
18577}
18578
18579// CONCATENATED MODULE: ./jslib/src/models/response/identityTokenResponse.ts
18580
18581class identityTokenResponse_IdentityTokenResponse extends BaseResponse {
18582 constructor(response) {
18583 super(response);
18584 this.accessToken = response.access_token;
18585 this.expiresIn = response.expires_in;
18586 this.refreshToken = response.refresh_token;
18587 this.tokenType = response.token_type;
18588 this.privateKey = this.getResponseProperty('PrivateKey');
18589 this.key = this.getResponseProperty('Key');
18590 this.twoFactorToken = this.getResponseProperty('TwoFactorToken');
18591 }
18592}
18593
18594// CONCATENATED MODULE: ./jslib/src/models/response/identityTwoFactorResponse.ts
18595
18596class identityTwoFactorResponse_IdentityTwoFactorResponse extends BaseResponse {
18597 constructor(response) {
18598 super(response);
18599 this.twoFactorProviders2 = new Map();
18600 this.twoFactorProviders = this.getResponseProperty('TwoFactorProviders');
18601 const twoFactorProviders2 = this.getResponseProperty('TwoFactorProviders2');
18602 if (twoFactorProviders2 != null) {
18603 for (const prop in twoFactorProviders2) {
18604 if (twoFactorProviders2.hasOwnProperty(prop)) {
18605 this.twoFactorProviders2.set(parseInt(prop, null), twoFactorProviders2[prop]);
18606 }
18607 }
18608 }
18609 }
18610}
18611
18612// CONCATENATED MODULE: ./jslib/src/models/response/listResponse.ts
18613
18614class listResponse_ListResponse extends BaseResponse {
18615 constructor(response, t) {
18616 super(response);
18617 const data = this.getResponseProperty('Data');
18618 this.data = data == null ? [] : data.map((dr) => new t(dr));
18619 this.continuationToken = this.getResponseProperty('ContinuationToken');
18620 }
18621}
18622
18623// CONCATENATED MODULE: ./jslib/src/models/response/organizationResponse.ts
18624
18625class organizationResponse_OrganizationResponse extends BaseResponse {
18626 constructor(response) {
18627 super(response);
18628 this.id = this.getResponseProperty('Id');
18629 this.name = this.getResponseProperty('Name');
18630 this.businessName = this.getResponseProperty('BusinessName');
18631 this.businessAddress1 = this.getResponseProperty('BusinessAddress1');
18632 this.businessAddress2 = this.getResponseProperty('BusinessAddress2');
18633 this.businessAddress3 = this.getResponseProperty('BusinessAddress3');
18634 this.businessCountry = this.getResponseProperty('BusinessCountry');
18635 this.businessTaxNumber = this.getResponseProperty('BusinessTaxNumber');
18636 this.billingEmail = this.getResponseProperty('BillingEmail');
18637 this.plan = this.getResponseProperty('Plan');
18638 this.planType = this.getResponseProperty('PlanType');
18639 this.seats = this.getResponseProperty('Seats');
18640 this.maxCollections = this.getResponseProperty('MaxCollections');
18641 this.maxStorageGb = this.getResponseProperty('MaxStorageGb');
18642 this.useGroups = this.getResponseProperty('UseGroups');
18643 this.useDirectory = this.getResponseProperty('UseDirectory');
18644 this.useEvents = this.getResponseProperty('UseEvents');
18645 this.useTotp = this.getResponseProperty('UseTotp');
18646 this.use2fa = this.getResponseProperty('Use2fa');
18647 this.useApi = this.getResponseProperty('UseApi');
18648 }
18649}
18650
18651// CONCATENATED MODULE: ./jslib/src/models/response/subscriptionResponse.ts
18652
18653class subscriptionResponse_SubscriptionResponse extends BaseResponse {
18654 constructor(response) {
18655 super(response);
18656 this.storageName = this.getResponseProperty('StorageName');
18657 this.storageGb = this.getResponseProperty('StorageGb');
18658 this.maxStorageGb = this.getResponseProperty('MaxStorageGb');
18659 this.license = this.getResponseProperty('License');
18660 this.expiration = this.getResponseProperty('Expiration');
18661 this.usingInAppPurchase = this.getResponseProperty('UsingInAppPurchase');
18662 const subscription = this.getResponseProperty('Subscription');
18663 const upcomingInvoice = this.getResponseProperty('UpcomingInvoice');
18664 this.subscription = subscription == null ? null : new subscriptionResponse_BillingSubscriptionResponse(subscription);
18665 this.upcomingInvoice = upcomingInvoice == null ? null :
18666 new subscriptionResponse_BillingSubscriptionUpcomingInvoiceResponse(upcomingInvoice);
18667 }
18668}
18669class subscriptionResponse_BillingSubscriptionResponse extends BaseResponse {
18670 constructor(response) {
18671 super(response);
18672 this.items = [];
18673 this.trialEndDate = this.getResponseProperty('TrialStartDate');
18674 this.trialEndDate = this.getResponseProperty('TrialEndDate');
18675 this.periodStartDate = this.getResponseProperty('PeriodStartDate');
18676 this.periodEndDate = this.getResponseProperty('PeriodEndDate');
18677 this.cancelledDate = this.getResponseProperty('CancelledDate');
18678 this.cancelAtEndDate = this.getResponseProperty('CancelAtEndDate');
18679 this.status = this.getResponseProperty('Status');
18680 this.cancelled = this.getResponseProperty('Cancelled');
18681 const items = this.getResponseProperty('Items');
18682 if (items != null) {
18683 this.items = items.map((i) => new subscriptionResponse_BillingSubscriptionItemResponse(i));
18684 }
18685 }
18686}
18687class subscriptionResponse_BillingSubscriptionItemResponse extends BaseResponse {
18688 constructor(response) {
18689 super(response);
18690 this.name = this.getResponseProperty('Name');
18691 this.amount = this.getResponseProperty('Amount');
18692 this.quantity = this.getResponseProperty('Quantity');
18693 this.interval = this.getResponseProperty('Interval');
18694 }
18695}
18696class subscriptionResponse_BillingSubscriptionUpcomingInvoiceResponse extends BaseResponse {
18697 constructor(response) {
18698 super(response);
18699 this.date = this.getResponseProperty('Date');
18700 this.amount = this.getResponseProperty('Amount');
18701 }
18702}
18703
18704// CONCATENATED MODULE: ./jslib/src/models/response/organizationSubscriptionResponse.ts
18705
18706
18707class organizationSubscriptionResponse_OrganizationSubscriptionResponse extends organizationResponse_OrganizationResponse {
18708 constructor(response) {
18709 super(response);
18710 this.storageName = this.getResponseProperty('StorageName');
18711 this.storageGb = this.getResponseProperty('StorageGb');
18712 const subscription = this.getResponseProperty('Subscription');
18713 this.subscription = subscription == null ? null : new subscriptionResponse_BillingSubscriptionResponse(subscription);
18714 const upcomingInvoice = this.getResponseProperty('UpcomingInvoice');
18715 this.upcomingInvoice = upcomingInvoice == null ? null :
18716 new subscriptionResponse_BillingSubscriptionUpcomingInvoiceResponse(upcomingInvoice);
18717 this.expiration = this.getResponseProperty('Expiration');
18718 }
18719}
18720
18721// CONCATENATED MODULE: ./jslib/src/models/response/organizationUserResponse.ts
18722
18723
18724class organizationUserResponse_OrganizationUserResponse extends BaseResponse {
18725 constructor(response) {
18726 super(response);
18727 this.id = this.getResponseProperty('Id');
18728 this.userId = this.getResponseProperty('UserId');
18729 this.type = this.getResponseProperty('Type');
18730 this.status = this.getResponseProperty('Status');
18731 this.accessAll = this.getResponseProperty('AccessAll');
18732 }
18733}
18734class OrganizationUserUserDetailsResponse extends organizationUserResponse_OrganizationUserResponse {
18735 constructor(response) {
18736 super(response);
18737 this.name = this.getResponseProperty('Name');
18738 this.email = this.getResponseProperty('Email');
18739 this.twoFactorEnabled = this.getResponseProperty('TwoFactorEnabled');
18740 }
18741}
18742class organizationUserResponse_OrganizationUserDetailsResponse extends organizationUserResponse_OrganizationUserResponse {
18743 constructor(response) {
18744 super(response);
18745 this.collections = [];
18746 const collections = this.getResponseProperty('Collections');
18747 if (collections != null) {
18748 this.collections = collections.map((c) => new selectionReadOnlyResponse_SelectionReadOnlyResponse(c));
18749 }
18750 }
18751}
18752
18753// CONCATENATED MODULE: ./jslib/src/models/response/profileOrganizationResponse.ts
18754
18755class profileOrganizationResponse_ProfileOrganizationResponse extends BaseResponse {
18756 constructor(response) {
18757 super(response);
18758 this.id = this.getResponseProperty('Id');
18759 this.name = this.getResponseProperty('Name');
18760 this.usePolicies = this.getResponseProperty('UsePolicies');
18761 this.useGroups = this.getResponseProperty('UseGroups');
18762 this.useDirectory = this.getResponseProperty('UseDirectory');
18763 this.useEvents = this.getResponseProperty('UseEvents');
18764 this.useTotp = this.getResponseProperty('UseTotp');
18765 this.use2fa = this.getResponseProperty('Use2fa');
18766 this.useApi = this.getResponseProperty('UseApi');
18767 this.selfHost = this.getResponseProperty('SelfHost');
18768 this.usersGetPremium = this.getResponseProperty('UsersGetPremium');
18769 this.seats = this.getResponseProperty('Seats');
18770 this.maxCollections = this.getResponseProperty('MaxCollections');
18771 this.maxStorageGb = this.getResponseProperty('MaxStorageGb');
18772 this.key = this.getResponseProperty('Key');
18773 this.status = this.getResponseProperty('Status');
18774 this.type = this.getResponseProperty('Type');
18775 this.enabled = this.getResponseProperty('Enabled');
18776 }
18777}
18778
18779// CONCATENATED MODULE: ./jslib/src/models/response/profileResponse.ts
18780
18781
18782class profileResponse_ProfileResponse extends BaseResponse {
18783 constructor(response) {
18784 super(response);
18785 this.organizations = [];
18786 this.id = this.getResponseProperty('Id');
18787 this.name = this.getResponseProperty('Name');
18788 this.email = this.getResponseProperty('Email');
18789 this.emailVerified = this.getResponseProperty('EmailVerified');
18790 this.masterPasswordHint = this.getResponseProperty('MasterPasswordHint');
18791 this.premium = this.getResponseProperty('Premium');
18792 this.culture = this.getResponseProperty('Culture');
18793 this.twoFactorEnabled = this.getResponseProperty('TwoFactorEnabled');
18794 this.key = this.getResponseProperty('Key');
18795 this.privateKey = this.getResponseProperty('PrivateKey');
18796 this.securityStamp = this.getResponseProperty('SecurityStamp');
18797 const organizations = this.getResponseProperty('Organizations');
18798 if (organizations != null) {
18799 this.organizations = organizations.map((o) => new profileOrganizationResponse_ProfileOrganizationResponse(o));
18800 }
18801 }
18802}
18803
18804// CONCATENATED MODULE: ./jslib/src/models/response/paymentResponse.ts
18805
18806
18807class paymentResponse_PaymentResponse extends BaseResponse {
18808 constructor(response) {
18809 super(response);
18810 const userProfile = this.getResponseProperty('UserProfile');
18811 if (userProfile != null) {
18812 this.userProfile = new profileResponse_ProfileResponse(userProfile);
18813 }
18814 this.paymentIntentClientSecret = this.getResponseProperty('PaymentIntentClientSecret');
18815 this.success = this.getResponseProperty('Success');
18816 }
18817}
18818
18819// CONCATENATED MODULE: ./jslib/src/models/response/policyResponse.ts
18820
18821class policyResponse_PolicyResponse extends BaseResponse {
18822 constructor(response) {
18823 super(response);
18824 this.id = this.getResponseProperty('Id');
18825 this.organizationId = this.getResponseProperty('OrganizationId');
18826 this.type = this.getResponseProperty('Type');
18827 this.data = this.getResponseProperty('Data');
18828 this.enabled = this.getResponseProperty('Enabled');
18829 }
18830}
18831
18832// CONCATENATED MODULE: ./jslib/src/models/response/preloginResponse.ts
18833
18834class preloginResponse_PreloginResponse extends BaseResponse {
18835 constructor(response) {
18836 super(response);
18837 this.kdf = this.getResponseProperty('Kdf');
18838 this.kdfIterations = this.getResponseProperty('KdfIterations');
18839 }
18840}
18841
18842// CONCATENATED MODULE: ./jslib/src/models/response/syncResponse.ts
18843
18844
18845
18846
18847
18848
18849
18850class syncResponse_SyncResponse extends BaseResponse {
18851 constructor(response) {
18852 super(response);
18853 this.folders = [];
18854 this.collections = [];
18855 this.ciphers = [];
18856 this.policies = [];
18857 const profile = this.getResponseProperty('Profile');
18858 if (profile != null) {
18859 this.profile = new profileResponse_ProfileResponse(profile);
18860 }
18861 const folders = this.getResponseProperty('Folders');
18862 if (folders != null) {
18863 this.folders = folders.map((f) => new folderResponse_FolderResponse(f));
18864 }
18865 const collections = this.getResponseProperty('Collections');
18866 if (collections != null) {
18867 this.collections = collections.map((c) => new CollectionDetailsResponse(c));
18868 }
18869 const ciphers = this.getResponseProperty('Ciphers');
18870 if (ciphers != null) {
18871 this.ciphers = ciphers.map((c) => new cipherResponse_CipherResponse(c));
18872 }
18873 const domains = this.getResponseProperty('Domains');
18874 if (domains != null) {
18875 this.domains = new domainsResponse_DomainsResponse(domains);
18876 }
18877 const policies = this.getResponseProperty('Policies');
18878 if (policies != null) {
18879 this.policies = policies.map((p) => new policyResponse_PolicyResponse(p));
18880 }
18881 }
18882}
18883
18884// CONCATENATED MODULE: ./jslib/src/models/response/taxInfoResponse.ts
18885
18886class taxInfoResponse_TaxInfoResponse extends BaseResponse {
18887 constructor(response) {
18888 super(response);
18889 this.taxId = this.getResponseProperty('TaxIdNumber');
18890 this.taxIdType = this.getResponseProperty('TaxIdType');
18891 this.line1 = this.getResponseProperty('Line1');
18892 this.line2 = this.getResponseProperty('Line2');
18893 this.city = this.getResponseProperty('City');
18894 this.state = this.getResponseProperty('State');
18895 this.postalCode = this.getResponseProperty('PostalCode');
18896 this.country = this.getResponseProperty('Country');
18897 }
18898}
18899
18900// CONCATENATED MODULE: ./jslib/src/models/response/twoFactorAuthenticatorResponse.ts
18901
18902class twoFactorAuthenticatorResponse_TwoFactorAuthenticatorResponse extends BaseResponse {
18903 constructor(response) {
18904 super(response);
18905 this.enabled = this.getResponseProperty('Enabled');
18906 this.key = this.getResponseProperty('Key');
18907 }
18908}
18909
18910// CONCATENATED MODULE: ./jslib/src/models/response/twoFactorDuoResponse.ts
18911
18912class twoFactorDuoResponse_TwoFactorDuoResponse extends BaseResponse {
18913 constructor(response) {
18914 super(response);
18915 this.enabled = this.getResponseProperty('Enabled');
18916 this.host = this.getResponseProperty('Host');
18917 this.secretKey = this.getResponseProperty('SecretKey');
18918 this.integrationKey = this.getResponseProperty('IntegrationKey');
18919 }
18920}
18921
18922// CONCATENATED MODULE: ./jslib/src/models/response/twoFactorEmailResponse.ts
18923
18924class twoFactorEmailResponse_TwoFactorEmailResponse extends BaseResponse {
18925 constructor(response) {
18926 super(response);
18927 this.enabled = this.getResponseProperty('Enabled');
18928 this.email = this.getResponseProperty('Email');
18929 }
18930}
18931
18932// CONCATENATED MODULE: ./jslib/src/models/response/twoFactorProviderResponse.ts
18933
18934class twoFactorProviderResponse_TwoFactorProviderResponse extends BaseResponse {
18935 constructor(response) {
18936 super(response);
18937 this.enabled = this.getResponseProperty('Enabled');
18938 this.type = this.getResponseProperty('Type');
18939 }
18940}
18941
18942// CONCATENATED MODULE: ./jslib/src/models/response/twoFactorRescoverResponse.ts
18943
18944class twoFactorRescoverResponse_TwoFactorRecoverResponse extends BaseResponse {
18945 constructor(response) {
18946 super(response);
18947 this.code = this.getResponseProperty('Code');
18948 }
18949}
18950
18951// CONCATENATED MODULE: ./jslib/src/models/response/twoFactorU2fResponse.ts
18952
18953class twoFactorU2fResponse_TwoFactorU2fResponse extends BaseResponse {
18954 constructor(response) {
18955 super(response);
18956 this.enabled = this.getResponseProperty('Enabled');
18957 const keys = this.getResponseProperty('Keys');
18958 this.keys = keys == null ? null : keys.map((k) => new twoFactorU2fResponse_KeyResponse(k));
18959 }
18960}
18961class twoFactorU2fResponse_KeyResponse extends BaseResponse {
18962 constructor(response) {
18963 super(response);
18964 this.name = this.getResponseProperty('Name');
18965 this.id = this.getResponseProperty('Id');
18966 this.compromised = this.getResponseProperty('Compromised');
18967 }
18968}
18969class twoFactorU2fResponse_ChallengeResponse extends BaseResponse {
18970 constructor(response) {
18971 super(response);
18972 this.userId = this.getResponseProperty('UserId');
18973 this.appId = this.getResponseProperty('AppId');
18974 this.challenge = this.getResponseProperty('Challenge');
18975 this.version = this.getResponseProperty('Version');
18976 }
18977}
18978
18979// CONCATENATED MODULE: ./jslib/src/models/response/twoFactorYubiKeyResponse.ts
18980
18981class twoFactorYubiKeyResponse_TwoFactorYubiKeyResponse extends BaseResponse {
18982 constructor(response) {
18983 super(response);
18984 this.enabled = this.getResponseProperty('Enabled');
18985 this.key1 = this.getResponseProperty('Key1');
18986 this.key2 = this.getResponseProperty('Key2');
18987 this.key3 = this.getResponseProperty('Key3');
18988 this.key4 = this.getResponseProperty('Key4');
18989 this.key5 = this.getResponseProperty('Key5');
18990 this.nfc = this.getResponseProperty('Nfc');
18991 }
18992}
18993
18994// CONCATENATED MODULE: ./jslib/src/models/response/userKeyResponse.ts
18995
18996class userKeyResponse_UserKeyResponse extends BaseResponse {
18997 constructor(response) {
18998 super(response);
18999 this.userId = this.getResponseProperty('UserId');
19000 this.publicKey = this.getResponseProperty('PublicKey');
19001 }
19002}
19003
19004// CONCATENATED MODULE: ./jslib/src/services/api.service.ts
19005var api_service_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
19006 return new (P || (P = Promise))(function (resolve, reject) {
19007 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
19008 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
19009 function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
19010 step((generator = generator.apply(thisArg, _arguments || [])).next());
19011 });
19012};
19013
19014
19015
19016
19017
19018
19019
19020
19021
19022
19023
19024
19025
19026
19027
19028
19029
19030
19031
19032
19033
19034
19035
19036
19037
19038
19039
19040
19041
19042
19043
19044
19045
19046class api_service_ApiService {
19047 constructor(tokenService, platformUtilsService, logoutCallback, customUserAgent = null) {
19048 this.tokenService = tokenService;
19049 this.platformUtilsService = platformUtilsService;
19050 this.logoutCallback = logoutCallback;
19051 this.customUserAgent = customUserAgent;
19052 this.urlsSet = false;
19053 this.isWebClient = false;
19054 this.isDesktopClient = false;
19055 this.usingBaseUrl = false;
19056 this.device = platformUtilsService.getDevice();
19057 this.deviceType = this.device.toString();
19058 this.isWebClient = this.device === DeviceType.IEBrowser || this.device === DeviceType.ChromeBrowser ||
19059 this.device === DeviceType.EdgeBrowser || this.device === DeviceType.FirefoxBrowser ||
19060 this.device === DeviceType.OperaBrowser || this.device === DeviceType.SafariBrowser ||
19061 this.device === DeviceType.UnknownBrowser || this.device === DeviceType.VivaldiBrowser;
19062 this.isDesktopClient = this.device === DeviceType.WindowsDesktop || this.device === DeviceType.MacOsDesktop ||
19063 this.device === DeviceType.LinuxDesktop;
19064 }
19065 setUrls(urls) {
19066 this.urlsSet = true;
19067 if (urls.base != null) {
19068 this.usingBaseUrl = true;
19069 this.apiBaseUrl = urls.base + '/api';
19070 this.identityBaseUrl = urls.base + '/identity';
19071 this.eventsBaseUrl = urls.base + '/events';
19072 return;
19073 }
19074 this.apiBaseUrl = urls.api;
19075 this.identityBaseUrl = urls.identity;
19076 this.eventsBaseUrl = urls.events;
19077 // Production
19078 if (this.apiBaseUrl == null) {
19079 this.apiBaseUrl = 'https://api.bitwarden.com';
19080 }
19081 if (this.identityBaseUrl == null) {
19082 this.identityBaseUrl = 'https://identity.bitwarden.com';
19083 }
19084 if (this.eventsBaseUrl == null) {
19085 this.eventsBaseUrl = 'https://events.bitwarden.com';
19086 }
19087 }
19088 // Auth APIs
19089 postIdentityToken(request) {
19090 return api_service_awaiter(this, void 0, void 0, function* () {
19091 const headers = new Headers({
19092 'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8',
19093 'Accept': 'application/json',
19094 'Device-Type': this.deviceType,
19095 });
19096 if (this.customUserAgent != null) {
19097 headers.set('User-Agent', this.customUserAgent);
19098 }
19099 const response = yield this.fetch(new Request(this.identityBaseUrl + '/connect/token', {
19100 body: this.qsStringify(request.toIdentityToken(this.platformUtilsService.identityClientId)),
19101 credentials: this.getCredentials(),
19102 cache: 'no-store',
19103 headers: headers,
19104 method: 'POST',
19105 }));
19106 let responseJson = null;
19107 if (this.isJsonResponse(response)) {
19108 responseJson = yield response.json();
19109 }
19110 if (responseJson != null) {
19111 if (response.status === 200) {
19112 return new identityTokenResponse_IdentityTokenResponse(responseJson);
19113 }
19114 else if (response.status === 400 && responseJson.TwoFactorProviders2 &&
19115 Object.keys(responseJson.TwoFactorProviders2).length) {
19116 yield this.tokenService.clearTwoFactorToken(request.email);
19117 return new identityTwoFactorResponse_IdentityTwoFactorResponse(responseJson);
19118 }
19119 }
19120 return Promise.reject(new errorResponse_ErrorResponse(responseJson, response.status, true));
19121 });
19122 }
19123 refreshIdentityToken() {
19124 return api_service_awaiter(this, void 0, void 0, function* () {
19125 try {
19126 yield this.doRefreshToken();
19127 }
19128 catch (e) {
19129 return Promise.reject(null);
19130 }
19131 });
19132 }
19133 // Account APIs
19134 getProfile() {
19135 return api_service_awaiter(this, void 0, void 0, function* () {
19136 const r = yield this.send('GET', '/accounts/profile', null, true, true);
19137 return new profileResponse_ProfileResponse(r);
19138 });
19139 }
19140 getUserBilling() {
19141 return api_service_awaiter(this, void 0, void 0, function* () {
19142 const r = yield this.send('GET', '/accounts/billing', null, true, true);
19143 return new billingResponse_BillingResponse(r);
19144 });
19145 }
19146 getUserSubscription() {
19147 return api_service_awaiter(this, void 0, void 0, function* () {
19148 const r = yield this.send('GET', '/accounts/subscription', null, true, true);
19149 return new subscriptionResponse_SubscriptionResponse(r);
19150 });
19151 }
19152 getTaxInfo() {
19153 return api_service_awaiter(this, void 0, void 0, function* () {
19154 const r = yield this.send('GET', '/accounts/tax', null, true, true);
19155 return new taxInfoResponse_TaxInfoResponse(r);
19156 });
19157 }
19158 putProfile(request) {
19159 return api_service_awaiter(this, void 0, void 0, function* () {
19160 const r = yield this.send('PUT', '/accounts/profile', request, true, true);
19161 return new profileResponse_ProfileResponse(r);
19162 });
19163 }
19164 putTaxInfo(request) {
19165 return this.send('PUT', '/accounts/tax', request, true, false);
19166 }
19167 postPrelogin(request) {
19168 return api_service_awaiter(this, void 0, void 0, function* () {
19169 const r = yield this.send('POST', '/accounts/prelogin', request, false, true);
19170 return new preloginResponse_PreloginResponse(r);
19171 });
19172 }
19173 postEmailToken(request) {
19174 return this.send('POST', '/accounts/email-token', request, true, false);
19175 }
19176 postEmail(request) {
19177 return this.send('POST', '/accounts/email', request, true, false);
19178 }
19179 postPassword(request) {
19180 return this.send('POST', '/accounts/password', request, true, false);
19181 }
19182 postSecurityStamp(request) {
19183 return this.send('POST', '/accounts/security-stamp', request, true, false);
19184 }
19185 deleteAccount(request) {
19186 return this.send('DELETE', '/accounts', request, true, false);
19187 }
19188 getAccountRevisionDate() {
19189 return api_service_awaiter(this, void 0, void 0, function* () {
19190 const r = yield this.send('GET', '/accounts/revision-date', null, true, true);
19191 return r;
19192 });
19193 }
19194 postPasswordHint(request) {
19195 return this.send('POST', '/accounts/password-hint', request, false, false);
19196 }
19197 postRegister(request) {
19198 return this.send('POST', '/accounts/register', request, false, false);
19199 }
19200 postPremium(data) {
19201 return api_service_awaiter(this, void 0, void 0, function* () {
19202 const r = yield this.send('POST', '/accounts/premium', data, true, true);
19203 return new paymentResponse_PaymentResponse(r);
19204 });
19205 }
19206 postIapCheck(request) {
19207 return api_service_awaiter(this, void 0, void 0, function* () {
19208 return this.send('POST', '/accounts/iap-check', request, true, false);
19209 });
19210 }
19211 postReinstatePremium() {
19212 return this.send('POST', '/accounts/reinstate-premium', null, true, false);
19213 }
19214 postCancelPremium() {
19215 return this.send('POST', '/accounts/cancel-premium', null, true, false);
19216 }
19217 postAccountStorage(request) {
19218 return api_service_awaiter(this, void 0, void 0, function* () {
19219 const r = yield this.send('POST', '/accounts/storage', request, true, true);
19220 return new paymentResponse_PaymentResponse(r);
19221 });
19222 }
19223 postAccountPayment(request) {
19224 return this.send('POST', '/accounts/payment', request, true, false);
19225 }
19226 postAccountLicense(data) {
19227 return this.send('POST', '/accounts/license', data, true, false);
19228 }
19229 postAccountKeys(request) {
19230 return this.send('POST', '/accounts/keys', request, true, false);
19231 }
19232 postAccountKey(request) {
19233 return this.send('POST', '/accounts/key', request, true, false);
19234 }
19235 postAccountVerifyEmail() {
19236 return this.send('POST', '/accounts/verify-email', null, true, false);
19237 }
19238 postAccountVerifyEmailToken(request) {
19239 return this.send('POST', '/accounts/verify-email-token', request, false, false);
19240 }
19241 postAccountRecoverDelete(request) {
19242 return this.send('POST', '/accounts/delete-recover', request, false, false);
19243 }
19244 postAccountRecoverDeleteToken(request) {
19245 return this.send('POST', '/accounts/delete-recover-token', request, false, false);
19246 }
19247 postAccountKdf(request) {
19248 return this.send('POST', '/accounts/kdf', request, true, false);
19249 }
19250 getEnterprisePortalSignInToken() {
19251 return api_service_awaiter(this, void 0, void 0, function* () {
19252 const r = yield this.send('GET', '/accounts/enterprise-portal-signin-token', null, true, true);
19253 return r;
19254 });
19255 }
19256 // Folder APIs
19257 getFolder(id) {
19258 return api_service_awaiter(this, void 0, void 0, function* () {
19259 const r = yield this.send('GET', '/folders/' + id, null, true, true);
19260 return new folderResponse_FolderResponse(r);
19261 });
19262 }
19263 postFolder(request) {
19264 return api_service_awaiter(this, void 0, void 0, function* () {
19265 const r = yield this.send('POST', '/folders', request, true, true);
19266 return new folderResponse_FolderResponse(r);
19267 });
19268 }
19269 putFolder(id, request) {
19270 return api_service_awaiter(this, void 0, void 0, function* () {
19271 const r = yield this.send('PUT', '/folders/' + id, request, true, true);
19272 return new folderResponse_FolderResponse(r);
19273 });
19274 }
19275 deleteFolder(id) {
19276 return this.send('DELETE', '/folders/' + id, null, true, false);
19277 }
19278 // Cipher APIs
19279 getCipher(id) {
19280 return api_service_awaiter(this, void 0, void 0, function* () {
19281 const r = yield this.send('GET', '/ciphers/' + id, null, true, true);
19282 return new cipherResponse_CipherResponse(r);
19283 });
19284 }
19285 getCipherAdmin(id) {
19286 return api_service_awaiter(this, void 0, void 0, function* () {
19287 const r = yield this.send('GET', '/ciphers/' + id + '/admin', null, true, true);
19288 return new cipherResponse_CipherResponse(r);
19289 });
19290 }
19291 getCiphersOrganization(organizationId) {
19292 return api_service_awaiter(this, void 0, void 0, function* () {
19293 const r = yield this.send('GET', '/ciphers/organization-details?organizationId=' + organizationId, null, true, true);
19294 return new listResponse_ListResponse(r, cipherResponse_CipherResponse);
19295 });
19296 }
19297 postCipher(request) {
19298 return api_service_awaiter(this, void 0, void 0, function* () {
19299 const r = yield this.send('POST', '/ciphers', request, true, true);
19300 return new cipherResponse_CipherResponse(r);
19301 });
19302 }
19303 postCipherCreate(request) {
19304 return api_service_awaiter(this, void 0, void 0, function* () {
19305 const r = yield this.send('POST', '/ciphers/create', request, true, true);
19306 return new cipherResponse_CipherResponse(r);
19307 });
19308 }
19309 postCipherAdmin(request) {
19310 return api_service_awaiter(this, void 0, void 0, function* () {
19311 const r = yield this.send('POST', '/ciphers/admin', request, true, true);
19312 return new cipherResponse_CipherResponse(r);
19313 });
19314 }
19315 putCipher(id, request) {
19316 return api_service_awaiter(this, void 0, void 0, function* () {
19317 const r = yield this.send('PUT', '/ciphers/' + id, request, true, true);
19318 return new cipherResponse_CipherResponse(r);
19319 });
19320 }
19321 putCipherAdmin(id, request) {
19322 return api_service_awaiter(this, void 0, void 0, function* () {
19323 const r = yield this.send('PUT', '/ciphers/' + id + '/admin', request, true, true);
19324 return new cipherResponse_CipherResponse(r);
19325 });
19326 }
19327 deleteCipher(id) {
19328 return this.send('DELETE', '/ciphers/' + id, null, true, false);
19329 }
19330 deleteCipherAdmin(id) {
19331 return this.send('DELETE', '/ciphers/' + id + '/admin', null, true, false);
19332 }
19333 deleteManyCiphers(request) {
19334 return this.send('DELETE', '/ciphers', request, true, false);
19335 }
19336 putMoveCiphers(request) {
19337 return this.send('PUT', '/ciphers/move', request, true, false);
19338 }
19339 putShareCipher(id, request) {
19340 return api_service_awaiter(this, void 0, void 0, function* () {
19341 const r = yield this.send('PUT', '/ciphers/' + id + '/share', request, true, true);
19342 return new cipherResponse_CipherResponse(r);
19343 });
19344 }
19345 putShareCiphers(request) {
19346 return this.send('PUT', '/ciphers/share', request, true, false);
19347 }
19348 putCipherCollections(id, request) {
19349 return this.send('PUT', '/ciphers/' + id + '/collections', request, true, false);
19350 }
19351 putCipherCollectionsAdmin(id, request) {
19352 return this.send('PUT', '/ciphers/' + id + '/collections-admin', request, true, false);
19353 }
19354 postPurgeCiphers(request, organizationId = null) {
19355 let path = '/ciphers/purge';
19356 if (organizationId != null) {
19357 path += '?organizationId=' + organizationId;
19358 }
19359 return this.send('POST', path, request, true, false);
19360 }
19361 postImportCiphers(request) {
19362 return this.send('POST', '/ciphers/import', request, true, false);
19363 }
19364 postImportOrganizationCiphers(organizationId, request) {
19365 return this.send('POST', '/ciphers/import-organization?organizationId=' + organizationId, request, true, false);
19366 }
19367 putDeleteCipher(id) {
19368 return this.send('PUT', '/ciphers/' + id + '/delete', null, true, false);
19369 }
19370 putDeleteCipherAdmin(id) {
19371 return this.send('PUT', '/ciphers/' + id + '/delete-admin', null, true, false);
19372 }
19373 putDeleteManyCiphers(request) {
19374 return this.send('PUT', '/ciphers/delete', request, true, false);
19375 }
19376 putRestoreCipher(id) {
19377 return this.send('PUT', '/ciphers/' + id + '/restore', null, true, false);
19378 }
19379 putRestoreCipherAdmin(id) {
19380 return this.send('PUT', '/ciphers/' + id + '/restore-admin', null, true, false);
19381 }
19382 putRestoreManyCiphers(request) {
19383 return this.send('PUT', '/ciphers/restore', request, true, false);
19384 }
19385 // Attachments APIs
19386 postCipherAttachment(id, data) {
19387 return api_service_awaiter(this, void 0, void 0, function* () {
19388 const r = yield this.send('POST', '/ciphers/' + id + '/attachment', data, true, true);
19389 return new cipherResponse_CipherResponse(r);
19390 });
19391 }
19392 postCipherAttachmentAdmin(id, data) {
19393 return api_service_awaiter(this, void 0, void 0, function* () {
19394 const r = yield this.send('POST', '/ciphers/' + id + '/attachment-admin', data, true, true);
19395 return new cipherResponse_CipherResponse(r);
19396 });
19397 }
19398 deleteCipherAttachment(id, attachmentId) {
19399 return this.send('DELETE', '/ciphers/' + id + '/attachment/' + attachmentId, null, true, false);
19400 }
19401 deleteCipherAttachmentAdmin(id, attachmentId) {
19402 return this.send('DELETE', '/ciphers/' + id + '/attachment/' + attachmentId + '/admin', null, true, false);
19403 }
19404 postShareCipherAttachment(id, attachmentId, data, organizationId) {
19405 return this.send('POST', '/ciphers/' + id + '/attachment/' +
19406 attachmentId + '/share?organizationId=' + organizationId, data, true, false);
19407 }
19408 // Collections APIs
19409 getCollectionDetails(organizationId, id) {
19410 return api_service_awaiter(this, void 0, void 0, function* () {
19411 const r = yield this.send('GET', '/organizations/' + organizationId + '/collections/' + id + '/details', null, true, true);
19412 return new collectionResponse_CollectionGroupDetailsResponse(r);
19413 });
19414 }
19415 getUserCollections() {
19416 return api_service_awaiter(this, void 0, void 0, function* () {
19417 const r = yield this.send('GET', '/collections', null, true, true);
19418 return new listResponse_ListResponse(r, collectionResponse_CollectionResponse);
19419 });
19420 }
19421 getCollections(organizationId) {
19422 return api_service_awaiter(this, void 0, void 0, function* () {
19423 const r = yield this.send('GET', '/organizations/' + organizationId + '/collections', null, true, true);
19424 return new listResponse_ListResponse(r, collectionResponse_CollectionResponse);
19425 });
19426 }
19427 getCollectionUsers(organizationId, id) {
19428 return api_service_awaiter(this, void 0, void 0, function* () {
19429 const r = yield this.send('GET', '/organizations/' + organizationId + '/collections/' + id + '/users', null, true, true);
19430 return r.map((dr) => new selectionReadOnlyResponse_SelectionReadOnlyResponse(dr));
19431 });
19432 }
19433 postCollection(organizationId, request) {
19434 return api_service_awaiter(this, void 0, void 0, function* () {
19435 const r = yield this.send('POST', '/organizations/' + organizationId + '/collections', request, true, true);
19436 return new collectionResponse_CollectionResponse(r);
19437 });
19438 }
19439 putCollection(organizationId, id, request) {
19440 return api_service_awaiter(this, void 0, void 0, function* () {
19441 const r = yield this.send('PUT', '/organizations/' + organizationId + '/collections/' + id, request, true, true);
19442 return new collectionResponse_CollectionResponse(r);
19443 });
19444 }
19445 putCollectionUsers(organizationId, id, request) {
19446 return api_service_awaiter(this, void 0, void 0, function* () {
19447 yield this.send('PUT', '/organizations/' + organizationId + '/collections/' + id + '/users', request, true, false);
19448 });
19449 }
19450 deleteCollection(organizationId, id) {
19451 return this.send('DELETE', '/organizations/' + organizationId + '/collections/' + id, null, true, false);
19452 }
19453 deleteCollectionUser(organizationId, id, organizationUserId) {
19454 return this.send('DELETE', '/organizations/' + organizationId + '/collections/' + id + '/user/' + organizationUserId, null, true, false);
19455 }
19456 // Groups APIs
19457 getGroupDetails(organizationId, id) {
19458 return api_service_awaiter(this, void 0, void 0, function* () {
19459 const r = yield this.send('GET', '/organizations/' + organizationId + '/groups/' + id + '/details', null, true, true);
19460 return new groupResponse_GroupDetailsResponse(r);
19461 });
19462 }
19463 getGroups(organizationId) {
19464 return api_service_awaiter(this, void 0, void 0, function* () {
19465 const r = yield this.send('GET', '/organizations/' + organizationId + '/groups', null, true, true);
19466 return new listResponse_ListResponse(r, groupResponse_GroupResponse);
19467 });
19468 }
19469 getGroupUsers(organizationId, id) {
19470 return api_service_awaiter(this, void 0, void 0, function* () {
19471 const r = yield this.send('GET', '/organizations/' + organizationId + '/groups/' + id + '/users', null, true, true);
19472 return r;
19473 });
19474 }
19475 postGroup(organizationId, request) {
19476 return api_service_awaiter(this, void 0, void 0, function* () {
19477 const r = yield this.send('POST', '/organizations/' + organizationId + '/groups', request, true, true);
19478 return new groupResponse_GroupResponse(r);
19479 });
19480 }
19481 putGroup(organizationId, id, request) {
19482 return api_service_awaiter(this, void 0, void 0, function* () {
19483 const r = yield this.send('PUT', '/organizations/' + organizationId + '/groups/' + id, request, true, true);
19484 return new groupResponse_GroupResponse(r);
19485 });
19486 }
19487 putGroupUsers(organizationId, id, request) {
19488 return api_service_awaiter(this, void 0, void 0, function* () {
19489 yield this.send('PUT', '/organizations/' + organizationId + '/groups/' + id + '/users', request, true, false);
19490 });
19491 }
19492 deleteGroup(organizationId, id) {
19493 return this.send('DELETE', '/organizations/' + organizationId + '/groups/' + id, null, true, false);
19494 }
19495 deleteGroupUser(organizationId, id, organizationUserId) {
19496 return this.send('DELETE', '/organizations/' + organizationId + '/groups/' + id + '/user/' + organizationUserId, null, true, false);
19497 }
19498 // Policy APIs
19499 getPolicy(organizationId, type) {
19500 return api_service_awaiter(this, void 0, void 0, function* () {
19501 const r = yield this.send('GET', '/organizations/' + organizationId + '/policies/' + type, null, true, true);
19502 return new policyResponse_PolicyResponse(r);
19503 });
19504 }
19505 getPolicies(organizationId) {
19506 return api_service_awaiter(this, void 0, void 0, function* () {
19507 const r = yield this.send('GET', '/organizations/' + organizationId + '/policies', null, true, true);
19508 return new listResponse_ListResponse(r, policyResponse_PolicyResponse);
19509 });
19510 }
19511 getPoliciesByToken(organizationId, token, email, organizationUserId) {
19512 return api_service_awaiter(this, void 0, void 0, function* () {
19513 const r = yield this.send('GET', '/organizations/' + organizationId + '/policies/token?' +
19514 'token=' + encodeURIComponent(token) + '&email=' + encodeURIComponent(email) +
19515 '&organizationUserId=' + organizationUserId, null, false, true);
19516 return new listResponse_ListResponse(r, policyResponse_PolicyResponse);
19517 });
19518 }
19519 putPolicy(organizationId, type, request) {
19520 return api_service_awaiter(this, void 0, void 0, function* () {
19521 const r = yield this.send('PUT', '/organizations/' + organizationId + '/policies/' + type, request, true, true);
19522 return new policyResponse_PolicyResponse(r);
19523 });
19524 }
19525 // Organization User APIs
19526 getOrganizationUser(organizationId, id) {
19527 return api_service_awaiter(this, void 0, void 0, function* () {
19528 const r = yield this.send('GET', '/organizations/' + organizationId + '/users/' + id, null, true, true);
19529 return new organizationUserResponse_OrganizationUserDetailsResponse(r);
19530 });
19531 }
19532 getOrganizationUserGroups(organizationId, id) {
19533 return api_service_awaiter(this, void 0, void 0, function* () {
19534 const r = yield this.send('GET', '/organizations/' + organizationId + '/users/' + id + '/groups', null, true, true);
19535 return r;
19536 });
19537 }
19538 getOrganizationUsers(organizationId) {
19539 return api_service_awaiter(this, void 0, void 0, function* () {
19540 const r = yield this.send('GET', '/organizations/' + organizationId + '/users', null, true, true);
19541 return new listResponse_ListResponse(r, OrganizationUserUserDetailsResponse);
19542 });
19543 }
19544 postOrganizationUserInvite(organizationId, request) {
19545 return this.send('POST', '/organizations/' + organizationId + '/users/invite', request, true, false);
19546 }
19547 postOrganizationUserReinvite(organizationId, id) {
19548 return this.send('POST', '/organizations/' + organizationId + '/users/' + id + '/reinvite', null, true, false);
19549 }
19550 postOrganizationUserAccept(organizationId, id, request) {
19551 return this.send('POST', '/organizations/' + organizationId + '/users/' + id + '/accept', request, true, false);
19552 }
19553 postOrganizationUserConfirm(organizationId, id, request) {
19554 return this.send('POST', '/organizations/' + organizationId + '/users/' + id + '/confirm', request, true, false);
19555 }
19556 putOrganizationUser(organizationId, id, request) {
19557 return this.send('PUT', '/organizations/' + organizationId + '/users/' + id, request, true, false);
19558 }
19559 putOrganizationUserGroups(organizationId, id, request) {
19560 return this.send('PUT', '/organizations/' + organizationId + '/users/' + id + '/groups', request, true, false);
19561 }
19562 deleteOrganizationUser(organizationId, id) {
19563 return this.send('DELETE', '/organizations/' + organizationId + '/users/' + id, null, true, false);
19564 }
19565 // Sync APIs
19566 getSync() {
19567 return api_service_awaiter(this, void 0, void 0, function* () {
19568 const path = this.isDesktopClient || this.isWebClient ? '/sync?excludeDomains=true' : '/sync';
19569 const r = yield this.send('GET', path, null, true, true);
19570 return new syncResponse_SyncResponse(r);
19571 });
19572 }
19573 postImportDirectory(organizationId, request) {
19574 return api_service_awaiter(this, void 0, void 0, function* () {
19575 return this.send('POST', '/organizations/' + organizationId + '/import', request, true, false);
19576 });
19577 }
19578 // Settings APIs
19579 getSettingsDomains() {
19580 return api_service_awaiter(this, void 0, void 0, function* () {
19581 const r = yield this.send('GET', '/settings/domains', null, true, true);
19582 return new domainsResponse_DomainsResponse(r);
19583 });
19584 }
19585 putSettingsDomains(request) {
19586 return api_service_awaiter(this, void 0, void 0, function* () {
19587 const r = yield this.send('PUT', '/settings/domains', request, true, true);
19588 return new domainsResponse_DomainsResponse(r);
19589 });
19590 }
19591 // Two-factor APIs
19592 getTwoFactorProviders() {
19593 return api_service_awaiter(this, void 0, void 0, function* () {
19594 const r = yield this.send('GET', '/two-factor', null, true, true);
19595 return new listResponse_ListResponse(r, twoFactorProviderResponse_TwoFactorProviderResponse);
19596 });
19597 }
19598 getTwoFactorOrganizationProviders(organizationId) {
19599 return api_service_awaiter(this, void 0, void 0, function* () {
19600 const r = yield this.send('GET', '/organizations/' + organizationId + '/two-factor', null, true, true);
19601 return new listResponse_ListResponse(r, twoFactorProviderResponse_TwoFactorProviderResponse);
19602 });
19603 }
19604 getTwoFactorAuthenticator(request) {
19605 return api_service_awaiter(this, void 0, void 0, function* () {
19606 const r = yield this.send('POST', '/two-factor/get-authenticator', request, true, true);
19607 return new twoFactorAuthenticatorResponse_TwoFactorAuthenticatorResponse(r);
19608 });
19609 }
19610 getTwoFactorEmail(request) {
19611 return api_service_awaiter(this, void 0, void 0, function* () {
19612 const r = yield this.send('POST', '/two-factor/get-email', request, true, true);
19613 return new twoFactorEmailResponse_TwoFactorEmailResponse(r);
19614 });
19615 }
19616 getTwoFactorDuo(request) {
19617 return api_service_awaiter(this, void 0, void 0, function* () {
19618 const r = yield this.send('POST', '/two-factor/get-duo', request, true, true);
19619 return new twoFactorDuoResponse_TwoFactorDuoResponse(r);
19620 });
19621 }
19622 getTwoFactorOrganizationDuo(organizationId, request) {
19623 return api_service_awaiter(this, void 0, void 0, function* () {
19624 const r = yield this.send('POST', '/organizations/' + organizationId + '/two-factor/get-duo', request, true, true);
19625 return new twoFactorDuoResponse_TwoFactorDuoResponse(r);
19626 });
19627 }
19628 getTwoFactorYubiKey(request) {
19629 return api_service_awaiter(this, void 0, void 0, function* () {
19630 const r = yield this.send('POST', '/two-factor/get-yubikey', request, true, true);
19631 return new twoFactorYubiKeyResponse_TwoFactorYubiKeyResponse(r);
19632 });
19633 }
19634 getTwoFactorU2f(request) {
19635 return api_service_awaiter(this, void 0, void 0, function* () {
19636 const r = yield this.send('POST', '/two-factor/get-u2f', request, true, true);
19637 return new twoFactorU2fResponse_TwoFactorU2fResponse(r);
19638 });
19639 }
19640 getTwoFactorU2fChallenge(request) {
19641 return api_service_awaiter(this, void 0, void 0, function* () {
19642 const r = yield this.send('POST', '/two-factor/get-u2f-challenge', request, true, true);
19643 return new twoFactorU2fResponse_ChallengeResponse(r);
19644 });
19645 }
19646 getTwoFactorRecover(request) {
19647 return api_service_awaiter(this, void 0, void 0, function* () {
19648 const r = yield this.send('POST', '/two-factor/get-recover', request, true, true);
19649 return new twoFactorRescoverResponse_TwoFactorRecoverResponse(r);
19650 });
19651 }
19652 putTwoFactorAuthenticator(request) {
19653 return api_service_awaiter(this, void 0, void 0, function* () {
19654 const r = yield this.send('PUT', '/two-factor/authenticator', request, true, true);
19655 return new twoFactorAuthenticatorResponse_TwoFactorAuthenticatorResponse(r);
19656 });
19657 }
19658 putTwoFactorEmail(request) {
19659 return api_service_awaiter(this, void 0, void 0, function* () {
19660 const r = yield this.send('PUT', '/two-factor/email', request, true, true);
19661 return new twoFactorEmailResponse_TwoFactorEmailResponse(r);
19662 });
19663 }
19664 putTwoFactorDuo(request) {
19665 return api_service_awaiter(this, void 0, void 0, function* () {
19666 const r = yield this.send('PUT', '/two-factor/duo', request, true, true);
19667 return new twoFactorDuoResponse_TwoFactorDuoResponse(r);
19668 });
19669 }
19670 putTwoFactorOrganizationDuo(organizationId, request) {
19671 return api_service_awaiter(this, void 0, void 0, function* () {
19672 const r = yield this.send('PUT', '/organizations/' + organizationId + '/two-factor/duo', request, true, true);
19673 return new twoFactorDuoResponse_TwoFactorDuoResponse(r);
19674 });
19675 }
19676 putTwoFactorYubiKey(request) {
19677 return api_service_awaiter(this, void 0, void 0, function* () {
19678 const r = yield this.send('PUT', '/two-factor/yubikey', request, true, true);
19679 return new twoFactorYubiKeyResponse_TwoFactorYubiKeyResponse(r);
19680 });
19681 }
19682 putTwoFactorU2f(request) {
19683 return api_service_awaiter(this, void 0, void 0, function* () {
19684 const r = yield this.send('PUT', '/two-factor/u2f', request, true, true);
19685 return new twoFactorU2fResponse_TwoFactorU2fResponse(r);
19686 });
19687 }
19688 deleteTwoFactorU2f(request) {
19689 return api_service_awaiter(this, void 0, void 0, function* () {
19690 const r = yield this.send('DELETE', '/two-factor/u2f', request, true, true);
19691 return new twoFactorU2fResponse_TwoFactorU2fResponse(r);
19692 });
19693 }
19694 putTwoFactorDisable(request) {
19695 return api_service_awaiter(this, void 0, void 0, function* () {
19696 const r = yield this.send('PUT', '/two-factor/disable', request, true, true);
19697 return new twoFactorProviderResponse_TwoFactorProviderResponse(r);
19698 });
19699 }
19700 putTwoFactorOrganizationDisable(organizationId, request) {
19701 return api_service_awaiter(this, void 0, void 0, function* () {
19702 const r = yield this.send('PUT', '/organizations/' + organizationId + '/two-factor/disable', request, true, true);
19703 return new twoFactorProviderResponse_TwoFactorProviderResponse(r);
19704 });
19705 }
19706 postTwoFactorRecover(request) {
19707 return this.send('POST', '/two-factor/recover', request, false, false);
19708 }
19709 postTwoFactorEmailSetup(request) {
19710 return this.send('POST', '/two-factor/send-email', request, true, false);
19711 }
19712 postTwoFactorEmail(request) {
19713 return this.send('POST', '/two-factor/send-email-login', request, false, false);
19714 }
19715 // Organization APIs
19716 getOrganization(id) {
19717 return api_service_awaiter(this, void 0, void 0, function* () {
19718 const r = yield this.send('GET', '/organizations/' + id, null, true, true);
19719 return new organizationResponse_OrganizationResponse(r);
19720 });
19721 }
19722 getOrganizationBilling(id) {
19723 return api_service_awaiter(this, void 0, void 0, function* () {
19724 const r = yield this.send('GET', '/organizations/' + id + '/billing', null, true, true);
19725 return new billingResponse_BillingResponse(r);
19726 });
19727 }
19728 getOrganizationSubscription(id) {
19729 return api_service_awaiter(this, void 0, void 0, function* () {
19730 const r = yield this.send('GET', '/organizations/' + id + '/subscription', null, true, true);
19731 return new organizationSubscriptionResponse_OrganizationSubscriptionResponse(r);
19732 });
19733 }
19734 getOrganizationLicense(id, installationId) {
19735 return api_service_awaiter(this, void 0, void 0, function* () {
19736 return this.send('GET', '/organizations/' + id + '/license?installationId=' + installationId, null, true, true);
19737 });
19738 }
19739 getOrganizationTaxInfo(id) {
19740 return api_service_awaiter(this, void 0, void 0, function* () {
19741 const r = yield this.send('GET', '/organizations/' + id + '/tax', null, true, true);
19742 return new taxInfoResponse_TaxInfoResponse(r);
19743 });
19744 }
19745 postOrganization(request) {
19746 return api_service_awaiter(this, void 0, void 0, function* () {
19747 const r = yield this.send('POST', '/organizations', request, true, true);
19748 return new organizationResponse_OrganizationResponse(r);
19749 });
19750 }
19751 putOrganization(id, request) {
19752 return api_service_awaiter(this, void 0, void 0, function* () {
19753 const r = yield this.send('PUT', '/organizations/' + id, request, true, true);
19754 return new organizationResponse_OrganizationResponse(r);
19755 });
19756 }
19757 putOrganizationTaxInfo(id, request) {
19758 return api_service_awaiter(this, void 0, void 0, function* () {
19759 return this.send('PUT', '/organizations/' + id + '/tax', request, true, false);
19760 });
19761 }
19762 postLeaveOrganization(id) {
19763 return this.send('POST', '/organizations/' + id + '/leave', null, true, false);
19764 }
19765 postOrganizationLicense(data) {
19766 return api_service_awaiter(this, void 0, void 0, function* () {
19767 const r = yield this.send('POST', '/organizations/license', data, true, true);
19768 return new organizationResponse_OrganizationResponse(r);
19769 });
19770 }
19771 postOrganizationLicenseUpdate(id, data) {
19772 return api_service_awaiter(this, void 0, void 0, function* () {
19773 return this.send('POST', '/organizations/' + id + '/license', data, true, false);
19774 });
19775 }
19776 postOrganizationApiKey(id, request) {
19777 return api_service_awaiter(this, void 0, void 0, function* () {
19778 const r = yield this.send('POST', '/organizations/' + id + '/api-key', request, true, true);
19779 return new apiKeyResponse_ApiKeyResponse(r);
19780 });
19781 }
19782 postOrganizationRotateApiKey(id, request) {
19783 return api_service_awaiter(this, void 0, void 0, function* () {
19784 const r = yield this.send('POST', '/organizations/' + id + '/rotate-api-key', request, true, true);
19785 return new apiKeyResponse_ApiKeyResponse(r);
19786 });
19787 }
19788 postOrganizationUpgrade(id, request) {
19789 return api_service_awaiter(this, void 0, void 0, function* () {
19790 const r = yield this.send('POST', '/organizations/' + id + '/upgrade', request, true, true);
19791 return new paymentResponse_PaymentResponse(r);
19792 });
19793 }
19794 postOrganizationSeat(id, request) {
19795 return api_service_awaiter(this, void 0, void 0, function* () {
19796 const r = yield this.send('POST', '/organizations/' + id + '/seat', request, true, true);
19797 return new paymentResponse_PaymentResponse(r);
19798 });
19799 }
19800 postOrganizationStorage(id, request) {
19801 return api_service_awaiter(this, void 0, void 0, function* () {
19802 const r = yield this.send('POST', '/organizations/' + id + '/storage', request, true, true);
19803 return new paymentResponse_PaymentResponse(r);
19804 });
19805 }
19806 postOrganizationPayment(id, request) {
19807 return this.send('POST', '/organizations/' + id + '/payment', request, true, false);
19808 }
19809 postOrganizationVerifyBank(id, request) {
19810 return this.send('POST', '/organizations/' + id + '/verify-bank', request, true, false);
19811 }
19812 postOrganizationCancel(id) {
19813 return this.send('POST', '/organizations/' + id + '/cancel', null, true, false);
19814 }
19815 postOrganizationReinstate(id) {
19816 return this.send('POST', '/organizations/' + id + '/reinstate', null, true, false);
19817 }
19818 deleteOrganization(id, request) {
19819 return this.send('DELETE', '/organizations/' + id, request, true, false);
19820 }
19821 // Event APIs
19822 getEvents(start, end, token) {
19823 return api_service_awaiter(this, void 0, void 0, function* () {
19824 const r = yield this.send('GET', this.addEventParameters('/events', start, end, token), null, true, true);
19825 return new listResponse_ListResponse(r, eventResponse_EventResponse);
19826 });
19827 }
19828 getEventsCipher(id, start, end, token) {
19829 return api_service_awaiter(this, void 0, void 0, function* () {
19830 const r = yield this.send('GET', this.addEventParameters('/ciphers/' + id + '/events', start, end, token), null, true, true);
19831 return new listResponse_ListResponse(r, eventResponse_EventResponse);
19832 });
19833 }
19834 getEventsOrganization(id, start, end, token) {
19835 return api_service_awaiter(this, void 0, void 0, function* () {
19836 const r = yield this.send('GET', this.addEventParameters('/organizations/' + id + '/events', start, end, token), null, true, true);
19837 return new listResponse_ListResponse(r, eventResponse_EventResponse);
19838 });
19839 }
19840 getEventsOrganizationUser(organizationId, id, start, end, token) {
19841 return api_service_awaiter(this, void 0, void 0, function* () {
19842 const r = yield this.send('GET', this.addEventParameters('/organizations/' + organizationId + '/users/' + id + '/events', start, end, token), null, true, true);
19843 return new listResponse_ListResponse(r, eventResponse_EventResponse);
19844 });
19845 }
19846 postEventsCollect(request) {
19847 return api_service_awaiter(this, void 0, void 0, function* () {
19848 const authHeader = yield this.getActiveBearerToken();
19849 const headers = new Headers({
19850 'Device-Type': this.deviceType,
19851 'Authorization': 'Bearer ' + authHeader,
19852 'Content-Type': 'application/json; charset=utf-8',
19853 });
19854 if (this.customUserAgent != null) {
19855 headers.set('User-Agent', this.customUserAgent);
19856 }
19857 const response = yield this.fetch(new Request(this.eventsBaseUrl + '/collect', {
19858 cache: 'no-store',
19859 credentials: this.getCredentials(),
19860 method: 'POST',
19861 body: JSON.stringify(request),
19862 headers: headers,
19863 }));
19864 if (response.status !== 200) {
19865 return Promise.reject('Event post failed.');
19866 }
19867 });
19868 }
19869 // User APIs
19870 getUserPublicKey(id) {
19871 return api_service_awaiter(this, void 0, void 0, function* () {
19872 const r = yield this.send('GET', '/users/' + id + '/public-key', null, true, true);
19873 return new userKeyResponse_UserKeyResponse(r);
19874 });
19875 }
19876 // HIBP APIs
19877 getHibpBreach(username) {
19878 return api_service_awaiter(this, void 0, void 0, function* () {
19879 const r = yield this.send('GET', '/hibp/breach?username=' + username, null, true, true);
19880 return r.map((a) => new breachAccountResponse_BreachAccountResponse(a));
19881 });
19882 }
19883 // Misc
19884 postBitPayInvoice(request) {
19885 return api_service_awaiter(this, void 0, void 0, function* () {
19886 const r = yield this.send('POST', '/bitpay-invoice', request, true, true);
19887 return r;
19888 });
19889 }
19890 postSetupPayment() {
19891 return api_service_awaiter(this, void 0, void 0, function* () {
19892 const r = yield this.send('POST', '/setup-payment', null, true, true);
19893 return r;
19894 });
19895 }
19896 // Helpers
19897 getActiveBearerToken() {
19898 return api_service_awaiter(this, void 0, void 0, function* () {
19899 let accessToken = yield this.tokenService.getToken();
19900 if (this.tokenService.tokenNeedsRefresh()) {
19901 const tokenResponse = yield this.doRefreshToken();
19902 accessToken = tokenResponse.accessToken;
19903 }
19904 return accessToken;
19905 });
19906 }
19907 fetch(request) {
19908 if (request.method === 'GET') {
19909 request.headers.set('Cache-Control', 'no-store');
19910 request.headers.set('Pragma', 'no-cache');
19911 }
19912 return this.nativeFetch(request);
19913 }
19914 nativeFetch(request) {
19915 return fetch(request);
19916 }
19917 send(method, path, body, authed, hasResponse) {
19918 return api_service_awaiter(this, void 0, void 0, function* () {
19919 const headers = new Headers({
19920 'Device-Type': this.deviceType,
19921 });
19922 if (this.customUserAgent != null) {
19923 headers.set('User-Agent', this.customUserAgent);
19924 }
19925 const requestInit = {
19926 cache: 'no-store',
19927 credentials: this.getCredentials(),
19928 method: method,
19929 };
19930 if (authed) {
19931 const authHeader = yield this.getActiveBearerToken();
19932 headers.set('Authorization', 'Bearer ' + authHeader);
19933 }
19934 if (body != null) {
19935 if (typeof body === 'string') {
19936 requestInit.body = body;
19937 headers.set('Content-Type', 'application/x-www-form-urlencoded; charset=utf-8');
19938 }
19939 else if (typeof body === 'object') {
19940 if (body instanceof FormData) {
19941 requestInit.body = body;
19942 }
19943 else {
19944 headers.set('Content-Type', 'application/json; charset=utf-8');
19945 requestInit.body = JSON.stringify(body);
19946 }
19947 }
19948 }
19949 if (hasResponse) {
19950 headers.set('Accept', 'application/json');
19951 }
19952 requestInit.headers = headers;
19953 const response = yield this.fetch(new Request(this.apiBaseUrl + path, requestInit));
19954 if (hasResponse && response.status === 200) {
19955 const responseJson = yield response.json();
19956 return responseJson;
19957 }
19958 else if (response.status !== 200) {
19959 const error = yield this.handleError(response, false);
19960 return Promise.reject(error);
19961 }
19962 });
19963 }
19964 handleError(response, tokenError) {
19965 return api_service_awaiter(this, void 0, void 0, function* () {
19966 if ((tokenError && response.status === 400) || response.status === 401 || response.status === 403) {
19967 yield this.logoutCallback(true);
19968 return null;
19969 }
19970 let responseJson = null;
19971 if (this.isJsonResponse(response)) {
19972 responseJson = yield response.json();
19973 }
19974 return new errorResponse_ErrorResponse(responseJson, response.status, tokenError);
19975 });
19976 }
19977 doRefreshToken() {
19978 return api_service_awaiter(this, void 0, void 0, function* () {
19979 const refreshToken = yield this.tokenService.getRefreshToken();
19980 if (refreshToken == null || refreshToken === '') {
19981 throw new Error();
19982 }
19983 const headers = new Headers({
19984 'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8',
19985 'Accept': 'application/json',
19986 'Device-Type': this.deviceType,
19987 });
19988 if (this.customUserAgent != null) {
19989 headers.set('User-Agent', this.customUserAgent);
19990 }
19991 const decodedToken = this.tokenService.decodeToken();
19992 const response = yield this.fetch(new Request(this.identityBaseUrl + '/connect/token', {
19993 body: this.qsStringify({
19994 grant_type: 'refresh_token',
19995 client_id: decodedToken.client_id,
19996 refresh_token: refreshToken,
19997 }),
19998 cache: 'no-store',
19999 credentials: this.getCredentials(),
20000 headers: headers,
20001 method: 'POST',
20002 }));
20003 if (response.status === 200) {
20004 const responseJson = yield response.json();
20005 const tokenResponse = new identityTokenResponse_IdentityTokenResponse(responseJson);
20006 yield this.tokenService.setTokens(tokenResponse.accessToken, tokenResponse.refreshToken);
20007 return tokenResponse;
20008 }
20009 else {
20010 const error = yield this.handleError(response, true);
20011 return Promise.reject(error);
20012 }
20013 });
20014 }
20015 qsStringify(params) {
20016 return Object.keys(params).map((key) => {
20017 return encodeURIComponent(key) + '=' + encodeURIComponent(params[key]);
20018 }).join('&');
20019 }
20020 getCredentials() {
20021 if (this.device !== DeviceType.SafariExtension && (!this.isWebClient || this.usingBaseUrl)) {
20022 return 'include';
20023 }
20024 return undefined;
20025 }
20026 addEventParameters(base, start, end, token) {
20027 if (start != null) {
20028 base += ('?start=' + start);
20029 }
20030 if (end != null) {
20031 base += (base.indexOf('?') > -1 ? '&' : '?');
20032 base += ('end=' + end);
20033 }
20034 if (token != null) {
20035 base += (base.indexOf('?') > -1 ? '&' : '?');
20036 base += ('continuationToken=' + token);
20037 }
20038 return base;
20039 }
20040 isJsonResponse(response) {
20041 const typeHeader = response.headers.get('content-type');
20042 return typeHeader != null && typeHeader.indexOf('application/json') > -1;
20043 }
20044}
20045
20046// CONCATENATED MODULE: ./jslib/src/services/nodeApi.service.ts
20047
20048
20049
20050
20051global.fetch = external_node_fetch_default.a;
20052global.Request = external_node_fetch_["Request"];
20053global.Response = external_node_fetch_["Response"];
20054global.Headers = external_node_fetch_["Headers"];
20055global.FormData = external_form_data_;
20056class nodeApi_service_NodeApiService extends api_service_ApiService {
20057 constructor(tokenService, platformUtilsService, logoutCallback, customUserAgent = null) {
20058 super(tokenService, platformUtilsService, logoutCallback, customUserAgent);
20059 }
20060 nativeFetch(request) {
20061 const proxy = process.env.http_proxy || process.env.https_proxy;
20062 if (proxy) {
20063 request.agent = new external_https_proxy_agent_(proxy);
20064 }
20065 return fetch(request);
20066 }
20067}
20068
20069// EXTERNAL MODULE: external "crypto"
20070var external_crypto_ = __webpack_require__(6);
20071
20072// EXTERNAL MODULE: external "node-forge"
20073var external_node_forge_ = __webpack_require__(2);
20074
20075// CONCATENATED MODULE: ./jslib/src/models/domain/decryptParameters.ts
20076class DecryptParameters {
20077}
20078
20079// CONCATENATED MODULE: ./jslib/src/services/nodeCryptoFunction.service.ts
20080var nodeCryptoFunction_service_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
20081 return new (P || (P = Promise))(function (resolve, reject) {
20082 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
20083 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
20084 function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
20085 step((generator = generator.apply(thisArg, _arguments || [])).next());
20086 });
20087};
20088
20089
20090
20091
20092class nodeCryptoFunction_service_NodeCryptoFunctionService {
20093 pbkdf2(password, salt, algorithm, iterations) {
20094 const len = algorithm === 'sha256' ? 32 : 64;
20095 const nodePassword = this.toNodeValue(password);
20096 const nodeSalt = this.toNodeValue(salt);
20097 return new Promise((resolve, reject) => {
20098 external_crypto_["pbkdf2"](nodePassword, nodeSalt, iterations, len, algorithm, (error, key) => {
20099 if (error != null) {
20100 reject(error);
20101 }
20102 else {
20103 resolve(this.toArrayBuffer(key));
20104 }
20105 });
20106 });
20107 }
20108 hash(value, algorithm) {
20109 const nodeValue = this.toNodeValue(value);
20110 const hash = external_crypto_["createHash"](algorithm);
20111 hash.update(nodeValue);
20112 return Promise.resolve(this.toArrayBuffer(hash.digest()));
20113 }
20114 hmac(value, key, algorithm) {
20115 const nodeValue = this.toNodeBuffer(value);
20116 const nodeKey = this.toNodeBuffer(key);
20117 const hmac = external_crypto_["createHmac"](algorithm, nodeKey);
20118 hmac.update(nodeValue);
20119 return Promise.resolve(this.toArrayBuffer(hmac.digest()));
20120 }
20121 compare(a, b) {
20122 return nodeCryptoFunction_service_awaiter(this, void 0, void 0, function* () {
20123 const key = yield this.randomBytes(32);
20124 const mac1 = yield this.hmac(a, key, 'sha256');
20125 const mac2 = yield this.hmac(b, key, 'sha256');
20126 if (mac1.byteLength !== mac2.byteLength) {
20127 return false;
20128 }
20129 const arr1 = new Uint8Array(mac1);
20130 const arr2 = new Uint8Array(mac2);
20131 for (let i = 0; i < arr2.length; i++) {
20132 if (arr1[i] !== arr2[i]) {
20133 return false;
20134 }
20135 }
20136 return true;
20137 });
20138 }
20139 hmacFast(value, key, algorithm) {
20140 return this.hmac(value, key, algorithm);
20141 }
20142 compareFast(a, b) {
20143 return this.compare(a, b);
20144 }
20145 aesEncrypt(data, iv, key) {
20146 const nodeData = this.toNodeBuffer(data);
20147 const nodeIv = this.toNodeBuffer(iv);
20148 const nodeKey = this.toNodeBuffer(key);
20149 const cipher = external_crypto_["createCipheriv"]('aes-256-cbc', nodeKey, nodeIv);
20150 const encBuf = Buffer.concat([cipher.update(nodeData), cipher.final()]);
20151 return Promise.resolve(this.toArrayBuffer(encBuf));
20152 }
20153 aesDecryptFastParameters(data, iv, mac, key) {
20154 const p = new DecryptParameters();
20155 p.encKey = key.encKey;
20156 p.data = utils_Utils.fromB64ToArray(data).buffer;
20157 p.iv = utils_Utils.fromB64ToArray(iv).buffer;
20158 const macData = new Uint8Array(p.iv.byteLength + p.data.byteLength);
20159 macData.set(new Uint8Array(p.iv), 0);
20160 macData.set(new Uint8Array(p.data), p.iv.byteLength);
20161 p.macData = macData.buffer;
20162 if (key.macKey != null) {
20163 p.macKey = key.macKey;
20164 }
20165 if (mac != null) {
20166 p.mac = utils_Utils.fromB64ToArray(mac).buffer;
20167 }
20168 return p;
20169 }
20170 aesDecryptFast(parameters) {
20171 return nodeCryptoFunction_service_awaiter(this, void 0, void 0, function* () {
20172 const decBuf = yield this.aesDecrypt(parameters.data, parameters.iv, parameters.encKey);
20173 return utils_Utils.fromBufferToUtf8(decBuf);
20174 });
20175 }
20176 aesDecrypt(data, iv, key) {
20177 const nodeData = this.toNodeBuffer(data);
20178 const nodeIv = this.toNodeBuffer(iv);
20179 const nodeKey = this.toNodeBuffer(key);
20180 const decipher = external_crypto_["createDecipheriv"]('aes-256-cbc', nodeKey, nodeIv);
20181 const decBuf = Buffer.concat([decipher.update(nodeData), decipher.final()]);
20182 return Promise.resolve(this.toArrayBuffer(decBuf));
20183 }
20184 rsaEncrypt(data, publicKey, algorithm) {
20185 if (algorithm === 'sha256') {
20186 throw new Error('Node crypto does not support RSA-OAEP SHA-256');
20187 }
20188 const pem = this.toPemPublicKey(publicKey);
20189 const decipher = external_crypto_["publicEncrypt"](pem, this.toNodeBuffer(data));
20190 return Promise.resolve(this.toArrayBuffer(decipher));
20191 }
20192 rsaDecrypt(data, privateKey, algorithm) {
20193 if (algorithm === 'sha256') {
20194 throw new Error('Node crypto does not support RSA-OAEP SHA-256');
20195 }
20196 const pem = this.toPemPrivateKey(privateKey);
20197 const decipher = external_crypto_["privateDecrypt"](pem, this.toNodeBuffer(data));
20198 return Promise.resolve(this.toArrayBuffer(decipher));
20199 }
20200 rsaExtractPublicKey(privateKey) {
20201 const privateKeyByteString = utils_Utils.fromBufferToByteString(privateKey);
20202 const privateKeyAsn1 = external_node_forge_["asn1"].fromDer(privateKeyByteString);
20203 const forgePrivateKey = external_node_forge_["pki"].privateKeyFromAsn1(privateKeyAsn1);
20204 const forgePublicKey = external_node_forge_["pki"].setRsaPublicKey(forgePrivateKey.n, forgePrivateKey.e);
20205 const publicKeyAsn1 = external_node_forge_["pki"].publicKeyToAsn1(forgePublicKey);
20206 const publicKeyByteString = external_node_forge_["asn1"].toDer(publicKeyAsn1).data;
20207 const publicKeyArray = utils_Utils.fromByteStringToArray(publicKeyByteString);
20208 return Promise.resolve(publicKeyArray.buffer);
20209 }
20210 rsaGenerateKeyPair(length) {
20211 return nodeCryptoFunction_service_awaiter(this, void 0, void 0, function* () {
20212 return new Promise((resolve, reject) => {
20213 external_node_forge_["pki"].rsa.generateKeyPair({
20214 bits: length,
20215 workers: -1,
20216 e: 0x10001,
20217 }, (error, keyPair) => {
20218 if (error != null) {
20219 reject(error);
20220 return;
20221 }
20222 const publicKeyAsn1 = external_node_forge_["pki"].publicKeyToAsn1(keyPair.publicKey);
20223 const publicKeyByteString = external_node_forge_["asn1"].toDer(publicKeyAsn1).getBytes();
20224 const publicKey = utils_Utils.fromByteStringToArray(publicKeyByteString);
20225 const privateKeyAsn1 = external_node_forge_["pki"].privateKeyToAsn1(keyPair.privateKey);
20226 const privateKeyPkcs8 = external_node_forge_["pki"].wrapRsaPrivateKey(privateKeyAsn1);
20227 const privateKeyByteString = external_node_forge_["asn1"].toDer(privateKeyPkcs8).getBytes();
20228 const privateKey = utils_Utils.fromByteStringToArray(privateKeyByteString);
20229 resolve([publicKey.buffer, privateKey.buffer]);
20230 });
20231 });
20232 });
20233 }
20234 randomBytes(length) {
20235 return new Promise((resolve, reject) => {
20236 external_crypto_["randomBytes"](length, (error, bytes) => {
20237 if (error != null) {
20238 reject(error);
20239 }
20240 else {
20241 resolve(this.toArrayBuffer(bytes));
20242 }
20243 });
20244 });
20245 }
20246 toNodeValue(value) {
20247 let nodeValue;
20248 if (typeof (value) === 'string') {
20249 nodeValue = value;
20250 }
20251 else {
20252 nodeValue = this.toNodeBuffer(value);
20253 }
20254 return nodeValue;
20255 }
20256 toNodeBuffer(value) {
20257 return Buffer.from(new Uint8Array(value));
20258 }
20259 toArrayBuffer(buf) {
20260 return new Uint8Array(buf).buffer;
20261 }
20262 toPemPrivateKey(key) {
20263 const byteString = utils_Utils.fromBufferToByteString(key);
20264 const asn1 = external_node_forge_["asn1"].fromDer(byteString);
20265 const privateKey = external_node_forge_["pki"].privateKeyFromAsn1(asn1);
20266 const rsaPrivateKey = external_node_forge_["pki"].privateKeyToAsn1(privateKey);
20267 const privateKeyInfo = external_node_forge_["pki"].wrapRsaPrivateKey(rsaPrivateKey);
20268 return external_node_forge_["pki"].privateKeyInfoToPem(privateKeyInfo);
20269 }
20270 toPemPublicKey(key) {
20271 const byteString = utils_Utils.fromBufferToByteString(key);
20272 const asn1 = external_node_forge_["asn1"].fromDer(byteString);
20273 const publicKey = external_node_forge_["pki"].publicKeyFromAsn1(asn1);
20274 return external_node_forge_["pki"].publicKeyToPem(publicKey);
20275 }
20276}
20277
20278// CONCATENATED MODULE: ./jslib/src/services/noopMessaging.service.ts
20279class NoopMessagingService {
20280 send(subscriber, arg = {}) {
20281 // Do nothing...
20282 }
20283}
20284
20285// EXTERNAL MODULE: external "zxcvbn"
20286var external_zxcvbn_ = __webpack_require__(18);
20287
20288// CONCATENATED MODULE: ./jslib/src/models/domain/passwordGeneratorPolicyOptions.ts
20289
20290class passwordGeneratorPolicyOptions_PasswordGeneratorPolicyOptions extends domainBase_Domain {
20291 constructor() {
20292 super(...arguments);
20293 this.defaultType = '';
20294 this.minLength = 0;
20295 this.useUppercase = false;
20296 this.useLowercase = false;
20297 this.useNumbers = false;
20298 this.numberCount = 0;
20299 this.useSpecial = false;
20300 this.specialCount = 0;
20301 this.minNumberWords = 0;
20302 this.capitalize = false;
20303 this.includeNumber = false;
20304 }
20305 inEffect() {
20306 return this.defaultType !== '' ||
20307 this.minLength > 0 ||
20308 this.numberCount > 0 ||
20309 this.specialCount > 0 ||
20310 this.useUppercase ||
20311 this.useLowercase ||
20312 this.useNumbers ||
20313 this.useSpecial ||
20314 this.minNumberWords > 0 ||
20315 this.capitalize ||
20316 this.includeNumber;
20317 }
20318}
20319
20320// CONCATENATED MODULE: ./jslib/src/enums/policyType.ts
20321var PolicyType;
20322(function (PolicyType) {
20323 PolicyType[PolicyType["TwoFactorAuthentication"] = 0] = "TwoFactorAuthentication";
20324 PolicyType[PolicyType["MasterPassword"] = 1] = "MasterPassword";
20325 PolicyType[PolicyType["PasswordGenerator"] = 2] = "PasswordGenerator";
20326})(PolicyType || (PolicyType = {}));
20327
20328// CONCATENATED MODULE: ./jslib/src/services/passwordGeneration.service.ts
20329var passwordGeneration_service_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
20330 return new (P || (P = Promise))(function (resolve, reject) {
20331 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
20332 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
20333 function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
20334 step((generator = generator.apply(thisArg, _arguments || [])).next());
20335 });
20336};
20337
20338
20339
20340
20341
20342
20343const DefaultOptions = {
20344 length: 14,
20345 ambiguous: false,
20346 number: true,
20347 minNumber: 1,
20348 uppercase: true,
20349 minUppercase: 0,
20350 lowercase: true,
20351 minLowercase: 0,
20352 special: false,
20353 minSpecial: 1,
20354 type: 'password',
20355 numWords: 3,
20356 wordSeparator: '-',
20357 capitalize: false,
20358 includeNumber: false,
20359};
20360const passwordGeneration_service_Keys = {
20361 options: 'passwordGenerationOptions',
20362 history: 'generatedPasswordHistory',
20363};
20364const MaxPasswordsInHistory = 100;
20365class passwordGeneration_service_PasswordGenerationService {
20366 constructor(cryptoService, storageService, policyService) {
20367 this.cryptoService = cryptoService;
20368 this.storageService = storageService;
20369 this.policyService = policyService;
20370 }
20371 generatePassword(options) {
20372 return passwordGeneration_service_awaiter(this, void 0, void 0, function* () {
20373 // overload defaults with given options
20374 const o = Object.assign({}, DefaultOptions, options);
20375 if (o.type === 'passphrase') {
20376 return this.generatePassphrase(options);
20377 }
20378 // sanitize
20379 this.sanitizePasswordLength(o, true);
20380 const minLength = o.minUppercase + o.minLowercase + o.minNumber + o.minSpecial;
20381 if (o.length < minLength) {
20382 o.length = minLength;
20383 }
20384 const positions = [];
20385 if (o.lowercase && o.minLowercase > 0) {
20386 for (let i = 0; i < o.minLowercase; i++) {
20387 positions.push('l');
20388 }
20389 }
20390 if (o.uppercase && o.minUppercase > 0) {
20391 for (let i = 0; i < o.minUppercase; i++) {
20392 positions.push('u');
20393 }
20394 }
20395 if (o.number && o.minNumber > 0) {
20396 for (let i = 0; i < o.minNumber; i++) {
20397 positions.push('n');
20398 }
20399 }
20400 if (o.special && o.minSpecial > 0) {
20401 for (let i = 0; i < o.minSpecial; i++) {
20402 positions.push('s');
20403 }
20404 }
20405 while (positions.length < o.length) {
20406 positions.push('a');
20407 }
20408 // shuffle
20409 yield this.shuffleArray(positions);
20410 // build out the char sets
20411 let allCharSet = '';
20412 let lowercaseCharSet = 'abcdefghijkmnopqrstuvwxyz';
20413 if (o.ambiguous) {
20414 lowercaseCharSet += 'l';
20415 }
20416 if (o.lowercase) {
20417 allCharSet += lowercaseCharSet;
20418 }
20419 let uppercaseCharSet = 'ABCDEFGHJKLMNPQRSTUVWXYZ';
20420 if (o.ambiguous) {
20421 uppercaseCharSet += 'IO';
20422 }
20423 if (o.uppercase) {
20424 allCharSet += uppercaseCharSet;
20425 }
20426 let numberCharSet = '23456789';
20427 if (o.ambiguous) {
20428 numberCharSet += '01';
20429 }
20430 if (o.number) {
20431 allCharSet += numberCharSet;
20432 }
20433 const specialCharSet = '!@#$%^&*';
20434 if (o.special) {
20435 allCharSet += specialCharSet;
20436 }
20437 let password = '';
20438 for (let i = 0; i < o.length; i++) {
20439 let positionChars;
20440 switch (positions[i]) {
20441 case 'l':
20442 positionChars = lowercaseCharSet;
20443 break;
20444 case 'u':
20445 positionChars = uppercaseCharSet;
20446 break;
20447 case 'n':
20448 positionChars = numberCharSet;
20449 break;
20450 case 's':
20451 positionChars = specialCharSet;
20452 break;
20453 case 'a':
20454 positionChars = allCharSet;
20455 break;
20456 default:
20457 break;
20458 }
20459 const randomCharIndex = yield this.cryptoService.randomNumber(0, positionChars.length - 1);
20460 password += positionChars.charAt(randomCharIndex);
20461 }
20462 return password;
20463 });
20464 }
20465 generatePassphrase(options) {
20466 return passwordGeneration_service_awaiter(this, void 0, void 0, function* () {
20467 const o = Object.assign({}, DefaultOptions, options);
20468 if (o.numWords == null || o.numWords <= 2) {
20469 o.numWords = DefaultOptions.numWords;
20470 }
20471 if (o.wordSeparator == null || o.wordSeparator.length === 0 || o.wordSeparator.length > 1) {
20472 o.wordSeparator = ' ';
20473 }
20474 if (o.capitalize == null) {
20475 o.capitalize = false;
20476 }
20477 if (o.includeNumber == null) {
20478 o.includeNumber = false;
20479 }
20480 const listLength = EEFLongWordList.length - 1;
20481 const wordList = new Array(o.numWords);
20482 for (let i = 0; i < o.numWords; i++) {
20483 const wordIndex = yield this.cryptoService.randomNumber(0, listLength);
20484 if (o.capitalize) {
20485 wordList[i] = this.capitalize(EEFLongWordList[wordIndex]);
20486 }
20487 else {
20488 wordList[i] = EEFLongWordList[wordIndex];
20489 }
20490 }
20491 if (o.includeNumber) {
20492 yield this.appendRandomNumberToRandomWord(wordList);
20493 }
20494 return wordList.join(o.wordSeparator);
20495 });
20496 }
20497 getOptions() {
20498 return passwordGeneration_service_awaiter(this, void 0, void 0, function* () {
20499 if (this.optionsCache == null) {
20500 const options = yield this.storageService.get(passwordGeneration_service_Keys.options);
20501 if (options == null) {
20502 this.optionsCache = DefaultOptions;
20503 }
20504 else {
20505 this.optionsCache = Object.assign({}, DefaultOptions, options);
20506 }
20507 }
20508 const enforcedOptions = yield this.enforcePasswordGeneratorPoliciesOnOptions(this.optionsCache);
20509 this.optionsCache = enforcedOptions[0];
20510 return [this.optionsCache, enforcedOptions[1]];
20511 });
20512 }
20513 enforcePasswordGeneratorPoliciesOnOptions(options) {
20514 return passwordGeneration_service_awaiter(this, void 0, void 0, function* () {
20515 let enforcedPolicyOptions = yield this.getPasswordGeneratorPolicyOptions();
20516 if (enforcedPolicyOptions != null) {
20517 if (options.length < enforcedPolicyOptions.minLength) {
20518 options.length = enforcedPolicyOptions.minLength;
20519 }
20520 if (enforcedPolicyOptions.useUppercase) {
20521 options.uppercase = true;
20522 }
20523 if (enforcedPolicyOptions.useLowercase) {
20524 options.lowercase = true;
20525 }
20526 if (enforcedPolicyOptions.useNumbers) {
20527 options.number = true;
20528 }
20529 if (options.minNumber < enforcedPolicyOptions.numberCount) {
20530 options.minNumber = enforcedPolicyOptions.numberCount;
20531 }
20532 if (enforcedPolicyOptions.useSpecial) {
20533 options.special = true;
20534 }
20535 if (options.minSpecial < enforcedPolicyOptions.specialCount) {
20536 options.minSpecial = enforcedPolicyOptions.specialCount;
20537 }
20538 // Must normalize these fields because the receiving call expects all options to pass the current rules
20539 if (options.minSpecial + options.minNumber > options.length) {
20540 options.minSpecial = options.length - options.minNumber;
20541 }
20542 if (options.numWords < enforcedPolicyOptions.minNumberWords) {
20543 options.numWords = enforcedPolicyOptions.minNumberWords;
20544 }
20545 if (enforcedPolicyOptions.capitalize) {
20546 options.capitalize = true;
20547 }
20548 if (enforcedPolicyOptions.includeNumber) {
20549 options.includeNumber = true;
20550 }
20551 // Force default type if password/passphrase selected via policy
20552 if (enforcedPolicyOptions.defaultType === 'password' ||
20553 enforcedPolicyOptions.defaultType === 'passphrase') {
20554 options.type = enforcedPolicyOptions.defaultType;
20555 }
20556 }
20557 else { // UI layer expects an instantiated object to prevent more explicit null checks
20558 enforcedPolicyOptions = new passwordGeneratorPolicyOptions_PasswordGeneratorPolicyOptions();
20559 }
20560 return [options, enforcedPolicyOptions];
20561 });
20562 }
20563 getPasswordGeneratorPolicyOptions() {
20564 return passwordGeneration_service_awaiter(this, void 0, void 0, function* () {
20565 const policies = yield this.policyService.getAll(PolicyType.PasswordGenerator);
20566 let enforcedOptions = null;
20567 if (policies == null || policies.length === 0) {
20568 return enforcedOptions;
20569 }
20570 policies.forEach((currentPolicy) => {
20571 if (!currentPolicy.enabled || currentPolicy.data == null) {
20572 return;
20573 }
20574 if (enforcedOptions == null) {
20575 enforcedOptions = new passwordGeneratorPolicyOptions_PasswordGeneratorPolicyOptions();
20576 }
20577 // Password wins in multi-org collisions
20578 if (currentPolicy.data.defaultType != null && enforcedOptions.defaultType !== 'password') {
20579 enforcedOptions.defaultType = currentPolicy.data.defaultType;
20580 }
20581 if (currentPolicy.data.minLength != null
20582 && currentPolicy.data.minLength > enforcedOptions.minLength) {
20583 enforcedOptions.minLength = currentPolicy.data.minLength;
20584 }
20585 if (currentPolicy.data.useUpper) {
20586 enforcedOptions.useUppercase = true;
20587 }
20588 if (currentPolicy.data.useLower) {
20589 enforcedOptions.useLowercase = true;
20590 }
20591 if (currentPolicy.data.useNumbers) {
20592 enforcedOptions.useNumbers = true;
20593 }
20594 if (currentPolicy.data.minNumbers != null
20595 && currentPolicy.data.minNumbers > enforcedOptions.numberCount) {
20596 enforcedOptions.numberCount = currentPolicy.data.minNumbers;
20597 }
20598 if (currentPolicy.data.useSpecial) {
20599 enforcedOptions.useSpecial = true;
20600 }
20601 if (currentPolicy.data.minSpecial != null
20602 && currentPolicy.data.minSpecial > enforcedOptions.specialCount) {
20603 enforcedOptions.specialCount = currentPolicy.data.minSpecial;
20604 }
20605 if (currentPolicy.data.minNumberWords != null
20606 && currentPolicy.data.minNumberWords > enforcedOptions.minNumberWords) {
20607 enforcedOptions.minNumberWords = currentPolicy.data.minNumberWords;
20608 }
20609 if (currentPolicy.data.capitalize) {
20610 enforcedOptions.capitalize = true;
20611 }
20612 if (currentPolicy.data.includeNumber) {
20613 enforcedOptions.includeNumber = true;
20614 }
20615 });
20616 return enforcedOptions;
20617 });
20618 }
20619 saveOptions(options) {
20620 return passwordGeneration_service_awaiter(this, void 0, void 0, function* () {
20621 yield this.storageService.save(passwordGeneration_service_Keys.options, options);
20622 this.optionsCache = options;
20623 });
20624 }
20625 getHistory() {
20626 return passwordGeneration_service_awaiter(this, void 0, void 0, function* () {
20627 const hasKey = yield this.cryptoService.hasKey();
20628 if (!hasKey) {
20629 return new Array();
20630 }
20631 if (!this.history) {
20632 const encrypted = yield this.storageService.get(passwordGeneration_service_Keys.history);
20633 this.history = yield this.decryptHistory(encrypted);
20634 }
20635 return this.history || new Array();
20636 });
20637 }
20638 addHistory(password) {
20639 return passwordGeneration_service_awaiter(this, void 0, void 0, function* () {
20640 // Cannot add new history if no key is available
20641 const hasKey = yield this.cryptoService.hasKey();
20642 if (!hasKey) {
20643 return;
20644 }
20645 const currentHistory = yield this.getHistory();
20646 // Prevent duplicates
20647 if (this.matchesPrevious(password, currentHistory)) {
20648 return;
20649 }
20650 currentHistory.unshift(new GeneratedPasswordHistory(password, Date.now()));
20651 // Remove old items.
20652 if (currentHistory.length > MaxPasswordsInHistory) {
20653 currentHistory.pop();
20654 }
20655 const newHistory = yield this.encryptHistory(currentHistory);
20656 return yield this.storageService.save(passwordGeneration_service_Keys.history, newHistory);
20657 });
20658 }
20659 clear() {
20660 return passwordGeneration_service_awaiter(this, void 0, void 0, function* () {
20661 this.history = [];
20662 return yield this.storageService.remove(passwordGeneration_service_Keys.history);
20663 });
20664 }
20665 passwordStrength(password, userInputs = null) {
20666 if (password == null || password.length === 0) {
20667 return null;
20668 }
20669 let globalUserInputs = ['bitwarden', 'bit', 'warden'];
20670 if (userInputs != null && userInputs.length > 0) {
20671 globalUserInputs = globalUserInputs.concat(userInputs);
20672 }
20673 // Use a hash set to get rid of any duplicate user inputs
20674 const finalUserInputs = Array.from(new Set(globalUserInputs));
20675 const result = external_zxcvbn_(password, finalUserInputs);
20676 return result;
20677 }
20678 normalizeOptions(options, enforcedPolicyOptions) {
20679 options.minLowercase = 0;
20680 options.minUppercase = 0;
20681 if (!options.length || options.length < 5) {
20682 options.length = 5;
20683 }
20684 else if (options.length > 128) {
20685 options.length = 128;
20686 }
20687 if (options.length < enforcedPolicyOptions.minLength) {
20688 options.length = enforcedPolicyOptions.minLength;
20689 }
20690 if (!options.minNumber) {
20691 options.minNumber = 0;
20692 }
20693 else if (options.minNumber > options.length) {
20694 options.minNumber = options.length;
20695 }
20696 else if (options.minNumber > 9) {
20697 options.minNumber = 9;
20698 }
20699 if (options.minNumber < enforcedPolicyOptions.numberCount) {
20700 options.minNumber = enforcedPolicyOptions.numberCount;
20701 }
20702 if (!options.minSpecial) {
20703 options.minSpecial = 0;
20704 }
20705 else if (options.minSpecial > options.length) {
20706 options.minSpecial = options.length;
20707 }
20708 else if (options.minSpecial > 9) {
20709 options.minSpecial = 9;
20710 }
20711 if (options.minSpecial < enforcedPolicyOptions.specialCount) {
20712 options.minSpecial = enforcedPolicyOptions.specialCount;
20713 }
20714 if (options.minSpecial + options.minNumber > options.length) {
20715 options.minSpecial = options.length - options.minNumber;
20716 }
20717 if (options.numWords == null || options.length < 3) {
20718 options.numWords = 3;
20719 }
20720 else if (options.numWords > 20) {
20721 options.numWords = 20;
20722 }
20723 if (options.numWords < enforcedPolicyOptions.minNumberWords) {
20724 options.numWords = enforcedPolicyOptions.minNumberWords;
20725 }
20726 if (options.wordSeparator != null && options.wordSeparator.length > 1) {
20727 options.wordSeparator = options.wordSeparator[0];
20728 }
20729 this.sanitizePasswordLength(options, false);
20730 }
20731 capitalize(str) {
20732 return str.charAt(0).toUpperCase() + str.slice(1);
20733 }
20734 appendRandomNumberToRandomWord(wordList) {
20735 return passwordGeneration_service_awaiter(this, void 0, void 0, function* () {
20736 if (wordList == null || wordList.length <= 0) {
20737 return;
20738 }
20739 const index = yield this.cryptoService.randomNumber(0, wordList.length - 1);
20740 const num = yield this.cryptoService.randomNumber(0, 9);
20741 wordList[index] = wordList[index] + num;
20742 });
20743 }
20744 encryptHistory(history) {
20745 return passwordGeneration_service_awaiter(this, void 0, void 0, function* () {
20746 if (history == null || history.length === 0) {
20747 return Promise.resolve([]);
20748 }
20749 const promises = history.map((item) => passwordGeneration_service_awaiter(this, void 0, void 0, function* () {
20750 const encrypted = yield this.cryptoService.encrypt(item.password);
20751 return new GeneratedPasswordHistory(encrypted.encryptedString, item.date);
20752 }));
20753 return yield Promise.all(promises);
20754 });
20755 }
20756 decryptHistory(history) {
20757 return passwordGeneration_service_awaiter(this, void 0, void 0, function* () {
20758 if (history == null || history.length === 0) {
20759 return Promise.resolve([]);
20760 }
20761 const promises = history.map((item) => passwordGeneration_service_awaiter(this, void 0, void 0, function* () {
20762 const decrypted = yield this.cryptoService.decryptToUtf8(new cipherString_CipherString(item.password));
20763 return new GeneratedPasswordHistory(decrypted, item.date);
20764 }));
20765 return yield Promise.all(promises);
20766 });
20767 }
20768 matchesPrevious(password, history) {
20769 if (history == null || history.length === 0) {
20770 return false;
20771 }
20772 return history[history.length - 1].password === password;
20773 }
20774 // ref: https://stackoverflow.com/a/12646864/1090359
20775 shuffleArray(array) {
20776 return passwordGeneration_service_awaiter(this, void 0, void 0, function* () {
20777 for (let i = array.length - 1; i > 0; i--) {
20778 const j = yield this.cryptoService.randomNumber(0, i);
20779 [array[i], array[j]] = [array[j], array[i]];
20780 }
20781 });
20782 }
20783 sanitizePasswordLength(options, forGeneration) {
20784 let minUppercaseCalc = 0;
20785 let minLowercaseCalc = 0;
20786 let minNumberCalc = options.minNumber;
20787 let minSpecialCalc = options.minSpecial;
20788 if (options.uppercase && options.minUppercase <= 0) {
20789 minUppercaseCalc = 1;
20790 }
20791 else if (!options.uppercase) {
20792 minUppercaseCalc = 0;
20793 }
20794 if (options.lowercase && options.minLowercase <= 0) {
20795 minLowercaseCalc = 1;
20796 }
20797 else if (!options.lowercase) {
20798 minLowercaseCalc = 0;
20799 }
20800 if (options.number && options.minNumber <= 0) {
20801 minNumberCalc = 1;
20802 }
20803 else if (!options.number) {
20804 minNumberCalc = 0;
20805 }
20806 if (options.special && options.minSpecial <= 0) {
20807 minSpecialCalc = 1;
20808 }
20809 else if (!options.special) {
20810 minSpecialCalc = 0;
20811 }
20812 // This should never happen but is a final safety net
20813 if (!options.length || options.length < 1) {
20814 options.length = 10;
20815 }
20816 const minLength = minUppercaseCalc + minLowercaseCalc + minNumberCalc + minSpecialCalc;
20817 // Normalize and Generation both require this modification
20818 if (options.length < minLength) {
20819 options.length = minLength;
20820 }
20821 // Apply other changes if the options object passed in is for generation
20822 if (forGeneration) {
20823 options.minUppercase = minUppercaseCalc;
20824 options.minLowercase = minLowercaseCalc;
20825 options.minNumber = minNumberCalc;
20826 options.minSpecial = minSpecialCalc;
20827 }
20828 }
20829}
20830
20831// CONCATENATED MODULE: ./jslib/src/models/domain/masterPasswordPolicyOptions.ts
20832
20833class masterPasswordPolicyOptions_MasterPasswordPolicyOptions extends domainBase_Domain {
20834 constructor() {
20835 super(...arguments);
20836 this.minComplexity = 0;
20837 this.minLength = 0;
20838 this.requireUpper = false;
20839 this.requireLower = false;
20840 this.requireNumbers = false;
20841 this.requireSpecial = false;
20842 }
20843}
20844
20845// CONCATENATED MODULE: ./jslib/src/models/domain/policy.ts
20846
20847class policy_Policy extends domainBase_Domain {
20848 constructor(obj) {
20849 super();
20850 if (obj == null) {
20851 return;
20852 }
20853 this.id = obj.id;
20854 this.organizationId = obj.organizationId;
20855 this.type = obj.type;
20856 this.data = obj.data;
20857 this.enabled = obj.enabled;
20858 }
20859}
20860
20861// CONCATENATED MODULE: ./jslib/src/services/policy.service.ts
20862var policy_service_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
20863 return new (P || (P = Promise))(function (resolve, reject) {
20864 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
20865 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
20866 function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
20867 step((generator = generator.apply(thisArg, _arguments || [])).next());
20868 });
20869};
20870
20871
20872
20873const policy_service_Keys = {
20874 policiesPrefix: 'policies_',
20875};
20876class policy_service_PolicyService {
20877 constructor(userService, storageService) {
20878 this.userService = userService;
20879 this.storageService = storageService;
20880 }
20881 clearCache() {
20882 this.policyCache = null;
20883 }
20884 getAll(type) {
20885 return policy_service_awaiter(this, void 0, void 0, function* () {
20886 if (this.policyCache == null) {
20887 const userId = yield this.userService.getUserId();
20888 const policies = yield this.storageService.get(policy_service_Keys.policiesPrefix + userId);
20889 const response = [];
20890 for (const id in policies) {
20891 if (policies.hasOwnProperty(id)) {
20892 response.push(new policy_Policy(policies[id]));
20893 }
20894 }
20895 this.policyCache = response;
20896 }
20897 if (type != null) {
20898 return this.policyCache.filter((p) => p.type === type);
20899 }
20900 else {
20901 return this.policyCache;
20902 }
20903 });
20904 }
20905 replace(policies) {
20906 return policy_service_awaiter(this, void 0, void 0, function* () {
20907 const userId = yield this.userService.getUserId();
20908 yield this.storageService.save(policy_service_Keys.policiesPrefix + userId, policies);
20909 this.policyCache = null;
20910 });
20911 }
20912 clear(userId) {
20913 return policy_service_awaiter(this, void 0, void 0, function* () {
20914 yield this.storageService.remove(policy_service_Keys.policiesPrefix + userId);
20915 this.policyCache = null;
20916 });
20917 }
20918 getMasterPasswordPolicyOptions(policies) {
20919 return policy_service_awaiter(this, void 0, void 0, function* () {
20920 let enforcedOptions = null;
20921 if (policies == null) {
20922 policies = yield this.getAll(PolicyType.MasterPassword);
20923 }
20924 else {
20925 policies = policies.filter((p) => p.type === PolicyType.MasterPassword);
20926 }
20927 if (policies == null || policies.length === 0) {
20928 return enforcedOptions;
20929 }
20930 policies.forEach((currentPolicy) => {
20931 if (!currentPolicy.enabled || currentPolicy.data == null) {
20932 return;
20933 }
20934 if (enforcedOptions == null) {
20935 enforcedOptions = new masterPasswordPolicyOptions_MasterPasswordPolicyOptions();
20936 }
20937 if (currentPolicy.data.minComplexity != null
20938 && currentPolicy.data.minComplexity > enforcedOptions.minComplexity) {
20939 enforcedOptions.minComplexity = currentPolicy.data.minComplexity;
20940 }
20941 if (currentPolicy.data.minLength != null
20942 && currentPolicy.data.minLength > enforcedOptions.minLength) {
20943 enforcedOptions.minLength = currentPolicy.data.minLength;
20944 }
20945 if (currentPolicy.data.requireUpper) {
20946 enforcedOptions.requireUpper = true;
20947 }
20948 if (currentPolicy.data.requireLower) {
20949 enforcedOptions.requireLower = true;
20950 }
20951 if (currentPolicy.data.requireNumbers) {
20952 enforcedOptions.requireNumbers = true;
20953 }
20954 if (currentPolicy.data.requireSpecial) {
20955 enforcedOptions.requireSpecial = true;
20956 }
20957 });
20958 return enforcedOptions;
20959 });
20960 }
20961 evaluateMasterPassword(passwordStrength, newPassword, enforcedPolicyOptions) {
20962 if (enforcedPolicyOptions == null) {
20963 return true;
20964 }
20965 if (enforcedPolicyOptions.minComplexity > 0 && enforcedPolicyOptions.minComplexity > passwordStrength) {
20966 return false;
20967 }
20968 if (enforcedPolicyOptions.minLength > 0 && enforcedPolicyOptions.minLength > newPassword.length) {
20969 return false;
20970 }
20971 if (enforcedPolicyOptions.requireUpper && newPassword.toLocaleLowerCase() === newPassword) {
20972 return false;
20973 }
20974 if (enforcedPolicyOptions.requireLower && newPassword.toLocaleUpperCase() === newPassword) {
20975 return false;
20976 }
20977 if (enforcedPolicyOptions.requireNumbers && !(/[0-9]/.test(newPassword))) {
20978 return false;
20979 }
20980 if (enforcedPolicyOptions.requireSpecial && !(/[!@#$%\^&*]/g.test(newPassword))) {
20981 return false;
20982 }
20983 return true;
20984 }
20985}
20986
20987// EXTERNAL MODULE: external "lunr"
20988var external_lunr_ = __webpack_require__(9);
20989
20990// CONCATENATED MODULE: ./jslib/src/services/search.service.ts
20991var search_service_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
20992 return new (P || (P = Promise))(function (resolve, reject) {
20993 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
20994 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
20995 function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
20996 step((generator = generator.apply(thisArg, _arguments || [])).next());
20997 });
20998};
20999
21000
21001
21002
21003
21004class search_service_SearchService {
21005 constructor(cipherService, platformUtilsService) {
21006 this.cipherService = cipherService;
21007 this.indexing = false;
21008 this.index = null;
21009 this.onlySearchName = false;
21010 this.onlySearchName = platformUtilsService == null ||
21011 platformUtilsService.getDevice() === DeviceType.EdgeExtension;
21012 }
21013 clearIndex() {
21014 this.index = null;
21015 }
21016 isSearchable(query) {
21017 const notSearchable = query == null || (this.index == null && query.length < 2) ||
21018 (this.index != null && query.length < 2 && query.indexOf('>') !== 0);
21019 return !notSearchable;
21020 }
21021 indexCiphers() {
21022 return search_service_awaiter(this, void 0, void 0, function* () {
21023 if (this.indexing) {
21024 return;
21025 }
21026 // tslint:disable-next-line
21027 console.time('search indexing');
21028 this.indexing = true;
21029 this.index = null;
21030 const builder = new external_lunr_["Builder"]();
21031 builder.ref('id');
21032 builder.field('shortid', { boost: 100, extractor: (c) => c.id.substr(0, 8) });
21033 builder.field('name', { boost: 10 });
21034 builder.field('subtitle', {
21035 boost: 5,
21036 extractor: (c) => {
21037 if (c.subTitle != null && c.type === CipherType.Card) {
21038 return c.subTitle.replace(/\*/g, '');
21039 }
21040 return c.subTitle;
21041 },
21042 });
21043 builder.field('notes');
21044 builder.field('login.username', {
21045 extractor: (c) => c.type === CipherType.Login && c.login != null ? c.login.username : null,
21046 });
21047 builder.field('login.uris', { boost: 2, extractor: (c) => this.uriExtractor(c) });
21048 builder.field('fields', { extractor: (c) => this.fieldExtractor(c, false) });
21049 builder.field('fields_joined', { extractor: (c) => this.fieldExtractor(c, true) });
21050 builder.field('attachments', { extractor: (c) => this.attachmentExtractor(c, false) });
21051 builder.field('attachments_joined', { extractor: (c) => this.attachmentExtractor(c, true) });
21052 builder.field('organizationid', { extractor: (c) => c.organizationId });
21053 const ciphers = yield this.cipherService.getAllDecrypted();
21054 ciphers.forEach((c) => builder.add(c));
21055 this.index = builder.build();
21056 this.indexing = false;
21057 // tslint:disable-next-line
21058 console.timeEnd('search indexing');
21059 });
21060 }
21061 searchCiphers(query, filter = null, ciphers = null) {
21062 return search_service_awaiter(this, void 0, void 0, function* () {
21063 const results = [];
21064 if (query != null) {
21065 query = query.trim().toLowerCase();
21066 }
21067 if (query === '') {
21068 query = null;
21069 }
21070 if (ciphers == null) {
21071 ciphers = yield this.cipherService.getAllDecrypted();
21072 }
21073 if (filter != null && Array.isArray(filter) && filter.length > 0) {
21074 ciphers = ciphers.filter((c) => filter.every((f) => f == null || f(c)));
21075 }
21076 else if (filter != null) {
21077 ciphers = ciphers.filter(filter);
21078 }
21079 if (!this.isSearchable(query)) {
21080 return ciphers;
21081 }
21082 if (this.indexing) {
21083 yield new Promise((r) => setTimeout(r, 250));
21084 if (this.indexing) {
21085 yield new Promise((r) => setTimeout(r, 500));
21086 }
21087 }
21088 const index = this.getIndexForSearch();
21089 if (index == null) {
21090 // Fall back to basic search if index is not available
21091 return this.searchCiphersBasic(ciphers, query);
21092 }
21093 const ciphersMap = new Map();
21094 ciphers.forEach((c) => ciphersMap.set(c.id, c));
21095 let searchResults = null;
21096 const isQueryString = query != null && query.length > 1 && query.indexOf('>') === 0;
21097 if (isQueryString) {
21098 try {
21099 searchResults = index.search(query.substr(1).trim());
21100 }
21101 catch (_a) { }
21102 }
21103 else {
21104 // tslint:disable-next-line
21105 const soWild = external_lunr_["Query"].wildcard.LEADING | external_lunr_["Query"].wildcard.TRAILING;
21106 searchResults = index.query((q) => {
21107 external_lunr_["tokenizer"](query).forEach((token) => {
21108 const t = token.toString();
21109 q.term(t, { fields: ['name'], wildcard: soWild });
21110 q.term(t, { fields: ['subtitle'], wildcard: soWild });
21111 q.term(t, { fields: ['login.uris'], wildcard: soWild });
21112 q.term(t, {});
21113 });
21114 });
21115 }
21116 if (searchResults != null) {
21117 searchResults.forEach((r) => {
21118 if (ciphersMap.has(r.ref)) {
21119 results.push(ciphersMap.get(r.ref));
21120 }
21121 });
21122 }
21123 return results;
21124 });
21125 }
21126 searchCiphersBasic(ciphers, query, deleted = false) {
21127 query = query.trim().toLowerCase();
21128 return ciphers.filter((c) => {
21129 if (deleted !== c.isDeleted) {
21130 return false;
21131 }
21132 if (c.name != null && c.name.toLowerCase().indexOf(query) > -1) {
21133 return true;
21134 }
21135 if (this.onlySearchName) {
21136 return false;
21137 }
21138 if (query.length >= 8 && c.id.startsWith(query)) {
21139 return true;
21140 }
21141 if (c.subTitle != null && c.subTitle.toLowerCase().indexOf(query) > -1) {
21142 return true;
21143 }
21144 if (c.login && c.login.uri != null && c.login.uri.toLowerCase().indexOf(query) > -1) {
21145 return true;
21146 }
21147 return false;
21148 });
21149 }
21150 getIndexForSearch() {
21151 return this.index;
21152 }
21153 fieldExtractor(c, joined) {
21154 if (!c.hasFields) {
21155 return null;
21156 }
21157 let fields = [];
21158 c.fields.forEach((f) => {
21159 if (f.name != null) {
21160 fields.push(f.name);
21161 }
21162 if (f.type === FieldType.Text && f.value != null) {
21163 fields.push(f.value);
21164 }
21165 });
21166 fields = fields.filter((f) => f.trim() !== '');
21167 if (fields.length === 0) {
21168 return null;
21169 }
21170 return joined ? fields.join(' ') : fields;
21171 }
21172 attachmentExtractor(c, joined) {
21173 if (!c.hasAttachments) {
21174 return null;
21175 }
21176 let attachments = [];
21177 c.attachments.forEach((a) => {
21178 if (a != null && a.fileName != null) {
21179 if (joined && a.fileName.indexOf('.') > -1) {
21180 attachments.push(a.fileName.substr(0, a.fileName.lastIndexOf('.')));
21181 }
21182 else {
21183 attachments.push(a.fileName);
21184 }
21185 }
21186 });
21187 attachments = attachments.filter((f) => f.trim() !== '');
21188 if (attachments.length === 0) {
21189 return null;
21190 }
21191 return joined ? attachments.join(' ') : attachments;
21192 }
21193 uriExtractor(c) {
21194 if (c.type !== CipherType.Login || c.login == null || !c.login.hasUris) {
21195 return null;
21196 }
21197 const uris = [];
21198 c.login.uris.forEach((u) => {
21199 if (u.uri == null || u.uri === '') {
21200 return;
21201 }
21202 if (u.hostname != null) {
21203 uris.push(u.hostname);
21204 return;
21205 }
21206 let uri = u.uri;
21207 if (u.match !== UriMatchType.RegularExpression) {
21208 const protocolIndex = uri.indexOf('://');
21209 if (protocolIndex > -1) {
21210 uri = uri.substr(protocolIndex + 3);
21211 }
21212 const queryIndex = uri.search(/\?|&|#/);
21213 if (queryIndex > -1) {
21214 uri = uri.substring(0, queryIndex);
21215 }
21216 }
21217 uris.push(uri);
21218 });
21219 return uris.length > 0 ? uris : null;
21220 }
21221}
21222
21223// CONCATENATED MODULE: ./jslib/src/services/settings.service.ts
21224var settings_service_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
21225 return new (P || (P = Promise))(function (resolve, reject) {
21226 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
21227 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
21228 function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
21229 step((generator = generator.apply(thisArg, _arguments || [])).next());
21230 });
21231};
21232const settings_service_Keys = {
21233 settingsPrefix: 'settings_',
21234 equivalentDomains: 'equivalentDomains',
21235};
21236class SettingsService {
21237 constructor(userService, storageService) {
21238 this.userService = userService;
21239 this.storageService = storageService;
21240 }
21241 clearCache() {
21242 this.settingsCache = null;
21243 }
21244 getEquivalentDomains() {
21245 return this.getSettingsKey(settings_service_Keys.equivalentDomains);
21246 }
21247 setEquivalentDomains(equivalentDomains) {
21248 return settings_service_awaiter(this, void 0, void 0, function* () {
21249 yield this.setSettingsKey(settings_service_Keys.equivalentDomains, equivalentDomains);
21250 });
21251 }
21252 clear(userId) {
21253 return settings_service_awaiter(this, void 0, void 0, function* () {
21254 yield this.storageService.remove(settings_service_Keys.settingsPrefix + userId);
21255 this.clearCache();
21256 });
21257 }
21258 // Helpers
21259 getSettings() {
21260 return settings_service_awaiter(this, void 0, void 0, function* () {
21261 if (this.settingsCache == null) {
21262 const userId = yield this.userService.getUserId();
21263 this.settingsCache = this.storageService.get(settings_service_Keys.settingsPrefix + userId);
21264 }
21265 return this.settingsCache;
21266 });
21267 }
21268 getSettingsKey(key) {
21269 return settings_service_awaiter(this, void 0, void 0, function* () {
21270 const settings = yield this.getSettings();
21271 if (settings != null && settings[key]) {
21272 return settings[key];
21273 }
21274 return null;
21275 });
21276 }
21277 setSettingsKey(key, value) {
21278 return settings_service_awaiter(this, void 0, void 0, function* () {
21279 const userId = yield this.userService.getUserId();
21280 let settings = yield this.getSettings();
21281 if (!settings) {
21282 settings = {};
21283 }
21284 settings[key] = value;
21285 yield this.storageService.save(settings_service_Keys.settingsPrefix + userId, settings);
21286 this.settingsCache = settings;
21287 });
21288 }
21289}
21290
21291// CONCATENATED MODULE: ./jslib/src/models/data/organizationData.ts
21292class OrganizationData {
21293 constructor(response) {
21294 this.id = response.id;
21295 this.name = response.name;
21296 this.status = response.status;
21297 this.type = response.type;
21298 this.enabled = response.enabled;
21299 this.usePolicies = response.usePolicies;
21300 this.useGroups = response.useGroups;
21301 this.useDirectory = response.useDirectory;
21302 this.useEvents = response.useEvents;
21303 this.useTotp = response.useTotp;
21304 this.use2fa = response.use2fa;
21305 this.useApi = response.useApi;
21306 this.selfHost = response.selfHost;
21307 this.usersGetPremium = response.usersGetPremium;
21308 this.seats = response.seats;
21309 this.maxCollections = response.maxCollections;
21310 this.maxStorageGb = response.maxStorageGb;
21311 }
21312}
21313
21314// CONCATENATED MODULE: ./jslib/src/models/data/policyData.ts
21315class PolicyData {
21316 constructor(response) {
21317 this.id = response.id;
21318 this.organizationId = response.organizationId;
21319 this.type = response.type;
21320 this.data = response.data;
21321 this.enabled = response.enabled;
21322 }
21323}
21324
21325// CONCATENATED MODULE: ./jslib/src/services/sync.service.ts
21326var sync_service_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
21327 return new (P || (P = Promise))(function (resolve, reject) {
21328 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
21329 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
21330 function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
21331 step((generator = generator.apply(thisArg, _arguments || [])).next());
21332 });
21333};
21334
21335
21336
21337
21338
21339const sync_service_Keys = {
21340 lastSyncPrefix: 'lastSync_',
21341};
21342class sync_service_SyncService {
21343 constructor(userService, apiService, settingsService, folderService, cipherService, cryptoService, collectionService, storageService, messagingService, policyService, logoutCallback) {
21344 this.userService = userService;
21345 this.apiService = apiService;
21346 this.settingsService = settingsService;
21347 this.folderService = folderService;
21348 this.cipherService = cipherService;
21349 this.cryptoService = cryptoService;
21350 this.collectionService = collectionService;
21351 this.storageService = storageService;
21352 this.messagingService = messagingService;
21353 this.policyService = policyService;
21354 this.logoutCallback = logoutCallback;
21355 this.syncInProgress = false;
21356 }
21357 getLastSync() {
21358 return sync_service_awaiter(this, void 0, void 0, function* () {
21359 const userId = yield this.userService.getUserId();
21360 if (userId == null) {
21361 return null;
21362 }
21363 const lastSync = yield this.storageService.get(sync_service_Keys.lastSyncPrefix + userId);
21364 if (lastSync) {
21365 return new Date(lastSync);
21366 }
21367 return null;
21368 });
21369 }
21370 setLastSync(date) {
21371 return sync_service_awaiter(this, void 0, void 0, function* () {
21372 const userId = yield this.userService.getUserId();
21373 if (userId == null) {
21374 return;
21375 }
21376 yield this.storageService.save(sync_service_Keys.lastSyncPrefix + userId, date.toJSON());
21377 });
21378 }
21379 fullSync(forceSync, allowThrowOnError = false) {
21380 return sync_service_awaiter(this, void 0, void 0, function* () {
21381 this.syncStarted();
21382 const isAuthenticated = yield this.userService.isAuthenticated();
21383 if (!isAuthenticated) {
21384 return this.syncCompleted(false);
21385 }
21386 const now = new Date();
21387 const needsSyncResult = yield this.needsSyncing(forceSync);
21388 const needsSync = needsSyncResult[0];
21389 const skipped = needsSyncResult[1];
21390 if (skipped) {
21391 return this.syncCompleted(false);
21392 }
21393 if (!needsSync) {
21394 yield this.setLastSync(now);
21395 return this.syncCompleted(false);
21396 }
21397 const userId = yield this.userService.getUserId();
21398 try {
21399 const response = yield this.apiService.getSync();
21400 yield this.syncProfile(response.profile);
21401 yield this.syncFolders(userId, response.folders);
21402 yield this.syncCollections(response.collections);
21403 yield this.syncCiphers(userId, response.ciphers);
21404 yield this.syncSettings(userId, response.domains);
21405 yield this.syncPolicies(response.policies);
21406 yield this.setLastSync(now);
21407 return this.syncCompleted(true);
21408 }
21409 catch (e) {
21410 if (allowThrowOnError) {
21411 throw e;
21412 }
21413 else {
21414 return this.syncCompleted(false);
21415 }
21416 }
21417 });
21418 }
21419 syncUpsertFolder(notification, isEdit) {
21420 return sync_service_awaiter(this, void 0, void 0, function* () {
21421 this.syncStarted();
21422 if (yield this.userService.isAuthenticated()) {
21423 try {
21424 const localFolder = yield this.folderService.get(notification.id);
21425 if ((!isEdit && localFolder == null) ||
21426 (isEdit && localFolder != null && localFolder.revisionDate < notification.revisionDate)) {
21427 const remoteFolder = yield this.apiService.getFolder(notification.id);
21428 if (remoteFolder != null) {
21429 const userId = yield this.userService.getUserId();
21430 yield this.folderService.upsert(new FolderData(remoteFolder, userId));
21431 this.messagingService.send('syncedUpsertedFolder', { folderId: notification.id });
21432 return this.syncCompleted(true);
21433 }
21434 }
21435 }
21436 catch (_a) { }
21437 }
21438 return this.syncCompleted(false);
21439 });
21440 }
21441 syncDeleteFolder(notification) {
21442 return sync_service_awaiter(this, void 0, void 0, function* () {
21443 this.syncStarted();
21444 if (yield this.userService.isAuthenticated()) {
21445 yield this.folderService.delete(notification.id);
21446 this.messagingService.send('syncedDeletedFolder', { folderId: notification.id });
21447 this.syncCompleted(true);
21448 return true;
21449 }
21450 return this.syncCompleted(false);
21451 });
21452 }
21453 syncUpsertCipher(notification, isEdit) {
21454 return sync_service_awaiter(this, void 0, void 0, function* () {
21455 this.syncStarted();
21456 if (yield this.userService.isAuthenticated()) {
21457 try {
21458 let shouldUpdate = true;
21459 const localCipher = yield this.cipherService.get(notification.id);
21460 if (localCipher != null && localCipher.revisionDate >= notification.revisionDate) {
21461 shouldUpdate = false;
21462 }
21463 let checkCollections = false;
21464 if (shouldUpdate) {
21465 if (isEdit) {
21466 shouldUpdate = localCipher != null;
21467 checkCollections = true;
21468 }
21469 else {
21470 if (notification.collectionIds == null || notification.organizationId == null) {
21471 shouldUpdate = localCipher == null;
21472 }
21473 else {
21474 shouldUpdate = false;
21475 checkCollections = true;
21476 }
21477 }
21478 }
21479 if (!shouldUpdate && checkCollections && notification.organizationId != null &&
21480 notification.collectionIds != null && notification.collectionIds.length > 0) {
21481 const collections = yield this.collectionService.getAll();
21482 if (collections != null) {
21483 for (let i = 0; i < collections.length; i++) {
21484 if (notification.collectionIds.indexOf(collections[i].id) > -1) {
21485 shouldUpdate = true;
21486 break;
21487 }
21488 }
21489 }
21490 }
21491 if (shouldUpdate) {
21492 const remoteCipher = yield this.apiService.getCipher(notification.id);
21493 if (remoteCipher != null) {
21494 const userId = yield this.userService.getUserId();
21495 yield this.cipherService.upsert(new cipherData_CipherData(remoteCipher, userId));
21496 this.messagingService.send('syncedUpsertedCipher', { cipherId: notification.id });
21497 return this.syncCompleted(true);
21498 }
21499 }
21500 }
21501 catch (e) {
21502 if (e != null && e.statusCode === 404 && isEdit) {
21503 yield this.cipherService.delete(notification.id);
21504 this.messagingService.send('syncedDeletedCipher', { cipherId: notification.id });
21505 return this.syncCompleted(true);
21506 }
21507 }
21508 }
21509 return this.syncCompleted(false);
21510 });
21511 }
21512 syncDeleteCipher(notification) {
21513 return sync_service_awaiter(this, void 0, void 0, function* () {
21514 this.syncStarted();
21515 if (yield this.userService.isAuthenticated()) {
21516 yield this.cipherService.delete(notification.id);
21517 this.messagingService.send('syncedDeletedCipher', { cipherId: notification.id });
21518 return this.syncCompleted(true);
21519 }
21520 return this.syncCompleted(false);
21521 });
21522 }
21523 // Helpers
21524 syncStarted() {
21525 this.syncInProgress = true;
21526 this.messagingService.send('syncStarted');
21527 }
21528 syncCompleted(successfully) {
21529 this.syncInProgress = false;
21530 this.messagingService.send('syncCompleted', { successfully: successfully });
21531 return successfully;
21532 }
21533 needsSyncing(forceSync) {
21534 return sync_service_awaiter(this, void 0, void 0, function* () {
21535 if (forceSync) {
21536 return [true, false];
21537 }
21538 const lastSync = yield this.getLastSync();
21539 if (lastSync == null || lastSync.getTime() === 0) {
21540 return [true, false];
21541 }
21542 try {
21543 const response = yield this.apiService.getAccountRevisionDate();
21544 if (new Date(response) <= lastSync) {
21545 return [false, false];
21546 }
21547 return [true, false];
21548 }
21549 catch (e) {
21550 return [false, true];
21551 }
21552 });
21553 }
21554 syncProfile(response) {
21555 return sync_service_awaiter(this, void 0, void 0, function* () {
21556 const stamp = yield this.userService.getSecurityStamp();
21557 if (stamp != null && stamp !== response.securityStamp) {
21558 if (this.logoutCallback != null) {
21559 yield this.logoutCallback(true);
21560 }
21561 throw new Error('Stamp has changed');
21562 }
21563 yield this.cryptoService.setEncKey(response.key);
21564 yield this.cryptoService.setEncPrivateKey(response.privateKey);
21565 yield this.cryptoService.setOrgKeys(response.organizations);
21566 yield this.userService.setSecurityStamp(response.securityStamp);
21567 const organizations = {};
21568 response.organizations.forEach((o) => {
21569 organizations[o.id] = new OrganizationData(o);
21570 });
21571 return yield this.userService.replaceOrganizations(organizations);
21572 });
21573 }
21574 syncFolders(userId, response) {
21575 return sync_service_awaiter(this, void 0, void 0, function* () {
21576 const folders = {};
21577 response.forEach((f) => {
21578 folders[f.id] = new FolderData(f, userId);
21579 });
21580 return yield this.folderService.replace(folders);
21581 });
21582 }
21583 syncCollections(response) {
21584 return sync_service_awaiter(this, void 0, void 0, function* () {
21585 const collections = {};
21586 response.forEach((c) => {
21587 collections[c.id] = new CollectionData(c);
21588 });
21589 return yield this.collectionService.replace(collections);
21590 });
21591 }
21592 syncCiphers(userId, response) {
21593 return sync_service_awaiter(this, void 0, void 0, function* () {
21594 const ciphers = {};
21595 response.forEach((c) => {
21596 ciphers[c.id] = new cipherData_CipherData(c, userId);
21597 });
21598 return yield this.cipherService.replace(ciphers);
21599 });
21600 }
21601 syncSettings(userId, response) {
21602 return sync_service_awaiter(this, void 0, void 0, function* () {
21603 let eqDomains = [];
21604 if (response != null && response.equivalentDomains != null) {
21605 eqDomains = eqDomains.concat(response.equivalentDomains);
21606 }
21607 if (response != null && response.globalEquivalentDomains != null) {
21608 response.globalEquivalentDomains.forEach((global) => {
21609 if (global.domains.length > 0) {
21610 eqDomains.push(global.domains);
21611 }
21612 });
21613 }
21614 return this.settingsService.setEquivalentDomains(eqDomains);
21615 });
21616 }
21617 syncPolicies(response) {
21618 return sync_service_awaiter(this, void 0, void 0, function* () {
21619 const policies = {};
21620 if (response != null) {
21621 response.forEach((p) => {
21622 policies[p.id] = new PolicyData(p);
21623 });
21624 }
21625 return yield this.policyService.replace(policies);
21626 });
21627 }
21628}
21629
21630// CONCATENATED MODULE: ./jslib/src/services/token.service.ts
21631var token_service_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
21632 return new (P || (P = Promise))(function (resolve, reject) {
21633 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
21634 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
21635 function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
21636 step((generator = generator.apply(thisArg, _arguments || [])).next());
21637 });
21638};
21639
21640
21641const token_service_Keys = {
21642 accessToken: 'accessToken',
21643 refreshToken: 'refreshToken',
21644 twoFactorTokenPrefix: 'twoFactorToken_',
21645};
21646class token_service_TokenService {
21647 constructor(storageService) {
21648 this.storageService = storageService;
21649 }
21650 setTokens(accessToken, refreshToken) {
21651 return Promise.all([
21652 this.setToken(accessToken),
21653 this.setRefreshToken(refreshToken),
21654 ]);
21655 }
21656 setToken(token) {
21657 return token_service_awaiter(this, void 0, void 0, function* () {
21658 this.token = token;
21659 this.decodedToken = null;
21660 if (yield this.skipTokenStorage()) {
21661 // if we have a vault timeout and the action is log out, don't store token
21662 return;
21663 }
21664 return this.storageService.save(token_service_Keys.accessToken, token);
21665 });
21666 }
21667 getToken() {
21668 return token_service_awaiter(this, void 0, void 0, function* () {
21669 if (this.token != null) {
21670 return this.token;
21671 }
21672 this.token = yield this.storageService.get(token_service_Keys.accessToken);
21673 return this.token;
21674 });
21675 }
21676 setRefreshToken(refreshToken) {
21677 return token_service_awaiter(this, void 0, void 0, function* () {
21678 this.refreshToken = refreshToken;
21679 if (yield this.skipTokenStorage()) {
21680 // if we have a vault timeout and the action is log out, don't store token
21681 return;
21682 }
21683 return this.storageService.save(token_service_Keys.refreshToken, refreshToken);
21684 });
21685 }
21686 getRefreshToken() {
21687 return token_service_awaiter(this, void 0, void 0, function* () {
21688 if (this.refreshToken != null) {
21689 return this.refreshToken;
21690 }
21691 this.refreshToken = yield this.storageService.get(token_service_Keys.refreshToken);
21692 return this.refreshToken;
21693 });
21694 }
21695 toggleTokens() {
21696 return token_service_awaiter(this, void 0, void 0, function* () {
21697 const token = yield this.getToken();
21698 const refreshToken = yield this.getRefreshToken();
21699 const timeout = yield this.storageService.get(ConstantsService.vaultTimeoutKey);
21700 const action = yield this.storageService.get(ConstantsService.vaultTimeoutActionKey);
21701 if ((timeout != null || timeout === 0) && action === 'logOut') {
21702 // if we have a vault timeout and the action is log out, reset tokens
21703 yield this.clearToken();
21704 this.token = token;
21705 this.refreshToken = refreshToken;
21706 return;
21707 }
21708 yield this.setToken(token);
21709 yield this.setRefreshToken(refreshToken);
21710 });
21711 }
21712 setTwoFactorToken(token, email) {
21713 return this.storageService.save(token_service_Keys.twoFactorTokenPrefix + email, token);
21714 }
21715 getTwoFactorToken(email) {
21716 return this.storageService.get(token_service_Keys.twoFactorTokenPrefix + email);
21717 }
21718 clearTwoFactorToken(email) {
21719 return this.storageService.remove(token_service_Keys.twoFactorTokenPrefix + email);
21720 }
21721 clearToken() {
21722 this.token = null;
21723 this.decodedToken = null;
21724 this.refreshToken = null;
21725 return Promise.all([
21726 this.storageService.remove(token_service_Keys.accessToken),
21727 this.storageService.remove(token_service_Keys.refreshToken),
21728 ]);
21729 }
21730 // jwthelper methods
21731 // ref https://github.com/auth0/angular-jwt/blob/master/src/angularJwt/services/jwt.js
21732 decodeToken() {
21733 if (this.decodedToken) {
21734 return this.decodedToken;
21735 }
21736 if (this.token == null) {
21737 throw new Error('Token not found.');
21738 }
21739 const parts = this.token.split('.');
21740 if (parts.length !== 3) {
21741 throw new Error('JWT must have 3 parts');
21742 }
21743 const decoded = utils_Utils.fromUrlB64ToUtf8(parts[1]);
21744 if (decoded == null) {
21745 throw new Error('Cannot decode the token');
21746 }
21747 this.decodedToken = JSON.parse(decoded);
21748 return this.decodedToken;
21749 }
21750 getTokenExpirationDate() {
21751 const decoded = this.decodeToken();
21752 if (typeof decoded.exp === 'undefined') {
21753 return null;
21754 }
21755 const d = new Date(0); // The 0 here is the key, which sets the date to the epoch
21756 d.setUTCSeconds(decoded.exp);
21757 return d;
21758 }
21759 tokenSecondsRemaining(offsetSeconds = 0) {
21760 const d = this.getTokenExpirationDate();
21761 if (d == null) {
21762 return 0;
21763 }
21764 const msRemaining = d.valueOf() - (new Date().valueOf() + (offsetSeconds * 1000));
21765 return Math.round(msRemaining / 1000);
21766 }
21767 tokenNeedsRefresh(minutes = 5) {
21768 const sRemaining = this.tokenSecondsRemaining();
21769 return sRemaining < (60 * minutes);
21770 }
21771 getUserId() {
21772 const decoded = this.decodeToken();
21773 if (typeof decoded.sub === 'undefined') {
21774 throw new Error('No user id found');
21775 }
21776 return decoded.sub;
21777 }
21778 getEmail() {
21779 const decoded = this.decodeToken();
21780 if (typeof decoded.email === 'undefined') {
21781 throw new Error('No email found');
21782 }
21783 return decoded.email;
21784 }
21785 getEmailVerified() {
21786 const decoded = this.decodeToken();
21787 if (typeof decoded.email_verified === 'undefined') {
21788 throw new Error('No email verification found');
21789 }
21790 return decoded.email_verified;
21791 }
21792 getName() {
21793 const decoded = this.decodeToken();
21794 if (typeof decoded.name === 'undefined') {
21795 return null;
21796 }
21797 return decoded.name;
21798 }
21799 getPremium() {
21800 const decoded = this.decodeToken();
21801 if (typeof decoded.premium === 'undefined') {
21802 return false;
21803 }
21804 return decoded.premium;
21805 }
21806 getIssuer() {
21807 const decoded = this.decodeToken();
21808 if (typeof decoded.iss === 'undefined') {
21809 throw new Error('No issuer found');
21810 }
21811 return decoded.iss;
21812 }
21813 skipTokenStorage() {
21814 return token_service_awaiter(this, void 0, void 0, function* () {
21815 const timeout = yield this.storageService.get(ConstantsService.vaultTimeoutKey);
21816 const action = yield this.storageService.get(ConstantsService.vaultTimeoutActionKey);
21817 return timeout != null && action === 'logOut';
21818 });
21819 }
21820}
21821
21822// CONCATENATED MODULE: ./jslib/src/services/totp.service.ts
21823var totp_service_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
21824 return new (P || (P = Promise))(function (resolve, reject) {
21825 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
21826 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
21827 function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
21828 step((generator = generator.apply(thisArg, _arguments || [])).next());
21829 });
21830};
21831
21832
21833const B32Chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567';
21834const SteamChars = '23456789BCDFGHJKMNPQRTVWXY';
21835class totp_service_TotpService {
21836 constructor(storageService, cryptoFunctionService) {
21837 this.storageService = storageService;
21838 this.cryptoFunctionService = cryptoFunctionService;
21839 }
21840 getCode(key) {
21841 return totp_service_awaiter(this, void 0, void 0, function* () {
21842 if (key == null) {
21843 return null;
21844 }
21845 let period = 30;
21846 let alg = 'sha1';
21847 let digits = 6;
21848 let keyB32 = key;
21849 const isOtpAuth = key.toLowerCase().indexOf('otpauth://') === 0;
21850 const isSteamAuth = !isOtpAuth && key.toLowerCase().indexOf('steam://') === 0;
21851 if (isOtpAuth) {
21852 const params = utils_Utils.getQueryParams(key);
21853 if (params.has('digits') && params.get('digits') != null) {
21854 try {
21855 const digitParams = parseInt(params.get('digits').trim(), null);
21856 if (digitParams > 10) {
21857 digits = 10;
21858 }
21859 else if (digitParams > 0) {
21860 digits = digitParams;
21861 }
21862 }
21863 catch (_a) { }
21864 }
21865 if (params.has('period') && params.get('period') != null) {
21866 try {
21867 const periodParam = parseInt(params.get('period').trim(), null);
21868 if (periodParam > 0) {
21869 period = periodParam;
21870 }
21871 }
21872 catch (_b) { }
21873 }
21874 if (params.has('secret') && params.get('secret') != null) {
21875 keyB32 = params.get('secret');
21876 }
21877 if (params.has('algorithm') && params.get('algorithm') != null) {
21878 const algParam = params.get('algorithm').toLowerCase();
21879 if (algParam === 'sha1' || algParam === 'sha256' || algParam === 'sha512') {
21880 alg = algParam;
21881 }
21882 }
21883 }
21884 else if (isSteamAuth) {
21885 keyB32 = key.substr('steam://'.length);
21886 digits = 5;
21887 }
21888 const epoch = Math.round(new Date().getTime() / 1000.0);
21889 const timeHex = this.leftPad(this.decToHex(Math.floor(epoch / period)), 16, '0');
21890 const timeBytes = utils_Utils.fromHexToArray(timeHex);
21891 const keyBytes = this.b32ToBytes(keyB32);
21892 if (!keyBytes.length || !timeBytes.length) {
21893 return null;
21894 }
21895 const hash = yield this.sign(keyBytes, timeBytes, alg);
21896 if (hash.length === 0) {
21897 return null;
21898 }
21899 /* tslint:disable */
21900 const offset = (hash[hash.length - 1] & 0xf);
21901 const binary = ((hash[offset] & 0x7f) << 24) | ((hash[offset + 1] & 0xff) << 16) |
21902 ((hash[offset + 2] & 0xff) << 8) | (hash[offset + 3] & 0xff);
21903 /* tslint:enable */
21904 let otp = '';
21905 if (isSteamAuth) {
21906 // tslint:disable-next-line
21907 let fullCode = binary & 0x7fffffff;
21908 for (let i = 0; i < digits; i++) {
21909 otp += SteamChars[fullCode % SteamChars.length];
21910 fullCode = Math.trunc(fullCode / SteamChars.length);
21911 }
21912 }
21913 else {
21914 otp = (binary % Math.pow(10, digits)).toString();
21915 otp = this.leftPad(otp, digits, '0');
21916 }
21917 return otp;
21918 });
21919 }
21920 getTimeInterval(key) {
21921 let period = 30;
21922 if (key != null && key.toLowerCase().indexOf('otpauth://') === 0) {
21923 const params = utils_Utils.getQueryParams(key);
21924 if (params.has('period') && params.get('period') != null) {
21925 try {
21926 period = parseInt(params.get('period').trim(), null);
21927 }
21928 catch (_a) { }
21929 }
21930 }
21931 return period;
21932 }
21933 isAutoCopyEnabled() {
21934 return totp_service_awaiter(this, void 0, void 0, function* () {
21935 return !(yield this.storageService.get(ConstantsService.disableAutoTotpCopyKey));
21936 });
21937 }
21938 // Helpers
21939 leftPad(s, l, p) {
21940 if (l + 1 >= s.length) {
21941 s = Array(l + 1 - s.length).join(p) + s;
21942 }
21943 return s;
21944 }
21945 decToHex(d) {
21946 return (d < 15.5 ? '0' : '') + Math.round(d).toString(16);
21947 }
21948 b32ToHex(s) {
21949 s = s.toUpperCase();
21950 let cleanedInput = '';
21951 for (let i = 0; i < s.length; i++) {
21952 if (B32Chars.indexOf(s[i]) < 0) {
21953 continue;
21954 }
21955 cleanedInput += s[i];
21956 }
21957 s = cleanedInput;
21958 let bits = '';
21959 let hex = '';
21960 for (let i = 0; i < s.length; i++) {
21961 const byteIndex = B32Chars.indexOf(s.charAt(i));
21962 if (byteIndex < 0) {
21963 continue;
21964 }
21965 bits += this.leftPad(byteIndex.toString(2), 5, '0');
21966 }
21967 for (let i = 0; i + 4 <= bits.length; i += 4) {
21968 const chunk = bits.substr(i, 4);
21969 hex = hex + parseInt(chunk, 2).toString(16);
21970 }
21971 return hex;
21972 }
21973 b32ToBytes(s) {
21974 return utils_Utils.fromHexToArray(this.b32ToHex(s));
21975 }
21976 sign(keyBytes, timeBytes, alg) {
21977 return totp_service_awaiter(this, void 0, void 0, function* () {
21978 const signature = yield this.cryptoFunctionService.hmac(timeBytes.buffer, keyBytes.buffer, alg);
21979 return new Uint8Array(signature);
21980 });
21981 }
21982}
21983
21984// CONCATENATED MODULE: ./jslib/src/enums/organizationUserStatusType.ts
21985var OrganizationUserStatusType;
21986(function (OrganizationUserStatusType) {
21987 OrganizationUserStatusType[OrganizationUserStatusType["Invited"] = 0] = "Invited";
21988 OrganizationUserStatusType[OrganizationUserStatusType["Accepted"] = 1] = "Accepted";
21989 OrganizationUserStatusType[OrganizationUserStatusType["Confirmed"] = 2] = "Confirmed";
21990})(OrganizationUserStatusType || (OrganizationUserStatusType = {}));
21991
21992// CONCATENATED MODULE: ./jslib/src/enums/organizationUserType.ts
21993var OrganizationUserType;
21994(function (OrganizationUserType) {
21995 OrganizationUserType[OrganizationUserType["Owner"] = 0] = "Owner";
21996 OrganizationUserType[OrganizationUserType["Admin"] = 1] = "Admin";
21997 OrganizationUserType[OrganizationUserType["User"] = 2] = "User";
21998 OrganizationUserType[OrganizationUserType["Manager"] = 3] = "Manager";
21999})(OrganizationUserType || (OrganizationUserType = {}));
22000
22001// CONCATENATED MODULE: ./jslib/src/models/domain/organization.ts
22002
22003
22004class organization_Organization {
22005 constructor(obj) {
22006 if (obj == null) {
22007 return;
22008 }
22009 this.id = obj.id;
22010 this.name = obj.name;
22011 this.status = obj.status;
22012 this.type = obj.type;
22013 this.enabled = obj.enabled;
22014 this.usePolicies = obj.usePolicies;
22015 this.useGroups = obj.useGroups;
22016 this.useDirectory = obj.useDirectory;
22017 this.useEvents = obj.useEvents;
22018 this.useTotp = obj.useTotp;
22019 this.use2fa = obj.use2fa;
22020 this.useApi = obj.useApi;
22021 this.selfHost = obj.selfHost;
22022 this.usersGetPremium = obj.usersGetPremium;
22023 this.seats = obj.seats;
22024 this.maxCollections = obj.maxCollections;
22025 this.maxStorageGb = obj.maxStorageGb;
22026 }
22027 get canAccess() {
22028 if (this.type === OrganizationUserType.Owner) {
22029 return true;
22030 }
22031 return this.enabled && this.status === OrganizationUserStatusType.Confirmed;
22032 }
22033 get isManager() {
22034 return this.type === OrganizationUserType.Manager || this.type === OrganizationUserType.Owner ||
22035 this.type === OrganizationUserType.Admin;
22036 }
22037 get isAdmin() {
22038 return this.type === OrganizationUserType.Owner || this.type === OrganizationUserType.Admin;
22039 }
22040 get isOwner() {
22041 return this.type === OrganizationUserType.Owner;
22042 }
22043}
22044
22045// CONCATENATED MODULE: ./jslib/src/services/user.service.ts
22046var user_service_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
22047 return new (P || (P = Promise))(function (resolve, reject) {
22048 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
22049 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
22050 function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
22051 step((generator = generator.apply(thisArg, _arguments || [])).next());
22052 });
22053};
22054
22055const user_service_Keys = {
22056 userId: 'userId',
22057 userEmail: 'userEmail',
22058 stamp: 'securityStamp',
22059 kdf: 'kdf',
22060 kdfIterations: 'kdfIterations',
22061 organizationsPrefix: 'organizations_',
22062};
22063class user_service_UserService {
22064 constructor(tokenService, storageService) {
22065 this.tokenService = tokenService;
22066 this.storageService = storageService;
22067 }
22068 setInformation(userId, email, kdf, kdfIterations) {
22069 this.email = email;
22070 this.userId = userId;
22071 this.kdf = kdf;
22072 this.kdfIterations = kdfIterations;
22073 return Promise.all([
22074 this.storageService.save(user_service_Keys.userEmail, email),
22075 this.storageService.save(user_service_Keys.userId, userId),
22076 this.storageService.save(user_service_Keys.kdf, kdf),
22077 this.storageService.save(user_service_Keys.kdfIterations, kdfIterations),
22078 ]);
22079 }
22080 setSecurityStamp(stamp) {
22081 this.stamp = stamp;
22082 return this.storageService.save(user_service_Keys.stamp, stamp);
22083 }
22084 getUserId() {
22085 return user_service_awaiter(this, void 0, void 0, function* () {
22086 if (this.userId == null) {
22087 this.userId = yield this.storageService.get(user_service_Keys.userId);
22088 }
22089 return this.userId;
22090 });
22091 }
22092 getEmail() {
22093 return user_service_awaiter(this, void 0, void 0, function* () {
22094 if (this.email == null) {
22095 this.email = yield this.storageService.get(user_service_Keys.userEmail);
22096 }
22097 return this.email;
22098 });
22099 }
22100 getSecurityStamp() {
22101 return user_service_awaiter(this, void 0, void 0, function* () {
22102 if (this.stamp == null) {
22103 this.stamp = yield this.storageService.get(user_service_Keys.stamp);
22104 }
22105 return this.stamp;
22106 });
22107 }
22108 getKdf() {
22109 return user_service_awaiter(this, void 0, void 0, function* () {
22110 if (this.kdf == null) {
22111 this.kdf = yield this.storageService.get(user_service_Keys.kdf);
22112 }
22113 return this.kdf;
22114 });
22115 }
22116 getKdfIterations() {
22117 return user_service_awaiter(this, void 0, void 0, function* () {
22118 if (this.kdfIterations == null) {
22119 this.kdfIterations = yield this.storageService.get(user_service_Keys.kdfIterations);
22120 }
22121 return this.kdfIterations;
22122 });
22123 }
22124 clear() {
22125 return user_service_awaiter(this, void 0, void 0, function* () {
22126 const userId = yield this.getUserId();
22127 yield Promise.all([
22128 this.storageService.remove(user_service_Keys.userId),
22129 this.storageService.remove(user_service_Keys.userEmail),
22130 this.storageService.remove(user_service_Keys.stamp),
22131 this.storageService.remove(user_service_Keys.kdf),
22132 this.storageService.remove(user_service_Keys.kdfIterations),
22133 this.clearOrganizations(userId),
22134 ]);
22135 this.userId = this.email = this.stamp = null;
22136 this.kdf = null;
22137 this.kdfIterations = null;
22138 });
22139 }
22140 isAuthenticated() {
22141 return user_service_awaiter(this, void 0, void 0, function* () {
22142 const token = yield this.tokenService.getToken();
22143 if (token == null) {
22144 return false;
22145 }
22146 const userId = yield this.getUserId();
22147 return userId != null;
22148 });
22149 }
22150 canAccessPremium() {
22151 return user_service_awaiter(this, void 0, void 0, function* () {
22152 const tokenPremium = this.tokenService.getPremium();
22153 if (tokenPremium) {
22154 return true;
22155 }
22156 const orgs = yield this.getAllOrganizations();
22157 for (let i = 0; i < orgs.length; i++) {
22158 if (orgs[i].usersGetPremium && orgs[i].enabled) {
22159 return true;
22160 }
22161 }
22162 return false;
22163 });
22164 }
22165 getOrganization(id) {
22166 return user_service_awaiter(this, void 0, void 0, function* () {
22167 const userId = yield this.getUserId();
22168 const organizations = yield this.storageService.get(user_service_Keys.organizationsPrefix + userId);
22169 if (organizations == null || !organizations.hasOwnProperty(id)) {
22170 return null;
22171 }
22172 return new organization_Organization(organizations[id]);
22173 });
22174 }
22175 getAllOrganizations() {
22176 return user_service_awaiter(this, void 0, void 0, function* () {
22177 const userId = yield this.getUserId();
22178 const organizations = yield this.storageService.get(user_service_Keys.organizationsPrefix + userId);
22179 const response = [];
22180 for (const id in organizations) {
22181 if (organizations.hasOwnProperty(id)) {
22182 response.push(new organization_Organization(organizations[id]));
22183 }
22184 }
22185 return response;
22186 });
22187 }
22188 replaceOrganizations(organizations) {
22189 return user_service_awaiter(this, void 0, void 0, function* () {
22190 const userId = yield this.getUserId();
22191 yield this.storageService.save(user_service_Keys.organizationsPrefix + userId, organizations);
22192 });
22193 }
22194 clearOrganizations(userId) {
22195 return user_service_awaiter(this, void 0, void 0, function* () {
22196 yield this.storageService.remove(user_service_Keys.organizationsPrefix + userId);
22197 });
22198 }
22199}
22200
22201// CONCATENATED MODULE: ./jslib/src/services/vaultTimeout.service.ts
22202var vaultTimeout_service_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
22203 return new (P || (P = Promise))(function (resolve, reject) {
22204 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
22205 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
22206 function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
22207 step((generator = generator.apply(thisArg, _arguments || [])).next());
22208 });
22209};
22210
22211class vaultTimeout_service_VaultTimeoutService {
22212 constructor(cipherService, folderService, collectionService, cryptoService, platformUtilsService, storageService, messagingService, searchService, userService, tokenService, lockedCallback = null, loggedOutCallback = null) {
22213 this.cipherService = cipherService;
22214 this.folderService = folderService;
22215 this.collectionService = collectionService;
22216 this.cryptoService = cryptoService;
22217 this.platformUtilsService = platformUtilsService;
22218 this.storageService = storageService;
22219 this.messagingService = messagingService;
22220 this.searchService = searchService;
22221 this.userService = userService;
22222 this.tokenService = tokenService;
22223 this.lockedCallback = lockedCallback;
22224 this.loggedOutCallback = loggedOutCallback;
22225 this.pinProtectedKey = null;
22226 this.inited = false;
22227 }
22228 init(checkOnInterval) {
22229 if (this.inited) {
22230 return;
22231 }
22232 this.inited = true;
22233 if (checkOnInterval) {
22234 this.checkVaultTimeout();
22235 setInterval(() => this.checkVaultTimeout(), 10 * 1000); // check every 10 seconds
22236 }
22237 }
22238 // Keys aren't stored for a device that is locked or logged out.
22239 isLocked() {
22240 return vaultTimeout_service_awaiter(this, void 0, void 0, function* () {
22241 const hasKey = yield this.cryptoService.hasKey();
22242 return !hasKey;
22243 });
22244 }
22245 checkVaultTimeout() {
22246 return vaultTimeout_service_awaiter(this, void 0, void 0, function* () {
22247 if (yield this.platformUtilsService.isViewOpen()) {
22248 // Do not lock
22249 return;
22250 }
22251 // "is logged out check" - similar to isLocked, below
22252 const authed = yield this.userService.isAuthenticated();
22253 if (!authed) {
22254 return;
22255 }
22256 if (yield this.isLocked()) {
22257 return;
22258 }
22259 // This has the potential to be removed. Evaluate after all platforms complete with auto-logout
22260 let vaultTimeout = this.platformUtilsService.lockTimeout();
22261 if (vaultTimeout == null) {
22262 vaultTimeout = yield this.storageService.get(ConstantsService.vaultTimeoutKey);
22263 }
22264 if (vaultTimeout == null || vaultTimeout < 0) {
22265 return;
22266 }
22267 const lastActive = yield this.storageService.get(ConstantsService.lastActiveKey);
22268 if (lastActive == null) {
22269 return;
22270 }
22271 const vaultTimeoutSeconds = vaultTimeout * 60;
22272 const diffSeconds = ((new Date()).getTime() - lastActive) / 1000;
22273 if (diffSeconds >= vaultTimeoutSeconds) {
22274 // Pivot based on the saved vault timeout action
22275 const timeoutAction = yield this.storageService.get(ConstantsService.vaultTimeoutActionKey);
22276 timeoutAction === 'logOut' ? yield this.logOut() : yield this.lock(true);
22277 }
22278 });
22279 }
22280 lock(allowSoftLock = false) {
22281 return vaultTimeout_service_awaiter(this, void 0, void 0, function* () {
22282 const authed = yield this.userService.isAuthenticated();
22283 if (!authed) {
22284 return;
22285 }
22286 yield Promise.all([
22287 this.cryptoService.clearKey(),
22288 this.cryptoService.clearOrgKeys(true),
22289 this.cryptoService.clearKeyPair(true),
22290 this.cryptoService.clearEncKey(true),
22291 ]);
22292 this.folderService.clearCache();
22293 this.cipherService.clearCache();
22294 this.collectionService.clearCache();
22295 this.searchService.clearIndex();
22296 this.messagingService.send('locked');
22297 if (this.lockedCallback != null) {
22298 yield this.lockedCallback();
22299 }
22300 });
22301 }
22302 logOut() {
22303 return vaultTimeout_service_awaiter(this, void 0, void 0, function* () {
22304 if (this.loggedOutCallback != null) {
22305 yield this.loggedOutCallback();
22306 }
22307 });
22308 }
22309 setVaultTimeoutOptions(timeout, action) {
22310 return vaultTimeout_service_awaiter(this, void 0, void 0, function* () {
22311 yield this.storageService.save(ConstantsService.vaultTimeoutKey, timeout);
22312 yield this.storageService.save(ConstantsService.vaultTimeoutActionKey, action);
22313 yield this.cryptoService.toggleKey();
22314 yield this.tokenService.toggleTokens();
22315 });
22316 }
22317 isPinLockSet() {
22318 return vaultTimeout_service_awaiter(this, void 0, void 0, function* () {
22319 const protectedPin = yield this.storageService.get(ConstantsService.protectedPin);
22320 const pinProtectedKey = yield this.storageService.get(ConstantsService.pinProtectedKey);
22321 return [protectedPin != null, pinProtectedKey != null];
22322 });
22323 }
22324 clear() {
22325 this.pinProtectedKey = null;
22326 return this.storageService.remove(ConstantsService.protectedPin);
22327 }
22328}
22329
22330// EXTERNAL MODULE: external "chalk"
22331var external_chalk_ = __webpack_require__(10);
22332var external_chalk_default = /*#__PURE__*/__webpack_require__.n(external_chalk_);
22333
22334// EXTERNAL MODULE: external "commander"
22335var external_commander_ = __webpack_require__(0);
22336
22337// CONCATENATED MODULE: ./jslib/src/cli/models/response.ts
22338class Response {
22339 static error(error, data) {
22340 const res = new Response();
22341 res.success = false;
22342 if (typeof (error) === 'string') {
22343 res.message = error;
22344 }
22345 else {
22346 res.message = error.message != null ? error.message : error.toString();
22347 }
22348 res.data = data;
22349 return res;
22350 }
22351 static notFound() {
22352 return Response.error('Not found.');
22353 }
22354 static badRequest(message) {
22355 return Response.error(message);
22356 }
22357 static multipleResults(ids) {
22358 let msg = 'More than one result was found. Try getting a specific object by `id` instead. ' +
22359 'The following objects were found:';
22360 ids.forEach((id) => {
22361 msg += '\n' + id;
22362 });
22363 return Response.error(msg, ids);
22364 }
22365 static success(data) {
22366 const res = new Response();
22367 res.success = true;
22368 res.data = data;
22369 return res;
22370 }
22371}
22372
22373// CONCATENATED MODULE: ./jslib/src/cli/models/response/messageResponse.ts
22374class MessageResponse {
22375 constructor(title, message) {
22376 this.noColor = false;
22377 this.object = 'message';
22378 this.title = title;
22379 this.message = message;
22380 }
22381}
22382
22383// CONCATENATED MODULE: ./jslib/src/cli/models/response/stringResponse.ts
22384class StringResponse {
22385 constructor(data) {
22386 this.object = 'string';
22387 this.data = data;
22388 }
22389}
22390
22391// CONCATENATED MODULE: ./src/commands/config.command.ts
22392var config_command_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
22393 return new (P || (P = Promise))(function (resolve, reject) {
22394 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
22395 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
22396 function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
22397 step((generator = generator.apply(thisArg, _arguments || [])).next());
22398 });
22399};
22400
22401
22402
22403class config_command_ConfigCommand {
22404 constructor(environmentService) {
22405 this.environmentService = environmentService;
22406 }
22407 run(setting, value, cmd) {
22408 return config_command_awaiter(this, void 0, void 0, function* () {
22409 setting = setting.toLowerCase();
22410 switch (setting) {
22411 case 'server':
22412 return yield this.getOrSetServer(value, cmd);
22413 default:
22414 return Response.badRequest('Unknown setting.');
22415 }
22416 });
22417 }
22418 getOrSetServer(url, cmd) {
22419 return config_command_awaiter(this, void 0, void 0, function* () {
22420 if ((url == null || url.trim() === '') &&
22421 !cmd.webVault && !cmd.api && !cmd.identity && !cmd.icons && !cmd.notifications && !cmd.events) {
22422 const baseUrl = this.environmentService.baseUrl;
22423 const stringRes = new StringResponse(baseUrl == null ? 'https://bitwarden.com' : baseUrl);
22424 return Response.success(stringRes);
22425 }
22426 url = (url === 'null' || url === 'bitwarden.com' || url === 'https://bitwarden.com' ? null : url);
22427 yield this.environmentService.setUrls({
22428 base: url,
22429 webVault: cmd.webVault || null,
22430 api: cmd.api || null,
22431 identity: cmd.identity || null,
22432 icons: cmd.icons || null,
22433 notifications: cmd.notifications || null,
22434 events: cmd.events || null,
22435 });
22436 const res = new MessageResponse('Saved setting `config`.', null);
22437 return Response.success(res);
22438 });
22439 }
22440}
22441
22442// CONCATENATED MODULE: ./jslib/src/models/request/organizationUserConfirmRequest.ts
22443class OrganizationUserConfirmRequest {
22444}
22445
22446// CONCATENATED MODULE: ./src/commands/confirm.command.ts
22447var confirm_command_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
22448 return new (P || (P = Promise))(function (resolve, reject) {
22449 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
22450 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
22451 function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
22452 step((generator = generator.apply(thisArg, _arguments || [])).next());
22453 });
22454};
22455
22456
22457
22458class confirm_command_ConfirmCommand {
22459 constructor(apiService, cryptoService) {
22460 this.apiService = apiService;
22461 this.cryptoService = cryptoService;
22462 }
22463 run(object, id, cmd) {
22464 return confirm_command_awaiter(this, void 0, void 0, function* () {
22465 if (id != null) {
22466 id = id.toLowerCase();
22467 }
22468 switch (object.toLowerCase()) {
22469 case 'org-member':
22470 return yield this.confirmOrganizationMember(id, cmd);
22471 default:
22472 return Response.badRequest('Unknown object.');
22473 }
22474 });
22475 }
22476 confirmOrganizationMember(id, cmd) {
22477 return confirm_command_awaiter(this, void 0, void 0, function* () {
22478 if (cmd.organizationid == null || cmd.organizationid === '') {
22479 return Response.badRequest('--organizationid <organizationid> required.');
22480 }
22481 if (!utils_Utils.isGuid(id)) {
22482 return Response.error('`' + id + '` is not a GUID.');
22483 }
22484 if (!utils_Utils.isGuid(cmd.organizationid)) {
22485 return Response.error('`' + cmd.organizationid + '` is not a GUID.');
22486 }
22487 try {
22488 const orgKey = yield this.cryptoService.getOrgKey(cmd.organizationid);
22489 if (orgKey == null) {
22490 throw new Error('No encryption key for this organization.');
22491 }
22492 const orgUser = yield this.apiService.getOrganizationUser(cmd.organizationid, id);
22493 if (orgUser == null) {
22494 throw new Error('Member id does not exist for this organization.');
22495 }
22496 const publicKeyResponse = yield this.apiService.getUserPublicKey(orgUser.userId);
22497 const publicKey = utils_Utils.fromB64ToArray(publicKeyResponse.publicKey);
22498 const key = yield this.cryptoService.rsaEncrypt(orgKey.key, publicKey.buffer);
22499 const req = new OrganizationUserConfirmRequest();
22500 req.key = key.encryptedString;
22501 yield this.apiService.postOrganizationUserConfirm(cmd.organizationid, id, req);
22502 return Response.success();
22503 }
22504 catch (e) {
22505 return Response.error(e);
22506 }
22507 });
22508 }
22509}
22510
22511// CONCATENATED MODULE: ./jslib/src/models/request/selectionReadOnlyRequest.ts
22512class SelectionReadOnlyRequest {
22513 constructor(id, readOnly, hidePasswords) {
22514 this.id = id;
22515 this.readOnly = readOnly;
22516 this.hidePasswords = hidePasswords;
22517 }
22518}
22519
22520// CONCATENATED MODULE: ./src/models/response/attachmentResponse.ts
22521class response_attachmentResponse_AttachmentResponse {
22522 constructor(o) {
22523 this.id = o.id;
22524 this.fileName = o.fileName;
22525 this.size = o.size;
22526 this.sizeName = o.sizeName;
22527 this.url = o.url;
22528 }
22529}
22530
22531// CONCATENATED MODULE: ./src/models/response/loginResponse.ts
22532
22533class loginResponse_LoginResponse extends export_login_Login {
22534 constructor(o) {
22535 super(o);
22536 this.passwordRevisionDate = o.passwordRevisionDate != null ? o.passwordRevisionDate : null;
22537 }
22538}
22539
22540// CONCATENATED MODULE: ./src/models/response/passwordHistoryResponse.ts
22541class response_passwordHistoryResponse_PasswordHistoryResponse {
22542 constructor(o) {
22543 this.lastUsedDate = o.lastUsedDate;
22544 this.password = o.password;
22545 }
22546}
22547
22548// CONCATENATED MODULE: ./jslib/src/enums/logLevelType.ts
22549var LogLevelType;
22550(function (LogLevelType) {
22551 LogLevelType[LogLevelType["Debug"] = 0] = "Debug";
22552 LogLevelType[LogLevelType["Info"] = 1] = "Info";
22553 LogLevelType[LogLevelType["Warning"] = 2] = "Warning";
22554 LogLevelType[LogLevelType["Error"] = 3] = "Error";
22555})(LogLevelType || (LogLevelType = {}));
22556
22557// CONCATENATED MODULE: ./jslib/src/enums/index.ts
22558
22559
22560
22561
22562
22563
22564
22565
22566
22567// CONCATENATED MODULE: ./src/models/response/cipherResponse.ts
22568
22569
22570
22571
22572
22573class response_cipherResponse_CipherResponse extends cipherWithIds_CipherWithIds {
22574 constructor(o) {
22575 super();
22576 this.object = 'item';
22577 this.build(o);
22578 if (o.attachments != null) {
22579 this.attachments = o.attachments.map((a) => new response_attachmentResponse_AttachmentResponse(a));
22580 }
22581 this.revisionDate = o.revisionDate;
22582 if (o.passwordHistory != null) {
22583 this.passwordHistory = o.passwordHistory.map((h) => new response_passwordHistoryResponse_PasswordHistoryResponse(h));
22584 }
22585 if (o.type === CipherType.Login && o.login != null) {
22586 this.login = new loginResponse_LoginResponse(o.login);
22587 }
22588 }
22589}
22590
22591// CONCATENATED MODULE: ./src/models/response/folderResponse.ts
22592
22593class response_folderResponse_FolderResponse extends folderWithId_FolderWithId {
22594 constructor(o) {
22595 super();
22596 this.object = 'folder';
22597 this.build(o);
22598 }
22599}
22600
22601// CONCATENATED MODULE: ./src/models/response/collectionResponse.ts
22602
22603class response_collectionResponse_CollectionResponse extends collectionWithId_CollectionWithId {
22604 constructor(o) {
22605 super();
22606 this.object = 'collection';
22607 this.build(o);
22608 }
22609}
22610
22611// CONCATENATED MODULE: ./src/models/response/organizationCollectionResponse.ts
22612
22613class organizationCollectionResponse_OrganizationCollectionResponse extends response_collectionResponse_CollectionResponse {
22614 constructor(o, groups) {
22615 super(o);
22616 this.object = 'org-collection';
22617 this.groups = groups;
22618 }
22619}
22620
22621// CONCATENATED MODULE: ./src/utils.ts
22622
22623
22624
22625class utils_CliUtils {
22626 static writeLn(s, finalLine = false, error = false) {
22627 const stream = error ? process.stderr : process.stdout;
22628 if (finalLine && (process.platform === 'win32' || !stream.isTTY)) {
22629 stream.write(s);
22630 }
22631 else {
22632 stream.write(s + '\n');
22633 }
22634 }
22635 static readFile(input) {
22636 return new Promise((resolve, reject) => {
22637 let p = null;
22638 if (input != null && input !== '') {
22639 const osInput = external_path_["join"](input);
22640 if (osInput.indexOf(external_path_["sep"]) === -1) {
22641 p = external_path_["join"](process.cwd(), osInput);
22642 }
22643 else {
22644 p = osInput;
22645 }
22646 }
22647 else {
22648 reject('You must specify a file path.');
22649 }
22650 external_fs_["readFile"](p, 'utf8', (err, data) => {
22651 if (err != null) {
22652 reject(err.message);
22653 }
22654 resolve(data);
22655 });
22656 });
22657 }
22658 static saveFile(data, output, defaultFileName) {
22659 let p = null;
22660 let mkdir = false;
22661 if (output != null && output !== '') {
22662 const osOutput = external_path_["join"](output);
22663 if (osOutput.indexOf(external_path_["sep"]) === -1) {
22664 p = external_path_["join"](process.cwd(), osOutput);
22665 }
22666 else {
22667 mkdir = true;
22668 if (osOutput.endsWith(external_path_["sep"])) {
22669 p = external_path_["join"](osOutput, defaultFileName);
22670 }
22671 else {
22672 p = osOutput;
22673 }
22674 }
22675 }
22676 else {
22677 p = external_path_["join"](process.cwd(), defaultFileName);
22678 }
22679 p = external_path_["resolve"](p);
22680 if (mkdir) {
22681 const dir = p.substring(0, p.lastIndexOf(external_path_["sep"]));
22682 if (!external_fs_["existsSync"](dir)) {
22683 nodeUtils_NodeUtils.mkdirpSync(dir, '700');
22684 }
22685 }
22686 return new Promise((resolve, reject) => {
22687 external_fs_["writeFile"](p, data, 'utf8', (err) => {
22688 if (err != null) {
22689 reject('Cannot save file to ' + p);
22690 }
22691 resolve(p);
22692 });
22693 });
22694 }
22695 static readStdin() {
22696 return new Promise((resolve, reject) => {
22697 let input = '';
22698 if (process.stdin.isTTY) {
22699 resolve(input);
22700 return;
22701 }
22702 process.stdin.setEncoding('utf8');
22703 process.stdin.on('readable', () => {
22704 while (true) {
22705 const chunk = process.stdin.read();
22706 if (chunk == null) {
22707 break;
22708 }
22709 input += chunk;
22710 }
22711 });
22712 process.stdin.on('end', () => {
22713 resolve(input);
22714 });
22715 });
22716 }
22717 static searchFolders(folders, search) {
22718 search = search.toLowerCase();
22719 return folders.filter((f) => {
22720 if (f.name != null && f.name.toLowerCase().indexOf(search) > -1) {
22721 return true;
22722 }
22723 return false;
22724 });
22725 }
22726 static searchCollections(collections, search) {
22727 search = search.toLowerCase();
22728 return collections.filter((c) => {
22729 if (c.name != null && c.name.toLowerCase().indexOf(search) > -1) {
22730 return true;
22731 }
22732 return false;
22733 });
22734 }
22735 static searchOrganizations(organizations, search) {
22736 search = search.toLowerCase();
22737 return organizations.filter((o) => {
22738 if (o.name != null && o.name.toLowerCase().indexOf(search) > -1) {
22739 return true;
22740 }
22741 return false;
22742 });
22743 }
22744}
22745
22746// CONCATENATED MODULE: ./src/commands/create.command.ts
22747var create_command_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
22748 return new (P || (P = Promise))(function (resolve, reject) {
22749 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
22750 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
22751 function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
22752 step((generator = generator.apply(thisArg, _arguments || [])).next());
22753 });
22754};
22755
22756
22757
22758
22759
22760
22761
22762
22763
22764
22765
22766
22767
22768class create_command_CreateCommand {
22769 constructor(cipherService, folderService, userService, cryptoService, apiService) {
22770 this.cipherService = cipherService;
22771 this.folderService = folderService;
22772 this.userService = userService;
22773 this.cryptoService = cryptoService;
22774 this.apiService = apiService;
22775 }
22776 run(object, requestJson, cmd) {
22777 return create_command_awaiter(this, void 0, void 0, function* () {
22778 let req = null;
22779 if (object !== 'attachment') {
22780 if (requestJson == null || requestJson === '') {
22781 requestJson = yield utils_CliUtils.readStdin();
22782 }
22783 if (requestJson == null || requestJson === '') {
22784 return Response.badRequest('`requestJson` was not provided.');
22785 }
22786 try {
22787 const reqJson = Buffer.from(requestJson, 'base64').toString();
22788 req = JSON.parse(reqJson);
22789 }
22790 catch (e) {
22791 return Response.badRequest('Error parsing the encoded request data.');
22792 }
22793 }
22794 switch (object.toLowerCase()) {
22795 case 'item':
22796 return yield this.createCipher(req);
22797 case 'attachment':
22798 return yield this.createAttachment(cmd);
22799 case 'folder':
22800 return yield this.createFolder(req);
22801 case 'org-collection':
22802 return yield this.createOrganizationCollection(req, cmd);
22803 default:
22804 return Response.badRequest('Unknown object.');
22805 }
22806 });
22807 }
22808 createCipher(req) {
22809 return create_command_awaiter(this, void 0, void 0, function* () {
22810 const cipher = yield this.cipherService.encrypt(export_cipher_Cipher.toView(req));
22811 try {
22812 yield this.cipherService.saveWithServer(cipher);
22813 const newCipher = yield this.cipherService.get(cipher.id);
22814 const decCipher = yield newCipher.decrypt();
22815 const res = new response_cipherResponse_CipherResponse(decCipher);
22816 return Response.success(res);
22817 }
22818 catch (e) {
22819 return Response.error(e);
22820 }
22821 });
22822 }
22823 createAttachment(cmd) {
22824 return create_command_awaiter(this, void 0, void 0, function* () {
22825 if (cmd.itemid == null || cmd.itemid === '') {
22826 return Response.badRequest('--itemid <itemid> required.');
22827 }
22828 if (cmd.file == null || cmd.file === '') {
22829 return Response.badRequest('--file <file> required.');
22830 }
22831 const filePath = external_path_["resolve"](cmd.file);
22832 if (!external_fs_["existsSync"](cmd.file)) {
22833 return Response.badRequest('Cannot find file at ' + filePath);
22834 }
22835 const itemId = cmd.itemid.toLowerCase();
22836 const cipher = yield this.cipherService.get(itemId);
22837 if (cipher == null) {
22838 return Response.notFound();
22839 }
22840 if (cipher.organizationId == null && !(yield this.userService.canAccessPremium())) {
22841 return Response.error('Premium status is required to use this feature.');
22842 }
22843 const encKey = yield this.cryptoService.getEncKey();
22844 if (encKey == null) {
22845 return Response.error('You must update your encryption key before you can use this feature. ' +
22846 'See https://help.bitwarden.com/article/update-encryption-key/');
22847 }
22848 try {
22849 const fileBuf = external_fs_["readFileSync"](filePath);
22850 yield this.cipherService.saveAttachmentRawWithServer(cipher, external_path_["basename"](filePath), new Uint8Array(fileBuf).buffer);
22851 const updatedCipher = yield this.cipherService.get(cipher.id);
22852 const decCipher = yield updatedCipher.decrypt();
22853 const res = new response_cipherResponse_CipherResponse(decCipher);
22854 return Response.success(res);
22855 }
22856 catch (e) {
22857 return Response.error(e);
22858 }
22859 });
22860 }
22861 createFolder(req) {
22862 return create_command_awaiter(this, void 0, void 0, function* () {
22863 const folder = yield this.folderService.encrypt(export_folder_Folder.toView(req));
22864 try {
22865 yield this.folderService.saveWithServer(folder);
22866 const newFolder = yield this.folderService.get(folder.id);
22867 const decFolder = yield newFolder.decrypt();
22868 const res = new response_folderResponse_FolderResponse(decFolder);
22869 return Response.success(res);
22870 }
22871 catch (e) {
22872 return Response.error(e);
22873 }
22874 });
22875 }
22876 createOrganizationCollection(req, cmd) {
22877 return create_command_awaiter(this, void 0, void 0, function* () {
22878 if (cmd.organizationid == null || cmd.organizationid === '') {
22879 return Response.badRequest('--organizationid <organizationid> required.');
22880 }
22881 if (!utils_Utils.isGuid(cmd.organizationid)) {
22882 return Response.error('`' + cmd.organizationid + '` is not a GUID.');
22883 }
22884 if (cmd.organizationid !== req.organizationId) {
22885 return Response.error('--organizationid <organizationid> does not match request object.');
22886 }
22887 try {
22888 const orgKey = yield this.cryptoService.getOrgKey(req.organizationId);
22889 if (orgKey == null) {
22890 throw new Error('No encryption key for this organization.');
22891 }
22892 const groups = req.groups == null ? null :
22893 req.groups.map((g) => new SelectionReadOnlyRequest(g.id, g.readOnly, g.hidePasswords));
22894 const request = new CollectionRequest();
22895 request.name = (yield this.cryptoService.encrypt(req.name, orgKey)).encryptedString;
22896 request.externalId = req.externalId;
22897 request.groups = groups;
22898 yield this.apiService.postCollection(req.organizationId, request);
22899 const res = new organizationCollectionResponse_OrganizationCollectionResponse(export_collection_Collection.toView(req), groups);
22900 return Response.success(res);
22901 }
22902 catch (e) {
22903 return Response.error(e);
22904 }
22905 });
22906 }
22907}
22908
22909// CONCATENATED MODULE: ./src/commands/delete.command.ts
22910var delete_command_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
22911 return new (P || (P = Promise))(function (resolve, reject) {
22912 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
22913 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
22914 function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
22915 step((generator = generator.apply(thisArg, _arguments || [])).next());
22916 });
22917};
22918
22919
22920class delete_command_DeleteCommand {
22921 constructor(cipherService, folderService, userService, apiService) {
22922 this.cipherService = cipherService;
22923 this.folderService = folderService;
22924 this.userService = userService;
22925 this.apiService = apiService;
22926 }
22927 run(object, id, cmd) {
22928 return delete_command_awaiter(this, void 0, void 0, function* () {
22929 if (id != null) {
22930 id = id.toLowerCase();
22931 }
22932 switch (object.toLowerCase()) {
22933 case 'item':
22934 return yield this.deleteCipher(id, cmd);
22935 case 'attachment':
22936 return yield this.deleteAttachment(id, cmd);
22937 case 'folder':
22938 return yield this.deleteFolder(id);
22939 case 'org-collection':
22940 return yield this.deleteOrganizationCollection(id, cmd);
22941 default:
22942 return Response.badRequest('Unknown object.');
22943 }
22944 });
22945 }
22946 deleteCipher(id, cmd) {
22947 return delete_command_awaiter(this, void 0, void 0, function* () {
22948 const cipher = yield this.cipherService.get(id);
22949 if (cipher == null) {
22950 return Response.notFound();
22951 }
22952 try {
22953 if (cmd.permanent) {
22954 yield this.cipherService.deleteWithServer(id);
22955 }
22956 else {
22957 yield this.cipherService.softDeleteWithServer(id);
22958 }
22959 return Response.success();
22960 }
22961 catch (e) {
22962 return Response.error(e);
22963 }
22964 });
22965 }
22966 deleteAttachment(id, cmd) {
22967 return delete_command_awaiter(this, void 0, void 0, function* () {
22968 if (cmd.itemid == null || cmd.itemid === '') {
22969 return Response.badRequest('--itemid <itemid> required.');
22970 }
22971 const itemId = cmd.itemid.toLowerCase();
22972 const cipher = yield this.cipherService.get(itemId);
22973 if (cipher == null) {
22974 return Response.notFound();
22975 }
22976 if (cipher.attachments == null || cipher.attachments.length === 0) {
22977 return Response.error('No attachments available for this item.');
22978 }
22979 const attachments = cipher.attachments.filter((a) => a.id.toLowerCase() === id);
22980 if (attachments.length === 0) {
22981 return Response.error('Attachment `' + id + '` was not found.');
22982 }
22983 if (cipher.organizationId == null && !(yield this.userService.canAccessPremium())) {
22984 return Response.error('Premium status is required to use this feature.');
22985 }
22986 try {
22987 yield this.cipherService.deleteAttachmentWithServer(cipher.id, attachments[0].id);
22988 return Response.success();
22989 }
22990 catch (e) {
22991 return Response.error(e);
22992 }
22993 });
22994 }
22995 deleteFolder(id) {
22996 return delete_command_awaiter(this, void 0, void 0, function* () {
22997 const folder = yield this.folderService.get(id);
22998 if (folder == null) {
22999 return Response.notFound();
23000 }
23001 try {
23002 yield this.folderService.deleteWithServer(id);
23003 return Response.success();
23004 }
23005 catch (e) {
23006 return Response.error(e);
23007 }
23008 });
23009 }
23010 deleteOrganizationCollection(id, cmd) {
23011 return delete_command_awaiter(this, void 0, void 0, function* () {
23012 if (cmd.organizationid == null || cmd.organizationid === '') {
23013 return Response.badRequest('--organizationid <organizationid> required.');
23014 }
23015 if (!utils_Utils.isGuid(id)) {
23016 return Response.error('`' + id + '` is not a GUID.');
23017 }
23018 if (!utils_Utils.isGuid(cmd.organizationid)) {
23019 return Response.error('`' + cmd.organizationid + '` is not a GUID.');
23020 }
23021 try {
23022 yield this.apiService.deleteCollection(cmd.organizationid, id);
23023 return Response.success();
23024 }
23025 catch (e) {
23026 return Response.error(e);
23027 }
23028 });
23029 }
23030}
23031
23032// CONCATENATED MODULE: ./src/commands/edit.command.ts
23033var edit_command_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
23034 return new (P || (P = Promise))(function (resolve, reject) {
23035 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
23036 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
23037 function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
23038 step((generator = generator.apply(thisArg, _arguments || [])).next());
23039 });
23040};
23041
23042
23043
23044
23045
23046
23047
23048
23049
23050
23051
23052class edit_command_EditCommand {
23053 constructor(cipherService, folderService, cryptoService, apiService) {
23054 this.cipherService = cipherService;
23055 this.folderService = folderService;
23056 this.cryptoService = cryptoService;
23057 this.apiService = apiService;
23058 }
23059 run(object, id, requestJson, cmd) {
23060 return edit_command_awaiter(this, void 0, void 0, function* () {
23061 if (requestJson == null || requestJson === '') {
23062 requestJson = yield utils_CliUtils.readStdin();
23063 }
23064 if (requestJson == null || requestJson === '') {
23065 return Response.badRequest('`requestJson` was not provided.');
23066 }
23067 let req = null;
23068 try {
23069 const reqJson = Buffer.from(requestJson, 'base64').toString();
23070 req = JSON.parse(reqJson);
23071 }
23072 catch (e) {
23073 return Response.badRequest('Error parsing the encoded request data.');
23074 }
23075 if (id != null) {
23076 id = id.toLowerCase();
23077 }
23078 switch (object.toLowerCase()) {
23079 case 'item':
23080 return yield this.editCipher(id, req);
23081 case 'item-collections':
23082 return yield this.editCipherCollections(id, req);
23083 case 'folder':
23084 return yield this.editFolder(id, req);
23085 case 'org-collection':
23086 return yield this.editOrganizationCollection(id, req, cmd);
23087 default:
23088 return Response.badRequest('Unknown object.');
23089 }
23090 });
23091 }
23092 editCipher(id, req) {
23093 return edit_command_awaiter(this, void 0, void 0, function* () {
23094 const cipher = yield this.cipherService.get(id);
23095 if (cipher == null) {
23096 return Response.notFound();
23097 }
23098 let cipherView = yield cipher.decrypt();
23099 if (cipherView.isDeleted) {
23100 return Response.badRequest('You may not edit a deleted cipher. Use restore item <id> command first.');
23101 }
23102 cipherView = export_cipher_Cipher.toView(req, cipherView);
23103 const encCipher = yield this.cipherService.encrypt(cipherView);
23104 try {
23105 yield this.cipherService.saveWithServer(encCipher);
23106 const updatedCipher = yield this.cipherService.get(cipher.id);
23107 const decCipher = yield updatedCipher.decrypt();
23108 const res = new response_cipherResponse_CipherResponse(decCipher);
23109 return Response.success(res);
23110 }
23111 catch (e) {
23112 return Response.error(e);
23113 }
23114 });
23115 }
23116 editCipherCollections(id, req) {
23117 return edit_command_awaiter(this, void 0, void 0, function* () {
23118 const cipher = yield this.cipherService.get(id);
23119 if (cipher == null) {
23120 return Response.notFound();
23121 }
23122 if (cipher.organizationId == null) {
23123 return Response.badRequest('Item does not belong to an organization. Consider sharing it first.');
23124 }
23125 cipher.collectionIds = req;
23126 try {
23127 yield this.cipherService.saveCollectionsWithServer(cipher);
23128 const updatedCipher = yield this.cipherService.get(cipher.id);
23129 const decCipher = yield updatedCipher.decrypt();
23130 const res = new response_cipherResponse_CipherResponse(decCipher);
23131 return Response.success(res);
23132 }
23133 catch (e) {
23134 return Response.error(e);
23135 }
23136 });
23137 }
23138 editFolder(id, req) {
23139 return edit_command_awaiter(this, void 0, void 0, function* () {
23140 const folder = yield this.folderService.get(id);
23141 if (folder == null) {
23142 return Response.notFound();
23143 }
23144 let folderView = yield folder.decrypt();
23145 folderView = export_folder_Folder.toView(req, folderView);
23146 const encFolder = yield this.folderService.encrypt(folderView);
23147 try {
23148 yield this.folderService.saveWithServer(encFolder);
23149 const updatedFolder = yield this.folderService.get(folder.id);
23150 const decFolder = yield updatedFolder.decrypt();
23151 const res = new response_folderResponse_FolderResponse(decFolder);
23152 return Response.success(res);
23153 }
23154 catch (e) {
23155 return Response.error(e);
23156 }
23157 });
23158 }
23159 editOrganizationCollection(id, req, cmd) {
23160 return edit_command_awaiter(this, void 0, void 0, function* () {
23161 if (cmd.organizationid == null || cmd.organizationid === '') {
23162 return Response.badRequest('--organizationid <organizationid> required.');
23163 }
23164 if (!utils_Utils.isGuid(id)) {
23165 return Response.error('`' + id + '` is not a GUID.');
23166 }
23167 if (!utils_Utils.isGuid(cmd.organizationid)) {
23168 return Response.error('`' + cmd.organizationid + '` is not a GUID.');
23169 }
23170 if (cmd.organizationid !== req.organizationId) {
23171 return Response.error('--organizationid <organizationid> does not match request object.');
23172 }
23173 try {
23174 const orgKey = yield this.cryptoService.getOrgKey(req.organizationId);
23175 if (orgKey == null) {
23176 throw new Error('No encryption key for this organization.');
23177 }
23178 const groups = req.groups == null ? null :
23179 req.groups.map((g) => new SelectionReadOnlyRequest(g.id, g.readOnly, g.hidePasswords));
23180 const request = new CollectionRequest();
23181 request.name = (yield this.cryptoService.encrypt(req.name, orgKey)).encryptedString;
23182 request.externalId = req.externalId;
23183 request.groups = groups;
23184 yield this.apiService.putCollection(req.organizationId, id, request);
23185 const res = new organizationCollectionResponse_OrganizationCollectionResponse(export_collection_Collection.toView(req), groups);
23186 return Response.success(res);
23187 }
23188 catch (e) {
23189 return Response.error(e);
23190 }
23191 });
23192 }
23193}
23194
23195// CONCATENATED MODULE: ./src/commands/encode.command.ts
23196var encode_command_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
23197 return new (P || (P = Promise))(function (resolve, reject) {
23198 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
23199 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
23200 function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
23201 step((generator = generator.apply(thisArg, _arguments || [])).next());
23202 });
23203};
23204
23205
23206
23207class encode_command_EncodeCommand {
23208 run(cmd) {
23209 return encode_command_awaiter(this, void 0, void 0, function* () {
23210 if (process.stdin.isTTY) {
23211 return Response.badRequest('No stdin was piped in.');
23212 }
23213 const input = yield utils_CliUtils.readStdin();
23214 const b64 = Buffer.from(input, 'utf8').toString('base64');
23215 const res = new StringResponse(b64);
23216 return Response.success(res);
23217 });
23218 }
23219}
23220
23221// EXTERNAL MODULE: external "inquirer"
23222var external_inquirer_ = __webpack_require__(5);
23223
23224// CONCATENATED MODULE: ./src/commands/export.command.ts
23225var export_command_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
23226 return new (P || (P = Promise))(function (resolve, reject) {
23227 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
23228 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
23229 function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
23230 step((generator = generator.apply(thisArg, _arguments || [])).next());
23231 });
23232};
23233
23234
23235
23236
23237
23238class export_command_ExportCommand {
23239 constructor(cryptoService, exportService) {
23240 this.cryptoService = cryptoService;
23241 this.exportService = exportService;
23242 }
23243 run(password, cmd) {
23244 return export_command_awaiter(this, void 0, void 0, function* () {
23245 const canInteract = process.env.BW_NOINTERACTION !== 'true';
23246 if ((password == null || password === '') && canInteract) {
23247 const answer = yield external_inquirer_["createPromptModule"]({ output: process.stderr })({
23248 type: 'password',
23249 name: 'password',
23250 message: 'Master password:',
23251 });
23252 password = answer.password;
23253 }
23254 if (password == null || password === '') {
23255 return Response.badRequest('Master password is required.');
23256 }
23257 const keyHash = yield this.cryptoService.hashPassword(password, null);
23258 const storedKeyHash = yield this.cryptoService.getKeyHash();
23259 if (storedKeyHash != null && keyHash != null && storedKeyHash === keyHash) {
23260 const format = cmd.format !== 'json' ? 'csv' : 'json';
23261 if (cmd.organizationid != null && !utils_Utils.isGuid(cmd.organizationid)) {
23262 return Response.error('`' + cmd.organizationid + '` is not a GUID.');
23263 }
23264 let csv = null;
23265 try {
23266 csv = cmd.organizationid != null ?
23267 yield this.exportService.getOrganizationExport(cmd.organizationid, format) :
23268 yield this.exportService.getExport(format);
23269 }
23270 catch (e) {
23271 return Response.error(e);
23272 }
23273 return yield this.saveFile(csv, cmd, format);
23274 }
23275 else {
23276 return Response.error('Invalid master password.');
23277 }
23278 });
23279 }
23280 saveFile(csv, cmd, format) {
23281 return export_command_awaiter(this, void 0, void 0, function* () {
23282 try {
23283 const filePath = yield utils_CliUtils.saveFile(csv, cmd.output, this.exportService.getFileName(cmd.organizationid != null ? 'org' : null, format));
23284 const res = new MessageResponse('Saved ' + filePath, null);
23285 res.raw = filePath;
23286 return Response.success(res);
23287 }
23288 catch (e) {
23289 return Response.error(e.toString());
23290 }
23291 });
23292 }
23293}
23294
23295// CONCATENATED MODULE: ./src/commands/generate.command.ts
23296var generate_command_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
23297 return new (P || (P = Promise))(function (resolve, reject) {
23298 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
23299 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
23300 function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
23301 step((generator = generator.apply(thisArg, _arguments || [])).next());
23302 });
23303};
23304
23305
23306class generate_command_GenerateCommand {
23307 constructor(passwordGenerationService) {
23308 this.passwordGenerationService = passwordGenerationService;
23309 }
23310 run(cmd) {
23311 return generate_command_awaiter(this, void 0, void 0, function* () {
23312 const options = {
23313 uppercase: cmd.uppercase || false,
23314 lowercase: cmd.lowercase || false,
23315 number: cmd.number || false,
23316 special: cmd.special || false,
23317 length: cmd.length || 14,
23318 type: cmd.passphrase ? 'passphrase' : 'password',
23319 wordSeparator: cmd.separator == null ? '-' : cmd.separator,
23320 numWords: cmd.words || 3,
23321 };
23322 if (!options.uppercase && !options.lowercase && !options.special && !options.number) {
23323 options.lowercase = true;
23324 options.uppercase = true;
23325 options.number = true;
23326 }
23327 if (options.length < 5) {
23328 options.length = 5;
23329 }
23330 if (options.numWords < 3) {
23331 options.numWords = 3;
23332 }
23333 if (options.wordSeparator === 'space') {
23334 options.wordSeparator = ' ';
23335 }
23336 else if (options.wordSeparator != null && options.wordSeparator.length > 1) {
23337 options.wordSeparator = options.wordSeparator[0];
23338 }
23339 const enforcedOptions = yield this.passwordGenerationService.enforcePasswordGeneratorPoliciesOnOptions(options);
23340 const password = yield this.passwordGenerationService.generatePassword(enforcedOptions[0]);
23341 const res = new StringResponse(password);
23342 return Response.success(res);
23343 });
23344 }
23345}
23346
23347// CONCATENATED MODULE: ./src/models/response/organizationResponse.ts
23348class response_organizationResponse_OrganizationResponse {
23349 constructor(o) {
23350 this.object = 'organization';
23351 this.id = o.id;
23352 this.name = o.name;
23353 this.status = o.status;
23354 this.type = o.type;
23355 this.enabled = o.enabled;
23356 }
23357}
23358
23359// CONCATENATED MODULE: ./src/models/response/templateResponse.ts
23360class TemplateResponse {
23361 constructor(template) {
23362 this.object = 'template';
23363 this.template = template;
23364 }
23365}
23366
23367// CONCATENATED MODULE: ./src/models/selectionReadOnly.ts
23368class SelectionReadOnly {
23369 static template() {
23370 return new SelectionReadOnly('00000000-0000-0000-0000-000000000000', false, false);
23371 }
23372 constructor(id, readOnly, hidePasswords) {
23373 this.id = id;
23374 this.readOnly = readOnly;
23375 this.hidePasswords = hidePasswords || false;
23376 }
23377}
23378
23379// CONCATENATED MODULE: ./src/models/request/organizationCollectionRequest.ts
23380
23381
23382class organizationCollectionRequest_OrganizationCollectionRequest extends export_collection_Collection {
23383 static template() {
23384 const req = new organizationCollectionRequest_OrganizationCollectionRequest();
23385 req.organizationId = '00000000-0000-0000-0000-000000000000';
23386 req.name = 'Collection name';
23387 req.externalId = null;
23388 req.groups = [SelectionReadOnly.template(), SelectionReadOnly.template()];
23389 return req;
23390 }
23391}
23392
23393// CONCATENATED MODULE: ./src/commands/get.command.ts
23394var get_command_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
23395 return new (P || (P = Promise))(function (resolve, reject) {
23396 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
23397 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
23398 function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
23399 step((generator = generator.apply(thisArg, _arguments || [])).next());
23400 });
23401};
23402
23403
23404
23405
23406
23407
23408
23409
23410
23411
23412
23413
23414
23415
23416
23417
23418
23419
23420
23421
23422
23423
23424
23425
23426
23427
23428class get_command_GetCommand {
23429 constructor(cipherService, folderService, collectionService, totpService, auditService, cryptoService, userService, searchService, apiService) {
23430 this.cipherService = cipherService;
23431 this.folderService = folderService;
23432 this.collectionService = collectionService;
23433 this.totpService = totpService;
23434 this.auditService = auditService;
23435 this.cryptoService = cryptoService;
23436 this.userService = userService;
23437 this.searchService = searchService;
23438 this.apiService = apiService;
23439 }
23440 run(object, id, cmd) {
23441 return get_command_awaiter(this, void 0, void 0, function* () {
23442 if (id != null) {
23443 id = id.toLowerCase();
23444 }
23445 switch (object.toLowerCase()) {
23446 case 'item':
23447 return yield this.getCipher(id);
23448 case 'username':
23449 return yield this.getUsername(id);
23450 case 'password':
23451 return yield this.getPassword(id);
23452 case 'uri':
23453 return yield this.getUri(id);
23454 case 'totp':
23455 return yield this.getTotp(id);
23456 case 'exposed':
23457 return yield this.getExposed(id);
23458 case 'attachment':
23459 return yield this.getAttachment(id, cmd);
23460 case 'folder':
23461 return yield this.getFolder(id);
23462 case 'collection':
23463 return yield this.getCollection(id);
23464 case 'org-collection':
23465 return yield this.getOrganizationCollection(id, cmd);
23466 case 'organization':
23467 return yield this.getOrganization(id);
23468 case 'template':
23469 return yield this.getTemplate(id);
23470 case 'fingerprint':
23471 return yield this.getFingerprint(id);
23472 default:
23473 return Response.badRequest('Unknown object.');
23474 }
23475 });
23476 }
23477 getCipherView(id) {
23478 return get_command_awaiter(this, void 0, void 0, function* () {
23479 let decCipher = null;
23480 if (utils_Utils.isGuid(id)) {
23481 const cipher = yield this.cipherService.get(id);
23482 if (cipher != null) {
23483 decCipher = yield cipher.decrypt();
23484 }
23485 }
23486 else if (id.trim() !== '') {
23487 let ciphers = yield this.cipherService.getAllDecrypted();
23488 ciphers = this.searchService.searchCiphersBasic(ciphers, id);
23489 if (ciphers.length > 1) {
23490 return ciphers;
23491 }
23492 if (ciphers.length > 0) {
23493 decCipher = ciphers[0];
23494 }
23495 }
23496 return decCipher;
23497 });
23498 }
23499 getCipher(id, filter) {
23500 return get_command_awaiter(this, void 0, void 0, function* () {
23501 let decCipher = yield this.getCipherView(id);
23502 if (decCipher == null) {
23503 return Response.notFound();
23504 }
23505 if (Array.isArray(decCipher)) {
23506 if (filter != null) {
23507 const filteredCiphers = decCipher.filter(filter);
23508 if (filteredCiphers.length === 1) {
23509 decCipher = filteredCiphers[0];
23510 }
23511 }
23512 if (Array.isArray(decCipher)) {
23513 return Response.multipleResults(decCipher.map((c) => c.id));
23514 }
23515 }
23516 const res = new response_cipherResponse_CipherResponse(decCipher);
23517 return Response.success(res);
23518 });
23519 }
23520 getUsername(id) {
23521 return get_command_awaiter(this, void 0, void 0, function* () {
23522 const cipherResponse = yield this.getCipher(id, (c) => c.type === CipherType.Login && !utils_Utils.isNullOrWhitespace(c.login.username));
23523 if (!cipherResponse.success) {
23524 return cipherResponse;
23525 }
23526 const cipher = cipherResponse.data;
23527 if (cipher.type !== CipherType.Login) {
23528 return Response.badRequest('Not a login.');
23529 }
23530 if (utils_Utils.isNullOrWhitespace(cipher.login.username)) {
23531 return Response.error('No username available for this login.');
23532 }
23533 const res = new StringResponse(cipher.login.username);
23534 return Response.success(res);
23535 });
23536 }
23537 getPassword(id) {
23538 return get_command_awaiter(this, void 0, void 0, function* () {
23539 const cipherResponse = yield this.getCipher(id, (c) => c.type === CipherType.Login && !utils_Utils.isNullOrWhitespace(c.login.password));
23540 if (!cipherResponse.success) {
23541 return cipherResponse;
23542 }
23543 const cipher = cipherResponse.data;
23544 if (cipher.type !== CipherType.Login) {
23545 return Response.badRequest('Not a login.');
23546 }
23547 if (utils_Utils.isNullOrWhitespace(cipher.login.password)) {
23548 return Response.error('No password available for this login.');
23549 }
23550 const res = new StringResponse(cipher.login.password);
23551 return Response.success(res);
23552 });
23553 }
23554 getUri(id) {
23555 return get_command_awaiter(this, void 0, void 0, function* () {
23556 const cipherResponse = yield this.getCipher(id, (c) => c.type === CipherType.Login && c.login.uris != null && c.login.uris.length > 0 &&
23557 c.login.uris[0].uri !== '');
23558 if (!cipherResponse.success) {
23559 return cipherResponse;
23560 }
23561 const cipher = cipherResponse.data;
23562 if (cipher.type !== CipherType.Login) {
23563 return Response.badRequest('Not a login.');
23564 }
23565 if (cipher.login.uris == null || cipher.login.uris.length === 0 || cipher.login.uris[0].uri === '') {
23566 return Response.error('No uri available for this login.');
23567 }
23568 const res = new StringResponse(cipher.login.uris[0].uri);
23569 return Response.success(res);
23570 });
23571 }
23572 getTotp(id) {
23573 return get_command_awaiter(this, void 0, void 0, function* () {
23574 const cipherResponse = yield this.getCipher(id, (c) => c.type === CipherType.Login && !utils_Utils.isNullOrWhitespace(c.login.totp));
23575 if (!cipherResponse.success) {
23576 return cipherResponse;
23577 }
23578 const cipher = cipherResponse.data;
23579 if (cipher.type !== CipherType.Login) {
23580 return Response.badRequest('Not a login.');
23581 }
23582 if (utils_Utils.isNullOrWhitespace(cipher.login.totp)) {
23583 return Response.error('No TOTP available for this login.');
23584 }
23585 const totp = yield this.totpService.getCode(cipher.login.totp);
23586 if (totp == null) {
23587 return Response.error('Couldn\'t generate TOTP code.');
23588 }
23589 const canAccessPremium = yield this.userService.canAccessPremium();
23590 if (!canAccessPremium) {
23591 const originalCipher = yield this.cipherService.get(cipher.id);
23592 if (originalCipher == null || originalCipher.organizationId == null ||
23593 !originalCipher.organizationUseTotp) {
23594 return Response.error('Premium status is required to use this feature.');
23595 }
23596 }
23597 const res = new StringResponse(totp);
23598 return Response.success(res);
23599 });
23600 }
23601 getExposed(id) {
23602 return get_command_awaiter(this, void 0, void 0, function* () {
23603 const passwordResponse = yield this.getPassword(id);
23604 if (!passwordResponse.success) {
23605 return passwordResponse;
23606 }
23607 const exposedNumber = yield this.auditService.passwordLeaked(passwordResponse.data.data);
23608 const res = new StringResponse(exposedNumber.toString());
23609 return Response.success(res);
23610 });
23611 }
23612 getAttachment(id, cmd) {
23613 return get_command_awaiter(this, void 0, void 0, function* () {
23614 if (cmd.itemid == null || cmd.itemid === '') {
23615 return Response.badRequest('--itemid <itemid> required.');
23616 }
23617 const itemId = cmd.itemid.toLowerCase();
23618 const cipherResponse = yield this.getCipher(itemId);
23619 if (!cipherResponse.success) {
23620 return cipherResponse;
23621 }
23622 const cipher = yield this.getCipherView(itemId);
23623 if (cipher == null || Array.isArray(cipher) || cipher.attachments.length === 0) {
23624 return Response.error('No attachments available for this item.');
23625 }
23626 const attachments = cipher.attachments.filter((a) => a.id.toLowerCase() === id ||
23627 (a.fileName != null && a.fileName.toLowerCase().indexOf(id) > -1));
23628 if (attachments.length === 0) {
23629 return Response.error('Attachment `' + id + '` was not found.');
23630 }
23631 if (attachments.length > 1) {
23632 return Response.multipleResults(attachments.map((a) => a.id));
23633 }
23634 if (!(yield this.userService.canAccessPremium())) {
23635 const originalCipher = yield this.cipherService.get(cipher.id);
23636 if (originalCipher == null || originalCipher.organizationId == null) {
23637 return Response.error('Premium status is required to use this feature.');
23638 }
23639 }
23640 const response = yield external_node_fetch_default.a(new external_node_fetch_["Request"](attachments[0].url, { headers: { cache: 'no-cache' } }));
23641 if (response.status !== 200) {
23642 return Response.error('A ' + response.status + ' error occurred while downloading the attachment.');
23643 }
23644 try {
23645 const buf = yield response.arrayBuffer();
23646 const key = attachments[0].key != null ? attachments[0].key :
23647 yield this.cryptoService.getOrgKey(cipher.organizationId);
23648 const decBuf = yield this.cryptoService.decryptFromBytes(buf, key);
23649 const filePath = yield utils_CliUtils.saveFile(Buffer.from(decBuf), cmd.output, attachments[0].fileName);
23650 const res = new MessageResponse('Saved ' + filePath, null);
23651 res.raw = filePath;
23652 return Response.success(res);
23653 }
23654 catch (e) {
23655 if (typeof (e) === 'string') {
23656 return Response.error(e);
23657 }
23658 else {
23659 return Response.error('An error occurred while saving the attachment.');
23660 }
23661 }
23662 });
23663 }
23664 getFolder(id) {
23665 return get_command_awaiter(this, void 0, void 0, function* () {
23666 let decFolder = null;
23667 if (utils_Utils.isGuid(id)) {
23668 const folder = yield this.folderService.get(id);
23669 if (folder != null) {
23670 decFolder = yield folder.decrypt();
23671 }
23672 }
23673 else if (id.trim() !== '') {
23674 let folders = yield this.folderService.getAllDecrypted();
23675 folders = utils_CliUtils.searchFolders(folders, id);
23676 if (folders.length > 1) {
23677 return Response.multipleResults(folders.map((f) => f.id));
23678 }
23679 if (folders.length > 0) {
23680 decFolder = folders[0];
23681 }
23682 }
23683 if (decFolder == null) {
23684 return Response.notFound();
23685 }
23686 const res = new response_folderResponse_FolderResponse(decFolder);
23687 return Response.success(res);
23688 });
23689 }
23690 getCollection(id) {
23691 return get_command_awaiter(this, void 0, void 0, function* () {
23692 let decCollection = null;
23693 if (utils_Utils.isGuid(id)) {
23694 const collection = yield this.collectionService.get(id);
23695 if (collection != null) {
23696 decCollection = yield collection.decrypt();
23697 }
23698 }
23699 else if (id.trim() !== '') {
23700 let collections = yield this.collectionService.getAllDecrypted();
23701 collections = utils_CliUtils.searchCollections(collections, id);
23702 if (collections.length > 1) {
23703 return Response.multipleResults(collections.map((c) => c.id));
23704 }
23705 if (collections.length > 0) {
23706 decCollection = collections[0];
23707 }
23708 }
23709 if (decCollection == null) {
23710 return Response.notFound();
23711 }
23712 const res = new response_collectionResponse_CollectionResponse(decCollection);
23713 return Response.success(res);
23714 });
23715 }
23716 getOrganizationCollection(id, cmd) {
23717 return get_command_awaiter(this, void 0, void 0, function* () {
23718 if (cmd.organizationid == null || cmd.organizationid === '') {
23719 return Response.badRequest('--organizationid <organizationid> required.');
23720 }
23721 if (!utils_Utils.isGuid(id)) {
23722 return Response.error('`' + id + '` is not a GUID.');
23723 }
23724 if (!utils_Utils.isGuid(cmd.organizationid)) {
23725 return Response.error('`' + cmd.organizationid + '` is not a GUID.');
23726 }
23727 try {
23728 const orgKey = yield this.cryptoService.getOrgKey(cmd.organizationid);
23729 if (orgKey == null) {
23730 throw new Error('No encryption key for this organization.');
23731 }
23732 const response = yield this.apiService.getCollectionDetails(cmd.organizationid, id);
23733 const decCollection = new collectionView_CollectionView(response);
23734 decCollection.name = yield this.cryptoService.decryptToUtf8(new cipherString_CipherString(response.name), orgKey);
23735 const groups = response.groups == null ? null :
23736 response.groups.map((g) => new SelectionReadOnly(g.id, g.readOnly, g.hidePasswords));
23737 const res = new organizationCollectionResponse_OrganizationCollectionResponse(decCollection, groups);
23738 return Response.success(res);
23739 }
23740 catch (e) {
23741 return Response.error(e);
23742 }
23743 });
23744 }
23745 getOrganization(id) {
23746 return get_command_awaiter(this, void 0, void 0, function* () {
23747 let org = null;
23748 if (utils_Utils.isGuid(id)) {
23749 org = yield this.userService.getOrganization(id);
23750 }
23751 else if (id.trim() !== '') {
23752 let orgs = yield this.userService.getAllOrganizations();
23753 orgs = utils_CliUtils.searchOrganizations(orgs, id);
23754 if (orgs.length > 1) {
23755 return Response.multipleResults(orgs.map((c) => c.id));
23756 }
23757 if (orgs.length > 0) {
23758 org = orgs[0];
23759 }
23760 }
23761 if (org == null) {
23762 return Response.notFound();
23763 }
23764 const res = new response_organizationResponse_OrganizationResponse(org);
23765 return Response.success(res);
23766 });
23767 }
23768 getTemplate(id) {
23769 return get_command_awaiter(this, void 0, void 0, function* () {
23770 let template = null;
23771 switch (id.toLowerCase()) {
23772 case 'item':
23773 template = export_cipher_Cipher.template();
23774 break;
23775 case 'item.field':
23776 template = export_field_Field.template();
23777 break;
23778 case 'item.login':
23779 template = export_login_Login.template();
23780 break;
23781 case 'item.login.uri':
23782 template = export_loginUri_LoginUri.template();
23783 break;
23784 case 'item.card':
23785 template = export_card_Card.template();
23786 break;
23787 case 'item.identity':
23788 template = export_identity_Identity.template();
23789 break;
23790 case 'item.securenote':
23791 template = export_secureNote_SecureNote.template();
23792 break;
23793 case 'folder':
23794 template = export_folder_Folder.template();
23795 break;
23796 case 'collection':
23797 template = export_collection_Collection.template();
23798 break;
23799 case 'item-collections':
23800 template = ['collection-id1', 'collection-id2'];
23801 break;
23802 case 'org-collection':
23803 template = organizationCollectionRequest_OrganizationCollectionRequest.template();
23804 break;
23805 default:
23806 return Response.badRequest('Unknown template object.');
23807 }
23808 const res = new TemplateResponse(template);
23809 return Response.success(res);
23810 });
23811 }
23812 getFingerprint(id) {
23813 return get_command_awaiter(this, void 0, void 0, function* () {
23814 let fingerprint = null;
23815 if (id === 'me') {
23816 fingerprint = yield this.cryptoService.getFingerprint(yield this.userService.getUserId());
23817 }
23818 else if (utils_Utils.isGuid(id)) {
23819 try {
23820 const response = yield this.apiService.getUserPublicKey(id);
23821 const pubKey = utils_Utils.fromB64ToArray(response.publicKey);
23822 fingerprint = yield this.cryptoService.getFingerprint(id, pubKey.buffer);
23823 }
23824 catch (_a) { }
23825 }
23826 if (fingerprint == null) {
23827 return Response.notFound();
23828 }
23829 const res = new StringResponse(fingerprint.join('-'));
23830 return Response.success(res);
23831 });
23832 }
23833}
23834
23835// CONCATENATED MODULE: ./src/commands/import.command.ts
23836var import_command_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
23837 return new (P || (P = Promise))(function (resolve, reject) {
23838 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
23839 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
23840 function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
23841 step((generator = generator.apply(thisArg, _arguments || [])).next());
23842 });
23843};
23844
23845
23846
23847class import_command_ImportCommand {
23848 constructor(importService) {
23849 this.importService = importService;
23850 }
23851 run(format, filepath, cmd) {
23852 return import_command_awaiter(this, void 0, void 0, function* () {
23853 if (cmd.formats || false) {
23854 return this.list();
23855 }
23856 else {
23857 return this.import(format, filepath);
23858 }
23859 });
23860 }
23861 import(format, filepath) {
23862 return import_command_awaiter(this, void 0, void 0, function* () {
23863 if (format == null || format === '') {
23864 return Response.badRequest('`format` was not provided.');
23865 }
23866 if (filepath == null || filepath === '') {
23867 return Response.badRequest('`filepath` was not provided.');
23868 }
23869 const importer = yield this.importService.getImporter(format, false);
23870 if (importer === null) {
23871 return Response.badRequest('Proper importer type required.');
23872 }
23873 try {
23874 const contents = yield utils_CliUtils.readFile(filepath);
23875 if (contents === null || contents === '') {
23876 return Response.badRequest('Import file was empty.');
23877 }
23878 const err = yield this.importService.import(importer, contents, null);
23879 if (err != null) {
23880 return Response.badRequest(err.message);
23881 }
23882 const res = new MessageResponse('Imported ' + filepath, null);
23883 return Response.success(res);
23884 }
23885 catch (err) {
23886 return Response.badRequest(err);
23887 }
23888 });
23889 }
23890 list() {
23891 return import_command_awaiter(this, void 0, void 0, function* () {
23892 const options = this.importService.getImportOptions().sort((a, b) => {
23893 return a.id < b.id ? -1 : a.id > b.id ? 1 : 0;
23894 }).map((option) => option.id).join('\n');
23895 const res = new MessageResponse('Supported input formats:', options);
23896 res.raw = options;
23897 return Response.success(res);
23898 });
23899 }
23900}
23901
23902// CONCATENATED MODULE: ./jslib/src/cli/models/response/listResponse.ts
23903class response_listResponse_ListResponse {
23904 constructor(data) {
23905 this.object = 'list';
23906 this.data = data;
23907 }
23908}
23909
23910// CONCATENATED MODULE: ./src/models/response/organizationUserResponse.ts
23911class response_organizationUserResponse_OrganizationUserResponse {
23912 constructor() {
23913 this.object = 'org-member';
23914 }
23915}
23916
23917// CONCATENATED MODULE: ./src/commands/list.command.ts
23918var list_command_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
23919 return new (P || (P = Promise))(function (resolve, reject) {
23920 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
23921 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
23922 function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
23923 step((generator = generator.apply(thisArg, _arguments || [])).next());
23924 });
23925};
23926
23927
23928
23929
23930
23931
23932
23933
23934
23935
23936
23937class list_command_ListCommand {
23938 constructor(cipherService, folderService, collectionService, userService, searchService, apiService) {
23939 this.cipherService = cipherService;
23940 this.folderService = folderService;
23941 this.collectionService = collectionService;
23942 this.userService = userService;
23943 this.searchService = searchService;
23944 this.apiService = apiService;
23945 }
23946 run(object, cmd) {
23947 return list_command_awaiter(this, void 0, void 0, function* () {
23948 switch (object.toLowerCase()) {
23949 case 'items':
23950 return yield this.listCiphers(cmd);
23951 case 'folders':
23952 return yield this.listFolders(cmd);
23953 case 'collections':
23954 return yield this.listCollections(cmd);
23955 case 'org-collections':
23956 return yield this.listOrganizationCollections(cmd);
23957 case 'org-members':
23958 return yield this.listOrganizationMembers(cmd);
23959 case 'organizations':
23960 return yield this.listOrganizations(cmd);
23961 default:
23962 return Response.badRequest('Unknown object.');
23963 }
23964 });
23965 }
23966 listCiphers(cmd) {
23967 return list_command_awaiter(this, void 0, void 0, function* () {
23968 let ciphers;
23969 cmd.trash = cmd.trash || false;
23970 if (cmd.url != null && cmd.url.trim() !== '') {
23971 ciphers = yield this.cipherService.getAllDecryptedForUrl(cmd.url);
23972 }
23973 else {
23974 ciphers = yield this.cipherService.getAllDecrypted();
23975 }
23976 if (cmd.folderid != null || cmd.collectionid != null || cmd.organizationid != null) {
23977 ciphers = ciphers.filter((c) => {
23978 if (cmd.trash !== c.isDeleted) {
23979 return false;
23980 }
23981 if (cmd.folderid != null) {
23982 if (cmd.folderid === 'notnull' && c.folderId != null) {
23983 return true;
23984 }
23985 const folderId = cmd.folderid === 'null' ? null : cmd.folderid;
23986 if (folderId === c.folderId) {
23987 return true;
23988 }
23989 }
23990 if (cmd.organizationid != null) {
23991 if (cmd.organizationid === 'notnull' && c.organizationId != null) {
23992 return true;
23993 }
23994 const organizationId = cmd.organizationid === 'null' ? null : cmd.organizationid;
23995 if (organizationId === c.organizationId) {
23996 return true;
23997 }
23998 }
23999 if (cmd.collectionid != null) {
24000 if (cmd.collectionid === 'notnull' && c.collectionIds != null && c.collectionIds.length > 0) {
24001 return true;
24002 }
24003 const collectionId = cmd.collectionid === 'null' ? null : cmd.collectionid;
24004 if (collectionId == null && (c.collectionIds == null || c.collectionIds.length === 0)) {
24005 return true;
24006 }
24007 if (collectionId != null && c.collectionIds != null && c.collectionIds.indexOf(collectionId) > -1) {
24008 return true;
24009 }
24010 }
24011 return false;
24012 });
24013 }
24014 else if (cmd.search == null || cmd.search.trim() === '') {
24015 ciphers = ciphers.filter((c) => cmd.trash === c.isDeleted);
24016 }
24017 if (cmd.search != null && cmd.search.trim() !== '') {
24018 ciphers = this.searchService.searchCiphersBasic(ciphers, cmd.search, cmd.trash);
24019 }
24020 const res = new response_listResponse_ListResponse(ciphers.map((o) => new response_cipherResponse_CipherResponse(o)));
24021 return Response.success(res);
24022 });
24023 }
24024 listFolders(cmd) {
24025 return list_command_awaiter(this, void 0, void 0, function* () {
24026 let folders = yield this.folderService.getAllDecrypted();
24027 if (cmd.search != null && cmd.search.trim() !== '') {
24028 folders = utils_CliUtils.searchFolders(folders, cmd.search);
24029 }
24030 const res = new response_listResponse_ListResponse(folders.map((o) => new response_folderResponse_FolderResponse(o)));
24031 return Response.success(res);
24032 });
24033 }
24034 listCollections(cmd) {
24035 return list_command_awaiter(this, void 0, void 0, function* () {
24036 let collections = yield this.collectionService.getAllDecrypted();
24037 if (cmd.organizationid != null) {
24038 collections = collections.filter((c) => {
24039 if (cmd.organizationid === c.organizationId) {
24040 return true;
24041 }
24042 return false;
24043 });
24044 }
24045 if (cmd.search != null && cmd.search.trim() !== '') {
24046 collections = utils_CliUtils.searchCollections(collections, cmd.search);
24047 }
24048 const res = new response_listResponse_ListResponse(collections.map((o) => new response_collectionResponse_CollectionResponse(o)));
24049 return Response.success(res);
24050 });
24051 }
24052 listOrganizationCollections(cmd) {
24053 return list_command_awaiter(this, void 0, void 0, function* () {
24054 if (cmd.organizationid == null || cmd.organizationid === '') {
24055 return Response.badRequest('--organizationid <organizationid> required.');
24056 }
24057 if (!utils_Utils.isGuid(cmd.organizationid)) {
24058 return Response.error('`' + cmd.organizationid + '` is not a GUID.');
24059 }
24060 const organization = yield this.userService.getOrganization(cmd.organizationid);
24061 if (organization == null) {
24062 return Response.error('Organization not found.');
24063 }
24064 try {
24065 let response;
24066 if (organization.isAdmin) {
24067 response = yield this.apiService.getCollections(cmd.organizationid);
24068 }
24069 else {
24070 response = yield this.apiService.getUserCollections();
24071 }
24072 const collections = response.data.filter((c) => c.organizationId === cmd.organizationid).map((r) => new collection_Collection(new CollectionData(r)));
24073 let decCollections = yield this.collectionService.decryptMany(collections);
24074 if (cmd.search != null && cmd.search.trim() !== '') {
24075 decCollections = utils_CliUtils.searchCollections(decCollections, cmd.search);
24076 }
24077 const res = new response_listResponse_ListResponse(decCollections.map((o) => new response_collectionResponse_CollectionResponse(o)));
24078 return Response.success(res);
24079 }
24080 catch (e) {
24081 return Response.error(e);
24082 }
24083 });
24084 }
24085 listOrganizationMembers(cmd) {
24086 return list_command_awaiter(this, void 0, void 0, function* () {
24087 if (cmd.organizationid == null || cmd.organizationid === '') {
24088 return Response.badRequest('--organizationid <organizationid> required.');
24089 }
24090 if (!utils_Utils.isGuid(cmd.organizationid)) {
24091 return Response.error('`' + cmd.organizationid + '` is not a GUID.');
24092 }
24093 const organization = yield this.userService.getOrganization(cmd.organizationid);
24094 if (organization == null) {
24095 return Response.error('Organization not found.');
24096 }
24097 try {
24098 const response = yield this.apiService.getOrganizationUsers(cmd.organizationid);
24099 const res = new response_listResponse_ListResponse(response.data.map((r) => {
24100 const u = new response_organizationUserResponse_OrganizationUserResponse();
24101 u.email = r.email;
24102 u.name = r.name;
24103 u.id = r.id;
24104 u.status = r.status;
24105 u.type = r.type;
24106 u.twoFactorEnabled = r.twoFactorEnabled;
24107 return u;
24108 }));
24109 return Response.success(res);
24110 }
24111 catch (e) {
24112 return Response.error(e);
24113 }
24114 });
24115 }
24116 listOrganizations(cmd) {
24117 return list_command_awaiter(this, void 0, void 0, function* () {
24118 let organizations = yield this.userService.getAllOrganizations();
24119 if (cmd.search != null && cmd.search.trim() !== '') {
24120 organizations = utils_CliUtils.searchOrganizations(organizations, cmd.search);
24121 }
24122 const res = new response_listResponse_ListResponse(organizations.map((o) => new response_organizationResponse_OrganizationResponse(o)));
24123 return Response.success(res);
24124 });
24125 }
24126}
24127
24128// CONCATENATED MODULE: ./src/commands/lock.command.ts
24129var lock_command_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
24130 return new (P || (P = Promise))(function (resolve, reject) {
24131 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
24132 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
24133 function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
24134 step((generator = generator.apply(thisArg, _arguments || [])).next());
24135 });
24136};
24137
24138
24139class lock_command_LockCommand {
24140 constructor(vaultTimeoutService) {
24141 this.vaultTimeoutService = vaultTimeoutService;
24142 }
24143 run(cmd) {
24144 return lock_command_awaiter(this, void 0, void 0, function* () {
24145 yield this.vaultTimeoutService.lock();
24146 process.env.BW_SESSION = null;
24147 const res = new MessageResponse('Your vault is locked.', null);
24148 return Response.success(res);
24149 });
24150 }
24151}
24152
24153// CONCATENATED MODULE: ./jslib/src/models/request/passwordVerificationRequest.ts
24154class PasswordVerificationRequest {
24155}
24156
24157// CONCATENATED MODULE: ./jslib/src/models/request/twoFactorEmailRequest.ts
24158
24159class twoFactorEmailRequest_TwoFactorEmailRequest extends PasswordVerificationRequest {
24160 constructor(email, masterPasswordHash) {
24161 super();
24162 this.masterPasswordHash = masterPasswordHash;
24163 this.email = email;
24164 }
24165}
24166
24167// CONCATENATED MODULE: ./jslib/src/cli/commands/login.command.ts
24168var login_command_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
24169 return new (P || (P = Promise))(function (resolve, reject) {
24170 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
24171 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
24172 function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
24173 step((generator = generator.apply(thisArg, _arguments || [])).next());
24174 });
24175};
24176
24177
24178
24179
24180
24181
24182class login_command_LoginCommand {
24183 constructor(authService, apiService, i18nService) {
24184 this.authService = authService;
24185 this.apiService = apiService;
24186 this.i18nService = i18nService;
24187 }
24188 run(email, password, cmd) {
24189 return login_command_awaiter(this, void 0, void 0, function* () {
24190 const canInteract = process.env.BW_NOINTERACTION !== 'true';
24191 if ((email == null || email === '') && canInteract) {
24192 const answer = yield external_inquirer_["createPromptModule"]({ output: process.stderr })({
24193 type: 'input',
24194 name: 'email',
24195 message: 'Email address:',
24196 });
24197 email = answer.email;
24198 }
24199 if (email == null || email.trim() === '') {
24200 return Response.badRequest('Email address is required.');
24201 }
24202 if (email.indexOf('@') === -1) {
24203 return Response.badRequest('Email address is invalid.');
24204 }
24205 if (password == null || password === '') {
24206 if (cmd.passwordfile) {
24207 password = yield nodeUtils_NodeUtils.readFirstLine(cmd.passwordfile);
24208 }
24209 else if (cmd.passwordenv && process.env[cmd.passwordenv]) {
24210 password = process.env[cmd.passwordenv];
24211 }
24212 else if (canInteract) {
24213 const answer = yield external_inquirer_["createPromptModule"]({ output: process.stderr })({
24214 type: 'password',
24215 name: 'password',
24216 message: 'Master password:',
24217 });
24218 password = answer.password;
24219 }
24220 }
24221 if (password == null || password === '') {
24222 return Response.badRequest('Master password is required.');
24223 }
24224 let twoFactorToken = cmd.code;
24225 let twoFactorMethod = null;
24226 try {
24227 if (cmd.method != null) {
24228 twoFactorMethod = parseInt(cmd.method, null);
24229 }
24230 }
24231 catch (e) {
24232 return Response.error('Invalid two-step login method.');
24233 }
24234 try {
24235 if (this.validatedParams != null) {
24236 yield this.validatedParams();
24237 }
24238 let response = null;
24239 if (twoFactorToken != null && twoFactorMethod != null) {
24240 response = yield this.authService.logInComplete(email, password, twoFactorMethod, twoFactorToken, false);
24241 }
24242 else {
24243 response = yield this.authService.logIn(email, password);
24244 if (response.twoFactor) {
24245 let selectedProvider = null;
24246 const twoFactorProviders = this.authService.getSupportedTwoFactorProviders(null);
24247 if (twoFactorProviders.length === 0) {
24248 return Response.badRequest('No providers available for this client.');
24249 }
24250 if (twoFactorMethod != null) {
24251 try {
24252 selectedProvider = twoFactorProviders.filter((p) => p.type === twoFactorMethod)[0];
24253 }
24254 catch (e) {
24255 return Response.error('Invalid two-step login method.');
24256 }
24257 }
24258 if (selectedProvider == null) {
24259 if (twoFactorProviders.length === 1) {
24260 selectedProvider = twoFactorProviders[0];
24261 }
24262 else if (canInteract) {
24263 const options = twoFactorProviders.map((p) => p.name);
24264 options.push(new external_inquirer_["Separator"]());
24265 options.push('Cancel');
24266 const answer = yield external_inquirer_["createPromptModule"]({ output: process.stderr })({
24267 type: 'list',
24268 name: 'method',
24269 message: 'Two-step login method:',
24270 choices: options,
24271 });
24272 const i = options.indexOf(answer.method);
24273 if (i === (options.length - 1)) {
24274 return Response.error('Login failed.');
24275 }
24276 selectedProvider = twoFactorProviders[i];
24277 }
24278 if (selectedProvider == null) {
24279 return Response.error('Login failed. No provider selected.');
24280 }
24281 }
24282 if (twoFactorToken == null && response.twoFactorProviders.size > 1 &&
24283 selectedProvider.type === TwoFactorProviderType.Email) {
24284 const emailReq = new twoFactorEmailRequest_TwoFactorEmailRequest(this.authService.email, this.authService.masterPasswordHash);
24285 yield this.apiService.postTwoFactorEmail(emailReq);
24286 }
24287 if (twoFactorToken == null) {
24288 if (canInteract) {
24289 const answer = yield external_inquirer_["createPromptModule"]({ output: process.stderr })({
24290 type: 'input',
24291 name: 'token',
24292 message: 'Two-step login code:',
24293 });
24294 twoFactorToken = answer.token;
24295 }
24296 if (twoFactorToken == null || twoFactorToken === '') {
24297 return Response.badRequest('Code is required.');
24298 }
24299 }
24300 response = yield this.authService.logInTwoFactor(selectedProvider.type, twoFactorToken, false);
24301 }
24302 }
24303 if (response.twoFactor) {
24304 return Response.error('Login failed.');
24305 }
24306 if (this.success != null) {
24307 const res = yield this.success();
24308 return Response.success(res);
24309 }
24310 else {
24311 const res = new MessageResponse('You are logged in!', null);
24312 return Response.success(res);
24313 }
24314 }
24315 catch (e) {
24316 return Response.error(e);
24317 }
24318 });
24319 }
24320}
24321
24322// CONCATENATED MODULE: ./src/commands/login.command.ts
24323var commands_login_command_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
24324 return new (P || (P = Promise))(function (resolve, reject) {
24325 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
24326 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
24327 function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
24328 step((generator = generator.apply(thisArg, _arguments || [])).next());
24329 });
24330};
24331
24332
24333
24334class commands_login_command_LoginCommand extends login_command_LoginCommand {
24335 constructor(authService, apiService, cryptoFunctionService, syncService, i18nService) {
24336 super(authService, apiService, i18nService);
24337 this.validatedParams = () => commands_login_command_awaiter(this, void 0, void 0, function* () {
24338 const key = yield cryptoFunctionService.randomBytes(64);
24339 process.env.BW_SESSION = utils_Utils.fromBufferToB64(key);
24340 });
24341 this.success = () => commands_login_command_awaiter(this, void 0, void 0, function* () {
24342 yield syncService.fullSync(true);
24343 const res = new MessageResponse('You are logged in!', '\n' +
24344 'To unlock your vault, set your session key to the `BW_SESSION` environment variable. ex:\n' +
24345 '$ export BW_SESSION="' + process.env.BW_SESSION + '"\n' +
24346 '> $env:BW_SESSION="' + process.env.BW_SESSION + '"\n\n' +
24347 'You can also pass the session key to any command with the `--session` option. ex:\n' +
24348 '$ bw list items --session ' + process.env.BW_SESSION);
24349 res.raw = process.env.BW_SESSION;
24350 return res;
24351 });
24352 }
24353}
24354
24355// CONCATENATED MODULE: ./src/commands/restore.command.ts
24356var restore_command_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
24357 return new (P || (P = Promise))(function (resolve, reject) {
24358 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
24359 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
24360 function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
24361 step((generator = generator.apply(thisArg, _arguments || [])).next());
24362 });
24363};
24364
24365class restore_command_RestoreCommand {
24366 constructor(cipherService) {
24367 this.cipherService = cipherService;
24368 }
24369 run(object, id, cmd) {
24370 return restore_command_awaiter(this, void 0, void 0, function* () {
24371 if (id != null) {
24372 id = id.toLowerCase();
24373 }
24374 switch (object.toLowerCase()) {
24375 case 'item':
24376 return yield this.restoreCipher(id, cmd);
24377 default:
24378 return Response.badRequest('Unknown object.');
24379 }
24380 });
24381 }
24382 restoreCipher(id, cmd) {
24383 return restore_command_awaiter(this, void 0, void 0, function* () {
24384 const cipher = yield this.cipherService.get(id);
24385 if (cipher == null) {
24386 return Response.notFound();
24387 }
24388 if (cipher.deletedDate == null) {
24389 return Response.badRequest('Cipher is not in trash.');
24390 }
24391 try {
24392 yield this.cipherService.restoreWithServer(id);
24393 return Response.success();
24394 }
24395 catch (e) {
24396 return Response.error(e);
24397 }
24398 });
24399 }
24400}
24401
24402// CONCATENATED MODULE: ./src/commands/share.command.ts
24403var share_command_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
24404 return new (P || (P = Promise))(function (resolve, reject) {
24405 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
24406 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
24407 function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
24408 step((generator = generator.apply(thisArg, _arguments || [])).next());
24409 });
24410};
24411
24412
24413
24414class share_command_ShareCommand {
24415 constructor(cipherService) {
24416 this.cipherService = cipherService;
24417 }
24418 run(id, organizationId, requestJson, cmd) {
24419 return share_command_awaiter(this, void 0, void 0, function* () {
24420 if (requestJson == null || requestJson === '') {
24421 requestJson = yield utils_CliUtils.readStdin();
24422 }
24423 if (requestJson == null || requestJson === '') {
24424 return Response.badRequest('`requestJson` was not provided.');
24425 }
24426 let req = [];
24427 try {
24428 const reqJson = Buffer.from(requestJson, 'base64').toString();
24429 req = JSON.parse(reqJson);
24430 if (req == null || req.length === 0) {
24431 return Response.badRequest('You must provide at least one collection id for this item.');
24432 }
24433 }
24434 catch (e) {
24435 return Response.badRequest('Error parsing the encoded request data.');
24436 }
24437 if (id != null) {
24438 id = id.toLowerCase();
24439 }
24440 if (organizationId != null) {
24441 organizationId = organizationId.toLowerCase();
24442 }
24443 const cipher = yield this.cipherService.get(id);
24444 if (cipher == null) {
24445 return Response.notFound();
24446 }
24447 if (cipher.organizationId != null) {
24448 return Response.badRequest('This item already belongs to an organization.');
24449 }
24450 const cipherView = yield cipher.decrypt();
24451 try {
24452 yield this.cipherService.shareWithServer(cipherView, organizationId, req);
24453 const updatedCipher = yield this.cipherService.get(cipher.id);
24454 const decCipher = yield updatedCipher.decrypt();
24455 const res = new response_cipherResponse_CipherResponse(decCipher);
24456 return Response.success(res);
24457 }
24458 catch (e) {
24459 return Response.error(e);
24460 }
24461 });
24462 }
24463}
24464
24465// CONCATENATED MODULE: ./src/commands/status.command.ts
24466var status_command_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
24467 return new (P || (P = Promise))(function (resolve, reject) {
24468 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
24469 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
24470 function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
24471 step((generator = generator.apply(thisArg, _arguments || [])).next());
24472 });
24473};
24474
24475
24476class status_command_StatusCommand {
24477 constructor(envService, syncService, userService, vaultTimeoutService) {
24478 this.envService = envService;
24479 this.syncService = syncService;
24480 this.userService = userService;
24481 this.vaultTimeoutService = vaultTimeoutService;
24482 }
24483 run(cmd) {
24484 return status_command_awaiter(this, void 0, void 0, function* () {
24485 try {
24486 const baseUrl = this.baseUrl();
24487 const status = yield this.status();
24488 const lastSync = yield this.syncService.getLastSync();
24489 const userId = yield this.userService.getUserId();
24490 const email = yield this.userService.getEmail();
24491 return Response.success(new TemplateResponse({
24492 serverUrl: baseUrl,
24493 lastSync: lastSync,
24494 userEmail: email,
24495 userId: userId,
24496 status: status,
24497 }));
24498 }
24499 catch (e) {
24500 return Response.error(e);
24501 }
24502 });
24503 }
24504 baseUrl() {
24505 let url = this.envService.baseUrl;
24506 if (url == null) {
24507 url = 'https://bitwarden.com';
24508 }
24509 return url;
24510 }
24511 status() {
24512 return status_command_awaiter(this, void 0, void 0, function* () {
24513 const authed = yield this.userService.isAuthenticated();
24514 if (!authed) {
24515 return 'unauthenticated';
24516 }
24517 const isLocked = yield this.vaultTimeoutService.isLocked();
24518 return isLocked ? 'locked' : 'unlocked';
24519 });
24520 }
24521}
24522
24523// CONCATENATED MODULE: ./src/commands/sync.command.ts
24524var sync_command_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
24525 return new (P || (P = Promise))(function (resolve, reject) {
24526 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
24527 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
24528 function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
24529 step((generator = generator.apply(thisArg, _arguments || [])).next());
24530 });
24531};
24532
24533
24534
24535class sync_command_SyncCommand {
24536 constructor(syncService) {
24537 this.syncService = syncService;
24538 }
24539 run(cmd) {
24540 return sync_command_awaiter(this, void 0, void 0, function* () {
24541 if (cmd.last || false) {
24542 return yield this.getLastSync();
24543 }
24544 try {
24545 const result = yield this.syncService.fullSync(cmd.force || false);
24546 const res = new MessageResponse('Syncing complete.', null);
24547 return Response.success(res);
24548 }
24549 catch (e) {
24550 return Response.error(e);
24551 }
24552 });
24553 }
24554 getLastSync() {
24555 return sync_command_awaiter(this, void 0, void 0, function* () {
24556 const lastSyncDate = yield this.syncService.getLastSync();
24557 const res = new StringResponse(lastSyncDate == null ? null : lastSyncDate.toISOString());
24558 return Response.success(res);
24559 });
24560 }
24561}
24562
24563// CONCATENATED MODULE: ./src/commands/unlock.command.ts
24564var unlock_command_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
24565 return new (P || (P = Promise))(function (resolve, reject) {
24566 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
24567 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
24568 function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
24569 step((generator = generator.apply(thisArg, _arguments || [])).next());
24570 });
24571};
24572
24573
24574
24575
24576class unlock_command_UnlockCommand {
24577 constructor(cryptoService, userService, cryptoFunctionService) {
24578 this.cryptoService = cryptoService;
24579 this.userService = userService;
24580 this.cryptoFunctionService = cryptoFunctionService;
24581 }
24582 run(password, cmd) {
24583 return unlock_command_awaiter(this, void 0, void 0, function* () {
24584 const canInteract = process.env.BW_NOINTERACTION !== 'true';
24585 if ((password == null || password === '') && canInteract) {
24586 const answer = yield external_inquirer_["createPromptModule"]({ output: process.stderr })({
24587 type: 'password',
24588 name: 'password',
24589 message: 'Master password:',
24590 });
24591 password = answer.password;
24592 }
24593 if (password == null || password === '') {
24594 return Response.badRequest('Master password is required.');
24595 }
24596 this.setNewSessionKey();
24597 const email = yield this.userService.getEmail();
24598 const kdf = yield this.userService.getKdf();
24599 const kdfIterations = yield this.userService.getKdfIterations();
24600 const key = yield this.cryptoService.makeKey(password, email, kdf, kdfIterations);
24601 const keyHash = yield this.cryptoService.hashPassword(password, key);
24602 const storedKeyHash = yield this.cryptoService.getKeyHash();
24603 if (storedKeyHash != null && keyHash != null && storedKeyHash === keyHash) {
24604 yield this.cryptoService.setKey(key);
24605 const res = new MessageResponse('Your vault is now unlocked!', '\n' +
24606 'To unlock your vault, set your session key to the `BW_SESSION` environment variable. ex:\n' +
24607 '$ export BW_SESSION="' + process.env.BW_SESSION + '"\n' +
24608 '> $env:BW_SESSION="' + process.env.BW_SESSION + '"\n\n' +
24609 'You can also pass the session key to any command with the `--session` option. ex:\n' +
24610 '$ bw list items --session ' + process.env.BW_SESSION);
24611 res.raw = process.env.BW_SESSION;
24612 return Response.success(res);
24613 }
24614 else {
24615 return Response.error('Invalid master password.');
24616 }
24617 });
24618 }
24619 setNewSessionKey() {
24620 return unlock_command_awaiter(this, void 0, void 0, function* () {
24621 const key = yield this.cryptoFunctionService.randomBytes(64);
24622 process.env.BW_SESSION = utils_Utils.fromBufferToB64(key);
24623 });
24624 }
24625}
24626
24627// CONCATENATED MODULE: ./src/commands/completion.command.ts
24628var completion_command_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
24629 return new (P || (P = Promise))(function (resolve, reject) {
24630 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
24631 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
24632 function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
24633 step((generator = generator.apply(thisArg, _arguments || [])).next());
24634 });
24635};
24636
24637
24638const validShells = ['zsh'];
24639class completion_command_CompletionCommand {
24640 run(cmd) {
24641 return completion_command_awaiter(this, void 0, void 0, function* () {
24642 const shell = cmd.shell;
24643 if (!shell) {
24644 return Response.badRequest('`shell` was not provided.');
24645 }
24646 if (!validShells.includes(shell)) {
24647 return Response.badRequest('Unsupported shell.');
24648 }
24649 let content = '';
24650 if (shell === 'zsh') {
24651 content = this.zshCompletion('bw', cmd.parent).render();
24652 }
24653 const res = new MessageResponse(content, null);
24654 return Response.success(res);
24655 });
24656 }
24657 zshCompletion(rootName, rootCommand) {
24658 return {
24659 render: () => {
24660 return [
24661 `#compdef _${rootName} ${rootName}`,
24662 '',
24663 this.renderCommandBlock(rootName, rootCommand),
24664 ].join('\n');
24665 },
24666 };
24667 }
24668 renderCommandBlock(name, command) {
24669 const { commands = [], options = [] } = command;
24670 const hasOptions = options.length > 0;
24671 const hasCommands = commands.length > 0;
24672 const args = options
24673 .map(({ long, short, description }) => {
24674 const aliases = [short, long].filter(Boolean);
24675 const opts = aliases.join(',');
24676 const desc = `[${description.replace(`'`, `'"'"'`)}]`;
24677 return aliases.length > 1 ? `'(${aliases.join(' ')})'{${opts}}'${desc}'` : `'${opts}${desc}'`;
24678 }).concat(`'(-h --help)'{-h,--help}'[output usage information]'`, hasCommands ? '"1: :->cmnds"' : null, '"*::arg:->args"').filter(Boolean);
24679 const commandBlockFunctionParts = [];
24680 if (hasCommands) {
24681 commandBlockFunctionParts.push('local -a commands');
24682 }
24683 if (hasOptions) {
24684 commandBlockFunctionParts.push(`_arguments -C \\\n ${args.join(` \\\n `)}`);
24685 }
24686 if (hasCommands) {
24687 commandBlockFunctionParts.push(`case $state in
24688 cmnds)
24689 commands=(
24690 ${commands.map(({ _name, _description }) => `"${_name}:${_description}"`).join('\n ')}
24691 )
24692 _describe "command" commands
24693 ;;
24694 esac
24695
24696 case "$words[1]" in
24697 ${commands.map(({ _name }) => [`${_name})`, `_${name}_${_name}`, ';;'].join('\n ')).join('\n ')}
24698 esac`);
24699 }
24700 const commandBlocParts = [
24701 `function _${name} {\n ${commandBlockFunctionParts.join('\n\n ')}\n}`,
24702 ];
24703 if (hasCommands) {
24704 commandBlocParts.push(commands.map((c) => this.renderCommandBlock(`${name}_${c._name}`, c)).join('\n\n'));
24705 }
24706 return commandBlocParts.join('\n\n');
24707 }
24708}
24709
24710// CONCATENATED MODULE: ./jslib/src/cli/commands/logout.command.ts
24711var logout_command_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
24712 return new (P || (P = Promise))(function (resolve, reject) {
24713 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
24714 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
24715 function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
24716 step((generator = generator.apply(thisArg, _arguments || [])).next());
24717 });
24718};
24719
24720
24721class logout_command_LogoutCommand {
24722 constructor(authService, i18nService, logoutCallback) {
24723 this.authService = authService;
24724 this.i18nService = i18nService;
24725 this.logoutCallback = logoutCallback;
24726 }
24727 run(cmd) {
24728 return logout_command_awaiter(this, void 0, void 0, function* () {
24729 yield this.logoutCallback();
24730 this.authService.logOut(() => { });
24731 const res = new MessageResponse('You have logged out.', null);
24732 return Response.success(res);
24733 });
24734 }
24735}
24736
24737// CONCATENATED MODULE: ./jslib/src/cli/commands/update.command.ts
24738var update_command_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
24739 return new (P || (P = Promise))(function (resolve, reject) {
24740 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
24741 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
24742 function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
24743 step((generator = generator.apply(thisArg, _arguments || [])).next());
24744 });
24745};
24746
24747
24748
24749class update_command_UpdateCommand {
24750 constructor(platformUtilsService, i18nService, repoName, executableName, showExtendedMessage) {
24751 this.platformUtilsService = platformUtilsService;
24752 this.i18nService = i18nService;
24753 this.repoName = repoName;
24754 this.executableName = executableName;
24755 this.showExtendedMessage = showExtendedMessage;
24756 this.inPkg = false;
24757 this.inPkg = !!process.pkg;
24758 }
24759 run(cmd) {
24760 return update_command_awaiter(this, void 0, void 0, function* () {
24761 const currentVersion = this.platformUtilsService.getApplicationVersion();
24762 const response = yield external_node_fetch_default.a('https://api.github.com/repos/bitwarden/' +
24763 this.repoName + '/releases/latest');
24764 if (response.status === 200) {
24765 const responseJson = yield response.json();
24766 const res = new MessageResponse(null, null);
24767 const tagName = responseJson.tag_name;
24768 if (tagName === ('v' + currentVersion)) {
24769 res.title = 'No update available.';
24770 res.noColor = true;
24771 return Response.success(res);
24772 }
24773 let downloadUrl = null;
24774 if (responseJson.assets != null) {
24775 for (const a of responseJson.assets) {
24776 const download = a.browser_download_url;
24777 if (download == null) {
24778 continue;
24779 }
24780 if (download.indexOf('.zip') === -1) {
24781 continue;
24782 }
24783 if (process.platform === 'win32' && download.indexOf(this.executableName + '-windows') > -1) {
24784 downloadUrl = download;
24785 break;
24786 }
24787 else if (process.platform === 'darwin' && download.indexOf(this.executableName + '-macos') > -1) {
24788 downloadUrl = download;
24789 break;
24790 }
24791 else if (process.platform === 'linux' && download.indexOf(this.executableName + '-linux') > -1) {
24792 downloadUrl = download;
24793 break;
24794 }
24795 }
24796 }
24797 res.title = 'A new version is available: ' + tagName;
24798 if (downloadUrl == null) {
24799 downloadUrl = 'https://github.com/bitwarden/' + this.repoName + '/releases';
24800 }
24801 else {
24802 res.raw = downloadUrl;
24803 }
24804 res.message = '';
24805 if (responseJson.body != null && responseJson.body !== '') {
24806 res.message = responseJson.body + '\n\n';
24807 }
24808 res.message += 'You can download this update at ' + downloadUrl;
24809 if (this.showExtendedMessage) {
24810 if (this.inPkg) {
24811 res.message += '\n\nIf you installed this CLI through a package manager ' +
24812 'you should probably update using its update command instead.';
24813 }
24814 else {
24815 res.message += '\n\nIf you installed this CLI through NPM ' +
24816 'you should update using `npm install -g @bitwarden/' + this.repoName + '`';
24817 }
24818 }
24819 return Response.success(res);
24820 }
24821 else {
24822 return Response.error('Error contacting update API: ' + response.status);
24823 }
24824 });
24825 }
24826}
24827
24828// CONCATENATED MODULE: ./jslib/src/cli/baseProgram.ts
24829var baseProgram_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
24830 return new (P || (P = Promise))(function (resolve, reject) {
24831 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
24832 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
24833 function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
24834 step((generator = generator.apply(thisArg, _arguments || [])).next());
24835 });
24836};
24837
24838
24839const chalk = external_chalk_default.a;
24840class baseProgram_BaseProgram {
24841 constructor(userService, writeLn) {
24842 this.userService = userService;
24843 this.writeLn = writeLn;
24844 }
24845 processResponse(response, exitImmediately = false, dataProcessor = null) {
24846 if (!response.success) {
24847 if (process.env.BW_QUIET !== 'true') {
24848 if (process.env.BW_RESPONSE === 'true') {
24849 this.writeLn(this.getJson(response), true, true);
24850 }
24851 else {
24852 this.writeLn(chalk.redBright(response.message), true, true);
24853 }
24854 }
24855 if (exitImmediately) {
24856 process.exit(1);
24857 }
24858 else {
24859 process.exitCode = 1;
24860 }
24861 return;
24862 }
24863 if (process.env.BW_RESPONSE === 'true') {
24864 this.writeLn(this.getJson(response), true, false);
24865 }
24866 else if (response.data != null) {
24867 let out = dataProcessor != null ? dataProcessor() : null;
24868 if (out == null) {
24869 if (response.data.object === 'string') {
24870 const data = response.data.data;
24871 if (data != null) {
24872 out = data;
24873 }
24874 }
24875 else if (response.data.object === 'list') {
24876 out = this.getJson(response.data.data);
24877 }
24878 else if (response.data.object === 'message') {
24879 out = this.getMessage(response);
24880 }
24881 else {
24882 out = this.getJson(response.data);
24883 }
24884 }
24885 if (out != null && process.env.BW_QUIET !== 'true') {
24886 this.writeLn(out, true, false);
24887 }
24888 }
24889 if (exitImmediately) {
24890 process.exit(0);
24891 }
24892 else {
24893 process.exitCode = 0;
24894 }
24895 }
24896 getJson(obj) {
24897 if (process.env.BW_PRETTY === 'true') {
24898 return JSON.stringify(obj, null, ' ');
24899 }
24900 else {
24901 return JSON.stringify(obj);
24902 }
24903 }
24904 getMessage(response) {
24905 const message = response.data;
24906 if (process.env.BW_RAW === 'true') {
24907 return message.raw;
24908 }
24909 let out = '';
24910 if (message.title != null) {
24911 if (message.noColor) {
24912 out = message.title;
24913 }
24914 else {
24915 out = chalk.greenBright(message.title);
24916 }
24917 }
24918 if (message.message != null) {
24919 if (message.title != null) {
24920 out += '\n';
24921 }
24922 out += message.message;
24923 }
24924 return out.trim() === '' ? null : out;
24925 }
24926 exitIfAuthed() {
24927 return baseProgram_awaiter(this, void 0, void 0, function* () {
24928 const authed = yield this.userService.isAuthenticated();
24929 if (authed) {
24930 const email = yield this.userService.getEmail();
24931 this.processResponse(Response.error('You are already logged in as ' + email + '.'), true);
24932 }
24933 });
24934 }
24935 exitIfNotAuthed() {
24936 return baseProgram_awaiter(this, void 0, void 0, function* () {
24937 const authed = yield this.userService.isAuthenticated();
24938 if (!authed) {
24939 this.processResponse(Response.error('You are not logged in.'), true);
24940 }
24941 });
24942 }
24943}
24944
24945// CONCATENATED MODULE: ./src/program.ts
24946var program_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
24947 return new (P || (P = Promise))(function (resolve, reject) {
24948 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
24949 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
24950 function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
24951 step((generator = generator.apply(thisArg, _arguments || [])).next());
24952 });
24953};
24954
24955
24956
24957
24958
24959
24960
24961
24962
24963
24964
24965
24966
24967
24968
24969
24970
24971
24972
24973
24974
24975
24976
24977
24978
24979
24980
24981const program_chalk = external_chalk_default.a;
24982const writeLn = utils_CliUtils.writeLn;
24983class program_Program extends baseProgram_BaseProgram {
24984 constructor(main) {
24985 super(main.userService, writeLn);
24986 this.main = main;
24987 }
24988 run() {
24989 external_commander_["option"]('--pretty', 'Format output. JSON is tabbed with two spaces.')
24990 .option('--raw', 'Return raw output instead of a descriptive message.')
24991 .option('--response', 'Return a JSON formatted version of response output.')
24992 .option('--quiet', 'Don\'t return anything to stdout.')
24993 .option('--nointeraction', 'Do not prompt for interactive user input.')
24994 .option('--session <session>', 'Pass session key instead of reading from env.')
24995 .version(this.main.platformUtilsService.getApplicationVersion(), '-v, --version');
24996 external_commander_["on"]('option:pretty', () => {
24997 process.env.BW_PRETTY = 'true';
24998 });
24999 external_commander_["on"]('option:raw', () => {
25000 process.env.BW_RAW = 'true';
25001 });
25002 external_commander_["on"]('option:quiet', () => {
25003 process.env.BW_QUIET = 'true';
25004 });
25005 external_commander_["on"]('option:response', () => {
25006 process.env.BW_RESPONSE = 'true';
25007 });
25008 external_commander_["on"]('option:nointeraction', () => {
25009 process.env.BW_NOINTERACTION = 'true';
25010 });
25011 external_commander_["on"]('option:session', (key) => {
25012 process.env.BW_SESSION = key;
25013 });
25014 external_commander_["on"]('command:*', () => {
25015 writeLn(program_chalk.redBright('Invalid command: ' + external_commander_["args"].join(' ')), false, true);
25016 writeLn('See --help for a list of available commands.', true, true);
25017 process.exitCode = 1;
25018 });
25019 external_commander_["on"]('--help', () => {
25020 writeLn('\n Examples:');
25021 writeLn('');
25022 writeLn(' bw login');
25023 writeLn(' bw lock');
25024 writeLn(' bw unlock myPassword321');
25025 writeLn(' bw list --help');
25026 writeLn(' bw list items --search google');
25027 writeLn(' bw get item 99ee88d2-6046-4ea7-92c2-acac464b1412');
25028 writeLn(' bw get password google.com');
25029 writeLn(' echo \'{"name":"My Folder"}\' | bw encode');
25030 writeLn(' bw create folder eyJuYW1lIjoiTXkgRm9sZGVyIn0K');
25031 writeLn(' bw edit folder c7c7b60b-9c61-40f2-8ccd-36c49595ed72 eyJuYW1lIjoiTXkgRm9sZGVyMiJ9Cg==');
25032 writeLn(' bw delete item 99ee88d2-6046-4ea7-92c2-acac464b1412');
25033 writeLn(' bw generate -lusn --length 18');
25034 writeLn(' bw config server https://bitwarden.example.com');
25035 writeLn('', true);
25036 });
25037 external_commander_["command"]('login [email] [password]')
25038 .description('Log into a user account.')
25039 .option('--method <method>', 'Two-step login method.')
25040 .option('--code <code>', 'Two-step login code.')
25041 .option('--check', 'Check login status.', () => program_awaiter(this, void 0, void 0, function* () {
25042 const authed = yield this.main.userService.isAuthenticated();
25043 if (authed) {
25044 const res = new MessageResponse('You are logged in!', null);
25045 this.processResponse(Response.success(res), true);
25046 }
25047 this.processResponse(Response.error('You are not logged in.'), true);
25048 }))
25049 .on('--help', () => {
25050 writeLn('\n Notes:');
25051 writeLn('');
25052 writeLn(' See docs for valid `method` enum values.');
25053 writeLn('');
25054 writeLn(' Pass `--raw` option to only return the session key.');
25055 writeLn('');
25056 writeLn(' Examples:');
25057 writeLn('');
25058 writeLn(' bw login');
25059 writeLn(' bw login john@example.com myPassword321 --raw');
25060 writeLn(' bw login john@example.com myPassword321 --method 1 --code 249213');
25061 writeLn('', true);
25062 })
25063 .action((email, password, cmd) => program_awaiter(this, void 0, void 0, function* () {
25064 if (!cmd.check) {
25065 yield this.exitIfAuthed();
25066 const command = new commands_login_command_LoginCommand(this.main.authService, this.main.apiService, this.main.cryptoFunctionService, this.main.syncService, this.main.i18nService);
25067 const response = yield command.run(email, password, cmd);
25068 this.processResponse(response);
25069 }
25070 }));
25071 external_commander_["command"]('logout')
25072 .description('Log out of the current user account.')
25073 .on('--help', () => {
25074 writeLn('\n Examples:');
25075 writeLn('');
25076 writeLn(' bw logout');
25077 writeLn('', true);
25078 })
25079 .action((cmd) => program_awaiter(this, void 0, void 0, function* () {
25080 yield this.exitIfNotAuthed();
25081 const command = new logout_command_LogoutCommand(this.main.authService, this.main.i18nService, () => program_awaiter(this, void 0, void 0, function* () { return yield this.main.logout(); }));
25082 const response = yield command.run(cmd);
25083 this.processResponse(response);
25084 }));
25085 external_commander_["command"]('lock')
25086 .description('Lock the vault and destroy active session keys.')
25087 .on('--help', () => {
25088 writeLn('\n Examples:');
25089 writeLn('');
25090 writeLn(' bw lock');
25091 writeLn('', true);
25092 })
25093 .action((cmd) => program_awaiter(this, void 0, void 0, function* () {
25094 yield this.exitIfNotAuthed();
25095 const command = new lock_command_LockCommand(this.main.vaultTimeoutService);
25096 const response = yield command.run(cmd);
25097 this.processResponse(response);
25098 }));
25099 external_commander_["command"]('unlock [password]')
25100 .description('Unlock the vault and return a new session key.')
25101 .on('--help', () => {
25102 writeLn('\n Notes:');
25103 writeLn('');
25104 writeLn(' After unlocking, any previous session keys will no longer be valid.');
25105 writeLn('');
25106 writeLn(' Pass `--raw` option to only return the session key.');
25107 writeLn('');
25108 writeLn(' Examples:');
25109 writeLn('');
25110 writeLn(' bw unlock');
25111 writeLn(' bw unlock myPassword321');
25112 writeLn(' bw unlock myPassword321 --raw');
25113 writeLn('', true);
25114 })
25115 .option('--check', 'Check lock status.', () => program_awaiter(this, void 0, void 0, function* () {
25116 const locked = yield this.main.vaultTimeoutService.isLocked();
25117 if (!locked) {
25118 const res = new MessageResponse('Vault is unlocked!', null);
25119 this.processResponse(Response.success(res), true);
25120 }
25121 this.processResponse(Response.error('Vault is locked.'), true);
25122 }))
25123 .action((password, cmd) => program_awaiter(this, void 0, void 0, function* () {
25124 if (!cmd.check) {
25125 yield this.exitIfNotAuthed();
25126 const command = new unlock_command_UnlockCommand(this.main.cryptoService, this.main.userService, this.main.cryptoFunctionService);
25127 const response = yield command.run(password, cmd);
25128 this.processResponse(response);
25129 }
25130 }));
25131 external_commander_["command"]('sync')
25132 .description('Pull the latest vault data from server.')
25133 .option('-f, --force', 'Force a full sync.')
25134 .option('--last', 'Get the last sync date.')
25135 .on('--help', () => {
25136 writeLn('\n Examples:');
25137 writeLn('');
25138 writeLn(' bw sync');
25139 writeLn(' bw sync -f');
25140 writeLn(' bw sync --last');
25141 writeLn('', true);
25142 })
25143 .action((cmd) => program_awaiter(this, void 0, void 0, function* () {
25144 yield this.exitIfLocked();
25145 const command = new sync_command_SyncCommand(this.main.syncService);
25146 const response = yield command.run(cmd);
25147 this.processResponse(response);
25148 }));
25149 external_commander_["command"]('list <object>')
25150 .description('List an array of objects from the vault.')
25151 .option('--search <search>', 'Perform a search on the listed objects.')
25152 .option('--url <url>', 'Filter items of type login with a url-match search.')
25153 .option('--folderid <folderid>', 'Filter items by folder id.')
25154 .option('--collectionid <collectionid>', 'Filter items by collection id.')
25155 .option('--organizationid <organizationid>', 'Filter items or collections by organization id.')
25156 .option('--trash', 'Filter items that are deleted and in the trash.')
25157 .on('--help', () => {
25158 writeLn('\n Objects:');
25159 writeLn('');
25160 writeLn(' items');
25161 writeLn(' folders');
25162 writeLn(' collections');
25163 writeLn(' organizations');
25164 writeLn(' org-collections');
25165 writeLn(' org-members');
25166 writeLn('');
25167 writeLn(' Notes:');
25168 writeLn('');
25169 writeLn(' Combining search with a filter performs a logical AND operation.');
25170 writeLn('');
25171 writeLn(' Combining multiple filters performs a logical OR operation.');
25172 writeLn('');
25173 writeLn(' Examples:');
25174 writeLn('');
25175 writeLn(' bw list items');
25176 writeLn(' bw list items --folderid 60556c31-e649-4b5d-8daf-fc1c391a1bf2');
25177 writeLn(' bw list items --search google --folderid 60556c31-e649-4b5d-8daf-fc1c391a1bf2');
25178 writeLn(' bw list items --url https://google.com');
25179 writeLn(' bw list items --folderid null');
25180 writeLn(' bw list items --organizationid notnull');
25181 writeLn(' bw list items --folderid 60556c31-e649-4b5d-8daf-fc1c391a1bf2 --organizationid notnull');
25182 writeLn(' bw list items --trash');
25183 writeLn(' bw list folders --search email');
25184 writeLn(' bw list org-members --organizationid 60556c31-e649-4b5d-8daf-fc1c391a1bf2');
25185 writeLn('', true);
25186 })
25187 .action((object, cmd) => program_awaiter(this, void 0, void 0, function* () {
25188 yield this.exitIfLocked();
25189 const command = new list_command_ListCommand(this.main.cipherService, this.main.folderService, this.main.collectionService, this.main.userService, this.main.searchService, this.main.apiService);
25190 const response = yield command.run(object, cmd);
25191 this.processResponse(response);
25192 }));
25193 external_commander_["command"]('get <object> <id>')
25194 .description('Get an object from the vault.')
25195 .option('--itemid <itemid>', 'Attachment\'s item id.')
25196 .option('--output <output>', 'Output directory or filename for attachment.')
25197 .option('--organizationid <organizationid>', 'Organization id for an organization object.')
25198 .on('--help', () => {
25199 writeLn('\n Objects:');
25200 writeLn('');
25201 writeLn(' item');
25202 writeLn(' username');
25203 writeLn(' password');
25204 writeLn(' uri');
25205 writeLn(' totp');
25206 writeLn(' exposed');
25207 writeLn(' attachment');
25208 writeLn(' folder');
25209 writeLn(' collection');
25210 writeLn(' org-collection');
25211 writeLn(' organization');
25212 writeLn(' template');
25213 writeLn(' fingerprint');
25214 writeLn('');
25215 writeLn(' Id:');
25216 writeLn('');
25217 writeLn(' Search term or object\'s globally unique `id`.');
25218 writeLn('');
25219 writeLn(' Examples:');
25220 writeLn('');
25221 writeLn(' bw get item 99ee88d2-6046-4ea7-92c2-acac464b1412');
25222 writeLn(' bw get password https://google.com');
25223 writeLn(' bw get totp google.com');
25224 writeLn(' bw get exposed yahoo.com');
25225 writeLn(' bw get attachment b857igwl1dzrs2 --itemid 99ee88d2-6046-4ea7-92c2-acac464b1412 ' +
25226 '--output ./photo.jpg');
25227 writeLn(' bw get attachment photo.jpg --itemid 99ee88d2-6046-4ea7-92c2-acac464b1412 --raw');
25228 writeLn(' bw get folder email');
25229 writeLn(' bw get template folder');
25230 writeLn('', true);
25231 })
25232 .action((object, id, cmd) => program_awaiter(this, void 0, void 0, function* () {
25233 yield this.exitIfLocked();
25234 const command = new get_command_GetCommand(this.main.cipherService, this.main.folderService, this.main.collectionService, this.main.totpService, this.main.auditService, this.main.cryptoService, this.main.userService, this.main.searchService, this.main.apiService);
25235 const response = yield command.run(object, id, cmd);
25236 this.processResponse(response);
25237 }));
25238 external_commander_["command"]('create <object> [encodedJson]')
25239 .option('--file <file>', 'Path to file for attachment.')
25240 .option('--itemid <itemid>', 'Attachment\'s item id.')
25241 .option('--organizationid <organizationid>', 'Organization id for an organization object.')
25242 .description('Create an object in the vault.')
25243 .on('--help', () => {
25244 writeLn('\n Objects:');
25245 writeLn('');
25246 writeLn(' item');
25247 writeLn(' attachment');
25248 writeLn(' folder');
25249 writeLn(' org-collection');
25250 writeLn('');
25251 writeLn(' Notes:');
25252 writeLn('');
25253 writeLn(' `encodedJson` can also be piped into stdin.');
25254 writeLn('');
25255 writeLn(' Examples:');
25256 writeLn('');
25257 writeLn(' bw create folder eyJuYW1lIjoiTXkgRm9sZGVyIn0K');
25258 writeLn(' echo \'eyJuYW1lIjoiTXkgRm9sZGVyIn0K\' | bw create folder');
25259 writeLn(' bw create attachment --file ./myfile.csv ' +
25260 '--itemid 16b15b89-65b3-4639-ad2a-95052a6d8f66');
25261 writeLn('', true);
25262 })
25263 .action((object, encodedJson, cmd) => program_awaiter(this, void 0, void 0, function* () {
25264 yield this.exitIfLocked();
25265 const command = new create_command_CreateCommand(this.main.cipherService, this.main.folderService, this.main.userService, this.main.cryptoService, this.main.apiService);
25266 const response = yield command.run(object, encodedJson, cmd);
25267 this.processResponse(response);
25268 }));
25269 external_commander_["command"]('edit <object> <id> [encodedJson]')
25270 .option('--organizationid <organizationid>', 'Organization id for an organization object.')
25271 .description('Edit an object from the vault.')
25272 .on('--help', () => {
25273 writeLn('\n Objects:');
25274 writeLn('');
25275 writeLn(' item');
25276 writeLn(' item-collections');
25277 writeLn(' folder');
25278 writeLn(' org-collection');
25279 writeLn('');
25280 writeLn(' Id:');
25281 writeLn('');
25282 writeLn(' Object\'s globally unique `id`.');
25283 writeLn('');
25284 writeLn(' Notes:');
25285 writeLn('');
25286 writeLn(' `encodedJson` can also be piped into stdin.');
25287 writeLn('');
25288 writeLn(' Examples:');
25289 writeLn('');
25290 writeLn(' bw edit folder 5cdfbd80-d99f-409b-915b-f4c5d0241b02 eyJuYW1lIjoiTXkgRm9sZGVyMiJ9Cg==');
25291 writeLn(' echo \'eyJuYW1lIjoiTXkgRm9sZGVyMiJ9Cg==\' | ' +
25292 'bw edit folder 5cdfbd80-d99f-409b-915b-f4c5d0241b02');
25293 writeLn(' bw edit item-collections 78307355-fd25-416b-88b8-b33fd0e88c82 ' +
25294 'WyI5NzQwNTNkMC0zYjMzLTRiOTgtODg2ZS1mZWNmNWM4ZGJhOTYiXQ==');
25295 writeLn('', true);
25296 })
25297 .action((object, id, encodedJson, cmd) => program_awaiter(this, void 0, void 0, function* () {
25298 yield this.exitIfLocked();
25299 const command = new edit_command_EditCommand(this.main.cipherService, this.main.folderService, this.main.cryptoService, this.main.apiService);
25300 const response = yield command.run(object, id, encodedJson, cmd);
25301 this.processResponse(response);
25302 }));
25303 external_commander_["command"]('delete <object> <id>')
25304 .option('--itemid <itemid>', 'Attachment\'s item id.')
25305 .option('--organizationid <organizationid>', 'Organization id for an organization object.')
25306 .option('-p, --permanent', 'Permanently deletes the item instead of soft-deleting it (item only).')
25307 .description('Delete an object from the vault.')
25308 .on('--help', () => {
25309 writeLn('\n Objects:');
25310 writeLn('');
25311 writeLn(' item');
25312 writeLn(' attachment');
25313 writeLn(' folder');
25314 writeLn(' org-collection');
25315 writeLn('');
25316 writeLn(' Id:');
25317 writeLn('');
25318 writeLn(' Object\'s globally unique `id`.');
25319 writeLn('');
25320 writeLn(' Examples:');
25321 writeLn('');
25322 writeLn(' bw delete item 7063feab-4b10-472e-b64c-785e2b870b92');
25323 writeLn(' bw delete item 89c21cd2-fab0-4f69-8c6e-ab8a0168f69a --permanent');
25324 writeLn(' bw delete folder 5cdfbd80-d99f-409b-915b-f4c5d0241b02');
25325 writeLn(' bw delete attachment b857igwl1dzrs2 --itemid 310d5ffd-e9a2-4451-af87-ea054dce0f78');
25326 writeLn('', true);
25327 })
25328 .action((object, id, cmd) => program_awaiter(this, void 0, void 0, function* () {
25329 yield this.exitIfLocked();
25330 const command = new delete_command_DeleteCommand(this.main.cipherService, this.main.folderService, this.main.userService, this.main.apiService);
25331 const response = yield command.run(object, id, cmd);
25332 this.processResponse(response);
25333 }));
25334 external_commander_["command"]('restore <object> <id>')
25335 .description('Restores an object from the trash.')
25336 .on('--help', () => {
25337 writeLn('\n Objects:');
25338 writeLn('');
25339 writeLn(' item');
25340 writeLn('');
25341 writeLn(' Id:');
25342 writeLn('');
25343 writeLn(' Object\'s globally unique `id`.');
25344 writeLn('');
25345 writeLn(' Examples:');
25346 writeLn('');
25347 writeLn(' bw restore item 7063feab-4b10-472e-b64c-785e2b870b92');
25348 writeLn('', true);
25349 })
25350 .action((object, id, cmd) => program_awaiter(this, void 0, void 0, function* () {
25351 yield this.exitIfLocked();
25352 const command = new restore_command_RestoreCommand(this.main.cipherService);
25353 const response = yield command.run(object, id, cmd);
25354 this.processResponse(response);
25355 }));
25356 external_commander_["command"]('share <id> <organizationId> [encodedJson]')
25357 .description('Share an item to an organization.')
25358 .on('--help', () => {
25359 writeLn('\n Id:');
25360 writeLn('');
25361 writeLn(' Item\'s globally unique `id`.');
25362 writeLn('');
25363 writeLn(' Organization Id:');
25364 writeLn('');
25365 writeLn(' Organization\'s globally unique `id`.');
25366 writeLn('');
25367 writeLn(' Notes:');
25368 writeLn('');
25369 writeLn(' `encodedJson` can also be piped into stdin. `encodedJson` contains ' +
25370 'an array of collection ids.');
25371 writeLn('');
25372 writeLn(' Examples:');
25373 writeLn('');
25374 writeLn(' bw share 4af958ce-96a7-45d9-beed-1e70fabaa27a 6d82949b-b44d-468a-adae-3f3bacb0ea32 ' +
25375 'WyI5NzQwNTNkMC0zYjMzLTRiOTgtODg2ZS1mZWNmNWM4ZGJhOTYiXQ==');
25376 writeLn(' echo \'["974053d0-3b33-4b98-886e-fecf5c8dba96"]\' | bw encode | ' +
25377 'bw share 4af958ce-96a7-45d9-beed-1e70fabaa27a 6d82949b-b44d-468a-adae-3f3bacb0ea32');
25378 writeLn('', true);
25379 })
25380 .action((id, organizationId, encodedJson, cmd) => program_awaiter(this, void 0, void 0, function* () {
25381 yield this.exitIfLocked();
25382 const command = new share_command_ShareCommand(this.main.cipherService);
25383 const response = yield command.run(id, organizationId, encodedJson, cmd);
25384 this.processResponse(response);
25385 }));
25386 external_commander_["command"]('confirm <object> <id>')
25387 .option('--organizationid <organizationid>', 'Organization id for an organization object.')
25388 .description('Confirm an object to the organization.')
25389 .on('--help', () => {
25390 writeLn('\n Objects:');
25391 writeLn('');
25392 writeLn(' org-member');
25393 writeLn('');
25394 writeLn(' Id:');
25395 writeLn('');
25396 writeLn(' Object\'s globally unique `id`.');
25397 writeLn('');
25398 writeLn(' Examples:');
25399 writeLn('');
25400 writeLn(' bw confirm org-member 7063feab-4b10-472e-b64c-785e2b870b92 ' +
25401 '--organizationid 310d5ffd-e9a2-4451-af87-ea054dce0f78');
25402 writeLn('', true);
25403 })
25404 .action((object, id, cmd) => program_awaiter(this, void 0, void 0, function* () {
25405 yield this.exitIfLocked();
25406 const command = new confirm_command_ConfirmCommand(this.main.apiService, this.main.cryptoService);
25407 const response = yield command.run(object, id, cmd);
25408 this.processResponse(response);
25409 }));
25410 external_commander_["command"]('import [format] [input]')
25411 .description('Import vault data from a file.')
25412 .option('--formats', 'List formats')
25413 .on('--help', () => {
25414 writeLn('\n Examples:');
25415 writeLn('');
25416 writeLn(' bw import --formats');
25417 writeLn(' bw import bitwardencsv ./from/source.csv');
25418 writeLn(' bw import keepass2xml keepass_backup.xml');
25419 })
25420 .action((format, filepath, cmd) => program_awaiter(this, void 0, void 0, function* () {
25421 yield this.exitIfLocked();
25422 const command = new import_command_ImportCommand(this.main.importService);
25423 const response = yield command.run(format, filepath, cmd);
25424 this.processResponse(response);
25425 }));
25426 external_commander_["command"]('export [password]')
25427 .description('Export vault data to a CSV or JSON file.')
25428 .option('--output <output>', 'Output directory or filename.')
25429 .option('--format <format>', 'Export file format.')
25430 .option('--organizationid <organizationid>', 'Organization id for an organization.')
25431 .on('--help', () => {
25432 writeLn('\n Notes:');
25433 writeLn('');
25434 writeLn(' Valid formats are `csv` and `json`. Default format is `csv`.');
25435 writeLn('');
25436 writeLn(' Examples:');
25437 writeLn('');
25438 writeLn(' bw export');
25439 writeLn(' bw export myPassword321');
25440 writeLn(' bw export myPassword321 --format json');
25441 writeLn(' bw export --output ./exp/bw.csv');
25442 writeLn(' bw export myPassword321 --output bw.json --format json');
25443 writeLn(' bw export myPassword321 --organizationid 7063feab-4b10-472e-b64c-785e2b870b92');
25444 writeLn('', true);
25445 })
25446 .action((password, cmd) => program_awaiter(this, void 0, void 0, function* () {
25447 yield this.exitIfLocked();
25448 const command = new export_command_ExportCommand(this.main.cryptoService, this.main.exportService);
25449 const response = yield command.run(password, cmd);
25450 this.processResponse(response);
25451 }));
25452 external_commander_["command"]('generate')
25453 .description('Generate a password/passphrase.')
25454 .option('-u, --uppercase', 'Include uppercase characters.')
25455 .option('-l, --lowercase', 'Include lowercase characters.')
25456 .option('-n, --number', 'Include numeric characters.')
25457 .option('-s, --special', 'Include special characters.')
25458 .option('-p, --passphrase', 'Generate a passphrase.')
25459 .option('--length <length>', 'Length of the password.')
25460 .option('--words <words>', 'Number of words.')
25461 .option('--separator <separator>', 'Word separator.')
25462 .on('--help', () => {
25463 writeLn('\n Notes:');
25464 writeLn('');
25465 writeLn(' Default options are `-uln --length 14`.');
25466 writeLn('');
25467 writeLn(' Minimum `length` is 5.');
25468 writeLn('');
25469 writeLn(' Minimum `words` is 3.');
25470 writeLn('');
25471 writeLn(' Examples:');
25472 writeLn('');
25473 writeLn(' bw generate');
25474 writeLn(' bw generate -u -l --length 18');
25475 writeLn(' bw generate -ulns --length 25');
25476 writeLn(' bw generate -ul');
25477 writeLn(' bw generate -p --separator _');
25478 writeLn(' bw generate -p --words 5 --separator space');
25479 writeLn('', true);
25480 })
25481 .action((cmd) => program_awaiter(this, void 0, void 0, function* () {
25482 const command = new generate_command_GenerateCommand(this.main.passwordGenerationService);
25483 const response = yield command.run(cmd);
25484 this.processResponse(response);
25485 }));
25486 external_commander_["command"]('encode')
25487 .description('Base 64 encode stdin.')
25488 .on('--help', () => {
25489 writeLn('\n Notes:');
25490 writeLn('');
25491 writeLn(' Use to create `encodedJson` for `create` and `edit` commands.');
25492 writeLn('');
25493 writeLn(' Examples:');
25494 writeLn('');
25495 writeLn(' echo \'{"name":"My Folder"}\' | bw encode');
25496 writeLn('', true);
25497 })
25498 .action((object, id, cmd) => program_awaiter(this, void 0, void 0, function* () {
25499 const command = new encode_command_EncodeCommand();
25500 const response = yield command.run(cmd);
25501 this.processResponse(response);
25502 }));
25503 external_commander_["command"]('config <setting> [value]')
25504 .description('Configure CLI settings.')
25505 .option('--web-vault <url>', 'Provides a custom web vault URL that differs from the base URL.')
25506 .option('--api <url>', 'Provides a custom API URL that differs from the base URL.')
25507 .option('--identity <url>', 'Provides a custom identity URL that differs from the base URL.')
25508 .option('--icons <url>', 'Provides a custom icons service URL that differs from the base URL.')
25509 .option('--notifications <url>', 'Provides a custom notifications URL that differs from the base URL.')
25510 .option('--events <url>', 'Provides a custom events URL that differs from the base URL.')
25511 .on('--help', () => {
25512 writeLn('\n Settings:');
25513 writeLn('');
25514 writeLn(' server - On-premises hosted installation URL.');
25515 writeLn('');
25516 writeLn(' Examples:');
25517 writeLn('');
25518 writeLn(' bw config server');
25519 writeLn(' bw config server https://bw.company.com');
25520 writeLn(' bw config server bitwarden.com');
25521 writeLn(' bw config server --api http://localhost:4000 --identity http://localhost:33656');
25522 writeLn('', true);
25523 })
25524 .action((setting, value, cmd) => program_awaiter(this, void 0, void 0, function* () {
25525 const command = new config_command_ConfigCommand(this.main.environmentService);
25526 const response = yield command.run(setting, value, cmd);
25527 this.processResponse(response);
25528 }));
25529 external_commander_["command"]('update')
25530 .description('Check for updates.')
25531 .on('--help', () => {
25532 writeLn('\n Notes:');
25533 writeLn('');
25534 writeLn(' Returns the URL to download the newest version of this CLI tool.');
25535 writeLn('');
25536 writeLn(' Use the `--raw` option to return only the download URL for the update.');
25537 writeLn('');
25538 writeLn(' Examples:');
25539 writeLn('');
25540 writeLn(' bw update');
25541 writeLn(' bw update --raw');
25542 writeLn('', true);
25543 })
25544 .action((cmd) => program_awaiter(this, void 0, void 0, function* () {
25545 const command = new update_command_UpdateCommand(this.main.platformUtilsService, this.main.i18nService, 'cli', 'bw', true);
25546 const response = yield command.run(cmd);
25547 this.processResponse(response);
25548 }));
25549 external_commander_["command"]('completion')
25550 .description('Generate shell completions.')
25551 .option('--shell <shell>', 'Shell to generate completions for.')
25552 .on('--help', () => {
25553 writeLn('\n Notes:');
25554 writeLn('');
25555 writeLn(' Valid shells are `zsh`.');
25556 writeLn('');
25557 writeLn(' Examples:');
25558 writeLn('');
25559 writeLn(' bw completion --shell zsh');
25560 writeLn('', true);
25561 })
25562 .action((cmd) => program_awaiter(this, void 0, void 0, function* () {
25563 const command = new completion_command_CompletionCommand();
25564 const response = yield command.run(cmd);
25565 this.processResponse(response);
25566 }));
25567 external_commander_["command"]('status')
25568 .description('Show server, last sync, user information, and vault status.')
25569 .on('--help', () => {
25570 writeLn('');
25571 writeLn('');
25572 writeLn(' Example return value:');
25573 writeLn('');
25574 writeLn(' {');
25575 writeLn(' "serverUrl": "https://bitwarden.example.com",');
25576 writeLn(' "lastSync": "2020-06-16T06:33:51.419Z",');
25577 writeLn(' "userEmail": "user@example.com,');
25578 writeLn(' "userId": "00000000-0000-0000-0000-000000000000",');
25579 writeLn(' "status": "locked"');
25580 writeLn(' }');
25581 writeLn('');
25582 writeLn(' Notes:');
25583 writeLn('');
25584 writeLn(' `status` is one of:');
25585 writeLn(' - `unauthenticated` when you are not logged in');
25586 writeLn(' - `locked` when you are logged in and the vault is locked');
25587 writeLn(' - `unlocked` when you are logged in and the vault is unlocked');
25588 writeLn('', true);
25589 })
25590 .action((cmd) => program_awaiter(this, void 0, void 0, function* () {
25591 const command = new status_command_StatusCommand(this.main.environmentService, this.main.syncService, this.main.userService, this.main.vaultTimeoutService);
25592 const response = yield command.run(cmd);
25593 this.processResponse(response);
25594 }));
25595 external_commander_["parse"](process.argv);
25596 if (process.argv.slice(2).length === 0) {
25597 external_commander_["outputHelp"]();
25598 }
25599 }
25600 processResponse(response, exitImmediately = false) {
25601 super.processResponse(response, exitImmediately, () => {
25602 if (response.data.object === 'template') {
25603 return this.getJson(response.data.template);
25604 }
25605 return null;
25606 });
25607 }
25608 exitIfLocked() {
25609 return program_awaiter(this, void 0, void 0, function* () {
25610 yield this.exitIfNotAuthed();
25611 const hasKey = yield this.main.cryptoService.hasKey();
25612 if (!hasKey) {
25613 const canInteract = process.env.BW_NOINTERACTION !== 'true';
25614 if (canInteract) {
25615 const command = new unlock_command_UnlockCommand(this.main.cryptoService, this.main.userService, this.main.cryptoFunctionService);
25616 const response = yield command.run(null, null);
25617 if (!response.success) {
25618 this.processResponse(response, true);
25619 }
25620 }
25621 else {
25622 this.processResponse(Response.error('Vault is locked.'), true);
25623 }
25624 }
25625 });
25626 }
25627}
25628
25629// CONCATENATED MODULE: ./src/bw.ts
25630/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Main", function() { return bw_Main; });
25631var bw_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
25632 return new (P || (P = Promise))(function (resolve, reject) {
25633 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
25634 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
25635 function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
25636 step((generator = generator.apply(thisArg, _arguments || [])).next());
25637 });
25638};
25639
25640
25641
25642
25643
25644
25645
25646
25647
25648
25649
25650
25651
25652
25653
25654
25655
25656
25657
25658
25659
25660
25661
25662
25663
25664
25665
25666
25667
25668
25669
25670
25671// Polyfills
25672global.DOMParser = new external_jsdom_["JSDOM"]().window.DOMParser;
25673// tslint:disable-next-line
25674const packageJson = __webpack_require__(20);
25675class bw_Main {
25676 constructor() {
25677 let p = null;
25678 const relativeDataDir = external_path_["join"](external_path_["dirname"](process.execPath), 'bw-data');
25679 if (external_fs_["existsSync"](relativeDataDir)) {
25680 p = relativeDataDir;
25681 }
25682 else if (process.env.BITWARDENCLI_APPDATA_DIR) {
25683 p = external_path_["resolve"](process.env.BITWARDENCLI_APPDATA_DIR);
25684 }
25685 else if (process.platform === 'darwin') {
25686 p = external_path_["join"](process.env.HOME, 'Library/Application Support/Bitwarden CLI');
25687 }
25688 else if (process.platform === 'win32') {
25689 p = external_path_["join"](process.env.APPDATA, 'Bitwarden CLI');
25690 }
25691 else if (process.env.XDG_CONFIG_HOME) {
25692 p = external_path_["join"](process.env.XDG_CONFIG_HOME, 'Bitwarden CLI');
25693 }
25694 else {
25695 p = external_path_["join"](process.env.HOME, '.config/Bitwarden CLI');
25696 }
25697 this.i18nService = new services_i18n_service_I18nService('en', './locales');
25698 this.platformUtilsService = new cliPlatformUtils_service_CliPlatformUtilsService('cli', packageJson);
25699 this.cryptoFunctionService = new nodeCryptoFunction_service_NodeCryptoFunctionService();
25700 this.storageService = new lowdbStorage_service_LowdbStorageService(null, p, true);
25701 this.secureStorageService = new nodeEnvSecureStorage_service_NodeEnvSecureStorageService(this.storageService, () => this.cryptoService);
25702 this.cryptoService = new crypto_service_CryptoService(this.storageService, this.secureStorageService, this.cryptoFunctionService);
25703 this.appIdService = new appId_service_AppIdService(this.storageService);
25704 this.tokenService = new token_service_TokenService(this.storageService);
25705 this.messagingService = new NoopMessagingService();
25706 this.apiService = new nodeApi_service_NodeApiService(this.tokenService, this.platformUtilsService, (expired) => bw_awaiter(this, void 0, void 0, function* () { return yield this.logout(); }), 'Bitwarden_CLI/' + this.platformUtilsService.getApplicationVersion() +
25707 ' (' + this.platformUtilsService.getDeviceString().toUpperCase() + ')');
25708 this.environmentService = new environment_service_EnvironmentService(this.apiService, this.storageService, null);
25709 this.userService = new user_service_UserService(this.tokenService, this.storageService);
25710 this.containerService = new ContainerService(this.cryptoService);
25711 this.settingsService = new SettingsService(this.userService, this.storageService);
25712 this.cipherService = new cipher_service_CipherService(this.cryptoService, this.userService, this.settingsService, this.apiService, this.storageService, this.i18nService, null);
25713 this.folderService = new folder_service_FolderService(this.cryptoService, this.userService, this.apiService, this.storageService, this.i18nService, this.cipherService);
25714 this.collectionService = new collection_service_CollectionService(this.cryptoService, this.userService, this.storageService, this.i18nService);
25715 this.searchService = new search_service_SearchService(this.cipherService, this.platformUtilsService);
25716 this.policyService = new policy_service_PolicyService(this.userService, this.storageService);
25717 this.vaultTimeoutService = new vaultTimeout_service_VaultTimeoutService(this.cipherService, this.folderService, this.collectionService, this.cryptoService, this.platformUtilsService, this.storageService, this.messagingService, this.searchService, this.userService, this.tokenService, null, null);
25718 this.syncService = new sync_service_SyncService(this.userService, this.apiService, this.settingsService, this.folderService, this.cipherService, this.cryptoService, this.collectionService, this.storageService, this.messagingService, this.policyService, (expired) => bw_awaiter(this, void 0, void 0, function* () { return yield this.logout(); }));
25719 this.passwordGenerationService = new passwordGeneration_service_PasswordGenerationService(this.cryptoService, this.storageService, this.policyService);
25720 this.totpService = new totp_service_TotpService(this.storageService, this.cryptoFunctionService);
25721 this.importService = new import_service_ImportService(this.cipherService, this.folderService, this.apiService, this.i18nService, this.collectionService);
25722 this.exportService = new export_service_ExportService(this.folderService, this.cipherService, this.apiService);
25723 this.authService = new auth_service_AuthService(this.cryptoService, this.apiService, this.userService, this.tokenService, this.appIdService, this.i18nService, this.platformUtilsService, this.messagingService, true);
25724 this.auditService = new audit_service_AuditService(this.cryptoFunctionService, this.apiService);
25725 this.program = new program_Program(this);
25726 }
25727 run() {
25728 return bw_awaiter(this, void 0, void 0, function* () {
25729 yield this.init();
25730 this.program.run();
25731 });
25732 }
25733 logout() {
25734 return bw_awaiter(this, void 0, void 0, function* () {
25735 const userId = yield this.userService.getUserId();
25736 yield Promise.all([
25737 this.syncService.setLastSync(new Date(0)),
25738 this.tokenService.clearToken(),
25739 this.cryptoService.clearKeys(),
25740 this.userService.clear(),
25741 this.settingsService.clear(userId),
25742 this.cipherService.clear(userId),
25743 this.folderService.clear(userId),
25744 this.collectionService.clear(userId),
25745 this.policyService.clear(userId),
25746 this.passwordGenerationService.clear(),
25747 ]);
25748 process.env.BW_SESSION = null;
25749 });
25750 }
25751 init() {
25752 return bw_awaiter(this, void 0, void 0, function* () {
25753 this.storageService.init();
25754 this.containerService.attachToWindow(global);
25755 yield this.environmentService.setUrlsFromStorage();
25756 // Dev Server URLs. Comment out the line above.
25757 // this.apiService.setUrls({
25758 // base: null,
25759 // api: 'http://localhost:4000',
25760 // identity: 'http://localhost:33656',
25761 // });
25762 const locale = yield this.storageService.get(ConstantsService.localeKey);
25763 yield this.i18nService.init(locale);
25764 this.authService.init();
25765 const installedVersion = yield this.storageService.get(ConstantsService.installedVersionKey);
25766 const currentVersion = this.platformUtilsService.getApplicationVersion();
25767 if (installedVersion == null || installedVersion !== currentVersion) {
25768 yield this.storageService.save(ConstantsService.installedVersionKey, currentVersion);
25769 }
25770 });
25771 }
25772}
25773const main = new bw_Main();
25774main.run();
25775
25776
25777/***/ })
25778/******/ ]);
25779//# sourceMappingURL=bw.js.map
\No newline at end of file