@authrim/sveltekit 0.1.0 → 0.1.2
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/LICENSE +191 -191
- package/README.md +527 -531
- package/dist/components/AuthProvider.svelte +56 -56
- package/dist/components/ProtectedRoute.svelte +71 -71
- package/dist/components/SignInButton.svelte +93 -93
- package/dist/components/SignOutButton.svelte +72 -72
- package/dist/components/UserProfile.svelte +71 -71
- package/dist/ui/account/LinkAccountButton.svelte +133 -133
- package/dist/ui/account/LinkedAccountsList.svelte +233 -233
- package/dist/ui/account/UnlinkAccountButton.svelte +179 -179
- package/dist/ui/forms/EmailCodeForm.svelte +224 -224
- package/dist/ui/forms/PasskeyConditionalInput.svelte +173 -173
- package/dist/ui/forms/SocialLoginButtons.svelte +209 -209
- package/dist/ui/helpers/AuthError.svelte +124 -124
- package/dist/ui/helpers/AuthLoading.svelte +83 -83
- package/dist/ui/helpers/OTPInput.svelte +214 -214
- package/dist/ui/helpers/ResendCodeButton.svelte +140 -140
- package/dist/ui/passkey/PasskeyDeleteButton.svelte +177 -177
- package/dist/ui/passkey/PasskeyList.svelte +225 -225
- package/dist/ui/passkey/PasskeyRegisterButton.svelte +52 -52
- package/dist/ui/session/SessionExpiryIndicator.svelte +109 -109
- package/dist/ui/session/SessionList.svelte +231 -231
- package/dist/ui/session/SessionRevokeButton.svelte +72 -72
- package/dist/ui/shared/Badge.svelte +100 -100
- package/dist/ui/shared/Button.svelte +213 -213
- package/dist/ui/shared/Card.svelte +85 -85
- package/dist/ui/shared/Input.svelte +192 -192
- package/dist/ui/shared/Spinner.svelte +75 -75
- package/dist/ui/styles/base.css +168 -168
- package/dist/ui/styles/theme.css +279 -279
- package/dist/ui/templates/AccountSettingsTemplate.svelte +205 -205
- package/dist/ui/templates/LoginTemplate.svelte +234 -234
- package/dist/ui/templates/SignUpTemplate.svelte +345 -345
- package/package.json +112 -111
|
@@ -1,109 +1,109 @@
|
|
|
1
|
-
<!--
|
|
2
|
-
SessionExpiryIndicator Component
|
|
3
|
-
Shows session expiry time with visual indicator
|
|
4
|
-
-->
|
|
5
|
-
<script lang="ts">
|
|
6
|
-
import { onMount, onDestroy } from 'svelte';
|
|
7
|
-
|
|
8
|
-
export let expiresAt: Date;
|
|
9
|
-
let className = '';
|
|
10
|
-
export { className as class };
|
|
11
|
-
|
|
12
|
-
let timeLeft = '';
|
|
13
|
-
let urgency: 'normal' | 'warning' | 'critical' = 'normal';
|
|
14
|
-
let timeoutId: ReturnType<typeof setTimeout> | null = null;
|
|
15
|
-
|
|
16
|
-
function updateTimeLeft() {
|
|
17
|
-
const now = Date.now();
|
|
18
|
-
const expiry = expiresAt.getTime();
|
|
19
|
-
const diff = expiry - now;
|
|
20
|
-
|
|
21
|
-
if (diff <= 0) {
|
|
22
|
-
timeLeft = 'Expired';
|
|
23
|
-
urgency = 'critical';
|
|
24
|
-
return; // Don't schedule next update when expired
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const hours = Math.floor(diff / (1000 * 60 * 60));
|
|
28
|
-
const minutes = Math.floor((diff % (1000 * 60 * 60)) / (1000 * 60));
|
|
29
|
-
|
|
30
|
-
if (hours > 24) {
|
|
31
|
-
const days = Math.floor(hours / 24);
|
|
32
|
-
timeLeft = `${days}d left`;
|
|
33
|
-
urgency = 'normal';
|
|
34
|
-
} else if (hours > 0) {
|
|
35
|
-
timeLeft = `${hours}h ${minutes}m left`;
|
|
36
|
-
urgency = hours < 2 ? 'warning' : 'normal';
|
|
37
|
-
} else {
|
|
38
|
-
timeLeft = `${minutes}m left`;
|
|
39
|
-
urgency = minutes < 15 ? 'critical' : 'warning';
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// Schedule next update using setTimeout (not setInterval)
|
|
43
|
-
// This avoids interval-in-interval issues
|
|
44
|
-
scheduleNextUpdate();
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
function scheduleNextUpdate() {
|
|
48
|
-
cancelScheduledUpdate();
|
|
49
|
-
// Update every 10 seconds for critical, 60 seconds otherwise
|
|
50
|
-
const delayMs = urgency === 'critical' ? 10000 : 60000;
|
|
51
|
-
timeoutId = setTimeout(updateTimeLeft, delayMs);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function cancelScheduledUpdate() {
|
|
55
|
-
if (timeoutId !== null) {
|
|
56
|
-
clearTimeout(timeoutId);
|
|
57
|
-
timeoutId = null;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
onMount(() => {
|
|
62
|
-
updateTimeLeft();
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
onDestroy(cancelScheduledUpdate);
|
|
66
|
-
</script>
|
|
67
|
-
|
|
68
|
-
<div
|
|
69
|
-
class="authrim-expiry authrim-expiry--{urgency} {className}"
|
|
70
|
-
{...$$restProps}
|
|
71
|
-
>
|
|
72
|
-
<svg class="authrim-expiry__icon" viewBox="0 0 16 16" fill="currentColor">
|
|
73
|
-
<path fill-rule="evenodd" d="M8 0a8 8 0 100 16A8 8 0 008 0zM4.5 8a.75.75 0 01.75-.75h2.25V4.5a.75.75 0 011.5 0v3.25a.75.75 0 01-.75.75H5.25A.75.75 0 014.5 8z" clip-rule="evenodd"/>
|
|
74
|
-
</svg>
|
|
75
|
-
<span class="authrim-expiry__text">{timeLeft}</span>
|
|
76
|
-
</div>
|
|
77
|
-
|
|
78
|
-
<style>
|
|
79
|
-
.authrim-expiry {
|
|
80
|
-
display: inline-flex;
|
|
81
|
-
align-items: center;
|
|
82
|
-
gap: var(--authrim-space-1);
|
|
83
|
-
margin-top: var(--authrim-space-2);
|
|
84
|
-
font-size: var(--authrim-text-xs);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
.authrim-expiry--normal {
|
|
88
|
-
color: var(--authrim-color-text-muted);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
.authrim-expiry--warning {
|
|
92
|
-
color: var(--authrim-color-warning-text);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
.authrim-expiry--critical {
|
|
96
|
-
color: var(--authrim-color-error-text);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
.authrim-expiry__icon {
|
|
100
|
-
width: 12px;
|
|
101
|
-
height: 12px;
|
|
102
|
-
flex-shrink: 0;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
.authrim-expiry__text {
|
|
106
|
-
font-weight: 500;
|
|
107
|
-
letter-spacing: var(--authrim-tracking-tight);
|
|
108
|
-
}
|
|
109
|
-
</style>
|
|
1
|
+
<!--
|
|
2
|
+
SessionExpiryIndicator Component
|
|
3
|
+
Shows session expiry time with visual indicator
|
|
4
|
+
-->
|
|
5
|
+
<script lang="ts">
|
|
6
|
+
import { onMount, onDestroy } from 'svelte';
|
|
7
|
+
|
|
8
|
+
export let expiresAt: Date;
|
|
9
|
+
let className = '';
|
|
10
|
+
export { className as class };
|
|
11
|
+
|
|
12
|
+
let timeLeft = '';
|
|
13
|
+
let urgency: 'normal' | 'warning' | 'critical' = 'normal';
|
|
14
|
+
let timeoutId: ReturnType<typeof setTimeout> | null = null;
|
|
15
|
+
|
|
16
|
+
function updateTimeLeft() {
|
|
17
|
+
const now = Date.now();
|
|
18
|
+
const expiry = expiresAt.getTime();
|
|
19
|
+
const diff = expiry - now;
|
|
20
|
+
|
|
21
|
+
if (diff <= 0) {
|
|
22
|
+
timeLeft = 'Expired';
|
|
23
|
+
urgency = 'critical';
|
|
24
|
+
return; // Don't schedule next update when expired
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const hours = Math.floor(diff / (1000 * 60 * 60));
|
|
28
|
+
const minutes = Math.floor((diff % (1000 * 60 * 60)) / (1000 * 60));
|
|
29
|
+
|
|
30
|
+
if (hours > 24) {
|
|
31
|
+
const days = Math.floor(hours / 24);
|
|
32
|
+
timeLeft = `${days}d left`;
|
|
33
|
+
urgency = 'normal';
|
|
34
|
+
} else if (hours > 0) {
|
|
35
|
+
timeLeft = `${hours}h ${minutes}m left`;
|
|
36
|
+
urgency = hours < 2 ? 'warning' : 'normal';
|
|
37
|
+
} else {
|
|
38
|
+
timeLeft = `${minutes}m left`;
|
|
39
|
+
urgency = minutes < 15 ? 'critical' : 'warning';
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Schedule next update using setTimeout (not setInterval)
|
|
43
|
+
// This avoids interval-in-interval issues
|
|
44
|
+
scheduleNextUpdate();
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function scheduleNextUpdate() {
|
|
48
|
+
cancelScheduledUpdate();
|
|
49
|
+
// Update every 10 seconds for critical, 60 seconds otherwise
|
|
50
|
+
const delayMs = urgency === 'critical' ? 10000 : 60000;
|
|
51
|
+
timeoutId = setTimeout(updateTimeLeft, delayMs);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function cancelScheduledUpdate() {
|
|
55
|
+
if (timeoutId !== null) {
|
|
56
|
+
clearTimeout(timeoutId);
|
|
57
|
+
timeoutId = null;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
onMount(() => {
|
|
62
|
+
updateTimeLeft();
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
onDestroy(cancelScheduledUpdate);
|
|
66
|
+
</script>
|
|
67
|
+
|
|
68
|
+
<div
|
|
69
|
+
class="authrim-expiry authrim-expiry--{urgency} {className}"
|
|
70
|
+
{...$$restProps}
|
|
71
|
+
>
|
|
72
|
+
<svg class="authrim-expiry__icon" viewBox="0 0 16 16" fill="currentColor">
|
|
73
|
+
<path fill-rule="evenodd" d="M8 0a8 8 0 100 16A8 8 0 008 0zM4.5 8a.75.75 0 01.75-.75h2.25V4.5a.75.75 0 011.5 0v3.25a.75.75 0 01-.75.75H5.25A.75.75 0 014.5 8z" clip-rule="evenodd"/>
|
|
74
|
+
</svg>
|
|
75
|
+
<span class="authrim-expiry__text">{timeLeft}</span>
|
|
76
|
+
</div>
|
|
77
|
+
|
|
78
|
+
<style>
|
|
79
|
+
.authrim-expiry {
|
|
80
|
+
display: inline-flex;
|
|
81
|
+
align-items: center;
|
|
82
|
+
gap: var(--authrim-space-1);
|
|
83
|
+
margin-top: var(--authrim-space-2);
|
|
84
|
+
font-size: var(--authrim-text-xs);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.authrim-expiry--normal {
|
|
88
|
+
color: var(--authrim-color-text-muted);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.authrim-expiry--warning {
|
|
92
|
+
color: var(--authrim-color-warning-text);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.authrim-expiry--critical {
|
|
96
|
+
color: var(--authrim-color-error-text);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.authrim-expiry__icon {
|
|
100
|
+
width: 12px;
|
|
101
|
+
height: 12px;
|
|
102
|
+
flex-shrink: 0;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.authrim-expiry__text {
|
|
106
|
+
font-weight: 500;
|
|
107
|
+
letter-spacing: var(--authrim-tracking-tight);
|
|
108
|
+
}
|
|
109
|
+
</style>
|