refactor: remove misc/secure-rndstr.ts

This commit is contained in:
naskya 2024-01-14 12:24:29 +09:00
parent 26cd2a68da
commit 4e63873fc1
Signed by: naskya
GPG key ID: 712D413B3A9FED5C
5 changed files with 9 additions and 14 deletions

View file

@ -1,5 +0,0 @@
import { genString } from "native-utils/built/index.js";
export function secureRndstr(length = 32, _ = true): string {
return genString(length);
}

View file

@ -1,3 +1,3 @@
import { secureRndstr } from "@/misc/secure-rndstr.js";
import { genString } from "native-utils/built/index.js";
export default () => secureRndstr(16, true);
export default () => genString(16);

View file

@ -2,7 +2,7 @@ import define from "@/server/api/define.js";
import { Apps } from "@/models/index.js";
import { genId } from "@/misc/gen-id.js";
import { unique } from "@/prelude/array.js";
import { secureRndstr } from "@/misc/secure-rndstr.js";
import { genString } from "native-utils/built/index.js";
export const meta = {
tags: ["app"],
@ -41,7 +41,7 @@ export default define(meta, paramDef, async (ps, user) => {
includeSecret: true,
});
// Generate secret
const secret = secureRndstr(32, true);
const secret = genString(32);
// for backward compatibility
const permission = unique(

View file

@ -3,7 +3,7 @@ import define from "@/server/api/define.js";
import { ApiError } from "@/server/api/error.js";
import { AuthSessions, AccessTokens, Apps } from "@/models/index.js";
import { genId } from "@/misc/gen-id.js";
import { secureRndstr } from "@/misc/secure-rndstr.js";
import { genString } from "native-utils/built/index.js";
export const meta = {
tags: ["auth"],
@ -38,10 +38,10 @@ export default define(meta, paramDef, async (ps, user) => {
}
// Generate access token
const accessToken = secureRndstr(32, true);
const accessToken = genString(32);
// Fetch exist access token
const exist = await AccessTokens.exist({
const exist = await AccessTokens.exists({
where: {
appId: session.appId,
userId: user.id,

View file

@ -1,7 +1,7 @@
import define from "@/server/api/define.js";
import { AccessTokens } from "@/models/index.js";
import { genId } from "@/misc/gen-id.js";
import { secureRndstr } from "@/misc/secure-rndstr.js";
import { genString } from "native-utils/built/index.js";
export const meta = {
tags: ["auth"],
@ -44,7 +44,7 @@ export const paramDef = {
export default define(meta, paramDef, async (ps, user) => {
// Generate access token
const accessToken = secureRndstr(32, true);
const accessToken = genString(32);
const now = new Date();