Skip to content

Commit

Permalink
fix(bb.js): use globalThis instead of self (#10747)
Browse files Browse the repository at this point in the history
Fixes #10741
  • Loading branch information
olehmisar authored and AztecBot committed Dec 18, 2024
1 parent 9f6fda1 commit 54ce5ec
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ts/src/barretenberg_wasm/helpers/browser/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { wrap } from 'comlink';

export function getSharedMemoryAvailable() {
const globalScope = typeof window !== 'undefined' ? window : self;
const globalScope = typeof window !== 'undefined' ? window : globalThis;
return typeof SharedArrayBuffer !== 'undefined' && globalScope.crossOriginIsolated;
}

Expand Down
2 changes: 1 addition & 1 deletion ts/src/random/browser/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export const randomBytes = (len: number) => {
const getWebCrypto = () => {
if (typeof window !== 'undefined' && window.crypto) return window.crypto;
if (typeof self !== 'undefined' && self.crypto) return self.crypto;
if (typeof globalThis !== 'undefined' && globalThis.crypto) return globalThis.crypto;
return undefined;
};

Expand Down
1 change: 1 addition & 0 deletions ts/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export default {
path: resolve(dirname(fileURLToPath(import.meta.url)), './dest/browser'),
filename: 'index.js',
module: true,
globalObject: 'globalThis',
library: {
type: 'module',
},
Expand Down

0 comments on commit 54ce5ec

Please sign in to comment.