@arcblock/did-connect-service 4.0.5 → 4.0.7
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/assets/fonts/noto-sans-sc-regular.otf +0 -0
- package/dist/_generated/asset-bytes.d.ts +3 -0
- package/dist/_generated/asset-bytes.d.ts.map +1 -0
- package/dist/_generated/asset-bytes.js +2 -0
- package/dist/_generated/asset-bytes.js.map +1 -0
- package/dist/_generated/asset-manifest.d.ts +3 -0
- package/dist/_generated/asset-manifest.d.ts.map +1 -0
- package/dist/_generated/asset-manifest.js +12 -0
- package/dist/_generated/asset-manifest.js.map +1 -0
- package/dist/asset-registry.d.ts +38 -0
- package/dist/asset-registry.d.ts.map +1 -0
- package/dist/asset-registry.js +73 -0
- package/dist/asset-registry.js.map +1 -0
- package/dist/assets/admin-core.c0b5af61.js +1393 -0
- package/dist/assets/admin-extra.7ca9c16b.js +2529 -0
- package/dist/assets/admin.c26bb17a.css +2219 -0
- package/dist/assets/design.99dc4ddc.css +97 -0
- package/dist/assets/did-address.7df30f28.js +51 -0
- package/dist/assets/header.94d9e46b.js +136 -0
- package/dist/assets/login.7b12c6dc.css +662 -0
- package/dist/assets/login.d3f05790.js +720 -0
- package/dist/assets/qr.c0d203ca.js +3 -0
- package/dist/embedded.d.ts +32 -0
- package/dist/embedded.d.ts.map +1 -1
- package/dist/embedded.js +3 -0
- package/dist/embedded.js.map +1 -1
- package/dist/handlers/auth-handler.d.ts +5 -0
- package/dist/handlers/auth-handler.d.ts.map +1 -1
- package/dist/handlers/auth-handler.js +11 -32
- package/dist/handlers/auth-handler.js.map +1 -1
- package/dist/handlers/branding-handler.d.ts +17 -0
- package/dist/handlers/branding-handler.d.ts.map +1 -1
- package/dist/handlers/branding-handler.js +107 -5
- package/dist/handlers/branding-handler.js.map +1 -1
- package/dist/identity/gravatar.d.ts +0 -2
- package/dist/identity/gravatar.d.ts.map +1 -1
- package/dist/identity/gravatar.js +0 -9
- package/dist/identity/gravatar.js.map +1 -1
- package/dist/og/emoji.d.ts +12 -0
- package/dist/og/emoji.d.ts.map +1 -0
- package/dist/og/emoji.js +71 -0
- package/dist/og/emoji.js.map +1 -0
- package/dist/og/generator.d.ts +3 -0
- package/dist/og/generator.d.ts.map +1 -0
- package/dist/og/generator.js +338 -0
- package/dist/og/generator.js.map +1 -0
- package/dist/og/index.d.ts +6 -0
- package/dist/og/index.d.ts.map +1 -0
- package/dist/og/index.js +4 -0
- package/dist/og/index.js.map +1 -0
- package/dist/og/passport-svg.d.ts +52 -0
- package/dist/og/passport-svg.d.ts.map +1 -0
- package/dist/og/passport-svg.js +157 -0
- package/dist/og/passport-svg.js.map +1 -0
- package/dist/og/ssrf-guard.d.ts +38 -0
- package/dist/og/ssrf-guard.d.ts.map +1 -0
- package/dist/og/ssrf-guard.js +188 -0
- package/dist/og/ssrf-guard.js.map +1 -0
- package/dist/og/templates.d.ts +26 -0
- package/dist/og/templates.d.ts.map +1 -0
- package/dist/og/templates.js +302 -0
- package/dist/og/templates.js.map +1 -0
- package/dist/og/types.d.ts +74 -0
- package/dist/og/types.d.ts.map +1 -0
- package/dist/og/types.js +14 -0
- package/dist/og/types.js.map +1 -0
- package/dist/pages/admin/index.d.ts.map +1 -1
- package/dist/pages/admin/index.js +25 -41
- package/dist/pages/admin/index.js.map +1 -1
- package/dist/pages/admin/tab-access.d.ts +1 -1
- package/dist/pages/admin/tab-access.d.ts.map +1 -1
- package/dist/pages/admin/tab-access.js +5 -2
- package/dist/pages/admin/tab-access.js.map +1 -1
- package/dist/pages/admin/tab-appearance.d.ts +1 -1
- package/dist/pages/admin/tab-appearance.d.ts.map +1 -1
- package/dist/pages/admin/tab-appearance.js +4 -2
- package/dist/pages/admin/tab-appearance.js.map +1 -1
- package/dist/pages/admin/tab-branding.d.ts.map +1 -1
- package/dist/pages/admin/tab-branding.js +4 -2
- package/dist/pages/admin/tab-branding.js.map +1 -1
- package/dist/pages/admin/tab-profile-accounts.d.ts.map +1 -1
- package/dist/pages/admin/tab-profile-accounts.js +4 -2
- package/dist/pages/admin/tab-profile-accounts.js.map +1 -1
- package/dist/pages/admin/tab-settings.d.ts.map +1 -1
- package/dist/pages/admin/tab-settings.js +4 -2
- package/dist/pages/admin/tab-settings.js.map +1 -1
- package/dist/pages/admin-instances-page.d.ts.map +1 -1
- package/dist/pages/admin-instances-page.js +4 -6
- package/dist/pages/admin-instances-page.js.map +1 -1
- package/dist/pages/error-page.d.ts.map +1 -1
- package/dist/pages/error-page.js +3 -2
- package/dist/pages/error-page.js.map +1 -1
- package/dist/pages/gen-access-key-page.d.ts.map +1 -1
- package/dist/pages/gen-access-key-page.js +3 -4
- package/dist/pages/gen-access-key-page.js.map +1 -1
- package/dist/pages/homepage.d.ts.map +1 -1
- package/dist/pages/homepage.js +4 -3
- package/dist/pages/homepage.js.map +1 -1
- package/dist/pages/invite-page.d.ts.map +1 -1
- package/dist/pages/invite-page.js +4 -4
- package/dist/pages/invite-page.js.map +1 -1
- package/dist/pages/login-page.d.ts.map +1 -1
- package/dist/pages/login-page.js +3 -4
- package/dist/pages/login-page.js.map +1 -1
- package/package.json +21 -5
- package/dist/access-key-handler.d.ts +0 -37
- package/dist/access-key-handler.d.ts.map +0 -1
- package/dist/access-key-handler.js +0 -316
- package/dist/access-key-handler.js.map +0 -1
- package/dist/access-key-util.d.ts +0 -19
- package/dist/access-key-util.d.ts.map +0 -1
- package/dist/access-key-util.js +0 -45
- package/dist/access-key-util.js.map +0 -1
- package/dist/access-policy.d.ts +0 -53
- package/dist/access-policy.d.ts.map +0 -1
- package/dist/access-policy.js +0 -153
- package/dist/access-policy.js.map +0 -1
- package/dist/auth-client.d.ts +0 -20
- package/dist/auth-client.d.ts.map +0 -1
- package/dist/auth-client.js +0 -42
- package/dist/auth-client.js.map +0 -1
- package/dist/auth-entrypoint.d.ts +0 -45
- package/dist/auth-entrypoint.d.ts.map +0 -1
- package/dist/auth-entrypoint.js +0 -31
- package/dist/auth-entrypoint.js.map +0 -1
- package/dist/auth-handler.d.ts +0 -136
- package/dist/auth-handler.d.ts.map +0 -1
- package/dist/auth-handler.js +0 -408
- package/dist/auth-handler.js.map +0 -1
- package/dist/auth-rpc-types.d.ts +0 -139
- package/dist/auth-rpc-types.d.ts.map +0 -1
- package/dist/auth-rpc-types.js +0 -11
- package/dist/auth-rpc-types.js.map +0 -1
- package/dist/auth-rpc.d.ts +0 -80
- package/dist/auth-rpc.d.ts.map +0 -1
- package/dist/auth-rpc.js +0 -257
- package/dist/auth-rpc.js.map +0 -1
- package/dist/auth-worker.d.ts +0 -42
- package/dist/auth-worker.d.ts.map +0 -1
- package/dist/auth-worker.js +0 -120
- package/dist/auth-worker.js.map +0 -1
- package/dist/blocklet-js-handler.d.ts +0 -22
- package/dist/blocklet-js-handler.d.ts.map +0 -1
- package/dist/blocklet-js-handler.js +0 -205
- package/dist/blocklet-js-handler.js.map +0 -1
- package/dist/branding-handler.d.ts +0 -42
- package/dist/branding-handler.d.ts.map +0 -1
- package/dist/branding-handler.js +0 -326
- package/dist/branding-handler.js.map +0 -1
- package/dist/d1-token-storage.d.ts +0 -31
- package/dist/d1-token-storage.d.ts.map +0 -1
- package/dist/d1-token-storage.js +0 -83
- package/dist/d1-token-storage.js.map +0 -1
- package/dist/did-connect-handler.d.ts +0 -57
- package/dist/did-connect-handler.d.ts.map +0 -1
- package/dist/did-connect-handler.js +0 -182
- package/dist/did-connect-handler.js.map +0 -1
- package/dist/did.d.ts +0 -14
- package/dist/did.d.ts.map +0 -1
- package/dist/did.js +0 -17
- package/dist/did.js.map +0 -1
- package/dist/email-login-handler.d.ts +0 -50
- package/dist/email-login-handler.d.ts.map +0 -1
- package/dist/email-login-handler.js +0 -238
- package/dist/email-login-handler.js.map +0 -1
- package/dist/federation-utils.d.ts +0 -23
- package/dist/federation-utils.d.ts.map +0 -1
- package/dist/federation-utils.js +0 -25
- package/dist/federation-utils.js.map +0 -1
- package/dist/handler.d.ts +0 -90
- package/dist/handler.d.ts.map +0 -1
- package/dist/handler.js +0 -591
- package/dist/handler.js.map +0 -1
- package/dist/identity/csrf.d.ts +0 -17
- package/dist/identity/csrf.d.ts.map +0 -1
- package/dist/identity/csrf.js +0 -56
- package/dist/identity/csrf.js.map +0 -1
- package/dist/identity/invitation-util.d.ts +0 -7
- package/dist/identity/invitation-util.d.ts.map +0 -1
- package/dist/identity/invitation-util.js +0 -66
- package/dist/identity/invitation-util.js.map +0 -1
- package/dist/instance-role.d.ts +0 -10
- package/dist/instance-role.d.ts.map +0 -1
- package/dist/instance-role.js +0 -20
- package/dist/instance-role.js.map +0 -1
- package/dist/jwt.d.ts +0 -7
- package/dist/jwt.d.ts.map +0 -1
- package/dist/jwt.js +0 -72
- package/dist/jwt.js.map +0 -1
- package/dist/login-entry.d.ts +0 -9
- package/dist/login-entry.d.ts.map +0 -1
- package/dist/login-entry.js +0 -9
- package/dist/login-entry.js.map +0 -1
- package/dist/membership-handler.d.ts +0 -27
- package/dist/membership-handler.d.ts.map +0 -1
- package/dist/membership-handler.js +0 -111
- package/dist/membership-handler.js.map +0 -1
- package/dist/oauth-callback-page.d.ts +0 -9
- package/dist/oauth-callback-page.d.ts.map +0 -1
- package/dist/oauth-callback-page.js +0 -31
- package/dist/oauth-callback-page.js.map +0 -1
- package/dist/oauth-handler.d.ts +0 -72
- package/dist/oauth-handler.d.ts.map +0 -1
- package/dist/oauth-handler.js +0 -423
- package/dist/oauth-handler.js.map +0 -1
- package/dist/page.d.ts +0 -33
- package/dist/page.d.ts.map +0 -1
- package/dist/page.js +0 -59
- package/dist/page.js.map +0 -1
- package/dist/pages/auth-script.d.ts +0 -18
- package/dist/pages/auth-script.d.ts.map +0 -1
- package/dist/pages/auth-script.js +0 -185
- package/dist/pages/auth-script.js.map +0 -1
- package/dist/pages/design-tokens.d.ts +0 -86
- package/dist/pages/design-tokens.d.ts.map +0 -1
- package/dist/pages/design-tokens.js +0 -159
- package/dist/pages/design-tokens.js.map +0 -1
- package/dist/pages/did-connect-script.d.ts +0 -16
- package/dist/pages/did-connect-script.d.ts.map +0 -1
- package/dist/pages/did-connect-script.js +0 -105
- package/dist/pages/did-connect-script.js.map +0 -1
- package/dist/pages/shared-styles.d.ts +0 -6
- package/dist/pages/shared-styles.d.ts.map +0 -1
- package/dist/pages/shared-styles.js +0 -109
- package/dist/pages/shared-styles.js.map +0 -1
- package/dist/rbac.d.ts +0 -19
- package/dist/rbac.d.ts.map +0 -1
- package/dist/rbac.js +0 -76
- package/dist/rbac.js.map +0 -1
- package/dist/session-context.d.ts +0 -35
- package/dist/session-context.d.ts.map +0 -1
- package/dist/session-context.js +0 -39
- package/dist/session-context.js.map +0 -1
- package/dist/store.d.ts +0 -222
- package/dist/store.d.ts.map +0 -1
- package/dist/store.js +0 -1366
- package/dist/store.js.map +0 -1
- package/dist/team-handler.d.ts +0 -90
- package/dist/team-handler.d.ts.map +0 -1
- package/dist/team-handler.js +0 -1225
- package/dist/team-handler.js.map +0 -1
- package/dist/ticket-handler.d.ts +0 -28
- package/dist/ticket-handler.d.ts.map +0 -1
- package/dist/ticket-handler.js +0 -74
- package/dist/ticket-handler.js.map +0 -1
- package/dist/wallet-identity.d.ts +0 -32
- package/dist/wallet-identity.d.ts.map +0 -1
- package/dist/wallet-identity.js +0 -43
- package/dist/wallet-identity.js.map +0 -1
- package/dist/webauthn.d.ts +0 -65
- package/dist/webauthn.d.ts.map +0 -1
- package/dist/webauthn.js +0 -112
- package/dist/webauthn.js.map +0 -1
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
import { html } from "satori-html";
|
|
2
|
+
import { __unsafeHTML } from "ultrahtml";
|
|
3
|
+
import { getTextColor } from "./passport-svg.js";
|
|
4
|
+
// Join the raw strings and values to reconstruct the original string
|
|
5
|
+
const join = (strings, ...values) => {
|
|
6
|
+
const original = strings.raw.reduce((result, str, i) => {
|
|
7
|
+
return result + str + (values[i] !== undefined ? values[i] : "");
|
|
8
|
+
}, "");
|
|
9
|
+
return original;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Public brand-logo SVG helper. Returns an inline SVG string with the given
|
|
13
|
+
* stroke color. Not used by any of the 4 OG templates in this file — it's
|
|
14
|
+
* exported for external callers (e.g., admin UI, embed previews) that want
|
|
15
|
+
* the same brand mark with a custom stroke.
|
|
16
|
+
*/
|
|
17
|
+
export const getLogoSvg = (color) => {
|
|
18
|
+
return `<svg
|
|
19
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
20
|
+
style="position: absolute; right: 24px; bottom: 24px; opacity: 0.1"
|
|
21
|
+
width="360"
|
|
22
|
+
height="416"
|
|
23
|
+
viewBox="0 0 45 52"
|
|
24
|
+
>
|
|
25
|
+
<g fill="none" fill-rule="evenodd" stroke="${color}">
|
|
26
|
+
<path
|
|
27
|
+
d="M.5 13.077L22.15.577l21.651 12.5v25l-21.65 12.5L.5 38.077zM22.15.577v50M.5 13.077l43.301 25m-43.301 0l43.301-25"
|
|
28
|
+
></path>
|
|
29
|
+
<path d="M22.15 38.077l10.826-6.25-10.825-18.75-10.825 18.75z"></path>
|
|
30
|
+
</g>
|
|
31
|
+
</svg>`;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Background CSS for image-backed templates. When the blocklet has an
|
|
35
|
+
* uploaded og-image its URL is used as a cover image (legacy blocklet-server
|
|
36
|
+
* behavior); when `background` is empty we fall back to a brand-color
|
|
37
|
+
* gradient so blocklets without uploaded art still get a clean, on-brand
|
|
38
|
+
* card instead of a stretched default letter-SVG.
|
|
39
|
+
*/
|
|
40
|
+
const backgroundStyle = (background, color) => background
|
|
41
|
+
? `background-image: url(${background});
|
|
42
|
+
background-size: cover;
|
|
43
|
+
background-position: center;`
|
|
44
|
+
: `background: linear-gradient(160deg, ${color.start} 0%, ${color.end} 100%);`;
|
|
45
|
+
/**
|
|
46
|
+
* Foreground text color. Legacy image backgrounds were always dark, so the
|
|
47
|
+
* original hardcoded #EEE. On the gradient fallback the brand color can be
|
|
48
|
+
* light (e.g. DID-derived yellow), so pick a contrasting color instead.
|
|
49
|
+
*/
|
|
50
|
+
const foregroundColor = (background, color) => background ? "#EEE" : getTextColor(color.start);
|
|
51
|
+
/**
|
|
52
|
+
* Decorative layer for the gradient fallback: two soft radial glows plus the
|
|
53
|
+
* ArcBlock wireframe brand mark anchored bottom-right (the same mark
|
|
54
|
+
* `getLogoSvg` exposes, embedded as a data URI because satori rasterizes
|
|
55
|
+
* `<img>` sources more reliably than inline `<svg>` children). Empty string
|
|
56
|
+
* in legacy image mode — uploaded backgrounds stay untouched.
|
|
57
|
+
*
|
|
58
|
+
* Paint order matters: callers must place this BEFORE the text content so
|
|
59
|
+
* the glows render underneath.
|
|
60
|
+
*/
|
|
61
|
+
const gradientDecor = (background, color) => {
|
|
62
|
+
if (background)
|
|
63
|
+
return "";
|
|
64
|
+
const stroke = foregroundColor(background, color);
|
|
65
|
+
const mark = `<svg xmlns="http://www.w3.org/2000/svg" width="360" height="416" viewBox="0 0 45 52"><g fill="none" fill-rule="evenodd" stroke="${stroke}" stroke-width="0.6"><path d="M.5 13.077L22.15.577l21.651 12.5v25l-21.65 12.5L.5 38.077zM22.15.577v50M.5 13.077l43.301 25m-43.301 0l43.301-25"></path><path d="M22.15 38.077l10.826-6.25-10.825-18.75-10.825 18.75z"></path></g></svg>`;
|
|
66
|
+
const markUri = `data:image/svg+xml;base64,${Buffer.from(mark).toString("base64")}`;
|
|
67
|
+
// __unsafeHTML: satori-html's tagged template escapes interpolated strings
|
|
68
|
+
// (anti-injection); this wrapper marks the decor markup as trusted. The
|
|
69
|
+
// markup is fully static except for `stroke`/`markUri`, both derived from
|
|
70
|
+
// internal color math — no user input reaches it.
|
|
71
|
+
return __unsafeHTML(`<div style="position: absolute; top: -320px; right: -180px; width: 820px; height: 820px; border-radius: 50%; background: radial-gradient(circle, rgba(255,255,255,0.14) 0%, rgba(255,255,255,0) 68%); display: flex;"></div>
|
|
72
|
+
<div style="position: absolute; bottom: -280px; left: -160px; width: 640px; height: 640px; border-radius: 50%; background: radial-gradient(circle, rgba(0,0,0,0.10) 0%, rgba(0,0,0,0) 68%); display: flex;"></div>
|
|
73
|
+
<img src="${markUri}" style="position: absolute; right: -36px; bottom: -64px; width: 360px; height: 416px; opacity: 0.14" />`);
|
|
74
|
+
};
|
|
75
|
+
const getDefaultTemplate = ({ width, height, logo, background, logoRounded, color, title, description, }, fn) => {
|
|
76
|
+
const fg = foregroundColor(background, color);
|
|
77
|
+
return fn `<div
|
|
78
|
+
style="
|
|
79
|
+
width: ${width}px;
|
|
80
|
+
height: ${height}px;
|
|
81
|
+
${backgroundStyle(background, color)}
|
|
82
|
+
display: flex;
|
|
83
|
+
flex-direction: column;
|
|
84
|
+
justify-content: center;
|
|
85
|
+
align-items: flex-start;
|
|
86
|
+
position: relative;
|
|
87
|
+
overflow: hidden;
|
|
88
|
+
"
|
|
89
|
+
>
|
|
90
|
+
${gradientDecor(background, color)}
|
|
91
|
+
<img
|
|
92
|
+
src="${logo}"
|
|
93
|
+
height="90"
|
|
94
|
+
width="90"
|
|
95
|
+
style="margin-left: 96px; height: 90px; width: 90px;${logoRounded ? "border-radius: 50%;" : ""} margin-bottom: 64px"
|
|
96
|
+
/>
|
|
97
|
+
<h2
|
|
98
|
+
style="
|
|
99
|
+
font-size: 48px;
|
|
100
|
+
letter-spacing: -2px;
|
|
101
|
+
margin: 0 0 32px;
|
|
102
|
+
color: ${fg};
|
|
103
|
+
font-weight: 500;
|
|
104
|
+
font-family: Arial, sans-serif;
|
|
105
|
+
text-align: left;
|
|
106
|
+
padding: 0 96px;
|
|
107
|
+
"
|
|
108
|
+
>
|
|
109
|
+
${title}
|
|
110
|
+
</h2>
|
|
111
|
+
<h3
|
|
112
|
+
style="
|
|
113
|
+
font-size: 2rem;
|
|
114
|
+
margin: 0;
|
|
115
|
+
color: ${fg};
|
|
116
|
+
opacity: 0.7;
|
|
117
|
+
font-weight: 400;
|
|
118
|
+
font-family: Arial, sans-serif;
|
|
119
|
+
text-align: left;
|
|
120
|
+
padding: 0 96px;
|
|
121
|
+
line-clamp: 3;
|
|
122
|
+
"
|
|
123
|
+
>
|
|
124
|
+
${description}
|
|
125
|
+
</h3>
|
|
126
|
+
</div>`;
|
|
127
|
+
};
|
|
128
|
+
const getSectionTemplate = ({ width, height, logo, logoRounded, background, color, title, description, section, }, fn) => {
|
|
129
|
+
const fg = foregroundColor(background, color);
|
|
130
|
+
// Section label: with an image background the brand color is the accent;
|
|
131
|
+
// on the gradient fallback the brand color IS the background, so the
|
|
132
|
+
// label must use the contrasting foreground instead.
|
|
133
|
+
const labelColor = background ? color.start : fg;
|
|
134
|
+
return fn `<div
|
|
135
|
+
style="
|
|
136
|
+
width: ${width}px;
|
|
137
|
+
height: ${height}px;
|
|
138
|
+
${backgroundStyle(background, color)}
|
|
139
|
+
display: flex;
|
|
140
|
+
flex-direction: column;
|
|
141
|
+
justify-content: center;
|
|
142
|
+
align-items: flex-start;
|
|
143
|
+
position: relative;
|
|
144
|
+
overflow: hidden;
|
|
145
|
+
"
|
|
146
|
+
>
|
|
147
|
+
${gradientDecor(background, color)}
|
|
148
|
+
<img
|
|
149
|
+
src="${logo}"
|
|
150
|
+
height="90"
|
|
151
|
+
width="90"
|
|
152
|
+
style="margin-left: 96px; height: 90px; width: 90px; ${logoRounded ? "border-radius: 50%;" : ""} margin-bottom: 64px"
|
|
153
|
+
/>
|
|
154
|
+
<p
|
|
155
|
+
style="
|
|
156
|
+
font-size: 1.5rem;
|
|
157
|
+
margin: 0;
|
|
158
|
+
color: ${labelColor};
|
|
159
|
+
font-weight: 400;
|
|
160
|
+
font-family: Arial, sans-serif;
|
|
161
|
+
text-align: left;
|
|
162
|
+
text-transform: uppercase;
|
|
163
|
+
padding: 0 96px;
|
|
164
|
+
"
|
|
165
|
+
>
|
|
166
|
+
${section}
|
|
167
|
+
</p>
|
|
168
|
+
<h2
|
|
169
|
+
style="
|
|
170
|
+
font-size: 48px;
|
|
171
|
+
margin: 0 0 32px;
|
|
172
|
+
color: ${fg};
|
|
173
|
+
letter-spacing: -2px;
|
|
174
|
+
font-weight: 500;
|
|
175
|
+
font-family: Arial, sans-serif;
|
|
176
|
+
text-align: left;
|
|
177
|
+
padding: 0 96px;
|
|
178
|
+
line-clamp: 2;
|
|
179
|
+
"
|
|
180
|
+
>
|
|
181
|
+
${title}
|
|
182
|
+
</h2>
|
|
183
|
+
<h3
|
|
184
|
+
style="
|
|
185
|
+
font-size: 2rem;
|
|
186
|
+
margin: 0;
|
|
187
|
+
color: ${fg};
|
|
188
|
+
opacity: 0.7;
|
|
189
|
+
font-weight: 400;
|
|
190
|
+
font-family: Arial, sans-serif;
|
|
191
|
+
text-align: left;
|
|
192
|
+
padding: 0 96px;
|
|
193
|
+
line-clamp: 3;
|
|
194
|
+
"
|
|
195
|
+
>
|
|
196
|
+
${description}
|
|
197
|
+
</h3>
|
|
198
|
+
</div>`;
|
|
199
|
+
};
|
|
200
|
+
const getCoverTemplate = ({ width, height, logo, logoRounded, color, title, description, cover, }, fn) => {
|
|
201
|
+
const textColor = getTextColor(color.start);
|
|
202
|
+
// TODO: cover template hardcodes 630px panel height (carried from source); replace with ${height} when we generalize.
|
|
203
|
+
return fn `<div style="width: ${width}px; height: ${height}px; display: flex; background: ${color.start};">
|
|
204
|
+
<div style="display: flex; height: ${height}px; background: ${color.start}; width: 45%">
|
|
205
|
+
<div style="margin-left: 32px; display: flex; flex-direction: column; align-items: flex-start; justify-content: space-around;">
|
|
206
|
+
<h2
|
|
207
|
+
style="
|
|
208
|
+
font-size: 3rem;
|
|
209
|
+
color: ${textColor};
|
|
210
|
+
font-weight: 400;
|
|
211
|
+
font-family: Arial, sans-serif;
|
|
212
|
+
margin: 32px 32px 0 0;
|
|
213
|
+
text-align: left;
|
|
214
|
+
"
|
|
215
|
+
>
|
|
216
|
+
${description}
|
|
217
|
+
</h2>
|
|
218
|
+
<div style="display: flex; justify-content: flex-start; align-items: center">
|
|
219
|
+
<img src="${logo}" height="60" width="60" style="height: 60px; width: 60px; ${logoRounded ? "border-radius: 50%;" : ""}" />
|
|
220
|
+
<h3
|
|
221
|
+
style="
|
|
222
|
+
font-size: 2rem;
|
|
223
|
+
margin: 0 0 0 16px;
|
|
224
|
+
color: ${textColor};
|
|
225
|
+
font-weight: 400;
|
|
226
|
+
font-family: Arial, sans-serif;
|
|
227
|
+
text-align: left;
|
|
228
|
+
text-transform: capitalize;
|
|
229
|
+
"
|
|
230
|
+
>
|
|
231
|
+
${title}
|
|
232
|
+
</h3>
|
|
233
|
+
</div>
|
|
234
|
+
</div>
|
|
235
|
+
</div>
|
|
236
|
+
<div style="display: flex; height: 630px; width: 55%; background-color: ${color.start}">
|
|
237
|
+
<img src="${cover}" height="630" width="100%" style="height: 630px; width: 100%; object-fit: cover" />
|
|
238
|
+
<div style="
|
|
239
|
+
display: flex;
|
|
240
|
+
background: ${color.start};
|
|
241
|
+
height: ${height * 2}px;
|
|
242
|
+
width: 100px;
|
|
243
|
+
position: absolute;
|
|
244
|
+
transform: rotate(8deg);
|
|
245
|
+
left: -90px;
|
|
246
|
+
top: -25px;"></div>
|
|
247
|
+
</div>
|
|
248
|
+
</div>`;
|
|
249
|
+
};
|
|
250
|
+
const getBannerTemplate = ({ width, height, logo, logoRounded, background, color, title, }, fn) => {
|
|
251
|
+
const fg = foregroundColor(background, color);
|
|
252
|
+
return fn `<div
|
|
253
|
+
style="
|
|
254
|
+
width: ${width}px;
|
|
255
|
+
height: ${height}px;
|
|
256
|
+
${backgroundStyle(background, color)}
|
|
257
|
+
display: flex;
|
|
258
|
+
flex-direction: row;
|
|
259
|
+
justify-content: center;
|
|
260
|
+
align-items: center;
|
|
261
|
+
position: relative;
|
|
262
|
+
overflow: hidden;
|
|
263
|
+
"
|
|
264
|
+
>
|
|
265
|
+
${gradientDecor(background, color)}
|
|
266
|
+
<img
|
|
267
|
+
src="${logo}"
|
|
268
|
+
height="150"
|
|
269
|
+
width="150"
|
|
270
|
+
style="height: 150px; width: 150px; ${logoRounded ? "border-radius: 50%;" : ""} margin-right: 48px"
|
|
271
|
+
/>
|
|
272
|
+
<h2
|
|
273
|
+
style="
|
|
274
|
+
font-size: 72px;
|
|
275
|
+
color: ${fg};
|
|
276
|
+
font-weight: 500;
|
|
277
|
+
font-family: Arial, sans-serif;
|
|
278
|
+
text-align: left;
|
|
279
|
+
line-clamp: 1;
|
|
280
|
+
"
|
|
281
|
+
>
|
|
282
|
+
${title}
|
|
283
|
+
</h2>
|
|
284
|
+
</div>`;
|
|
285
|
+
};
|
|
286
|
+
export const getTemplate = async (params) => {
|
|
287
|
+
const fn = params.format === "html" ? join : html;
|
|
288
|
+
if (params.template === "default") {
|
|
289
|
+
return getDefaultTemplate(params, fn);
|
|
290
|
+
}
|
|
291
|
+
if (params.template === "section") {
|
|
292
|
+
return getSectionTemplate(params, fn);
|
|
293
|
+
}
|
|
294
|
+
if (params.template === "cover") {
|
|
295
|
+
return getCoverTemplate(params, fn);
|
|
296
|
+
}
|
|
297
|
+
if (params.template === "banner") {
|
|
298
|
+
return getBannerTemplate(params, fn);
|
|
299
|
+
}
|
|
300
|
+
throw new Error("Invalid open graph template");
|
|
301
|
+
};
|
|
302
|
+
//# sourceMappingURL=templates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../../src/og/templates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAoBjD,qEAAqE;AACrE,MAAM,IAAI,GAAG,CAAC,OAA6B,EAAE,GAAG,MAAiB,EAAU,EAAE;IAC3E,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE;QACrD,OAAO,MAAM,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,SAAS,C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AE,GAAqB,MAAM,CAAC,MAAM,KAAK,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;IAEpE,IAAI,MAAM,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;QAClC,OAAO,kBAAkB,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IACxC,CAAC;IACD,IAAI,MAAM,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;QAClC,OAAO,kBAAkB,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IACxC,CAAC;IACD,IAAI,MAAM,CAAC,QAAQ,KAAK,OAAO,EAAE,CAAC;QAChC,OAAO,gBAAgB,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IACtC,CAAC;IACD,IAAI,MAAM,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;QACjC,OAAO,iBAAiB,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IACvC,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;AACjD,CAAC,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { EmojiType } from "./emoji.js";
|
|
2
|
+
import type { OgFormat, OgTemplate } from "./templates.js";
|
|
3
|
+
export type { OgFormat, OgTemplate } from "./templates.js";
|
|
4
|
+
export interface OgInfoContext {
|
|
5
|
+
/** Display name of the blocklet/app. Used as title fallback. */
|
|
6
|
+
name: string;
|
|
7
|
+
/** Display description. Used as description fallback. */
|
|
8
|
+
description: string;
|
|
9
|
+
/** DID of the blocklet instance. Used to derive brand color when passportColor='auto'. */
|
|
10
|
+
did: string;
|
|
11
|
+
/** Public origin where the blocklet serves logos/og-images (used to build absolute URLs). */
|
|
12
|
+
appUrl: string;
|
|
13
|
+
/** Brand color preference: 'default' | 'auto' | hex string (e.g., '#3882C7'). */
|
|
14
|
+
passportColor?: string;
|
|
15
|
+
/** Hash suffix appended to default logo URL for cache busting. */
|
|
16
|
+
logoHash?: string;
|
|
17
|
+
/** Hash suffix appended to default og-image URL for cache busting. */
|
|
18
|
+
ogImageHash?: string;
|
|
19
|
+
}
|
|
20
|
+
export interface OgGenerateInput {
|
|
21
|
+
template?: OgTemplate;
|
|
22
|
+
title?: string;
|
|
23
|
+
description?: string;
|
|
24
|
+
section?: string;
|
|
25
|
+
cover?: string;
|
|
26
|
+
logo?: string;
|
|
27
|
+
logoRounded?: "0" | "1";
|
|
28
|
+
emoji?: EmojiType;
|
|
29
|
+
nocache?: "1";
|
|
30
|
+
}
|
|
31
|
+
export interface OgGenerateOptions {
|
|
32
|
+
input: OgGenerateInput;
|
|
33
|
+
info: OgInfoContext;
|
|
34
|
+
format: OgFormat;
|
|
35
|
+
/** Directory for cached final PNG output. */
|
|
36
|
+
cacheDir: string;
|
|
37
|
+
/** Directory for intermediate downloads (external images converted to PNG). */
|
|
38
|
+
tmpDir: string;
|
|
39
|
+
}
|
|
40
|
+
export interface OgGenerator {
|
|
41
|
+
/** Returns the absolute path to the generated/cached file. */
|
|
42
|
+
generate(opts: OgGenerateOptions): Promise<string>;
|
|
43
|
+
}
|
|
44
|
+
export interface CreateOgGeneratorOptions {
|
|
45
|
+
/** Override fetch implementation (used in tests to bypass network). Defaults to global fetch. */
|
|
46
|
+
fetchImpl?: typeof fetch;
|
|
47
|
+
/**
|
|
48
|
+
* Override the DNS resolver used by the SSRF guard before fetching external
|
|
49
|
+
* images (tests inject a public-IP stub to avoid real lookups). Defaults to
|
|
50
|
+
* node:dns lookup. Returns all resolved addresses for a host.
|
|
51
|
+
*/
|
|
52
|
+
lookupImpl?: (host: string) => Promise<Array<{
|
|
53
|
+
address: string;
|
|
54
|
+
}>>;
|
|
55
|
+
/**
|
|
56
|
+
* Remote font URL (OTF/TTF). When set, the font is fetched once, cached on
|
|
57
|
+
* disk, and used for all renders — keeping the 8MB CJK font OUT of the npm
|
|
58
|
+
* package. Falls back to the bundled font when the fetch fails. Defaults to
|
|
59
|
+
* `process.env.OG_FONT_URL`.
|
|
60
|
+
*/
|
|
61
|
+
fontUrl?: string;
|
|
62
|
+
/** Disk cache directory for remote fonts. Defaults to `<os.tmpdir()>/og-fonts`. */
|
|
63
|
+
fontCacheDir?: string;
|
|
64
|
+
}
|
|
65
|
+
export declare const OG_TEMPLATES: readonly OgTemplate[];
|
|
66
|
+
export declare const MAX_TITLE_LENGTH = 128;
|
|
67
|
+
export declare const MAX_DESCRIPTION_LENGTH = 512;
|
|
68
|
+
export declare const MAX_IMAGE_SIZE: number;
|
|
69
|
+
export declare const MAX_IMAGE_DIMENSION = 2400;
|
|
70
|
+
export declare class OgValidationError extends Error {
|
|
71
|
+
statusCode: number;
|
|
72
|
+
constructor(message: string);
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/og/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAG5C,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE3D,YAAY,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE3D,MAAM,WAAW,aAAa;IAC5B,gEAAgE;IAChE,IAAI,EAAE,MAAM,CAAC;IACb,yDAAyD;IACzD,WAAW,EAAE,MAAM,CAAC;IACpB,0FAA0F;IAC1F,GAAG,EAAE,MAAM,CAAC;IACZ,6FAA6F;IAC7F,MAAM,EAAE,MAAM,CAAC;IACf,iFAAiF;IACjF,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,kEAAkE;IAClE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,sEAAsE;IACtE,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,EAAE,UAAU,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW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/dist/og/types.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export const OG_TEMPLATES = ["default", "section", "cover", "banner"];
|
|
2
|
+
// Validation thresholds (match blocklet-server original).
|
|
3
|
+
export const MAX_TITLE_LENGTH = 128;
|
|
4
|
+
export const MAX_DESCRIPTION_LENGTH = 512;
|
|
5
|
+
export const MAX_IMAGE_SIZE = 5 * 1024 * 1024;
|
|
6
|
+
export const MAX_IMAGE_DIMENSION = 2400;
|
|
7
|
+
export class OgValidationError extends Error {
|
|
8
|
+
statusCode = 400;
|
|
9
|
+
constructor(message) {
|
|
10
|
+
super(message);
|
|
11
|
+
this.name = "OgValidationError";
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/og/types.ts"],"names":[],"mappings":"AAuEA,MAAM,CAAC,MAAM,YAAY,GAA0B,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;AAE7F,0DAA0D;AAC1D,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,CAAC;AACpC,MAAM,CAAC,MAAM,sBAAsB,GAAG,GAAG,CAAC;AAC1C,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;AAC9C,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,CAAC;AAExC,MAAM,OAAO,iBAAkB,SAAQ,KAAK;IAC1C,UAAU,GAAG,GAAG,CAAC;IACjB,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;IAClC,CAAC;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/pages/admin/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/pages/admin/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAmBH,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE;QACN,GAAG,EAAE,MAAM,CAAC;QACZ,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,IAAI,EAAE,MAAM,CAAC;QACb,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,CAAC;IACF,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAClD,yCAAyC;IACzC,YAAY,CAAC,EAAE,KAAK,CAAC;QACnB,EAAE,EAAE,MAAM,CAAC;QACX,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAChC,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,GAAG,EAAE,MAAM,CAAC;KACb,CAAC,CAAC;IACH,iFAAiF;IACjF,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAgBD,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,aAAa,GAAG,MAAM,CA0W9D"}
|
|
@@ -4,27 +4,22 @@
|
|
|
4
4
|
* Embeds caller data as <script type="application/json"> for safe injection.
|
|
5
5
|
* Includes header, tab router, all 4 tabs: profile, members, invitations, audit logs.
|
|
6
6
|
*/
|
|
7
|
-
import {
|
|
8
|
-
import DID_ADDRESS_BUNDLE from "../../_generated/did-address-bundle-string.js";
|
|
9
|
-
import QR_BUNDLE from "../../_generated/qr-bundle-string.js";
|
|
7
|
+
import { assetUrl } from "../../asset-registry.js";
|
|
10
8
|
import { adminT, getClientI18nScript } from "./i18n.js";
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import { PROFILE_TAB_SCRIPT, profileTabHtml } from "./tab-profile.js";
|
|
26
|
-
import { CONNECTED_ACCOUNTS_SCRIPT } from "./tab-profile-accounts.js";
|
|
27
|
-
import { SETTINGS_TAB_SCRIPT, settingsTabHtml } from "./tab-settings.js";
|
|
9
|
+
// Client-side scripts (TOAST/UTILS/API/DIALOG/ROUTER + all tab *_SCRIPT consts) are
|
|
10
|
+
// no longer inlined here — they ship as external cacheable bundles (admin-core.js +
|
|
11
|
+
// admin-extra.js, assembled by build-assets.mjs). Only server-side render helpers
|
|
12
|
+
// (*TabHtml, cropDialogHTML) are imported.
|
|
13
|
+
import { cropDialogHTML } from "./scripts/cropper.js";
|
|
14
|
+
import { accessTabHtml } from "./tab-access.js";
|
|
15
|
+
import { accessKeysTabHtml } from "./tab-access-keys.js";
|
|
16
|
+
import { appearanceTabHtml } from "./tab-appearance.js";
|
|
17
|
+
import { auditTabHtml } from "./tab-audit.js";
|
|
18
|
+
import { brandingTabHtml } from "./tab-branding.js";
|
|
19
|
+
import { invitationsTabHtml } from "./tab-invitations.js";
|
|
20
|
+
import { membersTabHtml } from "./tab-members.js";
|
|
21
|
+
import { profileTabHtml } from "./tab-profile.js";
|
|
22
|
+
import { settingsTabHtml } from "./tab-settings.js";
|
|
28
23
|
const ICON_GLOBE = `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none"><path fill="currentColor" d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10s10-4.48 10-10S17.52 2 12 2m-1 17.93c-3.95-.49-7-3.85-7-7.93c0-.62.08-1.21.21-1.79L9 15v1c0 1.1.9 2 2 2zm6.9-2.54c-.26-.81-1-1.39-1.9-1.39h-1v-3c0-.55-.45-1-1-1H8v-2h2c.55 0 1-.45 1-1V7h2c1.1 0 2-.9 2-2v-.41c2.93 1.19 5 4.06 5 7.41c0 2.08-.8 3.97-2.1 5.39"/></svg>`;
|
|
29
24
|
const ICON_MENU = `<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none"><path fill="currentColor" d="M3 18h18v-2H3zm0-5h18v-2H3zm0-7v2h18V6z"/></svg>`;
|
|
30
25
|
const ICON_CLOSE = `<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none"><path fill="currentColor" d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/></svg>`;
|
|
@@ -75,7 +70,9 @@ export function buildAdminPageHTML(data) {
|
|
|
75
70
|
<link rel="icon" href="/.well-known/service/blocklet/logo-favicon" type="image/png" />
|
|
76
71
|
<link rel="stylesheet" href="/.well-known/service/theme/styles.css" />
|
|
77
72
|
<script src="/.well-known/service/theme/init.js"></script>
|
|
78
|
-
<
|
|
73
|
+
<link rel="stylesheet" href="${assetUrl("design.css")}" />
|
|
74
|
+
<link rel="stylesheet" href="${assetUrl("admin.css")}" />
|
|
75
|
+
${isAdmin ? `<style>${MEMBERS_EXTRA_STYLES}</style>` : ""}
|
|
79
76
|
</head>
|
|
80
77
|
<body>
|
|
81
78
|
<script type="application/json" id="team-admin-data">${safeData}</script>
|
|
@@ -188,8 +185,13 @@ export function buildAdminPageHTML(data) {
|
|
|
188
185
|
${isAdmin ? settingsTabHtml(t) : ""}
|
|
189
186
|
</main>
|
|
190
187
|
|
|
191
|
-
<script
|
|
192
|
-
<script
|
|
188
|
+
<script src="${assetUrl("did-address.js")}"></script>
|
|
189
|
+
<script src="${assetUrl("qr.js")}"></script>
|
|
190
|
+
<!-- Core admin client scripts (toast/utils/api/dialog/router + always-on tabs).
|
|
191
|
+
Loaded before the inline glue so its globals (api, registerTab, renderAvatar)
|
|
192
|
+
are defined; the inline init() below calls into them. -->
|
|
193
|
+
<script src="${assetUrl("admin-core.js")}"></script>
|
|
194
|
+
${isAdmin ? `<script src="${assetUrl("admin-extra.js")}"></script>` : ""}
|
|
193
195
|
<script>
|
|
194
196
|
// i18n client-side runtime
|
|
195
197
|
${getClientI18nScript(locale)}
|
|
@@ -199,12 +201,6 @@ var __pageData = JSON.parse(document.getElementById("team-admin-data").textConte
|
|
|
199
201
|
window.__BASE_PATH = __pageData.basePath;
|
|
200
202
|
var __caller = __pageData.caller;
|
|
201
203
|
|
|
202
|
-
${TOAST_SCRIPT}
|
|
203
|
-
${UTILS_SCRIPT}
|
|
204
|
-
${API_CLIENT_SCRIPT}
|
|
205
|
-
${DIALOG_SCRIPT}
|
|
206
|
-
${ROUTER_SCRIPT}
|
|
207
|
-
|
|
208
204
|
function renderPagination(containerId, paging, onPageChange) {
|
|
209
205
|
var c = document.getElementById(containerId);
|
|
210
206
|
if (!c || !paging) return;
|
|
@@ -361,18 +357,6 @@ document.addEventListener('keydown', function(e) {
|
|
|
361
357
|
if (e.key === 'Escape') closeAllOverlays();
|
|
362
358
|
});
|
|
363
359
|
|
|
364
|
-
${PROFILE_TAB_SCRIPT}
|
|
365
|
-
${CONNECTED_ACCOUNTS_SCRIPT}
|
|
366
|
-
${isAdmin ? MEMBERS_TAB_SCRIPT : ""}
|
|
367
|
-
${isAdmin ? INVITATIONS_TAB_SCRIPT : ""}
|
|
368
|
-
${isAdmin ? AUDIT_TAB_SCRIPT : ""}
|
|
369
|
-
${ACCESS_KEYS_TAB_SCRIPT}
|
|
370
|
-
${isOwner ? ACCESS_TAB_SCRIPT : ""}
|
|
371
|
-
${isOwner ? CROPPER_SCRIPT : ""}
|
|
372
|
-
${isOwner ? BRANDING_TAB_SCRIPT : ""}
|
|
373
|
-
${isOwner ? APPEARANCE_TAB_SCRIPT : ""}
|
|
374
|
-
${isAdmin ? SETTINGS_TAB_SCRIPT : ""}
|
|
375
|
-
|
|
376
360
|
function updateHeaderAvatar() {
|
|
377
361
|
var avatarUrl = __caller.avatar || "/.well-known/service/user/avatar/" + __caller.did;
|
|
378
362
|
var inner = renderAvatar(avatarUrl, __caller.fullName, "sm").replace(/^<div[^>]*>/, "").replace(/<\\/div>$/, "");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/pages/admin/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/pages/admin/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AACxD,oFAAoF;AACpF,oFAAoF;AACpF,kFAAkF;AAClF,2CAA2C;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gBAgJrB,UAAU;;;EAGxB,OAAO,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE;;QAE1B,CAAC;AACT,CAAC;AAED,SAAS,aAAa,CAAC,GAAW;IAChC,OAAO,GAAG;SACP,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC;SACtB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;AAC7B,CAAC"}
|
|
@@ -9,6 +9,6 @@
|
|
|
9
9
|
*/
|
|
10
10
|
type TFn = (key: string, params?: Record<string, string>) => string;
|
|
11
11
|
export declare function accessTabHtml(t: TFn): string;
|
|
12
|
-
export declare const ACCESS_TAB_SCRIPT = "\n// \u2500\u2500\u2500 Access Tab State \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nvar apPolicies = [];\nvar apRules = [];\nvar apDefaultRule = null;\nvar apEditingPolicyId = null;\nvar apEditingRuleId = null;\n\n// \u2500\u2500\u2500 Icon constants \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nvar AP_ICON_EDIT = '<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z\"/><path d=\"m15 5 4 4\"/></svg>';\nvar AP_ICON_DELETE = '<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M3 6h18\"/><path d=\"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6\"/><path d=\"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2\"/><line x1=\"10\" x2=\"10\" y1=\"11\" y2=\"17\"/><line x1=\"14\" x2=\"14\" y1=\"11\" y2=\"17\"/></svg>';\nvar AP_ICON_LOCK = '<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><rect width=\"18\" height=\"11\" x=\"3\" y=\"11\" rx=\"2\" ry=\"2\"/><path d=\"M7 11V7a5 5 0 0 1 10 0v4\"/></svg>';\n\n// \u2500\u2500\u2500 Access Type helpers \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nvar AP_TYPE_LABELS = {\n public: __t(\"access.typeLabels.public\"),\n invited: __t(\"access.typeLabels.invited\"),\n owner: __t(\"access.typeLabels.owner\"),\n admin: __t(\"access.typeLabels.admin\"),\n roles: __t(\"access.typeLabels.roles\"),\n roles_reverse: __t(\"access.typeLabels.rolesReverse\")\n};\n\nvar AP_TYPE_DESCS = {\n public: __t(\"access.typeDescs.public\"),\n invited: __t(\"access.typeDescs.invited\"),\n admin: __t(\"access.typeDescs.admin\"),\n owner: __t(\"access.typeDescs.owner\")\n};\n\nfunction apAccessTypeLabel(policy) {\n if (policy.accessType === \"roles\" || policy.accessType === \"roles_reverse\") {\n return AP_TYPE_LABELS[policy.accessType] + \": \" + (policy.roles || []).join(\", \");\n }\n return AP_TYPE_LABELS[policy.accessType] || policy.accessType;\n}\n\nfunction apIsBuiltin(policy) {\n return !!policy.isProtected;\n}\n\nfunction apPolicyAccessType(policyId) {\n var p = apPolicies.find(function(x) { return x.id === policyId; });\n return p ? p.accessType : \"public\";\n}\n\nfunction apIconBtn(icon, title, onclick, variant) {\n var cls = variant === \"danger\" ? \"ap-icon-btn ap-icon-btn-danger\" : \"ap-icon-btn\";\n return '<button class=\"' + cls + '\" title=\"' + escapeHtml(title) + '\" onclick=\"event.stopPropagation();' + onclick + '\">' + icon + '</button>';\n}\n\n// \u2500\u2500\u2500 Load Data \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nasync function apLoadAll() {\n document.getElementById(\"ap-policies-wrap\").innerHTML = skeletonTable(3, 3);\n document.getElementById(\"ap-rules-wrap\").innerHTML = skeletonTable(5, 2);\n\n var pRes = await api(\"GET\", \"/access-policies\");\n if (pRes.ok) apPolicies = pRes.policies;\n\n var rRes = await api(\"GET\", \"/security-rules\");\n if (rRes.ok) apRules = rRes.rules;\n\n // Find the default rule\n apDefaultRule = apRules.find(function(r) { return r.id.indexOf(\"default\") === 0; }) || null;\n\n apRenderPolicies();\n apRenderRules();\n}\n\n// \u2500\u2500\u2500 Render All Policies (built-in + custom in one table) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nfunction apRenderPolicies() {\n var wrap = document.getElementById(\"ap-policies-wrap\");\n\n if (!apPolicies.length) {\n wrap.innerHTML = '<div class=\"empty-state\" style=\"padding:16px\"><div class=\"empty-state-title\">' + __t(\"access.noPolicies\") + '</div></div>';\n return;\n }\n\n // Built-in first, then custom\n var builtins = apPolicies.filter(function(p) { return apIsBuiltin(p); });\n var customs = apPolicies.filter(function(p) { return !apIsBuiltin(p); });\n var sorted = builtins.concat(customs);\n\n var html = '<table class=\"table\"><thead><tr>'\n + '<th>' + __t(\"access.name\") + '</th>'\n + '<th>' + __t(\"access.accessType\") + '</th>'\n + '<th style=\"width:80px;text-align:center\">' + __t(\"common.actions\") + '</th>'\n + '</tr></thead><tbody>';\n\n builtins.forEach(function(p) {\n html += \"<tr>\";\n html += '<td><span class=\"ap-lock-name\">' + AP_ICON_LOCK + ' ' + escapeHtml(p.name) + '</span>';\n if (p.description) html += '<div class=\"text-muted\" style=\"font-size:12px;margin-top:2px\">' + escapeHtml(p.description) + '</div>';\n html += \"</td>\";\n html += \"<td>\" + escapeHtml(apAccessTypeLabel(p)) + \"</td>\";\n html += \"<td></td>\";\n html += \"</tr>\";\n });\n\n if (builtins.length > 0 && customs.length > 0) {\n html += '<tr class=\"ap-separator\"><td colspan=\"3\"></td></tr>';\n }\n\n customs.forEach(function(p) {\n html += \"<tr>\";\n html += \"<td>\" + escapeHtml(p.name);\n if (p.description) html += '<div class=\"text-muted\" style=\"font-size:12px;margin-top:2px\">' + escapeHtml(p.description) + '</div>';\n html += \"</td>\";\n html += \"<td>\" + escapeHtml(apAccessTypeLabel(p)) + \"</td>\";\n html += '<td class=\"ap-actions\">';\n html += apIconBtn(AP_ICON_EDIT, __t(\"common.edit\"), \"openPolicyDialog('edit','\" + escapeHtml(p.id) + \"')\");\n html += apIconBtn(AP_ICON_DELETE, __t(\"common.delete\"), \"apDeletePolicy('\" + escapeHtml(p.id) + \"')\", \"danger\");\n html += \"</td></tr>\";\n });\n\n html += \"</tbody></table>\";\n wrap.innerHTML = html;\n}\n\n// \u2500\u2500\u2500 Render Path Rules \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nfunction apRenderRules() {\n var wrap = document.getElementById(\"ap-rules-wrap\");\n var nonDefaultRules = apRules.filter(function(r) { return r.id.indexOf(\"default\") !== 0; });\n\n // Sort non-default rules by priority ascending\n nonDefaultRules.sort(function(a, b) { return a.priority - b.priority; });\n\n var html = '<table class=\"table\"><thead><tr>'\n + '<th style=\"width:80px\">#</th>'\n + '<th>' + __t(\"access.urlPattern\") + '</th>'\n + '<th>' + __t(\"access.accessPolicy\") + '</th>'\n + '<th style=\"width:80px\">' + __t(\"common.status\") + '</th>'\n + '<th style=\"width:80px;text-align:center\">' + __t(\"common.actions\") + '</th>'\n + '</tr></thead><tbody>';\n\n // Default rule \u2014 first row, special style\n if (apDefaultRule) {\n var policyOptions = apPolicies.map(function(p) {\n var label = escapeHtml(p.name) + ' \\u2014 ' + escapeHtml(apAccessTypeLabel(p));\n var selected = p.id === apDefaultRule.accessPolicyId ? ' selected' : '';\n return '<option value=\"' + escapeHtml(p.id) + '\"' + selected + '>' + label + '</option>';\n }).join(\"\");\n\n html += '<tr style=\"background:var(--bg-elevated)\">';\n html += '<td><span class=\"badge badge-active\">' + __t(\"access.defaultLabel\") + '</span></td>';\n html += '<td><code>*</code></td>';\n html += '<td><select class=\"select select-sm\" onchange=\"apSaveDefaultRulePolicy(this.value)\" style=\"max-width:280px\">' + policyOptions + '</select></td>';\n html += '<td></td>';\n html += '<td></td>';\n html += '</tr>';\n }\n\n // Empty state for non-default rules\n if (nonDefaultRules.length === 0 && apDefaultRule) {\n html += '<tr><td colspan=\"5\" class=\"text-muted\" style=\"text-align:center;padding:16px\">' + __t(\"access.noRules\") + '</td></tr>';\n }\n\n nonDefaultRules.forEach(function(r, i) {\n html += \"<tr>\";\n html += \"<td>#\" + (i + 1) + \"</td>\";\n html += \"<td><code>\" + escapeHtml(r.pathPattern) + \"</code></td>\";\n html += \"<td>\" + escapeHtml(r.accessPolicyName) + \"</td>\";\n html += '<td><label class=\"ap-switch\" title=\"' + (r.enabled ? __t(\"access.clickToDisable\") : __t(\"access.clickToEnable\")) + '\"><input type=\"checkbox\"' + (r.enabled ? ' checked' : '') + ' onchange=\"apToggleRule('' + escapeHtml(r.id) + '',' + (r.enabled ? 0 : 1) + ')\"><span class=\"ap-switch-slider\"></span></label></td>';\n html += '<td class=\"ap-actions\">';\n html += apIconBtn(AP_ICON_EDIT, __t(\"common.edit\"), \"openRuleDialog('edit','\" + escapeHtml(r.id) + \"')\");\n html += apIconBtn(AP_ICON_DELETE, __t(\"common.delete\"), \"apDeleteRule('\" + escapeHtml(r.id) + \"')\", \"danger\");\n html += \"</td></tr>\";\n });\n\n html += \"</tbody></table>\";\n wrap.innerHTML = html;\n}\n\nasync function apSaveDefaultRulePolicy(policyId) {\n if (!apDefaultRule) return;\n var res = await api(\"PUT\", \"/security-rules/\" + apDefaultRule.id, {\n accessPolicyId: policyId,\n remark: apDefaultRule.remark || \"Default fallback rule\"\n });\n if (res.ok) {\n showToast(__t(\"access.ruleSaved\"), \"success\");\n apDefaultRule.accessPolicyId = policyId;\n }\n}\n\nasync function apToggleRule(id, enabled) {\n var r = apRules.find(function(x) { return x.id === id; });\n if (!r) return;\n var res = await api(\"PUT\", \"/security-rules/\" + id, {\n accessPolicyId: r.accessPolicyId,\n pathPattern: r.pathPattern,\n priority: r.priority,\n enabled: enabled,\n remark: r.remark || \"\"\n });\n if (res.ok) {\n r.enabled = enabled;\n apRenderRules();\n showToast(__t(\"access.ruleSaved\"), \"success\");\n }\n}\n\n// \u2500\u2500\u2500 Policy Dialog (custom only) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nfunction openPolicyDialog(mode, id) {\n apEditingPolicyId = (mode === \"edit\") ? id : null;\n document.getElementById(\"ap-policy-dialog-title\").textContent = mode === \"edit\" ? __t(\"access.editPolicyTitle\") : __t(\"access.policyTitle\");\n\n if (mode === \"edit\") {\n var p = apPolicies.find(function(x) { return x.id === id; });\n if (!p) return;\n document.getElementById(\"ap-policy-name\").value = p.name;\n document.getElementById(\"ap-policy-type\").value = p.accessType || \"roles\";\n document.getElementById(\"ap-policy-desc\").value = p.description || \"\";\n document.querySelectorAll(\".ap-role-cb\").forEach(function(cb) {\n cb.checked = (p.roles || []).includes(cb.value);\n });\n } else {\n document.getElementById(\"ap-policy-name\").value = \"\";\n document.getElementById(\"ap-policy-type\").value = \"roles\";\n document.getElementById(\"ap-policy-desc\").value = \"\";\n document.querySelectorAll(\".ap-role-cb\").forEach(function(cb) { cb.checked = false; });\n }\n showDialog(\"ap-policy-dialog\");\n}\n\nasync function apSavePolicy() {\n var body = {\n name: document.getElementById(\"ap-policy-name\").value.trim(),\n accessType: document.getElementById(\"ap-policy-type\").value,\n description: document.getElementById(\"ap-policy-desc\").value.trim(),\n };\n body.roles = [];\n document.querySelectorAll(\".ap-role-cb:checked\").forEach(function(cb) { body.roles.push(cb.value); });\n if (body.roles.length === 0) { showToast(__t(\"access.roleRequired\"), \"error\"); return; }\n if (!body.name) { showToast(__t(\"access.nameRequired\"), \"error\"); return; }\n\n var res;\n if (apEditingPolicyId) {\n res = await api(\"PUT\", \"/access-policies/\" + apEditingPolicyId, body);\n } else {\n res = await api(\"POST\", \"/access-policies\", body);\n }\n if (res.ok) {\n showToast(__t(\"access.policySaved\"), \"success\");\n closeDialog(\"ap-policy-dialog\");\n apLoadAll();\n }\n}\n\nasync function apDeletePolicy(id) {\n var ok = await confirmDialog({ title: __t(\"access.deletePolicy\"), message: __t(\"access.deletePolicyMsg\"), danger: true });\n if (!ok) return;\n var res = await api(\"DELETE\", \"/access-policies/\" + id);\n if (res.ok) { showToast(__t(\"access.policyDeleted\"), \"success\"); apLoadAll(); }\n}\n\n// \u2500\u2500\u2500 Rule Dialog \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nfunction openRuleDialog(mode, id) {\n apEditingRuleId = (mode === \"edit\") ? id : null;\n document.getElementById(\"ap-rule-dialog-title\").textContent = mode === \"edit\" ? __t(\"access.editRuleTitle\") : __t(\"access.ruleTitle\");\n\n // Populate policy dropdown with all policies\n var sel = document.getElementById(\"ap-rule-policy\");\n sel.innerHTML = apPolicies.map(function(p) {\n return '<option value=\"' + escapeHtml(p.id) + '\">' + escapeHtml(p.name) + ' \\u2014 ' + escapeHtml(apAccessTypeLabel(p)) + '</option>';\n }).join(\"\");\n\n document.getElementById(\"ap-rule-pattern\").disabled = false;\n document.getElementById(\"ap-rule-priority\").disabled = false;\n\n if (mode === \"edit\") {\n var r = apRules.find(function(x) { return x.id === id; });\n if (!r) return;\n document.getElementById(\"ap-rule-pattern\").value = r.pathPattern;\n document.getElementById(\"ap-rule-priority\").value = r.priority;\n document.getElementById(\"ap-rule-remark\").value = r.remark || \"\";\n sel.value = r.accessPolicyId;\n } else {\n document.getElementById(\"ap-rule-pattern\").value = \"\";\n document.getElementById(\"ap-rule-priority\").value = \"0\";\n document.getElementById(\"ap-rule-remark\").value = \"\";\n }\n showDialog(\"ap-rule-dialog\");\n}\n\nasync function apSaveRule() {\n var body = {\n accessPolicyId: document.getElementById(\"ap-rule-policy\").value,\n remark: document.getElementById(\"ap-rule-remark\").value.trim(),\n pathPattern: document.getElementById(\"ap-rule-pattern\").value.trim(),\n priority: parseInt(document.getElementById(\"ap-rule-priority\").value, 10) || 0,\n };\n if (!body.pathPattern) { showToast(__t(\"access.patternRequired\"), \"error\"); return; }\n\n var res;\n if (apEditingRuleId) {\n res = await api(\"PUT\", \"/security-rules/\" + apEditingRuleId, body);\n } else {\n res = await api(\"POST\", \"/security-rules\", body);\n }\n if (res.ok) {\n showToast(__t(\"access.ruleSaved\"), \"success\");\n closeDialog(\"ap-rule-dialog\");\n apLoadAll();\n }\n}\n\nasync function apDeleteRule(id) {\n var ok = await confirmDialog({ title: __t(\"access.deleteRule\"), message: __t(\"access.deleteRuleMsg\"), danger: true });\n if (!ok) return;\n var res = await api(\"DELETE\", \"/security-rules/\" + id);\n if (res.ok) { showToast(__t(\"access.ruleDeleted\"), \"success\"); apLoadAll(); }\n}\n\n// \u2500\u2500\u2500 Register Tab \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nregisterTab(\"access\", function() { apLoadAll(); });\n";
|
|
12
|
+
export declare const ACCESS_TAB_SCRIPT: string;
|
|
13
13
|
export {};
|
|
14
14
|
//# sourceMappingURL=tab-access.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tab-access.d.ts","sourceRoot":"","sources":["../../../src/pages/admin/tab-access.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,KAAK,GAAG,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,MAAM,CAAC;AAOpE,wBAAgB,aAAa,CAAC,CAAC,EAAE,GAAG,GAAG,MAAM,CAwF5C;
|
|
1
|
+
{"version":3,"file":"tab-access.d.ts","sourceRoot":"","sources":["../../../src/pages/admin/tab-access.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,KAAK,GAAG,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,MAAM,CAAC;AAOpE,wBAAgB,aAAa,CAAC,CAAC,EAAE,GAAG,GAAG,MAAM,CAwF5C;AAKD,eAAO,MAAM,iBAAiB,QA4T1B,CAAC"}
|
|
@@ -100,7 +100,10 @@ export function accessTabHtml(t) {
|
|
|
100
100
|
</dialog>
|
|
101
101
|
`;
|
|
102
102
|
}
|
|
103
|
-
|
|
103
|
+
// Wrapped in a @__PURE__ IIFE so bundlers can tree-shake this client-only string
|
|
104
|
+
// out of the server bundle (it's served as an external asset; only build-assets.mjs
|
|
105
|
+
// reads it). The template interpolates module locals, which otherwise blocks DCE.
|
|
106
|
+
export const ACCESS_TAB_SCRIPT = /* @__PURE__ */ (() => /* js */ `
|
|
104
107
|
// ─── Access Tab State ──────────────────────────────────────────────────────
|
|
105
108
|
var apPolicies = [];
|
|
106
109
|
var apRules = [];
|
|
@@ -416,5 +419,5 @@ async function apDeleteRule(id) {
|
|
|
416
419
|
|
|
417
420
|
// ─── Register Tab ──────────────────────────────────────────────────────────
|
|
418
421
|
registerTab("access", function() { apLoadAll(); });
|
|
419
|
-
|
|
422
|
+
`)();
|
|
420
423
|
//# sourceMappingURL=tab-access.js.map
|