Skip to content

Commit

Permalink
✨ app: polyfill node buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
cruzdanilo committed Nov 8, 2024
1 parent 43776fe commit b4ae411
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/utils/polyfill.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
/* eslint-disable @typescript-eslint/no-unnecessary-condition */

import type * as crypto from "@peculiar/webcrypto";
import type * as buffer from "buffer"; // eslint-disable-line unicorn/prefer-node-protocol -- polyfill module
import "fast-text-encoding";

global.crypto ??= new (require("@peculiar/webcrypto").Crypto)(); // eslint-disable-line @typescript-eslint/no-require-imports, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access, unicorn/prefer-module
/* eslint-disable @typescript-eslint/no-unnecessary-condition */

global.Buffer ??= (require("buffer") as typeof buffer).Buffer; // eslint-disable-line @typescript-eslint/no-require-imports, unicorn/prefer-module, unicorn/prefer-node-protocol
global.crypto ??= new (require("@peculiar/webcrypto") as typeof crypto).Crypto(); // eslint-disable-line @typescript-eslint/no-require-imports, unicorn/prefer-module

if (global.window) {
// @ts-expect-error -- enough for mipd
Expand Down

0 comments on commit b4ae411

Please sign in to comment.