# avatar

avatar is a small service that fetches your Tangled avatar (`org.tangled.actor.profile`) from your PDS and caches it on Cloudflare.
It uses a shared secret `AVATAR_SHARED_SECRET` to ensure requests only originate from the trusted appview.

Set `PLC_DIRECTORY_URL` to resolve DIDs somewhere other than <https://plc.directory>,
which a self-hosted network needs.

It's deployed using `wrangler` like so:

```
npx wrangler deploy
npx wrangler secrets put AVATAR_SHARED_SECRET
```

## placeholder gradients

When an actor has no avatar on their PDS, the service generates a
light, multicolor gradient placeholder. The gradient is derived entirely from
the actor string in `src/gradient.js`, so it is deterministic and needs no
storage.

To explore the generator, run the playground:

```
pnpm playground
```

Then open <http://localhost:8787/playground.html>. It renders live previews at
the real avatar sizes and a gallery of random actors.

