@sylphx/sdk 0.9.0 → 0.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -26,20 +26,21 @@ bun add @sylphx/sdk
26
26
 
27
27
  ### 1. Environment Variables
28
28
 
29
- Your server connection URL and environment app ID from your
30
- [Platform Console](https://sylphx.com/console):
29
+ Your server and browser connection URLs from your
30
+ [Platform Console](https://sylphx.com/console). Sylphx deploys inject these
31
+ automatically; local development can pull the same values into `.env.local`.
31
32
 
32
33
  ```bash
33
34
  # .env.local
34
- SYLPHX_URL=sylphx://sk_dev_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx@bold-river-a1b2c3.api.sylphx.com
35
- NEXT_PUBLIC_SYLPHX_APP_ID=app_dev_xxxxxxxxxxxx
35
+ SYLPHX_SECRET_URL=sylphx://sk_dev_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx@bold-river-a1b2c3.api.sylphx.com
36
+ NEXT_PUBLIC_SYLPHX_URL=sylphx://pk_dev_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx@bold-river-a1b2c3.api.sylphx.com
36
37
  ```
37
38
 
38
39
  That's it. No other config needed.
39
40
 
40
41
  > **Key formats**
41
42
  > - `sylphx://sk_*@<tenant-slug>.api.sylphx.com` — Server connection URL (server only, never expose)
42
- > - `app_dev_*` / `app_stg_*` / `app_prod_*` App ID (safe for client-side)
43
+ > - `sylphx://pk_*@<tenant-slug>.api.sylphx.com` Browser connection URL (publishable)
43
44
  >
44
45
  > Get both from **Console → Your App → API Keys**. The hosted BaaS API is always
45
46
  > addressed as `<tenant-slug>.api.sylphx.com`.
@@ -78,7 +79,7 @@ import { SylphxProvider } from '@sylphx/sdk/react'
78
79
  import { createServerClient } from '@sylphx/sdk'
79
80
 
80
81
  export default async function RootLayout({ children }: { children: React.ReactNode }) {
81
- const sylphx = createServerClient(process.env.SYLPHX_URL!)
82
+ const sylphx = createServerClient(process.env.SYLPHX_SECRET_URL!)
82
83
  const apiUrl = sylphx.baseUrl.replace(/\/v[0-9]+$/, '')
83
84
 
84
85
  const config = await getAppConfig({
@@ -169,7 +170,7 @@ const userId = await currentUserId()
169
170
  ```ts
170
171
  import { createServerClient, getPlans, track } from '@sylphx/sdk'
171
172
 
172
- const sylphx = createServerClient(process.env.SYLPHX_URL!)
173
+ const sylphx = createServerClient(process.env.SYLPHX_SECRET_URL!)
173
174
 
174
175
  // Billing
175
176
  const plans = await getPlans(sylphx)
@@ -189,7 +190,7 @@ import {
189
190
  } from '@sylphx/sdk/server'
190
191
  import { createServerClient } from '@sylphx/sdk'
191
192
 
192
- const sylphx = createServerClient(process.env.SYLPHX_URL!)
193
+ const sylphx = createServerClient(process.env.SYLPHX_SECRET_URL!)
193
194
 
194
195
  const config = await getAppConfig({
195
196
  secretKey: sylphx.secretKey!,
@@ -210,7 +211,7 @@ export async function POST(request: Request) {
210
211
  const result = await verifyWebhook({
211
212
  payload: body,
212
213
  signatureHeader: request.headers.get('x-webhook-signature'),
213
- secret: process.env.SYLPHX_SECRET_KEY!,
214
+ secret: process.env.SYLPHX_WEBHOOK_SECRET!,
214
215
  })
215
216
 
216
217
  if (!result.valid) {
@@ -229,7 +230,7 @@ Or use the handler factory:
229
230
  import { createWebhookHandler } from '@sylphx/sdk/server'
230
231
 
231
232
  export const POST = createWebhookHandler({
232
- secret: process.env.SYLPHX_SECRET_KEY!,
233
+ secret: process.env.SYLPHX_WEBHOOK_SECRET!,
233
234
  handlers: {
234
235
  'user.created': async (data) => { /* ... */ },
235
236
  'subscription.updated': async (data) => { /* ... */ },
@@ -243,7 +244,7 @@ export const POST = createWebhookHandler({
243
244
  import { verifyAccessToken } from '@sylphx/sdk/server'
244
245
 
245
246
  const payload = await verifyAccessToken(token, {
246
- secretKey: process.env.SYLPHX_SECRET_KEY!,
247
+ secretKey: createServerClient(process.env.SYLPHX_SECRET_URL!).secretKey!,
247
248
  })
248
249
  // payload.sub, payload.email, payload.role, payload.app_id
249
250
  ```
@@ -378,7 +379,7 @@ For non-React environments or maximum control:
378
379
  ```ts
379
380
  import { createClient, signIn, track, getPlans } from '@sylphx/sdk'
380
381
 
381
- const config = createClient(process.env.SYLPHX_URL!)
382
+ const config = createClient(process.env.NEXT_PUBLIC_SYLPHX_URL!)
382
383
 
383
384
  // Auth
384
385
  const tokens = await signIn(config, { email, password })