@howone/sdk 0.2.15 → 0.2.17
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 +35 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +35 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -274,12 +274,33 @@ var FloatingButton = ({
|
|
|
274
274
|
// src/services/unified-oauth.ts
|
|
275
275
|
init_config();
|
|
276
276
|
var API_BASE_URLS = {
|
|
277
|
-
local: "https://
|
|
278
|
-
dev: "https://
|
|
279
|
-
prod: "https://
|
|
277
|
+
local: "https://api.howone.dev",
|
|
278
|
+
dev: "https://api.howone.dev",
|
|
279
|
+
prod: "https://api.howone.ai"
|
|
280
|
+
};
|
|
281
|
+
var detectEnvironmentFromHostname = () => {
|
|
282
|
+
try {
|
|
283
|
+
const hostname = window.location.hostname.toLowerCase();
|
|
284
|
+
if (hostname.includes("howone.ai")) {
|
|
285
|
+
return "prod";
|
|
286
|
+
}
|
|
287
|
+
if (hostname.includes("howone.dev")) {
|
|
288
|
+
return "dev";
|
|
289
|
+
}
|
|
290
|
+
if (hostname === "localhost" || hostname === "127.0.0.1" || hostname.startsWith("192.168.") || hostname.endsWith(".local")) {
|
|
291
|
+
return "local";
|
|
292
|
+
}
|
|
293
|
+
const globalEnv = getGlobalEnvironment();
|
|
294
|
+
if (globalEnv) {
|
|
295
|
+
return globalEnv;
|
|
296
|
+
}
|
|
297
|
+
return "prod";
|
|
298
|
+
} catch (error) {
|
|
299
|
+
return getGlobalEnvironment() ?? "dev";
|
|
300
|
+
}
|
|
280
301
|
};
|
|
281
302
|
var resolveApiBaseUrl = () => {
|
|
282
|
-
const env2 =
|
|
303
|
+
const env2 = detectEnvironmentFromHostname();
|
|
283
304
|
return API_BASE_URLS[env2] ?? API_BASE_URLS.dev;
|
|
284
305
|
};
|
|
285
306
|
var UnifiedAuthService = class {
|
|
@@ -299,6 +320,7 @@ var UnifiedAuthService = class {
|
|
|
299
320
|
};
|
|
300
321
|
const stateString = encodeURIComponent(JSON.stringify(state));
|
|
301
322
|
try {
|
|
323
|
+
console.log("Using API_BASE_URL:", this.API_BASE_URL);
|
|
302
324
|
const response = await fetch(`${this.API_BASE_URL}/api/auth/google?state=${stateString}`);
|
|
303
325
|
const data = await response.json();
|
|
304
326
|
if (!data.data.success || !data.data.authUrl) {
|
|
@@ -358,9 +380,15 @@ var UnifiedAuthService = class {
|
|
|
358
380
|
};
|
|
359
381
|
popupCheckInterval = window.setInterval(checkPopupStatus, 1e3);
|
|
360
382
|
const messageHandler = (event) => {
|
|
361
|
-
const validOrigins = [
|
|
383
|
+
const validOrigins = [
|
|
384
|
+
window.location.origin,
|
|
385
|
+
this.API_BASE_URL,
|
|
386
|
+
// 使用当前环境的 API_BASE_URL
|
|
387
|
+
"https://api.howone.dev",
|
|
388
|
+
"https://api.howone.ai"
|
|
389
|
+
];
|
|
362
390
|
const isValidOrigin = validOrigins.some(
|
|
363
|
-
(origin) => event.origin === origin || event.origin.includes("localhost") || event.origin.includes("127.0.0.1") || event.origin.includes("fly.dev")
|
|
391
|
+
(origin) => event.origin === origin || event.origin.includes("localhost") || event.origin.includes("127.0.0.1") || event.origin.includes("fly.dev") || event.origin.includes("howone.dev") || event.origin.includes("howone.ai")
|
|
364
392
|
);
|
|
365
393
|
if (!isValidOrigin) {
|
|
366
394
|
return;
|
|
@@ -5525,7 +5553,7 @@ var LimitToastContainer = ({ message, onUpgrade, closeToast }) => {
|
|
|
5525
5553
|
/* @__PURE__ */ jsx13("div", { className: "relative z-10 flex items-start gap-4 p-4", children: /* @__PURE__ */ jsxs10("div", { className: "flex flex-1 flex-col gap-3", children: [
|
|
5526
5554
|
/* @__PURE__ */ jsxs10("div", { className: "flex items-center justify-between", children: [
|
|
5527
5555
|
/* @__PURE__ */ jsxs10("div", { className: "flex items-center gap-2", children: [
|
|
5528
|
-
/* @__PURE__ */ jsx13("div", { className: "text-lg font-bold
|
|
5556
|
+
/* @__PURE__ */ jsx13("div", { className: "text-lg font-bold text-white", children: "Upgrade Required" }),
|
|
5529
5557
|
/* @__PURE__ */ jsx13("div", { className: "px-2 py-0.5 text-xs font-bold bg-purple-500/20 text-purple-400 rounded-md border border-purple-500/30", children: "Premium" })
|
|
5530
5558
|
] }),
|
|
5531
5559
|
/* @__PURE__ */ jsx13(
|