ses 0.18.3 → 0.18.5

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.
Files changed (49) hide show
  1. package/NEWS.md +16 -0
  2. package/README.md +105 -47
  3. package/dist/lockdown.cjs +6779 -6508
  4. package/dist/lockdown.mjs +6779 -6508
  5. package/dist/lockdown.umd.js +6779 -6508
  6. package/dist/lockdown.umd.min.js +1 -1
  7. package/dist/ses.cjs +6779 -6508
  8. package/dist/ses.mjs +6779 -6508
  9. package/dist/ses.umd.js +6779 -6508
  10. package/dist/ses.umd.min.js +1 -1
  11. package/index.js +1 -1
  12. package/package.json +17 -13
  13. package/src/commons.js +14 -11
  14. package/src/compartment-evaluate.js +1 -1
  15. package/src/compartment-shim.js +10 -14
  16. package/src/enable-property-overrides.js +4 -4
  17. package/src/error/assert.js +36 -9
  18. package/src/error/note-log-args.js +2 -4
  19. package/src/error/tame-console.js +1 -1
  20. package/src/error/tame-error-constructor.js +3 -3
  21. package/src/error/tame-v8-error-constructor.js +1 -1
  22. package/src/error/types.js +1 -0
  23. package/src/eval-scope.js +4 -2
  24. package/src/get-anonymous-intrinsics.js +25 -4
  25. package/src/global-object.js +2 -2
  26. package/src/intrinsics.js +14 -11
  27. package/src/lockdown-shim.js +13 -26
  28. package/src/make-hardener.js +8 -1
  29. package/src/make-safe-evaluator.js +6 -5
  30. package/src/module-instance.js +8 -11
  31. package/src/module-link.js +2 -2
  32. package/src/module-load.js +5 -7
  33. package/src/module-proxy.js +12 -12
  34. package/src/{whitelist-intrinsics.js → permits-intrinsics.js} +24 -20
  35. package/src/{whitelist.js → permits.js} +135 -8
  36. package/src/scope-constants.js +1 -0
  37. package/src/strict-scope-terminator.js +10 -4
  38. package/src/tame-date-constructor.js +1 -1
  39. package/src/tame-domains.js +2 -2
  40. package/src/tame-function-constructors.js +2 -2
  41. package/src/tame-function-tostring.js +1 -1
  42. package/src/tame-harden.js +7 -1
  43. package/src/tame-locale-methods.js +2 -2
  44. package/src/tame-math-object.js +1 -1
  45. package/src/tame-regexp-constructor.js +11 -2
  46. package/src/tame-symbol-constructor.js +65 -0
  47. package/src/transforms.js +3 -3
  48. package/types.d.ts +1 -0
  49. package/src/environment-options.js +0 -117
@@ -1,117 +0,0 @@
1
- // @ts-check
2
-
3
- // environment-options needs to be imported quite early, and so should
4
- // avoid importing from anything but commons.js and assert.js
5
- import { arrayPush, freeze } from './commons.js';
6
- import { assert } from './error/assert.js';
7
-
8
- const { Fail, quote: q } = assert;
9
-
10
- /**
11
- * JavaScript module semantics resists attempts to parameterize a module's
12
- * initialization behavior. A module initializes in order according to
13
- * the path by which it is first imported, and then the initialized module
14
- * is reused by all the other times it is imported. Compartments give us
15
- * the opportunity to bind the same import name to different imported
16
- * modules, depending on the package/compartment doing the import. Compartments
17
- * also address the difficulty of parameterizing a module's initialization
18
- * logic, but not in a pleasant manner.
19
- *
20
- * A pleasant parameterization would be for a static module to be function-like
21
- * with explicit parameters, and for the parameterization to be like
22
- * calling the static module with parameters in order to derive from it a
23
- * module instance. Compartments instead lets us parameterize the meaning
24
- * of a module instance derived from a static module according to the
25
- * three namespaces provided by the JavaScript semantics, affecting the
26
- * meaning of a module instance.
27
- * * The global variable namespaces.
28
- * * The global scope, aliased to properties of the global object.
29
- * This is necessarily compartment-wide, and therefore in our
30
- * recommened usage pattern, package-wide.
31
- * * The global lexical scope. The SES-shim compartments support
32
- * these both compartment-wide as well as per-module. But it is
33
- * not yet clear what we will propose in the Compartment proposal.
34
- * * The import namespace.
35
- * * The host hooks.
36
- *
37
- * This `environment-options.js` module looks for a setting of an
38
- * `optionName` parameter rooted in the global scope. If follows the Node
39
- * precedent for finding Unix environment variable settings, looking for a
40
- * global `process` object holding an `env` object,
41
- * optionally holding a property named for the `optionName` whose value is the
42
- * configuration setting of that option. For example, for the optionName
43
- * `FOO_BAR` it would look in
44
- * `globalThis.process.env.FOO_BAR`.
45
- *
46
- * If setting is either absent or `undefined`, that indicates that
47
- * this configuration option should have its default behavior, whatever that is.
48
- * Otherwise, reflecting Unix environment variables, the setting must be a
49
- * string. This also helps ensure that this channel is used only to pass data,
50
- * not authority beyond the ability to read this global state.
51
- */
52
-
53
- /**
54
- * makeEnvironmentCaptor provides a mechanism for getting environment
55
- * variables, if they are needed, and a way to catalog the names of all
56
- * the environment variables that were captured.
57
- *
58
- * @param {object} aGlobal
59
- */
60
- export const makeEnvironmentCaptor = aGlobal => {
61
- const capturedEnvironmentOptionNames = [];
62
-
63
- /**
64
- * Gets an environment option by name and returns the option value or the
65
- * given default.
66
- *
67
- * @param {string} optionName
68
- * @param {string} defaultSetting
69
- * @returns {string}
70
- */
71
- const getEnvironmentOption = (optionName, defaultSetting) => {
72
- // eslint-disable-next-line @endo/no-polymorphic-call
73
- typeof optionName === 'string' ||
74
- Fail`Environment option name ${q(optionName)} must be a string.`;
75
- // eslint-disable-next-line @endo/no-polymorphic-call
76
- typeof defaultSetting === 'string' ||
77
- Fail`Environment option default setting ${q(
78
- defaultSetting,
79
- )} must be a string.`;
80
-
81
- /** @type {string} */
82
- let setting = defaultSetting;
83
- const globalProcess = aGlobal.process;
84
- if (globalProcess && typeof globalProcess === 'object') {
85
- const globalEnv = globalProcess.env;
86
- if (globalEnv && typeof globalEnv === 'object') {
87
- if (optionName in globalEnv) {
88
- arrayPush(capturedEnvironmentOptionNames, optionName);
89
- const optionValue = globalEnv[optionName];
90
- // eslint-disable-next-line @endo/no-polymorphic-call
91
- typeof optionValue === 'string' ||
92
- Fail`Environment option named ${q(
93
- optionName,
94
- )}, if present, must have a corresponding string value, got ${q(
95
- optionValue,
96
- )}`;
97
- setting = optionValue;
98
- }
99
- }
100
- }
101
- setting === undefined ||
102
- typeof setting === 'string' ||
103
- Fail`Environment option value ${q(
104
- setting,
105
- )}, if present, must be a string.`;
106
- return setting;
107
- };
108
- freeze(getEnvironmentOption);
109
-
110
- const getCapturedEnvironmentOptionNames = () => {
111
- return freeze([...capturedEnvironmentOptionNames]);
112
- };
113
- freeze(getCapturedEnvironmentOptionNames);
114
-
115
- return freeze({ getEnvironmentOption, getCapturedEnvironmentOptionNames });
116
- };
117
- freeze(makeEnvironmentCaptor);