From d6d457f999c9566db616b67809d600afd69f2928 Mon Sep 17 00:00:00 2001 From: Huskydog9988 <39809509+Huskydog9988@users.noreply.github.com> Date: Sun, 6 Apr 2025 13:46:53 -0400 Subject: [PATCH 1/8] fix: generate prisma types on install (like nuxt) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 77999288..2fe0b3fb 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "dev": "nuxt dev", "generate": "nuxt generate", "preview": "nuxt preview", - "postinstall": "nuxt prepare", + "postinstall": "prisma generate && nuxt prepare", "typecheck": "nuxt typecheck" }, "dependencies": { From 4fd2b159a6c6f44535c8407fc781885cc22e10f0 Mon Sep 17 00:00:00 2001 From: Huskydog9988 <39809509+Huskydog9988@users.noreply.github.com> Date: Sun, 6 Apr 2025 13:47:55 -0400 Subject: [PATCH 2/8] fix: type error in devices page --- pages/account/devices.vue | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pages/account/devices.vue b/pages/account/devices.vue index 4d3926c6..024c49f4 100644 --- a/pages/account/devices.vue +++ b/pages/account/devices.vue @@ -93,7 +93,7 @@ import { CheckIcon } from "@heroicons/vue/24/outline"; import moment from "moment"; -const clients = ref(await $dropFetch("/api/v1/user/client")); +const clients = await $dropFetch("/api/v1/user/client"); async function revokeClient(id: string) { await $dropFetch(`/api/v1/user/client/${id}`, { method: "DELETE" }); @@ -102,8 +102,8 @@ async function revokeClient(id: string) { function revokeClientWrapper(id: string) { revokeClient(id) .then(() => { - const index = clients.value.findIndex((e) => e.id == id); - clients.value.splice(index, 1); + const index = clients.findIndex((e) => e.id == id); + clients.splice(index, 1); }) .catch((e) => { createModal( From 17d3e0ef5495f93150ec763d37ea0a9a5b9a4618 Mon Sep 17 00:00:00 2001 From: Huskydog9988 <39809509+Huskydog9988@users.noreply.github.com> Date: Sun, 6 Apr 2025 14:08:36 -0400 Subject: [PATCH 3/8] refactor: use node crypto uuid --- package.json | 2 -- server/api/v1/auth/signup/simple.post.ts | 10 ++++------ server/internal/clients/handler.ts | 6 +++--- server/internal/objects/fsBackend.ts | 1 - server/internal/objects/objectHandler.ts | 1 - server/internal/objects/transactional.ts | 6 +++--- server/internal/saves/index.ts | 4 ++-- yarn.lock | 10 ---------- 8 files changed, 12 insertions(+), 28 deletions(-) diff --git a/package.json b/package.json index 2fe0b3fb..dec78b43 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,6 @@ "stream": "^0.0.3", "stream-mime-type": "^2.0.0", "turndown": "^7.2.0", - "uuid": "^10.0.0", "vue": "latest", "vue-router": "latest", "vue3-carousel": "^0.15.0", @@ -53,7 +52,6 @@ "@types/bcryptjs": "^2.4.6", "@types/node": "^22.13.16", "@types/turndown": "^5.0.5", - "@types/uuid": "^10.0.0", "autoprefixer": "^10.4.20", "h3": "^1.13.0", "postcss": "^8.4.47", diff --git a/server/api/v1/auth/signup/simple.post.ts b/server/api/v1/auth/signup/simple.post.ts index 8c91bb66..25a9ebd0 100644 --- a/server/api/v1/auth/signup/simple.post.ts +++ b/server/api/v1/auth/signup/simple.post.ts @@ -1,12 +1,10 @@ import { AuthMec, Invitation } from "@prisma/client"; import prisma from "~/server/internal/db/database"; -import { - createHashArgon2, -} from "~/server/internal/security/simple"; -import { v4 as uuidv4 } from "uuid"; +import { createHashArgon2 } from "~/server/internal/security/simple"; import * as jdenticon from "jdenticon"; import objectHandler from "~/server/internal/objects"; import { type } from "arktype"; +import { randomUUID } from "node:crypto"; import { writeNonLiteralDefaultMessage } from "arktype/internal/parser/shift/operator/default.ts"; const userValidator = type({ @@ -59,9 +57,9 @@ export default defineEventHandler(async (h3) => { statusMessage: "Username already taken.", }); - const userId = uuidv4(); + const userId = randomUUID(); - const profilePictureId = uuidv4(); + const profilePictureId = randomUUID(); await objectHandler.createFromSource( profilePictureId, async () => jdenticon.toPng(user.username, 256), diff --git a/server/internal/clients/handler.ts b/server/internal/clients/handler.ts index f2176ea5..a10d254d 100644 --- a/server/internal/clients/handler.ts +++ b/server/internal/clients/handler.ts @@ -1,4 +1,4 @@ -import { v4 as uuidv4 } from "uuid"; +import { randomUUID } from "node:crypto"; import { CertificateBundle } from "./ca"; import prisma from "../db/database"; import { Platform } from "@prisma/client"; @@ -20,7 +20,7 @@ export class ClientHandler { } = {}; async initiate(metadata: ClientMetadata) { - const clientId = uuidv4(); + const clientId = randomUUID(); this.temporaryClientTable[clientId] = { data: metadata, @@ -53,7 +53,7 @@ export class ClientHandler { const entry = this.temporaryClientTable[clientId]; if (!entry) throw new Error("Invalid clientId to generate token"); - const token = uuidv4(); + const token = randomUUID(); this.temporaryClientTable[clientId].authToken = token; return token; diff --git a/server/internal/objects/fsBackend.ts b/server/internal/objects/fsBackend.ts index 321acf06..d9be1222 100644 --- a/server/internal/objects/fsBackend.ts +++ b/server/internal/objects/fsBackend.ts @@ -11,7 +11,6 @@ import sanitize from "sanitize-filename"; import fs from "fs"; import path from "path"; import { Readable, Stream } from "stream"; -import { v4 as uuidv4 } from "uuid"; export class FsObjectBackend extends ObjectBackend { private baseObjectPath: string; diff --git a/server/internal/objects/objectHandler.ts b/server/internal/objects/objectHandler.ts index 818f3d13..84039e48 100644 --- a/server/internal/objects/objectHandler.ts +++ b/server/internal/objects/objectHandler.ts @@ -17,7 +17,6 @@ import { parse as getMimeTypeBuffer } from "file-type-mime"; import Stream, { Readable, Writable } from "stream"; import { getMimeType as getMimeTypeStream } from "stream-mime-type"; -import { v4 as uuidv4 } from "uuid"; export type ObjectReference = string; export type ObjectMetadata = { diff --git a/server/internal/objects/transactional.ts b/server/internal/objects/transactional.ts index 922ff6ae..dc557e2c 100644 --- a/server/internal/objects/transactional.ts +++ b/server/internal/objects/transactional.ts @@ -3,7 +3,7 @@ The purpose of this class is to hold references to remote objects (like images) This is used as a utility in metadata handling, so we only fetch the objects if we're actually creating a database record. */ import { Readable } from "stream"; -import { v4 as uuidv4 } from "uuid"; +import { randomUUID } from "node:crypto"; import objectHandler from "."; export type TransactionDataType = string | Readable | Buffer; @@ -21,12 +21,12 @@ export class ObjectTransactionalHandler { metadata: { [key: string]: string }, permissions: Array ): [Register, Pull, Dump] { - const transactionId = uuidv4(); + const transactionId = randomUUID(); this.record[transactionId] ??= {}; const register = (data: TransactionDataType) => { - const objectId = uuidv4(); + const objectId = randomUUID(); this.record[transactionId][objectId] = data; return objectId; diff --git a/server/internal/saves/index.ts b/server/internal/saves/index.ts index 5a9d23d8..df6797d3 100644 --- a/server/internal/saves/index.ts +++ b/server/internal/saves/index.ts @@ -2,7 +2,7 @@ import Stream, { Readable } from "stream"; import prisma from "../db/database"; import { applicationSettings } from "../config/application-configuration"; import objectHandler from "../objects"; -import { v4 as uuidv4 } from "uuid"; +import { randomUUID } from "node:crypto"; import crypto from "crypto"; import { IncomingMessage } from "http"; @@ -35,7 +35,7 @@ class SaveManager { if (!save) throw createError({ statusCode: 404, statusMessage: "Save not found" }); - const newSaveObjectId = uuidv4(); + const newSaveObjectId = randomUUID(); const newSaveStream = await objectHandler.createWithStream( newSaveObjectId, { saveSlot: JSON.stringify({ userId, gameId, index }) }, diff --git a/yarn.lock b/yarn.lock index b66fef7f..c8bbe85b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1777,11 +1777,6 @@ resolved "https://registry.yarnpkg.com/@types/turndown/-/turndown-5.0.5.tgz#614de24fc9ace4d8c0d9483ba81dc8c1976dd26f" integrity sha512-TL2IgGgc7B5j78rIccBtlYAnkuv8nUQqhQc+DSYV5j9Be9XOcm/SKOVRuA47xAVI3680Tk9B1d8flK2GWT2+4w== -"@types/uuid@^10.0.0": - version "10.0.0" - resolved "https://registry.yarnpkg.com/@types/uuid/-/uuid-10.0.0.tgz#e9c07fe50da0f53dc24970cca94d619ff03f6f6d" - integrity sha512-7gqG38EyHgyP1S+7+xomFtL+ZNHcKv6DwNaCZmJmo1vgMugyF3TCnXVg4t1uk89mLNwnLtnY3TpOpCOyp1/xHQ== - "@unhead/dom@1.11.20", "@unhead/dom@^1.11.18": version "1.11.20" resolved "https://registry.yarnpkg.com/@unhead/dom/-/dom-1.11.20.tgz#b777f439e1c5f80ebcceb89aa45c45e877013c62" @@ -7142,11 +7137,6 @@ util-deprecate@^1.0.1, util-deprecate@^1.0.2, util-deprecate@~1.0.1: resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" integrity sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw== -uuid@^10.0.0: - version "10.0.0" - resolved "https://registry.yarnpkg.com/uuid/-/uuid-10.0.0.tgz#5a95aa454e6e002725c79055fd42aaba30ca6294" - integrity sha512-8XkAphELsDnEGrDxUOHB3RGvXz6TeuYSGEZBOjtTtPm2lwhGBjLgOzLHB63IUWfBpNucQjND6d3AOudO+H3RWQ== - vary@^1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/vary/-/vary-1.1.2.tgz#2299f02c6ded30d4a5961b0b9f74524a18f634fc" From 0b9d0a4ad95b3c0d5f473d8c25ecb2b47175e1ba Mon Sep 17 00:00:00 2001 From: Huskydog9988 <39809509+Huskydog9988@users.noreply.github.com> Date: Sun, 6 Apr 2025 14:27:31 -0400 Subject: [PATCH 4/8] fix: don't use npm crypto --- package.json | 5 ++--- server/internal/saves/index.ts | 5 ++--- yarn.lock | 7 +------ 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index dec78b43..eabf0554 100644 --- a/package.json +++ b/package.json @@ -24,8 +24,7 @@ "arktype": "^2.1.10", "axios": "^1.7.7", "bcryptjs": "^2.4.3", - "cookie-es": "^1.2.2", - "crypto": "^1.0.1", + "cookie-es": "^2.0.0", "fast-fuzzy": "^1.12.0", "file-type-mime": "^0.4.3", "jdenticon": "^3.3.0", @@ -53,7 +52,7 @@ "@types/node": "^22.13.16", "@types/turndown": "^5.0.5", "autoprefixer": "^10.4.20", - "h3": "^1.13.0", + "h3": "^1.15.1", "postcss": "^8.4.47", "sass": "^1.79.4", "tailwindcss": "^4.0.0", diff --git a/server/internal/saves/index.ts b/server/internal/saves/index.ts index df6797d3..562e9826 100644 --- a/server/internal/saves/index.ts +++ b/server/internal/saves/index.ts @@ -2,8 +2,7 @@ import Stream, { Readable } from "stream"; import prisma from "../db/database"; import { applicationSettings } from "../config/application-configuration"; import objectHandler from "../objects"; -import { randomUUID } from "node:crypto"; -import crypto from "crypto"; +import { randomUUID, createHash } from "node:crypto"; import { IncomingMessage } from "http"; class SaveManager { @@ -50,7 +49,7 @@ class SaveManager { let hash: string | undefined; const hashPromise = Stream.promises.pipeline( stream, - crypto.createHash("sha256").setEncoding("hex"), + createHash("sha256").setEncoding("hex"), async function (source) { // Not sure how to get this to be typed // @ts-expect-error diff --git a/yarn.lock b/yarn.lock index c8bbe85b..6e7c0be7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2818,11 +2818,6 @@ cross-spawn@^7.0.3, cross-spawn@^7.0.6: dependencies: uncrypto "^0.1.3" -crypto@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/crypto/-/crypto-1.0.1.tgz#2af1b7cad8175d24c8a1b0778255794a21803037" - integrity sha512-VxBKmeNcqQdiUQUW2Tzq0t377b54N2bMtXO/qiLa+6eRRmmC4qT3D4OnTGoT/U6O9aklQ/jTwbOtRMTTY8G0Ig== - css-declaration-sorter@^7.2.0: version "7.2.0" resolved "https://registry.yarnpkg.com/css-declaration-sorter/-/css-declaration-sorter-7.2.0.tgz#6dec1c9523bc4a643e088aab8f09e67a54961024" @@ -3797,7 +3792,7 @@ gzip-size@^7.0.0: dependencies: duplexer "^0.1.2" -h3@^1.10.0, h3@^1.12.0, h3@^1.13.0, h3@^1.14.0, h3@^1.15.0, h3@^1.15.1: +h3@^1.10.0, h3@^1.12.0, h3@^1.14.0, h3@^1.15.0, h3@^1.15.1: version "1.15.1" resolved "https://registry.yarnpkg.com/h3/-/h3-1.15.1.tgz#59d6f70d7ef619fad74ecdf465a08fff898033bb" integrity sha512-+ORaOBttdUm1E2Uu/obAyCguiI7MbBvsLTndc3gyK3zU+SYLoZXlyCP9Xgy0gikkGufFLTZXCXD6+4BsufnmHA== From 9242a810b0cee20406a546580a9fe2abe5df9bab Mon Sep 17 00:00:00 2001 From: Huskydog9988 <39809509+Huskydog9988@users.noreply.github.com> Date: Sun, 6 Apr 2025 14:28:03 -0400 Subject: [PATCH 5/8] fix: don't prerender auth routes --- nuxt.config.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/nuxt.config.ts b/nuxt.config.ts index bd9f4061..4aad488b 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -24,7 +24,6 @@ export default defineNuxtConfig({ }, routeRules: { - "/auth/**": { prerender: true }, "/api/**": { cors: true }, }, From fd11d41dc50932061f8c8099e61269363842e54c Mon Sep 17 00:00:00 2001 From: Huskydog9988 <39809509+Huskydog9988@users.noreply.github.com> Date: Sun, 6 Apr 2025 14:34:25 -0400 Subject: [PATCH 6/8] chore: updates prisma and bycryptjs --- package.json | 6 +++--- yarn.lock | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index eabf0554..914848f1 100644 --- a/package.json +++ b/package.json @@ -18,12 +18,12 @@ "@nuxt/fonts": "^0.11.0", "@nuxt/image": "^1.10.0", "@nuxtjs/tailwindcss": "^6.12.2", - "@prisma/client": "^6.1.0", + "@prisma/client": "^6.5.0", "@tailwindcss/vite": "^4.0.6", "argon2": "^0.41.1", "arktype": "^2.1.10", "axios": "^1.7.7", - "bcryptjs": "^2.4.3", + "bcryptjs": "^3.0.2", "cookie-es": "^2.0.0", "fast-fuzzy": "^1.12.0", "file-type-mime": "^0.4.3", @@ -33,7 +33,7 @@ "moment": "^2.30.1", "nuxt": "3.15.4", "nuxt-security": "2.2.0", - "prisma": "^6.1.0", + "prisma": "^6.5.0", "sanitize-filename": "^1.6.3", "sharp": "^0.33.5", "stream": "^0.0.3", diff --git a/yarn.lock b/yarn.lock index 6e7c0be7..73728c6c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1354,7 +1354,7 @@ resolved "https://registry.yarnpkg.com/@poppinss/exception/-/exception-1.2.1.tgz#8a5f2120fabb64a99772166d537d8a97490209ff" integrity sha512-aQypoot0HPSJa6gDPEPTntc1GT6QINrSbgRlRhadGW2WaYqUK3tK4Bw9SBMZXhmxd3GeAlZjVcODHgiu+THY7A== -"@prisma/client@^6.1.0": +"@prisma/client@^6.5.0": version "6.5.0" resolved "https://registry.yarnpkg.com/@prisma/client/-/client-6.5.0.tgz#b5f4aa3820ff523734ef4e8dffe364ac9888369e" integrity sha512-M6w1Ql/BeiGoZmhMdAZUXHu5sz5HubyVcKukbLs3l0ELcQb8hTUJxtGEChhv4SVJ0QJlwtLnwOLgIRQhpsm9dw== @@ -2314,10 +2314,10 @@ basic-auth@^2.0.1: dependencies: safe-buffer "5.1.2" -bcryptjs@^2.4.3: - version "2.4.3" - resolved "https://registry.yarnpkg.com/bcryptjs/-/bcryptjs-2.4.3.tgz#9ab5627b93e60621ff7cdac5da9733027df1d0cb" - integrity sha512-V/Hy/X9Vt7f3BbPJEi8BdVFMByHi+jNXrYkW3huaybV/kQ0KJg0Y6PkEMbn+zeT+i+SiKZ/HMqJGIIt4LZDqNQ== +bcryptjs@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/bcryptjs/-/bcryptjs-3.0.2.tgz#caadcca1afefe372ed6e20f86db8e8546361c1ca" + integrity sha512-k38b3XOZKv60C4E2hVsXTolJWfkGRMbILBIe2IBITXciy5bOsTKot5kDrf3ZfufQtQOUN5mXceUEpU1rTl9Uog== binary-extensions@^2.0.0: version "2.3.0" @@ -5808,7 +5808,7 @@ pretty-bytes@^6.1.1: resolved "https://registry.yarnpkg.com/pretty-bytes/-/pretty-bytes-6.1.1.tgz#38cd6bb46f47afbf667c202cfc754bffd2016a3b" integrity sha512-mQUvGU6aUFQ+rNvTIAcZuWGRT9a6f6Yrg9bHs4ImKF+HZCEK+plBvnAZYSIQztknZF2qnzNtr6F8s0+IuptdlQ== -prisma@^6.1.0: +prisma@^6.5.0: version "6.5.0" resolved "https://registry.yarnpkg.com/prisma/-/prisma-6.5.0.tgz#0a02859bb59edb8821db4e63257c7f8de2d461a1" integrity sha512-yUGXmWqv5F4PByMSNbYFxke/WbnyTLjnJ5bKr8fLkcnY7U5rU9rUTh/+Fja+gOrRxEgtCbCtca94IeITj4j/pg== From fe82c7857198cc5baef565c734da037d9fc631d4 Mon Sep 17 00:00:00 2001 From: Huskydog9988 <39809509+Huskydog9988@users.noreply.github.com> Date: Sun, 6 Apr 2025 15:14:37 -0400 Subject: [PATCH 7/8] refactor: remove momentjs --- package.json | 3 ++- pages/account/devices.vue | 6 +++-- pages/admin/users/auth/simple/index.vue | 33 +++++++++++++++--------- pages/store/[id]/index.vue | 8 ++++-- server/internal/clients/event-handler.ts | 1 - server/internal/metadata/giantbomb.ts | 14 +++++----- server/internal/metadata/igdb.ts | 26 ++++++++++++------- server/internal/metadata/pcgamingwiki.ts | 7 ++--- server/internal/session/index.ts | 16 +++++++----- yarn.lock | 15 +++++++---- 10 files changed, 80 insertions(+), 49 deletions(-) diff --git a/package.json b/package.json index 914848f1..81383ecd 100644 --- a/package.json +++ b/package.json @@ -29,8 +29,8 @@ "file-type-mime": "^0.4.3", "jdenticon": "^3.3.0", "lru-cache": "^11.1.0", + "luxon": "^3.6.1", "micromark": "^4.0.1", - "moment": "^2.30.1", "nuxt": "3.15.4", "nuxt-security": "2.2.0", "prisma": "^6.5.0", @@ -49,6 +49,7 @@ "@tailwindcss/forms": "^0.5.9", "@tailwindcss/typography": "^0.5.15", "@types/bcryptjs": "^2.4.6", + "@types/luxon": "^3.6.2", "@types/node": "^22.13.16", "@types/turndown": "^5.0.5", "autoprefixer": "^10.4.20", diff --git a/pages/account/devices.vue b/pages/account/devices.vue index 024c49f4..5c80a62f 100644 --- a/pages/account/devices.vue +++ b/pages/account/devices.vue @@ -68,7 +68,9 @@ - {{ moment(client.lastConnected).fromNow() }} + {{ + DateTime.fromISO(client.lastConnected).diffNow().toHuman() + }} import { CheckIcon } from "@heroicons/vue/24/outline"; -import moment from "moment"; +import { DateTime } from "luxon"; const clients = await $dropFetch("/api/v1/user/client"); diff --git a/pages/admin/users/auth/simple/index.vue b/pages/admin/users/auth/simple/index.vue index 0ba6c9b3..6b58d3f7 100644 --- a/pages/admin/users/auth/simple/index.vue +++ b/pages/admin/users/auth/simple/index.vue @@ -352,7 +352,6 @@