@frigear-nu/users 3.1.5 → 3.1.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/module.d.mts +103 -3
- package/dist/module.json +1 -1
- package/dist/module.mjs +132 -16
- package/dist/runtime/access.js +3 -3
- package/dist/runtime/app/components/UserCreateSlideover.vue +8 -6
- package/dist/runtime/app/components/UserPicker.d.vue.ts +2 -2
- package/dist/runtime/app/components/UserPicker.vue.d.ts +2 -2
- package/dist/runtime/app/components/UsersAdminTerms.d.vue.ts +7 -0
- package/dist/runtime/app/components/UsersAdminTerms.vue +55 -0
- package/dist/runtime/app/components/UsersAdminTerms.vue.d.ts +7 -0
- package/dist/runtime/app/components/UsersTermsGate.d.vue.ts +11 -0
- package/dist/runtime/app/components/UsersTermsGate.vue +82 -0
- package/dist/runtime/app/components/UsersTermsGate.vue.d.ts +11 -0
- package/dist/runtime/app/components/UsersTermsText.d.vue.ts +7 -0
- package/dist/runtime/app/components/UsersTermsText.vue +34 -0
- package/dist/runtime/app/components/UsersTermsText.vue.d.ts +7 -0
- package/dist/runtime/app/composables/useUserActions.d.ts +6 -2
- package/dist/runtime/app/composables/useUserActions.js +32 -3
- package/dist/runtime/app/pages/admin-user.vue +3 -0
- package/dist/runtime/app/pages/admin.vue +2 -1
- package/dist/runtime/app/pages/revert-email-change.vue +2 -1
- package/dist/runtime/app/plugins/terms-gate.client.d.ts +2 -0
- package/dist/runtime/app/plugins/terms-gate.client.js +55 -0
- package/dist/runtime/app/tabs/Overview.vue +22 -12
- package/dist/runtime/app/utils/admin-user.d.ts +4 -2
- package/dist/runtime/app/utils/terms.d.ts +10 -0
- package/dist/runtime/app/utils/terms.js +7 -0
- package/dist/runtime/app/widgets/NewUsers.d.vue.ts +4 -1
- package/dist/runtime/app/widgets/NewUsers.vue +7 -4
- package/dist/runtime/app/widgets/NewUsers.vue.d.ts +4 -1
- package/dist/runtime/app/widgets/NewUsersStat.d.vue.ts +4 -1
- package/dist/runtime/app/widgets/NewUsersStat.vue +4 -1
- package/dist/runtime/app/widgets/NewUsersStat.vue.d.ts +4 -1
- package/dist/runtime/app/widgets/UsersAccountTerms.d.vue.ts +6 -0
- package/dist/runtime/app/widgets/UsersAccountTerms.vue +63 -0
- package/dist/runtime/app/widgets/UsersAccountTerms.vue.d.ts +6 -0
- package/dist/runtime/app/widgets/UsersRegisterTerms.d.vue.ts +9 -0
- package/dist/runtime/app/widgets/UsersRegisterTerms.vue +37 -0
- package/dist/runtime/app/widgets/UsersRegisterTerms.vue.d.ts +9 -0
- package/dist/runtime/db/terms-users.postgresql.d.ts +24 -0
- package/dist/runtime/db/terms-users.postgresql.js +4 -0
- package/dist/runtime/db/terms-users.sqlite.d.ts +26 -0
- package/dist/runtime/db/terms-users.sqlite.js +4 -0
- package/dist/runtime/db/terms.postgresql.d.ts +162 -0
- package/dist/runtime/db/terms.postgresql.js +21 -0
- package/dist/runtime/db/terms.sqlite.d.ts +173 -0
- package/dist/runtime/db/terms.sqlite.js +21 -0
- package/dist/runtime/i18n/lang/da.json +62 -3
- package/dist/runtime/i18n/lang/en.json +62 -3
- package/dist/runtime/server/plugins/terms-claims.d.ts +13 -0
- package/dist/runtime/server/plugins/terms-claims.js +19 -0
- package/dist/runtime/server/plugins/terms.d.ts +15 -0
- package/dist/runtime/server/plugins/terms.js +43 -0
- package/dist/runtime/server/routes/admin/user-avatar.delete.d.ts +2 -0
- package/dist/runtime/server/routes/admin/user-avatar.delete.js +11 -0
- package/dist/runtime/server/routes/admin/user-terms.get.d.ts +2 -0
- package/dist/runtime/server/routes/admin/user-terms.get.js +12 -0
- package/dist/runtime/server/routes/admin/user.delete.js +2 -0
- package/dist/runtime/server/routes/admin/user.patch.js +2 -2
- package/dist/runtime/server/routes/admin/users.get.js +1 -2
- package/dist/runtime/server/routes/avatar.get.d.ts +2 -0
- package/dist/runtime/server/routes/avatar.get.js +12 -0
- package/dist/runtime/server/routes/me/avatar.delete.d.ts +2 -0
- package/dist/runtime/server/routes/me/avatar.delete.js +13 -0
- package/dist/runtime/server/routes/me/avatar.put.d.ts +2 -0
- package/dist/runtime/server/routes/me/avatar.put.js +20 -0
- package/dist/runtime/server/routes/me/profile.patch.js +7 -2
- package/dist/runtime/server/routes/me/terms.get.d.ts +2 -0
- package/dist/runtime/server/routes/me/terms.get.js +4 -0
- package/dist/runtime/server/routes/me/terms.post.d.ts +2 -0
- package/dist/runtime/server/routes/me/terms.post.js +18 -0
- package/dist/runtime/server/schemas.d.ts +5 -1
- package/dist/runtime/server/schemas.js +2 -1
- package/dist/runtime/server/utils/dto.d.ts +1 -1
- package/dist/runtime/server/utils/dto.js +2 -1
- package/dist/runtime/server/utils/users-avatar.d.ts +29 -0
- package/dist/runtime/server/utils/users-avatar.js +69 -0
- package/dist/runtime/server/utils/users-terms.d.ts +35 -0
- package/dist/runtime/server/utils/users-terms.js +90 -0
- package/dist/runtime/utils/api.d.ts +21 -2
- package/dist/runtime/utils/api.js +20 -1
- package/dist/runtime/utils/avatar.d.ts +25 -0
- package/dist/runtime/utils/avatar.js +23 -0
- package/dist/runtime/utils/terms-claim.d.ts +27 -0
- package/dist/runtime/utils/terms-claim.js +15 -0
- package/dist/types.d.mts +1 -1
- package/package.json +18 -13
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/** The image types an uploaded avatar may have (read from its bytes, never from the name or the browser's type). */
|
|
2
|
+
export declare const USERS_AVATAR_TYPES: readonly ["image/png", "image/jpeg", "image/webp"];
|
|
3
|
+
/** The default largest avatar upload: 2 MB (`users.maxAvatarBytes`). */
|
|
4
|
+
export declare const USERS_MAX_AVATAR_BYTES: number;
|
|
5
|
+
/** The widest and tallest avatar upload, in pixels. The account page sends 512 by 512. */
|
|
6
|
+
export declare const USERS_MAX_AVATAR_DIMENSION = 4096;
|
|
7
|
+
/** The file name of a stored avatar: `avatar-<random suffix>.<png|jpg|webp>`, new for every upload. */
|
|
8
|
+
export declare const USERS_AVATAR_FILE_PATTERN: RegExp;
|
|
9
|
+
/**
|
|
10
|
+
* The user id and file name of an avatar uploaded here, or `null` for anything else: a URL from a sign-in provider, a
|
|
11
|
+
* pasted URL, nothing. `users.avatar` holds an uploaded avatar as an absolute URL of the route that serves it
|
|
12
|
+
* (`https://<site>/api/users/avatars/<userId>/<file>`); the bare path is recognised too.
|
|
13
|
+
*/
|
|
14
|
+
export declare function parseUploadedUserAvatar(value: unknown): {
|
|
15
|
+
userId: number;
|
|
16
|
+
file: string;
|
|
17
|
+
} | null;
|
|
18
|
+
/** Whether `value` is an avatar uploaded here (the URL or path of the avatar route), not a picture elsewhere. */
|
|
19
|
+
export declare function isUploadedUserAvatar(value: unknown): value is string;
|
|
20
|
+
/**
|
|
21
|
+
* The avatar as an absolute URL, for anything that leaves the app (OIDC `picture`, exports, other apps). Uploads are
|
|
22
|
+
* stored absolute already; an uploaded avatar stored as a bare path is resolved against `origin` (the app's public
|
|
23
|
+
* origin). Any other avatar is returned as it is; `null` stays `null`.
|
|
24
|
+
*/
|
|
25
|
+
export declare function absoluteUserAvatarUrl(avatar: string | null | undefined, origin: string | null | undefined): string | null;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { IMAGE_TYPES } from "@frigear-nu/module-kit/image";
|
|
2
|
+
export const USERS_AVATAR_TYPES = IMAGE_TYPES;
|
|
3
|
+
export const USERS_MAX_AVATAR_BYTES = 2 * 1024 * 1024;
|
|
4
|
+
export const USERS_MAX_AVATAR_DIMENSION = 4096;
|
|
5
|
+
export const USERS_AVATAR_FILE_PATTERN = /^avatar-[0-9a-f]{4,64}\.(?:png|jpg|webp)$/;
|
|
6
|
+
const UPLOADED_AVATAR = /^(?:https?:\/\/[a-z0-9.-]+(?::\d{1,5})?)?\/api\/users\/avatars\/(\d{1,15})\/(avatar-[0-9a-f]{4,64}\.(?:png|jpg|webp))$/i;
|
|
7
|
+
export function parseUploadedUserAvatar(value) {
|
|
8
|
+
if (typeof value !== "string") return null;
|
|
9
|
+
const match = UPLOADED_AVATAR.exec(value);
|
|
10
|
+
return match ? { userId: Number(match[1]), file: match[2] } : null;
|
|
11
|
+
}
|
|
12
|
+
export function isUploadedUserAvatar(value) {
|
|
13
|
+
return parseUploadedUserAvatar(value) !== null;
|
|
14
|
+
}
|
|
15
|
+
export function absoluteUserAvatarUrl(avatar, origin) {
|
|
16
|
+
if (!avatar) return null;
|
|
17
|
+
if (!origin || !isUploadedUserAvatar(avatar)) return avatar;
|
|
18
|
+
try {
|
|
19
|
+
return new URL(avatar, origin).href;
|
|
20
|
+
} catch {
|
|
21
|
+
return avatar;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** The `terms` claim. `accepted_at` is in epoch seconds, like `auth_time`. */
|
|
2
|
+
export type UsersTermsClaim = {
|
|
3
|
+
version: string;
|
|
4
|
+
locale: string;
|
|
5
|
+
/** SHA-256 (hex) of the terms file the user accepted. */
|
|
6
|
+
content_hash: string;
|
|
7
|
+
accepted_at: number;
|
|
8
|
+
};
|
|
9
|
+
/** The claim of a history row (the user's latest acceptance). */
|
|
10
|
+
export declare function toUsersTermsClaim(row: {
|
|
11
|
+
version: string;
|
|
12
|
+
locale: string;
|
|
13
|
+
contentHash: string;
|
|
14
|
+
acceptedAt: number | Date;
|
|
15
|
+
}): UsersTermsClaim;
|
|
16
|
+
/**
|
|
17
|
+
* The acceptance a `terms` claim proves here: when it is for this app's current version and its hash is the hash of one
|
|
18
|
+
* of this app's terms files (the text is the same, byte for byte). The locale is the matching file's; `acceptedAt` in
|
|
19
|
+
* epoch milliseconds. `null` for anything else (other terms, an older version, a malformed claim).
|
|
20
|
+
*/
|
|
21
|
+
export declare function matchUsersTermsClaim(value: unknown, config: {
|
|
22
|
+
version: string;
|
|
23
|
+
hashes: Record<string, string>;
|
|
24
|
+
}, now?: number): {
|
|
25
|
+
locale: string;
|
|
26
|
+
acceptedAt: number;
|
|
27
|
+
} | null;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export function toUsersTermsClaim(row) {
|
|
2
|
+
const acceptedAt = row.acceptedAt instanceof Date ? row.acceptedAt.getTime() : row.acceptedAt;
|
|
3
|
+
return { version: row.version, locale: row.locale, content_hash: row.contentHash, accepted_at: Math.floor(acceptedAt / 1e3) };
|
|
4
|
+
}
|
|
5
|
+
export function matchUsersTermsClaim(value, config, now = Date.now()) {
|
|
6
|
+
if (!value || typeof value !== "object") return null;
|
|
7
|
+
const claim = value;
|
|
8
|
+
if (claim.version !== config.version || typeof claim.content_hash !== "string") return null;
|
|
9
|
+
if (typeof claim.accepted_at !== "number" || !Number.isFinite(claim.accepted_at) || claim.accepted_at <= 0) return null;
|
|
10
|
+
const locales = Object.keys(config.hashes);
|
|
11
|
+
const claimed = typeof claim.locale === "string" && config.hashes[claim.locale] === claim.content_hash ? claim.locale : void 0;
|
|
12
|
+
const locale = claimed ?? locales.find((code) => config.hashes[code] === claim.content_hash);
|
|
13
|
+
if (!locale) return null;
|
|
14
|
+
return { locale, acceptedAt: Math.min(claim.accepted_at * 1e3, now) };
|
|
15
|
+
}
|
package/dist/types.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { default } from './module.mjs'
|
|
2
2
|
|
|
3
|
-
export { type AdminUserDto, type ModuleOptions, type ProfileDto, type PublicModuleOptions } from './module.mjs'
|
|
3
|
+
export { type AdminUserDto, type ModuleOptions, type ProfileDto, type PublicModuleOptions, type UserDeletedContext, type UserTermsAcceptanceDto, type UserTermsStatusDto, type UsersPublicTerms, type UsersTermsAcceptedContext, type UsersTermsSource } from './module.mjs'
|
package/package.json
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@frigear-nu/users",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.6",
|
|
4
4
|
"description": "The user entity for the main frigear app: the users table, admin user management and self-service profile, email and password changes. Sign-in lives in @frigear-nu/auth.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"frigear-module",
|
|
7
|
+
"nuxt-module"
|
|
8
|
+
],
|
|
5
9
|
"homepage": "https://docs.frigear.dev/modules/identity/users",
|
|
6
10
|
"repository": {
|
|
7
11
|
"type": "git",
|
|
@@ -34,23 +38,24 @@
|
|
|
34
38
|
"playground"
|
|
35
39
|
],
|
|
36
40
|
"dependencies": {
|
|
37
|
-
"@frigear-nu/auth": "^0.6.
|
|
38
|
-
"@frigear-nu/mcp": "^0.5.
|
|
39
|
-
"@frigear-nu/module-kit": "^1.3.
|
|
40
|
-
"@frigear-nu/notify": "^0.3.
|
|
41
|
-
"@frigear-nu/ui": "^0.2.
|
|
41
|
+
"@frigear-nu/auth": "^0.6.9",
|
|
42
|
+
"@frigear-nu/mcp": "^0.5.3",
|
|
43
|
+
"@frigear-nu/module-kit": "^1.3.13",
|
|
44
|
+
"@frigear-nu/notify": "^0.3.2",
|
|
45
|
+
"@frigear-nu/ui": "^0.2.12",
|
|
42
46
|
"@libsql/client": "^0.18.0",
|
|
43
47
|
"@nuxt/kit": "^4.6.4",
|
|
44
48
|
"drizzle-kit": "^0.31.11",
|
|
45
49
|
"drizzle-orm": "^0.45.4",
|
|
50
|
+
"h3": "^1.15.11",
|
|
46
51
|
"scule": "^1.3.0",
|
|
47
52
|
"zod": "^4.6.7"
|
|
48
53
|
},
|
|
49
54
|
"peerDependencies": {
|
|
50
55
|
"@frigear-nu/admin": ">=0.0.0",
|
|
51
|
-
"@frigear-nu/email-templates": "^0.1.
|
|
52
|
-
"@frigear-nu/menu": "^0.4.
|
|
53
|
-
"@frigear-nu/widget": "^0.4.
|
|
56
|
+
"@frigear-nu/email-templates": "^0.1.6",
|
|
57
|
+
"@frigear-nu/menu": "^0.4.2",
|
|
58
|
+
"@frigear-nu/widget": "^0.4.4",
|
|
54
59
|
"@nuxt/ui": "^4.12.0",
|
|
55
60
|
"@nuxthub/core": "^0.10.12"
|
|
56
61
|
},
|
|
@@ -73,10 +78,10 @@
|
|
|
73
78
|
},
|
|
74
79
|
"devDependencies": {
|
|
75
80
|
"@electric-sql/pglite": "^0.5.16",
|
|
76
|
-
"@frigear-nu/admin": "^0.5.
|
|
77
|
-
"@frigear-nu/email-templates": "^0.1.
|
|
78
|
-
"@frigear-nu/menu": "^0.4.
|
|
79
|
-
"@frigear-nu/widget": "^0.4.
|
|
81
|
+
"@frigear-nu/admin": "^0.5.3",
|
|
82
|
+
"@frigear-nu/email-templates": "^0.1.6",
|
|
83
|
+
"@frigear-nu/menu": "^0.4.2",
|
|
84
|
+
"@frigear-nu/widget": "^0.4.4",
|
|
80
85
|
"@nuxt/devtools": "^4.2.0",
|
|
81
86
|
"@nuxt/eslint-config": "^1.17.0",
|
|
82
87
|
"@nuxt/module-builder": "^1.0.4",
|