@dream-api/sdk 0.1.24 → 0.1.26

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.d.mts CHANGED
@@ -137,6 +137,8 @@ declare class DreamAPIException extends Error {
137
137
  *
138
138
  * Handles all HTTP communication with the Dream API.
139
139
  * Automatically injects authentication headers.
140
+ *
141
+ * Auto-detects localhost vs production for sign-up URLs.
140
142
  */
141
143
 
142
144
  declare class DreamClient {
@@ -216,6 +218,8 @@ declare class DreamClient {
216
218
  *
217
219
  * Handles loading Clerk internally so devs never touch it.
218
220
  * Uses the shared end-user-api Clerk app.
221
+ *
222
+ * Auto-detects localhost vs production and uses appropriate keys.
219
223
  */
220
224
  interface ClerkUser {
221
225
  id: string;
package/dist/index.d.ts CHANGED
@@ -137,6 +137,8 @@ declare class DreamAPIException extends Error {
137
137
  *
138
138
  * Handles all HTTP communication with the Dream API.
139
139
  * Automatically injects authentication headers.
140
+ *
141
+ * Auto-detects localhost vs production for sign-up URLs.
140
142
  */
141
143
 
142
144
  declare class DreamClient {
@@ -216,6 +218,8 @@ declare class DreamClient {
216
218
  *
217
219
  * Handles loading Clerk internally so devs never touch it.
218
220
  * Uses the shared end-user-api Clerk app.
221
+ *
222
+ * Auto-detects localhost vs production and uses appropriate keys.
219
223
  */
220
224
  interface ClerkUser {
221
225
  id: string;
package/dist/index.js CHANGED
@@ -38,8 +38,17 @@ var DreamAPIException = class extends Error {
38
38
 
39
39
  // src/client.ts
40
40
  var DEFAULT_BASE_URL = "https://api-multi.k-c-sheffield012376.workers.dev";
41
- var DEFAULT_SIGNUP_URL = "https://sign-up.k-c-sheffield012376.workers.dev";
42
- var DEFAULT_CLERK_URL = "https://users.panacea-tech.net";
41
+ var SIGNUP_URL_DEV = "https://sign-up.k-c-sheffield012376.workers.dev";
42
+ var SIGNUP_URL_LIVE = "https://signup.users.panacea-tech.net";
43
+ var CLERK_URL_DEV = "https://composed-blowfish-76.clerk.accounts.dev";
44
+ var CLERK_URL_LIVE = "https://users.panacea-tech.net";
45
+ function isLocalhost() {
46
+ if (typeof window === "undefined") return false;
47
+ const hostname = window.location.hostname;
48
+ return hostname === "localhost" || hostname === "127.0.0.1";
49
+ }
50
+ var DEFAULT_SIGNUP_URL = isLocalhost() ? SIGNUP_URL_DEV : SIGNUP_URL_LIVE;
51
+ var DEFAULT_CLERK_URL = isLocalhost() ? CLERK_URL_DEV : CLERK_URL_LIVE;
43
52
  var DreamClient = class {
44
53
  constructor(config) {
45
54
  this.userToken = null;
@@ -181,7 +190,16 @@ var DreamClient = class {
181
190
  };
182
191
 
183
192
  // src/clerk.ts
184
- var CLERK_PUBLISHABLE_KEY = "pk_live_Y2xlcmsudXNlcnMucGFuYWNlYS10ZWNoLm5ldCQ";
193
+ function isLocalhost2() {
194
+ if (typeof window === "undefined") return false;
195
+ const hostname = window.location.hostname;
196
+ return hostname === "localhost" || hostname === "127.0.0.1";
197
+ }
198
+ var CLERK_DEV_KEY = "pk_test_Y29tcG9zZWQtYmxvd2Zpc2gtNzYuY2xlcmsuYWNjb3VudHMuZGV2JA";
199
+ var CLERK_LIVE_KEY = "pk_live_Y2xlcmsudXNlcnMucGFuYWNlYS10ZWNoLm5ldCQ";
200
+ function getClerkKey() {
201
+ return isLocalhost2() ? CLERK_DEV_KEY : CLERK_LIVE_KEY;
202
+ }
185
203
  var CLERK_CDN_URL = "https://cdn.jsdelivr.net/npm/@clerk/clerk-js@5.118.0/dist/clerk.browser.js";
186
204
  var JWT_TEMPLATE = "end-user-api";
187
205
  function getClerk() {
@@ -209,7 +227,7 @@ var ClerkManager = class {
209
227
  script.src = CLERK_CDN_URL;
210
228
  script.async = true;
211
229
  script.crossOrigin = "anonymous";
212
- script.setAttribute("data-clerk-publishable-key", CLERK_PUBLISHABLE_KEY);
230
+ script.setAttribute("data-clerk-publishable-key", getClerkKey());
213
231
  script.onload = () => resolve();
214
232
  script.onerror = () => reject(new Error("Failed to load Clerk SDK"));
215
233
  document.head.appendChild(script);
package/dist/index.mjs CHANGED
@@ -10,8 +10,17 @@ var DreamAPIException = class extends Error {
10
10
 
11
11
  // src/client.ts
12
12
  var DEFAULT_BASE_URL = "https://api-multi.k-c-sheffield012376.workers.dev";
13
- var DEFAULT_SIGNUP_URL = "https://sign-up.k-c-sheffield012376.workers.dev";
14
- var DEFAULT_CLERK_URL = "https://users.panacea-tech.net";
13
+ var SIGNUP_URL_DEV = "https://sign-up.k-c-sheffield012376.workers.dev";
14
+ var SIGNUP_URL_LIVE = "https://signup.users.panacea-tech.net";
15
+ var CLERK_URL_DEV = "https://composed-blowfish-76.clerk.accounts.dev";
16
+ var CLERK_URL_LIVE = "https://users.panacea-tech.net";
17
+ function isLocalhost() {
18
+ if (typeof window === "undefined") return false;
19
+ const hostname = window.location.hostname;
20
+ return hostname === "localhost" || hostname === "127.0.0.1";
21
+ }
22
+ var DEFAULT_SIGNUP_URL = isLocalhost() ? SIGNUP_URL_DEV : SIGNUP_URL_LIVE;
23
+ var DEFAULT_CLERK_URL = isLocalhost() ? CLERK_URL_DEV : CLERK_URL_LIVE;
15
24
  var DreamClient = class {
16
25
  constructor(config) {
17
26
  this.userToken = null;
@@ -153,7 +162,16 @@ var DreamClient = class {
153
162
  };
154
163
 
155
164
  // src/clerk.ts
156
- var CLERK_PUBLISHABLE_KEY = "pk_live_Y2xlcmsudXNlcnMucGFuYWNlYS10ZWNoLm5ldCQ";
165
+ function isLocalhost2() {
166
+ if (typeof window === "undefined") return false;
167
+ const hostname = window.location.hostname;
168
+ return hostname === "localhost" || hostname === "127.0.0.1";
169
+ }
170
+ var CLERK_DEV_KEY = "pk_test_Y29tcG9zZWQtYmxvd2Zpc2gtNzYuY2xlcmsuYWNjb3VudHMuZGV2JA";
171
+ var CLERK_LIVE_KEY = "pk_live_Y2xlcmsudXNlcnMucGFuYWNlYS10ZWNoLm5ldCQ";
172
+ function getClerkKey() {
173
+ return isLocalhost2() ? CLERK_DEV_KEY : CLERK_LIVE_KEY;
174
+ }
157
175
  var CLERK_CDN_URL = "https://cdn.jsdelivr.net/npm/@clerk/clerk-js@5.118.0/dist/clerk.browser.js";
158
176
  var JWT_TEMPLATE = "end-user-api";
159
177
  function getClerk() {
@@ -181,7 +199,7 @@ var ClerkManager = class {
181
199
  script.src = CLERK_CDN_URL;
182
200
  script.async = true;
183
201
  script.crossOrigin = "anonymous";
184
- script.setAttribute("data-clerk-publishable-key", CLERK_PUBLISHABLE_KEY);
202
+ script.setAttribute("data-clerk-publishable-key", getClerkKey());
185
203
  script.onload = () => resolve();
186
204
  script.onerror = () => reject(new Error("Failed to load Clerk SDK"));
187
205
  document.head.appendChild(script);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dream-api/sdk",
3
- "version": "0.1.24",
3
+ "version": "0.1.26",
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",