@dream-api/sdk 0.1.8 → 0.1.10

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
@@ -195,6 +195,7 @@ var ClerkManager = class {
195
195
  }
196
196
  /**
197
197
  * Load Clerk SDK (call once on page load)
198
+ * Clerk automatically handles __clerk_ticket from sign-up redirect
198
199
  */
199
200
  async load() {
200
201
  if (this.loaded || typeof window === "undefined") return;
@@ -217,6 +218,20 @@ var ClerkManager = class {
217
218
  const clerk = getClerk();
218
219
  if (clerk) {
219
220
  await clerk.load();
221
+ const urlParams = new URLSearchParams(window.location.search);
222
+ const ticket = urlParams.get("__clerk_ticket");
223
+ if (ticket && clerk.client?.signIn) {
224
+ try {
225
+ console.log("[DreamAPI] Consuming sign-in ticket...");
226
+ await clerk.client.signIn.create({ strategy: "ticket", ticket });
227
+ urlParams.delete("__clerk_ticket");
228
+ const newUrl = urlParams.toString() ? `${window.location.pathname}?${urlParams}` : window.location.pathname;
229
+ window.history.replaceState({}, "", newUrl);
230
+ console.log("[DreamAPI] Sign-in ticket consumed successfully");
231
+ } catch (err) {
232
+ console.error("[DreamAPI] Failed to consume sign-in ticket:", err);
233
+ }
234
+ }
220
235
  }
221
236
  this.loaded = true;
222
237
  await this.checkSession();
package/dist/index.mjs CHANGED
@@ -167,6 +167,7 @@ var ClerkManager = class {
167
167
  }
168
168
  /**
169
169
  * Load Clerk SDK (call once on page load)
170
+ * Clerk automatically handles __clerk_ticket from sign-up redirect
170
171
  */
171
172
  async load() {
172
173
  if (this.loaded || typeof window === "undefined") return;
@@ -189,6 +190,20 @@ var ClerkManager = class {
189
190
  const clerk = getClerk();
190
191
  if (clerk) {
191
192
  await clerk.load();
193
+ const urlParams = new URLSearchParams(window.location.search);
194
+ const ticket = urlParams.get("__clerk_ticket");
195
+ if (ticket && clerk.client?.signIn) {
196
+ try {
197
+ console.log("[DreamAPI] Consuming sign-in ticket...");
198
+ await clerk.client.signIn.create({ strategy: "ticket", ticket });
199
+ urlParams.delete("__clerk_ticket");
200
+ const newUrl = urlParams.toString() ? `${window.location.pathname}?${urlParams}` : window.location.pathname;
201
+ window.history.replaceState({}, "", newUrl);
202
+ console.log("[DreamAPI] Sign-in ticket consumed successfully");
203
+ } catch (err) {
204
+ console.error("[DreamAPI] Failed to consume sign-in ticket:", err);
205
+ }
206
+ }
192
207
  }
193
208
  this.loaded = true;
194
209
  await this.checkSession();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dream-api/sdk",
3
- "version": "0.1.8",
3
+ "version": "0.1.10",
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",