Skip to content

Commit

Permalink
chore: CryptoKey is exported separately and therefore this is redundant
Browse files Browse the repository at this point in the history
  • Loading branch information
maxholman committed Apr 23, 2023
1 parent 31a183b commit 512c5f9
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions lib/isomorphic-crypto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@ const impl = await (typeof globalThis !== 'undefined' && globalThis.crypto
? globalThis.crypto
: import('node:crypto'));

// we only export SubtleCrypto to make sure the interface remains the same
// we only export the values we use to keep things simple, we dont need a fully
// cross platform compatible crypto library
export const crypto = {
getRandomValues: <T extends Uint8Array>(array: T) =>
'webcrypto' in impl
? impl.webcrypto.getRandomValues(array)
: impl.getRandomValues(array),
CryptoKey:
'webcrypto' in impl ? impl.webcrypto.CryptoKey : globalThis.CryptoKey,
subtle: 'webcrypto' in impl ? impl.webcrypto.subtle : impl.subtle,
};

Expand Down

0 comments on commit 512c5f9

Please sign in to comment.