summaryrefslogtreecommitdiffhomepage
path: root/packages/server/src/helpers/iso/isoCrypto/importKey.ts
blob: bfe8f66eb76640d8465a6f6ccfa748a67666f289 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import { getWebCrypto } from './getWebCrypto.ts';

export async function importKey(opts: {
  keyData: JsonWebKey;
  algorithm: AlgorithmIdentifier | RsaHashedImportParams | EcKeyImportParams;
}): Promise<CryptoKey> {
  const WebCrypto = await getWebCrypto();

  const { keyData, algorithm } = opts;

  return WebCrypto.subtle.importKey('jwk', keyData, algorithm, false, [
    'verify',
  ]);
}