@luxfi/ui 7.4.0 → 7.4.3

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.
Files changed (131) hide show
  1. package/dist/avatar.cjs +7 -6
  2. package/dist/avatar.js +7 -5
  3. package/dist/badge.cjs +33 -35
  4. package/dist/badge.js +33 -35
  5. package/dist/bank.d.cts +3 -3
  6. package/dist/bank.d.ts +3 -3
  7. package/dist/checkbox.cjs +4 -4
  8. package/dist/checkbox.d.cts +3 -2
  9. package/dist/checkbox.d.ts +3 -2
  10. package/dist/checkbox.js +5 -4
  11. package/dist/chrome.cjs +960 -0
  12. package/dist/chrome.d.cts +93 -0
  13. package/dist/chrome.d.ts +93 -0
  14. package/dist/chrome.js +931 -0
  15. package/dist/drawer.cjs +86 -20
  16. package/dist/drawer.js +85 -19
  17. package/dist/expiration-selector.cjs +3 -2
  18. package/dist/expiration-selector.js +3 -2
  19. package/dist/greeks-display.cjs +6 -6
  20. package/dist/greeks-display.js +6 -6
  21. package/dist/gui.cjs +13 -0
  22. package/dist/gui.d.cts +2 -0
  23. package/dist/gui.d.ts +2 -0
  24. package/dist/gui.js +2 -0
  25. package/dist/heading.cjs +4 -2
  26. package/dist/heading.js +4 -2
  27. package/dist/iam.cjs +216 -0
  28. package/dist/iam.d.cts +65 -0
  29. package/dist/iam.d.ts +65 -0
  30. package/dist/iam.js +211 -0
  31. package/dist/icons.cjs +13 -0
  32. package/dist/icons.d.cts +1 -0
  33. package/dist/icons.d.ts +1 -0
  34. package/dist/icons.js +2 -0
  35. package/dist/identity.cjs +430 -0
  36. package/dist/identity.d.cts +64 -0
  37. package/dist/identity.d.ts +64 -0
  38. package/dist/identity.js +408 -0
  39. package/dist/index.cjs +1610 -836
  40. package/dist/index.d.cts +7 -3
  41. package/dist/index.d.ts +7 -3
  42. package/dist/index.js +1587 -831
  43. package/dist/input.cjs +3 -1
  44. package/dist/input.d.cts +3 -5
  45. package/dist/input.d.ts +3 -5
  46. package/dist/input.js +3 -1
  47. package/dist/lux.config.cjs +23 -2
  48. package/dist/lux.config.d.cts +28 -10
  49. package/dist/lux.config.d.ts +28 -10
  50. package/dist/lux.config.js +23 -2
  51. package/dist/menu.cjs +4 -4
  52. package/dist/menu.js +4 -4
  53. package/dist/next.cjs +132 -0
  54. package/dist/next.d.cts +32 -0
  55. package/dist/next.d.ts +32 -0
  56. package/dist/next.js +129 -0
  57. package/dist/option-chain.cjs +1 -1
  58. package/dist/option-chain.js +1 -1
  59. package/dist/option-position.cjs +2 -1
  60. package/dist/option-position.js +2 -1
  61. package/dist/pnl-diagram.cjs +8 -6
  62. package/dist/pnl-diagram.js +8 -6
  63. package/dist/progress.cjs +7 -6
  64. package/dist/progress.js +7 -5
  65. package/dist/provider.cjs +146 -4
  66. package/dist/provider.d.cts +15 -3
  67. package/dist/provider.d.ts +15 -3
  68. package/dist/provider.js +146 -5
  69. package/dist/radio.cjs +9 -7
  70. package/dist/radio.js +10 -7
  71. package/dist/separator.cjs +3 -1
  72. package/dist/separator.js +3 -1
  73. package/dist/slider.cjs +28 -16
  74. package/dist/slider.js +28 -15
  75. package/dist/strategy-builder.cjs +2 -1
  76. package/dist/strategy-builder.js +2 -1
  77. package/dist/switch.cjs +11 -12
  78. package/dist/switch.js +12 -12
  79. package/dist/tag.cjs +34 -36
  80. package/dist/tag.js +33 -35
  81. package/dist/textarea.cjs +3 -1
  82. package/dist/textarea.js +3 -1
  83. package/dist/tooltip.cjs +28 -30
  84. package/dist/tooltip.js +27 -29
  85. package/dist/use-narrow.cjs +46 -0
  86. package/dist/use-narrow.d.cts +12 -0
  87. package/dist/use-narrow.d.ts +12 -0
  88. package/dist/use-narrow.js +20 -0
  89. package/dist/vite.cjs +109 -0
  90. package/dist/vite.d.cts +29 -0
  91. package/dist/vite.d.ts +29 -0
  92. package/dist/vite.js +107 -0
  93. package/dist/white-label.cjs +142 -0
  94. package/dist/white-label.d.cts +59 -0
  95. package/dist/white-label.d.ts +59 -0
  96. package/dist/white-label.js +134 -0
  97. package/package.json +85 -19
  98. package/src/avatar.tsx +22 -16
  99. package/src/checkbox.tsx +15 -10
  100. package/src/chrome.tsx +459 -0
  101. package/src/drawer.tsx +83 -10
  102. package/src/engine.ts +130 -0
  103. package/src/expiration-selector.tsx +3 -2
  104. package/src/greeks-display.tsx +9 -6
  105. package/src/gui.ts +17 -0
  106. package/src/heading.tsx +12 -8
  107. package/src/iam.ts +170 -0
  108. package/src/icons.ts +18 -0
  109. package/src/identity.tsx +318 -0
  110. package/src/index.ts +44 -1
  111. package/src/input.tsx +13 -9
  112. package/src/lux.config.ts +16 -15
  113. package/src/menu.tsx +4 -4
  114. package/src/next.ts +89 -0
  115. package/src/option-chain.tsx +1 -1
  116. package/src/option-position.tsx +2 -1
  117. package/src/pnl-diagram.tsx +11 -6
  118. package/src/progress.tsx +15 -8
  119. package/src/provider.tsx +48 -7
  120. package/src/radio.tsx +15 -11
  121. package/src/separator.tsx +8 -3
  122. package/src/slider.tsx +35 -19
  123. package/src/strategy-builder.tsx +3 -2
  124. package/src/switch.tsx +17 -16
  125. package/src/textarea.tsx +8 -4
  126. package/src/tooltip.tsx +15 -24
  127. package/src/use-narrow.ts +40 -0
  128. package/src/vite.ts +80 -0
  129. package/src/white-label.ts +254 -0
  130. package/tokens.css +613 -319
  131. package/src/tokens.css +0 -438
package/dist/iam.cjs ADDED
@@ -0,0 +1,216 @@
1
+ 'use strict';
2
+
3
+ // src/white-label.ts
4
+ var LUX_BRAND = {
5
+ lux: "#7000FF",
6
+ zoo: "#6C5EFB",
7
+ hanzo: "#EA580C",
8
+ pars: "#1C3879"};
9
+ var PARS_GOLD = "#C8A45C";
10
+ var ORGS = {
11
+ lux: {
12
+ org: "lux",
13
+ name: "Lux",
14
+ domain: "lux.network",
15
+ iamDomain: "lux.id",
16
+ accent: LUX_BRAND.lux,
17
+ accentForeground: "#FFFFFF"
18
+ },
19
+ zoo: {
20
+ org: "zoo",
21
+ name: "Zoo",
22
+ domain: "zoo.ngo",
23
+ // Zoo's issuer is `zoolabs.id` — the one row where it is not `<org>.id`,
24
+ // and the one every hand-rolled branding map gets wrong. `id.zoo.network`
25
+ // ANSWERS, which is why it keeps being copied around, but it is an alias:
26
+ // its own discovery document advertises
27
+ // issuer https://zoolabs.id
28
+ // authorization_endpoint https://zoolabs.id/v1/iam/oauth/authorize
29
+ // jwks_uri https://zoolabs.id/v1/iam/.well-known/jwks
30
+ // so a client configured on the alias validates `iss` against a string the
31
+ // IdP never emits and rejects every token it is given — the exact shape of
32
+ // the lux.id outage. `zoo.id` is not an IdP at all (no discovery document).
33
+ iamDomain: "zoolabs.id",
34
+ accent: LUX_BRAND.zoo,
35
+ accentForeground: "#FFFFFF"
36
+ },
37
+ bootnode: {
38
+ org: "bootnode",
39
+ name: "Bootnode",
40
+ domain: "bootno.de",
41
+ iamDomain: "id.bootno.de",
42
+ accent: LUX_BRAND.lux,
43
+ accentForeground: "#FFFFFF"
44
+ },
45
+ hanzo: {
46
+ org: "hanzo",
47
+ name: "Hanzo",
48
+ domain: "hanzo.ai",
49
+ iamDomain: "hanzo.id",
50
+ accent: LUX_BRAND.hanzo,
51
+ accentForeground: "#FFFFFF"
52
+ },
53
+ pars: {
54
+ org: "pars",
55
+ name: "Pars",
56
+ domain: "pars.id",
57
+ iamDomain: "pars.id",
58
+ accent: LUX_BRAND.pars,
59
+ accentForeground: PARS_GOLD
60
+ }
61
+ };
62
+ var DOMAIN_ORG = [
63
+ ["lux.network", "lux"],
64
+ ["lux.cloud", "lux"],
65
+ ["lux.id", "lux"],
66
+ ["lux.finance", "lux"],
67
+ ["lux.market", "lux"],
68
+ ["lux.exchange", "lux"],
69
+ ["zoo.ngo", "zoo"],
70
+ ["zoo.network", "zoo"],
71
+ ["zoo.cloud", "zoo"],
72
+ ["zoolabs.id", "zoo"],
73
+ ["hanzo.ai", "hanzo"],
74
+ ["hanzo.cloud", "hanzo"],
75
+ ["hanzo.id", "hanzo"],
76
+ ["pars.id", "pars", "app"],
77
+ ["pars.network", "pars", "app"],
78
+ ["parsdao.org", "pars", "app"],
79
+ ["bootno.de", "bootnode", "platform"]
80
+ ];
81
+ var DEFAULT_ORG = "lux";
82
+ function normalizeHost(host) {
83
+ const noPort = host.trim().toLowerCase().split(":")[0] ?? "";
84
+ return noPort.replace(/\.$/, "");
85
+ }
86
+ function isUnder(host, domain) {
87
+ return host === domain || host.endsWith(`.${domain}`);
88
+ }
89
+ function matchDomain(host) {
90
+ let best;
91
+ for (const entry of DOMAIN_ORG) {
92
+ if (isUnder(host, entry[0]) && (!best || entry[0].length > best[0].length)) {
93
+ best = entry;
94
+ }
95
+ }
96
+ return best;
97
+ }
98
+ function appSlug(host, domain, pinned) {
99
+ if (pinned) return pinned;
100
+ const sub = host === domain ? "" : host.slice(0, -(domain.length + 1));
101
+ const leftmost = sub.split(".")[0] ?? "";
102
+ if (leftmost && leftmost !== "www") return leftmost;
103
+ const label = domain.split(".")[0] ?? "";
104
+ const tld = domain.split(".").slice(1).join(".");
105
+ return tld.split(".")[0] || label;
106
+ }
107
+ function isLocal(host) {
108
+ return host === "localhost" || host.endsWith(".localhost") || host === "127.0.0.1" || host === "0.0.0.0" || host === "[::1]" || host.endsWith(".local");
109
+ }
110
+ function resolveWhiteLabel(host) {
111
+ const h = normalizeHost(host ?? "");
112
+ const match = h ? matchDomain(h) : void 0;
113
+ const org = match ? match[1] : DEFAULT_ORG;
114
+ const identity = ORGS[org];
115
+ const app = match ? appSlug(h, match[0], match[2]) : h && isLocal(h) ? "local" : "app";
116
+ return {
117
+ ...identity,
118
+ host: h,
119
+ app,
120
+ theme: `dark_${org}`,
121
+ issuer: `https://${identity.iamDomain}`,
122
+ clientId: `${org}-${app}`
123
+ };
124
+ }
125
+
126
+ // src/iam.ts
127
+ var IamError = class extends Error {
128
+ constructor(message, status, unauthenticated) {
129
+ super(message);
130
+ this.name = "IamError";
131
+ this.status = status;
132
+ this.unauthenticated = unauthenticated;
133
+ }
134
+ };
135
+ var SIGNED_OUT = /please sign in|authentication required|unauthorized/i;
136
+ function isSignedOut(status, msg) {
137
+ return status === 401 || status === 403 || SIGNED_OUT.test(msg);
138
+ }
139
+ function iamBase(host) {
140
+ const wl = typeof host === "object" && host !== null ? host : resolveWhiteLabel(host);
141
+ return `${wl.issuer}/v1/iam`;
142
+ }
143
+ async function read(call, verb, params) {
144
+ const url = new URL(`${call.base}/${verb}`);
145
+ for (const [k, v] of Object.entries(params)) url.searchParams.set(k, String(v));
146
+ let res;
147
+ try {
148
+ res = await fetch(url.toString(), {
149
+ method: "GET",
150
+ // The bearer is the whole credential. IAM does not allow credentialed
151
+ // CORS, so sending cookies would only get the response blocked.
152
+ headers: call.token ? { Authorization: `Bearer ${call.token}` } : {},
153
+ signal: call.signal
154
+ });
155
+ } catch (e) {
156
+ throw new IamError(e instanceof Error ? e.message : "IAM unreachable", 0, false);
157
+ }
158
+ const body = await res.json().catch(() => ({}));
159
+ const msg = typeof body.msg === "string" ? body.msg : "";
160
+ if (!res.ok || body.status === "error") {
161
+ throw new IamError(msg || `IAM ${verb} failed (${res.status})`, res.status, isSignedOut(res.status, msg));
162
+ }
163
+ return body.data;
164
+ }
165
+ var IAM_PAGE_SIZE = 20;
166
+ var iam = {
167
+ /** The signed-in principal, or null when there is no session. */
168
+ async account(call) {
169
+ try {
170
+ const data = await read(call, "get-account", {});
171
+ return data && data.name ? data : null;
172
+ } catch (e) {
173
+ if (e instanceof IamError && e.unauthenticated) return null;
174
+ throw e;
175
+ }
176
+ },
177
+ /**
178
+ * One page of the orgs the principal can see. IAM scopes the read to the
179
+ * caller's authority, so a normal member gets their own org and a super
180
+ * admin gets the tenant list — the page never has to decide.
181
+ */
182
+ async organizations(call, page = 0, query = "", pageSize = IAM_PAGE_SIZE) {
183
+ const params = {
184
+ owner: "admin",
185
+ // IAM orgs live under the reserved `admin` owner
186
+ p: page + 1,
187
+ // the backend page is 1-based
188
+ pageSize,
189
+ sortField: "name",
190
+ sortOrder: "ascending"
191
+ };
192
+ const q = query.trim();
193
+ if (q) {
194
+ params.field = "name";
195
+ params.value = q;
196
+ }
197
+ return await read(call, "get-organizations", params) ?? [];
198
+ },
199
+ /** One organization by name. */
200
+ async organization(call, name) {
201
+ return await read(call, "get-organization", { id: `admin/${name}` }) ?? null;
202
+ },
203
+ /** Members of an organization. */
204
+ async users(call, org) {
205
+ return await read(call, "get-users", { owner: org }) ?? [];
206
+ },
207
+ /** The organization's projects — IAM keys this read by `organization`. */
208
+ async projects(call, org) {
209
+ return await read(call, "get-organization-projects", { organization: org }) ?? [];
210
+ }
211
+ };
212
+
213
+ exports.IAM_PAGE_SIZE = IAM_PAGE_SIZE;
214
+ exports.IamError = IamError;
215
+ exports.iam = iam;
216
+ exports.iamBase = iamBase;
package/dist/iam.d.cts ADDED
@@ -0,0 +1,65 @@
1
+ import { WhiteLabel } from './white-label.cjs';
2
+
3
+ /** A signed-in principal, as IAM describes it. */
4
+ interface IamAccount {
5
+ readonly owner: string;
6
+ readonly name: string;
7
+ readonly displayName?: string;
8
+ readonly email?: string;
9
+ readonly avatar?: string;
10
+ readonly isAdmin?: boolean;
11
+ }
12
+ /** An organization the principal can see. */
13
+ interface IamOrg {
14
+ readonly owner: string;
15
+ readonly name: string;
16
+ readonly displayName?: string;
17
+ readonly logo?: string;
18
+ }
19
+ /** A project inside an organization (IAM's Org → Workspace → Project tier). */
20
+ interface IamProject {
21
+ readonly owner: string;
22
+ readonly name: string;
23
+ readonly displayName?: string;
24
+ readonly organization?: string;
25
+ readonly workspace?: string;
26
+ readonly isDefault?: boolean;
27
+ }
28
+ /**
29
+ * A refusal from IAM, carrying enough to tell "not signed in" apart from
30
+ * "signed in, and the answer is genuinely empty" — the distinction a switcher
31
+ * has to render honestly.
32
+ */
33
+ declare class IamError extends Error {
34
+ readonly status: number;
35
+ readonly unauthenticated: boolean;
36
+ constructor(message: string, status: number, unauthenticated: boolean);
37
+ }
38
+ /** The IAM API root for a host — `lux.cloud` → `https://lux.id/v1/iam`. */
39
+ declare function iamBase(host?: string | null | WhiteLabel): string;
40
+ /** How a read reaches IAM: where, and with whose bearer. */
41
+ interface IamCall {
42
+ readonly base: string;
43
+ readonly token?: string | null;
44
+ readonly signal?: AbortSignal;
45
+ }
46
+ /** Rows per page for the org list — small first paint, more on demand. */
47
+ declare const IAM_PAGE_SIZE = 20;
48
+ declare const iam: {
49
+ /** The signed-in principal, or null when there is no session. */
50
+ account(call: IamCall): Promise<IamAccount | null>;
51
+ /**
52
+ * One page of the orgs the principal can see. IAM scopes the read to the
53
+ * caller's authority, so a normal member gets their own org and a super
54
+ * admin gets the tenant list — the page never has to decide.
55
+ */
56
+ organizations(call: IamCall, page?: number, query?: string, pageSize?: number): Promise<Array<IamOrg>>;
57
+ /** One organization by name. */
58
+ organization(call: IamCall, name: string): Promise<IamOrg | null>;
59
+ /** Members of an organization. */
60
+ users(call: IamCall, org: string): Promise<Array<IamAccount>>;
61
+ /** The organization's projects — IAM keys this read by `organization`. */
62
+ projects(call: IamCall, org: string): Promise<Array<IamProject>>;
63
+ };
64
+
65
+ export { IAM_PAGE_SIZE, type IamAccount, type IamCall, IamError, type IamOrg, type IamProject, iam, iamBase };
package/dist/iam.d.ts ADDED
@@ -0,0 +1,65 @@
1
+ import { WhiteLabel } from './white-label.js';
2
+
3
+ /** A signed-in principal, as IAM describes it. */
4
+ interface IamAccount {
5
+ readonly owner: string;
6
+ readonly name: string;
7
+ readonly displayName?: string;
8
+ readonly email?: string;
9
+ readonly avatar?: string;
10
+ readonly isAdmin?: boolean;
11
+ }
12
+ /** An organization the principal can see. */
13
+ interface IamOrg {
14
+ readonly owner: string;
15
+ readonly name: string;
16
+ readonly displayName?: string;
17
+ readonly logo?: string;
18
+ }
19
+ /** A project inside an organization (IAM's Org → Workspace → Project tier). */
20
+ interface IamProject {
21
+ readonly owner: string;
22
+ readonly name: string;
23
+ readonly displayName?: string;
24
+ readonly organization?: string;
25
+ readonly workspace?: string;
26
+ readonly isDefault?: boolean;
27
+ }
28
+ /**
29
+ * A refusal from IAM, carrying enough to tell "not signed in" apart from
30
+ * "signed in, and the answer is genuinely empty" — the distinction a switcher
31
+ * has to render honestly.
32
+ */
33
+ declare class IamError extends Error {
34
+ readonly status: number;
35
+ readonly unauthenticated: boolean;
36
+ constructor(message: string, status: number, unauthenticated: boolean);
37
+ }
38
+ /** The IAM API root for a host — `lux.cloud` → `https://lux.id/v1/iam`. */
39
+ declare function iamBase(host?: string | null | WhiteLabel): string;
40
+ /** How a read reaches IAM: where, and with whose bearer. */
41
+ interface IamCall {
42
+ readonly base: string;
43
+ readonly token?: string | null;
44
+ readonly signal?: AbortSignal;
45
+ }
46
+ /** Rows per page for the org list — small first paint, more on demand. */
47
+ declare const IAM_PAGE_SIZE = 20;
48
+ declare const iam: {
49
+ /** The signed-in principal, or null when there is no session. */
50
+ account(call: IamCall): Promise<IamAccount | null>;
51
+ /**
52
+ * One page of the orgs the principal can see. IAM scopes the read to the
53
+ * caller's authority, so a normal member gets their own org and a super
54
+ * admin gets the tenant list — the page never has to decide.
55
+ */
56
+ organizations(call: IamCall, page?: number, query?: string, pageSize?: number): Promise<Array<IamOrg>>;
57
+ /** One organization by name. */
58
+ organization(call: IamCall, name: string): Promise<IamOrg | null>;
59
+ /** Members of an organization. */
60
+ users(call: IamCall, org: string): Promise<Array<IamAccount>>;
61
+ /** The organization's projects — IAM keys this read by `organization`. */
62
+ projects(call: IamCall, org: string): Promise<Array<IamProject>>;
63
+ };
64
+
65
+ export { IAM_PAGE_SIZE, type IamAccount, type IamCall, IamError, type IamOrg, type IamProject, iam, iamBase };
package/dist/iam.js ADDED
@@ -0,0 +1,211 @@
1
+ // src/white-label.ts
2
+ var LUX_BRAND = {
3
+ lux: "#7000FF",
4
+ zoo: "#6C5EFB",
5
+ hanzo: "#EA580C",
6
+ pars: "#1C3879"};
7
+ var PARS_GOLD = "#C8A45C";
8
+ var ORGS = {
9
+ lux: {
10
+ org: "lux",
11
+ name: "Lux",
12
+ domain: "lux.network",
13
+ iamDomain: "lux.id",
14
+ accent: LUX_BRAND.lux,
15
+ accentForeground: "#FFFFFF"
16
+ },
17
+ zoo: {
18
+ org: "zoo",
19
+ name: "Zoo",
20
+ domain: "zoo.ngo",
21
+ // Zoo's issuer is `zoolabs.id` — the one row where it is not `<org>.id`,
22
+ // and the one every hand-rolled branding map gets wrong. `id.zoo.network`
23
+ // ANSWERS, which is why it keeps being copied around, but it is an alias:
24
+ // its own discovery document advertises
25
+ // issuer https://zoolabs.id
26
+ // authorization_endpoint https://zoolabs.id/v1/iam/oauth/authorize
27
+ // jwks_uri https://zoolabs.id/v1/iam/.well-known/jwks
28
+ // so a client configured on the alias validates `iss` against a string the
29
+ // IdP never emits and rejects every token it is given — the exact shape of
30
+ // the lux.id outage. `zoo.id` is not an IdP at all (no discovery document).
31
+ iamDomain: "zoolabs.id",
32
+ accent: LUX_BRAND.zoo,
33
+ accentForeground: "#FFFFFF"
34
+ },
35
+ bootnode: {
36
+ org: "bootnode",
37
+ name: "Bootnode",
38
+ domain: "bootno.de",
39
+ iamDomain: "id.bootno.de",
40
+ accent: LUX_BRAND.lux,
41
+ accentForeground: "#FFFFFF"
42
+ },
43
+ hanzo: {
44
+ org: "hanzo",
45
+ name: "Hanzo",
46
+ domain: "hanzo.ai",
47
+ iamDomain: "hanzo.id",
48
+ accent: LUX_BRAND.hanzo,
49
+ accentForeground: "#FFFFFF"
50
+ },
51
+ pars: {
52
+ org: "pars",
53
+ name: "Pars",
54
+ domain: "pars.id",
55
+ iamDomain: "pars.id",
56
+ accent: LUX_BRAND.pars,
57
+ accentForeground: PARS_GOLD
58
+ }
59
+ };
60
+ var DOMAIN_ORG = [
61
+ ["lux.network", "lux"],
62
+ ["lux.cloud", "lux"],
63
+ ["lux.id", "lux"],
64
+ ["lux.finance", "lux"],
65
+ ["lux.market", "lux"],
66
+ ["lux.exchange", "lux"],
67
+ ["zoo.ngo", "zoo"],
68
+ ["zoo.network", "zoo"],
69
+ ["zoo.cloud", "zoo"],
70
+ ["zoolabs.id", "zoo"],
71
+ ["hanzo.ai", "hanzo"],
72
+ ["hanzo.cloud", "hanzo"],
73
+ ["hanzo.id", "hanzo"],
74
+ ["pars.id", "pars", "app"],
75
+ ["pars.network", "pars", "app"],
76
+ ["parsdao.org", "pars", "app"],
77
+ ["bootno.de", "bootnode", "platform"]
78
+ ];
79
+ var DEFAULT_ORG = "lux";
80
+ function normalizeHost(host) {
81
+ const noPort = host.trim().toLowerCase().split(":")[0] ?? "";
82
+ return noPort.replace(/\.$/, "");
83
+ }
84
+ function isUnder(host, domain) {
85
+ return host === domain || host.endsWith(`.${domain}`);
86
+ }
87
+ function matchDomain(host) {
88
+ let best;
89
+ for (const entry of DOMAIN_ORG) {
90
+ if (isUnder(host, entry[0]) && (!best || entry[0].length > best[0].length)) {
91
+ best = entry;
92
+ }
93
+ }
94
+ return best;
95
+ }
96
+ function appSlug(host, domain, pinned) {
97
+ if (pinned) return pinned;
98
+ const sub = host === domain ? "" : host.slice(0, -(domain.length + 1));
99
+ const leftmost = sub.split(".")[0] ?? "";
100
+ if (leftmost && leftmost !== "www") return leftmost;
101
+ const label = domain.split(".")[0] ?? "";
102
+ const tld = domain.split(".").slice(1).join(".");
103
+ return tld.split(".")[0] || label;
104
+ }
105
+ function isLocal(host) {
106
+ return host === "localhost" || host.endsWith(".localhost") || host === "127.0.0.1" || host === "0.0.0.0" || host === "[::1]" || host.endsWith(".local");
107
+ }
108
+ function resolveWhiteLabel(host) {
109
+ const h = normalizeHost(host ?? "");
110
+ const match = h ? matchDomain(h) : void 0;
111
+ const org = match ? match[1] : DEFAULT_ORG;
112
+ const identity = ORGS[org];
113
+ const app = match ? appSlug(h, match[0], match[2]) : h && isLocal(h) ? "local" : "app";
114
+ return {
115
+ ...identity,
116
+ host: h,
117
+ app,
118
+ theme: `dark_${org}`,
119
+ issuer: `https://${identity.iamDomain}`,
120
+ clientId: `${org}-${app}`
121
+ };
122
+ }
123
+
124
+ // src/iam.ts
125
+ var IamError = class extends Error {
126
+ constructor(message, status, unauthenticated) {
127
+ super(message);
128
+ this.name = "IamError";
129
+ this.status = status;
130
+ this.unauthenticated = unauthenticated;
131
+ }
132
+ };
133
+ var SIGNED_OUT = /please sign in|authentication required|unauthorized/i;
134
+ function isSignedOut(status, msg) {
135
+ return status === 401 || status === 403 || SIGNED_OUT.test(msg);
136
+ }
137
+ function iamBase(host) {
138
+ const wl = typeof host === "object" && host !== null ? host : resolveWhiteLabel(host);
139
+ return `${wl.issuer}/v1/iam`;
140
+ }
141
+ async function read(call, verb, params) {
142
+ const url = new URL(`${call.base}/${verb}`);
143
+ for (const [k, v] of Object.entries(params)) url.searchParams.set(k, String(v));
144
+ let res;
145
+ try {
146
+ res = await fetch(url.toString(), {
147
+ method: "GET",
148
+ // The bearer is the whole credential. IAM does not allow credentialed
149
+ // CORS, so sending cookies would only get the response blocked.
150
+ headers: call.token ? { Authorization: `Bearer ${call.token}` } : {},
151
+ signal: call.signal
152
+ });
153
+ } catch (e) {
154
+ throw new IamError(e instanceof Error ? e.message : "IAM unreachable", 0, false);
155
+ }
156
+ const body = await res.json().catch(() => ({}));
157
+ const msg = typeof body.msg === "string" ? body.msg : "";
158
+ if (!res.ok || body.status === "error") {
159
+ throw new IamError(msg || `IAM ${verb} failed (${res.status})`, res.status, isSignedOut(res.status, msg));
160
+ }
161
+ return body.data;
162
+ }
163
+ var IAM_PAGE_SIZE = 20;
164
+ var iam = {
165
+ /** The signed-in principal, or null when there is no session. */
166
+ async account(call) {
167
+ try {
168
+ const data = await read(call, "get-account", {});
169
+ return data && data.name ? data : null;
170
+ } catch (e) {
171
+ if (e instanceof IamError && e.unauthenticated) return null;
172
+ throw e;
173
+ }
174
+ },
175
+ /**
176
+ * One page of the orgs the principal can see. IAM scopes the read to the
177
+ * caller's authority, so a normal member gets their own org and a super
178
+ * admin gets the tenant list — the page never has to decide.
179
+ */
180
+ async organizations(call, page = 0, query = "", pageSize = IAM_PAGE_SIZE) {
181
+ const params = {
182
+ owner: "admin",
183
+ // IAM orgs live under the reserved `admin` owner
184
+ p: page + 1,
185
+ // the backend page is 1-based
186
+ pageSize,
187
+ sortField: "name",
188
+ sortOrder: "ascending"
189
+ };
190
+ const q = query.trim();
191
+ if (q) {
192
+ params.field = "name";
193
+ params.value = q;
194
+ }
195
+ return await read(call, "get-organizations", params) ?? [];
196
+ },
197
+ /** One organization by name. */
198
+ async organization(call, name) {
199
+ return await read(call, "get-organization", { id: `admin/${name}` }) ?? null;
200
+ },
201
+ /** Members of an organization. */
202
+ async users(call, org) {
203
+ return await read(call, "get-users", { owner: org }) ?? [];
204
+ },
205
+ /** The organization's projects — IAM keys this read by `organization`. */
206
+ async projects(call, org) {
207
+ return await read(call, "get-organization-projects", { organization: org }) ?? [];
208
+ }
209
+ };
210
+
211
+ export { IAM_PAGE_SIZE, IamError, iam, iamBase };
package/dist/icons.cjs ADDED
@@ -0,0 +1,13 @@
1
+ "use client";
2
+ 'use strict';
3
+
4
+ var lucideReact = require('lucide-react');
5
+
6
+
7
+
8
+ Object.keys(lucideReact).forEach(function (k) {
9
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
10
+ enumerable: true,
11
+ get: function () { return lucideReact[k]; }
12
+ });
13
+ });
@@ -0,0 +1 @@
1
+ export * from 'lucide-react';
@@ -0,0 +1 @@
1
+ export * from 'lucide-react';
package/dist/icons.js ADDED
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ export * from 'lucide-react';