Socket
Socket
Sign inDemoInstall

@agoric/zone

Package Overview
Dependencies
195
Maintainers
8
Versions
666
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @agoric/zone

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


Version published
Weekly downloads
7.1K
increased by76.16%
Maintainers
8
Created
Weekly downloads
 

Readme

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 { zoneFrobulator } from 'frob-package';
import { zoneWidget } from 'widget-package';

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

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

  // Create a collection of frobulators.
  const frobZone = zone.subZone('Frobs');
  const makeFrobulator = zoneFrobulator(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

Last updated on 27 Feb 2024

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc