@svadmin/ui 0.130.0 → 0.131.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app.css +301 -0
- package/dist/app.theme.css +301 -0
- package/dist/components/AboutSettings.svelte +1 -1
- package/dist/components/AccessRevocationMatrix.svelte +425 -0
- package/dist/components/AccessRevocationMatrix.svelte.d.ts +27 -0
- package/dist/components/AudioVisualInspector.svelte +458 -0
- package/dist/components/AudioVisualInspector.svelte.d.ts +53 -0
- package/dist/components/AuditSnapshotCapture.svelte +328 -0
- package/dist/components/AuditSnapshotCapture.svelte.d.ts +28 -0
- package/dist/components/CannedResponsePicker.svelte +257 -0
- package/dist/components/CannedResponsePicker.svelte.d.ts +22 -0
- package/dist/components/ContentModerationCenter.svelte +166 -0
- package/dist/components/ContentModerationCenter.svelte.d.ts +11 -0
- package/dist/components/ContractClauseDiffViewer.svelte +566 -0
- package/dist/components/ContractClauseDiffViewer.svelte.d.ts +53 -0
- package/dist/components/DataImportPipeline.svelte +577 -0
- package/dist/components/DataImportPipeline.svelte.d.ts +35 -0
- package/dist/components/DataRetentionPolicyEditor.svelte +455 -0
- package/dist/components/DataRetentionPolicyEditor.svelte.d.ts +10 -0
- package/dist/components/ElectronicSealInspector.svelte +450 -0
- package/dist/components/ElectronicSealInspector.svelte.d.ts +72 -0
- package/dist/components/EmployeeOffboardingAuditor.svelte +405 -0
- package/dist/components/EmployeeOffboardingAuditor.svelte.d.ts +39 -0
- package/dist/components/FieldMappingBuilder.svelte +393 -0
- package/dist/components/FieldMappingBuilder.svelte.d.ts +39 -0
- package/dist/components/GatewayRouteEditor.svelte +493 -0
- package/dist/components/GatewayRouteEditor.svelte.d.ts +34 -0
- package/dist/components/I18nStudio.svelte +635 -0
- package/dist/components/I18nStudio.svelte.d.ts +23 -0
- package/dist/components/IpAccessRuleEditor.svelte +290 -0
- package/dist/components/IpAccessRuleEditor.svelte.d.ts +19 -0
- package/dist/components/IpWhitelistDrawer.svelte +94 -0
- package/dist/components/IpWhitelistDrawer.svelte.d.ts +10 -0
- package/dist/components/MediaAuthenticityAuditCard.svelte +357 -0
- package/dist/components/MediaAuthenticityAuditCard.svelte.d.ts +64 -0
- package/dist/components/PrintDocument.svelte +95 -0
- package/dist/components/PrintDocument.svelte.d.ts +10 -0
- package/dist/components/PrintPreviewModal.svelte +52 -0
- package/dist/components/PrintPreviewModal.svelte.d.ts +11 -0
- package/dist/components/PrintTemplateDesigner.svelte +280 -0
- package/dist/components/PrintTemplateDesigner.svelte.d.ts +11 -0
- package/dist/components/RateLimitPolicyPanel.svelte +369 -0
- package/dist/components/RateLimitPolicyPanel.svelte.d.ts +29 -0
- package/dist/components/SensitiveWordAuditor.svelte +368 -0
- package/dist/components/SensitiveWordAuditor.svelte.d.ts +9 -0
- package/dist/components/ServiceDeskTicketCard.svelte +297 -0
- package/dist/components/ServiceDeskTicketCard.svelte.d.ts +52 -0
- package/dist/components/ShiftScheduler.svelte +490 -0
- package/dist/components/ShiftScheduler.svelte.d.ts +50 -0
- package/dist/components/SslCertificateMonitorCard.svelte +309 -0
- package/dist/components/SslCertificateMonitorCard.svelte.d.ts +30 -0
- package/dist/components/SsoConnectionStudio.svelte +784 -0
- package/dist/components/SsoConnectionStudio.svelte.d.ts +44 -0
- package/dist/components/SsoSpMetadataPanel.svelte +44 -0
- package/dist/components/SsoSpMetadataPanel.svelte.d.ts +8 -0
- package/dist/components/StepUpAuthModal.svelte +448 -0
- package/dist/components/StepUpAuthModal.svelte.d.ts +26 -0
- package/dist/components/TrafficTopologyInspector.svelte +361 -0
- package/dist/components/TrafficTopologyInspector.svelte.d.ts +43 -0
- package/dist/components/ip-access-rules.d.ts +24 -0
- package/dist/components/ip-access-rules.js +110 -0
- package/dist/components/moderation-utils.d.ts +45 -0
- package/dist/components/moderation-utils.js +74 -0
- package/dist/components/print-document.d.ts +3 -0
- package/dist/components/print-document.js +65 -0
- package/dist/components/print-utils.d.ts +44 -0
- package/dist/components/print-utils.js +68 -0
- package/dist/components/retention-utils.d.ts +31 -0
- package/dist/components/retention-utils.js +38 -0
- package/dist/components/sso-connection-presets.d.ts +2 -0
- package/dist/components/sso-connection-presets.js +59 -0
- package/dist/components/ui/sheet/sheet.svelte +3 -1
- package/dist/components/ui/sheet/sheet.svelte.d.ts +1 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.js +44 -0
- package/package.json +5 -4
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export type SsoProtocol = 'saml' | 'oidc' | 'oauth2' | 'feishu' | 'dingtalk' | 'wecom';
|
|
2
|
+
export type SsoStatus = 'active' | 'inactive' | 'testing';
|
|
3
|
+
export interface SsoClaimMapping {
|
|
4
|
+
remoteClaim: string;
|
|
5
|
+
localField: string;
|
|
6
|
+
defaultValue?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface SsoConnection {
|
|
9
|
+
id: string;
|
|
10
|
+
name: string;
|
|
11
|
+
protocol: SsoProtocol;
|
|
12
|
+
status: SsoStatus;
|
|
13
|
+
domains: string[];
|
|
14
|
+
isDefault?: boolean;
|
|
15
|
+
entityId?: string;
|
|
16
|
+
ssoUrl?: string;
|
|
17
|
+
certificate?: string;
|
|
18
|
+
clientId?: string;
|
|
19
|
+
clientSecret?: string;
|
|
20
|
+
discoveryUrl?: string;
|
|
21
|
+
scopes?: string[];
|
|
22
|
+
appId?: string;
|
|
23
|
+
appSecret?: string;
|
|
24
|
+
corpId?: string;
|
|
25
|
+
claimMappings?: SsoClaimMapping[];
|
|
26
|
+
lastTestedAt?: string;
|
|
27
|
+
testStatus?: 'success' | 'failed' | 'untested';
|
|
28
|
+
testMessage?: string;
|
|
29
|
+
}
|
|
30
|
+
export interface SsoConnectionStudioProps {
|
|
31
|
+
connections?: SsoConnection[];
|
|
32
|
+
class?: string;
|
|
33
|
+
spEntityId?: string;
|
|
34
|
+
spAcsUrl?: string;
|
|
35
|
+
onSave?: (conn: SsoConnection) => void;
|
|
36
|
+
onDelete?: (id: string) => void;
|
|
37
|
+
onTest?: (conn: SsoConnection) => Promise<{
|
|
38
|
+
success: boolean;
|
|
39
|
+
message: string;
|
|
40
|
+
}>;
|
|
41
|
+
}
|
|
42
|
+
declare const SsoConnectionStudio: import("svelte").Component<SsoConnectionStudioProps, {}, "">;
|
|
43
|
+
type SsoConnectionStudio = ReturnType<typeof SsoConnectionStudio>;
|
|
44
|
+
export default SsoConnectionStudio;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
interface Props {
|
|
3
|
+
spEntityId: string;
|
|
4
|
+
spAcsUrl: string;
|
|
5
|
+
onCopy: (value: string, label: string) => void;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
let { spEntityId, spAcsUrl, onCopy }: Props = $props();
|
|
9
|
+
</script>
|
|
10
|
+
|
|
11
|
+
<div class="p-4 rounded-lg bg-muted/40 border border-border flex flex-col gap-3">
|
|
12
|
+
<div class="flex items-center justify-between">
|
|
13
|
+
<span class="text-xs font-semibold text-foreground uppercase tracking-wider">系统服务提供商 (SP) 对接参数</span>
|
|
14
|
+
<span class="text-[11px] text-muted-foreground">请将此配置填入您的 Okta / Azure AD / Keycloak 中</span>
|
|
15
|
+
</div>
|
|
16
|
+
<div class="grid grid-cols-1 md:grid-cols-2 gap-3 text-xs">
|
|
17
|
+
<div class="flex flex-col gap-1 p-2.5 rounded bg-card border border-border">
|
|
18
|
+
<span class="text-muted-foreground font-medium">SP Entity ID (Audience URI):</span>
|
|
19
|
+
<div class="flex items-center justify-between font-mono text-[11px] text-foreground break-all">
|
|
20
|
+
<span>{spEntityId}</span>
|
|
21
|
+
<button
|
|
22
|
+
type="button"
|
|
23
|
+
onclick={() => onCopy(spEntityId, 'SP Entity ID')}
|
|
24
|
+
class="ml-2 px-1.5 py-0.5 text-[10px] font-sans rounded bg-muted hover:bg-muted/80 text-muted-foreground"
|
|
25
|
+
>
|
|
26
|
+
复制
|
|
27
|
+
</button>
|
|
28
|
+
</div>
|
|
29
|
+
</div>
|
|
30
|
+
<div class="flex flex-col gap-1 p-2.5 rounded bg-card border border-border">
|
|
31
|
+
<span class="text-muted-foreground font-medium">ACS URL (Single Sign-On Callback):</span>
|
|
32
|
+
<div class="flex items-center justify-between font-mono text-[11px] text-foreground break-all">
|
|
33
|
+
<span>{spAcsUrl}</span>
|
|
34
|
+
<button
|
|
35
|
+
type="button"
|
|
36
|
+
onclick={() => onCopy(spAcsUrl, 'ACS URL')}
|
|
37
|
+
class="ml-2 px-1.5 py-0.5 text-[10px] font-sans rounded bg-muted hover:bg-muted/80 text-muted-foreground"
|
|
38
|
+
>
|
|
39
|
+
复制
|
|
40
|
+
</button>
|
|
41
|
+
</div>
|
|
42
|
+
</div>
|
|
43
|
+
</div>
|
|
44
|
+
</div>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
interface Props {
|
|
2
|
+
spEntityId: string;
|
|
3
|
+
spAcsUrl: string;
|
|
4
|
+
onCopy: (value: string, label: string) => void;
|
|
5
|
+
}
|
|
6
|
+
declare const SsoSpMetadataPanel: import("svelte").Component<Props, {}, "">;
|
|
7
|
+
type SsoSpMetadataPanel = ReturnType<typeof SsoSpMetadataPanel>;
|
|
8
|
+
export default SsoSpMetadataPanel;
|
|
@@ -0,0 +1,448 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { onDestroy, untrack } from 'svelte';
|
|
3
|
+
import {
|
|
4
|
+
ShieldAlert,
|
|
5
|
+
Smartphone,
|
|
6
|
+
KeyRound,
|
|
7
|
+
UserCheck,
|
|
8
|
+
Lock,
|
|
9
|
+
Unlock,
|
|
10
|
+
AlertTriangle,
|
|
11
|
+
X,
|
|
12
|
+
CheckCircle2,
|
|
13
|
+
RefreshCw,
|
|
14
|
+
} from '@lucide/svelte';
|
|
15
|
+
|
|
16
|
+
export type StepUpAuthMethod = 'totp' | 'sms' | 'hardware' | 'supervisor';
|
|
17
|
+
export type StepUpRiskLevel = 'low' | 'medium' | 'high' | 'critical';
|
|
18
|
+
|
|
19
|
+
interface Props {
|
|
20
|
+
open?: boolean;
|
|
21
|
+
title?: string;
|
|
22
|
+
subtitle?: string;
|
|
23
|
+
operationName?: string;
|
|
24
|
+
riskLevel?: StepUpRiskLevel;
|
|
25
|
+
clientIp?: string;
|
|
26
|
+
phoneMask?: string;
|
|
27
|
+
methods?: StepUpAuthMethod[];
|
|
28
|
+
defaultMethod?: StepUpAuthMethod;
|
|
29
|
+
maxAttempts?: number;
|
|
30
|
+
cooldownSeconds?: number;
|
|
31
|
+
lockoutDurationSeconds?: number;
|
|
32
|
+
onverify?: (payload: { method: StepUpAuthMethod; code: string; supervisorToken?: string }) => Promise<boolean> | boolean;
|
|
33
|
+
oncancel?: () => void;
|
|
34
|
+
onlockout?: () => void;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
let {
|
|
38
|
+
open = $bindable(false),
|
|
39
|
+
title = '高敏特权二次认证',
|
|
40
|
+
subtitle = '当前操作涉及高风险核心资源变更,需完成多因子特权鉴权',
|
|
41
|
+
operationName = '特权操作执行 / 敏感数据导出',
|
|
42
|
+
riskLevel = 'critical',
|
|
43
|
+
clientIp = '10.12.88.42',
|
|
44
|
+
phoneMask = '138****8888',
|
|
45
|
+
methods = ['totp', 'sms', 'supervisor'],
|
|
46
|
+
defaultMethod = 'totp',
|
|
47
|
+
maxAttempts = 5,
|
|
48
|
+
cooldownSeconds = 60,
|
|
49
|
+
lockoutDurationSeconds = 300,
|
|
50
|
+
onverify,
|
|
51
|
+
oncancel,
|
|
52
|
+
onlockout,
|
|
53
|
+
}: Props = $props();
|
|
54
|
+
|
|
55
|
+
let activeMethod = $state<StepUpAuthMethod>(untrack(() => defaultMethod));
|
|
56
|
+
let digits = $state<string[]>(['', '', '', '', '', '']);
|
|
57
|
+
let supervisorToken = $state('');
|
|
58
|
+
let attemptsCount = $state(0);
|
|
59
|
+
let isLocked = $state(false);
|
|
60
|
+
let lockoutTimer = $state(0);
|
|
61
|
+
let smsCooldown = $state(0);
|
|
62
|
+
let isSubmitting = $state(false);
|
|
63
|
+
let errorMsg = $state<string | null>(null);
|
|
64
|
+
let successMsg = $state<string | null>(null);
|
|
65
|
+
|
|
66
|
+
let intervalId: ReturnType<typeof setInterval> | null = null;
|
|
67
|
+
let smsIntervalId: ReturnType<typeof setInterval> | null = null;
|
|
68
|
+
|
|
69
|
+
let remainingAttempts = $derived(Math.max(0, maxAttempts - attemptsCount));
|
|
70
|
+
let isCodeComplete = $derived(
|
|
71
|
+
activeMethod === 'supervisor'
|
|
72
|
+
? supervisorToken.trim().length >= 6
|
|
73
|
+
: digits.every((d) => d.trim().length > 0)
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
function resetCode() {
|
|
77
|
+
digits = ['', '', '', '', '', ''];
|
|
78
|
+
supervisorToken = '';
|
|
79
|
+
errorMsg = null;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function handleMethodSwitch(method: StepUpAuthMethod) {
|
|
83
|
+
if (isLocked) return;
|
|
84
|
+
activeMethod = method;
|
|
85
|
+
resetCode();
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function handleDigitInput(index: number, event: Event) {
|
|
89
|
+
if (isLocked) return;
|
|
90
|
+
const input = event.target as HTMLInputElement;
|
|
91
|
+
const val = input.value.slice(-1);
|
|
92
|
+
digits[index] = val;
|
|
93
|
+
|
|
94
|
+
if (val && index < 5) {
|
|
95
|
+
const nextInput = document.getElementById(`stepup-digit-${index + 1}`) as HTMLInputElement | null;
|
|
96
|
+
if (nextInput) nextInput.focus();
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function handleDigitKeydown(index: number, event: KeyboardEvent) {
|
|
101
|
+
if (isLocked) return;
|
|
102
|
+
if (event.key === 'Backspace' && !digits[index] && index > 0) {
|
|
103
|
+
const prevInput = document.getElementById(`stepup-digit-${index - 1}`) as HTMLInputElement | null;
|
|
104
|
+
if (prevInput) prevInput.focus();
|
|
105
|
+
} else if (event.key === 'ArrowLeft' && index > 0) {
|
|
106
|
+
const prevInput = document.getElementById(`stepup-digit-${index - 1}`) as HTMLInputElement | null;
|
|
107
|
+
if (prevInput) prevInput.focus();
|
|
108
|
+
} else if (event.key === 'ArrowRight' && index < 5) {
|
|
109
|
+
const nextInput = document.getElementById(`stepup-digit-${index + 1}`) as HTMLInputElement | null;
|
|
110
|
+
if (nextInput) nextInput.focus();
|
|
111
|
+
} else if (event.key === 'Enter' && isCodeComplete) {
|
|
112
|
+
handleSubmit();
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function handlePaste(event: ClipboardEvent) {
|
|
117
|
+
if (isLocked) return;
|
|
118
|
+
event.preventDefault();
|
|
119
|
+
const pasteData = event.clipboardData?.getData('text') ?? '';
|
|
120
|
+
const numeric = pasteData.replace(/\D/g, '').slice(0, 6);
|
|
121
|
+
if (!numeric) return;
|
|
122
|
+
for (let i = 0; i < 6; i++) {
|
|
123
|
+
digits[i] = numeric[i] || '';
|
|
124
|
+
}
|
|
125
|
+
const focusIndex = Math.min(numeric.length, 5);
|
|
126
|
+
const targetInput = document.getElementById(`stepup-digit-${focusIndex}`) as HTMLInputElement | null;
|
|
127
|
+
if (targetInput) targetInput.focus();
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function sendSmsCode() {
|
|
131
|
+
if (smsCooldown > 0 || isLocked) return;
|
|
132
|
+
smsCooldown = cooldownSeconds;
|
|
133
|
+
smsIntervalId = setInterval(() => {
|
|
134
|
+
smsCooldown -= 1;
|
|
135
|
+
if (smsCooldown <= 0 && smsIntervalId) {
|
|
136
|
+
clearInterval(smsIntervalId);
|
|
137
|
+
smsIntervalId = null;
|
|
138
|
+
}
|
|
139
|
+
}, 1000);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function startLockout() {
|
|
143
|
+
isLocked = true;
|
|
144
|
+
lockoutTimer = lockoutDurationSeconds;
|
|
145
|
+
if (onlockout) onlockout();
|
|
146
|
+
intervalId = setInterval(() => {
|
|
147
|
+
lockoutTimer -= 1;
|
|
148
|
+
if (lockoutTimer <= 0) {
|
|
149
|
+
if (intervalId) clearInterval(intervalId);
|
|
150
|
+
isLocked = false;
|
|
151
|
+
attemptsCount = 0;
|
|
152
|
+
lockoutTimer = 0;
|
|
153
|
+
}
|
|
154
|
+
}, 1000);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
async function handleSubmit() {
|
|
158
|
+
if (isLocked || isSubmitting) return;
|
|
159
|
+
const code = activeMethod === 'supervisor' ? supervisorToken.trim() : digits.join('');
|
|
160
|
+
if (!code) return;
|
|
161
|
+
|
|
162
|
+
isSubmitting = true;
|
|
163
|
+
errorMsg = null;
|
|
164
|
+
|
|
165
|
+
try {
|
|
166
|
+
if (onverify) {
|
|
167
|
+
const result = await onverify({
|
|
168
|
+
method: activeMethod,
|
|
169
|
+
code,
|
|
170
|
+
...(activeMethod === 'supervisor' ? { supervisorToken } : {}),
|
|
171
|
+
});
|
|
172
|
+
if (result === false) {
|
|
173
|
+
handleFailure();
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
successMsg = '特权鉴权成功,正在执行授权指令...';
|
|
178
|
+
setTimeout(() => {
|
|
179
|
+
open = false;
|
|
180
|
+
isSubmitting = false;
|
|
181
|
+
successMsg = null;
|
|
182
|
+
resetCode();
|
|
183
|
+
}, 600);
|
|
184
|
+
} catch (err: unknown) {
|
|
185
|
+
handleFailure(err instanceof Error ? err.message : '验证失败,请重试');
|
|
186
|
+
} finally {
|
|
187
|
+
if (!successMsg) {
|
|
188
|
+
isSubmitting = false;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
function handleFailure(customMsg?: string) {
|
|
194
|
+
attemptsCount += 1;
|
|
195
|
+
if (attemptsCount >= maxAttempts) {
|
|
196
|
+
errorMsg = '连续鉴权失败次数超限,特权通道已锁定!';
|
|
197
|
+
startLockout();
|
|
198
|
+
} else {
|
|
199
|
+
errorMsg = customMsg || `验证码错误,还剩 ${remainingAttempts} 次机会`;
|
|
200
|
+
resetCode();
|
|
201
|
+
const firstInput = document.getElementById('stepup-digit-0') as HTMLInputElement | null;
|
|
202
|
+
if (firstInput) firstInput.focus();
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
function handleClose() {
|
|
207
|
+
if (isLocked) return;
|
|
208
|
+
open = false;
|
|
209
|
+
if (oncancel) oncancel();
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
onDestroy(() => {
|
|
213
|
+
if (intervalId) clearInterval(intervalId);
|
|
214
|
+
if (smsIntervalId) clearInterval(smsIntervalId);
|
|
215
|
+
});
|
|
216
|
+
</script>
|
|
217
|
+
|
|
218
|
+
{#if open}
|
|
219
|
+
<!-- Backdrop -->
|
|
220
|
+
<div
|
|
221
|
+
class="fixed inset-0 z-50 flex items-center justify-center p-4 bg-background/80 backdrop-blur-sm"
|
|
222
|
+
data-svadmin-component="StepUpAuthModal"
|
|
223
|
+
role="dialog"
|
|
224
|
+
aria-modal="true"
|
|
225
|
+
aria-labelledby="stepup-auth-title"
|
|
226
|
+
>
|
|
227
|
+
<!-- Modal Card -->
|
|
228
|
+
<div
|
|
229
|
+
class="relative w-full max-w-lg rounded-xl border border-border bg-card p-6 shadow-2xl transition-all"
|
|
230
|
+
>
|
|
231
|
+
<!-- Close button -->
|
|
232
|
+
{#if !isLocked}
|
|
233
|
+
<button
|
|
234
|
+
type="button"
|
|
235
|
+
class="absolute right-4 top-4 rounded-lg p-1 text-muted-foreground hover:bg-muted hover:text-foreground transition-colors"
|
|
236
|
+
onclick={handleClose}
|
|
237
|
+
aria-label="关闭"
|
|
238
|
+
>
|
|
239
|
+
<X class="h-5 w-5" />
|
|
240
|
+
</button>
|
|
241
|
+
{/if}
|
|
242
|
+
|
|
243
|
+
<!-- Header Icon & Security Summary -->
|
|
244
|
+
<div class="flex items-start gap-4 mb-5">
|
|
245
|
+
<div
|
|
246
|
+
class="flex h-12 w-12 shrink-0 items-center justify-center rounded-xl bg-destructive/10 text-destructive border border-destructive/20"
|
|
247
|
+
>
|
|
248
|
+
<ShieldAlert class="h-6 w-6" />
|
|
249
|
+
</div>
|
|
250
|
+
<div class="space-y-1">
|
|
251
|
+
<div class="flex items-center gap-2">
|
|
252
|
+
<h2 id="stepup-auth-title" class="text-lg font-semibold tracking-tight text-foreground">
|
|
253
|
+
{title}
|
|
254
|
+
</h2>
|
|
255
|
+
<span
|
|
256
|
+
class="inline-flex items-center rounded-full px-2 py-0.5 text-xs font-semibold uppercase tracking-wider
|
|
257
|
+
{riskLevel === 'critical' ? 'bg-destructive/15 text-destructive border border-destructive/30 animate-pulse' :
|
|
258
|
+
riskLevel === 'high' ? 'bg-warning/15 text-warning border border-warning/30' :
|
|
259
|
+
'bg-muted text-muted-foreground'}"
|
|
260
|
+
>
|
|
261
|
+
{riskLevel === 'critical' ? '严重高危' : riskLevel === 'high' ? '高风险' : '特权操作'}
|
|
262
|
+
</span>
|
|
263
|
+
</div>
|
|
264
|
+
<p class="text-xs text-muted-foreground">{subtitle}</p>
|
|
265
|
+
</div>
|
|
266
|
+
</div>
|
|
267
|
+
|
|
268
|
+
<!-- Operation Target & Client Meta Banner -->
|
|
269
|
+
<div class="mb-5 rounded-lg border border-border/80 bg-muted/40 p-3 text-xs space-y-1.5">
|
|
270
|
+
<div class="flex items-center justify-between text-muted-foreground">
|
|
271
|
+
<span>拟操作项目</span>
|
|
272
|
+
<span class="font-medium text-foreground font-mono">{operationName}</span>
|
|
273
|
+
</div>
|
|
274
|
+
<div class="flex items-center justify-between text-muted-foreground">
|
|
275
|
+
<span>终端来源</span>
|
|
276
|
+
<span class="font-mono text-muted-foreground">{clientIp}</span>
|
|
277
|
+
</div>
|
|
278
|
+
</div>
|
|
279
|
+
|
|
280
|
+
<!-- Lockout Alert -->
|
|
281
|
+
{#if isLocked}
|
|
282
|
+
<div
|
|
283
|
+
class="mb-5 flex items-start gap-3 rounded-lg border border-destructive/30 bg-destructive/10 p-3.5 text-destructive"
|
|
284
|
+
role="alert"
|
|
285
|
+
>
|
|
286
|
+
<Lock class="h-5 w-5 shrink-0 mt-0.5" />
|
|
287
|
+
<div class="text-xs space-y-1">
|
|
288
|
+
<div class="font-semibold">特权鉴权通道已锁定</div>
|
|
289
|
+
<div>
|
|
290
|
+
连续错误次数已达上限。为确保系统资产安全,特权通道将在
|
|
291
|
+
<span class="font-bold font-mono text-sm underline">{lockoutTimer}s</span>
|
|
292
|
+
后自动解除。
|
|
293
|
+
</div>
|
|
294
|
+
</div>
|
|
295
|
+
</div>
|
|
296
|
+
{/if}
|
|
297
|
+
|
|
298
|
+
<!-- Method Switch Tabs -->
|
|
299
|
+
{#if methods.length > 1 && !isLocked}
|
|
300
|
+
<div class="mb-5 flex rounded-lg border border-border bg-muted/30 p-1">
|
|
301
|
+
{#if methods.includes('totp')}
|
|
302
|
+
<button
|
|
303
|
+
type="button"
|
|
304
|
+
class="flex flex-1 items-center justify-center gap-1.5 rounded-md py-1.5 text-xs font-medium transition-colors
|
|
305
|
+
{activeMethod === 'totp' ? 'bg-background text-foreground shadow-sm' : 'text-muted-foreground hover:text-foreground'}"
|
|
306
|
+
onclick={() => handleMethodSwitch('totp')}
|
|
307
|
+
>
|
|
308
|
+
<KeyRound class="h-3.5 w-3.5" />
|
|
309
|
+
<span>动态口令 TOTP</span>
|
|
310
|
+
</button>
|
|
311
|
+
{/if}
|
|
312
|
+
{#if methods.includes('sms')}
|
|
313
|
+
<button
|
|
314
|
+
type="button"
|
|
315
|
+
class="flex flex-1 items-center justify-center gap-1.5 rounded-md py-1.5 text-xs font-medium transition-colors
|
|
316
|
+
{activeMethod === 'sms' ? 'bg-background text-foreground shadow-sm' : 'text-muted-foreground hover:text-foreground'}"
|
|
317
|
+
onclick={() => handleMethodSwitch('sms')}
|
|
318
|
+
>
|
|
319
|
+
<Smartphone class="h-3.5 w-3.5" />
|
|
320
|
+
<span>短信验证码</span>
|
|
321
|
+
</button>
|
|
322
|
+
{/if}
|
|
323
|
+
{#if methods.includes('supervisor')}
|
|
324
|
+
<button
|
|
325
|
+
type="button"
|
|
326
|
+
class="flex flex-1 items-center justify-center gap-1.5 rounded-md py-1.5 text-xs font-medium transition-colors
|
|
327
|
+
{activeMethod === 'supervisor' ? 'bg-background text-foreground shadow-sm' : 'text-muted-foreground hover:text-foreground'}"
|
|
328
|
+
onclick={() => handleMethodSwitch('supervisor')}
|
|
329
|
+
>
|
|
330
|
+
<UserCheck class="h-3.5 w-3.5" />
|
|
331
|
+
<span>主管授权码</span>
|
|
332
|
+
</button>
|
|
333
|
+
{/if}
|
|
334
|
+
</div>
|
|
335
|
+
{/if}
|
|
336
|
+
|
|
337
|
+
<!-- Interactive Inputs -->
|
|
338
|
+
<div class="space-y-4">
|
|
339
|
+
{#if activeMethod === 'sms'}
|
|
340
|
+
<div class="flex items-center justify-between text-xs text-muted-foreground">
|
|
341
|
+
<span>已发送至绑定手机:<span class="font-mono font-medium text-foreground">{phoneMask}</span></span>
|
|
342
|
+
<button
|
|
343
|
+
type="button"
|
|
344
|
+
class="font-medium text-primary hover:underline disabled:opacity-50 disabled:no-underline transition-colors"
|
|
345
|
+
disabled={smsCooldown > 0 || isLocked}
|
|
346
|
+
onclick={sendSmsCode}
|
|
347
|
+
>
|
|
348
|
+
{#if smsCooldown > 0}
|
|
349
|
+
重新获取 ({smsCooldown}s)
|
|
350
|
+
{:else}
|
|
351
|
+
获取验证码
|
|
352
|
+
{/if}
|
|
353
|
+
</button>
|
|
354
|
+
</div>
|
|
355
|
+
{/if}
|
|
356
|
+
|
|
357
|
+
{#if activeMethod === 'totp'}
|
|
358
|
+
<div class="text-xs text-muted-foreground text-center">
|
|
359
|
+
请输入身份验证器 App (Google Authenticator / 1Password) 生成的 6 位数字
|
|
360
|
+
</div>
|
|
361
|
+
{/if}
|
|
362
|
+
|
|
363
|
+
{#if activeMethod === 'supervisor'}
|
|
364
|
+
<div class="space-y-2">
|
|
365
|
+
<label for="stepup-supervisor-token" class="text-xs text-muted-foreground">
|
|
366
|
+
请输入直属主管或合规官签署的 6 位以上审批授权令牌(Ticket Key)
|
|
367
|
+
</label>
|
|
368
|
+
<input
|
|
369
|
+
id="stepup-supervisor-token"
|
|
370
|
+
type="text"
|
|
371
|
+
class="w-full rounded-lg border border-input bg-background px-3 py-2 text-sm font-mono tracking-wider text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring"
|
|
372
|
+
placeholder="SUPV-AUTH-XXXXXX"
|
|
373
|
+
disabled={isLocked || isSubmitting}
|
|
374
|
+
bind:value={supervisorToken}
|
|
375
|
+
/>
|
|
376
|
+
</div>
|
|
377
|
+
{:else}
|
|
378
|
+
<!-- 6-digit PIN Box Grid -->
|
|
379
|
+
<div class="flex items-center justify-center gap-2 sm:gap-3" onpaste={handlePaste}>
|
|
380
|
+
{#each digits as digit, i (i)}
|
|
381
|
+
<input
|
|
382
|
+
id="stepup-digit-{i}"
|
|
383
|
+
type="text"
|
|
384
|
+
inputmode="numeric"
|
|
385
|
+
maxlength="1"
|
|
386
|
+
class="h-12 w-11 rounded-lg border border-input bg-background text-center text-lg font-bold font-mono text-foreground shadow-sm focus:border-primary focus:outline-none focus:ring-2 focus:ring-ring disabled:opacity-50"
|
|
387
|
+
value={digit}
|
|
388
|
+
disabled={isLocked || isSubmitting}
|
|
389
|
+
oninput={(e) => handleDigitInput(i, e)}
|
|
390
|
+
onkeydown={(e) => handleDigitKeydown(i, e)}
|
|
391
|
+
/>
|
|
392
|
+
{/each}
|
|
393
|
+
</div>
|
|
394
|
+
{/if}
|
|
395
|
+
|
|
396
|
+
<!-- Error & Success Messages -->
|
|
397
|
+
{#if errorMsg && !isLocked}
|
|
398
|
+
<div class="flex items-center gap-2 text-xs text-destructive font-medium justify-center">
|
|
399
|
+
<AlertTriangle class="h-3.5 w-3.5" />
|
|
400
|
+
<span>{errorMsg}</span>
|
|
401
|
+
</div>
|
|
402
|
+
{/if}
|
|
403
|
+
|
|
404
|
+
{#if successMsg}
|
|
405
|
+
<div class="flex items-center gap-2 text-xs text-success font-medium justify-center">
|
|
406
|
+
<CheckCircle2 class="h-3.5 w-3.5 text-success" />
|
|
407
|
+
<span>{successMsg}</span>
|
|
408
|
+
</div>
|
|
409
|
+
{/if}
|
|
410
|
+
|
|
411
|
+
{#if !isLocked && !successMsg && attemptsCount > 0}
|
|
412
|
+
<div class="text-[11px] text-muted-foreground text-center">
|
|
413
|
+
剩余尝试次数:<span class="font-bold text-foreground">{remainingAttempts}</span> / {maxAttempts}
|
|
414
|
+
</div>
|
|
415
|
+
{/if}
|
|
416
|
+
</div>
|
|
417
|
+
|
|
418
|
+
<!-- Action Footer -->
|
|
419
|
+
<div class="mt-6 flex items-center justify-end gap-3 pt-4 border-t border-border">
|
|
420
|
+
{#if !isLocked}
|
|
421
|
+
<button
|
|
422
|
+
type="button"
|
|
423
|
+
class="rounded-lg border border-input bg-background px-4 py-2 text-xs font-medium text-foreground hover:bg-muted transition-colors"
|
|
424
|
+
onclick={handleClose}
|
|
425
|
+
disabled={isSubmitting}
|
|
426
|
+
>
|
|
427
|
+
取消操作
|
|
428
|
+
</button>
|
|
429
|
+
{/if}
|
|
430
|
+
|
|
431
|
+
<button
|
|
432
|
+
type="button"
|
|
433
|
+
class="flex items-center gap-2 rounded-lg bg-primary px-5 py-2 text-xs font-medium text-primary-foreground shadow hover:bg-primary/90 disabled:opacity-50 transition-colors"
|
|
434
|
+
disabled={!isCodeComplete || isLocked || isSubmitting}
|
|
435
|
+
onclick={handleSubmit}
|
|
436
|
+
>
|
|
437
|
+
{#if isSubmitting}
|
|
438
|
+
<RefreshCw class="h-3.5 w-3.5 animate-spin" />
|
|
439
|
+
<span>正在校验特权...</span>
|
|
440
|
+
{:else}
|
|
441
|
+
<Unlock class="h-3.5 w-3.5" />
|
|
442
|
+
<span>验证并执行</span>
|
|
443
|
+
{/if}
|
|
444
|
+
</button>
|
|
445
|
+
</div>
|
|
446
|
+
</div>
|
|
447
|
+
</div>
|
|
448
|
+
{/if}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export type StepUpAuthMethod = 'totp' | 'sms' | 'hardware' | 'supervisor';
|
|
2
|
+
export type StepUpRiskLevel = 'low' | 'medium' | 'high' | 'critical';
|
|
3
|
+
interface Props {
|
|
4
|
+
open?: boolean;
|
|
5
|
+
title?: string;
|
|
6
|
+
subtitle?: string;
|
|
7
|
+
operationName?: string;
|
|
8
|
+
riskLevel?: StepUpRiskLevel;
|
|
9
|
+
clientIp?: string;
|
|
10
|
+
phoneMask?: string;
|
|
11
|
+
methods?: StepUpAuthMethod[];
|
|
12
|
+
defaultMethod?: StepUpAuthMethod;
|
|
13
|
+
maxAttempts?: number;
|
|
14
|
+
cooldownSeconds?: number;
|
|
15
|
+
lockoutDurationSeconds?: number;
|
|
16
|
+
onverify?: (payload: {
|
|
17
|
+
method: StepUpAuthMethod;
|
|
18
|
+
code: string;
|
|
19
|
+
supervisorToken?: string;
|
|
20
|
+
}) => Promise<boolean> | boolean;
|
|
21
|
+
oncancel?: () => void;
|
|
22
|
+
onlockout?: () => void;
|
|
23
|
+
}
|
|
24
|
+
declare const StepUpAuthModal: import("svelte").Component<Props, {}, "open">;
|
|
25
|
+
type StepUpAuthModal = ReturnType<typeof StepUpAuthModal>;
|
|
26
|
+
export default StepUpAuthModal;
|