Audit the project and secure toolbox data
This commit is contained in:
parent
96af62edf0
commit
e87edda5c7
40 changed files with 2324 additions and 125 deletions
|
|
@ -48,6 +48,7 @@ const TOOLBOX_ICON_FILES = [
|
|||
export const TOOLBOX_ICONS = TOOLBOX_ICON_FILES.map((file) => `${TOOLBOX_ICON_BASE}${file}`);
|
||||
export const DEFAULT_TOOLBOX_ICON = `${TOOLBOX_ICON_BASE}toolbox.png`;
|
||||
export const MAX_TOOLBOX_SPACES = 5;
|
||||
const LEGACY_TOOLBOX_UPDATED_AT = "1970-01-01T00:00:00.000Z";
|
||||
|
||||
export function normalizeToolboxIcon(icon) {
|
||||
const value = String(icon || "").trim();
|
||||
|
|
@ -137,7 +138,9 @@ export function normalizeToolboxSpaces(toolbox, modules) {
|
|||
const moduleIds = modules.map((module) => module.id);
|
||||
const rawSpaces = Array.isArray(toolbox?.spaces) ? toolbox.spaces.filter((space) => space && typeof space === "object") : [];
|
||||
if (!rawSpaces.length) {
|
||||
const id = uid("space");
|
||||
// L'identifiant stable permet de comparer une ancienne toolbox avec sa version
|
||||
// normalisée sans fabriquer un faux conflit entre deux lectures IndexedDB.
|
||||
const id = "default";
|
||||
return {
|
||||
spaces: [{ id, name: "Défaut", moduleOrder: normalizeModuleOrder(toolbox?.moduleOrder, modules) }],
|
||||
defaultSpaceId: id,
|
||||
|
|
@ -200,7 +203,7 @@ export function normalizeToolbox(toolbox) {
|
|||
moduleColumns: Number(toolbox.moduleColumns) === 1 ? 1 : 2,
|
||||
modules,
|
||||
...spaceState,
|
||||
updatedAt: toolbox.updatedAt || new Date().toISOString()
|
||||
updatedAt: toolbox.updatedAt || LEGACY_TOOLBOX_UPDATED_AT
|
||||
};
|
||||
if (toolbox.tutorial === true) normalized.tutorial = true;
|
||||
return normalized;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue