Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added images/tutorials/self-host/token.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion mint.json
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,10 @@
},
{
"group": "Self Host",
"pages": ["tutorials/self-host/overview"]
"pages": [
"tutorials/self-host/overview",
"tutorials/self-host/generate-dev-token"
]
},
{
"group": "Resources",
Expand Down
57 changes: 57 additions & 0 deletions tutorials/self-host/generate-dev-token.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---
title: "Generate a Development Token"
description: "In this tutorial we will show you how to generate a development token for the self-hosted [PowerSync Service](https://powersync.mintlify.app/architecture/powersync-service#powersync-service)."
---

<Steps>
<Step title={"Generate a SharedSecret"}>
To generate a SharedSecret, you can use this [Online JWS key generator](https://8gwifi.org/jwsgen.jsp):
<Note>
You don't need to edit the default payload in the [Online JWS key generator](https://8gwifi.org/jwsgen.jsp).
You simply need a valid `SharedSecret` value.
</Note>
- Click `Generate JWS Keys`
- Copy the `SharedSecret` value
<Warning>
Using an online key generator for secrets in a production environment is not recommended.
</Warning>
</Step>

<Step title={"Update powersync.yaml"}>
Update the `k` value in the jwks keys in your `powersync.yaml` config file with the `SharedSecret` value copied in the previous step:
```yaml powersync.yaml {8}
# Client (application end user) authentication settings
client_auth:
# JWKS URIs can be specified here
jwks_uri: !env PS_JWKS_URL
jwks:
keys:
- kty: 'oct'
k: 'YOUR_GENERATED_SHARED_SECRET'
alg: 'HS256'
```
</Step>

<Step title={"Generate a development token"}>
1. If you have not done so already, clone the [powersync-service repo](https://github.com/powersync-ja/powersync-service/tree/main) repo
2. Install the dependencies
- In the project root, run the following commands:
```bash
pnpm install
pnpm build:packages
```
- In the `test-client` directory, run the following commands:
```bash
pnpm build
```
3. Generate a new token by running the following command in the `test-client` directory with your updated `powersync.yaml` config file:
```bash
node dist/bin.js generate-token --config path/to/powersync.yaml --sub test-user
```
You should see an output similar to the following:
<Frame>
<img src="/images/tutorials/self-host/token.png" />
</Frame>
</Step>
</Steps>

9 changes: 7 additions & 2 deletions tutorials/self-host/overview.mdx
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
---
title: "Coming Soon..."
---
title: "Overview"
description: "A collection of tutorials related to self-hosting."
---

<CardGroup>
<Card title="Generate a development token" icon="server" href="/tutorials/self-host/generate-dev-token" horizontal/>
</CardGroup>
Loading