Skip to content

Commit a3de9a3

Browse files
authored
Revise key and token generation instructions in USER_GUIDE
Updated instructions for generating keys and tokens, clarified file usage and security notes.
1 parent b26d476 commit a3de9a3

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

docs/USER_GUIDE.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ The key is either a PKCS#8-encoded Ed25519 public key in PEM, or just plain byte
118118

119119
### Generate Keys using Node/Bun
120120

121-
Generate a private key and public key pair for JWT authentication:
121+
To generate a public and private key pair for JWT authentication, you can use the built-in Node.js `crypto` module:
122122

123123
```typescript
124124
import fs from "node:fs";
@@ -134,14 +134,14 @@ const pubPem = publicKey.export({ format: "pem", type: "spki" });
134134
fs.writeFileSync("public.pem", pubPem);
135135
```
136136

137-
The snippet code generate two files: `private.pem` and `public.pem`, use the `public.pem` in the configuration `--auth-jwt-key-file public.pem`.
137+
This snippet generates two files: `private.pem` and `public.pem`. Pass the `public.pem` file to your server using the `--auth-jwt-key-file public.pem` flag.
138138

139139
> [!CAUTION]
140-
> Always keep in mind that the `private.pem` file must not be shared publicly; you should store it in a secure location, unlike the `public.pem` file, which can be shared without any risk.
140+
> Never share your `private.pem` file. It must be stored in a secure location. The `public.pem` file, however, is safe to distribute publicly.
141141
142142
### Generate a Token using Node/Bun
143143

144-
For generate the JWT you can install `jose` library and sign a JWT using the `private.pem`.
144+
To generate the JWT, install the `jose` library and sign a new token using your `private.pem` file:
145145

146146
```console
147147
npm install jose
@@ -166,8 +166,10 @@ const jwt = await new SignJWT(payload)
166166

167167
fs.writeFileSync("token.txt", jwt);
168168
```
169+
> [!NOTE]
170+
> Token Expiration: In the example above, the token is configured to be valid for exactly one hour. Once this hour passes, the token will expire and the client will lose access. You will need to generate and provide a new token to re-authenticate.
169171
170-
The generated token could be used for authentication:
172+
You can now use the generated token to authenticate your `@libsql/client`:
171173

172174
```console
173175
npm install @libsql/client

0 commit comments

Comments
 (0)