SDK
share
What geode.share returns for a vault file, how the link carries its key, and the errors it raises.
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
Unlock the vault
On the client's first vault call, the wallet signs the key message and the manifest is read, as in
recover.Find the entry
The client finds the manifest entry with this
id. None raisesNOT_FOUND.Build the link
'/s/' + encodeURIComponent(id) + '#' + key. It equals the entry'slinkand thelinkthatstorereturned.
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
idrequiredstringStoreResult.id or FileEntry.id.Return value
linkstring/s/<id>#<key>.What it costs
Nothing. No request is made once the vault is unlocked, and no transaction is sent.
Errors
| Code | Raised when |
|---|---|
NOT_FOUND | The vault has no file with this id |
WALLET_REJECTED | The 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_FAILED | The manifest or the notes cannot be read on first unlock |
UPSTREAM_UNAVAILABLE | A network failure or any other unrecognised error |
Codes from /manifest and /tree pass through as listed at /docs/api#errors.
Sample
const link = await geode.share(id)
const absolute = new URL(link, 'https://geode.directory').toString()
await navigator.clipboard.writeText(absolute)