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 Dec 17, 2024
1 parent 5385fbf commit 309b5f7
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
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 barretenberg/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 barretenberg/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 309b5f7

Please sign in to comment.