@blinkdotnew/sdk 0.17.3 → 0.17.4

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
@@ -176,8 +176,8 @@ blink.auth.setToken(jwtFromHeader)
176
176
 
177
177
  ```typescript
178
178
  // Login/logout
179
- blink.auth.login(nextUrl?)
180
- blink.auth.logout(redirectUrl?)
179
+ blink.auth.login(nextUrl?) // Redirect to auth page
180
+ blink.auth.logout(redirectUrl?) // Clear tokens and redirect
181
181
 
182
182
  // User management
183
183
  const user = await blink.auth.me()
@@ -197,6 +197,31 @@ const unsubscribe = blink.auth.onAuthStateChanged((state) => {
197
197
  })
198
198
  ```
199
199
 
200
+ #### Login Redirect Behavior
201
+
202
+ When `login()` is called, the SDK automatically determines where to redirect after authentication:
203
+
204
+ ```typescript
205
+ // Automatic redirect (uses current page URL)
206
+ blink.auth.login()
207
+ // → Redirects to: blink.new/auth?redirect_url=https://yourapp.com/current-page
208
+
209
+ // Custom redirect URL
210
+ blink.auth.login('https://yourapp.com/dashboard')
211
+ // → Redirects to: blink.new/auth?redirect_url=https://yourapp.com/dashboard
212
+
213
+ // Manual login button example
214
+ const handleLogin = () => {
215
+ // The SDK will automatically use the current page URL
216
+ blink.auth.login()
217
+
218
+ // Or specify a custom redirect
219
+ // blink.auth.login('https://yourapp.com/welcome')
220
+ }
221
+ ```
222
+
223
+ **✅ Fixed in v1.x**: The SDK now ensures redirect URLs are always absolute, preventing broken redirects when `window.location.href` returns relative paths.
224
+
200
225
  ### Database Operations
201
226
 
202
227
  **🎉 NEW: Automatic Case Conversion!**
package/dist/index.js CHANGED
@@ -992,7 +992,14 @@ var BlinkAuth = class {
992
992
  * Redirect to Blink auth page
993
993
  */
994
994
  login(nextUrl) {
995
- let redirectUrl = nextUrl || (typeof window !== "undefined" ? window.location.href : "");
995
+ let redirectUrl = nextUrl;
996
+ if (!redirectUrl && typeof window !== "undefined") {
997
+ if (window.location.href.startsWith("http")) {
998
+ redirectUrl = window.location.href;
999
+ } else {
1000
+ redirectUrl = `${window.location.protocol}//${window.location.host}${window.location.pathname}${window.location.search}${window.location.hash}`;
1001
+ }
1002
+ }
996
1003
  if (redirectUrl && typeof window !== "undefined") {
997
1004
  try {
998
1005
  const url = new URL(redirectUrl);
@@ -1004,7 +1011,7 @@ var BlinkAuth = class {
1004
1011
  }
1005
1012
  }
1006
1013
  const authUrl = new URL("/auth", this.authUrl);
1007
- authUrl.searchParams.set("redirect_url", redirectUrl);
1014
+ authUrl.searchParams.set("redirect_url", redirectUrl || "");
1008
1015
  if (this.config.projectId) {
1009
1016
  authUrl.searchParams.set("project_id", this.config.projectId);
1010
1017
  }
package/dist/index.mjs CHANGED
@@ -990,7 +990,14 @@ var BlinkAuth = class {
990
990
  * Redirect to Blink auth page
991
991
  */
992
992
  login(nextUrl) {
993
- let redirectUrl = nextUrl || (typeof window !== "undefined" ? window.location.href : "");
993
+ let redirectUrl = nextUrl;
994
+ if (!redirectUrl && typeof window !== "undefined") {
995
+ if (window.location.href.startsWith("http")) {
996
+ redirectUrl = window.location.href;
997
+ } else {
998
+ redirectUrl = `${window.location.protocol}//${window.location.host}${window.location.pathname}${window.location.search}${window.location.hash}`;
999
+ }
1000
+ }
994
1001
  if (redirectUrl && typeof window !== "undefined") {
995
1002
  try {
996
1003
  const url = new URL(redirectUrl);
@@ -1002,7 +1009,7 @@ var BlinkAuth = class {
1002
1009
  }
1003
1010
  }
1004
1011
  const authUrl = new URL("/auth", this.authUrl);
1005
- authUrl.searchParams.set("redirect_url", redirectUrl);
1012
+ authUrl.searchParams.set("redirect_url", redirectUrl || "");
1006
1013
  if (this.config.projectId) {
1007
1014
  authUrl.searchParams.set("project_id", this.config.projectId);
1008
1015
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blinkdotnew/sdk",
3
- "version": "0.17.3",
3
+ "version": "0.17.4",
4
4
  "description": "Blink TypeScript SDK for client-side applications - Zero-boilerplate CRUD + auth + AI + analytics + notifications for modern SaaS/AI apps",
5
5
  "keywords": [
6
6
  "blink",