Skip to content

Commit

Permalink
♻️ Do not explicity import crypto in the lib file
Browse files Browse the repository at this point in the history
  • Loading branch information
Bernardstanislas committed Mar 23, 2023
1 parent 66dee8f commit 38ea9b8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
3 changes: 1 addition & 2 deletions src/lib/crypto.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import crypto from 'crypto';
const subtle = globalThis.crypto.subtle;

const subtle = crypto.subtle;
const encryption = {
name: 'RSA-OAEP'
};
Expand Down
7 changes: 7 additions & 0 deletions tests/setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import crypto from 'crypto';

Object.defineProperty(globalThis, 'crypto', {
value: {
subtle: crypto.webcrypto.subtle
}
});
3 changes: 2 additions & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { defineConfig } from 'vitest/config';
export default defineConfig({
plugins: [sveltekit()],
test: {
include: ['src/**/*.{test,spec}.{js,ts}']
include: ['src/**/*.{test,spec}.{js,ts}'],
setupFiles: 'tests/setup.ts'
}
});

1 comment on commit 38ea9b8

@vercel
Copy link

@vercel vercel bot commented on 38ea9b8 Mar 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.