run linter

This commit is contained in:
tiagosiebler
2022-05-12 01:23:49 +01:00
parent 1a6b4cc269
commit f0088f32c2
5 changed files with 21 additions and 22 deletions

View File

@@ -1,18 +1,25 @@
export async function signMessage(message: string, secret: string): Promise<string> {
export async function signMessage(
message: string,
secret: string
): Promise<string> {
const encoder = new TextEncoder();
const key = await window.crypto.subtle.importKey(
'raw',
encoder.encode(secret),
{name: 'HMAC', hash: {name: 'SHA-256'}},
{ name: 'HMAC', hash: { name: 'SHA-256' } },
false,
['sign']
);
const signature = await window.crypto.subtle.sign('HMAC', key, encoder.encode(message));
const signature = await window.crypto.subtle.sign(
'HMAC',
key,
encoder.encode(message)
);
return Array.prototype.map.call(
new Uint8Array(signature),
(x: any) => ('00'+x.toString(16)).slice(-2)
).join('');
};
return Array.prototype.map
.call(new Uint8Array(signature), (x: any) =>
('00' + x.toString(16)).slice(-2)
)
.join('');
}