# [SealRecipient] — a row a value may be sealed for

> Marks the member of an entity that holds a recipient's P-256 public key (base64 SPKI or PEM) — a build host's sealing key — so a value can be sealed (fcs1) for a ROW of that entity on the server: a stored keyed value with `Secret.X.SealFor(id, to: host, …)`, or a value an answer issues with `Http.PostSealedFor(…, to: host, …)`. The platform reads the key and the label from the row as stored, never from anything the code built or changed, so a key written as text, computed, or taken from a request can never be a recipient.

<!-- id: security-seal-recipient · area: security · stability: preview · html: https://osysharp.com/reference/security/seal-recipient/ -->

## Summary        {#summary}
`[SealRecipient(Label = Name)]` on a `string` member says: *this member holds a public key that a value may be sealed
for, and `Name` is what the sealed text is bound to as its host.* It is the only way to name a recipient of a server
seal — the `to:` of [`Secret.X.SealFor` and `Http.PostSealedFor`](#use) is a **row** of such an entity, never a key.

| | what it is |
|---|---|
| the member | a `string` (or `string?`) holding the recipient's P-256 public key, as base64 SPKI or PEM |
| `Label = Member` | a `string` member of the same entity; its text is the fcs1 `host` the sealed text opens as |
| one per entity | a row is one recipient |

## Signature      {#signature}
```osy syntax
[SealRecipient(Label = Name)] string? SealingKey;
```

## Description    {#description}

### Declaring a recipient   {#declare}
```osy title="a build host that values can be sealed for" test app=security-seal-recipient
entity BuildHost {
  [MaxLength(200)] string Name;
  /// The host's P-256 public key, as the host reported it.
  [SealRecipient(Label = Name)] string? SealingKey;
  security { allow read when IsAuthenticated; }
}
```

### Sealing for it   {#use}
A **stored keyed value** is sealed with `Secret.X.SealFor` — the id's value leaves the platform only as fcs1 text for the
row's stored key, the fcs1 `name` is the id, and the secret's `MayUse(id)` is asked as the caller — see [declaring secrets (app.Secrets)](https://osysharp.com/reference/config/secrets/):

```osy syntax title="seal a stored keyed value for a host row"
string sealedKey = Secret.ModelKeys.SealFor(key.Id.ToString(), to: host, kind: "anthropic", why: "approved on the host page");
```

A value an **answer issues** is sealed with `Http.PostSealedFor`: it posts, and the field of the answer it names leaves
the platform only as fcs1 text sealed for the row's stored key — see [Http.*](https://osysharp.com/reference/http/facade/) (`#post-sealed-for`):

```osy syntax title="seal a token an answer issues for a host row"
var r = Http.PostSealedFor("https://api.github.com/app/installations/" + installation + "/access_tokens", "",
  "application/json", headers, field: "token", to: host, kind: "github", name: "GH_TOKEN", why: "a build on " + host.Name);
```

### What the platform holds you to   {#rules}
- **The row as stored.** The key and the label are read from the database through a fresh read as the caller — an edit
  the code made to the row in memory is not what is sealed for, and a row the caller cannot read is refused.
- **No key, no seal.** A row whose key member is empty, or whose key is not a P-256 public key, is refused before
  anything is sealed — and, for `Http.PostSealedFor`, before anything is sent, so a provider never issues a value nobody
  can receive.
- **Labels.** The label, `kind:` and `name:` may not be empty or contain `|` (it separates the parts the sealed text is
  bound to).
- **Recorded.** Every seal for a recipient — and every refused one — is recorded with the row, its label, the SHA-256
  fingerprint of its key, the kind, who ran it, why and how it ended, and committed before the sealed text is handed back.
  The record never holds the value or the sealed text. A keyed secret's seals are read with `Secret.X.UsesFor(id)`.
- **Shape.** Not on a `class` (no rows), one per entity, on a `string`, and `Label` names another `string` member — each a
  compile error naming the fix.

## See also   {#see-also}
- [Http.*](https://osysharp.com/reference/http/facade/) — `Http.PostSealedFor`, and `Http.PostToSecrets` for a credential meant for your own app
- [Crypto.SealToHost — seal a page input to a host's public key](https://osysharp.com/reference/function/crypto-seal-to-host/) — the same fcs1 format, sealed in the browser from a password input
- [declaring secrets (app.Secrets)](https://osysharp.com/reference/config/secrets/) — keyed secrets: one stored value per id
