From 8e694202953d933203de2190fc9ddbebc2a8f29f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 2 Jul 2026 15:53:34 +0000 Subject: [PATCH] Restrict manual place id/apiKey entry, add regenerate/reveal, show place owner --- lib/generators.js | 22 +++++++++++ public/css/style.css | 13 ++++++ public/dashboard/index.html | 30 ++++++++++++-- public/js/dashboard.js | 79 +++++++++++++++++++++++++++++++++++-- routes/dashboard.js | 69 ++++++++++++++++++++++++++------ 5 files changed, 192 insertions(+), 21 deletions(-) create mode 100644 lib/generators.js diff --git a/lib/generators.js b/lib/generators.js new file mode 100644 index 0000000..4d69e2d --- /dev/null +++ b/lib/generators.js @@ -0,0 +1,22 @@ +const crypto = require('crypto'); + +// Characters used when generating a random API key: letters, digits and a handful of symbols. +const API_KEY_CHARS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()-_=+'; +const API_KEY_LENGTH = 64; + +// Generates a new place id as a random UUID (v4). +function generatePlaceId() { + return crypto.randomUUID(); +} + +// Generates a random alphanumeric+symbol API key of the given length (default 64 characters). +function generateApiKey(length = API_KEY_LENGTH) { + const bytes = crypto.randomBytes(length); + let key = ''; + for (let i = 0; i < length; i++) { + key += API_KEY_CHARS[bytes[i] % API_KEY_CHARS.length]; + } + return key; +} + +module.exports = { generatePlaceId, generateApiKey }; diff --git a/public/css/style.css b/public/css/style.css index 7ba063c..cbcf5a5 100644 --- a/public/css/style.css +++ b/public/css/style.css @@ -170,6 +170,19 @@ button.danger { font-size: 14px; margin-bottom: 4px; color: var(--muted); + display: flex; + flex-direction: column; + gap: 2px; +} + +.place-list-id { + font-size: 14px; +} + +.place-list-owner { + font-size: 11px; + color: var(--muted); + opacity: 0.75; } .place-list li:hover { diff --git a/public/dashboard/index.html b/public/dashboard/index.html index b36d986..dea4ded 100644 --- a/public/dashboard/index.html +++ b/public/dashboard/index.html @@ -19,10 +19,12 @@