Skip to content

Commit 3f39337

Browse files
committed
Add assertions for crypto and SubtleCrypto
1 parent d607aef commit 3f39337

File tree

1 file changed

+12
-0
lines changed
  • packages/snaps-execution-environments/src/common/endowments

1 file changed

+12
-0
lines changed

packages/snaps-execution-environments/src/common/endowments/crypto.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
1+
import { assert } from '@metamask/utils';
2+
13
import { rootRealmGlobal } from '../globalObject';
24

35
export const createCrypto = () => {
6+
assert(
7+
rootRealmGlobal.crypto,
8+
'Crypto endowment requires `globalThis.crypto` to be defined.',
9+
);
10+
11+
assert(
12+
rootRealmGlobal.SubtleCrypto,
13+
'Crypto endowment requires `globalThis.SubtleCrypto` to be defined.',
14+
);
15+
416
return {
517
crypto: harden(rootRealmGlobal.crypto),
618
SubtleCrypto: harden(rootRealmGlobal.SubtleCrypto),

0 commit comments

Comments
 (0)