mirror of
https://github.com/bitwarden/directory-connector
synced 2026-01-06 10:33:46 +00:00
Upgrade prettier (#409)
This commit is contained in:
@@ -80,7 +80,7 @@ describe("NodeCrypto Function Service", () => {
|
||||
prk32Byte,
|
||||
64,
|
||||
"BnIqJlfnHm0e/2iB/15cbHyR19ARPIcWRp4oNS22CD9BV+" +
|
||||
"/queOZenPNkDhmlVyL2WZ3OSU5+7ISNF5NhNfvZA=="
|
||||
"/queOZenPNkDhmlVyL2WZ3OSU5+7ISNF5NhNfvZA==",
|
||||
);
|
||||
testHkdfExpand("sha512", prk64Byte, 32, "uLWbMWodSBms5uGJ5WTRTesyW+MD7nlpCZvagvIRXlk=");
|
||||
testHkdfExpand(
|
||||
@@ -88,7 +88,7 @@ describe("NodeCrypto Function Service", () => {
|
||||
prk64Byte,
|
||||
64,
|
||||
"uLWbMWodSBms5uGJ5WTRTesyW+MD7nlpCZvagvIRXlkY5Pv0sB+" +
|
||||
"MqvaopmkC6sD/j89zDwTV9Ib2fpucUydO8w=="
|
||||
"MqvaopmkC6sD/j89zDwTV9Ib2fpucUydO8w==",
|
||||
);
|
||||
|
||||
it("should fail with prk too small", async () => {
|
||||
@@ -97,7 +97,7 @@ describe("NodeCrypto Function Service", () => {
|
||||
Utils.fromB64ToArray(prk16Byte),
|
||||
"info",
|
||||
32,
|
||||
"sha256"
|
||||
"sha256",
|
||||
);
|
||||
await expect(f).rejects.toEqual(new Error("prk is too small."));
|
||||
});
|
||||
@@ -108,7 +108,7 @@ describe("NodeCrypto Function Service", () => {
|
||||
Utils.fromB64ToArray(prk32Byte),
|
||||
"info",
|
||||
8161,
|
||||
"sha256"
|
||||
"sha256",
|
||||
);
|
||||
await expect(f).rejects.toEqual(new Error("outputByteSize is too large."));
|
||||
});
|
||||
@@ -172,7 +172,7 @@ describe("NodeCrypto Function Service", () => {
|
||||
const encValue = await nodeCryptoFunctionService.aesEncrypt(
|
||||
data.buffer,
|
||||
iv.buffer,
|
||||
key.buffer
|
||||
key.buffer,
|
||||
);
|
||||
expect(Utils.fromBufferToB64(encValue)).toBe("ByUF8vhyX4ddU9gcooznwA==");
|
||||
});
|
||||
@@ -186,7 +186,7 @@ describe("NodeCrypto Function Service", () => {
|
||||
const encValue = await nodeCryptoFunctionService.aesEncrypt(
|
||||
data.buffer,
|
||||
iv.buffer,
|
||||
key.buffer
|
||||
key.buffer,
|
||||
);
|
||||
const decValue = await nodeCryptoFunctionService.aesDecrypt(encValue, iv.buffer, key.buffer);
|
||||
expect(Utils.fromBufferToUtf8(decValue)).toBe(value);
|
||||
@@ -214,7 +214,7 @@ describe("NodeCrypto Function Service", () => {
|
||||
const decValue = await nodeCryptoFunctionService.aesDecrypt(
|
||||
data.buffer,
|
||||
iv.buffer,
|
||||
key.buffer
|
||||
key.buffer,
|
||||
);
|
||||
expect(Utils.fromBufferToUtf8(decValue)).toBe("EncryptMe!");
|
||||
});
|
||||
@@ -230,7 +230,7 @@ describe("NodeCrypto Function Service", () => {
|
||||
const encValue = await nodeCryptoFunctionService.rsaEncrypt(
|
||||
data.buffer,
|
||||
pubKey.buffer,
|
||||
"sha1"
|
||||
"sha1",
|
||||
);
|
||||
const decValue = await nodeCryptoFunctionService.rsaDecrypt(encValue, privKey.buffer, "sha1");
|
||||
expect(Utils.fromBufferToUtf8(decValue)).toBe(value);
|
||||
@@ -245,12 +245,12 @@ describe("NodeCrypto Function Service", () => {
|
||||
"A1/p8BQzN9UrbdYxUY2Va5+kPLyfZXF9JsZrjeEXcaclsnHurdxVAJcnbEqYMP3UXV" +
|
||||
"4YAS/mpf+Rxe6/X0WS1boQdA0MAHSgx95hIlAraZYpiMLLiJRKeo2u8YivCdTM9V5vuAEJwf9Tof/qFsFci3sApdbATkorCT" +
|
||||
"zFOIEPF2S1zgperEP23M01mr4dWVdYN18B32YF67xdJHMbFhp5dkQwv9CmscoWq7OE5HIfOb+JAh7BEZb+CmKhM3yWJvoR/D" +
|
||||
"/5jcercUtK2o+XrzNrL4UQ7yLZcFz6Bfwb/j6ICYvqd/YJwXNE6dwlL57OfwJyCdw2rRYf0/qI00t9u8Iitw=="
|
||||
"/5jcercUtK2o+XrzNrL4UQ7yLZcFz6Bfwb/j6ICYvqd/YJwXNE6dwlL57OfwJyCdw2rRYf0/qI00t9u8Iitw==",
|
||||
);
|
||||
const decValue = await nodeCryptoFunctionService.rsaDecrypt(
|
||||
data.buffer,
|
||||
privKey.buffer,
|
||||
"sha1"
|
||||
"sha1",
|
||||
);
|
||||
expect(Utils.fromBufferToUtf8(decValue)).toBe("EncryptMe!");
|
||||
});
|
||||
@@ -286,7 +286,7 @@ describe("NodeCrypto Function Service", () => {
|
||||
const randomData = await nodeCryptoFunctionService.randomBytes(16);
|
||||
const randomData2 = await nodeCryptoFunctionService.randomBytes(16);
|
||||
expect(
|
||||
randomData.byteLength === randomData2.byteLength && randomData !== randomData2
|
||||
randomData.byteLength === randomData2.byteLength && randomData !== randomData2,
|
||||
).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -296,7 +296,7 @@ function testPbkdf2(
|
||||
algorithm: "sha256" | "sha512",
|
||||
regularKey: string,
|
||||
utf8Key: string,
|
||||
unicodeKey: string
|
||||
unicodeKey: string,
|
||||
) {
|
||||
const regularEmail = "user@example.com";
|
||||
const utf8Email = "üser@example.com";
|
||||
@@ -329,7 +329,7 @@ function testPbkdf2(
|
||||
Utils.fromUtf8ToArray(regularPassword).buffer,
|
||||
Utils.fromUtf8ToArray(regularEmail).buffer,
|
||||
algorithm,
|
||||
5000
|
||||
5000,
|
||||
);
|
||||
expect(Utils.fromBufferToB64(key)).toBe(regularKey);
|
||||
});
|
||||
@@ -339,7 +339,7 @@ function testHkdf(
|
||||
algorithm: "sha256" | "sha512",
|
||||
regularKey: string,
|
||||
utf8Key: string,
|
||||
unicodeKey: string
|
||||
unicodeKey: string,
|
||||
) {
|
||||
const ikm = Utils.fromB64ToArray("criAmKtfzxanbgea5/kelQ==");
|
||||
|
||||
@@ -376,7 +376,7 @@ function testHkdf(
|
||||
Utils.fromUtf8ToArray(regularSalt).buffer,
|
||||
Utils.fromUtf8ToArray(regularInfo).buffer,
|
||||
32,
|
||||
algorithm
|
||||
algorithm,
|
||||
);
|
||||
expect(Utils.fromBufferToB64(key)).toBe(regularKey);
|
||||
});
|
||||
@@ -386,7 +386,7 @@ function testHkdfExpand(
|
||||
algorithm: "sha256" | "sha512",
|
||||
b64prk: string,
|
||||
outputByteSize: number,
|
||||
b64ExpectedOkm: string
|
||||
b64ExpectedOkm: string,
|
||||
) {
|
||||
const info = "info";
|
||||
|
||||
@@ -396,7 +396,7 @@ function testHkdfExpand(
|
||||
Utils.fromB64ToArray(b64prk),
|
||||
info,
|
||||
outputByteSize,
|
||||
algorithm
|
||||
algorithm,
|
||||
);
|
||||
expect(Utils.fromBufferToB64(okm)).toBe(b64ExpectedOkm);
|
||||
});
|
||||
@@ -406,7 +406,7 @@ function testHash(
|
||||
algorithm: "sha1" | "sha256" | "sha512" | "md5",
|
||||
regularHash: string,
|
||||
utf8Hash: string,
|
||||
unicodeHash: string
|
||||
unicodeHash: string,
|
||||
) {
|
||||
const regularValue = "HashMe!!";
|
||||
const utf8Value = "HǻshMe!!";
|
||||
@@ -434,7 +434,7 @@ function testHash(
|
||||
const cryptoFunctionService = new NodeCryptoFunctionService();
|
||||
const hash = await cryptoFunctionService.hash(
|
||||
Utils.fromUtf8ToArray(regularValue).buffer,
|
||||
algorithm
|
||||
algorithm,
|
||||
);
|
||||
expect(Utils.fromBufferToHex(hash)).toBe(regularHash);
|
||||
});
|
||||
@@ -505,7 +505,7 @@ function testRsaGenerateKeyPair(length: 1024 | 2048 | 4096) {
|
||||
const publicKey = await cryptoFunctionService.rsaExtractPublicKey(keyPair[1]);
|
||||
expect(Utils.fromBufferToB64(keyPair[0])).toBe(Utils.fromBufferToB64(publicKey));
|
||||
},
|
||||
30000
|
||||
30000,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,13 +10,13 @@ import { StringResponse } from "./models/response/stringResponse";
|
||||
export abstract class BaseProgram {
|
||||
constructor(
|
||||
protected stateService: StateService,
|
||||
private writeLn: (s: string, finalLine: boolean, error: boolean) => void
|
||||
private writeLn: (s: string, finalLine: boolean, error: boolean) => void,
|
||||
) {}
|
||||
|
||||
protected processResponse(
|
||||
response: Response,
|
||||
exitImmediately = false,
|
||||
dataProcessor: () => string = null
|
||||
dataProcessor: () => string = null,
|
||||
) {
|
||||
if (!response.success) {
|
||||
if (process.env.BW_QUIET !== "true") {
|
||||
|
||||
@@ -55,7 +55,7 @@ export class LoginCommand {
|
||||
protected cryptoService: CryptoService,
|
||||
protected policyService: PolicyService,
|
||||
protected twoFactorService: TwoFactorService,
|
||||
clientId: string
|
||||
clientId: string,
|
||||
) {
|
||||
this.clientId = clientId;
|
||||
}
|
||||
@@ -167,12 +167,12 @@ export class LoginCommand {
|
||||
ssoCodeVerifier,
|
||||
this.ssoRedirectUri,
|
||||
orgIdentifier,
|
||||
twoFactor
|
||||
)
|
||||
twoFactor,
|
||||
),
|
||||
);
|
||||
} else {
|
||||
response = await this.authService.logIn(
|
||||
new PasswordLogInCredentials(email, password, null, twoFactor)
|
||||
new PasswordLogInCredentials(email, password, null, twoFactor),
|
||||
);
|
||||
}
|
||||
if (response.captchaSiteKey) {
|
||||
@@ -255,7 +255,7 @@ export class LoginCommand {
|
||||
|
||||
response = await this.authService.logInTwoFactor(
|
||||
new TokenRequestTwoFactor(selectedProvider.type, twoFactorToken),
|
||||
null
|
||||
null,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -278,7 +278,7 @@ export class LoginCommand {
|
||||
if (response.resetMasterPassword) {
|
||||
return Response.error(
|
||||
"In order to log in with SSO from the CLI, you must first log in" +
|
||||
" through the web vault to set your master password."
|
||||
" through the web vault to set your master password.",
|
||||
);
|
||||
}
|
||||
|
||||
@@ -313,8 +313,8 @@ export class LoginCommand {
|
||||
return Response.error(
|
||||
new MessageResponse(
|
||||
"An organization administrator recently changed your master password. In order to access the vault, you must update your master password now via the web vault. You have been logged out.",
|
||||
null
|
||||
)
|
||||
null,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -346,7 +346,7 @@ export class LoginCommand {
|
||||
// Strength & Policy Validation
|
||||
const strengthResult = this.passwordGenerationService.passwordStrength(
|
||||
masterPassword,
|
||||
this.getPasswordStrengthUserInput()
|
||||
this.getPasswordStrengthUserInput(),
|
||||
);
|
||||
|
||||
// Get New Master Password Re-type
|
||||
@@ -381,11 +381,11 @@ export class LoginCommand {
|
||||
!this.policyService.evaluateMasterPassword(
|
||||
strengthResult.score,
|
||||
masterPassword,
|
||||
enforcedPolicyOptions
|
||||
enforcedPolicyOptions,
|
||||
)
|
||||
) {
|
||||
return this.updateTempPassword(
|
||||
"Your new master password does not meet the policy requirements.\n"
|
||||
"Your new master password does not meet the policy requirements.\n",
|
||||
);
|
||||
}
|
||||
|
||||
@@ -395,7 +395,7 @@ export class LoginCommand {
|
||||
masterPassword,
|
||||
this.email.trim().toLowerCase(),
|
||||
kdf,
|
||||
kdfIterations
|
||||
kdfIterations,
|
||||
);
|
||||
const newPasswordHash = await this.cryptoService.hashPassword(masterPassword, newKey);
|
||||
|
||||
@@ -425,12 +425,12 @@ export class LoginCommand {
|
||||
|
||||
private async handleCaptchaRequired(
|
||||
twoFactorRequest: TokenRequestTwoFactor,
|
||||
credentials: PasswordLogInCredentials = null
|
||||
credentials: PasswordLogInCredentials = null,
|
||||
): Promise<AuthResult | Response> {
|
||||
const badCaptcha = Response.badRequest(
|
||||
"Your authentication request has been flagged and will require user interaction to proceed.\n" +
|
||||
"Please use your API key to validate this request and ensure BW_CLIENTSECRET is correct, if set.\n" +
|
||||
"(https://bitwarden.com/help/cli-auth-challenges)"
|
||||
"(https://bitwarden.com/help/cli-auth-challenges)",
|
||||
);
|
||||
|
||||
try {
|
||||
@@ -447,7 +447,7 @@ export class LoginCommand {
|
||||
} else {
|
||||
authResultResponse = await this.authService.logInTwoFactor(
|
||||
twoFactorRequest,
|
||||
captchaClientSecret
|
||||
captchaClientSecret,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -474,7 +474,7 @@ export class LoginCommand {
|
||||
.substr(0, atPosition)
|
||||
.trim()
|
||||
.toLowerCase()
|
||||
.split(/[^A-Za-z0-9]/)
|
||||
.split(/[^A-Za-z0-9]/),
|
||||
);
|
||||
}
|
||||
return userInput;
|
||||
@@ -535,7 +535,7 @@ export class LoginCommand {
|
||||
|
||||
private async openSsoPrompt(
|
||||
codeChallenge: string,
|
||||
state: string
|
||||
state: string,
|
||||
): Promise<{ ssoCode: string; orgIdentifier: string }> {
|
||||
return new Promise((resolve, reject) => {
|
||||
const callbackServer = http.createServer((req, res) => {
|
||||
@@ -551,13 +551,13 @@ export class LoginCommand {
|
||||
"<html><head><title>Success | Bitwarden CLI</title></head><body>" +
|
||||
"<h1>Successfully authenticated with the Bitwarden CLI</h1>" +
|
||||
"<p>You may now close this tab and return to the terminal.</p>" +
|
||||
"</body></html>"
|
||||
"</body></html>",
|
||||
);
|
||||
callbackServer.close(() =>
|
||||
resolve({
|
||||
ssoCode: code,
|
||||
orgIdentifier: orgIdentifier,
|
||||
})
|
||||
}),
|
||||
);
|
||||
} else {
|
||||
res.writeHead(400);
|
||||
@@ -565,7 +565,7 @@ export class LoginCommand {
|
||||
"<html><head><title>Failed | Bitwarden CLI</title></head><body>" +
|
||||
"<h1>Something went wrong logging into the Bitwarden CLI</h1>" +
|
||||
"<p>You may now close this tab and return to the terminal.</p>" +
|
||||
"</body></html>"
|
||||
"</body></html>",
|
||||
);
|
||||
callbackServer.close(() => reject());
|
||||
}
|
||||
@@ -585,7 +585,7 @@ export class LoginCommand {
|
||||
"&state=" +
|
||||
state +
|
||||
"&codeChallenge=" +
|
||||
codeChallenge
|
||||
codeChallenge,
|
||||
);
|
||||
});
|
||||
foundPort = true;
|
||||
|
||||
@@ -8,7 +8,7 @@ export class LogoutCommand {
|
||||
constructor(
|
||||
private authService: AuthService,
|
||||
private i18nService: I18nService,
|
||||
private logoutCallback: () => Promise<void>
|
||||
private logoutCallback: () => Promise<void>,
|
||||
) {}
|
||||
|
||||
async run() {
|
||||
|
||||
@@ -14,7 +14,7 @@ export class UpdateCommand {
|
||||
private i18nService: I18nService,
|
||||
private repoName: string,
|
||||
private executableName: string,
|
||||
private showExtendedMessage: boolean
|
||||
private showExtendedMessage: boolean,
|
||||
) {
|
||||
this.inPkg = !!(process as any).pkg;
|
||||
}
|
||||
@@ -23,7 +23,7 @@ export class UpdateCommand {
|
||||
const currentVersion = await this.platformUtilsService.getApplicationVersion();
|
||||
|
||||
const response = await fetch.default(
|
||||
"https://api.github.com/repos/bitwarden/" + this.repoName + "/releases/latest"
|
||||
"https://api.github.com/repos/bitwarden/" + this.repoName + "/releases/latest",
|
||||
);
|
||||
if (response.status === 200) {
|
||||
const responseJson = await response.json();
|
||||
|
||||
@@ -11,8 +11,8 @@ export class Response {
|
||||
error.message != null
|
||||
? error.message
|
||||
: error.toString() === "[object Object]"
|
||||
? JSON.stringify(error)
|
||||
: error.toString();
|
||||
? JSON.stringify(error)
|
||||
: error.toString();
|
||||
}
|
||||
res.data = data;
|
||||
return res;
|
||||
|
||||
@@ -13,7 +13,10 @@ export class CliPlatformUtilsService implements PlatformUtilsService {
|
||||
|
||||
private deviceCache: DeviceType = null;
|
||||
|
||||
constructor(clientType: ClientType, private packageJson: any) {
|
||||
constructor(
|
||||
clientType: ClientType,
|
||||
private packageJson: any,
|
||||
) {
|
||||
this.clientType = clientType;
|
||||
}
|
||||
|
||||
@@ -109,7 +112,7 @@ export class CliPlatformUtilsService implements PlatformUtilsService {
|
||||
type: "error" | "success" | "warning" | "info",
|
||||
title: string,
|
||||
text: string | string[],
|
||||
options?: any
|
||||
options?: any,
|
||||
): void {
|
||||
throw new Error("Not implemented.");
|
||||
}
|
||||
@@ -119,7 +122,7 @@ export class CliPlatformUtilsService implements PlatformUtilsService {
|
||||
title?: string,
|
||||
confirmText?: string,
|
||||
cancelText?: string,
|
||||
type?: string
|
||||
type?: string,
|
||||
): Promise<boolean> {
|
||||
throw new Error("Not implemented.");
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ export class LowdbStorageService implements StorageService {
|
||||
protected logService: LogService,
|
||||
defaults?: any,
|
||||
private dir?: string,
|
||||
private allowCache = false
|
||||
private allowCache = false,
|
||||
) {
|
||||
this.defaults = defaults;
|
||||
}
|
||||
@@ -42,7 +42,7 @@ export class LowdbStorageService implements StorageService {
|
||||
this.dataFilePath = path.join(this.dir, "data.json");
|
||||
if (!fs.existsSync(this.dataFilePath)) {
|
||||
this.logService.warning(
|
||||
`Could not find data file, "${this.dataFilePath}"; creating it instead.`
|
||||
`Could not find data file, "${this.dataFilePath}"; creating it instead.`,
|
||||
);
|
||||
fs.writeFileSync(this.dataFilePath, "", { mode: 0o600 });
|
||||
fs.chmodSync(this.dataFilePath, 0o600);
|
||||
@@ -61,14 +61,14 @@ export class LowdbStorageService implements StorageService {
|
||||
} catch (e) {
|
||||
if (e instanceof SyntaxError) {
|
||||
this.logService.warning(
|
||||
`Error creating lowdb storage adapter, "${e.message}"; emptying data file.`
|
||||
`Error creating lowdb storage adapter, "${e.message}"; emptying data file.`,
|
||||
);
|
||||
if (fs.existsSync(this.dataFilePath)) {
|
||||
const backupPath = this.dataFilePath + ".bak";
|
||||
this.logService.warning(`Writing backup of data file to ${backupPath}`);
|
||||
await fs.copyFile(this.dataFilePath, backupPath, () => {
|
||||
this.logService.warning(
|
||||
`Error while creating data file backup, "${e.message}". No backup may have been created.`
|
||||
`Error while creating data file backup, "${e.message}". No backup may have been created.`,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ export class NodeApiService extends ApiService {
|
||||
environmentService: EnvironmentService,
|
||||
appIdService: AppIdService,
|
||||
logoutCallback: (expired: boolean) => Promise<void>,
|
||||
customUserAgent: string = null
|
||||
customUserAgent: string = null,
|
||||
) {
|
||||
super(
|
||||
tokenService,
|
||||
@@ -29,7 +29,7 @@ export class NodeApiService extends ApiService {
|
||||
environmentService,
|
||||
appIdService,
|
||||
logoutCallback,
|
||||
customUserAgent
|
||||
customUserAgent,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ export class NodeCryptoFunctionService implements CryptoFunctionService {
|
||||
password: string | ArrayBuffer,
|
||||
salt: string | ArrayBuffer,
|
||||
algorithm: "sha256" | "sha512",
|
||||
iterations: number
|
||||
iterations: number,
|
||||
): Promise<ArrayBuffer> {
|
||||
const len = algorithm === "sha256" ? 32 : 64;
|
||||
const nodePassword = this.toNodeValue(password);
|
||||
@@ -34,7 +34,7 @@ export class NodeCryptoFunctionService implements CryptoFunctionService {
|
||||
salt: string | ArrayBuffer,
|
||||
info: string | ArrayBuffer,
|
||||
outputByteSize: number,
|
||||
algorithm: "sha256" | "sha512"
|
||||
algorithm: "sha256" | "sha512",
|
||||
): Promise<ArrayBuffer> {
|
||||
const saltBuf = this.toArrayBuffer(salt);
|
||||
const prk = await this.hmac(ikm, saltBuf, algorithm);
|
||||
@@ -46,7 +46,7 @@ export class NodeCryptoFunctionService implements CryptoFunctionService {
|
||||
prk: ArrayBuffer,
|
||||
info: string | ArrayBuffer,
|
||||
outputByteSize: number,
|
||||
algorithm: "sha256" | "sha512"
|
||||
algorithm: "sha256" | "sha512",
|
||||
): Promise<ArrayBuffer> {
|
||||
const hashLen = algorithm === "sha256" ? 32 : 64;
|
||||
if (outputByteSize > 255 * hashLen) {
|
||||
@@ -79,7 +79,7 @@ export class NodeCryptoFunctionService implements CryptoFunctionService {
|
||||
|
||||
hash(
|
||||
value: string | ArrayBuffer,
|
||||
algorithm: "sha1" | "sha256" | "sha512" | "md5"
|
||||
algorithm: "sha1" | "sha256" | "sha512" | "md5",
|
||||
): Promise<ArrayBuffer> {
|
||||
const nodeValue = this.toNodeValue(value);
|
||||
const hash = crypto.createHash(algorithm);
|
||||
@@ -90,7 +90,7 @@ export class NodeCryptoFunctionService implements CryptoFunctionService {
|
||||
hmac(
|
||||
value: ArrayBuffer,
|
||||
key: ArrayBuffer,
|
||||
algorithm: "sha1" | "sha256" | "sha512"
|
||||
algorithm: "sha1" | "sha256" | "sha512",
|
||||
): Promise<ArrayBuffer> {
|
||||
const nodeValue = this.toNodeBuffer(value);
|
||||
const nodeKey = this.toNodeBuffer(key);
|
||||
@@ -121,7 +121,7 @@ export class NodeCryptoFunctionService implements CryptoFunctionService {
|
||||
hmacFast(
|
||||
value: ArrayBuffer,
|
||||
key: ArrayBuffer,
|
||||
algorithm: "sha1" | "sha256" | "sha512"
|
||||
algorithm: "sha1" | "sha256" | "sha512",
|
||||
): Promise<ArrayBuffer> {
|
||||
return this.hmac(value, key, algorithm);
|
||||
}
|
||||
@@ -143,7 +143,7 @@ export class NodeCryptoFunctionService implements CryptoFunctionService {
|
||||
data: string,
|
||||
iv: string,
|
||||
mac: string,
|
||||
key: SymmetricCryptoKey
|
||||
key: SymmetricCryptoKey,
|
||||
): DecryptParameters<ArrayBuffer> {
|
||||
const p = new DecryptParameters<ArrayBuffer>();
|
||||
p.encKey = key.encKey;
|
||||
@@ -182,7 +182,7 @@ export class NodeCryptoFunctionService implements CryptoFunctionService {
|
||||
rsaEncrypt(
|
||||
data: ArrayBuffer,
|
||||
publicKey: ArrayBuffer,
|
||||
algorithm: "sha1" | "sha256"
|
||||
algorithm: "sha1" | "sha256",
|
||||
): Promise<ArrayBuffer> {
|
||||
if (algorithm === "sha256") {
|
||||
throw new Error("Node crypto does not support RSA-OAEP SHA-256");
|
||||
@@ -196,7 +196,7 @@ export class NodeCryptoFunctionService implements CryptoFunctionService {
|
||||
rsaDecrypt(
|
||||
data: ArrayBuffer,
|
||||
privateKey: ArrayBuffer,
|
||||
algorithm: "sha1" | "sha256"
|
||||
algorithm: "sha1" | "sha256",
|
||||
): Promise<ArrayBuffer> {
|
||||
if (algorithm === "sha256") {
|
||||
throw new Error("Node crypto does not support RSA-OAEP SHA-256");
|
||||
@@ -242,7 +242,7 @@ export class NodeCryptoFunctionService implements CryptoFunctionService {
|
||||
const privateKey = Utils.fromByteStringToArray(privateKeyByteString);
|
||||
|
||||
resolve([publicKey.buffer, privateKey.buffer]);
|
||||
}
|
||||
},
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user