refactor: use node crypto uuid
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 = {
|
||||
|
||||
@@ -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<string>
|
||||
): [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;
|
||||
|
||||
@@ -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 }) },
|
||||
|
||||
Reference in New Issue
Block a user