mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-09 18:44:16 +00:00
use global.nanoid
This commit is contained in:
parent
d28d54e803
commit
a81bd1fe52
@ -1,7 +1,6 @@
|
||||
import path from "path"
|
||||
import fs from "fs"
|
||||
import { videoTranscode } from "../../../lib/videoTranscode"
|
||||
import { nanoid } from "nanoid"
|
||||
import Jimp from "jimp"
|
||||
|
||||
import pmap from "../../../utils/pMap"
|
||||
@ -93,7 +92,7 @@ export default async (payload) => {
|
||||
maxFileSize: params.maxFileSize,
|
||||
maxFields: params.maxFields,
|
||||
filename: (name, ext) => {
|
||||
name = nanoid()
|
||||
name = global.nanoid()
|
||||
|
||||
return name + ext
|
||||
},
|
||||
|
@ -1,5 +1,3 @@
|
||||
import { nanoid } from "nanoid"
|
||||
|
||||
import { StreamingKey, User } from "@models"
|
||||
|
||||
export default async (user_id) => {
|
||||
@ -12,7 +10,7 @@ export default async (user_id) => {
|
||||
const streamingKey = new StreamingKey({
|
||||
user_id,
|
||||
username: userData.username,
|
||||
key: nanoid()
|
||||
key: global.nanoid()
|
||||
})
|
||||
|
||||
await streamingKey.save()
|
||||
|
@ -1,4 +1,5 @@
|
||||
require("dotenv").config()
|
||||
const crypto = require("node:crypto")
|
||||
|
||||
// patches
|
||||
const { Buffer } = require("buffer")
|
||||
@ -10,6 +11,8 @@ global.b64Encode = (data) => {
|
||||
return Buffer.from(data, "utf-8").toString("base64")
|
||||
}
|
||||
|
||||
global.nanoid = (t = 21) => crypto.getRandomValues(new Uint8Array(t)).reduce(((t, e) => t += (e &= 63) < 36 ? e.toString(36) : e < 62 ? (e - 26).toString(36).toUpperCase() : e > 62 ? "-" : "_"), "");
|
||||
|
||||
Array.prototype.updateFromObjectKeys = function (obj) {
|
||||
this.forEach((value, index) => {
|
||||
if (obj[value] !== undefined) {
|
||||
|
@ -1,5 +1,4 @@
|
||||
import jwt from "jsonwebtoken"
|
||||
import { nanoid } from "nanoid"
|
||||
import { Session, RegenerationToken } from "../../models"
|
||||
|
||||
export async function regenerateSession(expiredToken, refreshToken) {
|
||||
@ -139,7 +138,7 @@ export async function signNewAuthToken(payload, options = {}) {
|
||||
|
||||
payload.session_uuid = sessionData.session_uuid
|
||||
} else {
|
||||
payload.session_uuid = nanoid()
|
||||
payload.session_uuid = global.nanoid()
|
||||
}
|
||||
|
||||
const token = jwt.sign(payload, global.jwtStrategy.secretOrKey, {
|
||||
|
Loading…
x
Reference in New Issue
Block a user