ses 2.1.0 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1454 -0
- package/README.md +4 -0
- package/dist/lockdown.cjs +1408 -641
- package/dist/lockdown.mjs +1408 -641
- package/dist/lockdown.umd.js +1408 -641
- package/dist/lockdown.umd.min.js +1 -1
- package/dist/ses-hermes.cjs +1408 -641
- package/dist/ses.cjs +1408 -641
- package/dist/ses.mjs +1408 -641
- package/dist/ses.umd.js +1408 -641
- package/dist/ses.umd.min.js +1 -1
- package/dist/types.d.cts +35 -2
- package/package.json +38 -9
- package/src/commons.js +1 -1
- package/src/compartment.js +7 -3
- package/src/enablements.js +48 -57
- package/src/error/assert.js +59 -14
- package/src/error/console.js +201 -30
- package/src/error/fatal-assert.js +2 -2
- package/src/error/stringify-utils.js +2 -4
- package/src/error/tame-console.js +0 -2
- package/src/error/tame-error-constructor.js +1 -1
- package/src/get-anonymous-intrinsics.js +0 -12
- package/src/lockdown.js +2 -0
- package/src/module-load.js +0 -2
- package/src/permits-intrinsics.js +18 -26
- package/src/permits.js +398 -32
- package/src/tame-faux-data-properties.js +1 -1
- package/src/tame-function-constructors.js +1 -1
- package/src/tame-nan-sidechannel.js +2 -2
- package/src/tame-temporal-object.js +75 -0
- package/types.d.ts +35 -2
package/src/permits.js
CHANGED
|
@@ -6,7 +6,7 @@ import { arrayPush, arrayForEach } from './commons.js';
|
|
|
6
6
|
/** @import {GenericErrorConstructor} from '../types.js' */
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
* Exports
|
|
9
|
+
* Exports `permits`, a recursively defined
|
|
10
10
|
* JSON record enumerating all intrinsics and their properties
|
|
11
11
|
* according to ECMA specs.
|
|
12
12
|
*
|
|
@@ -102,6 +102,15 @@ export const universalPropertyNames = {
|
|
|
102
102
|
JSON: 'JSON',
|
|
103
103
|
Reflect: 'Reflect',
|
|
104
104
|
|
|
105
|
+
// WHATWG Encoding Standard
|
|
106
|
+
// https://encoding.spec.whatwg.org/
|
|
107
|
+
// TextEncoder and TextDecoder are pure transformations between string and
|
|
108
|
+
// Uint8Array with no static side channels and no exposed iterator
|
|
109
|
+
// prototype. They are permitted universally; on hosts that do not provide
|
|
110
|
+
// them (XS), the sampling pass tolerates the absence.
|
|
111
|
+
TextEncoder: 'TextEncoder',
|
|
112
|
+
TextDecoder: 'TextDecoder',
|
|
113
|
+
|
|
105
114
|
// *** Annex B
|
|
106
115
|
|
|
107
116
|
escape: 'escape',
|
|
@@ -140,6 +149,7 @@ export const initialGlobalPropertyNames = {
|
|
|
140
149
|
// *** Other Properties of the Global Object
|
|
141
150
|
|
|
142
151
|
Math: '%InitialMath%',
|
|
152
|
+
Temporal: '%InitialTemporal%',
|
|
143
153
|
|
|
144
154
|
// We move these from universalPropertyNames because the NaN side channel
|
|
145
155
|
// means that they are not quite harmless.
|
|
@@ -186,6 +196,7 @@ export const sharedGlobalPropertyNames = {
|
|
|
186
196
|
// *** Other Properties of the Global Object
|
|
187
197
|
|
|
188
198
|
Math: '%SharedMath%',
|
|
199
|
+
Temporal: '%SharedTemporal%',
|
|
189
200
|
|
|
190
201
|
// TODO Temporal
|
|
191
202
|
// https://github.com/tc39/proposal-temporal
|
|
@@ -257,20 +268,20 @@ export { NativeErrors };
|
|
|
257
268
|
* are also considered blacklisted and are removed.
|
|
258
269
|
* <li>A string value equal to a primitive ("number", "string", etc),
|
|
259
270
|
* in which case the property is permitted if its value property
|
|
260
|
-
* is typeof the given type. For example,
|
|
261
|
-
* "number" and property values that fail
|
|
271
|
+
* is typeof the given type. For example, `Infinity` leads to
|
|
272
|
+
* "number" and property values that fail `typeof "number`.
|
|
262
273
|
* are removed.
|
|
263
274
|
* <li>A string value equal to an intinsic name ("ObjectPrototype",
|
|
264
275
|
* "Array", etc), in which case the property permitted if its
|
|
265
276
|
* value property is equal to the value of the corresponfing
|
|
266
|
-
* intrinsics. For example,
|
|
277
|
+
* intrinsics. For example, `Map.prototype` leads to
|
|
267
278
|
* "MapPrototype" and the property is removed if its value is
|
|
268
279
|
* not equal to %MapPrototype%
|
|
269
280
|
* <li>Another record, in which case this property is simply
|
|
270
281
|
* permitted and that next record represents the disposition of
|
|
271
|
-
* the object which is its value. For example,
|
|
272
|
-
* leads to another record explaining what properties
|
|
273
|
-
*
|
|
282
|
+
* the object which is its value. For example, `Object`
|
|
283
|
+
* leads to another record explaining what properties
|
|
284
|
+
* `Object` may have and how each such property should be treated.
|
|
274
285
|
*
|
|
275
286
|
* <p>Notes:
|
|
276
287
|
* <li>"[[Proto]]" is used to refer to the "[[Prototype]]" internal
|
|
@@ -866,7 +877,7 @@ export const permitted = {
|
|
|
866
877
|
setYear: fn,
|
|
867
878
|
toGMTString: fn,
|
|
868
879
|
|
|
869
|
-
toTemporalInstant:
|
|
880
|
+
toTemporalInstant: fn,
|
|
870
881
|
},
|
|
871
882
|
|
|
872
883
|
// Text Processing
|
|
@@ -1385,30 +1396,6 @@ export const permitted = {
|
|
|
1385
1396
|
immutable: getter,
|
|
1386
1397
|
},
|
|
1387
1398
|
|
|
1388
|
-
// If this exists, it is purely an artifact of how we currently shim
|
|
1389
|
-
// `transferToImmutable`. As natively implemented, there would be no
|
|
1390
|
-
// such extra prototype.
|
|
1391
|
-
'%ImmutableArrayBufferPrototype%': {
|
|
1392
|
-
'[[Proto]]': '%ArrayBufferPrototype%',
|
|
1393
|
-
byteLength: getter,
|
|
1394
|
-
slice: fn,
|
|
1395
|
-
// See https://github.com/endojs/endo/tree/master/packages/immutable-arraybuffer#purposeful-violation
|
|
1396
|
-
'@@toStringTag': 'string',
|
|
1397
|
-
// See https://github.com/tc39/proposal-resizablearraybuffer
|
|
1398
|
-
transfer: fn,
|
|
1399
|
-
resize: fn,
|
|
1400
|
-
resizable: getter,
|
|
1401
|
-
maxByteLength: getter,
|
|
1402
|
-
// https://github.com/tc39/proposal-arraybuffer-transfer
|
|
1403
|
-
transferToFixedLength: fn,
|
|
1404
|
-
detached: getter,
|
|
1405
|
-
// https://github.com/endojs/endo/pull/2309#issuecomment-2155513240
|
|
1406
|
-
// to be proposed
|
|
1407
|
-
transferToImmutable: fn,
|
|
1408
|
-
sliceToImmutable: fn,
|
|
1409
|
-
immutable: getter,
|
|
1410
|
-
},
|
|
1411
|
-
|
|
1412
1399
|
// SharedArrayBuffer Objects
|
|
1413
1400
|
SharedArrayBuffer: false, // UNSAFE and purposely suppressed.
|
|
1414
1401
|
'%SharedArrayBufferPrototype%': false, // UNSAFE and purposely suppressed.
|
|
@@ -1741,6 +1728,384 @@ export const permitted = {
|
|
|
1741
1728
|
revocable: fn,
|
|
1742
1729
|
},
|
|
1743
1730
|
|
|
1731
|
+
'%Temporal.PlainDatePrototype%': {
|
|
1732
|
+
constructor: '%Temporal.PlainDate%',
|
|
1733
|
+
era: accessor,
|
|
1734
|
+
eraYear: accessor,
|
|
1735
|
+
calendarId: accessor,
|
|
1736
|
+
year: accessor,
|
|
1737
|
+
month: accessor,
|
|
1738
|
+
monthCode: accessor,
|
|
1739
|
+
day: accessor,
|
|
1740
|
+
dayOfWeek: accessor,
|
|
1741
|
+
dayOfYear: accessor,
|
|
1742
|
+
weekOfYear: accessor,
|
|
1743
|
+
yearOfWeek: accessor,
|
|
1744
|
+
daysInWeek: accessor,
|
|
1745
|
+
daysInMonth: accessor,
|
|
1746
|
+
daysInYear: accessor,
|
|
1747
|
+
monthsInYear: accessor,
|
|
1748
|
+
inLeapYear: accessor,
|
|
1749
|
+
toPlainYearMonth: fn,
|
|
1750
|
+
toPlainMonthDay: fn,
|
|
1751
|
+
add: fn,
|
|
1752
|
+
subtract: fn,
|
|
1753
|
+
with: fn,
|
|
1754
|
+
withCalendar: fn,
|
|
1755
|
+
until: fn,
|
|
1756
|
+
since: fn,
|
|
1757
|
+
equals: fn,
|
|
1758
|
+
toPlainDateTime: fn,
|
|
1759
|
+
toZonedDateTime: fn,
|
|
1760
|
+
toString: fn,
|
|
1761
|
+
toLocaleString: fn,
|
|
1762
|
+
toJSON: fn,
|
|
1763
|
+
valueOf: fn,
|
|
1764
|
+
'@@toStringTag': 'string',
|
|
1765
|
+
},
|
|
1766
|
+
'%Temporal.PlainDate%': {
|
|
1767
|
+
'[[Proto]]': '%FunctionPrototype%',
|
|
1768
|
+
length: 'number',
|
|
1769
|
+
name: 'string',
|
|
1770
|
+
prototype: '%Temporal.PlainDatePrototype%',
|
|
1771
|
+
from: fn,
|
|
1772
|
+
compare: fn,
|
|
1773
|
+
},
|
|
1774
|
+
|
|
1775
|
+
'%Temporal.PlainTimePrototype%': {
|
|
1776
|
+
constructor: '%Temporal.PlainTime%',
|
|
1777
|
+
hour: accessor,
|
|
1778
|
+
minute: accessor,
|
|
1779
|
+
second: accessor,
|
|
1780
|
+
millisecond: accessor,
|
|
1781
|
+
microsecond: accessor,
|
|
1782
|
+
nanosecond: accessor,
|
|
1783
|
+
add: fn,
|
|
1784
|
+
subtract: fn,
|
|
1785
|
+
with: fn,
|
|
1786
|
+
until: fn,
|
|
1787
|
+
since: fn,
|
|
1788
|
+
round: fn,
|
|
1789
|
+
equals: fn,
|
|
1790
|
+
toLocaleString: fn,
|
|
1791
|
+
toString: fn,
|
|
1792
|
+
toJSON: fn,
|
|
1793
|
+
valueOf: fn,
|
|
1794
|
+
'@@toStringTag': 'string',
|
|
1795
|
+
},
|
|
1796
|
+
'%Temporal.PlainTime%': {
|
|
1797
|
+
'[[Proto]]': '%FunctionPrototype%',
|
|
1798
|
+
length: 'number',
|
|
1799
|
+
name: 'string',
|
|
1800
|
+
prototype: '%Temporal.PlainTimePrototype%',
|
|
1801
|
+
from: fn,
|
|
1802
|
+
compare: fn,
|
|
1803
|
+
},
|
|
1804
|
+
|
|
1805
|
+
'%Temporal.PlainDateTimePrototype%': {
|
|
1806
|
+
constructor: '%Temporal.PlainDateTime%',
|
|
1807
|
+
calendarId: accessor,
|
|
1808
|
+
era: accessor,
|
|
1809
|
+
eraYear: accessor,
|
|
1810
|
+
year: accessor,
|
|
1811
|
+
month: accessor,
|
|
1812
|
+
monthCode: accessor,
|
|
1813
|
+
day: accessor,
|
|
1814
|
+
hour: accessor,
|
|
1815
|
+
minute: accessor,
|
|
1816
|
+
second: accessor,
|
|
1817
|
+
millisecond: accessor,
|
|
1818
|
+
microsecond: accessor,
|
|
1819
|
+
nanosecond: accessor,
|
|
1820
|
+
dayOfWeek: accessor,
|
|
1821
|
+
dayOfYear: accessor,
|
|
1822
|
+
weekOfYear: accessor,
|
|
1823
|
+
yearOfWeek: accessor,
|
|
1824
|
+
daysInWeek: accessor,
|
|
1825
|
+
daysInMonth: accessor,
|
|
1826
|
+
daysInYear: accessor,
|
|
1827
|
+
monthsInYear: accessor,
|
|
1828
|
+
inLeapYear: accessor,
|
|
1829
|
+
with: fn,
|
|
1830
|
+
withCalendar: fn,
|
|
1831
|
+
withPlainTime: fn,
|
|
1832
|
+
add: fn,
|
|
1833
|
+
subtract: fn,
|
|
1834
|
+
until: fn,
|
|
1835
|
+
since: fn,
|
|
1836
|
+
round: fn,
|
|
1837
|
+
equals: fn,
|
|
1838
|
+
toLocaleString: fn,
|
|
1839
|
+
toJSON: fn,
|
|
1840
|
+
toString: fn,
|
|
1841
|
+
valueOf: fn,
|
|
1842
|
+
toZonedDateTime: fn,
|
|
1843
|
+
toPlainDate: fn,
|
|
1844
|
+
toPlainTime: fn,
|
|
1845
|
+
'@@toStringTag': 'string',
|
|
1846
|
+
},
|
|
1847
|
+
'%Temporal.PlainDateTime%': {
|
|
1848
|
+
'[[Proto]]': '%FunctionPrototype%',
|
|
1849
|
+
length: 'number',
|
|
1850
|
+
name: 'string',
|
|
1851
|
+
prototype: '%Temporal.PlainDateTimePrototype%',
|
|
1852
|
+
from: fn,
|
|
1853
|
+
compare: fn,
|
|
1854
|
+
},
|
|
1855
|
+
|
|
1856
|
+
'%Temporal.ZonedDateTimePrototype%': {
|
|
1857
|
+
constructor: '%Temporal.ZonedDateTime%',
|
|
1858
|
+
timeZoneId: accessor,
|
|
1859
|
+
calendarId: accessor,
|
|
1860
|
+
era: accessor,
|
|
1861
|
+
eraYear: accessor,
|
|
1862
|
+
year: accessor,
|
|
1863
|
+
month: accessor,
|
|
1864
|
+
monthCode: accessor,
|
|
1865
|
+
day: accessor,
|
|
1866
|
+
hour: accessor,
|
|
1867
|
+
minute: accessor,
|
|
1868
|
+
second: accessor,
|
|
1869
|
+
millisecond: accessor,
|
|
1870
|
+
microsecond: accessor,
|
|
1871
|
+
nanosecond: accessor,
|
|
1872
|
+
epochMilliseconds: accessor,
|
|
1873
|
+
epochNanoseconds: accessor,
|
|
1874
|
+
dayOfWeek: accessor,
|
|
1875
|
+
dayOfYear: accessor,
|
|
1876
|
+
weekOfYear: accessor,
|
|
1877
|
+
yearOfWeek: accessor,
|
|
1878
|
+
hoursInDay: accessor,
|
|
1879
|
+
daysInWeek: accessor,
|
|
1880
|
+
daysInMonth: accessor,
|
|
1881
|
+
daysInYear: accessor,
|
|
1882
|
+
monthsInYear: accessor,
|
|
1883
|
+
inLeapYear: accessor,
|
|
1884
|
+
offsetNanoseconds: accessor,
|
|
1885
|
+
offset: accessor,
|
|
1886
|
+
with: fn,
|
|
1887
|
+
withCalendar: fn,
|
|
1888
|
+
withPlainTime: fn,
|
|
1889
|
+
withTimeZone: fn,
|
|
1890
|
+
add: fn,
|
|
1891
|
+
subtract: fn,
|
|
1892
|
+
until: fn,
|
|
1893
|
+
since: fn,
|
|
1894
|
+
round: fn,
|
|
1895
|
+
equals: fn,
|
|
1896
|
+
toLocaleString: fn,
|
|
1897
|
+
toString: fn,
|
|
1898
|
+
toJSON: fn,
|
|
1899
|
+
valueOf: fn,
|
|
1900
|
+
startOfDay: fn,
|
|
1901
|
+
getTimeZoneTransition: fn,
|
|
1902
|
+
toInstant: fn,
|
|
1903
|
+
toPlainDate: fn,
|
|
1904
|
+
toPlainTime: fn,
|
|
1905
|
+
toPlainDateTime: fn,
|
|
1906
|
+
'@@toStringTag': 'string',
|
|
1907
|
+
},
|
|
1908
|
+
'%Temporal.ZonedDateTime%': {
|
|
1909
|
+
'[[Proto]]': '%FunctionPrototype%',
|
|
1910
|
+
length: 'number',
|
|
1911
|
+
name: 'string',
|
|
1912
|
+
prototype: '%Temporal.ZonedDateTimePrototype%',
|
|
1913
|
+
from: fn,
|
|
1914
|
+
compare: fn,
|
|
1915
|
+
},
|
|
1916
|
+
|
|
1917
|
+
'%Temporal.DurationPrototype%': {
|
|
1918
|
+
constructor: '%Temporal.Duration%',
|
|
1919
|
+
years: accessor,
|
|
1920
|
+
months: accessor,
|
|
1921
|
+
weeks: accessor,
|
|
1922
|
+
days: accessor,
|
|
1923
|
+
hours: accessor,
|
|
1924
|
+
minutes: accessor,
|
|
1925
|
+
seconds: accessor,
|
|
1926
|
+
milliseconds: accessor,
|
|
1927
|
+
microseconds: accessor,
|
|
1928
|
+
nanoseconds: accessor,
|
|
1929
|
+
sign: accessor,
|
|
1930
|
+
blank: accessor,
|
|
1931
|
+
with: fn,
|
|
1932
|
+
negated: fn,
|
|
1933
|
+
abs: fn,
|
|
1934
|
+
add: fn,
|
|
1935
|
+
subtract: fn,
|
|
1936
|
+
round: fn,
|
|
1937
|
+
total: fn,
|
|
1938
|
+
toLocaleString: fn,
|
|
1939
|
+
toString: fn,
|
|
1940
|
+
toJSON: fn,
|
|
1941
|
+
valueOf: fn,
|
|
1942
|
+
'@@toStringTag': 'string',
|
|
1943
|
+
},
|
|
1944
|
+
'%Temporal.Duration%': {
|
|
1945
|
+
'[[Proto]]': '%FunctionPrototype%',
|
|
1946
|
+
length: 'number',
|
|
1947
|
+
name: 'string',
|
|
1948
|
+
prototype: '%Temporal.DurationPrototype%',
|
|
1949
|
+
from: fn,
|
|
1950
|
+
compare: fn,
|
|
1951
|
+
},
|
|
1952
|
+
|
|
1953
|
+
'%Temporal.InstantPrototype%': {
|
|
1954
|
+
constructor: '%Temporal.Instant%',
|
|
1955
|
+
epochMilliseconds: accessor,
|
|
1956
|
+
epochNanoseconds: accessor,
|
|
1957
|
+
add: fn,
|
|
1958
|
+
subtract: fn,
|
|
1959
|
+
until: fn,
|
|
1960
|
+
since: fn,
|
|
1961
|
+
round: fn,
|
|
1962
|
+
equals: fn,
|
|
1963
|
+
toLocaleString: fn,
|
|
1964
|
+
toString: fn,
|
|
1965
|
+
toJSON: fn,
|
|
1966
|
+
valueOf: fn,
|
|
1967
|
+
toZonedDateTimeISO: fn,
|
|
1968
|
+
'@@toStringTag': 'string',
|
|
1969
|
+
},
|
|
1970
|
+
'%Temporal.Instant%': {
|
|
1971
|
+
'[[Proto]]': '%FunctionPrototype%',
|
|
1972
|
+
length: 'number',
|
|
1973
|
+
name: 'string',
|
|
1974
|
+
prototype: '%Temporal.InstantPrototype%',
|
|
1975
|
+
from: fn,
|
|
1976
|
+
fromEpochMilliseconds: fn,
|
|
1977
|
+
fromEpochNanoseconds: fn,
|
|
1978
|
+
compare: fn,
|
|
1979
|
+
},
|
|
1980
|
+
|
|
1981
|
+
'%Temporal.PlainYearMonthPrototype%': {
|
|
1982
|
+
constructor: '%Temporal.PlainYearMonth%',
|
|
1983
|
+
calendarId: accessor,
|
|
1984
|
+
era: accessor,
|
|
1985
|
+
eraYear: accessor,
|
|
1986
|
+
year: accessor,
|
|
1987
|
+
month: accessor,
|
|
1988
|
+
monthCode: accessor,
|
|
1989
|
+
daysInYear: accessor,
|
|
1990
|
+
daysInMonth: accessor,
|
|
1991
|
+
monthsInYear: accessor,
|
|
1992
|
+
inLeapYear: accessor,
|
|
1993
|
+
with: fn,
|
|
1994
|
+
add: fn,
|
|
1995
|
+
subtract: fn,
|
|
1996
|
+
until: fn,
|
|
1997
|
+
since: fn,
|
|
1998
|
+
equals: fn,
|
|
1999
|
+
toLocaleString: fn,
|
|
2000
|
+
toString: fn,
|
|
2001
|
+
toJSON: fn,
|
|
2002
|
+
valueOf: fn,
|
|
2003
|
+
toPlainDate: fn,
|
|
2004
|
+
'@@toStringTag': 'string',
|
|
2005
|
+
},
|
|
2006
|
+
'%Temporal.PlainYearMonth%': {
|
|
2007
|
+
'[[Proto]]': '%FunctionPrototype%',
|
|
2008
|
+
length: 'number',
|
|
2009
|
+
name: 'string',
|
|
2010
|
+
prototype: '%Temporal.PlainYearMonthPrototype%',
|
|
2011
|
+
from: fn,
|
|
2012
|
+
compare: fn,
|
|
2013
|
+
},
|
|
2014
|
+
|
|
2015
|
+
'%Temporal.PlainMonthDayPrototype%': {
|
|
2016
|
+
constructor: '%Temporal.PlainMonthDay%',
|
|
2017
|
+
calendarId: accessor,
|
|
2018
|
+
monthCode: accessor,
|
|
2019
|
+
day: accessor,
|
|
2020
|
+
with: fn,
|
|
2021
|
+
equals: fn,
|
|
2022
|
+
toLocaleString: fn,
|
|
2023
|
+
toString: fn,
|
|
2024
|
+
toJSON: fn,
|
|
2025
|
+
valueOf: fn,
|
|
2026
|
+
toPlainDate: fn,
|
|
2027
|
+
'@@toStringTag': 'string',
|
|
2028
|
+
},
|
|
2029
|
+
'%Temporal.PlainMonthDay%': {
|
|
2030
|
+
'[[Proto]]': '%FunctionPrototype%',
|
|
2031
|
+
length: 'number',
|
|
2032
|
+
name: 'string',
|
|
2033
|
+
prototype: '%Temporal.PlainMonthDayPrototype%',
|
|
2034
|
+
from: fn,
|
|
2035
|
+
},
|
|
2036
|
+
|
|
2037
|
+
'%Temporal.Now%': {
|
|
2038
|
+
instant: fn,
|
|
2039
|
+
timeZoneId: fn,
|
|
2040
|
+
plainDateTimeISO: fn,
|
|
2041
|
+
zonedDateTimeISO: fn,
|
|
2042
|
+
plainDateISO: fn,
|
|
2043
|
+
plainTimeISO: fn,
|
|
2044
|
+
'@@toStringTag': 'string',
|
|
2045
|
+
},
|
|
2046
|
+
|
|
2047
|
+
'%InitialTemporal%': {
|
|
2048
|
+
Now: '%Temporal.Now%',
|
|
2049
|
+
PlainDate: '%Temporal.PlainDate%',
|
|
2050
|
+
PlainTime: '%Temporal.PlainTime%',
|
|
2051
|
+
PlainDateTime: '%Temporal.PlainDateTime%',
|
|
2052
|
+
ZonedDateTime: '%Temporal.ZonedDateTime%',
|
|
2053
|
+
Duration: '%Temporal.Duration%',
|
|
2054
|
+
Instant: '%Temporal.Instant%',
|
|
2055
|
+
PlainYearMonth: '%Temporal.PlainYearMonth%',
|
|
2056
|
+
PlainMonthDay: '%Temporal.PlainMonthDay%',
|
|
2057
|
+
'@@toStringTag': 'string',
|
|
2058
|
+
},
|
|
2059
|
+
'%SharedTemporal%': {
|
|
2060
|
+
PlainDate: '%Temporal.PlainDate%',
|
|
2061
|
+
PlainTime: '%Temporal.PlainTime%',
|
|
2062
|
+
PlainDateTime: '%Temporal.PlainDateTime%',
|
|
2063
|
+
ZonedDateTime: '%Temporal.ZonedDateTime%',
|
|
2064
|
+
Duration: '%Temporal.Duration%',
|
|
2065
|
+
Instant: '%Temporal.Instant%',
|
|
2066
|
+
PlainYearMonth: '%Temporal.PlainYearMonth%',
|
|
2067
|
+
PlainMonthDay: '%Temporal.PlainMonthDay%',
|
|
2068
|
+
'@@toStringTag': 'string',
|
|
2069
|
+
},
|
|
2070
|
+
|
|
2071
|
+
// WHATWG Encoding Standard
|
|
2072
|
+
// https://encoding.spec.whatwg.org/
|
|
2073
|
+
|
|
2074
|
+
TextEncoder: {
|
|
2075
|
+
// Properties of the TextEncoder Constructor
|
|
2076
|
+
'[[Proto]]': '%FunctionPrototype%',
|
|
2077
|
+
prototype: '%TextEncoderPrototype%',
|
|
2078
|
+
},
|
|
2079
|
+
|
|
2080
|
+
'%TextEncoderPrototype%': {
|
|
2081
|
+
constructor: 'TextEncoder',
|
|
2082
|
+
encode: fn,
|
|
2083
|
+
encodeInto: fn,
|
|
2084
|
+
encoding: getter,
|
|
2085
|
+
'@@toStringTag': 'string',
|
|
2086
|
+
|
|
2087
|
+
// Non-standard property used by Node.js
|
|
2088
|
+
'RegisteredSymbol(nodejs.util.inspect.custom)': false,
|
|
2089
|
+
},
|
|
2090
|
+
|
|
2091
|
+
TextDecoder: {
|
|
2092
|
+
// Properties of the TextDecoder Constructor
|
|
2093
|
+
'[[Proto]]': '%FunctionPrototype%',
|
|
2094
|
+
prototype: '%TextDecoderPrototype%',
|
|
2095
|
+
},
|
|
2096
|
+
|
|
2097
|
+
'%TextDecoderPrototype%': {
|
|
2098
|
+
constructor: 'TextDecoder',
|
|
2099
|
+
decode: fn,
|
|
2100
|
+
encoding: getter,
|
|
2101
|
+
fatal: getter,
|
|
2102
|
+
ignoreBOM: getter,
|
|
2103
|
+
'@@toStringTag': 'string',
|
|
2104
|
+
|
|
2105
|
+
// Non-standard property used by Node.js
|
|
2106
|
+
'RegisteredSymbol(nodejs.util.inspect.custom)': false,
|
|
2107
|
+
},
|
|
2108
|
+
|
|
1744
2109
|
// Appendix B
|
|
1745
2110
|
|
|
1746
2111
|
// Annex B: Additional Properties of the Global Object
|
|
@@ -1771,6 +2136,7 @@ export const permitted = {
|
|
|
1771
2136
|
load: asyncFn,
|
|
1772
2137
|
importNow: fn,
|
|
1773
2138
|
module: fn,
|
|
2139
|
+
__noNamespaceBox__: getter,
|
|
1774
2140
|
'@@toStringTag': 'string',
|
|
1775
2141
|
},
|
|
1776
2142
|
|
|
@@ -49,7 +49,7 @@ export default function tameFunctionConstructors() {
|
|
|
49
49
|
// Verify that the method is not callable.
|
|
50
50
|
// eslint-disable-next-line @endo/no-polymorphic-call
|
|
51
51
|
FERAL_FUNCTION.prototype.constructor('return 1');
|
|
52
|
-
} catch (
|
|
52
|
+
} catch (_err) {
|
|
53
53
|
// Throws, no need to patch.
|
|
54
54
|
return freeze({});
|
|
55
55
|
}
|
|
@@ -46,7 +46,7 @@ const dataViewGetBuffer = uncurryThis(
|
|
|
46
46
|
*
|
|
47
47
|
* See https://github.com/endojs/endo/pull/3214#discussion_r3155852021
|
|
48
48
|
*/
|
|
49
|
-
const canonicalNaN64Encoding =
|
|
49
|
+
const canonicalNaN64Encoding = 0x7ff8_0000_0000_0000n;
|
|
50
50
|
|
|
51
51
|
/**
|
|
52
52
|
* As of this writing (April 29, 2026) all implementations agree that a
|
|
@@ -63,7 +63,7 @@ const canonicalNaN64Encoding = 0x7ff8000000000000n;
|
|
|
63
63
|
*
|
|
64
64
|
* See https://github.com/endojs/endo/pull/3214#discussion_r3155852021
|
|
65
65
|
*/
|
|
66
|
-
const canonicalNaN32Encoding =
|
|
66
|
+
const canonicalNaN32Encoding = 0x7fc0_0000;
|
|
67
67
|
|
|
68
68
|
/**
|
|
69
69
|
* As of this writing (April 29, 2026) all implementations that implement
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import {
|
|
2
|
+
freeze,
|
|
3
|
+
getOwnPropertyDescriptors,
|
|
4
|
+
create,
|
|
5
|
+
objectPrototype,
|
|
6
|
+
getPrototypeOf,
|
|
7
|
+
ownKeys,
|
|
8
|
+
fromEntries,
|
|
9
|
+
TypeError,
|
|
10
|
+
arrayPush,
|
|
11
|
+
Temporal, // may be undefined on old JS engines
|
|
12
|
+
} from './commons.js';
|
|
13
|
+
|
|
14
|
+
import { permitted } from './permits.js';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Tame the `Temporal` namespace object.
|
|
18
|
+
*
|
|
19
|
+
* The `%InitialTemporal%` is indeed the original `Temporal` namespace
|
|
20
|
+
* object, to remain present on the start compartment.
|
|
21
|
+
*
|
|
22
|
+
* The `%SharedTemporal%` is the safe shared `Temporal` namespace object,
|
|
23
|
+
* to be endowed by default on the gloabl of all constructed compartments.
|
|
24
|
+
* This differs only by the omission of `Temporal.Now`, which is the source of
|
|
25
|
+
* the dynamic non-determinism of the ever-changing current time, and the
|
|
26
|
+
* glacial dynamic non-determinism of current timezone and UTC offset (daylight
|
|
27
|
+
* savings time).
|
|
28
|
+
*
|
|
29
|
+
* The remaining source of glacial dynamic non-determinism is locale
|
|
30
|
+
* sensitivity, which `Temporal` provides only via `toLocaleString` methods.
|
|
31
|
+
* This is handled by `tame-locale-methods.js` in the same way as all other
|
|
32
|
+
* `*Locale*` methods.
|
|
33
|
+
*
|
|
34
|
+
* `tameTemporalObject` is modeletd on `tameMathObject` and `tameDateConstructor`
|
|
35
|
+
*/
|
|
36
|
+
const tameTemporalObject = () => {
|
|
37
|
+
if (Temporal === undefined) {
|
|
38
|
+
return {};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (typeof Temporal !== 'object') {
|
|
42
|
+
throw new TypeError(`unexpected typeof Temporal: ${typeof Temporal}`);
|
|
43
|
+
}
|
|
44
|
+
if (getPrototypeOf(Temporal) !== objectPrototype) {
|
|
45
|
+
throw new TypeError(
|
|
46
|
+
`unexpected Temporal __proto__: ${getPrototypeOf(Temporal)}`,
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const initialTemporal = Temporal;
|
|
51
|
+
const { Now: _, ...otherDescriptors } =
|
|
52
|
+
getOwnPropertyDescriptors(initialTemporal);
|
|
53
|
+
const sharedTemporal = create(objectPrototype, otherDescriptors);
|
|
54
|
+
|
|
55
|
+
const initialTemporalPermit = permitted['%InitialTemporal%'];
|
|
56
|
+
const intrinsicEntries = [];
|
|
57
|
+
for (const topName of ownKeys(Temporal)) {
|
|
58
|
+
const topPermitName = initialTemporalPermit[topName];
|
|
59
|
+
const topPermit = permitted[topPermitName];
|
|
60
|
+
if (typeof topPermit === 'object') {
|
|
61
|
+
const topVal = initialTemporal[topName];
|
|
62
|
+
arrayPush(intrinsicEntries, [topPermitName, topVal]);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const result = {
|
|
67
|
+
...fromEntries(intrinsicEntries),
|
|
68
|
+
'%InitialTemporal%': initialTemporal,
|
|
69
|
+
'%SharedTemporal%': sharedTemporal,
|
|
70
|
+
};
|
|
71
|
+
return result;
|
|
72
|
+
};
|
|
73
|
+
freeze(tameTemporalObject);
|
|
74
|
+
|
|
75
|
+
export default tameTemporalObject;
|
package/types.d.ts
CHANGED
|
@@ -132,6 +132,10 @@ export type ModuleDescriptor =
|
|
|
132
132
|
| PrecompiledModuleSource
|
|
133
133
|
| string;
|
|
134
134
|
|
|
135
|
+
export type StrictModuleDescriptor =
|
|
136
|
+
| SourceModuleDescriptor
|
|
137
|
+
| NamespaceModuleDescriptor;
|
|
138
|
+
|
|
135
139
|
// Deprecated type aliases:
|
|
136
140
|
export type PrecompiledStaticModuleInterface = PrecompiledModuleSource;
|
|
137
141
|
export type ThirdPartyStaticModuleInterface = VirtualModuleSource;
|
|
@@ -238,6 +242,11 @@ export interface AssertMakeErrorOptions {
|
|
|
238
242
|
* {@link sanitizeError}.
|
|
239
243
|
*/
|
|
240
244
|
sanitize?: boolean;
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* The error code to assign to the error.
|
|
248
|
+
*/
|
|
249
|
+
code?: string;
|
|
241
250
|
}
|
|
242
251
|
|
|
243
252
|
// TODO inline overloading
|
|
@@ -389,11 +398,33 @@ export interface AssertionUtilities {
|
|
|
389
398
|
* Create an error with a `message` in which unquoted {@link details}
|
|
390
399
|
* substitution values may have been redacted into lossy `typeof` output but
|
|
391
400
|
* are still available for logging to an associated console.
|
|
401
|
+
*
|
|
402
|
+
* Narrows the return type to the constructor type.
|
|
403
|
+
*
|
|
404
|
+
* @template T The constructor to use
|
|
405
|
+
* @param details The details of what was asserted
|
|
406
|
+
* @param errConstructor The constructor to use
|
|
407
|
+
* @param options Options
|
|
408
|
+
* @returns Instance of `T`
|
|
409
|
+
*/
|
|
410
|
+
makeError<T extends GenericErrorConstructor>(
|
|
411
|
+
details: Details,
|
|
412
|
+
errConstructor: T,
|
|
413
|
+
options?: AssertMakeErrorOptions,
|
|
414
|
+
): InstanceType<T>;
|
|
415
|
+
|
|
416
|
+
/**
|
|
417
|
+
* Create an error with a `message` in which unquoted {@link details}
|
|
418
|
+
* substitution values may have been redacted into lossy `typeof` output but
|
|
419
|
+
* are still available for logging to an associated console.
|
|
420
|
+
*
|
|
421
|
+
* @param details The details of what was asserted
|
|
422
|
+
* @param errConstructor The constructor to use
|
|
423
|
+
* @param options Options
|
|
424
|
+
* @returns Instance of `Error`
|
|
392
425
|
*/
|
|
393
426
|
makeError(
|
|
394
|
-
/** The details of what was asserted */
|
|
395
427
|
details?: Details,
|
|
396
|
-
/** An optional alternate error constructor to use */
|
|
397
428
|
errConstructor?: GenericErrorConstructor,
|
|
398
429
|
options?: AssertMakeErrorOptions,
|
|
399
430
|
): Error;
|
|
@@ -560,6 +591,8 @@ declare global {
|
|
|
560
591
|
|
|
561
592
|
get name(): string;
|
|
562
593
|
|
|
594
|
+
get __noNamespaceBox__(): boolean;
|
|
595
|
+
|
|
563
596
|
evaluate(code: string, options?: CompartmentEvaluateOptions): any;
|
|
564
597
|
|
|
565
598
|
import(
|