@luxfi/ui 8.2.7 → 8.2.8
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/3d-model-viewer.cjs +25 -421
- package/dist/3d-model-viewer.js +20 -416
- package/dist/accordion.cjs +3 -10
- package/dist/accordion.js +2 -10
- package/dist/advanced-navigation-bar.cjs +5 -401
- package/dist/advanced-navigation-bar.js +5 -401
- package/dist/ai-agents.cjs +45 -890
- package/dist/ai-agents.js +8 -834
- package/dist/ai-assistant.cjs +13 -740
- package/dist/ai-assistant.js +10 -738
- package/dist/ai-chat.cjs +24 -770
- package/dist/ai-chat.js +18 -765
- package/dist/ai-code.cjs +67 -923
- package/dist/ai-code.js +49 -905
- package/dist/ai-playground.cjs +25 -801
- package/dist/ai-playground.js +18 -795
- package/dist/ai-tools.cjs +22 -767
- package/dist/ai-tools.js +15 -761
- package/dist/ai-vision.cjs +41 -993
- package/dist/ai-vision.js +30 -983
- package/dist/ai-voice-settings.cjs +35 -1006
- package/dist/ai-voice-settings.js +32 -1004
- package/dist/ai-voice.cjs +51 -1024
- package/dist/ai-voice.js +9 -963
- package/dist/alert.cjs +11 -129
- package/dist/alert.js +8 -127
- package/dist/announcement.cjs +6 -402
- package/dist/announcement.js +6 -402
- package/dist/app-switcher-navigation-bar.cjs +5 -401
- package/dist/app-switcher-navigation-bar.js +5 -401
- package/dist/apple-cards-carousel.cjs +84 -480
- package/dist/apple-cards-carousel.js +19 -415
- package/dist/auth.cjs +10 -387
- package/dist/auth.js +7 -385
- package/dist/avatar.cjs +2 -9
- package/dist/avatar.js +2 -10
- package/dist/badge.cjs +8 -228
- package/dist/badge.js +5 -210
- package/dist/button.cjs +14 -67
- package/dist/button.js +12 -65
- package/dist/chrome.cjs +29 -493
- package/dist/chrome.js +9 -474
- package/dist/code-block.cjs +16 -664
- package/dist/code-block.js +13 -662
- package/dist/code-compare.cjs +28 -1302
- package/dist/code-compare.js +18 -1293
- package/dist/code-diff.cjs +21 -669
- package/dist/code-diff.js +17 -666
- package/dist/code-editor.cjs +13 -409
- package/dist/code-editor.js +12 -408
- package/dist/code-explorer.cjs +14 -456
- package/dist/code-explorer.js +13 -456
- package/dist/code-preview.cjs +31 -983
- package/dist/code-preview.js +23 -976
- package/dist/code-snippet.cjs +19 -667
- package/dist/code-snippet.js +14 -663
- package/dist/code-terminal.cjs +24 -485
- package/dist/code-terminal.js +19 -481
- package/dist/collapsible.cjs +13 -347
- package/dist/collapsible.js +11 -330
- package/dist/color-picker.cjs +8 -450
- package/dist/color-picker.js +7 -450
- package/dist/combobox.cjs +6 -402
- package/dist/combobox.js +6 -402
- package/dist/communication-navigation-bar.cjs +7 -403
- package/dist/communication-navigation-bar.js +5 -401
- package/dist/dashboard-navigation-bar.cjs +6 -402
- package/dist/dashboard-navigation-bar.js +5 -401
- package/dist/dialog-stack.cjs +5 -401
- package/dist/dialog-stack.js +5 -401
- package/dist/dialog.cjs +13 -70
- package/dist/dialog.js +13 -70
- package/dist/drawer.cjs +23 -99
- package/dist/drawer.js +19 -96
- package/dist/e-commerce-navigation-bar.cjs +7 -403
- package/dist/e-commerce-navigation-bar.js +5 -401
- package/dist/editor.cjs +9 -405
- package/dist/editor.js +6 -402
- package/dist/iam.cjs +2 -123
- package/dist/iam.js +1 -122
- package/dist/icon-button.cjs +2 -56
- package/dist/icon-button.js +1 -55
- package/dist/identity.cjs +28 -242
- package/dist/identity.js +20 -235
- package/dist/image-crop.cjs +10 -406
- package/dist/image-crop.js +7 -403
- package/dist/image.cjs +14 -83
- package/dist/image.js +13 -67
- package/dist/index.cjs +1868 -38770
- package/dist/index.js +174 -38320
- package/dist/input-group.cjs +3 -10
- package/dist/input-group.js +2 -10
- package/dist/item.cjs +2 -27
- package/dist/item.js +1 -22
- package/dist/kanban.cjs +25 -751
- package/dist/kanban.js +15 -742
- package/dist/limelight-nav.cjs +10 -452
- package/dist/limelight-nav.js +9 -452
- package/dist/link.cjs +11 -80
- package/dist/link.js +6 -60
- package/dist/lux.config.cjs +14 -32
- package/dist/lux.config.js +3 -26
- package/dist/menu.cjs +5 -13
- package/dist/menu.js +1 -9
- package/dist/message-dock.cjs +5 -401
- package/dist/message-dock.js +5 -401
- package/dist/mini-calendar.cjs +7 -403
- package/dist/mini-calendar.js +6 -402
- package/dist/music-player.cjs +30 -528
- package/dist/music-player.js +22 -520
- package/dist/next.cjs +8 -89
- package/dist/next.js +3 -86
- package/dist/popover.cjs +17 -74
- package/dist/popover.js +16 -73
- package/dist/progress-circle.cjs +3 -10
- package/dist/progress-circle.js +2 -10
- package/dist/provider.cjs +7 -176
- package/dist/provider.js +4 -174
- package/dist/select.cjs +36 -89
- package/dist/select.js +35 -88
- package/dist/sidebar.cjs +22 -493
- package/dist/sidebar.js +17 -489
- package/dist/site/commerce/ui/context.cjs +9 -214
- package/dist/site/commerce/ui/context.js +6 -215
- package/dist/site/components/analytics.cjs +2 -42
- package/dist/site/components/analytics.js +1 -37
- package/dist/site/components/auth/callback.cjs +2 -8
- package/dist/site/components/auth/callback.js +1 -7
- package/dist/site/components/auth/login-panel.cjs +15 -74
- package/dist/site/components/auth/login-panel.js +12 -73
- package/dist/site/components/auth/login.cjs +2 -6
- package/dist/site/components/auth/login.js +1 -5
- package/dist/site/components/auth/widget.cjs +2 -6
- package/dist/site/components/auth/widget.js +1 -5
- package/dist/site/components/commerce/bag-button.cjs +2 -3
- package/dist/site/components/commerce/bag-button.js +2 -3
- package/dist/site/components/commerce/buy-button.cjs +2 -11
- package/dist/site/components/commerce/buy-button.js +1 -10
- package/dist/site/components/commerce/checkout-button.cjs +2 -3
- package/dist/site/components/commerce/checkout-button.js +2 -3
- package/dist/site/components/commerce/checkout-panel/desktop-cp.cjs +15 -173
- package/dist/site/components/commerce/checkout-panel/desktop-cp.js +14 -174
- package/dist/site/components/commerce/checkout-panel/index.cjs +9 -400
- package/dist/site/components/commerce/checkout-panel/index.js +10 -403
- package/dist/site/components/commerce/checkout-panel/mobile-cp.cjs +15 -236
- package/dist/site/components/commerce/checkout-panel/mobile-cp.js +13 -237
- package/dist/site/components/commerce/desktop-bag-popup.cjs +7 -8
- package/dist/site/components/commerce/desktop-bag-popup.js +3 -8
- package/dist/site/components/commerce/drawer/index.cjs +15 -289
- package/dist/site/components/commerce/drawer/index.js +10 -290
- package/dist/site/components/commerce/drawer/micro.cjs +8 -115
- package/dist/site/components/commerce/drawer/micro.js +4 -115
- package/dist/site/components/commerce/drawer/shell.cjs +2 -10
- package/dist/site/components/commerce/drawer/shell.js +2 -10
- package/dist/site/components/contact-dialog/index.cjs +6 -69
- package/dist/site/components/contact-dialog/index.js +7 -71
- package/dist/site/components/drawer-margin.cjs +2 -10
- package/dist/site/components/drawer-margin.js +2 -10
- package/dist/site/components/footer.cjs +11 -81
- package/dist/site/components/footer.js +8 -80
- package/dist/site/components/header/desktop.cjs +18 -374
- package/dist/site/components/header/desktop.js +12 -355
- package/dist/site/components/header/index.cjs +9 -674
- package/dist/site/components/header/index.js +8 -657
- package/dist/site/components/header/mobile-bag-drawer.cjs +6 -71
- package/dist/site/components/header/mobile-bag-drawer.js +5 -74
- package/dist/site/components/header/mobile-nav-menu-ai.cjs +25 -28
- package/dist/site/components/header/mobile-nav-menu-ai.js +24 -27
- package/dist/site/components/header/mobile-nav-menu-item.cjs +6 -60
- package/dist/site/components/header/mobile-nav-menu-item.js +6 -61
- package/dist/site/components/header/mobile-nav-menu.cjs +7 -110
- package/dist/site/components/header/mobile-nav-menu.js +7 -112
- package/dist/site/components/header/mobile.cjs +48 -330
- package/dist/site/components/header/mobile.js +42 -330
- package/dist/site/components/icons/index.cjs +34 -35
- package/dist/site/components/icons/index.js +5 -33
- package/dist/site/components/index.cjs +118 -1961
- package/dist/site/components/index.js +23 -1951
- package/dist/site/components/mini-chart/index.cjs +7 -90
- package/dist/site/components/mini-chart/index.js +1 -92
- package/dist/site/components/mini-chart/wrapper.cjs +7 -76
- package/dist/site/components/mini-chart/wrapper.js +4 -77
- package/dist/site/components/not-found/index.cjs +9 -819
- package/dist/site/components/not-found/index.js +8 -802
- package/dist/site/components/security/index.cjs +9 -819
- package/dist/site/components/security/index.js +8 -802
- package/dist/site/next/analytics/index.cjs +16 -49
- package/dist/site/next/analytics/index.js +3 -49
- package/dist/site/next/analytics/pixel-analytics.cjs +23 -8
- package/dist/site/next/analytics/pixel-analytics.js +4 -8
- package/dist/site/next/index.cjs +13 -140
- package/dist/site/next/index.js +2 -140
- package/dist/site/root-layout/index.cjs +12 -1435
- package/dist/site/root-layout/index.css +0 -133
- package/dist/site/root-layout/index.js +12 -1416
- package/dist/site/site-def/footer/community.cjs +11 -27
- package/dist/site/site-def/footer/community.js +2 -18
- package/dist/site/site-def/footer/index.cjs +38 -218
- package/dist/site/site-def/footer/index.js +14 -215
- package/dist/site/site-def/index.cjs +28 -620
- package/dist/site/site-def/index.js +3 -624
- package/dist/table.cjs +20 -338
- package/dist/table.js +19 -338
- package/dist/tabs.cjs +3 -10
- package/dist/tabs.js +1 -9
- package/dist/tag.cjs +9 -270
- package/dist/tag.js +6 -268
- package/dist/tags.cjs +6 -314
- package/dist/tags.js +5 -314
- package/dist/textarea.cjs +4 -50
- package/dist/textarea.js +3 -49
- package/dist/tooltip.cjs +15 -34
- package/dist/tooltip.js +13 -33
- package/dist/vite.cjs +3 -82
- package/dist/vite.js +1 -80
- package/package.json +1 -1
- package/dist/index.css +0 -132
- package/dist/site/components/auth/login-panel.css +0 -4
- package/dist/site/components/commerce/bag-button.css +0 -4
- package/dist/site/components/commerce/checkout-button.css +0 -4
- package/dist/site/components/commerce/checkout-panel/desktop-cp.css +0 -132
- package/dist/site/components/commerce/checkout-panel/index.css +0 -132
- package/dist/site/components/commerce/checkout-panel/mobile-cp.css +0 -132
- package/dist/site/components/commerce/desktop-bag-popup.css +0 -4
- package/dist/site/components/commerce/drawer/index.css +0 -132
- package/dist/site/components/commerce/drawer/micro.css +0 -4
- package/dist/site/components/header/desktop.css +0 -4
- package/dist/site/components/header/index.css +0 -132
- package/dist/site/components/header/mobile-bag-drawer.css +0 -4
- package/dist/site/components/header/mobile-nav-menu-ai.css +0 -132
- package/dist/site/components/header/mobile-nav-menu-item.css +0 -132
- package/dist/site/components/header/mobile-nav-menu.css +0 -132
- package/dist/site/components/header/mobile.css +0 -132
- package/dist/site/components/icons/index.css +0 -4
- package/dist/site/components/index.css +0 -132
- package/dist/site/components/not-found/index.css +0 -132
- package/dist/site/components/security/index.css +0 -132
- package/dist/site/site-def/footer/community.css +0 -4
- package/dist/site/site-def/footer/index.css +0 -4
- package/dist/site/site-def/index.css +0 -4
package/dist/identity.js
CHANGED
|
@@ -1,224 +1,9 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import * as
|
|
3
|
-
import
|
|
4
|
-
import '
|
|
5
|
-
import { QueryClient } from '@tanstack/react-query';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { iamBase, iam, IamError } from './iam.js';
|
|
4
|
+
import { useWhiteLabel } from './provider.js';
|
|
6
5
|
import { jsx } from 'react/jsx-runtime';
|
|
7
6
|
|
|
8
|
-
// src/white-label.ts
|
|
9
|
-
var LUX_BRAND = {
|
|
10
|
-
lux: "#7000FF",
|
|
11
|
-
zoo: "#6C5EFB",
|
|
12
|
-
hanzo: "#EA580C",
|
|
13
|
-
pars: "#1C3879"};
|
|
14
|
-
var PARS_GOLD = "#C8A45C";
|
|
15
|
-
var ORGS = {
|
|
16
|
-
lux: {
|
|
17
|
-
org: "lux",
|
|
18
|
-
name: "Lux",
|
|
19
|
-
domain: "lux.network",
|
|
20
|
-
iamDomain: "lux.id",
|
|
21
|
-
accent: LUX_BRAND.lux,
|
|
22
|
-
accentForeground: "#FFFFFF"
|
|
23
|
-
},
|
|
24
|
-
zoo: {
|
|
25
|
-
org: "zoo",
|
|
26
|
-
name: "Zoo",
|
|
27
|
-
domain: "zoo.ngo",
|
|
28
|
-
// Zoo's issuer is `zoolabs.id` — the one row where it is not `<org>.id`,
|
|
29
|
-
// and the one every hand-rolled branding map gets wrong. `id.zoo.network`
|
|
30
|
-
// ANSWERS, which is why it keeps being copied around, but it is an alias:
|
|
31
|
-
// its own discovery document advertises
|
|
32
|
-
// issuer https://zoolabs.id
|
|
33
|
-
// authorization_endpoint https://zoolabs.id/v1/iam/oauth/authorize
|
|
34
|
-
// jwks_uri https://zoolabs.id/v1/iam/.well-known/jwks
|
|
35
|
-
// so a client configured on the alias validates `iss` against a string the
|
|
36
|
-
// IdP never emits and rejects every token it is given — the exact shape of
|
|
37
|
-
// the lux.id outage. `zoo.id` is not an IdP at all (no discovery document).
|
|
38
|
-
iamDomain: "zoolabs.id",
|
|
39
|
-
accent: LUX_BRAND.zoo,
|
|
40
|
-
accentForeground: "#FFFFFF"
|
|
41
|
-
},
|
|
42
|
-
bootnode: {
|
|
43
|
-
org: "bootnode",
|
|
44
|
-
name: "Bootnode",
|
|
45
|
-
domain: "bootno.de",
|
|
46
|
-
iamDomain: "id.bootno.de",
|
|
47
|
-
accent: LUX_BRAND.lux,
|
|
48
|
-
accentForeground: "#FFFFFF"
|
|
49
|
-
},
|
|
50
|
-
hanzo: {
|
|
51
|
-
org: "hanzo",
|
|
52
|
-
name: "Hanzo",
|
|
53
|
-
domain: "hanzo.ai",
|
|
54
|
-
iamDomain: "hanzo.id",
|
|
55
|
-
accent: LUX_BRAND.hanzo,
|
|
56
|
-
accentForeground: "#FFFFFF"
|
|
57
|
-
},
|
|
58
|
-
pars: {
|
|
59
|
-
org: "pars",
|
|
60
|
-
name: "Pars",
|
|
61
|
-
domain: "pars.id",
|
|
62
|
-
iamDomain: "pars.id",
|
|
63
|
-
accent: LUX_BRAND.pars,
|
|
64
|
-
accentForeground: PARS_GOLD
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
var DOMAIN_ORG = [
|
|
68
|
-
["lux.network", "lux"],
|
|
69
|
-
["lux.cloud", "lux"],
|
|
70
|
-
["lux.id", "lux"],
|
|
71
|
-
["lux.finance", "lux"],
|
|
72
|
-
["lux.market", "lux"],
|
|
73
|
-
["lux.exchange", "lux"],
|
|
74
|
-
["zoo.ngo", "zoo"],
|
|
75
|
-
["zoo.network", "zoo"],
|
|
76
|
-
["zoo.cloud", "zoo"],
|
|
77
|
-
["zoolabs.id", "zoo"],
|
|
78
|
-
["hanzo.ai", "hanzo"],
|
|
79
|
-
["hanzo.cloud", "hanzo"],
|
|
80
|
-
["hanzo.id", "hanzo"],
|
|
81
|
-
["pars.id", "pars", "app"],
|
|
82
|
-
["pars.network", "pars", "app"],
|
|
83
|
-
["parsdao.org", "pars", "app"],
|
|
84
|
-
["bootno.de", "bootnode", "platform"]
|
|
85
|
-
];
|
|
86
|
-
var DEFAULT_ORG = "lux";
|
|
87
|
-
function normalizeHost(host) {
|
|
88
|
-
const noPort = host.trim().toLowerCase().split(":")[0] ?? "";
|
|
89
|
-
return noPort.replace(/\.$/, "");
|
|
90
|
-
}
|
|
91
|
-
function isUnder(host, domain) {
|
|
92
|
-
return host === domain || host.endsWith(`.${domain}`);
|
|
93
|
-
}
|
|
94
|
-
function matchDomain(host) {
|
|
95
|
-
let best;
|
|
96
|
-
for (const entry of DOMAIN_ORG) {
|
|
97
|
-
if (isUnder(host, entry[0]) && (!best || entry[0].length > best[0].length)) {
|
|
98
|
-
best = entry;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
return best;
|
|
102
|
-
}
|
|
103
|
-
function appSlug(host, domain, pinned) {
|
|
104
|
-
if (pinned) return pinned;
|
|
105
|
-
const sub = host === domain ? "" : host.slice(0, -(domain.length + 1));
|
|
106
|
-
const leftmost = sub.split(".")[0] ?? "";
|
|
107
|
-
if (leftmost && leftmost !== "www") return leftmost;
|
|
108
|
-
const label = domain.split(".")[0] ?? "";
|
|
109
|
-
const tld = domain.split(".").slice(1).join(".");
|
|
110
|
-
return tld.split(".")[0] || label;
|
|
111
|
-
}
|
|
112
|
-
function isLocal(host) {
|
|
113
|
-
return host === "localhost" || host.endsWith(".localhost") || host === "127.0.0.1" || host === "0.0.0.0" || host === "[::1]" || host.endsWith(".local");
|
|
114
|
-
}
|
|
115
|
-
function resolveWhiteLabel(host) {
|
|
116
|
-
const h = normalizeHost(host ?? "");
|
|
117
|
-
const match = h ? matchDomain(h) : void 0;
|
|
118
|
-
const org = match ? match[1] : DEFAULT_ORG;
|
|
119
|
-
const identity = ORGS[org];
|
|
120
|
-
const app = match ? appSlug(h, match[0], match[2]) : h && isLocal(h) ? "local" : "app";
|
|
121
|
-
return {
|
|
122
|
-
...identity,
|
|
123
|
-
host: h,
|
|
124
|
-
app,
|
|
125
|
-
theme: `dark_${org}`,
|
|
126
|
-
issuer: `https://${identity.iamDomain}`,
|
|
127
|
-
clientId: `${org}-${app}`
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
// src/iam.ts
|
|
132
|
-
var IamError = class extends Error {
|
|
133
|
-
constructor(message, status, unauthenticated) {
|
|
134
|
-
super(message);
|
|
135
|
-
this.name = "IamError";
|
|
136
|
-
this.status = status;
|
|
137
|
-
this.unauthenticated = unauthenticated;
|
|
138
|
-
}
|
|
139
|
-
};
|
|
140
|
-
var SIGNED_OUT = /please sign in|authentication required|unauthorized/i;
|
|
141
|
-
function isSignedOut(status, msg) {
|
|
142
|
-
return status === 401 || SIGNED_OUT.test(msg);
|
|
143
|
-
}
|
|
144
|
-
function iamBase(host) {
|
|
145
|
-
const wl = typeof host === "object" && host !== null ? host : resolveWhiteLabel(host);
|
|
146
|
-
return `${wl.issuer}/v1/iam`;
|
|
147
|
-
}
|
|
148
|
-
async function read(call, verb, params) {
|
|
149
|
-
const url = new URL(`${call.base}/${verb}`);
|
|
150
|
-
for (const [k, v] of Object.entries(params)) url.searchParams.set(k, String(v));
|
|
151
|
-
let res;
|
|
152
|
-
try {
|
|
153
|
-
res = await fetch(url.toString(), {
|
|
154
|
-
method: "GET",
|
|
155
|
-
// The bearer is the whole credential. IAM does not allow credentialed
|
|
156
|
-
// CORS, so sending cookies would only get the response blocked.
|
|
157
|
-
headers: call.token ? { Authorization: `Bearer ${call.token}` } : {},
|
|
158
|
-
signal: call.signal
|
|
159
|
-
});
|
|
160
|
-
} catch (e) {
|
|
161
|
-
throw new IamError(e instanceof Error ? e.message : "IAM unreachable", 0, false);
|
|
162
|
-
}
|
|
163
|
-
const body = await res.json().catch(() => ({}));
|
|
164
|
-
const msg = typeof body.msg === "string" ? body.msg : "";
|
|
165
|
-
if (!res.ok || body.status === "error") {
|
|
166
|
-
throw new IamError(msg || `IAM ${verb} failed (${res.status})`, res.status, isSignedOut(res.status, msg));
|
|
167
|
-
}
|
|
168
|
-
return body.data;
|
|
169
|
-
}
|
|
170
|
-
var IAM_PAGE_SIZE = 20;
|
|
171
|
-
var iam = {
|
|
172
|
-
/** The signed-in principal, or null when there is no session. */
|
|
173
|
-
async account(call) {
|
|
174
|
-
try {
|
|
175
|
-
const data = await read(call, "get-account", {});
|
|
176
|
-
return data && data.name ? data : null;
|
|
177
|
-
} catch (e) {
|
|
178
|
-
if (e instanceof IamError && e.unauthenticated) return null;
|
|
179
|
-
throw e;
|
|
180
|
-
}
|
|
181
|
-
},
|
|
182
|
-
/**
|
|
183
|
-
* One page of the orgs the principal can see. IAM scopes the read to the
|
|
184
|
-
* caller's authority, so a normal member gets their own org and a super
|
|
185
|
-
* admin gets the tenant list — the page never has to decide.
|
|
186
|
-
*/
|
|
187
|
-
async organizations(call, page = 0, query = "", pageSize = IAM_PAGE_SIZE) {
|
|
188
|
-
const params = {
|
|
189
|
-
owner: "admin",
|
|
190
|
-
// IAM orgs live under the reserved `admin` owner
|
|
191
|
-
p: page + 1,
|
|
192
|
-
// the backend page is 1-based
|
|
193
|
-
pageSize,
|
|
194
|
-
sortField: "name",
|
|
195
|
-
sortOrder: "ascending"
|
|
196
|
-
};
|
|
197
|
-
const q = query.trim();
|
|
198
|
-
if (q) {
|
|
199
|
-
params.field = "name";
|
|
200
|
-
params.value = q;
|
|
201
|
-
}
|
|
202
|
-
return await read(call, "get-organizations", params) ?? [];
|
|
203
|
-
},
|
|
204
|
-
/** One organization by name. */
|
|
205
|
-
async organization(call, name) {
|
|
206
|
-
return await read(call, "get-organization", { id: `admin/${name}` }) ?? null;
|
|
207
|
-
},
|
|
208
|
-
/** Members of an organization. */
|
|
209
|
-
async users(call, org) {
|
|
210
|
-
return await read(call, "get-users", { owner: org }) ?? [];
|
|
211
|
-
},
|
|
212
|
-
/** The organization's projects — IAM keys this read by `organization`. */
|
|
213
|
-
async projects(call, org) {
|
|
214
|
-
return await read(call, "get-organization-projects", { organization: org }) ?? [];
|
|
215
|
-
}
|
|
216
|
-
};
|
|
217
|
-
new QueryClient({
|
|
218
|
-
defaultOptions: { queries: { refetchOnWindowFocus: false, retry: 1, staleTime: 3e4 } }
|
|
219
|
-
});
|
|
220
|
-
var WhiteLabelContext = React2__default.createContext(resolveWhiteLabel(""));
|
|
221
|
-
var useWhiteLabel = () => React2__default.useContext(WhiteLabelContext);
|
|
222
7
|
var IAM_TOKEN_KEY = "hanzo_iam_access_token";
|
|
223
8
|
function storedToken() {
|
|
224
9
|
if (typeof window === "undefined") return null;
|
|
@@ -259,23 +44,23 @@ function writeScope(host, kind, value) {
|
|
|
259
44
|
} catch {
|
|
260
45
|
}
|
|
261
46
|
}
|
|
262
|
-
var IdentityContext =
|
|
47
|
+
var IdentityContext = React.createContext(null);
|
|
263
48
|
var IdentityProvider = ({
|
|
264
49
|
children,
|
|
265
50
|
auth = defaultAuth,
|
|
266
51
|
loginPath = "/login"
|
|
267
52
|
}) => {
|
|
268
53
|
const whiteLabel = useWhiteLabel();
|
|
269
|
-
const base =
|
|
270
|
-
const [status, setStatus] =
|
|
271
|
-
const [account, setAccount] =
|
|
272
|
-
const [orgs, setOrgs] =
|
|
273
|
-
const [projects, setProjects] =
|
|
274
|
-
const [error, setError] =
|
|
275
|
-
const [orgName, setOrgName] =
|
|
276
|
-
const [projectName, setProjectName] =
|
|
277
|
-
const [epoch, setEpoch] =
|
|
278
|
-
|
|
54
|
+
const base = React.useMemo(() => iamBase(whiteLabel), [whiteLabel]);
|
|
55
|
+
const [status, setStatus] = React.useState("loading");
|
|
56
|
+
const [account, setAccount] = React.useState(null);
|
|
57
|
+
const [orgs, setOrgs] = React.useState([]);
|
|
58
|
+
const [projects, setProjects] = React.useState([]);
|
|
59
|
+
const [error, setError] = React.useState(null);
|
|
60
|
+
const [orgName, setOrgName] = React.useState(null);
|
|
61
|
+
const [projectName, setProjectName] = React.useState(null);
|
|
62
|
+
const [epoch, setEpoch] = React.useState(0);
|
|
63
|
+
React.useEffect(() => {
|
|
279
64
|
const ac = new AbortController();
|
|
280
65
|
let live = true;
|
|
281
66
|
void (async () => {
|
|
@@ -323,12 +108,12 @@ var IdentityProvider = ({
|
|
|
323
108
|
ac.abort();
|
|
324
109
|
};
|
|
325
110
|
}, [base, auth, epoch]);
|
|
326
|
-
const org =
|
|
111
|
+
const org = React.useMemo(() => {
|
|
327
112
|
if (orgs.length === 0) return null;
|
|
328
113
|
const saved = orgName ?? readScope(whiteLabel.host, "org");
|
|
329
114
|
return orgs.find((o) => o.name === saved) ?? orgs.find((o) => o.name === account?.owner) ?? orgs[0];
|
|
330
115
|
}, [orgs, orgName, account, whiteLabel.host]);
|
|
331
|
-
|
|
116
|
+
React.useEffect(() => {
|
|
332
117
|
if (!org) {
|
|
333
118
|
setProjects([]);
|
|
334
119
|
return;
|
|
@@ -346,12 +131,12 @@ var IdentityProvider = ({
|
|
|
346
131
|
ac.abort();
|
|
347
132
|
};
|
|
348
133
|
}, [base, auth, org, epoch]);
|
|
349
|
-
const project =
|
|
134
|
+
const project = React.useMemo(() => {
|
|
350
135
|
if (projects.length === 0) return null;
|
|
351
136
|
const saved = projectName ?? readScope(whiteLabel.host, "project");
|
|
352
137
|
return projects.find((p) => p.name === saved) ?? projects.find((p) => p.isDefault) ?? projects[0];
|
|
353
138
|
}, [projects, projectName, whiteLabel.host]);
|
|
354
|
-
const value =
|
|
139
|
+
const value = React.useMemo(() => ({
|
|
355
140
|
status,
|
|
356
141
|
account,
|
|
357
142
|
orgs,
|
|
@@ -383,9 +168,9 @@ var IdentityProvider = ({
|
|
|
383
168
|
return /* @__PURE__ */ jsx(IdentityContext.Provider, { value, children });
|
|
384
169
|
};
|
|
385
170
|
function useIdentity() {
|
|
386
|
-
const ctx =
|
|
171
|
+
const ctx = React.useContext(IdentityContext);
|
|
387
172
|
const whiteLabel = useWhiteLabel();
|
|
388
|
-
const fallback =
|
|
173
|
+
const fallback = React.useMemo(() => ({
|
|
389
174
|
status: "anonymous",
|
|
390
175
|
account: null,
|
|
391
176
|
orgs: [],
|