@dream-api/sdk 0.1.16 → 0.1.18

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/dist/index.js CHANGED
@@ -219,20 +219,27 @@ var ClerkManager = class {
219
219
  await clerk.load();
220
220
  const urlParams = new URLSearchParams(window.location.search);
221
221
  const ticket = urlParams.get("__clerk_ticket");
222
+ console.log("[DreamAPI] URL:", window.location.href);
223
+ console.log("[DreamAPI] Ticket present:", ticket ? "YES" : "NO");
222
224
  if (ticket && clerk.signIn && clerk.setActive) {
223
- urlParams.delete("__clerk_ticket");
224
- const newUrl = urlParams.toString() ? `${window.location.pathname}?${urlParams}` : window.location.pathname;
225
- window.history.replaceState({}, "", newUrl);
225
+ console.log("[DreamAPI] Consuming ticket...");
226
226
  try {
227
227
  const result = await clerk.signIn.create({ strategy: "ticket", ticket });
228
+ console.log("[DreamAPI] Ticket result:", result.status, result.createdSessionId);
228
229
  if (result.status === "complete" && result.createdSessionId) {
229
230
  await clerk.setActive({ session: result.createdSessionId });
230
- await new Promise((r) => setTimeout(r, 500));
231
+ console.log("[DreamAPI] Session activated!");
232
+ for (let i = 0; i < 20; i++) {
233
+ await new Promise((r) => setTimeout(r, 100));
234
+ if (clerk.user && clerk.session) break;
235
+ }
236
+ console.log("[DreamAPI] User hydrated:", !!clerk.user);
237
+ urlParams.delete("__clerk_ticket");
238
+ const newUrl = urlParams.toString() ? `${window.location.pathname}?${urlParams}` : window.location.pathname;
239
+ window.history.replaceState({}, "", newUrl);
231
240
  }
232
241
  } catch (err) {
233
- if (!err?.message?.includes("already")) {
234
- console.error("[DreamAPI] Ticket error:", err?.message);
235
- }
242
+ console.error("[DreamAPI] Ticket error:", err?.message, err);
236
243
  }
237
244
  }
238
245
  }
package/dist/index.mjs CHANGED
@@ -191,20 +191,27 @@ var ClerkManager = class {
191
191
  await clerk.load();
192
192
  const urlParams = new URLSearchParams(window.location.search);
193
193
  const ticket = urlParams.get("__clerk_ticket");
194
+ console.log("[DreamAPI] URL:", window.location.href);
195
+ console.log("[DreamAPI] Ticket present:", ticket ? "YES" : "NO");
194
196
  if (ticket && clerk.signIn && clerk.setActive) {
195
- urlParams.delete("__clerk_ticket");
196
- const newUrl = urlParams.toString() ? `${window.location.pathname}?${urlParams}` : window.location.pathname;
197
- window.history.replaceState({}, "", newUrl);
197
+ console.log("[DreamAPI] Consuming ticket...");
198
198
  try {
199
199
  const result = await clerk.signIn.create({ strategy: "ticket", ticket });
200
+ console.log("[DreamAPI] Ticket result:", result.status, result.createdSessionId);
200
201
  if (result.status === "complete" && result.createdSessionId) {
201
202
  await clerk.setActive({ session: result.createdSessionId });
202
- await new Promise((r) => setTimeout(r, 500));
203
+ console.log("[DreamAPI] Session activated!");
204
+ for (let i = 0; i < 20; i++) {
205
+ await new Promise((r) => setTimeout(r, 100));
206
+ if (clerk.user && clerk.session) break;
207
+ }
208
+ console.log("[DreamAPI] User hydrated:", !!clerk.user);
209
+ urlParams.delete("__clerk_ticket");
210
+ const newUrl = urlParams.toString() ? `${window.location.pathname}?${urlParams}` : window.location.pathname;
211
+ window.history.replaceState({}, "", newUrl);
203
212
  }
204
213
  } catch (err) {
205
- if (!err?.message?.includes("already")) {
206
- console.error("[DreamAPI] Ticket error:", err?.message);
207
- }
214
+ console.error("[DreamAPI] Ticket error:", err?.message, err);
208
215
  }
209
216
  }
210
217
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dream-api/sdk",
3
- "version": "0.1.16",
3
+ "version": "0.1.18",
4
4
  "description": "Official SDK for Dream API - Auth, billing, and usage tracking in one API",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",