# `OidcClaims`

Who an identity provider says signed in (OpenID Connect Core 1.0 §5.1): the subject and the standard claims a sign-in reads, each by its own name. Personal data.

[Security](types.md#security); not ordered; since Jadpo 0.1.0.

## Make one

Build one from its fields, `OidcClaims { sub: ... }`.

## Fields

| Field | Type |
|---|---|
| `sub` | `Text` |
| `name` | `Text?` |
| `given_name` | [`GivenName`](type-given-name.md)`?` |
| `family_name` | [`FamilyName`](type-family-name.md)`?` |
| `preferred_username` | `Text?` |
| `email` | [`Email`](type-email.md)`?` |
| `email_verified` | `Bool?` |
| `phone_number` | [`PhoneNumber`](type-phone-number.md)`?` |
| `phone_number_verified` | `Bool?` |
| `picture` | [`Url`](type-url.md)`?` |

## Text, JSON and storage

It has no single text form, so `text.from` and `text.parse` don't take it. JSON sends an object of its parts.

| JSON |
|---|
| `{"sub":"248289761001","name":"Jane Doe","given_name":"Jane","family_name":"Doe","preferred_username":"j.doe","email":"janedoe@example.com","email_verified":true,"picture":"https://example.com/janedoe/me.jpg"}` |
| `{"sub":"248289761002","email":"j.doe@example.org","email_verified":false}` |
| `{"sub":"248289761003"}` |

It is stored in 10 columns, each named for the field, `_` and its suffix. This is `{"sub":"248289761002","email":"j.doe@example.org","email_verified":false}`:

| Column | Type | Holds |
|---|---|---|
| `<field>_sub` | `text` | `'248289761002'` |
| `<field>_name` | `text` | `NULL::text` |
| `<field>_given_name` | `text` | `NULL::text` |
| `<field>_family_name` | `text` | `NULL::text` |
| `<field>_preferred_username` | `text` | `NULL::text` |
| `<field>_email` | `text` | `'j.doe@example.org'` |
| `<field>_email_verified` | `boolean` | `FALSE` |
| `<field>_phone_number` | `text` | `NULL::text` |
| `<field>_phone_number_verified` | `boolean` | `NULL::boolean` |
| `<field>_picture` | `text` | `NULL::text` |

## Shown to people

`text.format(value, locale:)` shows it to people in their locale.

With `locale: Locale.en_gb`:

| Value | Shown |
|---|---|
| `{"sub":"248289761001","name":"Jane Doe","given_name":"Jane","family_name":"Doe","preferred_username":"j.doe","email":"janedoe@example.com","email_verified":true,"picture":"https://example.com/janedoe/me.jpg"}` | `Jane Doe` |
| `{"sub":"248289761002","email":"j.doe@example.org","email_verified":false}` | `j.doe@example.org` |
| `{"sub":"248289761003"}` | `248289761003` |

## Operations

It has the contract's own operations: `text.format`, `json.read`, `json.write` and `==`. It isn't ordered, so `<` and sorting don't take it. [Every standard type meets one contract](../topics/every-standard-type-meets-one-contract.md) says how they work.
