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

@agoric/eventual-send

Package Overview
Dependencies
Maintainers
4
Versions
322
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@agoric/eventual-send - npm Package Compare versions

Comparing version 0.1.9 to 0.1.10

55

dist/eventual-send.cjs.js

@@ -27,10 +27,22 @@ 'use strict';

let forwardingHandler;
function handler(p, operation, ...args) {
const h = promiseToHandler.get(p) || forwardingHandler;
if (typeof h[operation] !== 'function') {
const handlerName =
h === forwardingHandler ? 'forwardingHandler' : 'unfulfilledHandler';
throw TypeError(`${handlerName}.${operation} is not a function`);
function handle(p, operation, ...args) {
const unfulfilledHandler = promiseToHandler.get(p);
if (unfulfilledHandler) {
if (typeof unfulfilledHandler[operation] !== 'function') {
throw TypeError(`unfulfilledHandler.${operation} is not a function`);
}
// We pass the Promise directly, but we need to ensure we
// run in a future turn, to prevent synchronous attacks.
return Promise.resolve().then(() =>
unfulfilledHandler[operation](p, ...args),
);
}
return Promise.resolve(h[operation](p, ...args));
// We use the forwardingHandler, but pass in the naked object in a future turn.
if (typeof forwardingHandler[operation] !== 'function') {
throw TypeError(`forwardingHandler.${operation} is not a function`);
}
return Promise.resolve(p).then(o =>
forwardingHandler[operation](o, ...args),
);
}

@@ -42,27 +54,27 @@

get(key) {
return handler(this, 'GET', key);
return handle(this, 'GET', key);
},
put(key, val) {
return handler(this, 'PUT', key, val);
return handle(this, 'PUT', key, val);
},
delete(key) {
return handler(this, 'DELETE', key);
return handle(this, 'DELETE', key);
},
post(optKey, args) {
return handler(this, 'POST', optKey, args);
return handle(this, 'POST', optKey, args);
},
invoke(optKey, ...args) {
return handler(this, 'POST', optKey, args);
return handle(this, 'POST', optKey, args);
},
fapply(args) {
return handler(this, 'POST', undefined, args);
return handle(this, 'POST', undefined, args);
},
fcall(...args) {
return handler(this, 'POST', undefined, args);
return handle(this, 'POST', undefined, args);
},

@@ -187,2 +199,3 @@ }),

if (!presenceToHandler.has(presence)) {
// Create table entries for the presence mapped to the fulfilledHandler.
presenceToPromise.set(presence, handledP);

@@ -192,5 +205,4 @@ presenceToHandler.set(presence, fulfilledHandler);

// We need to invoke fulfilledHandler immediately, so add it
// to the mapping.
promiseToHandler.set(handledP, fulfilledHandler);
// Remove the mapping, as our fulfilledHandler should be used instead.
promiseToHandler.delete(handledP);

@@ -220,7 +232,7 @@ // We committed to this presence, so resolve.

function makeForwarder(operation, localImpl) {
return async (ep, ...args) => {
const o = await ep;
return (o, ...args) => {
// We are in another turn already, and have the naked object.
const fulfilledHandler = presenceToHandler.get(o);
if (fulfilledHandler) {
// The handler was resolved, so give it a naked object.
// The handler was resolved, so use it.
if (typeof fulfilledHandler[operation] !== 'function') {

@@ -232,4 +244,3 @@ throw TypeError(`fulfilledHandler.${operation} is not a function`);

// Not a handled Promise, so use the local implementation on the
// naked object.
// Not handled, so use the local implementation.
return localImpl(o, ...args);

@@ -236,0 +247,0 @@ };

@@ -25,10 +25,22 @@ /**

let forwardingHandler;
function handler(p, operation, ...args) {
const h = promiseToHandler.get(p) || forwardingHandler;
if (typeof h[operation] !== 'function') {
const handlerName =
h === forwardingHandler ? 'forwardingHandler' : 'unfulfilledHandler';
throw TypeError(`${handlerName}.${operation} is not a function`);
function handle(p, operation, ...args) {
const unfulfilledHandler = promiseToHandler.get(p);
if (unfulfilledHandler) {
if (typeof unfulfilledHandler[operation] !== 'function') {
throw TypeError(`unfulfilledHandler.${operation} is not a function`);
}
// We pass the Promise directly, but we need to ensure we
// run in a future turn, to prevent synchronous attacks.
return Promise.resolve().then(() =>
unfulfilledHandler[operation](p, ...args),
);
}
return Promise.resolve(h[operation](p, ...args));
// We use the forwardingHandler, but pass in the naked object in a future turn.
if (typeof forwardingHandler[operation] !== 'function') {
throw TypeError(`forwardingHandler.${operation} is not a function`);
}
return Promise.resolve(p).then(o =>
forwardingHandler[operation](o, ...args),
);
}

@@ -40,27 +52,27 @@

get(key) {
return handler(this, 'GET', key);
return handle(this, 'GET', key);
},
put(key, val) {
return handler(this, 'PUT', key, val);
return handle(this, 'PUT', key, val);
},
delete(key) {
return handler(this, 'DELETE', key);
return handle(this, 'DELETE', key);
},
post(optKey, args) {
return handler(this, 'POST', optKey, args);
return handle(this, 'POST', optKey, args);
},
invoke(optKey, ...args) {
return handler(this, 'POST', optKey, args);
return handle(this, 'POST', optKey, args);
},
fapply(args) {
return handler(this, 'POST', undefined, args);
return handle(this, 'POST', undefined, args);
},
fcall(...args) {
return handler(this, 'POST', undefined, args);
return handle(this, 'POST', undefined, args);
},

@@ -185,2 +197,3 @@ }),

if (!presenceToHandler.has(presence)) {
// Create table entries for the presence mapped to the fulfilledHandler.
presenceToPromise.set(presence, handledP);

@@ -190,5 +203,4 @@ presenceToHandler.set(presence, fulfilledHandler);

// We need to invoke fulfilledHandler immediately, so add it
// to the mapping.
promiseToHandler.set(handledP, fulfilledHandler);
// Remove the mapping, as our fulfilledHandler should be used instead.
promiseToHandler.delete(handledP);

@@ -218,7 +230,7 @@ // We committed to this presence, so resolve.

function makeForwarder(operation, localImpl) {
return async (ep, ...args) => {
const o = await ep;
return (o, ...args) => {
// We are in another turn already, and have the naked object.
const fulfilledHandler = presenceToHandler.get(o);
if (fulfilledHandler) {
// The handler was resolved, so give it a naked object.
// The handler was resolved, so use it.
if (typeof fulfilledHandler[operation] !== 'function') {

@@ -230,4 +242,3 @@ throw TypeError(`fulfilledHandler.${operation} is not a function`);

// Not a handled Promise, so use the local implementation on the
// naked object.
// Not handled, so use the local implementation.
return localImpl(o, ...args);

@@ -234,0 +245,0 @@ };

@@ -31,10 +31,22 @@ (function (global, factory) {

let forwardingHandler;
function handler(p, operation, ...args) {
const h = promiseToHandler.get(p) || forwardingHandler;
if (typeof h[operation] !== 'function') {
const handlerName =
h === forwardingHandler ? 'forwardingHandler' : 'unfulfilledHandler';
throw TypeError(`${handlerName}.${operation} is not a function`);
function handle(p, operation, ...args) {
const unfulfilledHandler = promiseToHandler.get(p);
if (unfulfilledHandler) {
if (typeof unfulfilledHandler[operation] !== 'function') {
throw TypeError(`unfulfilledHandler.${operation} is not a function`);
}
// We pass the Promise directly, but we need to ensure we
// run in a future turn, to prevent synchronous attacks.
return Promise.resolve().then(() =>
unfulfilledHandler[operation](p, ...args),
);
}
return Promise.resolve(h[operation](p, ...args));
// We use the forwardingHandler, but pass in the naked object in a future turn.
if (typeof forwardingHandler[operation] !== 'function') {
throw TypeError(`forwardingHandler.${operation} is not a function`);
}
return Promise.resolve(p).then(o =>
forwardingHandler[operation](o, ...args),
);
}

@@ -46,27 +58,27 @@

get(key) {
return handler(this, 'GET', key);
return handle(this, 'GET', key);
},
put(key, val) {
return handler(this, 'PUT', key, val);
return handle(this, 'PUT', key, val);
},
delete(key) {
return handler(this, 'DELETE', key);
return handle(this, 'DELETE', key);
},
post(optKey, args) {
return handler(this, 'POST', optKey, args);
return handle(this, 'POST', optKey, args);
},
invoke(optKey, ...args) {
return handler(this, 'POST', optKey, args);
return handle(this, 'POST', optKey, args);
},
fapply(args) {
return handler(this, 'POST', undefined, args);
return handle(this, 'POST', undefined, args);
},
fcall(...args) {
return handler(this, 'POST', undefined, args);
return handle(this, 'POST', undefined, args);
},

@@ -191,2 +203,3 @@ }),

if (!presenceToHandler.has(presence)) {
// Create table entries for the presence mapped to the fulfilledHandler.
presenceToPromise.set(presence, handledP);

@@ -196,5 +209,4 @@ presenceToHandler.set(presence, fulfilledHandler);

// We need to invoke fulfilledHandler immediately, so add it
// to the mapping.
promiseToHandler.set(handledP, fulfilledHandler);
// Remove the mapping, as our fulfilledHandler should be used instead.
promiseToHandler.delete(handledP);

@@ -224,7 +236,7 @@ // We committed to this presence, so resolve.

function makeForwarder(operation, localImpl) {
return async (ep, ...args) => {
const o = await ep;
return (o, ...args) => {
// We are in another turn already, and have the naked object.
const fulfilledHandler = presenceToHandler.get(o);
if (fulfilledHandler) {
// The handler was resolved, so give it a naked object.
// The handler was resolved, so use it.
if (typeof fulfilledHandler[operation] !== 'function') {

@@ -236,4 +248,3 @@ throw TypeError(`fulfilledHandler.${operation} is not a function`);

// Not a handled Promise, so use the local implementation on the
// naked object.
// Not handled, so use the local implementation.
return localImpl(o, ...args);

@@ -240,0 +251,0 @@ };

2

package.json
{
"name": "@agoric/eventual-send",
"version": "0.1.9",
"version": "0.1.10",
"description": "Extend a Promise class to implement the eventual-send API",

@@ -5,0 +5,0 @@ "main": "dist/eventual-send.cjs.js",

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