keyForEnvelope
keyForEnvelope(
node,envelopeMetadata,holder?):Uint8Array
Defined in: derive.ts:367
Derive a piece’s key from whichever node the caller holds.
A keyspace-key holder walks the piece’s whole scope path. A scope holder walks the rest of the path below its own scope — which works only if its scope is the piece’s scope or an ancestor of it. A piece holder already has the key, and gets it back only for the piece whose salt it names.
Takes the metadata as FEE returns it (info.appMetadata), unvalidated, and
checks every field before using it.
Pass the grant that delivered the key as holding where you have it: then the
piece’s owner and keyspace are checked against the grant too, so a key from the
wrong keyspace fails here with a clear reason rather than later inside FEE.
Parameters
Section titled “Parameters”| Parameter | Type | Default value |
|---|---|---|
node | Uint8Array | undefined |
envelopeMetadata | PieceMetadata | Readonly<Record<string, unknown>> | undefined | undefined |
holder | GrantDescriptor | Holding | 'keyspace' |
Returns
Section titled “Returns”Throws
Section titled “Throws”If the piece is not in this format, belongs to another owner or keyspace than the grant, the held scope does not contain the piece’s scope, or the held piece is a different piece.