@dream-api/sdk 0.1.7 → 0.1.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/dist/index.js CHANGED
@@ -191,7 +191,6 @@ var ClerkManager = class {
191
191
  constructor(onTokenChange) {
192
192
  this.loaded = false;
193
193
  this.token = null;
194
- this.bootstrapUser = null;
195
194
  this.onTokenChange = onTokenChange;
196
195
  }
197
196
  /**
@@ -199,16 +198,6 @@ var ClerkManager = class {
199
198
  */
200
199
  async load() {
201
200
  if (this.loaded || typeof window === "undefined") return;
202
- const bootstrapToken = this.checkBootstrapToken();
203
- if (bootstrapToken) {
204
- this.token = bootstrapToken.token;
205
- this.bootstrapUser = bootstrapToken.user;
206
- this.onTokenChange?.(this.token);
207
- this.loaded = true;
208
- console.log("[DreamSDK] Bootstrap token found, user:", bootstrapToken.user.email);
209
- this.removeTokenFromUrl();
210
- return;
211
- }
212
201
  const existingClerk = getClerk();
213
202
  if (existingClerk) {
214
203
  this.loaded = true;
@@ -232,45 +221,6 @@ var ClerkManager = class {
232
221
  this.loaded = true;
233
222
  await this.checkSession();
234
223
  }
235
- /**
236
- * Check for bootstrap token in URL (from sign-up worker redirect)
237
- */
238
- checkBootstrapToken() {
239
- if (typeof window === "undefined") return null;
240
- const params = new URLSearchParams(window.location.search);
241
- const token = params.get("__dream_token");
242
- if (!token) return null;
243
- try {
244
- const parts = token.split(".");
245
- if (parts.length !== 3) return null;
246
- const payload = JSON.parse(atob(parts[1].replace(/-/g, "+").replace(/_/g, "/")));
247
- if (payload.exp && payload.exp < Math.floor(Date.now() / 1e3)) {
248
- console.log("[DreamSDK] Bootstrap token expired");
249
- return null;
250
- }
251
- return {
252
- token,
253
- user: {
254
- id: payload.userId,
255
- email: payload.email || "",
256
- plan: payload.plan || "free",
257
- publishableKey: payload.publishableKey || ""
258
- }
259
- };
260
- } catch (err) {
261
- console.error("[DreamSDK] Failed to parse bootstrap token:", err);
262
- return null;
263
- }
264
- }
265
- /**
266
- * Remove bootstrap token from URL (clean up after reading)
267
- */
268
- removeTokenFromUrl() {
269
- if (typeof window === "undefined") return;
270
- const url = new URL(window.location.href);
271
- url.searchParams.delete("__dream_token");
272
- window.history.replaceState({}, "", url.toString());
273
- }
274
224
  /**
275
225
  * Check if returning from auth and grab token
276
226
  */
@@ -290,7 +240,6 @@ var ClerkManager = class {
290
240
  * Check if user is signed in
291
241
  */
292
242
  isSignedIn() {
293
- if (this.bootstrapUser && this.token) return true;
294
243
  const clerk = getClerk();
295
244
  return !!clerk?.user && !!clerk?.session;
296
245
  }
@@ -298,7 +247,6 @@ var ClerkManager = class {
298
247
  * Get current user info
299
248
  */
300
249
  getUser() {
301
- if (this.bootstrapUser) return this.bootstrapUser;
302
250
  const clerk = getClerk();
303
251
  if (!clerk?.user) return null;
304
252
  const user = clerk.user;
@@ -336,7 +284,6 @@ var ClerkManager = class {
336
284
  * Sign out
337
285
  */
338
286
  async signOut() {
339
- this.bootstrapUser = null;
340
287
  this.token = null;
341
288
  this.onTokenChange?.(null);
342
289
  const clerk = getClerk();
package/dist/index.mjs CHANGED
@@ -163,7 +163,6 @@ var ClerkManager = class {
163
163
  constructor(onTokenChange) {
164
164
  this.loaded = false;
165
165
  this.token = null;
166
- this.bootstrapUser = null;
167
166
  this.onTokenChange = onTokenChange;
168
167
  }
169
168
  /**
@@ -171,16 +170,6 @@ var ClerkManager = class {
171
170
  */
172
171
  async load() {
173
172
  if (this.loaded || typeof window === "undefined") return;
174
- const bootstrapToken = this.checkBootstrapToken();
175
- if (bootstrapToken) {
176
- this.token = bootstrapToken.token;
177
- this.bootstrapUser = bootstrapToken.user;
178
- this.onTokenChange?.(this.token);
179
- this.loaded = true;
180
- console.log("[DreamSDK] Bootstrap token found, user:", bootstrapToken.user.email);
181
- this.removeTokenFromUrl();
182
- return;
183
- }
184
173
  const existingClerk = getClerk();
185
174
  if (existingClerk) {
186
175
  this.loaded = true;
@@ -204,45 +193,6 @@ var ClerkManager = class {
204
193
  this.loaded = true;
205
194
  await this.checkSession();
206
195
  }
207
- /**
208
- * Check for bootstrap token in URL (from sign-up worker redirect)
209
- */
210
- checkBootstrapToken() {
211
- if (typeof window === "undefined") return null;
212
- const params = new URLSearchParams(window.location.search);
213
- const token = params.get("__dream_token");
214
- if (!token) return null;
215
- try {
216
- const parts = token.split(".");
217
- if (parts.length !== 3) return null;
218
- const payload = JSON.parse(atob(parts[1].replace(/-/g, "+").replace(/_/g, "/")));
219
- if (payload.exp && payload.exp < Math.floor(Date.now() / 1e3)) {
220
- console.log("[DreamSDK] Bootstrap token expired");
221
- return null;
222
- }
223
- return {
224
- token,
225
- user: {
226
- id: payload.userId,
227
- email: payload.email || "",
228
- plan: payload.plan || "free",
229
- publishableKey: payload.publishableKey || ""
230
- }
231
- };
232
- } catch (err) {
233
- console.error("[DreamSDK] Failed to parse bootstrap token:", err);
234
- return null;
235
- }
236
- }
237
- /**
238
- * Remove bootstrap token from URL (clean up after reading)
239
- */
240
- removeTokenFromUrl() {
241
- if (typeof window === "undefined") return;
242
- const url = new URL(window.location.href);
243
- url.searchParams.delete("__dream_token");
244
- window.history.replaceState({}, "", url.toString());
245
- }
246
196
  /**
247
197
  * Check if returning from auth and grab token
248
198
  */
@@ -262,7 +212,6 @@ var ClerkManager = class {
262
212
  * Check if user is signed in
263
213
  */
264
214
  isSignedIn() {
265
- if (this.bootstrapUser && this.token) return true;
266
215
  const clerk = getClerk();
267
216
  return !!clerk?.user && !!clerk?.session;
268
217
  }
@@ -270,7 +219,6 @@ var ClerkManager = class {
270
219
  * Get current user info
271
220
  */
272
221
  getUser() {
273
- if (this.bootstrapUser) return this.bootstrapUser;
274
222
  const clerk = getClerk();
275
223
  if (!clerk?.user) return null;
276
224
  const user = clerk.user;
@@ -308,7 +256,6 @@ var ClerkManager = class {
308
256
  * Sign out
309
257
  */
310
258
  async signOut() {
311
- this.bootstrapUser = null;
312
259
  this.token = null;
313
260
  this.onTokenChange?.(null);
314
261
  const clerk = getClerk();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dream-api/sdk",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
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",