allow update for uploaded routes and implement creator id for routes
Sonarqube Scanner / Prepare environment (push) Successful in 8s
Sonarqube Scanner / Build and test (push) Successful in 21s
Sonarqube Scanner / SonarQube analysis (push) Failing after 1m3s
Sonarqube Scanner / Deploy to Server (push) Successful in 6s

This commit is contained in:
Florian Zumpe
2026-10-03 16:43:08 +02:00
parent 4b8bdcad5f
commit 0db91660b3
20 changed files with 423 additions and 91 deletions
+28
View File
@@ -19,6 +19,31 @@ globalThis.Wegwichtel = globalThis.Wegwichtel || {};
return target;
}
// Separate from app/route storage: ordinary cleanup must preserve this identity.
const CREATOR_KEY = 'wegwichtel.creator-id.v1';
function creatorId() {
const target = storage();
const existing = target.getItem(CREATOR_KEY);
if (existing) {
if (!/^[a-f0-9]{64}$/.test(existing)) throw new Error(ns.I18n.t("local.error.identity"));
return existing;
}
if (typeof globalThis.crypto?.getRandomValues !== 'function') {
throw new Error(ns.I18n.t("local.error.identity"));
}
const bytes = globalThis.crypto.getRandomValues(new Uint8Array(32));
const value = Array.from(bytes, byte => byte.toString(16).padStart(2, '0')).join('');
target.setItem(CREATOR_KEY, value);
return value;
}
function forgetCreatorId() {
if (globalThis.confirm?.(ns.I18n.t("local.confirm-forget-identity")) !== true) return false;
storage().removeItem(CREATOR_KEY);
return true;
}
function routeKey(id, suffix) {
return `${STORAGE_PREFIX}.${encodeURIComponent(String(id))}.${suffix}`;
}
@@ -499,6 +524,7 @@ globalThis.Wegwichtel = globalThis.Wegwichtel || {};
const inputRoute = routePackage.route || {};
const route = {
id,
creator_id: inputRoute.creator_id || creatorId(),
name: String(inputRoute.name || ''),
description: String(inputRoute.description || ''),
createdAt: inputRoute.createdAt || now,
@@ -724,6 +750,8 @@ globalThis.Wegwichtel = globalThis.Wegwichtel || {};
ns.LocalRoutes = Object.freeze({
STORAGE_PREFIX,
creatorId,
forgetCreatorId,
appendTrackPoint,
recordedPositions,
replaceRecordedPositions,