@endo/eventual-send
Advanced tools
Comparing version 0.14.1 to 0.14.2
@@ -6,2 +6,16 @@ # Change Log | ||
### [0.14.2](https://github.com/endojs/endo/compare/@endo/eventual-send@0.14.1...@endo/eventual-send@0.14.2) (2022-01-25) | ||
### Features | ||
* **eventual-send:** harden things where possible under SES ([2394c71](https://github.com/endojs/endo/commit/2394c71673360ce8ec8a3c30f5fa47753fb9bec5)) | ||
### Bug Fixes | ||
* remove more extraneous spaced-comment comments ([#1009](https://github.com/endojs/endo/issues/1009)) ([980a798](https://github.com/endojs/endo/commit/980a79898a4643a359d905c308eecf70d8ab2758)) | ||
### 0.14.1 (2022-01-23) | ||
@@ -8,0 +22,0 @@ |
{ | ||
"name": "@endo/eventual-send", | ||
"version": "0.14.1", | ||
"version": "0.14.2", | ||
"description": "Extend a Promise class to implement the eventual-send API", | ||
@@ -30,4 +30,4 @@ "type": "module", | ||
"devDependencies": { | ||
"@endo/lockdown": "^0.1.2", | ||
"@endo/ses-ava": "^0.2.14", | ||
"@endo/lockdown": "^0.1.3", | ||
"@endo/ses-ava": "^0.2.15", | ||
"ava": "^3.12.1", | ||
@@ -63,3 +63,3 @@ "c8": "^7.7.3" | ||
}, | ||
"gitHead": "eb554c875d7fc57ec6c77829c2d80da0be5987ae" | ||
"gitHead": "c46f8d5d40f71014a099c53d26c75b149ea56d09" | ||
} |
12
src/E.js
// @ts-check | ||
import { trackTurns } from './track-turns.js'; | ||
// eslint-disable-next-line spaced-comment | ||
/// <reference path="index.d.ts" /> | ||
@@ -34,11 +33,6 @@ | ||
get(_target, p, _receiver) { | ||
// Harden this Promise because it's our only opportunity to ensure | ||
// p1=E(x).foo() is hardened. The Handled Promise API does not (yet) | ||
// allow the handler to synchronously influence the promise returned | ||
// by the handled methods, so we must freeze it from the outside. See | ||
// #95 for details. | ||
return (...args) => harden(HandledPromise.applyMethod(x, p, args)); | ||
return harden((...args) => HandledPromise.applyMethod(x, p, args)); | ||
}, | ||
apply(_target, _thisArg, argArray = []) { | ||
return harden(HandledPromise.applyFunction(x, argArray)); | ||
return HandledPromise.applyFunction(x, argArray); | ||
}, | ||
@@ -93,3 +87,3 @@ has(_target, _p) { | ||
get(_target, prop) { | ||
return harden(HandledPromise.get(x, prop)); | ||
return HandledPromise.get(x, prop); | ||
}, | ||
@@ -96,0 +90,0 @@ }); |
@@ -66,2 +66,3 @@ // @ts-check | ||
const presenceToHandler = new WeakMap(); | ||
/** @type {WeakMap<any, any>} */ | ||
const presenceToPromise = new WeakMap(); | ||
@@ -481,3 +482,7 @@ const promiseToPendingHandler = new WeakMap(); | ||
handle = (p, operation, opArgs, ...dispatchArgs) => { | ||
handle = (...handleArgs) => { | ||
// We're in SES mode, so we should harden. | ||
harden(handleArgs); | ||
const [_p, operation, opArgs, ...dispatchArgs] = handleArgs; | ||
let [p] = handleArgs; | ||
const doDispatch = (handlerName, handler, o) => | ||
@@ -546,9 +551,10 @@ dispatchToHandler( | ||
// Workaround for Node.js: silence "Unhandled Rejection" by default when | ||
// using the static methods. | ||
returnedP.catch(_ => {}); | ||
// Harden the fulfillment and rejection, as well as a workaround for | ||
// Node.js: silence "Unhandled Rejection" by default when using the static | ||
// methods. | ||
returnedP.then(harden, harden); | ||
// We return a handled promise with the default pending handler. This | ||
// prevents a race between the above Promise.resolves and pipelining. | ||
return returnedP; | ||
return harden(returnedP); | ||
}; | ||
@@ -555,0 +561,0 @@ |
@@ -1,2 +0,2 @@ | ||
/* eslint-disable no-shadow,no-unused-vars,no-use-before-define,no-var,vars-on-top */ | ||
/* eslint-disable no-shadow,no-use-before-define,no-var,vars-on-top */ | ||
// Type definitions for eventual-send | ||
@@ -3,0 +3,0 @@ // TODO: Add jsdocs. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
69443