Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@agoric/transform-eventual-send

Package Overview
Dependencies
Maintainers
5
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@agoric/transform-eventual-send - npm Package Compare versions

Comparing version 1.2.4 to 1.3.0

src/rewriter.js

18

CHANGELOG.md

@@ -6,2 +6,20 @@ # Change Log

# [1.3.0](https://github.com/Agoric/agoric-sdk/compare/@agoric/transform-eventual-send@1.2.4...@agoric/transform-eventual-send@1.3.0) (2020-05-17)
### Bug Fixes
* **transform-eventual-send:** split out rewriter.js to fix cycle ([8a54d36](https://github.com/Agoric/agoric-sdk/commit/8a54d36f6de8cee2ea87d6c75ea1eb013f40e766))
* make output from bundleSource correspond to source map lines ([c1ddd4a](https://github.com/Agoric/agoric-sdk/commit/c1ddd4a0a27de9561b3bd827213562d9741e61a8))
* remove many build steps ([6c7d3bb](https://github.com/Agoric/agoric-sdk/commit/6c7d3bb0c70277c22f8eda40525d7240141a5434))
### Features
* **transform-eventual-send:** expose bare transform function too ([0bb35eb](https://github.com/Agoric/agoric-sdk/commit/0bb35eb11fd9acc4e90ec987f83f246e09cdcab5))
## [1.2.4](https://github.com/Agoric/agoric-sdk/compare/@agoric/transform-eventual-send@1.2.3...@agoric/transform-eventual-send@1.2.4) (2020-05-10)

@@ -8,0 +26,0 @@

16

package.json
{
"name": "@agoric/transform-eventual-send",
"version": "1.2.4",
"version": "1.3.0",
"description": "transform-eventual-send",
"main": "dist/transform-eventual-send.cjs.js",
"module": "src/index.js",
"browser": "dist/transform-eventual-send.umd.js",
"main": "src/index.js",
"scripts": {

@@ -12,9 +10,9 @@ "test": "tape -r esm 'test/**/*.js'",

"lint-check": "eslint '**/*.js'",
"build": "node -r esm ./scripts/build-esend.js && rollup -c rollup.config.js"
"build": "node -r esm ./scripts/build-esend.js"
},
"devDependencies": {
"@agoric/acorn-eventual-send": "^2.0.4",
"@agoric/acorn-eventual-send": "^2.0.5",
"@agoric/babel-parser": "^7.6.4",
"@agoric/bundle-source": "^1.1.4",
"@agoric/eventual-send": "^0.9.1",
"@agoric/bundle-source": "^1.1.5",
"@agoric/eventual-send": "^0.9.2",
"@agoric/harden": "^0.0.8",

@@ -49,3 +47,3 @@ "@babel/generator": "^7.5.0",

},
"gitHead": "41e9cd4b0475b0b0cc461e9c54c5dbec82994e3c"
"gitHead": "4cbbf2146ff4b47eaffd1bdf22f3fde8f184cc38"
}

@@ -1,90 +0,17 @@

import eventualSendBundle from './bundles/eventual-send';
function makeEventualSendTransformer(parser, generate) {
let HandledPromise;
let evaluateProgram;
let myRequire;
let recursive = false;
const transform = {
closeOverSES(s) {
// FIXME: This will go away when we can bundle an @agoric/harden that understands SES.
myRequire = name => {
if (name === '@agoric/harden') {
return s.global.SES.harden;
}
throw Error(`Unrecognized require ${name}`);
};
// FIXME: This should be replaced with ss.evaluateProgram support in SES.
evaluateProgram = (src, endowments = {}) => s.evaluate(src, endowments);
},
rewrite(ss) {
const source = ss.src;
const endowments = ss.endowments || {};
if (!recursive && !('HandledPromise' in endowments)) {
// Use a getter to postpone initialization.
Object.defineProperty(endowments, 'HandledPromise', {
get() {
if (!HandledPromise) {
// Get a HandledPromise endowment for the evaluator.
// It will be hardened in the evaluator's context.
const nestedEvaluate = src =>
(evaluateProgram || ss.evaluateProgram)(src, {
require: myRequire || require,
nestedEvaluate,
});
const {
source: evSendSrc,
moduleFormat,
sourceMap,
} = eventualSendBundle;
if (
moduleFormat === 'getExport' ||
moduleFormat === 'nestedEvaluate'
) {
recursive = true;
try {
const ns = nestedEvaluate(`(${evSendSrc}\n${sourceMap})`)();
HandledPromise = ns.HandledPromise;
} finally {
recursive = false;
}
} else {
throw Error(`Unrecognized moduleFormat ${moduleFormat}`);
}
}
return HandledPromise;
},
});
}
// Parse with eventualSend enabled, rewriting to
// HandledPromise.get/applyFunction/applyMethod(...)
const parseFunc = parser.parse;
const ast = (parseFunc || parser)(source, {
plugins: ['eventualSend'],
});
// Create the source from the ast.
const output = generate(ast, {}, source);
// Work around Babel appending semicolons.
const maybeSource = output.code;
const actualSource =
ss.sourceType === 'expression' &&
maybeSource.endsWith(';') &&
!source.endsWith(';')
? maybeSource.slice(0, -1)
: maybeSource;
return {
...ss,
ast,
endowments,
src: actualSource,
};
},
};
return [transform];
export function makeTransform(parser, generate) {
function transform(source) {
// Parse with eventualSend enabled, rewriting to
// HandledPromise.get/applyFunction/applyMethod(...). Whoever finally
// evaluates this code must provide a HandledPromise object, probably as
// an endowment.
const parseFunc = parser.parse;
const ast = (parseFunc || parser)(source, {
sourceType: 'module',
plugins: ['eventualSend'],
});
// Create the source from the ast.
const output = generate(ast, { retainLines: true }, source);
return output.code;
}
return transform;
}
export default makeEventualSendTransformer;
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc