# disclosure.yaml

A file where an app lists what it connects to, the credentials it handles and any pages that open without a login. Anyone can read it, and any JSON Schema validator can check it.

Source: https://ha-barkley.github.io/disclosure/

## What the file is for

Home Assistant integrations, cards and apps can reach a lot. An integration runs inside Home Assistant itself, and a card runs on the same page as the user's login. Users and reviewers can read the code, but working out from code which servers an app talks to, and why, takes time.

`disclosure.yaml` is the developer's own account of that, in a form people can read and tools can check. Nothing in it is proven, so a tool that reads it should show it as what the developer says, compare it with what it finds in the code, and point out where the two differ. A connection listed in the file isn't safe because it's listed.

When the code shows something different from the file, the code wins. A tool should go by what it found and show the developer's statement beside it. A difference isn't a sign of bad intent. Often the developer didn't know, and that's exactly what the comparison is for. Where a tool can't see something at all, such as how long a token lasts, it can show the developer's answer as theirs, but it shouldn't treat that answer as checked.

## Where it goes

At the root of the repository, named `disclosure.yaml`, and changed in the same commit as the code it describes. When the repository holds more than one integration, card or app, one file covers them all, and entries can say which one they're about with `component`.

Every section is optional, and the difference between leaving a section out and leaving it empty matters. A section that's missing means "not stated". An empty list (`[]`) means "none", so `telemetry: []` says the app sends no telemetry. The same goes for `sends`: `sends: []` says the requests carry nothing beyond the request itself.

Every entry can carry a `note` and a `component`. Any key that starts with `x-` is allowed anywhere, for details a developer or a tool wants to try out. Every other key is checked.

YAML reads some bare words as something else: `on`, `off`, `yes` and `no` can turn into true and false. Put quotes around a value like that when you mean the word.

## The fields

The file starts with `version: 1`, which is required. Then any of these sections, each a list of entries.

### connections

Servers outside Home Assistant that the app contacts.

| Field                | Required                                         | What it says                                                                                                                                                                                                                              |
|----------------------|--------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `source`             | yes                                              | Where the connection starts: `home_assistant` (Home Assistant itself) or `browser` (the browser showing the dashboard)                                                                                                                    |
| `destination`        | `destination` or `destination_set_by`            | The server it goes to: a host name, `*.` plus a domain for any of its subdomains, or an IP address. A list of them is fine when everything else in the entry is the same                                                                  |
| `destination_set_by` | `destination` or `destination_set_by`            | Who supplies the address when it isn't written in the code: `setup` (the user enters it while setting the app up), `setting` (a setting the user can change later) or `server_reply` (a server's answer says where to go next)            |
| `port`               | no                                               | Only when it isn't the usual port for the protocol                                                                                                                                                                                        |
| `purpose`            | yes                                              | Why, in a sentence                                                                                                                                                                                                                        |
| `run_by`             | no                                               | Who runs the server: `developer` (the app's developer), `vendor` (the company or public body whose device or service the app is for), `third_party` (anyone else, such as a map tile service) or `user` (the user's own device or server) |
| `run_by_name`        | no                                               | Their name, such as a company or a town                                                                                                                                                                                                   |
| `network`            | no                                               | Where the server is: `home` (the user's home network), `internet`, or `either`, depending on the user's setup                                                                                                                             |
| `encrypted`          | no                                               | `always`, `never`, or `setting` when a setting decides                                                                                                                                                                                    |
| `encryption_setting` | when `encrypted` is `setting`                    | The setting that turns encryption on                                                                                                                                                                                                      |
| `when`               | yes                                              | `always`, `setting` (only when a setting turns it on) or `user_action` (only when a person does something, such as opening a popup)                                                                                                       |
| `setting`            | when `when` or `destination_set_by` is `setting` | The setting's name, as users see it or write it                                                                                                                                                                                           |
| `condition`          | no                                               | The exact condition in words, when it's more than one setting                                                                                                                                                                             |
| `on_by_default`      | no                                               | `true` when the setting that turns it on is on out of the box                                                                                                                                                                             |
| `sends`              | no                                               | What the requests carry, from the list below                                                                                                                                                                                              |

`sends` can list:

| Value               | Means                                                                                                                                                                         |
|---------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `ip_address`        | The user's IP address. Every request carries it, so list it when it matters to the service, such as a map or weather service that also gets `map_area` or `physical_location` |
| `physical_location` | Coordinates or a street address: the home's, a person's or a device's                                                                                                         |
| `map_area`          | The part of a map being viewed                                                                                                                                                |
| `entity_states`     | States or attributes of Home Assistant entities                                                                                                                               |
| `credentials`       | A password, token or key the user gave                                                                                                                                        |
| `device_ids`        | Serial numbers, MAC addresses or account ids of devices                                                                                                                       |
| `ha_address`        | The address of the user's Home Assistant, for example in a `Referer` header                                                                                                   |
| `media`             | Camera images, audio or video                                                                                                                                                 |
| `personal_details`  | A name, email address or phone number                                                                                                                                         |
| `versions`          | The app's or Home Assistant's version                                                                                                                                         |

### links

Sites the app only links to. They open when a person selects the link. Each entry has a `host` or a `url`, and can have a `purpose`.

### pages

Pages and endpoints the app adds that answer without a Home Assistant login.

| Field        | Required | What it says                                                                                                                                                                                                                                    |
|--------------|----------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `path`       | yes      | The path, starting with `/`                                                                                                                                                                                                                     |
| `protection` | yes      | What stands in for the login: `none` (nothing, so anyone who can reach Home Assistant gets an answer), `own_token` (the app checks a token of its own), `signed_link` (a link Home Assistant signed) or `webhook` (a Home Assistant webhook id) |
| `local_only` | no       | `true` when it only answers on the local network                                                                                                                                                                                                |
| `purpose`    | yes      | Why it opens without a login                                                                                                                                                                                                                    |
| `checks`     | no       | What the app checks itself before it answers                                                                                                                                                                                                    |

### credentials

Passwords, tokens and keys the app asks the user for.

| Field       | Required | What it says                                                                      |
|-------------|----------|-----------------------------------------------------------------------------------|
| `what`      | yes      | What it is, such as "the Petal Garden account password"                           |
| `asked_in`  | yes      | `config_flow`, `options_flow`, `yaml`, `card_config` or `environment`             |
| `stored_in` | no       | `config_entry`, `secrets_yaml`, `card_config` or `own_storage`                    |
| `sent_to`   | yes      | The hosts it goes to. `setup_address` means the address the user entered at setup |

### login\_tokens

Home Assistant login tokens the app creates, reads or hands on. Tokens the user pastes in for another service go under `credentials`.

| Field        | Required | What it says                                                                                                                                                                               |
|--------------|----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `kind`       | yes      | `long_lived`, `refresh` (it can make new access tokens), `access` (short-lived) or `dashboard_session` (the token of the person using the dashboard, which a card can read in the browser) |
| `admin_user` | no       | `true` when the token belongs to an administrator                                                                                                                                          |
| `lifetime`   | no       | How long it lasts, such as `30 minutes` or `365 days`                                                                                                                                      |
| `given_to`   | no       | Where it goes outside Home Assistant: hosts, or `setup_address`. An empty list says it stays in Home Assistant, or in the browser for a `dashboard_session`                                |
| `purpose`    | yes      | Why the app needs it                                                                                                                                                                       |

### home\_assistant\_access

Parts of Home Assistant the app uses beyond its own entities and settings. Each entry has `uses` and a `purpose`.

| `uses`                   | Means                                                                                                                                                              |
|--------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `secrets_file`           | Reads `secrets.yaml`                                                                                                                                               |
| `other_apps_settings`    | Reads other integrations' options                                                                                                                                  |
| `other_apps_credentials` | Reads other integrations' stored passwords, tokens or keys                                                                                                         |
| `user_list`              | Reads the list of users                                                                                                                                            |
| `change_users`           | Adds, changes or removes users                                                                                                                                     |
| `login_store`            | Reads Home Assistant's login store                                                                                                                                 |
| `storage_files`          | Reads or writes files in `.storage` directly                                                                                                                       |
| `supervisor_api`         | Calls the Supervisor API                                                                                                                                           |
| `location_history`       | Reads location history for many entities at once                                                                                                                   |
| `patches_home_assistant` | Replaces or wraps Home Assistant's own code while it runs                                                                                                          |
| `actions`                | Runs actions on entities that aren't its own, or actions that change Home Assistant itself. List them in `actions`, such as `[lock.unlock, homeassistant.restart]` |

### embedded\_keys

Keys, tokens and certificates written into the code the app ships.

| Field                 | Required | What it says                                                                                                                    |
|-----------------------|----------|---------------------------------------------------------------------------------------------------------------------------------|
| `file`                | yes      | The file it's in                                                                                                                |
| `kind`                | yes      | `vendor_client_key`, `vendor_certificate`, `public_key`, `test_value` or `service_key` (a key for a service the developer runs) |
| `same_for_every_user` | yes      | `true` or `false`                                                                                                               |

### telemetry

Usage statistics, analytics and crash reports.

| Field                   | Required | What it says                                  |
|-------------------------|----------|-----------------------------------------------|
| `destination`           | yes      | Where it goes, one host or a list             |
| `type`                  | yes      | `usage_stats`, `analytics` or `crash_reports` |
| `contents`              | yes      | What's in a report, and how often it's sent   |
| `on_by_default`         | yes      | `true` when it's on out of the box            |
| `setting`               | no       | The setting that turns it on or off           |
| `run_by`, `run_by_name` | no       | Who runs the server, as in connections        |
| `sends`                 | no       | From the same list as connections             |

### encoded\_content

Large base64, hex or compressed content in the code. Each entry has the `file` and a `kind`: `image`, `font`, `key`, `lookup_table`, `data` or `code`.

### compiled\_code

Compiled files the app ships, such as native modules or Python bytecode.

| Field        | Required | What it says                                                                                 |
|--------------|----------|----------------------------------------------------------------------------------------------|
| `file`       | yes      | The compiled file                                                                            |
| `built_by`   | yes      | `ci` (a public build workflow made it) or `developer` (built on the developer's own machine) |
| `built_from` | no       | A link to its source code                                                                    |

### runtime\_downloads

Code the app downloads and runs while it runs.

| Field                                 | Required                               | What it says                                                                       |
|---------------------------------------|----------------------------------------|------------------------------------------------------------------------------------|
| `what`                                | yes                                    | What it is                                                                         |
| `kind`                                | yes                                    | `python_package`, `javascript`, `script`, `lua` or `binary`                        |
| `destination` or `destination_set_by` | one of them                            | Where it comes from: a host or URL, or who supplies the address, as in connections |
| `setting`                             | when `destination_set_by` is `setting` | The setting's name                                                                 |
| `pinned`                              | yes                                    | `true` when the app asks for one exact version or checks a checksum                |

### generated\_files

Files the app writes outside its own storage, such as a card it copies into `www/`. Each entry has the `path`.

## An example file

A made-up integration that also ships a map card. Its hosts use the reserved `.example` domain.

`sample.yamlDownload`

```
# disclosure.yaml for Petal Garden, a made-up integration with a map card.
# Spec: https://ha-barkley.github.io/disclosure/
# Checked against a copy of the schema in .github/disclosure.schema.json
version: 1

connections:
  - destination: api.petalgarden.example
    source: home_assistant
    purpose: Reads soil moisture and sets watering schedules.
    run_by: vendor
    run_by_name: Petal Garden
    network: internet
    encrypted: always
    when: always
    sends: [credentials, device_ids, entity_states]
  - destination_set_by: setup
    source: home_assistant
    purpose: The Petal Garden hub on the local network.
    run_by: user
    network: home
    encrypted: never
    when: always
    sends: [credentials]
    note: The hub only speaks plain HTTP. The password is the hub's own, not the account's.
  - destination: "*.tile.openmaps.example"
    source: browser
    purpose: Map tiles for the garden map card.
    run_by: third_party
    run_by_name: OpenMaps
    network: internet
    encrypted: always
    when: setting
    setting: map_style
    condition: "map_style: Streets or Terrain"
    on_by_default: true
    sends: [ip_address, map_area, ha_address]
  - destination_set_by: setting
    setting: custom_tile_url
    source: browser
    purpose: Your own map tiles.
    run_by: user
    network: either
    when: setting
    condition: "map_style: Custom"
    sends: [ip_address, map_area, ha_address]
  - destination:
      - weather.petalgarden.example
      - weather-eu.petalgarden.example
    source: home_assistant
    purpose: Rain forecast, so watering can be skipped before rain.
    run_by: vendor
    run_by_name: Petal Garden
    network: internet
    encrypted: always
    when: setting
    setting: Skip watering when rain is due
    on_by_default: false
    sends: [physical_location]

links:
  - url: https://petalgarden.example/support
    purpose: Help link in the setup dialog.
  - host: openmaps.example
    purpose: Map credits.

pages:
  - path: /api/petal_garden/zones
    protection: own_token
    local_only: true
    purpose: Lets the Petal phone app list and water zones.
    checks: The hub's token in the X-Petal-Token header.
  - path: /api/webhook/
    protection: webhook
    purpose: The cloud reports a finished watering run.

credentials:
  - what: Petal Garden account password
    asked_in: config_flow
    stored_in: config_entry
    sent_to: [api.petalgarden.example]
  - what: Hub password
    asked_in: config_flow
    stored_in: config_entry
    sent_to: [setup_address]

login_tokens:
  - kind: dashboard_session
    given_to: []
    purpose: The map card reads zone states over Home Assistant's own websocket.

home_assistant_access: []

embedded_keys:
  - file: custom_components/petal_garden/const.py
    kind: vendor_client_key
    same_for_every_user: true
    note: The Petal Garden phone app's own client id.

telemetry:
  - destination: stats.petalgarden.example
    type: usage_stats
    contents: Its version and the number of zones, once a day.
    on_by_default: false
    setting: Share anonymous usage
    run_by: developer
    sends: [ip_address, versions]

encoded_content:
  - file: custom_components/petal_garden/icons.py
    kind: image
    note: Base64 PNG icons for the zone types.

compiled_code: []

runtime_downloads: []

generated_files:
  - path: www/community/petal-garden/garden-map.js
    note: The map card, copied here at setup for the dashboard.
```

## Checking a file

Copy the schema into your repository, for example as `.github/disclosure.schema.json`, and check the file against that copy. That way your build doesn't depend on this site. Any validator that supports JSON Schema draft 2020-12 works, for example:

```
check-jsonschema --schemafile .github/disclosure.schema.json disclosure.yaml
```

Editors that use the YAML language server, such as Visual Studio Code with its YAML extension, check the file as you type when its first line points at your copy:

```
# yaml-language-server: $schema=.github/disclosure.schema.json
```

You can point at [the published schema](https://ha-barkley.github.io/disclosure/v1/schema.json) directly instead. Its address and its contents never change, but your build then depends on this site being up.

The SHA-256 of version 1's schema is `51c035784a6592333a1b2b911aa76aca6f6bf0c6b4cf91e44a7d33944b294cc3` . A copy with the same hash is the published version.

## Changes between versions

Version 1 is fixed. Once it's published, neither its schema nor the rules on this page change, so a file that's valid today stays valid. New sections, fields or values go into version 2, with its own schema at `/disclosure/v2/schema.json` and `version: 2` in the file.

This spec, its schema and the example file are dedicated to the public domain under [CC0 1.0](https://creativecommons.org/publicdomain/zero/1.0/). Anyone can copy, change and use them for any purpose, without asking and without credit.
