A distributed object programming system in Dart
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-12-02 13:54:36 -05:00
example Transfer progress to public repo 2026-01-03 16:23:50 -06:00
lib Fix bug where resolved promise was being broken 2026-12-02 13:46:36 -05:00
test Remove unused test 2026-12-02 13:54:36 -05:00
tool Switch libsodium dependency to sodium_asset 2026-11-02 17:52:27 -05:00
.gitignore Upgrade to Dart 3.12 and remove need for sodium_libs 2026-05-26 11:10:27 -05:00
analysis_options.yaml Transfer progress to public repo 2026-01-03 16:23:50 -06:00
CHANGELOG.md Transfer progress to public repo 2026-01-03 16:23:50 -06:00
LICENSE.txt Transfer progress to public repo 2026-01-03 16:23:50 -06:00
pubspec.yaml Add NoiseNetLayer 2026-11-16 16:17:06 -05:00
README.md Update NetLayer info in README 2026-11-23 15:04:50 -05:00

This library provides a distributed object programming system in Dart that enables developers to create peer-to-peer or federated software for devices running Linux, macOS, Windows, iOS, and Android. Communication takes place over OCapN (the Object Capability Network) and provides a programming experience that does not require developers to be experts in (or spend a lot of time focusing on) the intricacies of distributed protocol design.

The contents of this repository were lovingly crafted by a human brain.

Warning

This package should not yet be used in production! It is still fairly likely that there will be major changes!

Table of Contents

  1. Setup
  2. NetLayers
    1. FakeNetLayer
    2. TCPTestingNetLayer
    3. WebSocketNetLayer
    4. NoiseNetLayer
    5. OnionNetLayer
    6. TCPTLSNetLayer
  3. CapTP
  4. DObject
    1. handleMessage
    2. Accepted message types
    3. send
    4. call
    5. Message ordering guarantees
    6. Round-trip equality
  5. Asynchronous programming with Promises
    1. Promise vs Future
    2. Promise pipelining
    3. Promise and async/await
    4. Casting promises
  6. RemoteObject
  7. DWrapper
  8. Tagged
    1. CustomTagged
    2. SelfTagged
    3. taggedBuilder
  9. SturdyRef
    1. Registration
    2. De-registration
    3. Export
    4. Import
    5. Enliven
  10. Recovery from failure
    1. onDisconnect
    2. onClientDisconnect
  11. Distributed garbage collection
  12. Debugger
  13. Common DObjects
  14. Sample application
  15. Acknowledgements

Setup

To add DObjects to your project, add the following to your pubspec.yaml:

dependencies:
  d_objects:
    git:
      url: https://codeberg.org/ridley/DObjects.git

NetLayers

A NetLayer is a transport layer for creating connections between peers.

Users don't interact directly with NetLayers. Instead, CapTP is built on top of NetLayers.

FakeNetLayer

A FakeNetLayer allows testing communication between peers in one program instead of setting up an actual NetLayer and running multiple separate programs. It is not meant to be used in production.

FakeNetwork network = FakeNetwork();

PeerLocator peerA = PeerLocator(designator: 'peerA', transport: Sym('fake'));
NetLayer netLayerA = FakeNetLayer(network: network, ourLocator: peerA);

PeerLocator peerB = PeerLocator(designator: 'peerB', transport: Sym('fake'));		
NetLayer netLayerB = FakeNetLayer(network: network, ourLocator: peerB);

TCPTestingNetLayer

You can use this NetLayer to test interoperability between different programs running on the same machine.

Note that this NetLayer is not supported on web.

WARNING: This NetLayer performs no authentication or encryption and should absolutely not be used in production!

NetLayer netLayer = TCPTestingNetLayer();
await netLayer.init(designator: 'myPeer', address: 'localhost');

By default, an unused port number is automatically selected. If you wish to bind to a specific port and address you can bind to them using init.

NoiseNetLayer

The NoiseNetLayer is secured and authenticated by the Noise protocol framework.

This NetLayer does not specify a particular transport mechanism but instead communicates over another sub-NetLayer that may have worse security properties.

It is strongly recommended to use this NetLayer to avoid security issues.

WebSocketNetLayer

The WebSocketNetLayer communicates over WebSockets and can be configured to reach peers using either WS or WSS.

This NetLayer does not authenticate incoming connections. If used in an environment where this is dangerous, this NetLayer should be used in combination with a NetLayer that performs peer authentication like the NoiseNetLayer.

Here we may also introduce the first option for communicating with other peers from a web browser: WebSocketBrowserNetLayer. The WebSocketBrowserNetLayer is web-only and does not permit incoming connections.

Communication between the WebSocketBrowserNetLayer and the WebSocketNetlayer is supported.

OnionNetLayer

This NetLayer is designed for enabling OCapN communication over TOR.

WARNING: While TOR services are secure on their own, the use of a SOCKS proxy means that the OnionNetLayer does not know the identity of the peer that is connecting to it. For this reason the OnionNetLayer should be used in combination with a NetLayer that performs peer authentication like the NoiseNetLayer.

Supported Platforms

The OnionNetLayer is currently supported on Linux and macOS. In theory it might work on Android but that theory has not been tested yet (please tell me if you do).

The OnionNetLayer is not supported on the web.

Setup

The OnionNetLayer communicates over TOR Onion Services (v3) by interacting with a background tor process running on the local device.

If you haven't already, install tor by following the official instructions.

Create a config file at ~/.config/dobjects/tor-config.txt which contains:

DataDirectory /<home>/<user>/.cache/dobjects/tor/data/
SocksPort unix:/<home>/<user>/.cache/dobjects/tor/tor-socks-sock RelaxDirModeCheck
ControlSocket unix:/<home>/<user>/.cache/dobjects/tor/tor-control-sock RelaxDirModeCheck
Log notice file /<home>/<user>/.cache/dobjects/tor/tor-log.txt

where is replaced with your actual username and is replaced with home on Linux and Users on macOS.

Create the cache directory:

mkdir -p ~/.cache/dobjects/tor/data
Sandboxed macOS setup

If you are using a sandboxed macOS application, you need to write your config file as follows:

DataDirectory /Users/<user>/Library/Containers/<app-bundle-id>/Data/.tor/data/
SocksPort unix:/Users/<user>/Library/Containers/<app-bundle-id>/Data/.tor/tor-socks-sock RelaxDirModeCheck
ControlSocket unix:/Users/<user>/Library/Containers/<app-bundle-id>/Data/.tor/tor-control-sock RelaxDirModeCheck
Log notice file /Users/<user>/Library/Containers/<app-bundle-id>/Data/.tor/tor-log.txt

where is replaced with your actual username and is the id under which the application was registered with Apple. It often looks like com.example.my-application-name.

And then create the cache directory:

mkdir -p /Users/<user>/Library/Containers/<app-bundle-id>/Data/.tor/data/

Use

Launch the TOR daemon:

tor -f ~/.config/dobjects/tor-config.txt

Create a new OnionNetLayer in your application:

void main() async {
NetLayer netLayer = OnionNetLayer();
// Don't forget to initialize the netLayer and wait for it to be ready!
// You can save the secret key and include it in a future call to init() 
// to reuse the same locator.
final secretKey = await netLayer.init();
// ...
// initiate CapTP
}

Future Plans

The current plan is to eventually integrate arti through Dart's FFI system in order to avoid requiring users to set up a TOR proxy and to hopefully support more platforms.

At the time of the writing of this document (based off of the available information as least), it seems like arti won't be ready for safe use for a few years yet.

TCPTLSNetLayer

The TCPTLSNetLayer communicates with peers over TCP/TLS.

This NetLayer is not supported on the Web platform.

WARNING: While TLS does provide encrypted communication, the TCPTLSNetLayer does NOT perform client authentication.

For this reason the TCPTLSNetLayer should be used in combination with a NetLayer that performs full peer authentication like the NoiseNetLayer.

The server's TLS certificate and private key are provided to the NetLayer's init method. Self-signed certificates are supported so long as they are valid.

CapTP

The CapTP object is responsible for managing sessions with other peers. Most applications will only use a single instance. The CapTP constructor signature looks like this:

CapTP({
    required NetLayer netLayer,
    OCapNCrypto? crypto,
    bool useFinalizerGCDetection = true,
    Duration weakRefPollPeriod = const Duration(seconds: 3),
    Tagged? Function(String tag, dynamic value)? taggedBuilder,
})

crypto is used internally for cryptographic signatures, hashes, and other things. This package currently supports two crypto suites: SodiumCrypto and SubtleCrypto.

The SodiumCrypto suite uses Dart's FFI tools to interact with the native libsodium library and is currently supported on Android, iOS, Linux, and macos.

The SubtleCrypto suite uses the web browser's SubtleCrypto APIs. It works compiled either to JS or WASM.

The library automatically selects the crypto suite based on the compilation target but you can also specify a custom option.

useFinalizerGCDetection and weakRefPollPeriod are covered in Distributed garbage collection.

taggedBuilder is covered in taggedBuilder.

DObject

The most fundamental unit of the DObjects library is the DObject, short for "Distributable Object." An object that uses the DObject mixin is a lot like a regular object except its reference can be passed to remote peers that can interact with it via message passing.

handleMessage

The DObject mixin has a single required method named handleMessage. All messages received from other peers for this object will be passed to this method that accepts a message in the form of a List and may return a response of some kind.

Here is an example DObject that simply prints every message it receives:

class Printer with DObject {
	@override
	dynamic handleMessage(List message) {
		print(message);
		return;
	}
} 

NOTE: handleMessage should never be called directly by user code. Instead, the send or call methods should be used.

Accepted message types

The message passed to handleMessage can contain any of the following types:

  • null
  • bool
  • int
  • double
  • String
  • Sym (OCapN Symbol)
  • Tagged
  • DObject
  • SturdyRef
  • a CopyList containing only accepted types
  • a CopySet containing only accepted types
  • a CopyMap containing only accepted types (for both keys and values)
  • CopyByteData

Note that it is conventional though not required to have the first element of the message list be a Sym whose name is the name of the method being called on the local object.

Note that Sym represents an OCapN Symbol but is not the same thing as a Dart Symbol.

CopyList, CopySet, and CopyMap are like List, Set, and Map except for two differences:

  • they are not mutable, though their contents may be
  • they are equal if their contents are equal

CopyByteData is like ByteData except that it cannot modify its underlying buffer and two CopyByteData objects are equal if their contents are equal.

send

The send method of a DObject sends the provided message to the object, indicating that the sender is not interested in a response to the message.

final printer = Printer();
printer.send(['hello world']);

call

The call method of a DObject sends the provided message to the object and sets up a Promise to receive a response to the message.

An optional expected return type can be specified to provide type checking on responses.

If no response is desired from a message, send should be used instead of call for performance reasons.

To illustrate the use of call, let's consider another example DObject:

class Echo with DObject {
	@override
	dynamic handleMessage(List message) {
		switch(message) {
			case [const Sym('echo'), dynamic toEcho] :
				return toEcho;
			default:
				throw Exception('Invalid input.');
		}
	}
}

void main() {
	final echo = Echo();
	// <int> specifies that we're expecting this call to return an int
	Promise<int> result = echo.call([const Sym('echo'), 4]);
	result.then((value) => print(value)); // prints '4'
}

Message ordering guarantees

OCapN guarantees an "end-to-end reference FIFO" message order. Messages sent from one peer to a particular object or promise on another peer MUST be received by the message target in the order they were sent by the sending peer. This order is maintained even in the case of promise shortening.

Round-trip equality

If you send a DObject reference to another peer and later receive a reference to that same object, whether from the peer you sent it to or from a third peer, those references will be equal.

It is generally recommended to not rely on Promise equality.

When you share a DObject reference with a peer and that peer shares that reference with a third peer, that is called a "third-party handoff." With the way that third-party handoffs currently work, when you receive a third-party handoff, the object reference is replaced by a promise that will eventually contain the object reference. Therefore if you round-trip an object reference between two peers, it will return as the object reference. But if it goes through three or more peers, it will return as a promise, not the object reference you sent. Eliminating this inconsistency remains a goal of the OCapN group.

Asynchronous programming with Promises

Promise vs Future

Distributed computing brings with it the need for asynchronous programming. Experienced Dart developers will be well familiar with asynchronous programming using Futures.

OCapN has features designed to bring significant improvements to distributed object programming (covered later). Unfortunately, implementing those features (and meeting all of the other design requirements) meant Future alone was not going to suffice. Therefore this library introduces the Promise which works much the same (Promise<T> implements Future<T>!) but has a few extra features.

The basic functions of Promise/Resolver are much the same as Future/Completer:

final completer = Completer<String>();
completer.complete('Hello world');
final future = completer.future;
future.then((value) => print(value)); // prints 'Hello World'

final resolver = Resolver<String>();
resolver.fulfillPromise('Hello world');
final promise = resolver.promise;
promise.then((value) => print(value)); // prints 'Hello World'

Note that because Promise<T> implements Future<T>, promises can also be used wherever a FutureOr<T> is required.

If you have a Future (say, from a db library) and need a promise, don't fret. The Promise factory constructors accept a FutureOr so you can just pass in the Future and the rest is taken care of. Furthermore, any code that requires a Future should work if passed a Promise.

Promises can be chained just like Futures. In fact, a Future can chain a Promise and a Promise can chain a Future, though the latter case does have implications explained in the next section.

Promise pipelining

So, if Promise is practically Future, why do we need promises?

We are bound by physics. Even if we optimized all of our infrastructure to be spherical-cow-level ideal and our equipment posed no latency at all (left as an exercise to the reader...), communication between two peers would still be bound by the speed of light.

Let's take a quick look at an example:

final echo = await testObject.call([const Sym('getEcho')]);
final result = await echo.call([const Sym('echo'), 'Hello world']);
print(result); // prints 'Hello world'

In this example we start with a reference to some object on another peer we have named testObject. We call it with a request for an "echo" object and wait for it to be returned. Then we call the echo object with a request to echo the String 'Hello world'. We wait again for the result to be returned and then can proceed to print the result.

Looking at the above example, we would encounter network delays four times:

  1. us requesting the echo object
  2. the peer returning the reference to the echo object
  3. us requesting that they echo our message
  4. the peer returning the echoed message

The thing is, we don't really need the echo object except to target it with our echo message.

Unlike a Future, a Promise is a DObject and thus it also has call and send methods. Like callbacks from then and catchError, calls and sends to a promise are propagated up to any chained promises. Any messages sent to a promise in this way are buffered until one of two things happens:

  1. The promise is settled (fulfilled with a value or broken with an error): In this case the message is delivered to the settled result as if it were messaged directly using call or send.

  2. The promise is eventually chained to a promise on another peer: In this case the message is immediately forwarded to the peer where they will buffer it on their local promise until one of these two cases is met for that promise. This is called promise pipelining.

Let's modify our previous example to use promise pipelining:

final echoPromise = testObject.call([const Sym('getEcho')]);
final result = await echoPromise.call([const Sym('echo'), 'Hello world']);
print(result); // prints 'Hello world'

The only difference is that instead of waiting to receive a reference to an echo object, we just get a promise of an echo object and immediately send our echo request to that promise. Through the magic of promise pipelining, the echo object still receives the echo request, but we don't have to wait for a response to our first message before sending our second. This is a significant optimization!

Promises needed to be implemented to support promise pipelining, which as we've seen is a critical performance improvement for distributed applications. Unfortunately this meant giving up Dart's built-in Future, which has some performance advantages that are internal to the Dart SDK that we can't use. In specific situations with high performance needs where you know promise pipelining is not needed, you could potentially just use Futures and then interface with Promises where needed.

Promise and async/await

Though a Promise can be chained to a Future, it is important to note that this interrupts the ability for passing promise pipeline messages. The Future will wait to be settled before propagating the call. This also means that a request for the settled result will be sent to the peer, which promise pipelining attempts to reduce the need for.

It is important to note that this unfortunately means we must be extremely careful when using the async/await style of programming. I have used it in the examples of this document (and in many of the DObject library tests) because it's cleaner and easier to read than chaining .then calls, but caution is advised.

The challenge comes from the way that async/await is implemented internally in Dart. Dart programmers will know that when a function is marked with the async keyword, it must return either a Future or void. Since a Promise is a Future, you can technically return a promise from a function marked async, BUT what that function returns is NOT the promise you returned, but rather that promise chained to a _Future. This means that if you use a function marked as async and return a Promise, it will block the ability to use promise pipelining on that result.

Casting promises

If you have a Promise<T> and want a Promise<R> where T is a sub-type of R, you can implicitly cast like this:

Promise<int> intPromise = Promise.value(4);
Promise<num> numPromise = intPromise;

If you have a Promise<T> and want a Promise<R> where R is a sub-type of T, you can perform an explicit cast like this:

Promise<num> numPromise = Promise.value(4);
Promise<int> intPromise = numPromise.cast<int>();

This may be especially useful because a promise received over OCapN that we have not previously exported will be created as a Promise<dynamic>. Though not perfect, casting at least allows assigning an expected type to such a promise.

If the settled result of the promise being casted is NOT of type R, any value listeners attached to the returned promise will be completed with an error.

Note that contrary to regular Promise behaviour, no uncaught error is thrown if the promise is settled with a value that is not of type R and no error handlers have been attached.

RemoteObject

When a you receive a reference to an object that is being hosted by another peer, that reference will default to appearing as a RemoteObject. Any messages sent to the RemoteObject are automatically forwarded to the actual remote object.

RemoteObjects themselves contain no information about the type of the imported object, but we can build on them using DWrappers and SelfTagged.

DWrapper

A DWrapper wraps around a DObject to provide a familiar local method interface for objects that otherwise would not have one.

The primary use case of DWrappers is to wrap RemoteObjects and Promises but they can be used for other interesting purposes as well, such as wrapping forwarders.

When a DWrapper is sent over OCapN the wrapped object is sent instead.

If we wanted to write a DWrapper for an Echo object, we might do so as follows:

abstract class DEcho with DObject {
  Promise<T> echo<T>(T toEcho);
}

class Echo extends DEcho { // a local Echo object
  @override
  Promise<T> echo<T>(T toEcho) {
    return Promise.value(toEcho);
  }
  
  @override
  dynamic handleMessage(List message) {
    switch(message) {
      case [const Sym('echo'), dynamic toEcho] :
        return toEcho;
      default:
        throw Exception('Invalid input.');
    }
  }
}

class EchoWrapper extends DEcho with DWrapper {
  @override
  final DObject wrapped;
  
  const EchoWrapper(this.wrapped);
  
  @override
  Promise<T> echo<T>(T toEcho) => call([const Sym('echo'), toEcho]);
  // The call and send methods on a DWrapper will forward to the wrapped object.
}

We could then use our echo wrapper as follows:

final remoteEcho = EchoWrapper(remoteObject); // where remoteObject is a RemoteObject
final result = await remoteEcho.echo('Hello world');
print(result); // prints 'Hello world'

The beauty of the DWrapper is that we can now call echo('Hello world') on a DEcho without knowing or caring whether it is a local Echo object or a WrapperEcho. It also means we don't need to interact with an "untyped" RemoteObject via call([const Sym('echo'), 'Hello world']) and can instead just use a regular method call that follows an expected interface with all the powers of static analysis.

For those who don't mind dealing with build_runner, see DObjects_gen for a way to (deterministically!) generate wrappers.

Tagged

Tagged objects are the means by which we can expand the limited set of accepted message types.

Two Tagged objects are equal and have the same hash code if and only if both their tag and value are deep equal, regardless of whether they are CustomTagged or SelfTagged.

CustomTagged

A CustomTagged data structure is comprised of a String tag and a single value, where the value itself is one of the accepted message types.

Here is a simple example:

final class MyTimestamp extends CustomTagged {
	// A timestamp whose value is the number of milliseconds since the Unix epoch
	MyTimestamp(int millis) : super(tag: 'MyTimestamp', value: millis);
}

More complex types can be built by having the value of the CustomTagged object be a List, Set, or Map.

SelfTagged

As mentioned earlier, any remote object sent to us by a peer is referenced as a RemoteObject that contains no information about what type the remote object is.

While it is entirely possible to build applications in such a way, we would lose the advantages of static type checking. To allow indicating the type of a DObject we are sending to a peer, we can use the SelfTagged mixin.

A SelfTagged DObject is a regular DObject that when sent over OCapN is transmitted wrapped as a Tagged value.

A SelfTagged DWrapper is transmitted as a Tagged where the value is the DWrapper's wrapped value.

Extending our echo example to use SelfTagged is simple:

abstract class DEcho with DObject, SelfTagged {
	@override
	final String tag = 'echo';

	Promise<T> echo<T>(T toEcho);
}

Now instead of receiving only a RemoteObject representing an Echo object, we would receive a CustomTagged object with a tag of 'echo' and a value that is the RemoteObject reference.

taggedBuilder

It's nice and all that we can receive CustomTagged objects, but it would be even nicer if we received objects as the actual type that the tag indicates. Then we could use static type checking on incoming custom types.

If we receive a Tagged object and its value is a reference to a local SelfTagged object with the same tag as the Tagged object, the Tagged object is automatically replaced with its value before the message is passed to handleMessage.

When we create a CapTP instance, we can also provide a taggedBuilder function that is automatically run on all remaining incoming Tagged data. Here's an example function we could use:

Tagged? myTaggedBuilder(String tag, dynamic value) {
	if(tag == 'echo' && value is RemoteObject) {
		return EchoWrapper(value);
	}
}

Now if a peer sends us a tagged echo object, we will receive it in our handleMessage method as an Echo object if it is a reference to an object we are hosting or an EchoWrapper if it is a reference to an object hosted by another peer. Either way, we receive a DEcho object.

If our taggedBuilder returns null then the Tagged will be represented as a CustomTagged object.

SturdyRef

A SturdyRef is a capability that can be used to bootstrap access to a specific DObject at a specific peer.

All SturdyRefs represent objects but not all objects have a SturdyRef.

Each CapTP object contains a sturdyRefManager that possesses capabilities for managing sturdy references.

Registration

The first sturdyRefManager capability allows registering a local DObject to be accessible through the returned SturdyRef.

SturdyRef myRef = capTP.sturdyRefManager.register(myDObject);

Each sturdy reference is stored to be reachable via randomized byte data called a "swiss num". In order to preserve the security benefits of a swiss num it MUST have sufficiently high entropy as to be practically unguessable.

Swiss nums are automatically generated when you register an object, but you can provide a custom swiss num if necessary. The most common use-case for doing so is when restoring application state after a shut-down so that objects are still accessible by their old references.

Important: A DObject registered with a SturdyRefManager will not be eligible for garbage collection.

De-registration

To remove a local SturdyRef from the registry and free up its referenced object for garbage collection:

capTP.sturdyRefManager.deregister(myRef);

Export

If we have a SturdyRef object and want an out-of-band means of providing access to the registered object (sometimes called an "offline capability"), we can use the SturdyRefManager's export capability as such:

Uri refUri = capTP.sturdyRefManager.export(myRef);
// share the URI out of band

Note: SturdyRef objects are bound to a particular instance of CapTP that created them. If for some reason you have multiple CapTP objects, a SturdyRef can only be exported by the CapTP whose SturdyRefManager it was registered with.

Import

We can import an offline capability URI as follows:

SturdyRef myRef = capTP.sturdyRefManager.import(refUri);

Enliven

Finally, to get a reference to the object registered at a particular SturdyRef, we use the enliven method. If we know we are expecting a SelfTagged object, we can even specify the expected type. For example:

Promise<DEcho> echoPromise = sturdyRef.enliven<DEcho>();

Recovery from failure

While this library is designed to minimize thinking about connections and other distributed computing challenges, the following two methods are included to listen for lost connections.

As with call and send, invoking either of these two methods on a DWrapper will invoke the corresponding method on the wrapped object.

onDisconnect

To register a callback to be called when the connection to a particular remote object is lost, use the onDisconnect method.

Callbacks are called in order of registration and will never be called for local objects (because you can't disconnect from yourself).

remoteObject.onDisconnect(() => print('Connection to remoteObject lost!'))

onClientDisconnect

To register a callback to be called whenever a connection is lost to a peer that had a live reference to a DObject, use the onClientDisconnect method.

Callbacks are called in order of registration and will never be called for remote objects.

localDObject.onClientDisconnect(() => print('Client connection lost!'))

Distributed garbage collection

The OCapN protocol includes a means of communicating acyclic garbage collection (GC) messages so that peers can inform each other when they no longer need a particular reference.

The DObjects library takes care of this automatically. If the Dart garbage collector says that you no longer have a (non-weak) reference to a particular remote object or promise, the CapTP object will automatically transmit a message to the host peer.

All you need to do is be a good peer and don't hold on to references longer than you need to, which is generally good programming practice anyway.

The CapTP object can be configured with two means of garbage collection detection: finalizers and polling.

Finalizer-based GC detection is enabled by default and can be disabled using the useFinalizerGCDetection parameter when constructing a CapTP object. While finalizers add additional memory overhead, they can also allow a relatively quick discovery of a particular object being freed by the Dart garbage collector.

Unfortunately Dart finalizers can not be trusted on their own; the documentation says explicitly that it does not guarantee a finalizer's callback will actually be called. To catch cases where the finalizer callback was not called, weak references of all imported promise and object references are polled periodically to see if they have been collected by the Dart garbage collector. The polling period can be configured when constructing a CapTP object by using the weakRefPollPeriod parameter.

Debugger

This library provides preliminary support for distributed debuggers through the DDebugger.

CapTP has a debuggers field that contains a list of attached remote debuggers. CapTP will automatically send a copy of every sent and received message to the debuggers in that list. Keep in mind that this means any secrets in those messages are shared with the debugger.

Note that the DDebugger currently operates under the assumption that none of the participating peers are maliciously reporting false information to the debugger. This can be revisited if there is sufficient interest.

Common DObjects

There are certain patterns that are likely to be of interest for many users of the DObjects library. To this end, I have begun assembling a library of Common_DObjects.

Sample application

Sometimes it's easier to learn by seeing concepts applied in practice. Towards that end, I have put together a SimpleChat sample application.

SimpleChat was designed to interoperate with Goblin Chat, an example application by the Spritely Institute written in Guile Scheme. You may notice that SimpleChat doesn't take advantage of SelfTagged and that's because Goblin Chat was designed years before SimpleChat and did not use Tagged objects.

Acknowledgements

This project would not have been possible without decades of research into object capability security performed by various passionate people. Thanks for laying the foundations. Bit by bit, I continue to understand more and dream bigger of what is possible.

I would especially like to thank the kind people at the Spritely Institute for encouraging me to take on this project and supporting me along the way.

This project is funded through NGI0 Commons Fund, a fund established by NLnet with financial support from the European Commission's Next Generation Internet program. Learn more at the NLnet project page.

NLnet foundation logo NGI Zero Logo