mirror of
https://github.com/bitwarden/browser
synced 2025-12-12 14:23:32 +00:00
lint spec dir
This commit is contained in:
@@ -16,8 +16,8 @@
|
|||||||
"prebuild": "rimraf dist/**/*",
|
"prebuild": "rimraf dist/**/*",
|
||||||
"build": "tsc",
|
"build": "tsc",
|
||||||
"build:watch": "tsc -watch",
|
"build:watch": "tsc -watch",
|
||||||
"lint": "tslint src/**/*.ts || true",
|
"lint": "tslint src/**/*.ts spec/**/*.ts || true",
|
||||||
"lint:fix": "tslint src/**/*.ts --fix",
|
"lint:fix": "tslint src/**/*.ts spec/**/*.ts --fix",
|
||||||
"test": "karma start ./spec/support/karma.conf.js --single-run",
|
"test": "karma start ./spec/support/karma.conf.js --single-run",
|
||||||
"test:watch": "karma start ./spec/support/karma.conf.js",
|
"test:watch": "karma start ./spec/support/karma.conf.js",
|
||||||
"test:node": "npm run build && jasmine",
|
"test:node": "npm run build && jasmine",
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
// tslint:disable-next-line
|
||||||
const TSConsoleReporter = require('jasmine-ts-console-reporter');
|
const TSConsoleReporter = require('jasmine-ts-console-reporter');
|
||||||
jasmine.getEnv().clearReporters(); // Clear default console reporter
|
jasmine.getEnv().clearReporters(); // Clear default console reporter
|
||||||
jasmine.getEnv().addReporter(new TSConsoleReporter());
|
jasmine.getEnv().addReporter(new TSConsoleReporter());
|
||||||
|
|||||||
@@ -59,4 +59,3 @@ function makeStaticByteArray(length: number) {
|
|||||||
}
|
}
|
||||||
return arr;
|
return arr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -79,6 +79,6 @@ export class NodeCryptoFunctionService implements CryptoFunctionService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private toNodeBuffer(value: ArrayBuffer): Buffer {
|
private toNodeBuffer(value: ArrayBuffer): Buffer {
|
||||||
return Buffer.from(new Uint8Array(value) as any);;
|
return Buffer.from(new Uint8Array(value) as any);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,14 +19,14 @@ export class WebCryptoFunctionService implements CryptoFunctionService {
|
|||||||
async pbkdf2(password: string | ArrayBuffer, salt: string | ArrayBuffer, algorithm: 'sha256' | 'sha512',
|
async pbkdf2(password: string | ArrayBuffer, salt: string | ArrayBuffer, algorithm: 'sha256' | 'sha512',
|
||||||
iterations: number): Promise<ArrayBuffer> {
|
iterations: number): Promise<ArrayBuffer> {
|
||||||
if (this.isEdge) {
|
if (this.isEdge) {
|
||||||
const len = algorithm === 'sha256' ? 32 : 64;
|
const forgeLen = algorithm === 'sha256' ? 32 : 64;
|
||||||
const passwordBytes = this.toByteString(password);
|
const passwordBytes = this.toByteString(password);
|
||||||
const saltBytes = this.toByteString(salt);
|
const saltBytes = this.toByteString(salt);
|
||||||
const derivedKeyBytes = (forge as any).pbkdf2(passwordBytes, saltBytes, iterations, len, algorithm);
|
const derivedKeyBytes = (forge as any).pbkdf2(passwordBytes, saltBytes, iterations, forgeLen, algorithm);
|
||||||
return this.fromByteStringToBuf(derivedKeyBytes);
|
return this.fromByteStringToBuf(derivedKeyBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
const len = algorithm === 'sha256' ? 256 : 512;
|
const wcLen = algorithm === 'sha256' ? 256 : 512;
|
||||||
const passwordBuf = this.toBuf(password);
|
const passwordBuf = this.toBuf(password);
|
||||||
const saltBuf = this.toBuf(salt);
|
const saltBuf = this.toBuf(salt);
|
||||||
|
|
||||||
@@ -38,7 +38,7 @@ export class WebCryptoFunctionService implements CryptoFunctionService {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const impKey = await this.subtle.importKey('raw', passwordBuf, { name: 'PBKDF2' }, false, ['deriveBits']);
|
const impKey = await this.subtle.importKey('raw', passwordBuf, { name: 'PBKDF2' }, false, ['deriveBits']);
|
||||||
return await window.crypto.subtle.deriveBits(alg, impKey, len);
|
return await window.crypto.subtle.deriveBits(alg, impKey, wcLen);
|
||||||
}
|
}
|
||||||
|
|
||||||
async hash(value: string | ArrayBuffer, algorithm: 'sha1' | 'sha256' | 'sha512'): Promise<ArrayBuffer> {
|
async hash(value: string | ArrayBuffer, algorithm: 'sha1' | 'sha256' | 'sha512'): Promise<ArrayBuffer> {
|
||||||
|
|||||||
Reference in New Issue
Block a user