Skip to content

Commit

Permalink
refactor: Add isCryptoKey function to check crypto key
Browse files Browse the repository at this point in the history
  • Loading branch information
pawanpaudel93 committed Apr 24, 2024
1 parent 9721f2d commit 34d3234
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/lib/privateRepo.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import crypto from 'crypto';
import { getActivePublicKey } from './arweaveHelper';
import { getWallet, initArweave } from './common';
import { isCryptoKey } from 'util/types';

type PrivateState = {
iv: string;
Expand All @@ -12,6 +11,14 @@ type PrivateState = {

const arweave = initArweave();

function isCryptoKey(obj: any) {
try {
return obj instanceof CryptoKey;
} catch (e) {
return obj instanceof crypto.webcrypto.CryptoKey;
}
}

async function deriveAddress(publicKey: string) {
const pubKeyBuf = arweave.utils.b64UrlToBuffer(publicKey);
const sha512DigestBuf = await crypto.subtle.digest('SHA-512', pubKeyBuf);
Expand Down

0 comments on commit 34d3234

Please sign in to comment.