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

@agoric/zone

Package Overview
Dependencies
Maintainers
10
Versions
1497
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@agoric/zone

Allocation zone abstraction for objects on the heap, persistent stores, etc.

0.3.0-u19.2
latest
community-dev
agoric-upgrade-19
Source
npm
Version published
Weekly downloads
11K
22.23%
Maintainers
10
Weekly downloads
 
Created
Source

Zones

Each Zone provides an API that allows the allocation of Exo objects and Stores (object collections) which use the same underlying persistence mechanism. This allows library code to be agnostic to whether its objects are backed purely by the JS heap (ephemeral), pageable out to disk (virtual) or can be revived after a vat upgrade (durable).

See SwingSet vat upgrade documentation for more example use of the zone API.

An example of making a Zone-aware vat might look something like this:

import { makeDurableZone } from '@agoric/zone/durable.js';
import { prepareFrobulator } from 'frob-package';
import { prepareWidget } from 'widget-package';

export const buildRootObject = (vatPowers, _args, baggage) => {
  const zone = makeDurableZone(baggage);

  // Ensure that Widgets cannot interfere with Frobs.
  const makeWidget = prepareWidget(zone.subZone('Widgets'));

  // Create a collection of frobulators.
  const frobZone = zone.subZone('Frobs');
  const makeFrobulator = prepareFrobulator(frobZone);
  const widgetToFrob = frobZone.mapStore('widgetToFrob');

  return Far('WidgetFrobulator', {
    makeWidget,
    registerWidget(w) {
      const frobulator = makeFrobulator();
      widgetToFrob.init(w, frobulator);
    },
    frobWidget(w) {
      const frobulator = widgetToFrob.get(w);
      return frobulator.frob(w);
    },
  });
}

FAQs

Package last updated on 13 Mar 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts