Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/stevedylandev/farcaster-keys-server


https://github.com/stevedylandev/farcaster-keys-server

Last synced: 10 days ago
JSON representation

Awesome Lists containing this project

README

        

# Farcaster Keys Server

This is an open sourced Hono server deployed via a Cloudflare worker that can be used for creating and authorizing signer keys on Farcaster. It's not the most ideal approach as something like [Farcaster Auth](https://docs.pinata.cloud/farcaster/farcaster-auth) is much more streamline and scales better, but it can come in handy for certain use cases and educational settings on how keys in Farcaster work.

It is currently being used in production to assist with authorizing Raycaster.

## Getting Started

Clone the repo then install the packages with your manager of choice (i.e. `bun install`)

Then create a file called `.dev.vars` and put the following values in:

```
FARCASTER_DEVELOPER_FID= # The FID of the app account (e.g. @raycasterapp) that will be signing the keys
FARCASTER_DEVELOPER_MNEMONIC= # The mnemonic phrase for the same app account
```

After setting the environment variables start up the server

```
bun run dev
```

## Endpoint Overview

### `POST /sign-in`

Creates a keypair, sign it, then make a `signed-key-request` to Warpcast. If successful it will return the following data.

```json
{
"deepLinkUrl": "farcaster://signed-key-request?token=",
"pollingToken": "",
"privateKey": "",
"publicKey": ""
}
```

- `deepLinkUrl` - Can be turned into a QR code or button on mobile to open up Warpcast to approve the signed key
- `pollingToken` - Used in the `/sign-in/poll` edpoint to check on the status of whether the key has been approved
- `privateKey` & `publicKey` - The signed keypair

### `GET /sign-in/poll`

Checks the status of an approval for an existing signed keypair, uses a query parameter of `?token=TOKEN` like so:

```
/sign-in/poll?token=
```

Returns the following data:

```json
{
"state": "approved",
"userFid": 6023
}
```

- `state` - Can either be `pending` or `approved`
- `userFid` - Once a key is approved it will also return the user FID that approved the key

### `GET /qr/:token`

Returns a QR code that can be scanned by a mobile deviced based on the `pollingToken` passed into the path parameter.

## Contact

If you have any questions at all feel free to [contact me](https://warpcast.com/stevedylandev)!