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:
@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:expiryMs, createSubDelegation defaults to the longest lifetime the
parent allows. Sessions activated from a received delegation default the same
way.
Block further delegation
createSubDelegation() signs with the wallet, so it cannot set
disableSubDelegation; passing true throws. To issue a grant the recipient
cannot pass on, use createDelegation() with disableSubDelegation: true and
address it to the recipient’s session-key did:key, not its did:pkh owner
DID. Here carolSession is a client without a wallet signer. Its
credentialHolderDid is the bare did:key session-key DID; use it rather than
carolSession.did, which carries a #fragment that createDelegation rejects
as an invalid audience DID:
createDelegation() throws if disableSubDelegation is combined with a
did:pkh recipient. Drop the flag for a wallet recipient.
Revoke access
Both the Node and Web SDKs exposerevokeDelegation():
revokeDelegation() when access must end now.
Inspect received grants
The Node SDK records delegations installed byuseDelegation():
