@sanvika/ui 0.2.0 → 0.3.0
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/EmailIcon-ssF1iAVu.js +782 -0
- package/dist/icons/index.js +4 -0
- package/dist/index.js +583 -0
- package/package.json +1 -1
- package/src/context/ThemeContext.jsx +30 -21
- package/src/server/index.js +21 -7
package/src/server/index.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
// @sanvika/ui/server v0.
|
|
1
|
+
// @sanvika/ui/server v0.3.0
|
|
2
2
|
// HTTP client for ui.sanvikaproduction.com — cloud-driven Navbar configs and Theme presets.
|
|
3
|
-
//
|
|
3
|
+
// Universal S2S Auth Pattern (ecosystem rule §21):
|
|
4
|
+
// PROJECT_NAME — clientId
|
|
5
|
+
// SANVIKA_SERVICE_KEY — Tier 1 trust
|
|
6
|
+
// UI_URL — service endpoint
|
|
7
|
+
// UI_CLIENT_SECRET — (optional, Tier 2 fallback for 3rd-party)
|
|
4
8
|
|
|
5
9
|
const DEFAULT_TIMEOUT_MS = 8000;
|
|
6
10
|
|
|
@@ -14,15 +18,21 @@ function _readEnv(key) {
|
|
|
14
18
|
|
|
15
19
|
export class SanvikaUI {
|
|
16
20
|
#url;
|
|
21
|
+
#clientId;
|
|
22
|
+
#serviceKey;
|
|
17
23
|
#secret;
|
|
18
24
|
|
|
19
|
-
constructor({ url, secret } = {}) {
|
|
25
|
+
constructor({ url, clientId, serviceKey, secret } = {}) {
|
|
20
26
|
const finalUrl = url || _readEnv("UI_URL");
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
27
|
+
const finalClientId = clientId || _readEnv("PROJECT_NAME") || _readEnv("UI_CLIENT_ID");
|
|
28
|
+
const finalServiceKey = serviceKey || _readEnv("SANVIKA_SERVICE_KEY") || "";
|
|
29
|
+
const finalSecret = secret || _readEnv("UI_CLIENT_SECRET") || ""; // Tier 2 fallback (optional)
|
|
30
|
+
if (!finalUrl || !finalClientId) {
|
|
31
|
+
throw new Error("@sanvika/ui/server: UI_URL and PROJECT_NAME are required");
|
|
24
32
|
}
|
|
25
33
|
this.#url = finalUrl.replace(/\/$/, "");
|
|
34
|
+
this.#clientId = finalClientId;
|
|
35
|
+
this.#serviceKey = finalServiceKey;
|
|
26
36
|
this.#secret = finalSecret;
|
|
27
37
|
}
|
|
28
38
|
|
|
@@ -37,7 +47,11 @@ export class SanvikaUI {
|
|
|
37
47
|
const qs = query ? "?" + new URLSearchParams(query).toString() : "";
|
|
38
48
|
const init = {
|
|
39
49
|
method,
|
|
40
|
-
headers: {
|
|
50
|
+
headers: {
|
|
51
|
+
"x-client-id": this.#clientId,
|
|
52
|
+
"x-service-key": this.#serviceKey,
|
|
53
|
+
"x-client-secret": this.#secret,
|
|
54
|
+
},
|
|
41
55
|
signal: controller.signal,
|
|
42
56
|
};
|
|
43
57
|
if (body !== undefined) {
|