@bitwarden/cli 1.22.0 → 1.22.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/bw.js +145 -99
- package/build/bw.js.map +1 -1
- package/package.json +1 -1
package/build/bw.js
CHANGED
|
@@ -20,7 +20,7 @@ module.exports = require("url");
|
|
|
20
20
|
/***/ 147:
|
|
21
21
|
/***/ ((module) => {
|
|
22
22
|
|
|
23
|
-
module.exports = JSON.parse('{"name":"@bitwarden/cli","description":"A secure and free password manager for all of your devices.","version":"1.22.
|
|
23
|
+
module.exports = JSON.parse('{"name":"@bitwarden/cli","description":"A secure and free password manager for all of your devices.","version":"1.22.1","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-only","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:debug":"npm run build && node --inspect ./build/bw.js","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 --build","package:mac":"pkg . --targets macos-x64 --output ./dist/macos/bw","package:lin":"pkg . --targets linux-x64 --output ./dist/linux/bw","debug":"node --inspect ./build/bw.js","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":"eslint . && prettier --check .","lint:fix":"eslint . --fix","prettier":"prettier --write .","prepare":"husky install","test":"jasmine-ts -r tsconfig-paths/register -P spec/tsconfig.json","test:watch":"nodemon -w ./spec -w ./src -w ./jslib --ext \\"ts,js,mjs,json\\" --exec jasmine-ts -r tsconfig-paths/register -P spec/tsconfig.json"},"bin":{"bw":"build/bw.js"},"pkg":{"assets":"./build/**/*"},"devDependencies":{"@fluffy-spoon/substitute":"^1.208.0","@types/inquirer":"^7.3.1","@types/jasmine":"^3.7.0","@types/jsdom":"^16.2.10","@types/koa":"^2.13.4","@types/koa__multer":"^2.0.4","@types/koa__router":"^8.0.11","@types/koa-bodyparser":"^4.3.5","@types/koa-json":"^2.0.20","@types/lowdb":"^1.0.10","@types/lunr":"^2.3.3","@types/node":"^16.11.12","@types/node-fetch":"^2.5.10","@types/node-forge":"^0.9.7","@types/papaparse":"^5.2.5","@types/proper-lockfile":"^4.1.2","@types/retry":"^0.12.1","@types/tldjs":"^2.3.0","@types/zxcvbn":"^4.4.1","@typescript-eslint/eslint-plugin":"^5.12.1","@typescript-eslint/parser":"^5.12.1","clean-webpack-plugin":"^4.0.0","copy-webpack-plugin":"^10.2.0","cross-env":"^7.0.3","eslint":"^8.9.0","eslint-config-prettier":"^8.4.0","eslint-import-resolver-typescript":"^2.5.0","eslint-plugin-import":"^2.25.4","husky":"^7.0.4","jasmine":"^3.7.0","jasmine-core":"^3.7.1","jasmine-ts":"^0.4.0","jasmine-ts-console-reporter":"^3.1.1","lint-staged":"^12.1.3","pkg":"^5.5.1","prettier":"^2.5.1","rimraf":"^3.0.2","ts-loader":"^8.2.0","ts-node":"^10.4.0","tsconfig-paths":"^3.12.0","tsconfig-paths-webpack-plugin":"^3.5.2","typescript":"4.1.5","webpack":"^5.65.0","webpack-cli":"^4.9.1","webpack-node-externals":"^3.0.0"},"dependencies":{"@koa/multer":"^3.0.0","@koa/router":"^10.1.1","big-integer":"1.6.48","browser-hrtime":"^1.1.8","chalk":"^4.1.1","commander":"7.2.0","form-data":"4.0.0","https-proxy-agent":"5.0.0","inquirer":"8.0.0","jsdom":"^16.5.3","jszip":"^3.7.1","koa":"^2.13.4","koa-bodyparser":"^4.3.0","koa-json":"^2.0.2","lowdb":"1.0.0","lunr":"^2.3.9","multer":"^1.4.4","node-fetch":"^2.6.1","node-forge":"0.10.0","open":"^8.0.8","papaparse":"^5.3.0","proper-lockfile":"^4.1.2","rxjs":"6.6.7","tldjs":"^2.3.1","zxcvbn":"^4.4.2"},"engines":{"node":"~16","npm":">=7 <=8"},"lint-staged":{"./!(jslib)**":"prettier --ignore-unknown --write","*.ts":"eslint --fix"}}');
|
|
24
24
|
|
|
25
25
|
/***/ })
|
|
26
26
|
|
|
@@ -263,43 +263,6 @@ class GlobalState {
|
|
|
263
263
|
}
|
|
264
264
|
}
|
|
265
265
|
|
|
266
|
-
;// CONCATENATED MODULE: ./jslib/common/src/enums/authenticationType.ts
|
|
267
|
-
var AuthenticationType;
|
|
268
|
-
(function (AuthenticationType) {
|
|
269
|
-
AuthenticationType[AuthenticationType["Password"] = 0] = "Password";
|
|
270
|
-
AuthenticationType[AuthenticationType["Sso"] = 1] = "Sso";
|
|
271
|
-
AuthenticationType[AuthenticationType["Api"] = 2] = "Api";
|
|
272
|
-
})(AuthenticationType || (AuthenticationType = {}));
|
|
273
|
-
|
|
274
|
-
;// CONCATENATED MODULE: ./jslib/common/src/models/domain/logInCredentials.ts
|
|
275
|
-
|
|
276
|
-
class PasswordLogInCredentials {
|
|
277
|
-
constructor(email, masterPassword, captchaToken, twoFactor) {
|
|
278
|
-
this.email = email;
|
|
279
|
-
this.masterPassword = masterPassword;
|
|
280
|
-
this.captchaToken = captchaToken;
|
|
281
|
-
this.twoFactor = twoFactor;
|
|
282
|
-
this.type = AuthenticationType.Password;
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
class SsoLogInCredentials {
|
|
286
|
-
constructor(code, codeVerifier, redirectUrl, orgId, twoFactor) {
|
|
287
|
-
this.code = code;
|
|
288
|
-
this.codeVerifier = codeVerifier;
|
|
289
|
-
this.redirectUrl = redirectUrl;
|
|
290
|
-
this.orgId = orgId;
|
|
291
|
-
this.twoFactor = twoFactor;
|
|
292
|
-
this.type = AuthenticationType.Sso;
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
class ApiLogInCredentials {
|
|
296
|
-
constructor(clientId, clientSecret) {
|
|
297
|
-
this.clientId = clientId;
|
|
298
|
-
this.clientSecret = clientSecret;
|
|
299
|
-
this.type = AuthenticationType.Api;
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
|
|
303
266
|
;// CONCATENATED MODULE: ./jslib/common/src/enums/htmlStorageLocation.ts
|
|
304
267
|
var HtmlStorageLocation;
|
|
305
268
|
(function (HtmlStorageLocation) {
|
|
@@ -825,6 +788,14 @@ __decorate([
|
|
|
825
788
|
__metadata("design:returntype", Promise)
|
|
826
789
|
], AuditService.prototype, "passwordLeaked", null);
|
|
827
790
|
|
|
791
|
+
;// CONCATENATED MODULE: ./jslib/common/src/enums/authenticationType.ts
|
|
792
|
+
var AuthenticationType;
|
|
793
|
+
(function (AuthenticationType) {
|
|
794
|
+
AuthenticationType[AuthenticationType["Password"] = 0] = "Password";
|
|
795
|
+
AuthenticationType[AuthenticationType["Sso"] = 1] = "Sso";
|
|
796
|
+
AuthenticationType[AuthenticationType["Api"] = 2] = "Api";
|
|
797
|
+
})(AuthenticationType || (AuthenticationType = {}));
|
|
798
|
+
|
|
828
799
|
;// CONCATENATED MODULE: ./jslib/common/src/models/request/identityToken/tokenRequest.ts
|
|
829
800
|
class TokenRequest {
|
|
830
801
|
constructor(twoFactor, device) {
|
|
@@ -917,6 +888,15 @@ class DeviceRequest {
|
|
|
917
888
|
}
|
|
918
889
|
}
|
|
919
890
|
|
|
891
|
+
;// CONCATENATED MODULE: ./jslib/common/src/models/request/identityToken/tokenRequestTwoFactor.ts
|
|
892
|
+
class TokenRequestTwoFactor {
|
|
893
|
+
constructor(provider = null, token = null, remember = false) {
|
|
894
|
+
this.provider = provider;
|
|
895
|
+
this.token = token;
|
|
896
|
+
this.remember = remember;
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
|
|
920
900
|
;// CONCATENATED MODULE: ./jslib/common/src/models/request/keysRequest.ts
|
|
921
901
|
class KeysRequest {
|
|
922
902
|
constructor(publicKey, encryptedPrivateKey) {
|
|
@@ -1031,6 +1011,7 @@ var logIn_strategy_awaiter = (undefined && undefined.__awaiter) || function (thi
|
|
|
1031
1011
|
|
|
1032
1012
|
|
|
1033
1013
|
|
|
1014
|
+
|
|
1034
1015
|
class LogInStrategy {
|
|
1035
1016
|
constructor(cryptoService, apiService, tokenService, appIdService, platformUtilsService, messagingService, logService, stateService, twoFactorService) {
|
|
1036
1017
|
this.cryptoService = cryptoService;
|
|
@@ -1083,17 +1064,9 @@ class LogInStrategy {
|
|
|
1083
1064
|
}
|
|
1084
1065
|
const storedTwoFactorToken = yield this.tokenService.getTwoFactorToken();
|
|
1085
1066
|
if (storedTwoFactorToken != null) {
|
|
1086
|
-
return
|
|
1087
|
-
token: storedTwoFactorToken,
|
|
1088
|
-
provider: TwoFactorProviderType.Remember,
|
|
1089
|
-
remember: false,
|
|
1090
|
-
};
|
|
1067
|
+
return new TokenRequestTwoFactor(TwoFactorProviderType.Remember, storedTwoFactorToken, false);
|
|
1091
1068
|
}
|
|
1092
|
-
return
|
|
1093
|
-
token: null,
|
|
1094
|
-
provider: null,
|
|
1095
|
-
remember: false,
|
|
1096
|
-
};
|
|
1069
|
+
return new TokenRequestTwoFactor();
|
|
1097
1070
|
});
|
|
1098
1071
|
}
|
|
1099
1072
|
saveAccountInformation(tokenResponse) {
|
|
@@ -4690,7 +4663,7 @@ class CipherService {
|
|
|
4690
4663
|
ciphers[c.id].deletedDate = null;
|
|
4691
4664
|
ciphers[c.id].revisionDate = c.revisionDate;
|
|
4692
4665
|
};
|
|
4693
|
-
if (cipher.constructor.name ===
|
|
4666
|
+
if (cipher.constructor.name === Array.name) {
|
|
4694
4667
|
cipher.forEach(clearDeletedDate);
|
|
4695
4668
|
}
|
|
4696
4669
|
else {
|
|
@@ -5209,6 +5182,9 @@ var KdfType;
|
|
|
5209
5182
|
(function (KdfType) {
|
|
5210
5183
|
KdfType[KdfType["PBKDF2_SHA256"] = 0] = "PBKDF2_SHA256";
|
|
5211
5184
|
})(KdfType || (KdfType = {}));
|
|
5185
|
+
const DEFAULT_KDF_TYPE = KdfType.PBKDF2_SHA256;
|
|
5186
|
+
const DEFAULT_KDF_ITERATIONS = 100000;
|
|
5187
|
+
const SEND_KDF_ITERATIONS = 100000;
|
|
5212
5188
|
|
|
5213
5189
|
;// CONCATENATED MODULE: ./jslib/common/src/misc/wordlist.ts
|
|
5214
5190
|
// EFF's Long Wordlist from https://www.eff.org/dice
|
|
@@ -14812,7 +14788,7 @@ class ExportService {
|
|
|
14812
14788
|
? yield this.getOrganizationExport(organizationId, "json")
|
|
14813
14789
|
: yield this.getExport("json");
|
|
14814
14790
|
const salt = Utils.fromBufferToB64(yield this.cryptoFunctionService.randomBytes(16));
|
|
14815
|
-
const kdfIterations =
|
|
14791
|
+
const kdfIterations = DEFAULT_KDF_ITERATIONS;
|
|
14816
14792
|
const key = yield this.cryptoService.makePinKey(password, salt, KdfType.PBKDF2_SHA256, kdfIterations);
|
|
14817
14793
|
const encKeyValidation = yield this.cryptoService.encrypt(Utils.newGuid(), key);
|
|
14818
14794
|
const encText = yield this.cryptoService.encrypt(clearText, key);
|
|
@@ -20665,12 +20641,14 @@ class SafariCsvImporter extends BaseImporter {
|
|
|
20665
20641
|
return Promise.resolve(result);
|
|
20666
20642
|
}
|
|
20667
20643
|
results.forEach((value) => {
|
|
20644
|
+
var _a;
|
|
20668
20645
|
const cipher = this.initLoginCipher();
|
|
20669
20646
|
cipher.name = this.getValueOrDefault(value.Title, "--");
|
|
20670
20647
|
cipher.login.username = this.getValueOrDefault(value.Username);
|
|
20671
20648
|
cipher.login.password = this.getValueOrDefault(value.Password);
|
|
20672
|
-
cipher.login.uris = this.makeUriArray(value.Url);
|
|
20649
|
+
cipher.login.uris = this.makeUriArray((_a = value.Url) !== null && _a !== void 0 ? _a : value.URL);
|
|
20673
20650
|
cipher.login.totp = this.getValueOrDefault(value.OTPAuth);
|
|
20651
|
+
cipher.notes = this.getValueOrDefault(value.Notes);
|
|
20674
20652
|
this.cleanupCipher(cipher);
|
|
20675
20653
|
result.ciphers.push(cipher);
|
|
20676
20654
|
});
|
|
@@ -23469,6 +23447,7 @@ var send_service_awaiter = (undefined && undefined.__awaiter) || function (thisA
|
|
|
23469
23447
|
|
|
23470
23448
|
|
|
23471
23449
|
|
|
23450
|
+
|
|
23472
23451
|
class SendService {
|
|
23473
23452
|
constructor(cryptoService, apiService, fileUploadService, i18nService, cryptoFunctionService, stateService) {
|
|
23474
23453
|
this.cryptoService = cryptoService;
|
|
@@ -23497,7 +23476,7 @@ class SendService {
|
|
|
23497
23476
|
model.cryptoKey = yield this.cryptoService.makeSendKey(model.key);
|
|
23498
23477
|
}
|
|
23499
23478
|
if (password != null) {
|
|
23500
|
-
const passwordHash = yield this.cryptoFunctionService.pbkdf2(password, model.key, "sha256",
|
|
23479
|
+
const passwordHash = yield this.cryptoFunctionService.pbkdf2(password, model.key, "sha256", SEND_KDF_ITERATIONS);
|
|
23501
23480
|
send.password = Utils.fromBufferToB64(passwordHash);
|
|
23502
23481
|
}
|
|
23503
23482
|
send.key = yield this.cryptoService.encrypt(model.key, key);
|
|
@@ -25200,6 +25179,32 @@ class StateService {
|
|
|
25200
25179
|
yield this.saveAccount(account, this.reconcileOptions(options, yield this.defaultOnDiskOptions()));
|
|
25201
25180
|
});
|
|
25202
25181
|
}
|
|
25182
|
+
getUsernameGenerationOptions(options) {
|
|
25183
|
+
var _a, _b;
|
|
25184
|
+
return state_service_awaiter(this, void 0, void 0, function* () {
|
|
25185
|
+
return (_b = (_a = (yield this.getAccount(this.reconcileOptions(options, yield this.defaultOnDiskOptions())))) === null || _a === void 0 ? void 0 : _a.settings) === null || _b === void 0 ? void 0 : _b.usernameGenerationOptions;
|
|
25186
|
+
});
|
|
25187
|
+
}
|
|
25188
|
+
setUsernameGenerationOptions(value, options) {
|
|
25189
|
+
return state_service_awaiter(this, void 0, void 0, function* () {
|
|
25190
|
+
const account = yield this.getAccount(this.reconcileOptions(options, yield this.defaultOnDiskOptions()));
|
|
25191
|
+
account.settings.usernameGenerationOptions = value;
|
|
25192
|
+
yield this.saveAccount(account, this.reconcileOptions(options, yield this.defaultOnDiskOptions()));
|
|
25193
|
+
});
|
|
25194
|
+
}
|
|
25195
|
+
getGeneratorOptions(options) {
|
|
25196
|
+
var _a, _b;
|
|
25197
|
+
return state_service_awaiter(this, void 0, void 0, function* () {
|
|
25198
|
+
return (_b = (_a = (yield this.getAccount(this.reconcileOptions(options, yield this.defaultOnDiskOptions())))) === null || _a === void 0 ? void 0 : _a.settings) === null || _b === void 0 ? void 0 : _b.generatorOptions;
|
|
25199
|
+
});
|
|
25200
|
+
}
|
|
25201
|
+
setGeneratorOptions(value, options) {
|
|
25202
|
+
return state_service_awaiter(this, void 0, void 0, function* () {
|
|
25203
|
+
const account = yield this.getAccount(this.reconcileOptions(options, yield this.defaultOnDiskOptions()));
|
|
25204
|
+
account.settings.generatorOptions = value;
|
|
25205
|
+
yield this.saveAccount(account, this.reconcileOptions(options, yield this.defaultOnDiskOptions()));
|
|
25206
|
+
});
|
|
25207
|
+
}
|
|
25203
25208
|
getProtectedPin(options) {
|
|
25204
25209
|
var _a, _b;
|
|
25205
25210
|
return state_service_awaiter(this, void 0, void 0, function* () {
|
|
@@ -25757,11 +25762,8 @@ class StateService {
|
|
|
25757
25762
|
return state_service_awaiter(this, void 0, void 0, function* () {
|
|
25758
25763
|
yield this.setAccessToken(null, { userId: userId });
|
|
25759
25764
|
yield this.setLastActive(null, { userId: userId });
|
|
25760
|
-
|
|
25761
|
-
|
|
25762
|
-
this.state.authenticatedAccounts.splice(index, 1);
|
|
25763
|
-
yield this.storageService.save(keys.authenticatedAccounts, this.state.authenticatedAccounts);
|
|
25764
|
-
}
|
|
25765
|
+
this.state.authenticatedAccounts = this.state.authenticatedAccounts.filter((activeUserId) => activeUserId !== userId);
|
|
25766
|
+
yield this.storageService.save(keys.authenticatedAccounts, this.state.authenticatedAccounts);
|
|
25765
25767
|
});
|
|
25766
25768
|
}
|
|
25767
25769
|
removeAccountFromDisk(userId) {
|
|
@@ -26476,6 +26478,15 @@ class ProviderData {
|
|
|
26476
26478
|
}
|
|
26477
26479
|
|
|
26478
26480
|
;// CONCATENATED MODULE: ./jslib/common/src/services/sync.service.ts
|
|
26481
|
+
var sync_service_decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
26482
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
26483
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
26484
|
+
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;
|
|
26485
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
26486
|
+
};
|
|
26487
|
+
var sync_service_metadata = (undefined && undefined.__metadata) || function (k, v) {
|
|
26488
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
26489
|
+
};
|
|
26479
26490
|
var sync_service_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26480
26491
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
26481
26492
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -26492,6 +26503,7 @@ var sync_service_awaiter = (undefined && undefined.__awaiter) || function (thisA
|
|
|
26492
26503
|
|
|
26493
26504
|
|
|
26494
26505
|
|
|
26506
|
+
|
|
26495
26507
|
class SyncService {
|
|
26496
26508
|
constructor(apiService, settingsService, folderService, cipherService, cryptoService, collectionService, messagingService, policyService, sendService, logService, keyConnectorService, stateService, organizationService, providerService, logoutCallback) {
|
|
26497
26509
|
this.apiService = apiService;
|
|
@@ -26850,6 +26862,12 @@ class SyncService {
|
|
|
26850
26862
|
});
|
|
26851
26863
|
}
|
|
26852
26864
|
}
|
|
26865
|
+
sync_service_decorate([
|
|
26866
|
+
sequentialize(() => "fullSync"),
|
|
26867
|
+
sync_service_metadata("design:type", Function),
|
|
26868
|
+
sync_service_metadata("design:paramtypes", [Boolean, Object]),
|
|
26869
|
+
sync_service_metadata("design:returntype", Promise)
|
|
26870
|
+
], SyncService.prototype, "fullSync", null);
|
|
26853
26871
|
|
|
26854
26872
|
;// CONCATENATED MODULE: ./jslib/common/src/services/totp.service.ts
|
|
26855
26873
|
var totp_service_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
@@ -27535,9 +27553,6 @@ class CliPlatformUtilsService {
|
|
|
27535
27553
|
isSafari() {
|
|
27536
27554
|
return false;
|
|
27537
27555
|
}
|
|
27538
|
-
isIE() {
|
|
27539
|
-
return false;
|
|
27540
|
-
}
|
|
27541
27556
|
isMacAppStore() {
|
|
27542
27557
|
return false;
|
|
27543
27558
|
}
|
|
@@ -28990,14 +29005,17 @@ var api_service_awaiter = (undefined && undefined.__awaiter) || function (thisAr
|
|
|
28990
29005
|
|
|
28991
29006
|
|
|
28992
29007
|
|
|
29008
|
+
|
|
29009
|
+
|
|
28993
29010
|
|
|
28994
29011
|
|
|
28995
29012
|
|
|
28996
29013
|
class ApiService {
|
|
28997
|
-
constructor(tokenService, platformUtilsService, environmentService, logoutCallback, customUserAgent = null) {
|
|
29014
|
+
constructor(tokenService, platformUtilsService, environmentService, appIdService, logoutCallback, customUserAgent = null) {
|
|
28998
29015
|
this.tokenService = tokenService;
|
|
28999
29016
|
this.platformUtilsService = platformUtilsService;
|
|
29000
29017
|
this.environmentService = environmentService;
|
|
29018
|
+
this.appIdService = appIdService;
|
|
29001
29019
|
this.logoutCallback = logoutCallback;
|
|
29002
29020
|
this.customUserAgent = customUserAgent;
|
|
29003
29021
|
this.isWebClient = false;
|
|
@@ -30441,18 +30459,6 @@ class ApiService {
|
|
|
30441
30459
|
throw new Error("Cannot refresh token, no refresh token or api keys are stored");
|
|
30442
30460
|
});
|
|
30443
30461
|
}
|
|
30444
|
-
doApiTokenRefresh() {
|
|
30445
|
-
return api_service_awaiter(this, void 0, void 0, function* () {
|
|
30446
|
-
const clientId = yield this.tokenService.getClientId();
|
|
30447
|
-
const clientSecret = yield this.tokenService.getClientSecret();
|
|
30448
|
-
if (Utils.isNullOrWhitespace(clientId) ||
|
|
30449
|
-
Utils.isNullOrWhitespace(clientSecret) ||
|
|
30450
|
-
this.apiKeyRefresh == null) {
|
|
30451
|
-
throw new Error();
|
|
30452
|
-
}
|
|
30453
|
-
yield this.apiKeyRefresh(clientId, clientSecret);
|
|
30454
|
-
});
|
|
30455
|
-
}
|
|
30456
30462
|
doRefreshToken() {
|
|
30457
30463
|
return api_service_awaiter(this, void 0, void 0, function* () {
|
|
30458
30464
|
const refreshToken = yield this.tokenService.getRefreshToken();
|
|
@@ -30490,6 +30496,20 @@ class ApiService {
|
|
|
30490
30496
|
}
|
|
30491
30497
|
});
|
|
30492
30498
|
}
|
|
30499
|
+
doApiTokenRefresh() {
|
|
30500
|
+
return api_service_awaiter(this, void 0, void 0, function* () {
|
|
30501
|
+
const clientId = yield this.tokenService.getClientId();
|
|
30502
|
+
const clientSecret = yield this.tokenService.getClientSecret();
|
|
30503
|
+
const appId = yield this.appIdService.getAppId();
|
|
30504
|
+
const deviceRequest = new DeviceRequest(appId, this.platformUtilsService);
|
|
30505
|
+
const tokenRequest = new ApiTokenRequest(clientId, clientSecret, new TokenRequestTwoFactor(), deviceRequest);
|
|
30506
|
+
const response = yield this.postIdentityToken(tokenRequest);
|
|
30507
|
+
if (!(response instanceof IdentityTokenResponse)) {
|
|
30508
|
+
throw new Error("Invalid response received when refreshing api token");
|
|
30509
|
+
}
|
|
30510
|
+
yield this.tokenService.setToken(response.accessToken);
|
|
30511
|
+
});
|
|
30512
|
+
}
|
|
30493
30513
|
send(method, path, body, authed, hasResponse, apiUrl, alterHeaders) {
|
|
30494
30514
|
return api_service_awaiter(this, void 0, void 0, function* () {
|
|
30495
30515
|
apiUrl = Utils.isNullOrWhitespace(apiUrl) ? this.environmentService.getApiUrl() : apiUrl;
|
|
@@ -30613,9 +30633,8 @@ global.Response = external_node_fetch_namespaceObject.Response;
|
|
|
30613
30633
|
global.Headers = external_node_fetch_namespaceObject.Headers;
|
|
30614
30634
|
global.FormData = external_form_data_namespaceObject;
|
|
30615
30635
|
class NodeApiService extends ApiService {
|
|
30616
|
-
constructor(tokenService, platformUtilsService, environmentService, logoutCallback, customUserAgent = null
|
|
30617
|
-
super(tokenService, platformUtilsService, environmentService, logoutCallback, customUserAgent);
|
|
30618
|
-
this.apiKeyRefresh = apiKeyRefresh;
|
|
30636
|
+
constructor(tokenService, platformUtilsService, environmentService, appIdService, logoutCallback, customUserAgent = null) {
|
|
30637
|
+
super(tokenService, platformUtilsService, environmentService, appIdService, logoutCallback, customUserAgent);
|
|
30619
30638
|
}
|
|
30620
30639
|
nativeFetch(request) {
|
|
30621
30640
|
const proxy = process.env.http_proxy || process.env.https_proxy;
|
|
@@ -31768,6 +31787,35 @@ class LockCommand {
|
|
|
31768
31787
|
|
|
31769
31788
|
;// CONCATENATED MODULE: external "http"
|
|
31770
31789
|
const external_http_namespaceObject = require("http");
|
|
31790
|
+
;// CONCATENATED MODULE: ./jslib/common/src/models/domain/logInCredentials.ts
|
|
31791
|
+
|
|
31792
|
+
class PasswordLogInCredentials {
|
|
31793
|
+
constructor(email, masterPassword, captchaToken, twoFactor) {
|
|
31794
|
+
this.email = email;
|
|
31795
|
+
this.masterPassword = masterPassword;
|
|
31796
|
+
this.captchaToken = captchaToken;
|
|
31797
|
+
this.twoFactor = twoFactor;
|
|
31798
|
+
this.type = AuthenticationType.Password;
|
|
31799
|
+
}
|
|
31800
|
+
}
|
|
31801
|
+
class SsoLogInCredentials {
|
|
31802
|
+
constructor(code, codeVerifier, redirectUrl, orgId, twoFactor) {
|
|
31803
|
+
this.code = code;
|
|
31804
|
+
this.codeVerifier = codeVerifier;
|
|
31805
|
+
this.redirectUrl = redirectUrl;
|
|
31806
|
+
this.orgId = orgId;
|
|
31807
|
+
this.twoFactor = twoFactor;
|
|
31808
|
+
this.type = AuthenticationType.Sso;
|
|
31809
|
+
}
|
|
31810
|
+
}
|
|
31811
|
+
class ApiLogInCredentials {
|
|
31812
|
+
constructor(clientId, clientSecret) {
|
|
31813
|
+
this.clientId = clientId;
|
|
31814
|
+
this.clientSecret = clientSecret;
|
|
31815
|
+
this.type = AuthenticationType.Api;
|
|
31816
|
+
}
|
|
31817
|
+
}
|
|
31818
|
+
|
|
31771
31819
|
;// CONCATENATED MODULE: ./jslib/common/src/models/request/twoFactorEmailRequest.ts
|
|
31772
31820
|
|
|
31773
31821
|
class TwoFactorEmailRequest extends SecretVerificationRequest {
|
|
@@ -31803,6 +31851,7 @@ var login_command_awaiter = (undefined && undefined.__awaiter) || function (this
|
|
|
31803
31851
|
|
|
31804
31852
|
|
|
31805
31853
|
|
|
31854
|
+
|
|
31806
31855
|
class login_command_LoginCommand {
|
|
31807
31856
|
constructor(authService, apiService, i18nService, environmentService, passwordGenerationService, cryptoFunctionService, platformUtilsService, stateService, cryptoService, policyService, twoFactorService, clientId) {
|
|
31808
31857
|
this.authService = authService;
|
|
@@ -31907,11 +31956,7 @@ class login_command_LoginCommand {
|
|
|
31907
31956
|
}
|
|
31908
31957
|
const twoFactor = twoFactorToken == null
|
|
31909
31958
|
? null
|
|
31910
|
-
:
|
|
31911
|
-
provider: twoFactorMethod,
|
|
31912
|
-
token: twoFactorToken,
|
|
31913
|
-
remember: false,
|
|
31914
|
-
};
|
|
31959
|
+
: new TokenRequestTwoFactor(twoFactorMethod, twoFactorToken, false);
|
|
31915
31960
|
try {
|
|
31916
31961
|
if (this.validatedParams != null) {
|
|
31917
31962
|
yield this.validatedParams();
|
|
@@ -31999,18 +32044,10 @@ class login_command_LoginCommand {
|
|
|
31999
32044
|
return Response.badRequest("Code is required.");
|
|
32000
32045
|
}
|
|
32001
32046
|
}
|
|
32002
|
-
response = yield this.authService.logInTwoFactor(
|
|
32003
|
-
provider: selectedProvider.type,
|
|
32004
|
-
token: twoFactorToken,
|
|
32005
|
-
remember: false,
|
|
32006
|
-
}, null);
|
|
32047
|
+
response = yield this.authService.logInTwoFactor(new TokenRequestTwoFactor(selectedProvider.type, twoFactorToken), null);
|
|
32007
32048
|
}
|
|
32008
32049
|
if (response.captchaSiteKey) {
|
|
32009
|
-
const twoFactorRequest =
|
|
32010
|
-
provider: selectedProvider.type,
|
|
32011
|
-
token: twoFactorToken,
|
|
32012
|
-
remember: false,
|
|
32013
|
-
};
|
|
32050
|
+
const twoFactorRequest = new TokenRequestTwoFactor(selectedProvider.type, twoFactorToken);
|
|
32014
32051
|
const handledResponse = yield this.handleCaptchaRequired(twoFactorRequest);
|
|
32015
32052
|
// Error Response
|
|
32016
32053
|
if (handledResponse instanceof Response) {
|
|
@@ -32158,7 +32195,7 @@ class login_command_LoginCommand {
|
|
|
32158
32195
|
}
|
|
32159
32196
|
catch (e) {
|
|
32160
32197
|
if (e instanceof ErrorResponse ||
|
|
32161
|
-
(e.constructor.name ===
|
|
32198
|
+
(e.constructor.name === ErrorResponse.name &&
|
|
32162
32199
|
e.message.includes("Captcha is invalid"))) {
|
|
32163
32200
|
return badCaptcha;
|
|
32164
32201
|
}
|
|
@@ -34916,6 +34953,7 @@ class ServeCommand {
|
|
|
34916
34953
|
run(options) {
|
|
34917
34954
|
return serve_command_awaiter(this, void 0, void 0, function* () {
|
|
34918
34955
|
const port = options.port || 8087;
|
|
34956
|
+
const hostname = options.hostname || "localhost";
|
|
34919
34957
|
const server = new external_koa_namespaceObject();
|
|
34920
34958
|
const router = new router_namespaceObject();
|
|
34921
34959
|
process.env.BW_SERVE = "true";
|
|
@@ -35083,8 +35121,8 @@ class ServeCommand {
|
|
|
35083
35121
|
server
|
|
35084
35122
|
.use(router.routes())
|
|
35085
35123
|
.use(router.allowedMethods())
|
|
35086
|
-
.listen(port, () => {
|
|
35087
|
-
this.main.logService.info("Listening on
|
|
35124
|
+
.listen(port, hostname === "all" ? null : hostname, () => {
|
|
35125
|
+
this.main.logService.info("Listening on " + hostname + ":" + port);
|
|
35088
35126
|
});
|
|
35089
35127
|
});
|
|
35090
35128
|
}
|
|
@@ -35491,12 +35529,20 @@ class Program extends BaseProgram {
|
|
|
35491
35529
|
if (CliUtils.flagEnabled("serve")) {
|
|
35492
35530
|
external_commander_namespaceObject.command("serve")
|
|
35493
35531
|
.description("Start a RESTful API webserver.")
|
|
35494
|
-
.option("--
|
|
35532
|
+
.option("--hostname <hostname>", "The hostname to bind your API webserver to.")
|
|
35533
|
+
.option("--port <port>", "The port to run your API webserver on.")
|
|
35495
35534
|
.on("--help", () => {
|
|
35496
|
-
writeLn("\n
|
|
35535
|
+
writeLn("\n Notes:");
|
|
35536
|
+
writeLn("");
|
|
35537
|
+
writeLn(" Default hostname is `localhost`.");
|
|
35538
|
+
writeLn(" Use hostname `all` for no hostname binding.");
|
|
35539
|
+
writeLn(" Default port is `8087`.");
|
|
35540
|
+
writeLn("");
|
|
35541
|
+
writeLn(" Examples:");
|
|
35497
35542
|
writeLn("");
|
|
35498
35543
|
writeLn(" bw serve");
|
|
35499
35544
|
writeLn(" bw serve --port 8080");
|
|
35545
|
+
writeLn(" bw serve --hostname bwapi.mydomain.com --port 80");
|
|
35500
35546
|
writeLn("", true);
|
|
35501
35547
|
})
|
|
35502
35548
|
.action((cmd) => program_awaiter(this, void 0, void 0, function* () {
|
|
@@ -37230,7 +37276,6 @@ var bw_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _argum
|
|
|
37230
37276
|
|
|
37231
37277
|
|
|
37232
37278
|
|
|
37233
|
-
|
|
37234
37279
|
|
|
37235
37280
|
|
|
37236
37281
|
// Polyfills
|
|
@@ -37272,11 +37317,12 @@ class Main {
|
|
|
37272
37317
|
this.tokenService = new TokenService(this.stateService);
|
|
37273
37318
|
this.messagingService = new NoopMessagingService();
|
|
37274
37319
|
this.environmentService = new EnvironmentService(this.stateService);
|
|
37275
|
-
|
|
37320
|
+
const customUserAgent = "Bitwarden_CLI/" +
|
|
37276
37321
|
this.platformUtilsService.getApplicationVersionSync() +
|
|
37277
37322
|
" (" +
|
|
37278
37323
|
this.platformUtilsService.getDeviceString().toUpperCase() +
|
|
37279
|
-
")"
|
|
37324
|
+
")";
|
|
37325
|
+
this.apiService = new NodeApiService(this.tokenService, this.platformUtilsService, this.environmentService, this.appIdService, (expired) => bw_awaiter(this, void 0, void 0, function* () { return yield this.logout(); }), customUserAgent);
|
|
37280
37326
|
this.containerService = new ContainerService(this.cryptoService);
|
|
37281
37327
|
this.settingsService = new SettingsService(this.stateService);
|
|
37282
37328
|
this.fileUploadService = new FileUploadService(this.logService, this.apiService);
|