@endo/module-source 1.2.0 → 1.3.1
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 +1 -1
- package/SECURITY.md +2 -2
- package/package.json +11 -11
- package/src/{babelPlugin.d.ts → babel-plugin.d.ts} +1 -1
- package/src/babel-plugin.d.ts.map +1 -0
- package/src/{babelPlugin.js → babel-plugin.js} +2 -0
- package/src/hidden.d.ts +2 -2
- package/src/hidden.d.ts.map +1 -1
- package/src/module-source.d.ts +2 -2
- package/src/module-source.d.ts.map +1 -1
- package/src/transform-analyze.d.ts.map +1 -1
- package/src/transform-analyze.js +7 -15
- package/src/transform-source.d.ts +2 -0
- package/src/transform-source.d.ts.map +1 -0
- package/src/{transformSource.js → transform-source.js} +19 -10
- package/src/babelPlugin.d.ts.map +0 -1
- package/src/transformSource.d.ts +0 -2
- package/src/transformSource.d.ts.map +0 -1
package/LICENSE
CHANGED
|
@@ -186,7 +186,7 @@
|
|
|
186
186
|
same "printed page" as the copyright notice for easier
|
|
187
187
|
identification within third-party archives.
|
|
188
188
|
|
|
189
|
-
Copyright
|
|
189
|
+
Copyright 2024 Endo Contributors
|
|
190
190
|
|
|
191
191
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
192
|
you may not use this file except in compliance with the License.
|
package/SECURITY.md
CHANGED
|
@@ -8,9 +8,9 @@ be made for the most recent branch only.
|
|
|
8
8
|
|
|
9
9
|
## Coordinated Vulnerability Disclosure of Security Bugs
|
|
10
10
|
|
|
11
|
-
SES stands for fearless cooperation, and strong security requires strong collaboration with security researchers. If you believe that you have found a security sensitive bug that should not be disclosed until a fix has been made available, we encourage you to report it. To report a bug in HardenedJS, you have several options that include:
|
|
11
|
+
SES stands for fearless cooperation, and strong security requires strong collaboration with security researchers. If you believe that you have found a security sensitive bug that should not be disclosed until a fix has been made available, we encourage you to report it. To report a bug in HardenedJS, you have several options that include:
|
|
12
12
|
|
|
13
|
-
* Reporting the issue to the [Agoric HackerOne vulnerability rewards program](https://hackerone.com/agoric).
|
|
13
|
+
* Reporting the issue to the [Agoric HackerOne vulnerability rewards program](https://hackerone.com/agoric).
|
|
14
14
|
|
|
15
15
|
* Sending an email to security at (@) agoric.com., encrypted or unencrypted. To encrypt, please use @Warner’s personal GPG key [A476E2E6 11880C98 5B3C3A39 0386E81B 11CAA07A](http://www.lothar.com/warner-gpg.html) .
|
|
16
16
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@endo/module-source",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"description": "Ponyfill for the SES ModuleSource and module-to-program transformer",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ses",
|
|
@@ -42,24 +42,24 @@
|
|
|
42
42
|
"test:xs": "node scripts/generate-test-xs.js && xst tmp/test-xs.js"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@
|
|
46
|
-
"@babel/parser": "
|
|
47
|
-
"@babel/traverse": "
|
|
48
|
-
"@babel/types": "
|
|
49
|
-
"ses": "^1.
|
|
45
|
+
"@babel/generator": "^7.26.3",
|
|
46
|
+
"@babel/parser": "~7.26.2",
|
|
47
|
+
"@babel/traverse": "~7.25.9",
|
|
48
|
+
"@babel/types": "~7.26.0",
|
|
49
|
+
"ses": "^1.13.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"ava": "^6.1.3",
|
|
53
53
|
"babel-eslint": "^10.1.0",
|
|
54
54
|
"benchmark": "^2.1.4",
|
|
55
55
|
"c8": "^7.14.0",
|
|
56
|
-
"eslint": "^8.57.
|
|
56
|
+
"eslint": "^8.57.1",
|
|
57
57
|
"eslint-config-airbnb-base": "^15.0.0",
|
|
58
58
|
"eslint-config-prettier": "^9.1.0",
|
|
59
59
|
"eslint-plugin-eslint-comments": "^3.2.0",
|
|
60
|
-
"eslint-plugin-import": "^2.
|
|
61
|
-
"prettier": "^3.
|
|
62
|
-
"typescript": "~5.
|
|
60
|
+
"eslint-plugin-import": "^2.31.0",
|
|
61
|
+
"prettier": "^3.5.3",
|
|
62
|
+
"typescript": "~5.8.3"
|
|
63
63
|
},
|
|
64
64
|
"files": [
|
|
65
65
|
"./*.d.ts",
|
|
@@ -89,5 +89,5 @@
|
|
|
89
89
|
"typeCoverage": {
|
|
90
90
|
"atLeast": 40.33
|
|
91
91
|
},
|
|
92
|
-
"gitHead": "
|
|
92
|
+
"gitHead": "571b7803cf10df7cb4fa9d70e4d53a0b53767fa8"
|
|
93
93
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"babel-plugin.d.ts","sourceRoot":"","sources":["babel-plugin.js"],"names":[],"mappings":";AA0CA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA+kBC"}
|
|
@@ -31,6 +31,8 @@ const collectPatternIdentifiers = (path, pattern) => {
|
|
|
31
31
|
// Non-elided pattern.
|
|
32
32
|
return collectPatternIdentifiers(path, pat);
|
|
33
33
|
});
|
|
34
|
+
case 'AssignmentPattern':
|
|
35
|
+
return collectPatternIdentifiers(path, pattern.left);
|
|
34
36
|
default:
|
|
35
37
|
throw path.buildCodeFrameError(
|
|
36
38
|
`Pattern type ${pattern.type} is not recognized`,
|
package/src/hidden.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export const HIDDEN_PREFIX: "$h
|
|
2
|
-
export const HIDDEN_CONST_VAR_PREFIX: "$c
|
|
1
|
+
export const HIDDEN_PREFIX: "$h\u034F_";
|
|
2
|
+
export const HIDDEN_CONST_VAR_PREFIX: "$c\u034F_";
|
|
3
3
|
export const HIDDEN_A: "$h͏_a";
|
|
4
4
|
export const HIDDEN_IMPORT: "$h͏_import";
|
|
5
5
|
export const HIDDEN_IMPORT_SELF: "$h͏_importSelf";
|
package/src/hidden.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hidden.d.ts","sourceRoot":"","sources":["hidden.js"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"hidden.d.ts","sourceRoot":"","sources":["hidden.js"],"names":[],"mappings":"AAAA,4BAA6B,WAAW,CAAC;AACzC,sCAAuC,WAAW,CAAC;AACnD,+BAA4C;AAC5C,yCAAsD;AACtD,kDAA+D;AAC/D,2CAAwD;AACxD,qCAAkD;AAGlD,wCAAqD;AACrD,qCAAkD;AAClD,0CAQE"}
|
package/src/module-source.d.ts
CHANGED
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
* @param {string} source
|
|
26
26
|
* @param {string | Options} [opts]
|
|
27
27
|
*/
|
|
28
|
-
export function ModuleSource(source: string, opts?: string | Options
|
|
28
|
+
export function ModuleSource(source: string, opts?: string | Options): void;
|
|
29
29
|
export class ModuleSource {
|
|
30
30
|
/**
|
|
31
31
|
* @typedef {object} SourceMapHookDetails
|
|
@@ -54,7 +54,7 @@ export class ModuleSource {
|
|
|
54
54
|
* @param {string} source
|
|
55
55
|
* @param {string | Options} [opts]
|
|
56
56
|
*/
|
|
57
|
-
constructor(source: string, opts?: string | Options
|
|
57
|
+
constructor(source: string, opts?: string | Options);
|
|
58
58
|
imports: string[];
|
|
59
59
|
exports: any[];
|
|
60
60
|
reexports: never[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module-source.d.ts","sourceRoot":"","sources":["module-source.js"],"names":[],"mappings":"AAmCA;;;;;;GAMG;AAEH;;;;GAIG;AAEH;;;;;;GAMG;AAKH;;;;;;;GAOG;AACH,qCAHW,MAAM,
|
|
1
|
+
{"version":3,"file":"module-source.d.ts","sourceRoot":"","sources":["module-source.js"],"names":[],"mappings":"AAmCA;;;;;;GAMG;AAEH;;;;GAIG;AAEH;;;;;;GAMG;AAKH;;;;;;;GAOG;AACH,qCAHW,MAAM,SACN,MAAM,GAAG,OAAO,QAqC1B;;IApED;;;;;;OAMG;IAEH;;;;OAIG;IAEH;;;;;;OAMG;IAKH;;;;;;;OAOG;IACH,oBAHW,MAAM,SACN,MAAM,GAAG,OAAO,EAqC1B;IAhBC,kBAAyC;IACzC,eAMC;IACD,mBAA+C;IAC/C,8BAA0C;IAC1C,uBAAsC;IACtC,qBAAkC;IAClC,wBAAwC;IACxC,yBAAkC;IAClC,6BAA0C;;;iBAhE9B,MAAM;YACN,MAAM;cACN,MAAM;YACN,MAAM;;wCAKT,MAAM,WACN,oBAAoB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transform-analyze.d.ts","sourceRoot":"","sources":["transform-analyze.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"transform-analyze.d.ts","sourceRoot":"","sources":["transform-analyze.js"],"names":[],"mappings":"AA0HO,+DA7GM,MAAM,0DACN,OAAO;;;;;;;;;GA+GnB;AAEM;;EA6DN;6BApL0B,oBAAoB"}
|
package/src/transform-analyze.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @ts-nocheck XXX Babel types
|
|
2
|
-
import { makeTransformSource } from './
|
|
3
|
-
import makeModulePlugins from './
|
|
2
|
+
import { makeTransformSource } from './transform-source.js';
|
|
3
|
+
import makeModulePlugins from './babel-plugin.js';
|
|
4
4
|
|
|
5
5
|
import * as h from './hidden.js';
|
|
6
6
|
|
|
@@ -72,7 +72,7 @@ const makeCreateStaticRecord = transformSource =>
|
|
|
72
72
|
.map(
|
|
73
73
|
src =>
|
|
74
74
|
`[${js(src)}, [${Object.entries(isrc[src])
|
|
75
|
-
.map(([exp, upds]) => `[${js(exp)},
|
|
75
|
+
.map(([exp, upds]) => `[${js(exp)},[${upds.join(',')}]]`)
|
|
76
76
|
.join(',')}]]`,
|
|
77
77
|
)
|
|
78
78
|
.join(',')}]);`;
|
|
@@ -81,9 +81,7 @@ const makeCreateStaticRecord = transformSource =>
|
|
|
81
81
|
let src = '';
|
|
82
82
|
if (cvname) {
|
|
83
83
|
// It's a function assigned to, so set its name property.
|
|
84
|
-
src = `Object.defineProperty(${cvname},
|
|
85
|
-
vname,
|
|
86
|
-
)}});`;
|
|
84
|
+
src = `Object.defineProperty(${cvname},'name',{value:${js(vname)}});`;
|
|
87
85
|
}
|
|
88
86
|
const hDeclId = isOnce ? h.HIDDEN_ONCE : h.HIDDEN_LIVE;
|
|
89
87
|
src += `${hDeclId}.${vname}(${cvname || ''});`;
|
|
@@ -100,15 +98,9 @@ const makeCreateStaticRecord = transformSource =>
|
|
|
100
98
|
// well.
|
|
101
99
|
// Relies on the evaluator to ensure these functions are strict.
|
|
102
100
|
let functorSource = `\
|
|
103
|
-
({
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
onceVar: ${h.HIDDEN_ONCE}, \
|
|
107
|
-
import: ${h.HIDDEN_IMPORT}, \
|
|
108
|
-
importMeta: ${h.HIDDEN_META}, \
|
|
109
|
-
}) => (function () { 'use strict'; \
|
|
110
|
-
${preamble} \
|
|
111
|
-
${scriptSource}
|
|
101
|
+
({imports:${h.HIDDEN_IMPORTS},liveVar:${h.HIDDEN_LIVE},onceVar:${h.HIDDEN_ONCE},import:${h.HIDDEN_IMPORT},importMeta:${h.HIDDEN_META}})=>(function(){'use strict';\
|
|
102
|
+
${preamble}\
|
|
103
|
+
${scriptSource}
|
|
112
104
|
})()
|
|
113
105
|
`;
|
|
114
106
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transform-source.d.ts","sourceRoot":"","sources":["transform-source.js"],"names":[],"mappings":"AAeO,uHAmDN"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @ts-nocheck XXX Babel types
|
|
2
2
|
import * as babelParser from '@babel/parser';
|
|
3
|
-
import babelGenerate from '@
|
|
3
|
+
import babelGenerate from '@babel/generator';
|
|
4
4
|
import babelTraverse from '@babel/traverse';
|
|
5
5
|
import * as babelTypes from '@babel/types';
|
|
6
6
|
|
|
@@ -26,7 +26,11 @@ export const makeTransformSource = (makeModulePlugins, babel = null) => {
|
|
|
26
26
|
const { sourceUrl, sourceMapUrl, sourceType, sourceMap, sourceMapHook } =
|
|
27
27
|
sourceOptions;
|
|
28
28
|
|
|
29
|
-
const ast = parseBabel(source, {
|
|
29
|
+
const ast = parseBabel(source, {
|
|
30
|
+
sourceType,
|
|
31
|
+
tokens: true,
|
|
32
|
+
createParenthesizedExpressions: true,
|
|
33
|
+
});
|
|
30
34
|
|
|
31
35
|
traverseBabel(ast, visitorFromPlugin(analyzePlugin));
|
|
32
36
|
traverseBabel(ast, visitorFromPlugin(transformPlugin));
|
|
@@ -34,14 +38,19 @@ export const makeTransformSource = (makeModulePlugins, babel = null) => {
|
|
|
34
38
|
const sourceMaps = sourceOptions.sourceMapHook !== undefined;
|
|
35
39
|
|
|
36
40
|
const { code: transformedSource, map: transformedSourceMap } =
|
|
37
|
-
generateBabel(
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
generateBabel(
|
|
42
|
+
ast,
|
|
43
|
+
{
|
|
44
|
+
sourceFileName: sourceMapUrl,
|
|
45
|
+
sourceMaps,
|
|
46
|
+
inputSourceMap: sourceMap,
|
|
47
|
+
experimental_preserveFormat: true,
|
|
48
|
+
preserveFormat: true,
|
|
49
|
+
retainLines: true,
|
|
50
|
+
verbatim: true,
|
|
51
|
+
},
|
|
52
|
+
source,
|
|
53
|
+
);
|
|
45
54
|
|
|
46
55
|
if (sourceMaps) {
|
|
47
56
|
sourceMapHook(transformedSourceMap, {
|
package/src/babelPlugin.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"babelPlugin.d.ts","sourceRoot":"","sources":["babelPlugin.js"],"names":[],"mappings":";AAwCA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA+kBC"}
|
package/src/transformSource.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"transformSource.d.ts","sourceRoot":"","sources":["transformSource.js"],"names":[],"mappings":"AAeO,oHA0CN"}
|