@blinkdotnew/sdk 0.18.7 → 0.18.8
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 +20 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -187,8 +187,7 @@ const blink = createClient({
|
|
|
187
187
|
auth: { mode: 'managed' } // Manual token management
|
|
188
188
|
})
|
|
189
189
|
|
|
190
|
-
//
|
|
191
|
-
blink.auth.setToken(jwtFromHeader)
|
|
190
|
+
// Token injection is only needed when calling blink.auth.* methods on the server
|
|
192
191
|
```
|
|
193
192
|
|
|
194
193
|
## 📖 API Reference
|
|
@@ -235,6 +234,22 @@ const user = await blink.auth.signInWithGitHub()
|
|
|
235
234
|
const user = await blink.auth.signInWithApple()
|
|
236
235
|
const user = await blink.auth.signInWithMicrosoft()
|
|
237
236
|
|
|
237
|
+
// ✅ Store custom signup fields inside metadata
|
|
238
|
+
await blink.auth.signUp({
|
|
239
|
+
email: 'founder@example.com',
|
|
240
|
+
password: 'SuperSecret123',
|
|
241
|
+
displayName: 'Alex Founder',
|
|
242
|
+
role: 'operations',
|
|
243
|
+
metadata: {
|
|
244
|
+
company: 'Acme Freight',
|
|
245
|
+
marketingConsent: true
|
|
246
|
+
}
|
|
247
|
+
})
|
|
248
|
+
// `displayName`, `avatar`, and `role` map to dedicated auth columns.
|
|
249
|
+
// Everything else goes into auth.users.metadata automatically.
|
|
250
|
+
// Keep custom fields in metadata or your own profile table—avoid adding NOT NULL
|
|
251
|
+
// columns directly to auth tables.
|
|
252
|
+
|
|
238
253
|
// Magic links (passwordless)
|
|
239
254
|
await blink.auth.sendMagicLink(email)
|
|
240
255
|
|
|
@@ -427,6 +442,8 @@ function EditButton() {
|
|
|
427
442
|
|
|
428
443
|
#### Core Methods
|
|
429
444
|
|
|
445
|
+
> ⚠️ Tokens are managed automatically for Blink APIs. Use `getValidToken()` only if you must manually pass a token to your own backend or third-party services.
|
|
446
|
+
|
|
430
447
|
```typescript
|
|
431
448
|
// User management
|
|
432
449
|
const user = await blink.auth.me()
|
|
@@ -435,6 +452,7 @@ await blink.auth.updateMe({ displayName: 'New Name' })
|
|
|
435
452
|
// Token management
|
|
436
453
|
blink.auth.setToken(jwt, persist?)
|
|
437
454
|
const isAuth = blink.auth.isAuthenticated()
|
|
455
|
+
const token = await blink.auth.getValidToken() // Get valid token (auto-refreshes)
|
|
438
456
|
|
|
439
457
|
// Password management
|
|
440
458
|
await blink.auth.sendPasswordResetEmail('user@example.com')
|
|
@@ -2356,9 +2374,6 @@ const blink = createClient({
|
|
|
2356
2374
|
})
|
|
2357
2375
|
|
|
2358
2376
|
export default async function handler(req, res) {
|
|
2359
|
-
const jwt = req.headers.authorization?.replace('Bearer ', '')
|
|
2360
|
-
blink.auth.setToken(jwt)
|
|
2361
|
-
|
|
2362
2377
|
const todos = await blink.db.todos.list()
|
|
2363
2378
|
res.json(todos)
|
|
2364
2379
|
}
|
|
@@ -2376,9 +2391,6 @@ const blink = createClient({
|
|
|
2376
2391
|
})
|
|
2377
2392
|
|
|
2378
2393
|
Deno.serve(async (req) => {
|
|
2379
|
-
const jwt = req.headers.get('authorization')?.replace('Bearer ', '')
|
|
2380
|
-
blink.auth.setToken(jwt)
|
|
2381
|
-
|
|
2382
2394
|
const todos = await blink.db.todos.list()
|
|
2383
2395
|
return Response.json(todos)
|
|
2384
2396
|
})
|
package/package.json
CHANGED