@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.js
CHANGED
|
@@ -345,12 +345,33 @@ var FloatingButton = ({
|
|
|
345
345
|
// src/services/unified-oauth.ts
|
|
346
346
|
init_config();
|
|
347
347
|
var API_BASE_URLS = {
|
|
348
|
-
local: "https://
|
|
349
|
-
dev: "https://
|
|
350
|
-
prod: "https://
|
|
348
|
+
local: "https://api.howone.dev",
|
|
349
|
+
dev: "https://api.howone.dev",
|
|
350
|
+
prod: "https://api.howone.ai"
|
|
351
|
+
};
|
|
352
|
+
var detectEnvironmentFromHostname = () => {
|
|
353
|
+
try {
|
|
354
|
+
const hostname = window.location.hostname.toLowerCase();
|
|
355
|
+
if (hostname.includes("howone.ai")) {
|
|
356
|
+
return "prod";
|
|
357
|
+
}
|
|
358
|
+
if (hostname.includes("howone.dev")) {
|
|
359
|
+
return "dev";
|
|
360
|
+
}
|
|
361
|
+
if (hostname === "localhost" || hostname === "127.0.0.1" || hostname.startsWith("192.168.") || hostname.endsWith(".local")) {
|
|
362
|
+
return "local";
|
|
363
|
+
}
|
|
364
|
+
const globalEnv = getGlobalEnvironment();
|
|
365
|
+
if (globalEnv) {
|
|
366
|
+
return globalEnv;
|
|
367
|
+
}
|
|
368
|
+
return "prod";
|
|
369
|
+
} catch (error) {
|
|
370
|
+
return getGlobalEnvironment() ?? "dev";
|
|
371
|
+
}
|
|
351
372
|
};
|
|
352
373
|
var resolveApiBaseUrl = () => {
|
|
353
|
-
const env2 =
|
|
374
|
+
const env2 = detectEnvironmentFromHostname();
|
|
354
375
|
return API_BASE_URLS[env2] ?? API_BASE_URLS.dev;
|
|
355
376
|
};
|
|
356
377
|
var UnifiedAuthService = class {
|
|
@@ -370,6 +391,7 @@ var UnifiedAuthService = class {
|
|
|
370
391
|
};
|
|
371
392
|
const stateString = encodeURIComponent(JSON.stringify(state));
|
|
372
393
|
try {
|
|
394
|
+
console.log("Using API_BASE_URL:", this.API_BASE_URL);
|
|
373
395
|
const response = await fetch(`${this.API_BASE_URL}/api/auth/google?state=${stateString}`);
|
|
374
396
|
const data = await response.json();
|
|
375
397
|
if (!data.data.success || !data.data.authUrl) {
|
|
@@ -429,9 +451,15 @@ var UnifiedAuthService = class {
|
|
|
429
451
|
};
|
|
430
452
|
popupCheckInterval = window.setInterval(checkPopupStatus, 1e3);
|
|
431
453
|
const messageHandler = (event) => {
|
|
432
|
-
const validOrigins = [
|
|
454
|
+
const validOrigins = [
|
|
455
|
+
window.location.origin,
|
|
456
|
+
this.API_BASE_URL,
|
|
457
|
+
// 使用当前环境的 API_BASE_URL
|
|
458
|
+
"https://api.howone.dev",
|
|
459
|
+
"https://api.howone.ai"
|
|
460
|
+
];
|
|
433
461
|
const isValidOrigin = validOrigins.some(
|
|
434
|
-
(origin) => event.origin === origin || event.origin.includes("localhost") || event.origin.includes("127.0.0.1") || event.origin.includes("fly.dev")
|
|
462
|
+
(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")
|
|
435
463
|
);
|
|
436
464
|
if (!isValidOrigin) {
|
|
437
465
|
return;
|
|
@@ -5596,7 +5624,7 @@ var LimitToastContainer = ({ message, onUpgrade, closeToast }) => {
|
|
|
5596
5624
|
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "relative z-10 flex items-start gap-4 p-4", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex flex-1 flex-col gap-3", children: [
|
|
5597
5625
|
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex items-center justify-between", children: [
|
|
5598
5626
|
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
5599
|
-
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "text-lg font-bold
|
|
5627
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "text-lg font-bold text-white", children: "Upgrade Required" }),
|
|
5600
5628
|
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("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" })
|
|
5601
5629
|
] }),
|
|
5602
5630
|
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|