Skip to content

Commit a645d0d

Browse files
fix: Add isSecureContext endowment (#2893)
Adds `isSecureContext` for the browser environments, this will continue to be undefined in the Node.js environment. Fixes #2890
1 parent 5052aaa commit a645d0d

File tree

4 files changed

+13
-0
lines changed

4 files changed

+13
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ const commonEndowments: CommonEndowmentSpecification[] = [
4242
{ endowment: Int8Array, name: 'Int8Array' },
4343
{ endowment: Int16Array, name: 'Int16Array' },
4444
{ endowment: Int32Array, name: 'Int32Array' },
45+
{ endowment: globalThis.isSecureContext, name: 'isSecureContext' },
4546
{ endowment: Uint8Array, name: 'Uint8Array' },
4647
{ endowment: Uint8ClampedArray, name: 'Uint8ClampedArray' },
4748
{ endowment: Uint16Array, name: 'Uint16Array' },

packages/snaps-execution-environments/src/common/endowments/endowments.test.browser.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,12 @@ describe('endowments', () => {
177177
factory: () => WebAssembly,
178178
},
179179

180+
// Properties
181+
isSecureContext: {
182+
endowments: { isSecureContext: globalThis.isSecureContext },
183+
factory: () => globalThis.isSecureContext,
184+
},
185+
180186
// Functions.
181187
atob: {
182188
endowments: { atob },
@@ -358,6 +364,10 @@ describe('endowments', () => {
358364
factory: expect.any(Function),
359365
names: ['Int32Array'],
360366
},
367+
{
368+
factory: expect.any(Function),
369+
names: ['isSecureContext'],
370+
},
361371
{
362372
factory: expect.any(Function),
363373
names: ['Uint8Array'],

packages/snaps-simulation/src/methods/specifications.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,7 @@ describe('getEndowments', () => {
333333
"Int16Array",
334334
"Uint16Array",
335335
"Int32Array",
336+
"isSecureContext",
336337
"Uint32Array",
337338
"Float32Array",
338339
"Float64Array",

packages/snaps-utils/src/default-endowments.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export const DEFAULT_ENDOWMENTS: readonly string[] = Object.freeze([
2323
'Int16Array',
2424
'Uint16Array',
2525
'Int32Array',
26+
'isSecureContext',
2627
'Uint32Array',
2728
'Float32Array',
2829
'Float64Array',

0 commit comments

Comments
 (0)