diff options
| author | Adam Soltys <[email protected]> | 2026-02-24 13:01:02 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-02-24 13:01:02 -0800 |
| commit | db59579a2efa8416f78c855faa7d7e62048447e5 (patch) | |
| tree | 28444081de0120f21f7596198937bdd52fe43495 /src/lib/crypto.ts | |
| parent | 7eec7ac0b322b510b4e2cedef62422b6043d6405 (diff) | |
| download | coinos-ui-db59579a2efa8416f78c855faa7d7e62048447e5.tar.gz coinos-ui-db59579a2efa8416f78c855faa7d7e62048447e5.zip | |
lint
Diffstat (limited to 'src/lib/crypto.ts')
| -rw-r--r-- | src/lib/crypto.ts | 15 |
1 files changed, 3 insertions, 12 deletions
diff --git a/src/lib/crypto.ts b/src/lib/crypto.ts index d941d894..80a6364a 100644 --- a/src/lib/crypto.ts +++ b/src/lib/crypto.ts @@ -2,17 +2,11 @@ export function isPrfEncrypted(value: string): boolean { return value.startsWith("{"); } -async function importPrfKey( - prfKey: ArrayBuffer, - usages: KeyUsage[], -): Promise<CryptoKey> { +async function importPrfKey(prfKey: ArrayBuffer, usages: KeyUsage[]): Promise<CryptoKey> { return crypto.subtle.importKey("raw", prfKey, "AES-GCM", false, usages); } -export async function prfEncrypt( - prfKey: ArrayBuffer, - plaintext: Uint8Array, -): Promise<string> { +export async function prfEncrypt(prfKey: ArrayBuffer, plaintext: Uint8Array): Promise<string> { const key = await importPrfKey(prfKey, ["encrypt"]); const iv = crypto.getRandomValues(new Uint8Array(12)); const ciphertext = new Uint8Array( @@ -29,10 +23,7 @@ export async function prfEncrypt( }); } -export async function prfDecrypt( - prfKey: ArrayBuffer, - encrypted: string, -): Promise<Uint8Array> { +export async function prfDecrypt(prfKey: ArrayBuffer, encrypted: string): Promise<Uint8Array> { const { iv, ct } = JSON.parse(encrypted); const key = await importPrfKey(prfKey, ["decrypt"]); const ivBytes = fromBase64Url(iv); |
