puter.kv.unshare() Stops a share made with puter.kv.share().
Either side can call it:
The handle stops working right away for every puter.kv call. Persistent subscriptions on it are suspended with permission_revoked, and onLocal() subscriptions on it end with permission_revoked. If the holder still has a wider share that covers the same keys, calls through the stopped handle can keep working for up to 60 seconds. The keys stay in the owner's store.
A stopped share stays in the owner's puter.kv.listSharedByMe() listing for 30 days, with revokedAt and revokedBy set. Sharing the same prefix with the same user again makes a new share with a new handle.
puter.kv.unshare(handle)
handle (String) (required)
The share's handle, from puter.kv.share(), puter.kv.listSharedByMe(), or puter.kv.listShared().
A Promise that resolves to:
handle (String): The share that stopped.revokedAt (Number): When it stopped, in Unix seconds.Stopping a share that already stopped resolves the same way again.
The promise rejects with { message, code }:
| Code | Meaning |
|---|---|
invalid_request |
No handle was given. |
subject_does_not_exist |
The handle doesn't exist, you're neither its owner nor its holder, or the holder called from an app other than the one whose data it shares. |
events_kv_handle_not_delegated |
An app revoked its user's share without the user's consent for that prefix. |
events_kv_handle_owner_only |
The owner called from an app other than the one whose data it shares, or from an access token with less access than the account. |
too_many_requests |
Over the rate limit, which sharing and unsharing count toward together. See Rate Limits and Quotas. |
subject_does_not_exist, the same as one that doesn't exist.puter.kv.share() needs. To remove the user's own access as the holder, it needs no consent.Unsharing works when sharing is turned off on the deployment, so you can always stop a share.
puter.kv.share() - Share keys with another userputer.kv.listSharedByMe() - List the shares you madeputer.kv.listShared() - List the shares made with youconst share = await puter.kv.share('list:42:', 'alice', 'write');
const { revokedAt } = await puter.kv.unshare(share.handle);
puter.print(`Stopped at ${new Date(revokedAt * 1000).toISOString()}`);
const { items } = await puter.kv.listShared();
for (const share of items) {
if (share.label === 'Old project') {
await puter.kv.unshare(share.handle);
}
}