bitty-tui 0.0.20 → 0.0.21
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/dist/clients/bw.js +12 -5
- package/package.json +1 -1
package/dist/clients/bw.js
CHANGED
|
@@ -86,12 +86,13 @@ class Bw {
|
|
|
86
86
|
* The encryption key will be used to decrypt the user keys.
|
|
87
87
|
*/
|
|
88
88
|
async deriveMasterKey(email, password, prelogin) {
|
|
89
|
+
const normalizedEmail = email.trim().toLowerCase();
|
|
89
90
|
let masterKey;
|
|
90
91
|
if (prelogin.kdf === KdfType.PBKDF2) {
|
|
91
|
-
masterKey = this.derivePbkdf2(password,
|
|
92
|
+
masterKey = this.derivePbkdf2(password, normalizedEmail, prelogin.kdfIterations);
|
|
92
93
|
}
|
|
93
94
|
else {
|
|
94
|
-
masterKey = await this.deriveArgon2(password,
|
|
95
|
+
masterKey = await this.deriveArgon2(password, normalizedEmail, prelogin.kdfIterations, prelogin.kdfMemory, prelogin.kdfParallelism);
|
|
95
96
|
}
|
|
96
97
|
const masterPasswordHashBytes = this.derivePbkdf2(masterKey, password, 1);
|
|
97
98
|
const masterPasswordHash = Buffer.from(masterPasswordHashBytes).toString("base64");
|
|
@@ -343,8 +344,9 @@ export class Client {
|
|
|
343
344
|
}
|
|
344
345
|
setUrls(uri) {
|
|
345
346
|
if (uri.baseUrl) {
|
|
346
|
-
|
|
347
|
-
this.
|
|
347
|
+
const base = uri.baseUrl.replace(/\/+$/, "");
|
|
348
|
+
this.apiUrl = base + "/api";
|
|
349
|
+
this.identityUrl = base + "/identity";
|
|
348
350
|
}
|
|
349
351
|
else {
|
|
350
352
|
this.apiUrl = uri.apiUrl;
|
|
@@ -437,12 +439,17 @@ export class Client {
|
|
|
437
439
|
if (!this.refreshToken) {
|
|
438
440
|
throw new Error("No refresh token available. Please login first.");
|
|
439
441
|
}
|
|
442
|
+
const bodyParams = new URLSearchParams();
|
|
443
|
+
bodyParams.append("refresh_token", this.refreshToken);
|
|
444
|
+
bodyParams.append("grant_type", "refresh_token");
|
|
445
|
+
bodyParams.append("client_id", "web");
|
|
446
|
+
bodyParams.append("scope", "api offline_access");
|
|
440
447
|
const identityReq = await fetchApi(`${this.identityUrl}/connect/token`, {
|
|
441
448
|
method: "POST",
|
|
442
449
|
headers: {
|
|
443
450
|
"Content-Type": "application/x-www-form-urlencoded",
|
|
444
451
|
},
|
|
445
|
-
body:
|
|
452
|
+
body: bodyParams.toString(),
|
|
446
453
|
}).then((r) => r.json());
|
|
447
454
|
this.token = identityReq.access_token;
|
|
448
455
|
this.refreshToken = identityReq.refresh_token;
|