SDK

share

What geode.share returns for a vault file, how the link carries its key, and the errors it raises.

TypeScript
share(id: string): Promise<string>

share returns the share link of a file in the vault: /s/<id>#<key>, with the id URL-encoded and the file key in the fragment. The link is relative; the application prefixes its own origin.

What it does

  1. Unlock the vault

    On the client's first vault call, the wallet signs the key message and the manifest is read, as in recover.

  2. Find the entry

    The client finds the manifest entry with this id. None raises NOT_FOUND.

  3. '/s/' + encodeURIComponent(id) + '#' + key. It equals the entry's link and the link that store returned.

A browser sends no fragment to a server, so the key stays with whoever holds the link. open(id, key) on the other side reads it back with no wallet.

Arguments

share(id)
idrequired
string
The Irys id of a file in this vault, as in StoreResult.id or FileEntry.id.

Return value

string
link
string
The relative link /s/<id>#<key>.

What it costs

Nothing. No request is made once the vault is unlocked, and no transaction is sent.

Errors

CodeRaised when
NOT_FOUNDThe vault has no file with this id
WALLET_REJECTEDThe client has no wallet, or the wallet declines the key message
VALIDATION_ERROR, WRONG_KEY, IRYS_UNAVAILABLE, PAYLOAD_TOO_LARGE, CONFIGURATION_REQUIRED, UNKNOWN_ROOT, RELAYER_FAILEDThe manifest or the notes cannot be read on first unlock
UPSTREAM_UNAVAILABLEA network failure or any other unrecognised error

Codes from /manifest and /tree pass through as listed at /docs/api#errors.

Sample

TypeScript
const link = await geode.share(id)
const absolute = new URL(link, 'https://geode.directory').toString()
await navigator.clipboard.writeText(absolute)