Skip to main content
Use this guide to grant another signed-in TinyCloud principal access to a path in your space. In the examples, alice and bob are SDK instances that have already completed signIn().

Create and use a delegation

Use the recipient’s owner DID. After wallet sign-in, bob.did is that owner DID; bob.sessionDid identifies the ephemeral session key instead.
useDelegation() returns a DelegatedAccess handle for the delegator’s space. Its KV service is already rooted at shared/, so its keys are relative to that delegated path. It does not copy the data into the recipient’s space.

Serialize for transport

createDelegation() returns a PortableDelegation object. To send it as text, use the SDK helpers instead of manually converting its Date fields:
The same helpers are exported by @tinycloud/web-sdk for browser applications. The serialized delegation is a bearer credential; do not log it or send it through an untrusted channel.

Narrow access further

If the parent permits sub-delegation, Bob can grant Carol a narrower subset:
The child must stay within the parent’s resources and action set, cannot outlive the parent, and cannot bypass a parent’s sub-delegation restriction.

Revoke access

Both the Node and Web SDKs expose revokeDelegation():
Revocation is node-confirmed and invalidates use of that delegation. Revoking an ancestor also prevents its descendants from being used. The Node SDK can query the node-confirmed lifecycle state:
Delegations also stop working at their signed expiry. Expiry limits exposure, but it is not a substitute for revokeDelegation() when access must end now.

Inspect received grants

The Node SDK records delegations installed by useDelegation():
For the SDK transport fields and the node’s validation model, see Delegations.