origam 2.37.33 → 2.37.34
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/CHANGELOG.md +10 -0
- package/dist/src/nuxt/plugin.client.cjs +1 -1
- package/dist/src/nuxt/plugin.client.js +2 -2
- package/dist/src/nuxt/plugin.server.cjs +3 -2
- package/dist/src/nuxt/plugin.server.js +4 -3
- package/dist/src/utils/Commons/apply-theme.util.cjs +7 -0
- package/dist/src/utils/Commons/apply-theme.util.d.ts +14 -0
- package/dist/src/utils/Commons/apply-theme.util.js +6 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -18,6 +18,16 @@ This project follows [Semantic Versioning](https://semver.org).
|
|
|
18
18
|
|
|
19
19
|
## [Unreleased]
|
|
20
20
|
|
|
21
|
+
## [2.37.34] - 2026-11-04
|
|
22
|
+
|
|
23
|
+
### Security — `origam/nuxt` : le cookie de marque est validé contre les thèmes installés (#1120)
|
|
24
|
+
|
|
25
|
+
Le plugin serveur (`resolveServerTheme`) et le plugin client utilisaient la valeur brute du cookie de marque. Elle aboutissait dans `<html data-theme>` et servait de clé de lookup, si bien qu'un cookie arbitraire passait tel quel.
|
|
26
|
+
|
|
27
|
+
- Nouvel util partagé `knownBrand(value, themes)` (`utils/Commons/apply-theme.util.ts`) : il renvoie la valeur seulement si elle vaut `auto` ou le `name` d'un thème installé. La comparaison se fait par parcours `some` de la liste, sans lookup de propriété ; sinon il renvoie `null`.
|
|
28
|
+
- Les plugins serveur et client se replient sur `defaultTheme` quand le cookie (ou l'attribut DOM, côté client) n'est pas reconnu.
|
|
29
|
+
- Vérifié : le TU `1120-known-brand.util.spec.ts` couvre un nom installé, `auto`, `"><script>…`, `__proto__`, `constructor`, `toString`, un nom inconnu, la chaîne vide, null et undefined (PR #1319). Les plugins eux-mêmes ne sont pas testés avec un cookie hostile, car ils importent `#app`.
|
|
30
|
+
|
|
21
31
|
## [2.37.33] - 2026-11-03
|
|
22
32
|
|
|
23
33
|
### Added — `OrigamTable` : jetons de typographie des en-têtes (#1245)
|
|
@@ -28,7 +28,7 @@ module.exports = (0, _app.defineNuxtPlugin)({
|
|
|
28
28
|
});
|
|
29
29
|
const modePinned = (0, _applyTheme.isModePinned)(modeCookie.value, config.defaultMode);
|
|
30
30
|
const themeFromDom = typeof document !== "undefined" && document.documentElement.dataset.theme || null;
|
|
31
|
-
const initialTheme = themeFromDom ?? themeCookie.value ?? config.defaultTheme;
|
|
31
|
+
const initialTheme = (0, _applyTheme.knownBrand)(themeFromDom, config.themes) ?? (0, _applyTheme.knownBrand)(themeCookie.value, config.themes) ?? config.defaultTheme;
|
|
32
32
|
const initialMode = modeCookie.value ?? config.defaultMode;
|
|
33
33
|
const themes = config.themes ?? [];
|
|
34
34
|
const origam = (0, _origam.createOrigam)({
|
|
@@ -3,7 +3,7 @@ import { useTheme } from "../composables/Commons/theme.composable.js";
|
|
|
3
3
|
import { createOrigam } from "../origam.js";
|
|
4
4
|
import { nuxtIconsOptions } from "../utils/Commons/nuxt-icons.util.js";
|
|
5
5
|
import { nuxtLocaleOptions } from "../utils/Commons/nuxt-locale.util.js";
|
|
6
|
-
import { isModePinned } from "../utils/Commons/apply-theme.util.js";
|
|
6
|
+
import { isModePinned, knownBrand } from "../utils/Commons/apply-theme.util.js";
|
|
7
7
|
import { defineNuxtPlugin, useCookie, useRuntimeConfig } from "#app";
|
|
8
8
|
export default defineNuxtPlugin({
|
|
9
9
|
name: "origam:client",
|
|
@@ -22,7 +22,7 @@ export default defineNuxtPlugin({
|
|
|
22
22
|
});
|
|
23
23
|
const modePinned = isModePinned(modeCookie.value, config.defaultMode);
|
|
24
24
|
const themeFromDom = typeof document !== "undefined" && document.documentElement.dataset.theme || null;
|
|
25
|
-
const initialTheme = themeFromDom ?? themeCookie.value ?? config.defaultTheme;
|
|
25
|
+
const initialTheme = knownBrand(themeFromDom, config.themes) ?? knownBrand(themeCookie.value, config.themes) ?? config.defaultTheme;
|
|
26
26
|
const initialMode = modeCookie.value ?? config.defaultMode;
|
|
27
27
|
const themes = config.themes ?? [];
|
|
28
28
|
const origam = createOrigam({ themes, ssr: true, ...nuxtLocaleOptions(config), ...nuxtIconsOptions(config) });
|
|
@@ -12,8 +12,9 @@ var _ssrStyles = require("../utils/Commons/ssr-styles.util.cjs");
|
|
|
12
12
|
var _theme = require("../consts/Commons/theme.const.cjs");
|
|
13
13
|
var _app = require("#app");
|
|
14
14
|
function resolveServerTheme(cookieValue, config) {
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
const brand = (0, _applyTheme.knownBrand)(cookieValue, config.themes);
|
|
16
|
+
if (brand && brand !== _theme.ORIGAM_THEME_AUTO) {
|
|
17
|
+
return brand;
|
|
17
18
|
}
|
|
18
19
|
if (config.defaultTheme && config.defaultTheme !== _theme.ORIGAM_THEME_AUTO) {
|
|
19
20
|
return config.defaultTheme;
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { createOrigam } from "../origam.js";
|
|
2
2
|
import { nuxtIconsOptions } from "../utils/Commons/nuxt-icons.util.js";
|
|
3
3
|
import { nuxtLocaleOptions } from "../utils/Commons/nuxt-locale.util.js";
|
|
4
|
-
import { isModePinned, themeToCss, themeToUnpinnedCss } from "../utils/Commons/apply-theme.util.js";
|
|
4
|
+
import { isModePinned, knownBrand, themeToCss, themeToUnpinnedCss } from "../utils/Commons/apply-theme.util.js";
|
|
5
5
|
import { getSsrStyles } from "../utils/Commons/ssr-styles.util.js";
|
|
6
6
|
import { ORIGAM_MODE_ATTR, ORIGAM_MODE_DARK, ORIGAM_MODE_LIGHT, ORIGAM_THEME_ATTR, ORIGAM_THEME_AUTO } from "../consts/Commons/theme.const.js";
|
|
7
7
|
import { defineNuxtPlugin, useCookie, useHead, useRuntimeConfig } from "#app";
|
|
8
8
|
function resolveServerTheme(cookieValue, config) {
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
const brand = knownBrand(cookieValue, config.themes);
|
|
10
|
+
if (brand && brand !== ORIGAM_THEME_AUTO) {
|
|
11
|
+
return brand;
|
|
11
12
|
}
|
|
12
13
|
if (config.defaultTheme && config.defaultTheme !== ORIGAM_THEME_AUTO) {
|
|
13
14
|
return config.defaultTheme;
|
|
@@ -7,6 +7,7 @@ exports.applyTheme = applyTheme;
|
|
|
7
7
|
exports.applyThemes = applyThemes;
|
|
8
8
|
exports.installedThemesFromList = installedThemesFromList;
|
|
9
9
|
exports.isModePinned = isModePinned;
|
|
10
|
+
exports.knownBrand = knownBrand;
|
|
10
11
|
exports.resolveThemeVars = resolveThemeVars;
|
|
11
12
|
exports.semanticTreeToVars = semanticTreeToVars;
|
|
12
13
|
exports.themeSelector = themeSelector;
|
|
@@ -97,6 +98,12 @@ function isModePinned(cookieValue, defaultMode) {
|
|
|
97
98
|
const concrete = v => v === "light" || v === "dark";
|
|
98
99
|
return concrete(cookieValue) || concrete(defaultMode);
|
|
99
100
|
}
|
|
101
|
+
function knownBrand(value, themes) {
|
|
102
|
+
if (!value) {
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
return value === "auto" || (themes ?? []).some(t => t.name === value) ? value : null;
|
|
106
|
+
}
|
|
100
107
|
function themeToUnpinnedCss(theme) {
|
|
101
108
|
if (theme.mode !== "light" && theme.mode !== "dark") return "";
|
|
102
109
|
const vars = resolveThemeVars(theme);
|
|
@@ -53,6 +53,20 @@ export declare function themeToCss(theme: IOrigamTheme): string;
|
|
|
53
53
|
* Shared by both Nuxt plugins so server and client never disagree on it (#1103).
|
|
54
54
|
********************************************************/
|
|
55
55
|
export declare function isModePinned(cookieValue: string | null | undefined, defaultMode: string | undefined): boolean;
|
|
56
|
+
/*********************************************************
|
|
57
|
+
* knownBrand
|
|
58
|
+
*
|
|
59
|
+
* @description
|
|
60
|
+
* Trust boundary for the brand cookie (#1120): the value is returned only when
|
|
61
|
+
* it is `auto` or names an INSTALLED theme, otherwise `null` so the caller
|
|
62
|
+
* falls back to the configured default. A whitelist scan (`some`), never a
|
|
63
|
+
* property lookup, so `__proto__` / `constructor` are just unknown names.
|
|
64
|
+
* @description
|
|
65
|
+
* Shared by both Nuxt plugins so server and client never disagree on it.
|
|
66
|
+
********************************************************/
|
|
67
|
+
export declare function knownBrand(value: string | null | undefined, themes: readonly {
|
|
68
|
+
name?: string;
|
|
69
|
+
}[] | undefined): string | null;
|
|
56
70
|
/*********************************************************
|
|
57
71
|
* themeToUnpinnedCss
|
|
58
72
|
*
|
|
@@ -76,6 +76,12 @@ export function isModePinned(cookieValue, defaultMode) {
|
|
|
76
76
|
const concrete = (v) => v === "light" || v === "dark";
|
|
77
77
|
return concrete(cookieValue) || concrete(defaultMode);
|
|
78
78
|
}
|
|
79
|
+
export function knownBrand(value, themes) {
|
|
80
|
+
if (!value) {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
return value === "auto" || (themes ?? []).some((t) => t.name === value) ? value : null;
|
|
84
|
+
}
|
|
79
85
|
export function themeToUnpinnedCss(theme) {
|
|
80
86
|
if (theme.mode !== "light" && theme.mode !== "dark") return "";
|
|
81
87
|
const vars = resolveThemeVars(theme);
|