@frigear-nu/account 0.6.2 → 0.6.4
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/module.json +1 -1
- package/dist/module.mjs +16 -16
- package/dist/runtime/app/components/Account/AccountAvatarField.d.vue.ts +3 -0
- package/dist/runtime/app/components/Account/AccountAvatarField.vue +112 -0
- package/dist/runtime/app/components/Account/AccountAvatarField.vue.d.ts +3 -0
- package/dist/runtime/app/components/Account/AccountMenu.d.vue.ts +1 -1
- package/dist/runtime/app/components/Account/AccountMenu.vue +8 -10
- package/dist/runtime/app/components/Account/AccountMenu.vue.d.ts +1 -1
- package/dist/runtime/app/components/Account/AccountSignedInApps.vue +3 -1
- package/dist/runtime/app/composables/index.d.ts +2 -0
- package/dist/runtime/app/composables/index.js +1 -0
- package/dist/runtime/app/composables/useAccount.d.ts +6 -0
- package/dist/runtime/app/composables/useAccount.js +15 -1
- package/dist/runtime/app/composables/useAccountAreas.d.ts +21 -0
- package/dist/runtime/app/composables/useAccountAreas.js +12 -0
- package/dist/runtime/app/middleware/preload.js +6 -0
- package/dist/runtime/app/pages/api-tokens.vue +31 -28
- package/dist/runtime/app/pages/index.vue +9 -0
- package/dist/runtime/app/pages/profile.vue +122 -23
- package/dist/runtime/app/pages/security.vue +2 -1
- package/dist/runtime/app/plugins/preload.client.js +5 -0
- package/dist/runtime/app/utils/avatar-image.d.ts +34 -0
- package/dist/runtime/app/utils/avatar-image.js +61 -0
- package/dist/runtime/app/utils/mcp-connect.d.ts +27 -0
- package/dist/runtime/app/utils/mcp-connect.js +70 -0
- package/dist/runtime/app/utils/profile.d.ts +9 -3
- package/dist/runtime/app/utils/profile.js +3 -1
- package/dist/runtime/i18n/lang/da.json +72 -9
- package/dist/runtime/i18n/lang/en.json +71 -8
- package/dist/runtime/menus.js +1 -2
- package/dist/runtime/utils/areas.d.ts +7 -0
- package/dist/runtime/utils/areas.js +4 -0
- package/package.json +15 -11
- package/dist/runtime/app/middleware/bootstrap.js +0 -6
- package/dist/runtime/app/plugins/bootstrap.client.js +0 -5
- /package/dist/runtime/app/middleware/{bootstrap.d.ts → preload.d.ts} +0 -0
- /package/dist/runtime/app/plugins/{bootstrap.client.d.ts → preload.client.d.ts} +0 -0
|
@@ -1,61 +1,91 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import { z } from "zod";
|
|
3
|
-
import { USER_PHONE_MAX_LENGTH, USER_PHONE_PATTERN } from "@frigear-nu/users/api";
|
|
3
|
+
import { USER_NICKNAME_MAX_LENGTH, USER_PEOPLE_NUMBER_MAX_LENGTH, USER_PHONE_MAX_LENGTH, USER_PHONE_PATTERN } from "@frigear-nu/users/api";
|
|
4
|
+
import { phoneIssue } from "@frigear-nu/ui/phone";
|
|
4
5
|
import AccountChangeEmailSlideover from "../components/Account/AccountChangeEmailSlideover.vue";
|
|
5
6
|
import { PROFILE_NO_LOCALE as NO_LOCALE, profileChanges } from "../utils/profile";
|
|
6
|
-
import { computed, reactive, ref, useAccount, useAction, useModuleT, useNuxtApp, useOverlay, useRoute, useToast, useUserSession, watch } from "#imports";
|
|
7
|
+
import { computed, reactive, ref, resolveComponent, useAccount, useAction, useModuleT, useNuxtApp, useOverlay, useRoute, useRuntimeConfig, useToast, useUserSession, watch } from "#imports";
|
|
7
8
|
defineOptions({ name: "AccountProfilePage" });
|
|
8
9
|
const t = useModuleT("account.profile");
|
|
10
|
+
const WidgetArea = resolveComponent("WidgetArea");
|
|
11
|
+
const widgetArea = typeof WidgetArea === "string" ? void 0 : WidgetArea;
|
|
9
12
|
const toast = useToast();
|
|
10
13
|
const route = useRoute();
|
|
11
14
|
const { user } = useUserSession();
|
|
12
15
|
const { updateProfileDetails } = useAccount();
|
|
16
|
+
const avatarUpload = useRuntimeConfig().public.users?.avatarUpload === true;
|
|
13
17
|
const { $i18n } = useNuxtApp();
|
|
14
18
|
const localeItems = computed(() => {
|
|
15
19
|
const locales = ($i18n?.locales.value ?? []).map((locale) => typeof locale === "string" ? { value: locale, label: locale } : { value: locale.code, label: locale.name || locale.code });
|
|
16
20
|
return locales.length ? [{ value: NO_LOCALE, label: t("locale.none", "Not set") }, ...locales] : [];
|
|
17
21
|
});
|
|
18
|
-
const
|
|
22
|
+
const baseSchema = z.object({
|
|
19
23
|
name: z.string().trim().min(1, t("name.required", "Please enter your name.")),
|
|
20
|
-
|
|
24
|
+
nickname: z.string().trim().max(USER_NICKNAME_MAX_LENGTH, t("nickname.tooLong", "Use at most {max} characters.", { max: USER_NICKNAME_MAX_LENGTH })).optional(),
|
|
25
|
+
// The server's rule, imported from `@frigear-nu/users`, and a full international number (`PhoneInput` writes
|
|
26
|
+
// `+4512345678`); empty clears it. A number stored before the country selector passes until it is changed.
|
|
27
|
+
phone: z.string().trim().max(USER_PHONE_MAX_LENGTH).regex(USER_PHONE_PATTERN, t("phone.invalid", "Enter a valid phone number.")).refine((value) => !value || value === saved.value.phone || !phoneIssue(value), t("phone.invalid", "Enter a valid phone number.")).optional(),
|
|
28
|
+
peopleNumber: z.string().trim().max(USER_PEOPLE_NUMBER_MAX_LENGTH, t("peopleNumber.tooLong", "Use at most {max} characters.", { max: USER_PEOPLE_NUMBER_MAX_LENGTH })).optional()
|
|
29
|
+
});
|
|
30
|
+
const schema = avatarUpload ? baseSchema : baseSchema.extend({
|
|
21
31
|
avatar: z.union([
|
|
22
32
|
z.literal(""),
|
|
23
33
|
z.url({ protocol: /^https?$/, message: t("avatar.invalid", "Enter a valid URL.") }).max(2048, t("avatar.invalid", "Enter a valid URL."))
|
|
24
|
-
]).optional()
|
|
25
|
-
// The server's rule, imported from `@frigear-nu/users`: digits, spaces and `+-().`; empty clears it.
|
|
26
|
-
phone: z.string().trim().max(USER_PHONE_MAX_LENGTH).regex(USER_PHONE_PATTERN, t("phone.invalid", "Enter a phone number of digits, spaces and + - ( ).")).optional()
|
|
34
|
+
]).optional()
|
|
27
35
|
});
|
|
36
|
+
const sessionField = (key) => user.value?.[key];
|
|
28
37
|
const sessionText = (key) => {
|
|
29
|
-
const value =
|
|
38
|
+
const value = sessionField(key);
|
|
30
39
|
return typeof value === "string" ? value : "";
|
|
31
40
|
};
|
|
32
|
-
const
|
|
41
|
+
const ALL_FIELDS = ["name", "nickname", "avatar", "phone", "peopleNumber", "locale"];
|
|
42
|
+
const FIELDS = avatarUpload ? ALL_FIELDS.filter((key) => key !== "avatar") : ALL_FIELDS;
|
|
43
|
+
const saved = computed(() => ({
|
|
33
44
|
name: user.value?.name ?? "",
|
|
45
|
+
nickname: sessionText("nickname"),
|
|
34
46
|
avatar: user.value?.avatar ?? "",
|
|
35
47
|
phone: sessionText("phone"),
|
|
48
|
+
peopleNumber: sessionText("peopleNumber"),
|
|
36
49
|
locale: sessionText("locale") || NO_LOCALE
|
|
37
|
-
});
|
|
38
|
-
const
|
|
50
|
+
}));
|
|
51
|
+
const state = reactive({ ...saved.value });
|
|
39
52
|
let lastSynced = { ...saved.value };
|
|
40
53
|
watch(saved, (next) => {
|
|
41
|
-
const pristine =
|
|
54
|
+
const pristine = FIELDS.every((key) => state[key] === lastSynced[key]);
|
|
42
55
|
lastSynced = { ...next };
|
|
43
|
-
if (pristine)
|
|
44
|
-
state.name = next.name;
|
|
45
|
-
state.avatar = next.avatar;
|
|
46
|
-
state.phone = next.phone;
|
|
47
|
-
state.locale = next.locale;
|
|
48
|
-
}
|
|
56
|
+
if (pristine) Object.assign(state, next);
|
|
49
57
|
});
|
|
50
|
-
const dirty = computed(() =>
|
|
58
|
+
const dirty = computed(() => FIELDS.some((key) => (key === "name" || key === "locale" || key === "avatar" ? state[key] : state[key].trim()) !== saved.value[key]));
|
|
51
59
|
const profileAction = useAction();
|
|
52
60
|
function onSubmitProfile(event) {
|
|
53
|
-
const body = profileChanges({
|
|
61
|
+
const body = profileChanges({
|
|
62
|
+
...event.data,
|
|
63
|
+
nickname: event.data.nickname ?? "",
|
|
64
|
+
avatar: avatarUpload ? void 0 : event.data.avatar ?? "",
|
|
65
|
+
phone: event.data.phone ?? "",
|
|
66
|
+
peopleNumber: event.data.peopleNumber ?? "",
|
|
67
|
+
locale: state.locale
|
|
68
|
+
}, saved.value, { localeChoice: localeItems.value.length > 0 });
|
|
54
69
|
return profileAction.run(
|
|
55
70
|
() => updateProfileDetails(body),
|
|
56
71
|
{ success: t("saved", "Profile updated"), error: t("saveFailed", "Could not update your profile.") }
|
|
57
72
|
);
|
|
58
73
|
}
|
|
74
|
+
const media = reactive({ photoOptOut: sessionField("photoOptOut") === true, tagOptOut: sessionField("tagOptOut") === true });
|
|
75
|
+
watch(() => [sessionField("photoOptOut"), sessionField("tagOptOut")], ([photo, tag]) => {
|
|
76
|
+
media.photoOptOut = photo === true;
|
|
77
|
+
media.tagOptOut = tag === true;
|
|
78
|
+
});
|
|
79
|
+
const mediaAction = useAction();
|
|
80
|
+
async function onMediaChange(key, value) {
|
|
81
|
+
const before = media[key];
|
|
82
|
+
media[key] = value;
|
|
83
|
+
const result = await mediaAction.run(
|
|
84
|
+
() => updateProfileDetails({ [key]: value }),
|
|
85
|
+
{ success: t("media.saved", "Photo choices saved"), error: t("media.saveFailed", "Could not save your photo choices.") }
|
|
86
|
+
);
|
|
87
|
+
if (result === void 0) media[key] = before;
|
|
88
|
+
}
|
|
59
89
|
const emailVerificationSent = ref(false);
|
|
60
90
|
const emailChanged = computed(() => route.query["email-changed"] === "1");
|
|
61
91
|
const emailChangeFailed = computed(() => route.query.error === "email-change");
|
|
@@ -108,6 +138,13 @@ async function onChangeEmail() {
|
|
|
108
138
|
class="flex flex-col divide-y divide-default"
|
|
109
139
|
@submit="onSubmitProfile"
|
|
110
140
|
>
|
|
141
|
+
<FormRow
|
|
142
|
+
v-if="avatarUpload"
|
|
143
|
+
:label="t('avatar.label', 'Avatar')"
|
|
144
|
+
:description="t('avatar.hint', 'Saved as soon as you choose a photo.')"
|
|
145
|
+
>
|
|
146
|
+
<AccountAvatarField />
|
|
147
|
+
</FormRow>
|
|
111
148
|
<FormRow
|
|
112
149
|
name="name"
|
|
113
150
|
:label="t('name.label', 'Name')"
|
|
@@ -121,6 +158,18 @@ async function onChangeEmail() {
|
|
|
121
158
|
/>
|
|
122
159
|
</FormRow>
|
|
123
160
|
<FormRow
|
|
161
|
+
name="nickname"
|
|
162
|
+
:label="t('nickname.label', 'Nickname')"
|
|
163
|
+
:description="t('nickname.description', 'What you like to be called. Shown next to your name.')"
|
|
164
|
+
>
|
|
165
|
+
<UInput
|
|
166
|
+
v-model="state.nickname"
|
|
167
|
+
autocomplete="nickname"
|
|
168
|
+
class="w-full"
|
|
169
|
+
/>
|
|
170
|
+
</FormRow>
|
|
171
|
+
<FormRow
|
|
172
|
+
v-if="!avatarUpload"
|
|
124
173
|
name="avatar"
|
|
125
174
|
:label="t('avatar.label', 'Avatar')"
|
|
126
175
|
:description="t('avatar.description', 'Link to a square image.')"
|
|
@@ -145,11 +194,21 @@ async function onChangeEmail() {
|
|
|
145
194
|
name="phone"
|
|
146
195
|
:label="t('phone.label', 'Phone')"
|
|
147
196
|
:description="t('phone.description', 'For text messages. Only staff who need it can see it.')"
|
|
197
|
+
>
|
|
198
|
+
<PhoneInput
|
|
199
|
+
:model-value="state.phone"
|
|
200
|
+
:country-label="t('phone.country', 'Country')"
|
|
201
|
+
@update:model-value="state.phone = $event ?? ''"
|
|
202
|
+
/>
|
|
203
|
+
</FormRow>
|
|
204
|
+
<FormRow
|
|
205
|
+
name="peopleNumber"
|
|
206
|
+
:label="t('peopleNumber.label', 'People number')"
|
|
207
|
+
:description="t('peopleNumber.description', 'Your number in the volunteer system we use, if you have one. Only staff who need it can see it.')"
|
|
148
208
|
>
|
|
149
209
|
<UInput
|
|
150
|
-
v-model="state.
|
|
151
|
-
|
|
152
|
-
autocomplete="tel"
|
|
210
|
+
v-model="state.peopleNumber"
|
|
211
|
+
autocomplete="off"
|
|
153
212
|
class="w-full"
|
|
154
213
|
/>
|
|
155
214
|
</FormRow>
|
|
@@ -179,6 +238,38 @@ async function onChangeEmail() {
|
|
|
179
238
|
</template>
|
|
180
239
|
</SectionCard>
|
|
181
240
|
|
|
241
|
+
<SectionCard
|
|
242
|
+
:title="t('media.title', 'Photos and tagging')"
|
|
243
|
+
:description="t('media.description', 'Tell photographers and the people who post about us what you prefer. You can still appear in photos where you are not the main focus, such as crowd shots.')"
|
|
244
|
+
>
|
|
245
|
+
<div class="flex flex-col divide-y divide-default">
|
|
246
|
+
<FormRow
|
|
247
|
+
name="photoOptOut"
|
|
248
|
+
:label="t('media.photo.label', 'No photos of me')"
|
|
249
|
+
:description="t('media.photo.description', 'Do not take photos with me as the main subject.')"
|
|
250
|
+
>
|
|
251
|
+
<SwitchToggle
|
|
252
|
+
:model-value="media.photoOptOut"
|
|
253
|
+
:disabled="mediaAction.busy.value"
|
|
254
|
+
:aria-label="t('media.photo.label', 'No photos of me')"
|
|
255
|
+
@update:model-value="(value) => onMediaChange('photoOptOut', value)"
|
|
256
|
+
/>
|
|
257
|
+
</FormRow>
|
|
258
|
+
<FormRow
|
|
259
|
+
name="tagOptOut"
|
|
260
|
+
:label="t('media.tag.label', 'No tagging')"
|
|
261
|
+
:description="t('media.tag.description', 'Do not tag or name me in posts and photos online.')"
|
|
262
|
+
>
|
|
263
|
+
<SwitchToggle
|
|
264
|
+
:model-value="media.tagOptOut"
|
|
265
|
+
:disabled="mediaAction.busy.value"
|
|
266
|
+
:aria-label="t('media.tag.label', 'No tagging')"
|
|
267
|
+
@update:model-value="(value) => onMediaChange('tagOptOut', value)"
|
|
268
|
+
/>
|
|
269
|
+
</FormRow>
|
|
270
|
+
</div>
|
|
271
|
+
</SectionCard>
|
|
272
|
+
|
|
182
273
|
<SectionCard
|
|
183
274
|
:title="t('email.label', 'Email')"
|
|
184
275
|
:description="t('email.description', 'Where we send messages and how you sign in.')"
|
|
@@ -203,5 +294,13 @@ async function onChangeEmail() {
|
|
|
203
294
|
</div>
|
|
204
295
|
</template>
|
|
205
296
|
</SectionCard>
|
|
297
|
+
|
|
298
|
+
<component
|
|
299
|
+
:is="widgetArea"
|
|
300
|
+
v-if="widgetArea"
|
|
301
|
+
name="account.profile"
|
|
302
|
+
:context="{ user }"
|
|
303
|
+
grid-class="flex flex-col gap-4"
|
|
304
|
+
/>
|
|
206
305
|
</div>
|
|
207
306
|
</template>
|
|
@@ -152,9 +152,10 @@ const passkeyMenu = (passkey) => [[
|
|
|
152
152
|
flush
|
|
153
153
|
>
|
|
154
154
|
<template #actions>
|
|
155
|
-
<
|
|
155
|
+
<TooltipButton
|
|
156
156
|
icon="i-lucide-plus"
|
|
157
157
|
:label="t('passkeys.add', 'Add passkey')"
|
|
158
|
+
:tooltip="t('passkeys.addHint', 'Register this device so you can sign in without a password')"
|
|
158
159
|
@click="onAddPasskey"
|
|
159
160
|
/>
|
|
160
161
|
</template>
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/** The side of the stored avatar, in pixels. */
|
|
2
|
+
export declare const AVATAR_SIZE = 512;
|
|
3
|
+
/** Files above this are refused before decoding, so a huge photo never freezes the tab. */
|
|
4
|
+
export declare const AVATAR_MAX_SOURCE_BYTES: number;
|
|
5
|
+
/** The `accept` of the file input: the formats every browser decodes first, then any image. */
|
|
6
|
+
export declare const AVATAR_ACCEPT = "image/png,image/jpeg,image/webp,image/*";
|
|
7
|
+
/** Why a chosen file cannot become an avatar. */
|
|
8
|
+
export type AvatarFileProblem = 'wrong_type' | 'too_large';
|
|
9
|
+
/** Thrown by {@link squareAvatar}; `problem` says why. */
|
|
10
|
+
export declare class AvatarImageError extends Error {
|
|
11
|
+
readonly problem: AvatarFileProblem;
|
|
12
|
+
constructor(problem: AvatarFileProblem);
|
|
13
|
+
}
|
|
14
|
+
/** Checks a chosen file before it is decoded: an image of at most `maxBytes`. */
|
|
15
|
+
export declare function avatarFileProblem(file: Pick<File, 'type' | 'size'>, maxBytes?: number): AvatarFileProblem | null;
|
|
16
|
+
/**
|
|
17
|
+
* The problem behind a failed upload, from the server's `data.code` (`unsupported_media_type`, `file_too_large`) or
|
|
18
|
+
* else its status (415, 413), so the page can say it in the user's language; `null` for any other error.
|
|
19
|
+
*/
|
|
20
|
+
export declare function avatarUploadProblem(error: unknown): AvatarFileProblem | null;
|
|
21
|
+
/** The largest centred square of a `width` x `height` image: where to cut it (`sx`, `sy`) and its side. */
|
|
22
|
+
export declare function centreSquare(width: number, height: number): {
|
|
23
|
+
sx: number;
|
|
24
|
+
sy: number;
|
|
25
|
+
side: number;
|
|
26
|
+
};
|
|
27
|
+
/** The side of the output: `size`, or the image's own side when it is smaller (never scaled up). */
|
|
28
|
+
export declare function avatarOutputSide(side: number, size?: number): number;
|
|
29
|
+
/**
|
|
30
|
+
* Decodes `file`, cuts the centred square, scales it to `size` pixels and encodes it as WebP (quality 0.85), or as JPEG
|
|
31
|
+
* when the browser produced something else (Safari answers a WebP request with PNG). Throws {@link AvatarImageError}
|
|
32
|
+
* for a file that is not an image, is too large, or cannot be decoded.
|
|
33
|
+
*/
|
|
34
|
+
export declare function squareAvatar(file: File, size?: number): Promise<File>;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
export const AVATAR_SIZE = 512;
|
|
2
|
+
export const AVATAR_MAX_SOURCE_BYTES = 20 * 1024 * 1024;
|
|
3
|
+
export const AVATAR_ACCEPT = "image/png,image/jpeg,image/webp,image/*";
|
|
4
|
+
export class AvatarImageError extends Error {
|
|
5
|
+
constructor(problem) {
|
|
6
|
+
super(problem);
|
|
7
|
+
this.problem = problem;
|
|
8
|
+
this.name = "AvatarImageError";
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export function avatarFileProblem(file, maxBytes = AVATAR_MAX_SOURCE_BYTES) {
|
|
12
|
+
if (!file.type.startsWith("image/")) return "wrong_type";
|
|
13
|
+
if (file.size > maxBytes) return "too_large";
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
export function avatarUploadProblem(error) {
|
|
17
|
+
if (error instanceof AvatarImageError) return error.problem;
|
|
18
|
+
if (!error || typeof error !== "object") return null;
|
|
19
|
+
const { statusCode, status, data } = error;
|
|
20
|
+
const code = data?.data?.code;
|
|
21
|
+
const httpStatus = statusCode ?? status;
|
|
22
|
+
if (code === "unsupported_media_type" || httpStatus === 415) return "wrong_type";
|
|
23
|
+
if (code === "file_too_large" || httpStatus === 413) return "too_large";
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
export function centreSquare(width, height) {
|
|
27
|
+
const side = Math.min(width, height);
|
|
28
|
+
return { sx: Math.floor((width - side) / 2), sy: Math.floor((height - side) / 2), side };
|
|
29
|
+
}
|
|
30
|
+
export function avatarOutputSide(side, size = AVATAR_SIZE) {
|
|
31
|
+
return Math.max(1, Math.min(side, size));
|
|
32
|
+
}
|
|
33
|
+
const encode = (canvas, type, quality) => new Promise((resolve) => canvas.toBlob(resolve, type, quality));
|
|
34
|
+
export async function squareAvatar(file, size = AVATAR_SIZE) {
|
|
35
|
+
const problem = avatarFileProblem(file);
|
|
36
|
+
if (problem) throw new AvatarImageError(problem);
|
|
37
|
+
let bitmap;
|
|
38
|
+
try {
|
|
39
|
+
bitmap = await createImageBitmap(file);
|
|
40
|
+
} catch {
|
|
41
|
+
throw new AvatarImageError("wrong_type");
|
|
42
|
+
}
|
|
43
|
+
try {
|
|
44
|
+
const { sx, sy, side } = centreSquare(bitmap.width, bitmap.height);
|
|
45
|
+
const out = avatarOutputSide(side, size);
|
|
46
|
+
const canvas = document.createElement("canvas");
|
|
47
|
+
canvas.width = out;
|
|
48
|
+
canvas.height = out;
|
|
49
|
+
const context = canvas.getContext("2d");
|
|
50
|
+
if (!context) throw new AvatarImageError("wrong_type");
|
|
51
|
+
context.imageSmoothingQuality = "high";
|
|
52
|
+
context.drawImage(bitmap, sx, sy, side, side, 0, 0, out, out);
|
|
53
|
+
let blob = await encode(canvas, "image/webp", 0.85);
|
|
54
|
+
if (blob?.type !== "image/webp") blob = await encode(canvas, "image/jpeg", 0.85);
|
|
55
|
+
if (!blob) throw new AvatarImageError("wrong_type");
|
|
56
|
+
const ext = blob.type === "image/webp" ? "webp" : "jpg";
|
|
57
|
+
return new File([blob], `avatar.${ext}`, { type: blob.type });
|
|
58
|
+
} finally {
|
|
59
|
+
bitmap.close();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
type Translate = (key: string, fallback: string, params?: Record<string, string | number>) => string;
|
|
2
|
+
export interface McpConnectTab {
|
|
3
|
+
label: string;
|
|
4
|
+
value: string;
|
|
5
|
+
steps: string;
|
|
6
|
+
code: string;
|
|
7
|
+
extraSteps?: string;
|
|
8
|
+
extraCode?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface McpConnectOptions {
|
|
11
|
+
/** The absolute MCP URL, e.g. `https://example.org/mcp`. */
|
|
12
|
+
url: string;
|
|
13
|
+
/** Whether clients sign in with OAuth there (`runtimeConfig.public.mcpModules.oauth`). */
|
|
14
|
+
oauth: boolean;
|
|
15
|
+
/** The API token to fill in, or a placeholder. */
|
|
16
|
+
token: string;
|
|
17
|
+
/** `useModuleT('account.apiTokens')`. */
|
|
18
|
+
t: Translate;
|
|
19
|
+
}
|
|
20
|
+
/** The name the snippets give the server in the client. */
|
|
21
|
+
export declare const MCP_SERVER_NAME = "frigear";
|
|
22
|
+
/**
|
|
23
|
+
* The tabs of the connect card. With OAuth every client adds the URL and signs the user in (Claude Code keeps the API
|
|
24
|
+
* token as an alternative); without it only clients that can send an `Authorization` header are listed, with the token.
|
|
25
|
+
*/
|
|
26
|
+
export declare function mcpConnectTabs({ url, oauth, token, t }: McpConnectOptions): McpConnectTab[];
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
export const MCP_SERVER_NAME = "frigear";
|
|
2
|
+
const json = (value) => JSON.stringify(value, null, 2);
|
|
3
|
+
export function mcpConnectTabs({ url, oauth, token, t }) {
|
|
4
|
+
const bearer = `Bearer ${token}`;
|
|
5
|
+
const tokenCommand = `claude mcp add --transport http ${MCP_SERVER_NAME} ${url} --header "Authorization: ${bearer}"`;
|
|
6
|
+
if (!oauth) {
|
|
7
|
+
return [
|
|
8
|
+
{
|
|
9
|
+
label: "Claude Code",
|
|
10
|
+
value: "claude-code",
|
|
11
|
+
steps: t("connect.token.claudeCode", "Claude Code: run this command with an API token from this page."),
|
|
12
|
+
code: tokenCommand
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
label: "VS Code",
|
|
16
|
+
value: "vscode",
|
|
17
|
+
steps: t("connect.token.vscode", "VS Code: add this to .vscode/mcp.json, with an API token from this page."),
|
|
18
|
+
code: json({ servers: { [MCP_SERVER_NAME]: { type: "http", url, headers: { Authorization: bearer } } } })
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
label: "Cursor",
|
|
22
|
+
value: "cursor",
|
|
23
|
+
steps: t("connect.token.cursor", "Cursor: add this to .cursor/mcp.json (or ~/.cursor/mcp.json), with an API token from this page."),
|
|
24
|
+
code: json({ mcpServers: { [MCP_SERVER_NAME]: { url, headers: { Authorization: bearer } } } })
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
label: t("connect.token.otherLabel", "Other clients"),
|
|
28
|
+
value: "other",
|
|
29
|
+
steps: t("connect.token.other", 'Other clients: connect to the URL below and send an API token from this page as the header "Authorization: Bearer TOKEN".'),
|
|
30
|
+
code: url
|
|
31
|
+
}
|
|
32
|
+
];
|
|
33
|
+
}
|
|
34
|
+
return [
|
|
35
|
+
{
|
|
36
|
+
label: "Claude",
|
|
37
|
+
value: "claude",
|
|
38
|
+
steps: t("connect.claude.steps", "Claude.ai and Claude Desktop: open Settings \u2192 Connectors \u2192 Add custom connector, paste the URL below, then choose Connect and sign in. No token needed."),
|
|
39
|
+
code: url
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
label: "ChatGPT",
|
|
43
|
+
value: "chatgpt",
|
|
44
|
+
steps: t("connect.chatgpt.steps", "ChatGPT: turn on Developer mode under Settings \u2192 Apps & Connectors \u2192 Advanced settings, then create a connector with the URL below and OAuth authentication, and sign in. No token needed."),
|
|
45
|
+
code: url
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
label: "Claude Code",
|
|
49
|
+
value: "claude-code",
|
|
50
|
+
steps: t("connect.claudeCode.steps", "Claude Code: run this command, then run /mcp in Claude Code, pick {name} and choose Authenticate to sign in.", { name: MCP_SERVER_NAME }),
|
|
51
|
+
code: `claude mcp add --transport http ${MCP_SERVER_NAME} ${url}`,
|
|
52
|
+
extraSteps: t("connect.claudeCode.token", "Or use an API token from this page instead of signing in:"),
|
|
53
|
+
extraCode: tokenCommand
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
label: "VS Code",
|
|
57
|
+
value: "vscode",
|
|
58
|
+
steps: t("connect.vscode.steps", "VS Code: run MCP: Add Server, choose HTTP and paste the URL below, then sign in when VS Code asks."),
|
|
59
|
+
code: url,
|
|
60
|
+
extraSteps: t("connect.vscode.file", "Or add it to .vscode/mcp.json:"),
|
|
61
|
+
extraCode: json({ servers: { [MCP_SERVER_NAME]: { type: "http", url } } })
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
label: "Cursor",
|
|
65
|
+
value: "cursor",
|
|
66
|
+
steps: t("connect.cursor.steps", "Cursor: add this to .cursor/mcp.json (or ~/.cursor/mcp.json), then choose Login next to {name} under Settings \u2192 MCP.", { name: MCP_SERVER_NAME }),
|
|
67
|
+
code: json({ mcpServers: { [MCP_SERVER_NAME]: { url } } })
|
|
68
|
+
}
|
|
69
|
+
];
|
|
70
|
+
}
|
|
@@ -2,8 +2,12 @@
|
|
|
2
2
|
export declare const PROFILE_NO_LOCALE = "-";
|
|
3
3
|
export interface ProfileFormValues {
|
|
4
4
|
name: string;
|
|
5
|
-
|
|
5
|
+
nickname: string;
|
|
6
|
+
/** Left out when the avatar is uploaded on its own (`users.avatarUpload`): the body then keeps the stored one. */
|
|
7
|
+
avatar?: string;
|
|
6
8
|
phone: string;
|
|
9
|
+
/** The user's id in an external system (`users.peopleNumber`). */
|
|
10
|
+
peopleNumber: string;
|
|
7
11
|
/** A locale code, or {@link PROFILE_NO_LOCALE}. */
|
|
8
12
|
locale: string;
|
|
9
13
|
}
|
|
@@ -16,7 +20,9 @@ export declare function profileChanges(values: ProfileFormValues, saved: Pick<Pr
|
|
|
16
20
|
localeChoice: boolean;
|
|
17
21
|
}): {
|
|
18
22
|
locale?: string | null | undefined;
|
|
19
|
-
name: string;
|
|
20
|
-
avatar: string | null;
|
|
21
23
|
phone: string | null;
|
|
24
|
+
peopleNumber: string | null;
|
|
25
|
+
avatar?: string | null | undefined;
|
|
26
|
+
name: string;
|
|
27
|
+
nickname: string | null;
|
|
22
28
|
};
|
|
@@ -3,8 +3,10 @@ export function profileChanges(values, saved, options) {
|
|
|
3
3
|
const localeChanged = options.localeChoice && values.locale !== saved.locale;
|
|
4
4
|
return {
|
|
5
5
|
name: values.name,
|
|
6
|
-
|
|
6
|
+
nickname: values.nickname.trim() || null,
|
|
7
|
+
...values.avatar === void 0 ? {} : { avatar: values.avatar || null },
|
|
7
8
|
phone: values.phone || null,
|
|
9
|
+
peopleNumber: values.peopleNumber.trim() || null,
|
|
8
10
|
...localeChanged ? { locale: values.locale === PROFILE_NO_LOCALE ? null : values.locale } : {}
|
|
9
11
|
};
|
|
10
12
|
}
|
|
@@ -71,10 +71,25 @@
|
|
|
71
71
|
"invalid": "Indtast en gyldig e-mailadresse."
|
|
72
72
|
},
|
|
73
73
|
"avatar": {
|
|
74
|
-
"label": "
|
|
74
|
+
"label": "Profilbillede",
|
|
75
75
|
"description": "Link til et kvadratisk billede.",
|
|
76
76
|
"url": "Avatar URL",
|
|
77
|
-
"invalid": "Indtast en gyldig URL."
|
|
77
|
+
"invalid": "Indtast en gyldig URL.",
|
|
78
|
+
"hint": "Gemmes, så snart du vælger et billede.",
|
|
79
|
+
"upload": "Upload billede",
|
|
80
|
+
"change": "Skift billede",
|
|
81
|
+
"remove": "Fjern billede",
|
|
82
|
+
"removeHint": "Dine initialer vises i stedet, for alle",
|
|
83
|
+
"removeConfirm": {
|
|
84
|
+
"title": "Fjern dit billede?",
|
|
85
|
+
"description": "Dit billede fjernes for alle. Dine initialer vises i stedet."
|
|
86
|
+
},
|
|
87
|
+
"saved": "Billede gemt",
|
|
88
|
+
"removed": "Billede fjernet",
|
|
89
|
+
"saveFailed": "Kunne ikke gemme dit billede.",
|
|
90
|
+
"removeFailed": "Kunne ikke fjerne dit billede.",
|
|
91
|
+
"wrongType": "Vælg et billede, fx en PNG-, JPEG- eller WebP-fil.",
|
|
92
|
+
"tooLarge": "Billedet er for stort. Vælg et under {size}."
|
|
78
93
|
},
|
|
79
94
|
"save": "Gem profil",
|
|
80
95
|
"saved": "Profil opdateret",
|
|
@@ -82,12 +97,37 @@
|
|
|
82
97
|
"phone": {
|
|
83
98
|
"label": "Telefon",
|
|
84
99
|
"description": "Til sms'er. Kun personale, der har brug for det, kan se det.",
|
|
85
|
-
"invalid": "Angiv et telefonnummer
|
|
100
|
+
"invalid": "Angiv et gyldigt telefonnummer.",
|
|
101
|
+
"country": "Land"
|
|
86
102
|
},
|
|
87
103
|
"locale": {
|
|
88
104
|
"label": "Sprog",
|
|
89
105
|
"description": "Det sprog, vi skriver til dig på: e-mails, sms'er og notifikationer.",
|
|
90
106
|
"none": "Ikke valgt"
|
|
107
|
+
},
|
|
108
|
+
"nickname": {
|
|
109
|
+
"label": "Kaldenavn",
|
|
110
|
+
"description": "Det, du gerne vil kaldes. Vises ved siden af dit navn.",
|
|
111
|
+
"tooLong": "Brug højst {max} tegn."
|
|
112
|
+
},
|
|
113
|
+
"peopleNumber": {
|
|
114
|
+
"label": "Frivillig-ID",
|
|
115
|
+
"description": "Dit nummer i det frivilligsystem, vi bruger, hvis du har et. Kun personale, der har brug for det, kan se det.",
|
|
116
|
+
"tooLong": "Brug højst {max} tegn."
|
|
117
|
+
},
|
|
118
|
+
"media": {
|
|
119
|
+
"title": "Fotos og tagging",
|
|
120
|
+
"description": "Fortæl fotografer og dem, der laver opslag om os, hvad du foretrækker. Du kan stadig komme med på fotos, hvor du ikke er i fokus, fx billeder af publikum.",
|
|
121
|
+
"photo": {
|
|
122
|
+
"label": "Ingen fotos af mig",
|
|
123
|
+
"description": "Tag ikke billeder med mig som hovedmotiv."
|
|
124
|
+
},
|
|
125
|
+
"tag": {
|
|
126
|
+
"label": "Ingen tagging",
|
|
127
|
+
"description": "Tag eller navngiv mig ikke i opslag og på fotos online."
|
|
128
|
+
},
|
|
129
|
+
"saved": "Fotovalg gemt",
|
|
130
|
+
"saveFailed": "Kunne ikke gemme dine fotovalg."
|
|
91
131
|
}
|
|
92
132
|
},
|
|
93
133
|
"documents": {
|
|
@@ -125,6 +165,7 @@
|
|
|
125
165
|
"passkeys": {
|
|
126
166
|
"title": "Passkeys",
|
|
127
167
|
"add": "Tilføj passkey",
|
|
168
|
+
"addHint": "Registrér denne enhed, så du kan logge ind uden adgangskode",
|
|
128
169
|
"description": "Log ind med fingeraftryk, ansigt eller enhedens pinkode i stedet for et password.",
|
|
129
170
|
"unnamed": "Passkey",
|
|
130
171
|
"created": "Tilføjet {date}",
|
|
@@ -159,6 +200,7 @@
|
|
|
159
200
|
"signedOut": "Logget ud.",
|
|
160
201
|
"signOutError": "Kunne ikke logge ud af applikationen.",
|
|
161
202
|
"signOutAll": "Log ud af alle apps",
|
|
203
|
+
"signOutAllHint": "Alle apps på listen skal bede dig logge ind igen",
|
|
162
204
|
"signOutAllConfirm": {
|
|
163
205
|
"title": "Log ud af alle apps?",
|
|
164
206
|
"description": "Alle applikationer på listen, på alle enheder, skal bede dig logge ind igen. Du forbliver logget ind på dette website."
|
|
@@ -177,11 +219,12 @@
|
|
|
177
219
|
"copy": "Kopiér nøgle",
|
|
178
220
|
"copied": "Nøglen er kopieret.",
|
|
179
221
|
"copiedSnippet": "Kopieret.",
|
|
180
|
-
"
|
|
222
|
+
"copySnippetHint": "Kopiér kommandoen til udklipsholderen",
|
|
181
223
|
"create": {
|
|
182
224
|
"title": "Opret API-nøgle",
|
|
183
225
|
"description": "Nøgler lader scripts og værktøjer som MCP-klienter handle på dine vegne. Giv hver nøgle kun de rettigheder, den har brug for.",
|
|
184
|
-
"submit": "Opret API-nøgle"
|
|
226
|
+
"submit": "Opret API-nøgle",
|
|
227
|
+
"submitHint": "Lav en nøgle til scripts og værktøjer; den vises kun én gang"
|
|
185
228
|
},
|
|
186
229
|
"createError": "Kunne ikke oprette nøglen.",
|
|
187
230
|
"created": "Nøglen er oprettet",
|
|
@@ -213,13 +256,33 @@
|
|
|
213
256
|
"connect": {
|
|
214
257
|
"title": "Forbind til MCP",
|
|
215
258
|
"description": "Brug din konto fra en AI-assistent. Din API-nøgle indsættes kun i kommandoerne lige efter, du har oprettet den.",
|
|
259
|
+
"descriptionOAuth": "Brug din konto fra en AI-assistent: tilføj URL'en i appen, og log ind. Du skal kun bruge en API-nøgle til klienter, der ikke kan logge ind, og den indsættes i kommandoerne lige efter, du har oprettet den.",
|
|
216
260
|
"claude": {
|
|
217
|
-
"steps": "Claude.ai og Claude Desktop: åbn Indstillinger → Connectors → Tilføj brugerdefineret connector, indsæt URL'en nedenfor og log ind
|
|
218
|
-
"cli": "Claude Code (bruger en API-nøgle):"
|
|
261
|
+
"steps": "Claude.ai og Claude Desktop: åbn Indstillinger → Connectors → Tilføj brugerdefineret connector, indsæt URL'en nedenfor, vælg Forbind og log ind. Ingen nøgle nødvendig."
|
|
219
262
|
},
|
|
220
263
|
"chatgpt": {
|
|
221
|
-
"steps": "ChatGPT:
|
|
222
|
-
}
|
|
264
|
+
"steps": "ChatGPT: slå udviklertilstand til under Indstillinger → Apps og connectors → Avancerede indstillinger, opret en connector med URL'en nedenfor og OAuth-godkendelse, og log ind. Ingen nøgle nødvendig."
|
|
265
|
+
},
|
|
266
|
+
"claudeCode": {
|
|
267
|
+
"steps": "Claude Code: kør denne kommando, kør derefter /mcp i Claude Code, vælg {name} og vælg Authenticate for at logge ind.",
|
|
268
|
+
"token": "Eller brug en API-nøgle fra denne side i stedet for at logge ind:"
|
|
269
|
+
},
|
|
270
|
+
"vscode": {
|
|
271
|
+
"steps": "VS Code: kør MCP: Add Server, vælg HTTP og indsæt URL'en nedenfor, og log ind, når VS Code beder om det.",
|
|
272
|
+
"file": "Eller tilføj den i .vscode/mcp.json:"
|
|
273
|
+
},
|
|
274
|
+
"cursor": {
|
|
275
|
+
"steps": "Cursor: tilføj dette i .cursor/mcp.json (eller ~/.cursor/mcp.json), og vælg derefter Login ud for {name} under Settings → MCP."
|
|
276
|
+
},
|
|
277
|
+
"token": {
|
|
278
|
+
"claudeCode": "Claude Code: kør denne kommando med en API-nøgle fra denne side.",
|
|
279
|
+
"vscode": "VS Code: tilføj dette i .vscode/mcp.json med en API-nøgle fra denne side.",
|
|
280
|
+
"cursor": "Cursor: tilføj dette i .cursor/mcp.json (eller ~/.cursor/mcp.json) med en API-nøgle fra denne side.",
|
|
281
|
+
"otherLabel": "Andre klienter",
|
|
282
|
+
"other": "Andre klienter: forbind til URL'en nedenfor, og send en API-nøgle fra denne side som headeren \"Authorization: Bearer NØGLE\"."
|
|
283
|
+
},
|
|
284
|
+
"signedInApps": "Apps, du forbinder ved at logge ind, vises under Apps, der er logget ind, på siden Sikkerhed, hvor du kan logge dem ud.",
|
|
285
|
+
"signedInAppsLink": "Åbn apps, der er logget ind"
|
|
223
286
|
},
|
|
224
287
|
"list": {
|
|
225
288
|
"title": "Dine nøgler",
|