New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@agoric/base-zone

Package Overview
Dependencies
Maintainers
9
Versions
1043
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@agoric/base-zone - npm Package Compare versions

Comparing version 0.1.1-dev-5c28f49.0 to 0.1.1-dev-5cdf6e3.0

6

package.json
{
"name": "@agoric/base-zone",
"version": "0.1.1-dev-5c28f49.0+5c28f49",
"version": "0.1.1-dev-5cdf6e3.0+5cdf6e3",
"description": "Allocation zone abstraction library and heap implementation",

@@ -30,3 +30,3 @@ "type": "module",

"dependencies": {
"@agoric/store": "0.9.3-dev-5c28f49.0+5c28f49",
"@agoric/store": "0.9.3-dev-5cdf6e3.0+5cdf6e3",
"@endo/common": "^1.2.0",

@@ -62,3 +62,3 @@ "@endo/exo": "^1.3.0",

},
"gitHead": "5c28f496976128e59e0e5a8f1a8c24f7b496527d"
"gitHead": "5cdf6e3a8b4fbb5cb8e276e6efeec65d9c3d6623"
}

@@ -1,7 +0,14 @@

export function prepareRevocableKit<U extends unknown = any>(zone: import('@agoric/base-zone').Zone, uKindName: string, uMethodNames: (string | symbol)[], options?: RevocableKitOptions<any> | undefined): (underlying: U) => RevocableKit<U>;
export type Revoker = {
export function prepareRevocableMakerKit<U = any>(zone: import('@agoric/base-zone').Zone, uKindName: string, uMethodNames: (string | symbol)[], options?: RevocableKitOptions<any> | undefined): RevocableMakerKit<U>;
export type RevocableMakerKit<U = any> = {
revoke: (revocable: U) => boolean;
/**
* Forwards to the underlying exo object, until revoked
*/
makeRevocable: (underlying: U) => U;
};
export type RevokerFacet = {
revoke: () => boolean;
};
export type RevocableKit<U extends unknown = any> = {
revoker: Revoker;
export type RevocableKit<U = any> = {
revoker: RevokerFacet;
/**

@@ -18,3 +25,3 @@ * Forwards to the underlying exo object, until revoked

};
export type RevocableKitOptions<U extends unknown = any> = {
export type RevocableKitOptions<U = any> = {
/**

@@ -21,0 +28,0 @@ * The `interfaceName` of the underlying interface guard.

@@ -7,3 +7,11 @@ import { M } from '@endo/patterns';

/**
* @typedef {object} Revoker
* @template [U=any]
* @typedef {object} RevocableMakerKit
* @property {(revocable: U) => boolean} revoke
* @property {(underlying: U) => U} makeRevocable
* Forwards to the underlying exo object, until revoked
*/
/**
* @typedef {object} RevokerFacet
* @property {() => boolean} revoke

@@ -13,5 +21,5 @@ */

/**
* @template {any} [U=any]
* @template [U=any]
* @typedef {object} RevocableKit
* @property {Revoker} revoker
* @property {RevokerFacet} revoker
* @property {U} revocable

@@ -29,3 +37,3 @@ * Forwards to the underlying exo object, until revoked

/**
* @template {any} [U=any]
* @template [U=any]
* @typedef {object} RevocableKitOptions

@@ -54,4 +62,3 @@ * @property {string} [uInterfaceName]

*
* @deprecated Change to `prepareRevocableMakerKit` once #8977 happens
* @template {any} [U=any]
* @template [U=any]
* @param {import('@agoric/base-zone').Zone} zone

@@ -64,5 +71,5 @@ * @param {string} uKindName

* @param {RevocableKitOptions} [options]
* @returns {(underlying: U) => RevocableKit<U>}
* @returns {RevocableMakerKit<U>}
*/
export const prepareRevocableKit = (
export const prepareRevocableMakerKit = (
zone,

@@ -95,2 +102,4 @@ uKindName,

let amplifier;
const makeRevocableKit = zone.exoClassKit(

@@ -137,9 +146,34 @@ revocableKindName,

},
receiveAmplifier: amp => {
amplifier = amp;
},
},
);
// eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error
// @ts-ignore parameter confusion
return makeRevocableKit;
/**
* @param {U} underlying
* @returns {U}
*/
const makeRevocable = underlying =>
// @ts-expect-error some confusion about UU vs Guarded<U> I think
makeRevocableKit(underlying).revocable;
/**
* @param {U} revocable
* @returns {boolean}
*/
const revoke = revocable => {
/** @type {RevocableKit<U>} */
const facets = amplifier(revocable);
if (facets === undefined) {
return false;
}
return facets.revoker.revoke();
};
return harden({
revoke,
makeRevocable,
});
};
harden(prepareRevocableKit);
harden(prepareRevocableMakerKit);
export type KeyCategories = 'exoClass' | 'exoClassKit' | 'exo' | 'store' | 'zone';
export type KeyMakers = {
exoClass: (label: string) => string[];
exoClassKit: (label: string) => string[];
exo: (label: string) => string[];
store: (label: string) => string[];
zone: (label: string) => string[];
};
export type KeyMakers = Record<KeyCategories, (label: string) => string[]>;
/**

@@ -10,0 +4,0 @@ * A bag of methods for creating defensible objects and

@@ -8,3 +8,3 @@ // Modeled on test-heap-classes.js

import { makeHeapZone } from '../src/heap.js';
import { prepareRevocableKit } from '../src/prepare-revocable.js';
import { prepareRevocableMakerKit } from '../src/prepare-revocable.js';

@@ -42,12 +42,13 @@ const UpCounterI = M.interface('UpCounter', {

const makeRevocableUpCounterKit = prepareRevocableKit(zone, 'UpCounter', [
'incr',
]);
const { revoke, makeRevocable } = prepareRevocableMakerKit(
zone,
'UpCounter',
['incr'],
);
const makeUpCounterKit = x =>
makeRevocableUpCounterKit(makeUnderlyingUpCounter(x));
const makeUpCounter = x => makeRevocable(makeUnderlyingUpCounter(x));
const { revoker, revocable: upCounter } = makeUpCounterKit(3);
const upCounter = makeUpCounter(3);
t.is(upCounter.incr(5), 8);
t.is(revoker.revoke(), true);
t.is(revoke(upCounter), true);
t.throws(() => upCounter.incr(1), {

@@ -84,3 +85,3 @@ message: '"UpCounter_caretaker" revoked',

const makeRevocableUpCounterKit = prepareRevocableKit(
const { revoke, makeRevocable } = prepareRevocableMakerKit(
zone,

@@ -95,4 +96,8 @@ 'UpCounter',

selfRevoke() {
const { revoker } = this.facets;
return revoker.revoke();
// Could directly use the revoker facet instead, but this
// should now be considered more of an internal detail that
// we should deemphasize. This tests the code pattern we wish
// to encourage.
const { revocable } = this.facets;
return revoke(revocable);
},

@@ -105,4 +110,3 @@ },

const { up: upCounter, down: downCounter } = makeUnderlyingCounterKit(x);
const { revocable: revocableUpCounter } =
makeRevocableUpCounterKit(upCounter);
const revocableUpCounter = makeRevocable(upCounter);
return harden({

@@ -109,0 +113,0 @@ up: revocableUpCounter,

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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