@axium/client 0.39.5 → 0.39.6
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/user.d.ts +2 -1
- package/dist/user.js +4 -0
- package/lib/SessionList.svelte +36 -11
- package/locales/en.json +3 -1
- package/package.json +2 -2
- package/styles/account.css +3 -2
package/dist/user.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AuthInfo, NewSessionResponse, Passkey, PasskeyChangeable, Session, User, UserChangeable, UserPublic, Verification } from '@axium/core';
|
|
1
|
+
import type { AuthInfo, NewSessionResponse, Passkey, PasskeyChangeable, Session, SessionChangeable, User, UserChangeable, UserPublic, Verification } from '@axium/core';
|
|
2
2
|
import * as z from 'zod';
|
|
3
3
|
import Cache from './cache.js';
|
|
4
4
|
export declare function login(userId: string): Promise<NewSessionResponse>;
|
|
@@ -16,6 +16,7 @@ export declare function currentSession(): Promise<(Session & {
|
|
|
16
16
|
}) | null>;
|
|
17
17
|
export declare function extendCurrentSession(userId: string): Promise<void>;
|
|
18
18
|
export declare function getSessions(userId: string): Promise<Session[]>;
|
|
19
|
+
export declare function updateSession(userId: string, data: SessionChangeable): Promise<Session>;
|
|
19
20
|
export declare function logout(userId: string, ...sessionId: string[]): Promise<Session[]>;
|
|
20
21
|
export declare function logoutAll(userId: string): Promise<Session[]>;
|
|
21
22
|
export declare function logoutCurrentSession(): Promise<Session>;
|
package/dist/user.js
CHANGED
|
@@ -47,6 +47,10 @@ export async function getSessions(userId) {
|
|
|
47
47
|
_checkId(userId);
|
|
48
48
|
return await fetchAPI('GET', 'users/:id/sessions', {}, userId);
|
|
49
49
|
}
|
|
50
|
+
export async function updateSession(userId, data) {
|
|
51
|
+
_checkId(userId);
|
|
52
|
+
return await fetchAPI('PATCH', 'users/:id/sessions', data, userId);
|
|
53
|
+
}
|
|
50
54
|
export async function logout(userId, ...sessionId) {
|
|
51
55
|
_checkId(userId);
|
|
52
56
|
return await fetchAPI('DELETE', 'users/:id/sessions', { id: sessionId }, userId);
|
package/lib/SessionList.svelte
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { logout, logoutAll, text } from '@axium/client';
|
|
2
|
+
import { logout, logoutAll, text, updateSession } from '@axium/client';
|
|
3
3
|
import type { Session, User } from '@axium/core';
|
|
4
|
+
import { SessionChangeable } from '@axium/core/user';
|
|
4
5
|
import FormDialog from './FormDialog.svelte';
|
|
5
6
|
import Icon from './Icon.svelte';
|
|
7
|
+
import InlineEdit from './InlineEdit.svelte';
|
|
8
|
+
import { toastStatus } from './toast.js';
|
|
6
9
|
|
|
7
10
|
let {
|
|
8
11
|
sessions = $bindable(),
|
|
@@ -10,21 +13,43 @@
|
|
|
10
13
|
user,
|
|
11
14
|
redirectAfterLogoutAll = false,
|
|
12
15
|
}: { sessions: Session[]; currentSession?: Session; user: User; redirectAfterLogoutAll?: boolean } = $props();
|
|
16
|
+
|
|
17
|
+
let editing = $state<string>();
|
|
13
18
|
</script>
|
|
14
19
|
|
|
15
20
|
{#each sessions as session}
|
|
16
21
|
<div class="item session">
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
{#if editing == session.id}
|
|
23
|
+
<InlineEdit
|
|
24
|
+
value={session.name}
|
|
25
|
+
schema={SessionChangeable.shape.name}
|
|
26
|
+
placeholder={text('SessionList.rename_placeholder')}
|
|
27
|
+
commit={name =>
|
|
28
|
+
toastStatus(
|
|
29
|
+
updateSession(user.id, { id: session.id, name }).then(updated => {
|
|
30
|
+
sessions = sessions.map(s => (s.id == updated.id ? updated : s));
|
|
31
|
+
}),
|
|
32
|
+
text('SessionList.toast_renamed')
|
|
33
|
+
)}
|
|
34
|
+
close={() => (editing = undefined)}
|
|
35
|
+
/>
|
|
36
|
+
{:else}
|
|
37
|
+
<p>
|
|
38
|
+
{session.name || `${session.id.slice(0, 4)}...${session.id.slice(-4)}`}
|
|
39
|
+
{#if session.id == currentSession?.id}
|
|
40
|
+
<span class="current">{text('SessionList.current')}</span>
|
|
41
|
+
{/if}
|
|
42
|
+
{#if session.elevated}
|
|
43
|
+
<span class="elevated">{text('SessionList.elevated')}</span>
|
|
44
|
+
{/if}
|
|
45
|
+
</p>
|
|
46
|
+
{/if}
|
|
26
47
|
<p class="timestamp">{text('SessionList.created', { date: session.created.toLocaleString() })}</p>
|
|
27
48
|
<p class="timestamp">{text('SessionList.expires', { date: session.expires.toLocaleString() })}</p>
|
|
49
|
+
<button onclick={() => (editing = session.id)} class="rename icon-text">
|
|
50
|
+
<Icon i="pen" --size="16px" />
|
|
51
|
+
<span class="mobile-only">{text('generic.rename')}</span>
|
|
52
|
+
</button>
|
|
28
53
|
<button command="show-modal" commandfor={'logout-session:' + session.id} class="logout icon-text">
|
|
29
54
|
<Icon i="right-from-bracket" --size="16px" />
|
|
30
55
|
<span class="mobile-only">{text('generic.logout')}</span>
|
|
@@ -53,7 +78,7 @@
|
|
|
53
78
|
</FormDialog>
|
|
54
79
|
|
|
55
80
|
<style>
|
|
56
|
-
button.logout {
|
|
81
|
+
button:is(.logout, .rename) {
|
|
57
82
|
width: fit-content;
|
|
58
83
|
text-align: center;
|
|
59
84
|
}
|
package/locales/en.json
CHANGED
|
@@ -41,7 +41,9 @@
|
|
|
41
41
|
"logout_all_question": "Are you sure you want to log out all sessions?",
|
|
42
42
|
"logout_all_submit": "Logout All Sessions",
|
|
43
43
|
"logout_all_trigger": "Logout All",
|
|
44
|
-
"logout_single": "Are you sure you want to log out this session?"
|
|
44
|
+
"logout_single": "Are you sure you want to log out this session?",
|
|
45
|
+
"rename_placeholder": "Session name",
|
|
46
|
+
"toast_renamed": "Session renamed"
|
|
45
47
|
},
|
|
46
48
|
"Upload": {
|
|
47
49
|
"upload": "Upload"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@axium/client",
|
|
3
|
-
"version": "0.39.
|
|
3
|
+
"version": "0.39.6",
|
|
4
4
|
"author": "James Prevett <jp@jamespre.dev>",
|
|
5
5
|
"funding": {
|
|
6
6
|
"type": "individual",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"build": "tsc"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
|
-
"@axium/core": ">=0.41.
|
|
52
|
+
"@axium/core": ">=0.41.3",
|
|
53
53
|
"ioium": "^1.7.0",
|
|
54
54
|
"semver": "^7.7.4",
|
|
55
55
|
"svelte": "^5.36.0",
|
package/styles/account.css
CHANGED
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
.session {
|
|
73
|
-
grid-template-columns: 1fr 15em 15em 1em;
|
|
73
|
+
grid-template-columns: 1fr 15em 15em 1em 1em;
|
|
74
74
|
|
|
75
75
|
.current {
|
|
76
76
|
border-radius: 2em;
|
|
@@ -84,7 +84,8 @@
|
|
|
84
84
|
background-color: #733;
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
.logout
|
|
87
|
+
.logout,
|
|
88
|
+
.rename {
|
|
88
89
|
display: contents;
|
|
89
90
|
}
|
|
90
91
|
}
|