@nocobase/plugin-flow-engine 2.0.0-alpha.2
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/LICENSE +661 -0
- package/README.md +29 -0
- package/build.config.ts +22 -0
- package/client.d.ts +2 -0
- package/client.js +1 -0
- package/dist/client/index.d.ts +15 -0
- package/dist/client/index.js +10 -0
- package/dist/externalVersion.js +21 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +48 -0
- package/dist/locale/en-US.json +61 -0
- package/dist/locale/index.d.ts +141 -0
- package/dist/locale/index.js +79 -0
- package/dist/locale/zh-CN.json +61 -0
- package/dist/node_modules/ses/LICENSE +201 -0
- package/dist/node_modules/ses/LICENSE-aura +16 -0
- package/dist/node_modules/ses/LICENSE-caja +13 -0
- package/dist/node_modules/ses/LICENSE-corejs +19 -0
- package/dist/node_modules/ses/LICENSE-v8 +9 -0
- package/dist/node_modules/ses/assert-shim.js +1 -0
- package/dist/node_modules/ses/compartment-shim.js +1 -0
- package/dist/node_modules/ses/console-shim.js +1 -0
- package/dist/node_modules/ses/dist/lockdown.cjs +13912 -0
- package/dist/node_modules/ses/dist/lockdown.umd.js +13912 -0
- package/dist/node_modules/ses/dist/lockdown.umd.min.js +1 -0
- package/dist/node_modules/ses/dist/ses-hermes.cjs +13912 -0
- package/dist/node_modules/ses/dist/ses.cjs +1 -0
- package/dist/node_modules/ses/dist/ses.umd.js +13912 -0
- package/dist/node_modules/ses/dist/ses.umd.min.js +1 -0
- package/dist/node_modules/ses/dist/types.d.cts +606 -0
- package/dist/node_modules/ses/index.js +18 -0
- package/dist/node_modules/ses/lockdown-shim.js +1 -0
- package/dist/node_modules/ses/lockdown.js +1 -0
- package/dist/node_modules/ses/package.json +1 -0
- package/dist/node_modules/ses/src/assert-shim.js +4 -0
- package/dist/node_modules/ses/src/assert-sloppy-mode.js +11 -0
- package/dist/node_modules/ses/src/cauterize-property.js +69 -0
- package/dist/node_modules/ses/src/commons.js +425 -0
- package/dist/node_modules/ses/src/compartment-evaluate.js +93 -0
- package/dist/node_modules/ses/src/compartment-shim.js +22 -0
- package/dist/node_modules/ses/src/compartment.js +477 -0
- package/dist/node_modules/ses/src/console-shim.js +50 -0
- package/dist/node_modules/ses/src/enable-property-overrides.js +211 -0
- package/dist/node_modules/ses/src/enablements.js +244 -0
- package/dist/node_modules/ses/src/error/assert.js +584 -0
- package/dist/node_modules/ses/src/error/console.js +541 -0
- package/dist/node_modules/ses/src/error/fatal-assert.js +54 -0
- package/dist/node_modules/ses/src/error/internal-types.js +98 -0
- package/dist/node_modules/ses/src/error/note-log-args.js +77 -0
- package/dist/node_modules/ses/src/error/stringify-utils.js +195 -0
- package/dist/node_modules/ses/src/error/tame-console.js +197 -0
- package/dist/node_modules/ses/src/error/tame-error-constructor.js +284 -0
- package/dist/node_modules/ses/src/error/tame-v8-error-constructor.js +386 -0
- package/dist/node_modules/ses/src/error/types.js +59 -0
- package/dist/node_modules/ses/src/error/unhandled-rejection.js +122 -0
- package/dist/node_modules/ses/src/eval-scope.js +89 -0
- package/dist/node_modules/ses/src/get-anonymous-intrinsics.js +181 -0
- package/dist/node_modules/ses/src/get-source-url.js +50 -0
- package/dist/node_modules/ses/src/global-object.js +175 -0
- package/dist/node_modules/ses/src/intrinsics.js +192 -0
- package/dist/node_modules/ses/src/lockdown-shim.js +37 -0
- package/dist/node_modules/ses/src/lockdown.js +558 -0
- package/dist/node_modules/ses/src/make-eval-function.js +28 -0
- package/dist/node_modules/ses/src/make-evaluate.js +110 -0
- package/dist/node_modules/ses/src/make-function-constructor.js +79 -0
- package/dist/node_modules/ses/src/make-hardener.js +275 -0
- package/dist/node_modules/ses/src/make-safe-evaluator.js +112 -0
- package/dist/node_modules/ses/src/module-instance.js +497 -0
- package/dist/node_modules/ses/src/module-link.js +159 -0
- package/dist/node_modules/ses/src/module-load.js +719 -0
- package/dist/node_modules/ses/src/module-proxy.js +200 -0
- package/dist/node_modules/ses/src/permits-intrinsics.js +291 -0
- package/dist/node_modules/ses/src/permits.js +1761 -0
- package/dist/node_modules/ses/src/reporting-types.d.ts +13 -0
- package/dist/node_modules/ses/src/reporting.js +105 -0
- package/dist/node_modules/ses/src/scope-constants.js +180 -0
- package/dist/node_modules/ses/src/shim-arraybuffer-transfer.js +85 -0
- package/dist/node_modules/ses/src/sloppy-globals-scope-terminator.js +61 -0
- package/dist/node_modules/ses/src/strict-scope-terminator.js +99 -0
- package/dist/node_modules/ses/src/tame-date-constructor.js +127 -0
- package/dist/node_modules/ses/src/tame-domains.js +41 -0
- package/dist/node_modules/ses/src/tame-faux-data-properties.js +210 -0
- package/dist/node_modules/ses/src/tame-function-constructors.js +140 -0
- package/dist/node_modules/ses/src/tame-function-tostring.js +50 -0
- package/dist/node_modules/ses/src/tame-harden.js +29 -0
- package/dist/node_modules/ses/src/tame-locale-methods.js +78 -0
- package/dist/node_modules/ses/src/tame-math-object.js +41 -0
- package/dist/node_modules/ses/src/tame-module-source.js +51 -0
- package/dist/node_modules/ses/src/tame-regenerator-runtime.js +29 -0
- package/dist/node_modules/ses/src/tame-regexp-constructor.js +65 -0
- package/dist/node_modules/ses/src/tame-symbol-constructor.js +64 -0
- package/dist/node_modules/ses/src/transforms.js +267 -0
- package/dist/node_modules/ses/tools.js +25 -0
- package/dist/node_modules/ses/types.d.ts +606 -0
- package/dist/server/actions/ui-schema-action.d.ts +27 -0
- package/dist/server/actions/ui-schema-action.js +118 -0
- package/dist/server/collections/flowModelTreePath.d.ts +11 -0
- package/dist/server/collections/flowModelTreePath.js +74 -0
- package/dist/server/collections/flowModels.d.ts +11 -0
- package/dist/server/collections/flowModels.js +57 -0
- package/dist/server/collections/flowsql.d.ts +10 -0
- package/dist/server/collections/flowsql.js +51 -0
- package/dist/server/dao/ui_schema_node_dao.d.ts +26 -0
- package/dist/server/dao/ui_schema_node_dao.js +24 -0
- package/dist/server/helper.d.ts +8 -0
- package/dist/server/helper.js +9 -0
- package/dist/server/index.d.ts +9 -0
- package/dist/server/index.js +42 -0
- package/dist/server/model.d.ts +12 -0
- package/dist/server/model.js +38 -0
- package/dist/server/plugin.d.ts +26 -0
- package/dist/server/plugin.js +270 -0
- package/dist/server/repository.d.ts +116 -0
- package/dist/server/repository.js +1209 -0
- package/dist/server/server.d.ts +16 -0
- package/dist/server/server.js +198 -0
- package/dist/server/template/contexts.d.ts +73 -0
- package/dist/server/template/contexts.js +233 -0
- package/dist/server/template/resolver.d.ts +30 -0
- package/dist/server/template/resolver.js +225 -0
- package/dist/server/variables/registry.d.ts +42 -0
- package/dist/server/variables/registry.js +299 -0
- package/package.json +28 -0
- package/server.d.ts +2 -0
- package/server.js +1 -0
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
// Compartments need a mechanism to link a module from one compartment
|
|
2
|
+
// to another.
|
|
3
|
+
// The procedure is to use `compartment.module(specifier)` to obtain the module
|
|
4
|
+
// exports namespace from one compartment, possibly before importing or even
|
|
5
|
+
// merely loading module, and threading it into the module map of another
|
|
6
|
+
// compartment.
|
|
7
|
+
// For this to be possible, it is necessary to model the module exports
|
|
8
|
+
// namespace as a proxy that will treat all access to those exported properties
|
|
9
|
+
// as reference errors until the properties of the actual module are known.
|
|
10
|
+
// This provides the mechanism for modeling the public exports proxy
|
|
11
|
+
// and eventually connecting it to to the proxied exports.
|
|
12
|
+
|
|
13
|
+
import { makeAlias } from './module-load.js';
|
|
14
|
+
import {
|
|
15
|
+
Proxy,
|
|
16
|
+
TypeError,
|
|
17
|
+
create,
|
|
18
|
+
freeze,
|
|
19
|
+
mapGet,
|
|
20
|
+
mapHas,
|
|
21
|
+
mapSet,
|
|
22
|
+
ownKeys,
|
|
23
|
+
reflectGet,
|
|
24
|
+
reflectGetOwnPropertyDescriptor,
|
|
25
|
+
reflectHas,
|
|
26
|
+
reflectIsExtensible,
|
|
27
|
+
reflectPreventExtensions,
|
|
28
|
+
toStringTagSymbol,
|
|
29
|
+
weakmapSet,
|
|
30
|
+
} from './commons.js';
|
|
31
|
+
import { assert } from './error/assert.js';
|
|
32
|
+
|
|
33
|
+
const { quote: q } = assert;
|
|
34
|
+
|
|
35
|
+
// `deferExports` creates a module's exports proxy, proxied exports, and
|
|
36
|
+
// activator.
|
|
37
|
+
// A `Compartment` can create a module for any module specifier, regardless of
|
|
38
|
+
// whether it is loadable or executable, and use that object as a token that
|
|
39
|
+
// can be fed into another compartment's module map.
|
|
40
|
+
// Only after the specified module has been analyzed is it possible for the
|
|
41
|
+
// module namespace proxy to behave properly, so it throws exceptions until
|
|
42
|
+
// after the compartment has begun executing the module.
|
|
43
|
+
// The module instance must freeze the proxied exports and activate the exports
|
|
44
|
+
// proxy before executing the module.
|
|
45
|
+
//
|
|
46
|
+
// The module exports proxy's behavior differs from the ECMAScript 262
|
|
47
|
+
// specification for "module namespace exotic objects" only in that according
|
|
48
|
+
// to the specification value property descriptors have a non-writable "value"
|
|
49
|
+
// and this implementation models all properties with accessors.
|
|
50
|
+
//
|
|
51
|
+
// https://tc39.es/ecma262/#sec-module-namespace-exotic-objects
|
|
52
|
+
//
|
|
53
|
+
export const deferExports = () => {
|
|
54
|
+
let active = false;
|
|
55
|
+
const exportsTarget = create(null, {
|
|
56
|
+
// Make this appear like an ESM module namespace object.
|
|
57
|
+
[toStringTagSymbol]: {
|
|
58
|
+
value: 'Module',
|
|
59
|
+
writable: false,
|
|
60
|
+
enumerable: false,
|
|
61
|
+
configurable: false,
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
return freeze({
|
|
65
|
+
activate() {
|
|
66
|
+
active = true;
|
|
67
|
+
},
|
|
68
|
+
exportsTarget,
|
|
69
|
+
exportsProxy: new Proxy(exportsTarget, {
|
|
70
|
+
get(_target, name, receiver) {
|
|
71
|
+
if (!active) {
|
|
72
|
+
throw TypeError(
|
|
73
|
+
`Cannot get property ${q(
|
|
74
|
+
name,
|
|
75
|
+
)} of module exports namespace, the module has not yet begun to execute`,
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
return reflectGet(exportsTarget, name, receiver);
|
|
79
|
+
},
|
|
80
|
+
set(_target, name, _value) {
|
|
81
|
+
throw TypeError(
|
|
82
|
+
`Cannot set property ${q(name)} of module exports namespace`,
|
|
83
|
+
);
|
|
84
|
+
},
|
|
85
|
+
has(_target, name) {
|
|
86
|
+
if (!active) {
|
|
87
|
+
throw TypeError(
|
|
88
|
+
`Cannot check property ${q(
|
|
89
|
+
name,
|
|
90
|
+
)}, the module has not yet begun to execute`,
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
return reflectHas(exportsTarget, name);
|
|
94
|
+
},
|
|
95
|
+
deleteProperty(_target, name) {
|
|
96
|
+
throw TypeError(
|
|
97
|
+
`Cannot delete property ${q(name)}s of module exports namespace`,
|
|
98
|
+
);
|
|
99
|
+
},
|
|
100
|
+
ownKeys(_target) {
|
|
101
|
+
if (!active) {
|
|
102
|
+
throw TypeError(
|
|
103
|
+
'Cannot enumerate keys, the module has not yet begun to execute',
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
return ownKeys(exportsTarget);
|
|
107
|
+
},
|
|
108
|
+
getOwnPropertyDescriptor(_target, name) {
|
|
109
|
+
if (!active) {
|
|
110
|
+
throw TypeError(
|
|
111
|
+
`Cannot get own property descriptor ${q(
|
|
112
|
+
name,
|
|
113
|
+
)}, the module has not yet begun to execute`,
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
return reflectGetOwnPropertyDescriptor(exportsTarget, name);
|
|
117
|
+
},
|
|
118
|
+
preventExtensions(_target) {
|
|
119
|
+
if (!active) {
|
|
120
|
+
throw TypeError(
|
|
121
|
+
'Cannot prevent extensions of module exports namespace, the module has not yet begun to execute',
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
return reflectPreventExtensions(exportsTarget);
|
|
125
|
+
},
|
|
126
|
+
isExtensible() {
|
|
127
|
+
if (!active) {
|
|
128
|
+
throw TypeError(
|
|
129
|
+
'Cannot check extensibility of module exports namespace, the module has not yet begun to execute',
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
return reflectIsExtensible(exportsTarget);
|
|
133
|
+
},
|
|
134
|
+
getPrototypeOf(_target) {
|
|
135
|
+
return null;
|
|
136
|
+
},
|
|
137
|
+
setPrototypeOf(_target, _proto) {
|
|
138
|
+
throw TypeError('Cannot set prototype of module exports namespace');
|
|
139
|
+
},
|
|
140
|
+
defineProperty(_target, name, _descriptor) {
|
|
141
|
+
throw TypeError(
|
|
142
|
+
`Cannot define property ${q(name)} of module exports namespace`,
|
|
143
|
+
);
|
|
144
|
+
},
|
|
145
|
+
apply(_target, _thisArg, _args) {
|
|
146
|
+
throw TypeError(
|
|
147
|
+
'Cannot call module exports namespace, it is not a function',
|
|
148
|
+
);
|
|
149
|
+
},
|
|
150
|
+
construct(_target, _args) {
|
|
151
|
+
throw TypeError(
|
|
152
|
+
'Cannot construct module exports namespace, it is not a constructor',
|
|
153
|
+
);
|
|
154
|
+
},
|
|
155
|
+
}),
|
|
156
|
+
});
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* @typedef {object} DeferredExports
|
|
161
|
+
* @property {Record<string, any>} exportsTarget - The object to which a
|
|
162
|
+
* module's exports will be added.
|
|
163
|
+
* @property {Record<string, any>} exportsProxy - A proxy over the `exportsTarget`,
|
|
164
|
+
* used to expose its "exports" to other compartments.
|
|
165
|
+
* @property {() => void} activate - Activate the `exportsProxy` such that it can
|
|
166
|
+
* be used as a module namespace object.
|
|
167
|
+
*/
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Memoizes the creation of a deferred module exports namespace proxy for any
|
|
171
|
+
* arbitrary full specifier in a compartment. It also records the compartment
|
|
172
|
+
* and specifier affiliated with that module exports namespace proxy so it
|
|
173
|
+
* can be used as an alias into another compartment when threaded through
|
|
174
|
+
* a compartment's `moduleMap` argument.
|
|
175
|
+
*
|
|
176
|
+
* @param {*} compartment - The compartment to retrieve deferred exports from.
|
|
177
|
+
* @param {*} compartmentPrivateFields - The private fields of the compartment.
|
|
178
|
+
* @param {*} moduleAliases - The module aliases of the compartment.
|
|
179
|
+
* @param {string} specifier - The module specifier to retrieve deferred exports for.
|
|
180
|
+
* @returns {DeferredExports} - The deferred exports for the module specifier of
|
|
181
|
+
* the compartment.
|
|
182
|
+
*/
|
|
183
|
+
export const getDeferredExports = (
|
|
184
|
+
compartment,
|
|
185
|
+
compartmentPrivateFields,
|
|
186
|
+
moduleAliases,
|
|
187
|
+
specifier,
|
|
188
|
+
) => {
|
|
189
|
+
const { deferredExports } = compartmentPrivateFields;
|
|
190
|
+
if (!mapHas(deferredExports, specifier)) {
|
|
191
|
+
const deferred = deferExports();
|
|
192
|
+
weakmapSet(
|
|
193
|
+
moduleAliases,
|
|
194
|
+
deferred.exportsProxy,
|
|
195
|
+
makeAlias(compartment, specifier),
|
|
196
|
+
);
|
|
197
|
+
mapSet(deferredExports, specifier, deferred);
|
|
198
|
+
}
|
|
199
|
+
return mapGet(deferredExports, specifier);
|
|
200
|
+
};
|
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
// Copyright (C) 2011 Google Inc.
|
|
2
|
+
// Copyright (C) 2018 Agoric
|
|
3
|
+
//
|
|
4
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
// you may not use this file except in compliance with the License.
|
|
6
|
+
// You may obtain a copy of the License at
|
|
7
|
+
//
|
|
8
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
//
|
|
10
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
// See the License for the specific language governing permissions and
|
|
14
|
+
// limitations under the License.
|
|
15
|
+
|
|
16
|
+
// This module removes all non-allowed properties found by recursively and
|
|
17
|
+
// reflectively walking own property chains.
|
|
18
|
+
//
|
|
19
|
+
// The prototype properties are type checked.
|
|
20
|
+
//
|
|
21
|
+
// In addition, it verifies that the `prototype`, `__proto__`, and
|
|
22
|
+
// `constructor` properties do point to their allowed values.
|
|
23
|
+
//
|
|
24
|
+
// Typically, this module will not be used directly, but via the
|
|
25
|
+
// [lockdown-shim] which handles all necessary repairs and taming in SES.
|
|
26
|
+
//
|
|
27
|
+
// In the permits, the `prototype`, `__proto__`, and `constructor` must be
|
|
28
|
+
// specified and point to top level entries in the map. For example,
|
|
29
|
+
// `Object.__proto__` leads to `FunctionPrototype` which is a top level entry
|
|
30
|
+
// in the map.
|
|
31
|
+
//
|
|
32
|
+
// The permit value must be
|
|
33
|
+
// * the typeof name of a primitive for type-checking (for example,
|
|
34
|
+
// `Error.stackTraceLimit` leads to 'number'),
|
|
35
|
+
// * the name of an intrinsic,
|
|
36
|
+
// * an internal constant(for example, `eval` leads to `fn` which
|
|
37
|
+
// is an alias for `FunctionInstance`, a record that permits all
|
|
38
|
+
// properties allowed on such instance).
|
|
39
|
+
// * false, a property to be removed that we know about.
|
|
40
|
+
//
|
|
41
|
+
// All unlisted properties are also removed. But for the ones that are removed
|
|
42
|
+
// because they are unlisted, as opposed to `false`, we also print their
|
|
43
|
+
// name to the console as a useful diagnostic, possibly provoking an expansion
|
|
44
|
+
// of the permits.
|
|
45
|
+
|
|
46
|
+
import { permitted, FunctionInstance, isAccessorPermit } from './permits.js';
|
|
47
|
+
import {
|
|
48
|
+
Map,
|
|
49
|
+
String,
|
|
50
|
+
Symbol,
|
|
51
|
+
TypeError,
|
|
52
|
+
arrayFilter,
|
|
53
|
+
arrayIncludes,
|
|
54
|
+
arrayMap,
|
|
55
|
+
entries,
|
|
56
|
+
getOwnPropertyDescriptor,
|
|
57
|
+
getPrototypeOf,
|
|
58
|
+
isPrimitive,
|
|
59
|
+
mapGet,
|
|
60
|
+
hasOwn,
|
|
61
|
+
ownKeys,
|
|
62
|
+
symbolKeyFor,
|
|
63
|
+
} from './commons.js';
|
|
64
|
+
import { cauterizeProperty } from './cauterize-property.js';
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* @import {Reporter} from './reporting-types.js'
|
|
68
|
+
*/
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Removes all non-allowed properties found by recursively and
|
|
72
|
+
* reflectively walking own property chains.
|
|
73
|
+
*
|
|
74
|
+
* @param {object} intrinsics
|
|
75
|
+
* @param {(virtualizedNativeFunction: object) => void} markVirtualizedNativeFunction
|
|
76
|
+
* @param {Reporter} reporter
|
|
77
|
+
*/
|
|
78
|
+
export default function removeUnpermittedIntrinsics(
|
|
79
|
+
intrinsics,
|
|
80
|
+
markVirtualizedNativeFunction,
|
|
81
|
+
reporter,
|
|
82
|
+
) {
|
|
83
|
+
// These primitives are allowed for permits.
|
|
84
|
+
const primitives = ['undefined', 'boolean', 'number', 'string', 'symbol'];
|
|
85
|
+
|
|
86
|
+
// These symbols are allowed as well-known symbols
|
|
87
|
+
const wellKnownSymbolNames = new Map(
|
|
88
|
+
Symbol
|
|
89
|
+
? arrayMap(
|
|
90
|
+
arrayFilter(
|
|
91
|
+
entries(permitted['%SharedSymbol%']),
|
|
92
|
+
([name, permit]) =>
|
|
93
|
+
permit === 'symbol' && typeof Symbol[name] === 'symbol',
|
|
94
|
+
),
|
|
95
|
+
([name]) => [Symbol[name], `@@${name}`],
|
|
96
|
+
)
|
|
97
|
+
: [],
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* asStringPropertyName()
|
|
102
|
+
*
|
|
103
|
+
* @param {string} path
|
|
104
|
+
* @param {string | symbol} prop
|
|
105
|
+
*/
|
|
106
|
+
function asStringPropertyName(path, prop) {
|
|
107
|
+
if (typeof prop === 'string') {
|
|
108
|
+
return prop;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const wellKnownSymbol = mapGet(wellKnownSymbolNames, prop);
|
|
112
|
+
|
|
113
|
+
if (typeof prop === 'symbol') {
|
|
114
|
+
if (wellKnownSymbol) {
|
|
115
|
+
return wellKnownSymbol;
|
|
116
|
+
} else {
|
|
117
|
+
const registeredKey = symbolKeyFor(prop);
|
|
118
|
+
if (registeredKey !== undefined) {
|
|
119
|
+
return `RegisteredSymbol(${registeredKey})`;
|
|
120
|
+
} else {
|
|
121
|
+
return `Unique${String(prop)}`;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
throw TypeError(`Unexpected property name type ${path} ${prop}`);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/*
|
|
130
|
+
* visitPrototype()
|
|
131
|
+
* Validate the object's [[prototype]] against a permit.
|
|
132
|
+
*/
|
|
133
|
+
function visitPrototype(path, obj, protoName) {
|
|
134
|
+
if (isPrimitive(obj)) {
|
|
135
|
+
throw TypeError(`Object expected: ${path}, ${String(obj)}, ${protoName}`);
|
|
136
|
+
}
|
|
137
|
+
const proto = getPrototypeOf(obj);
|
|
138
|
+
|
|
139
|
+
// Null prototype.
|
|
140
|
+
if (proto === null && protoName === null) {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// Assert: protoName, if provided, is a string.
|
|
145
|
+
if (protoName !== undefined && typeof protoName !== 'string') {
|
|
146
|
+
throw TypeError(`Malformed permit ${path}.__proto__`);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// If permit not specified, default to Object.prototype.
|
|
150
|
+
if (proto === intrinsics[protoName || '%ObjectPrototype%']) {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// We can't clean [[Prototype]], therefore abort.
|
|
155
|
+
throw TypeError(
|
|
156
|
+
`Unexpected [[Prototype]] at ${path}.__proto__ (expected ${protoName || '%ObjectPrototype%'})`,
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/*
|
|
161
|
+
* isAllowedPropertyValue()
|
|
162
|
+
* enforce permit for a single property value.
|
|
163
|
+
*/
|
|
164
|
+
function isAllowedPropertyValue(path, value, prop, permit) {
|
|
165
|
+
if (typeof permit === 'object') {
|
|
166
|
+
// eslint-disable-next-line no-use-before-define
|
|
167
|
+
visitProperties(path, value, permit);
|
|
168
|
+
// The property is allowed.
|
|
169
|
+
return true;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
if (permit === false) {
|
|
173
|
+
// A boolan 'false' permit specifies the removal of a property.
|
|
174
|
+
// We require a more specific permit instead of allowing 'true'.
|
|
175
|
+
return false;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
if (typeof permit === 'string') {
|
|
179
|
+
// A string permit can have one of two meanings:
|
|
180
|
+
|
|
181
|
+
if (prop === 'prototype' || prop === 'constructor') {
|
|
182
|
+
// For prototype and constructor value properties, the permit
|
|
183
|
+
// is the name of an intrinsic.
|
|
184
|
+
// Assumption: prototype and constructor cannot be primitives.
|
|
185
|
+
// Assert: the permit is the name of an intrinsic.
|
|
186
|
+
// Assert: the property value is equal to that intrinsic.
|
|
187
|
+
|
|
188
|
+
if (hasOwn(intrinsics, permit)) {
|
|
189
|
+
if (value !== intrinsics[permit]) {
|
|
190
|
+
throw TypeError(`Does not match permit for ${path}`);
|
|
191
|
+
}
|
|
192
|
+
return true;
|
|
193
|
+
}
|
|
194
|
+
} else {
|
|
195
|
+
// For all other properties, the permit is the name of a primitive.
|
|
196
|
+
// Assert: the permit is the name of a primitive.
|
|
197
|
+
// Assert: the property value type is equal to that primitive.
|
|
198
|
+
|
|
199
|
+
// eslint-disable-next-line no-lonely-if
|
|
200
|
+
if (arrayIncludes(primitives, permit)) {
|
|
201
|
+
// eslint-disable-next-line valid-typeof
|
|
202
|
+
if (typeof value !== permit) {
|
|
203
|
+
throw TypeError(
|
|
204
|
+
`At ${path} expected ${permit} not ${typeof value}`,
|
|
205
|
+
);
|
|
206
|
+
}
|
|
207
|
+
return true;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
throw TypeError(
|
|
213
|
+
`Unexpected property ${prop} with permit ${permit} at ${path}`,
|
|
214
|
+
);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/*
|
|
218
|
+
* isAllowedProperty()
|
|
219
|
+
* Check whether a single property is allowed.
|
|
220
|
+
*/
|
|
221
|
+
function isAllowedProperty(path, obj, prop, permit) {
|
|
222
|
+
const desc = getOwnPropertyDescriptor(obj, prop);
|
|
223
|
+
if (!desc) {
|
|
224
|
+
throw TypeError(`Property ${prop} not found at ${path}`);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
// Is this a value property?
|
|
228
|
+
if (hasOwn(desc, 'value')) {
|
|
229
|
+
if (isAccessorPermit(permit)) {
|
|
230
|
+
throw TypeError(`Accessor expected at ${path}`);
|
|
231
|
+
}
|
|
232
|
+
return isAllowedPropertyValue(path, desc.value, prop, permit);
|
|
233
|
+
}
|
|
234
|
+
if (!isAccessorPermit(permit)) {
|
|
235
|
+
throw TypeError(`Accessor not expected at ${path}`);
|
|
236
|
+
}
|
|
237
|
+
return (
|
|
238
|
+
isAllowedPropertyValue(`${path}<get>`, desc.get, prop, permit.get) &&
|
|
239
|
+
isAllowedPropertyValue(`${path}<set>`, desc.set, prop, permit.set)
|
|
240
|
+
);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/*
|
|
244
|
+
* getSubPermit()
|
|
245
|
+
*/
|
|
246
|
+
function getSubPermit(obj, permit, prop) {
|
|
247
|
+
const permitProp = prop === '__proto__' ? '--proto--' : prop;
|
|
248
|
+
if (hasOwn(permit, permitProp)) {
|
|
249
|
+
return permit[permitProp];
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
if (typeof obj === 'function') {
|
|
253
|
+
if (hasOwn(FunctionInstance, permitProp)) {
|
|
254
|
+
return FunctionInstance[permitProp];
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
return undefined;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/*
|
|
262
|
+
* visitProperties()
|
|
263
|
+
* Visit all properties for a permit.
|
|
264
|
+
*/
|
|
265
|
+
function visitProperties(path, obj, permit) {
|
|
266
|
+
if (obj === undefined || obj === null) {
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
const protoName = permit['[[Proto]]'];
|
|
271
|
+
visitPrototype(path, obj, protoName);
|
|
272
|
+
|
|
273
|
+
if (typeof obj === 'function') {
|
|
274
|
+
markVirtualizedNativeFunction(obj);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
for (const prop of ownKeys(obj)) {
|
|
278
|
+
const propString = asStringPropertyName(path, prop);
|
|
279
|
+
const subPath = `${path}.${propString}`;
|
|
280
|
+
const subPermit = getSubPermit(obj, permit, propString);
|
|
281
|
+
|
|
282
|
+
if (!subPermit || !isAllowedProperty(subPath, obj, prop, subPermit)) {
|
|
283
|
+
cauterizeProperty(obj, prop, subPermit === false, subPath, reporter);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
// Start path with 'intrinsics' to clarify that properties are not
|
|
289
|
+
// removed from the global object by the permitting operation.
|
|
290
|
+
visitProperties('intrinsics', intrinsics, permitted);
|
|
291
|
+
}
|