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

@agoric/captp

Package Overview
Dependencies
Maintainers
4
Versions
160
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@agoric/captp - npm Package Compare versions

Comparing version 0.1.2 to 1.0.0

dist/captp.cjs.js

82

lib/captp.js

@@ -6,5 +6,7 @@ // This logic was mostly lifted from @agoric/swingset-vat liveSlots.js

import Nat from '@agoric/nat';
import { HandledPromise } from '@agoric/eventual-send';
import { HandledPromise, E } from '@agoric/eventual-send';
export default function makeCapTP(ourId, send, bootstrapObj = undefined) {
export { E, HandledPromise, Nat, harden };
export function makeCapTP(ourId, send, bootstrapObj = undefined) {
const { serialize, unserialize } = makeMarshal(

@@ -71,2 +73,34 @@ // eslint-disable-next-line no-use-before-define

function makeRemote(slot) {
const handler = {
POST(_o, prop, args) {
// Support: o~.[prop](...args) remote method invocation
// FIXME: Implement a HandledPromise here to support pipelining.
const pr = {};
pr.p = new Promise((resolve, reject) => {
pr.res = resolve;
pr.rej = reject;
});
lastQuestionID += 1;
const questionID = lastQuestionID;
questions.set(questionID, pr);
send({
type: 'CTP_CALL',
questionID,
target: slot,
method: serialize(harden([prop, args])),
});
return harden(pr.p);
},
};
const pr = {};
pr.p = Promise.makeHandled((res, rej, resolveWithPresence) => {
pr.rej = rej;
pr.resPres = () => resolveWithPresence(handler);
pr.res = res;
}, handler);
return harden(pr);
}
function unserializeSlot(data, slots) {

@@ -77,31 +111,3 @@ const slot = slots[Nat(data.index)];

// Make a new handled promise for the slot.
const handler = {
POST(_o, prop, args) {
// Support: o~.[prop](...args) remote method invocation
const pr = {};
pr.p = new Promise((resolve, reject) => {
pr.res = resolve;
pr.rej = reject;
});
lastQuestionID += 1;
const questionID = lastQuestionID;
questions.set(questionID, pr);
send({
type: 'CTP_CALL',
questionID,
target: slot,
method: serialize(harden([prop, args])),
});
return harden(pr.p);
},
};
const pr = {};
pr.p = Promise.makeHandled((res, rej, resolveWithPresence) => {
pr.rej = rej;
pr.resPres = () => resolveWithPresence(handler);
pr.res = res;
}, handler);
harden(pr);
const pr = makeRemote(slot);
if (slot[0] === 'o') {

@@ -200,3 +206,15 @@ // A new presence

};
return [handler, getBootstrap];
harden(handler);
// Return a dispatch function.
const dispatch = obj => {
const fn = handler[obj.type];
if (fn) {
fn(obj);
return true;
}
return false;
};
return harden({ dispatch, getBootstrap });
}
{
"name": "@agoric/captp",
"version": "0.1.2",
"version": "1.0.0",
"description": "Capability Transfer Protocol for distributed objects",

@@ -13,3 +13,5 @@ "keywords": [

"license": "Apache-2.0",
"main": "lib/captp.js",
"main": "dist/captp.cjs.js",
"module": "dist/captp.esm.js",
"browser": "dist/captp.umd.js",
"directories": {

@@ -20,3 +22,4 @@ "lib": "lib",

"files": [
"lib"
"lib",
"dist"
],

@@ -28,2 +31,3 @@ "repository": {

"scripts": {
"build": "rollup -c",
"test": "tape -r esm 'test/**/*.js'",

@@ -52,3 +56,6 @@ "lint-fix": "eslint --fix '**/*.{js,jsx}'",

"@agoric/nat": "^2.0.1",
"esm": "^3.2.5"
"esm": "^3.2.5",
"rollup": "^1.24.0",
"rollup-plugin-commonjs": "^10.1.0",
"rollup-plugin-node-resolve": "^5.2.0"
},

@@ -55,0 +62,0 @@ "bugs": {

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