https://github.com/dtinth/firetoy
Provision a public-but-secret ephemeral Firebase Realtime Database endpoint.
https://github.com/dtinth/firetoy
firebase jwt typescript
Last synced: about 1 month ago
JSON representation
Provision a public-but-secret ephemeral Firebase Realtime Database endpoint.
- Host: GitHub
- URL: https://github.com/dtinth/firetoy
- Owner: dtinth
- Created: 2020-06-21T07:52:30.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2022-12-22T17:00:04.000Z (over 3 years ago)
- Last Synced: 2025-01-23T19:48:55.151Z (over 1 year ago)
- Topics: firebase, jwt, typescript
- Language: TypeScript
- Homepage:
- Size: 165 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# firetoy
Provision a public-but-secret ephemeral Firebase Realtime Database endpoint.
## Usage
After deploying, go to real-time database console and set up the following
structure:
- `clients`
- ``
- `jwtSecret`: `""`
This sets up the credentials needed to provision endpoints.
Next, mint a JWT with the `` in the issuer (`iss`) claim.
```
$ node
> require('jsonwebtoken').sign({iss:''},'')
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiI8Y2xpZW50SWQ-IiwiaWF0IjoxNTkyNzI1NDA4fQ.9OSAH69VurEp8AZymkxSRPx6hDE8fr1oruVbhjAs4g4'
```
Finally, call the `provision` function to generate an endpoint.
```
$ http post https://us-central1-.cloudfunctions.net/provision \
'Authorization: Bearer '
{
"expiresAt": "2020-09-18T21:18:33.063Z",
"tenantId": "20200620T211833062Z-dtinth-84856058-2688-490c-9447-f9680897e5fd"
}
```
Now you can use that endpoint:
```
$ http get https://.firebaseio.com/data/.json
null
$ http patch https://.firebaseio.com/data/.json hello=world
{
"hello": "world"
}
$ http get https://.firebaseio.com/data/.json
{
"hello": "world"
}
```
The endpoint expires after 3 months. After the endpoint expires it can still be
used but it may be deleted (when the deletion logic is implemented).