@ikonai/sdk 1.0.31 → 1.0.33
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/client/ikon-client-config.d.ts +8 -0
- package/connection/urls.d.ts +14 -12
- package/index.js +13 -11
- package/package.json +1 -1
|
@@ -80,6 +80,14 @@ export interface LocalConfig extends CommonConnectionConfig {
|
|
|
80
80
|
* get-or-create the user's profile before connecting.
|
|
81
81
|
*/
|
|
82
82
|
token?: string;
|
|
83
|
+
/**
|
|
84
|
+
* Backend API URL for profile operations. If not provided, derived from environment.
|
|
85
|
+
*/
|
|
86
|
+
backendUrl?: string;
|
|
87
|
+
/**
|
|
88
|
+
* Auth service URL for anonymous authentication. If not provided, derived from environment.
|
|
89
|
+
*/
|
|
90
|
+
authUrl?: string;
|
|
83
91
|
}
|
|
84
92
|
/**
|
|
85
93
|
* Common options for cloud-based modes (apiKey and sessionToken).
|
package/connection/urls.d.ts
CHANGED
|
@@ -18,14 +18,15 @@ export declare const IKON_AUTH_BASE_URL = "https://auth.ikonai.com";
|
|
|
18
18
|
*/
|
|
19
19
|
export declare function getBackendUrl(backendType?: BackendType): string;
|
|
20
20
|
/**
|
|
21
|
-
* Derive backend API URL
|
|
21
|
+
* Derive backend API URL.
|
|
22
22
|
* Priority:
|
|
23
|
-
* 1.
|
|
24
|
-
* 2.
|
|
25
|
-
* 3.
|
|
26
|
-
* 4.
|
|
23
|
+
* 1. Explicit override (e.g. from config)
|
|
24
|
+
* 2. VITE_IKON_BACKEND_URL env var (set by .NET server during local dev)
|
|
25
|
+
* 3. Local environment (localhost, LAN IPs) → IKON_BACKEND_URL_DEV
|
|
26
|
+
* 4. Hostname contains '.dev.' → IKON_BACKEND_URL_DEV
|
|
27
|
+
* 5. Default → IKON_BACKEND_URL_PROD
|
|
27
28
|
*/
|
|
28
|
-
export declare function deriveBackendUrl(): string;
|
|
29
|
+
export declare function deriveBackendUrl(override?: string): string;
|
|
29
30
|
/**
|
|
30
31
|
* Derive backend type from environment or window.location.hostname.
|
|
31
32
|
* Priority:
|
|
@@ -37,14 +38,15 @@ export declare function deriveBackendUrl(): string;
|
|
|
37
38
|
*/
|
|
38
39
|
export declare function deriveBackendType(): BackendType;
|
|
39
40
|
/**
|
|
40
|
-
* Derive auth service URL
|
|
41
|
+
* Derive auth service URL.
|
|
41
42
|
* Priority:
|
|
42
|
-
* 1.
|
|
43
|
-
* 2.
|
|
44
|
-
* 3.
|
|
45
|
-
* 4.
|
|
43
|
+
* 1. Explicit override (e.g. from config)
|
|
44
|
+
* 2. VITE_IKON_AUTH_URL env var (set by .NET server during local dev)
|
|
45
|
+
* 3. Local environment (localhost, LAN IPs) → IKON_AUTH_URL_DEV
|
|
46
|
+
* 4. Hostname contains '.dev.' → IKON_AUTH_URL_DEV
|
|
47
|
+
* 5. Default → IKON_AUTH_URL_PROD
|
|
46
48
|
*/
|
|
47
|
-
export declare function deriveAuthUrl(): string;
|
|
49
|
+
export declare function deriveAuthUrl(override?: string): string;
|
|
48
50
|
/**
|
|
49
51
|
* Parse URL query parameters.
|
|
50
52
|
*/
|
package/index.js
CHANGED
|
@@ -4204,20 +4204,22 @@ const xe = {}, it = "https://api.prod.ikon.live", ot = "https://api.dev.ikon.liv
|
|
|
4204
4204
|
function ps(t) {
|
|
4205
4205
|
return t === "development" ? ot : it;
|
|
4206
4206
|
}
|
|
4207
|
-
function Kt() {
|
|
4208
|
-
|
|
4209
|
-
|
|
4207
|
+
function Kt(t) {
|
|
4208
|
+
if (t) return t;
|
|
4209
|
+
const e = typeof import.meta < "u" ? xe.VITE_IKON_BACKEND_URL : void 0;
|
|
4210
|
+
return e || (typeof window > "u" ? it : !Nt() || window.location.hostname.includes(".dev.") ? ot : it);
|
|
4210
4211
|
}
|
|
4211
4212
|
function Of() {
|
|
4212
|
-
const t = typeof import.meta < "u" ? xe
|
|
4213
|
+
const t = typeof import.meta < "u" ? xe.VITE_IKON_BACKEND_TYPE : void 0;
|
|
4213
4214
|
if (t === "development" || t === "production")
|
|
4214
4215
|
return t;
|
|
4215
|
-
const e = typeof import.meta < "u" ? xe
|
|
4216
|
+
const e = typeof import.meta < "u" ? xe.VITE_IKON_BACKEND_URL : void 0;
|
|
4216
4217
|
return e ? e.includes(".dev.") ? "development" : "production" : typeof window > "u" ? "production" : Nt() ? window.location.hostname.includes(".dev.") ? "development" : "production" : "development";
|
|
4217
4218
|
}
|
|
4218
|
-
function Nd() {
|
|
4219
|
-
|
|
4220
|
-
|
|
4219
|
+
function Nd(t) {
|
|
4220
|
+
if (t) return t;
|
|
4221
|
+
const e = typeof import.meta < "u" ? xe.VITE_IKON_AUTH_URL : void 0;
|
|
4222
|
+
return e || (typeof window > "u" ? Ht : !Nt() || window.location.hostname.includes(".dev.") ? $t : Ht);
|
|
4221
4223
|
}
|
|
4222
4224
|
function Ye() {
|
|
4223
4225
|
if (typeof window > "u")
|
|
@@ -4447,12 +4449,12 @@ async function Fd(t, e) {
|
|
|
4447
4449
|
const s = { ...Ye(), ...t.parameters }, i = t.deviceId ?? Ke();
|
|
4448
4450
|
let o = t.userId, a = t.token;
|
|
4449
4451
|
if (!o) {
|
|
4450
|
-
const S = await Ud(t.spaceId, i, Nd(), e);
|
|
4452
|
+
const S = await Ud(t.spaceId, i, Nd(t.authUrl), e);
|
|
4451
4453
|
S && (o = S.userId, a = S.token);
|
|
4452
4454
|
}
|
|
4453
4455
|
if (o || (o = i, ee.debug("Using deviceId as userId fallback")), t.spaceId && a)
|
|
4454
4456
|
if (t.token) {
|
|
4455
|
-
const S = Kt(), _ = await fetch(`${S}/profiles/me?space=${encodeURIComponent(t.spaceId)}`, {
|
|
4457
|
+
const S = Kt(t.backendUrl), _ = await fetch(`${S}/profiles/me?space=${encodeURIComponent(t.spaceId)}`, {
|
|
4456
4458
|
method: "GET",
|
|
4457
4459
|
headers: { Authorization: `Bearer ${a}` },
|
|
4458
4460
|
signal: e
|
|
@@ -4462,7 +4464,7 @@ async function Fd(t, e) {
|
|
|
4462
4464
|
throw new N(`Failed to get or create profile: ${_.status} ${E}`);
|
|
4463
4465
|
}
|
|
4464
4466
|
} else
|
|
4465
|
-
await Od(Kt(), t.spaceId, a, e);
|
|
4467
|
+
await Od(Kt(t.backendUrl), t.spaceId, a, e);
|
|
4466
4468
|
const c = Pd({ ...t, parameters: s }, o), l = Ld(c), f = await fetch(`${n}/connect-token`, {
|
|
4467
4469
|
method: "POST",
|
|
4468
4470
|
headers: {
|