chore (backend): remove gen-key-pair.ts
This commit is contained in:
parent
e80113ae6f
commit
bca44bf50a
2 changed files with 21 additions and 43 deletions
|
@ -1,9 +1,29 @@
|
|||
import type { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
import { v4 as uuid } from "uuid";
|
||||
import { genRsaKeyPair } from "@/misc/gen-key-pair.js";
|
||||
import { generateUserToken, genIdAt, hashPassword } from "backend-rs";
|
||||
|
||||
import * as crypto from "node:crypto";
|
||||
import * as util from "node:util";
|
||||
|
||||
const generateKeyPair = util.promisify(crypto.generateKeyPair);
|
||||
|
||||
export async function genRsaKeyPair(modulusLength = 2048) {
|
||||
return await generateKeyPair("rsa", {
|
||||
modulusLength,
|
||||
publicKeyEncoding: {
|
||||
type: "spki",
|
||||
format: "pem",
|
||||
},
|
||||
privateKeyEncoding: {
|
||||
type: "pkcs8",
|
||||
format: "pem",
|
||||
cipher: undefined,
|
||||
passphrase: undefined,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
async function createSystemUser(username: string, queryRunner: QueryRunner) {
|
||||
const password = uuid();
|
||||
|
||||
|
|
|
@ -1,42 +0,0 @@
|
|||
import * as crypto from "node:crypto";
|
||||
import * as util from "node:util";
|
||||
|
||||
const generateKeyPair = util.promisify(crypto.generateKeyPair);
|
||||
|
||||
export async function genRsaKeyPair(modulusLength = 2048) {
|
||||
return await generateKeyPair("rsa", {
|
||||
modulusLength,
|
||||
publicKeyEncoding: {
|
||||
type: "spki",
|
||||
format: "pem",
|
||||
},
|
||||
privateKeyEncoding: {
|
||||
type: "pkcs8",
|
||||
format: "pem",
|
||||
cipher: undefined,
|
||||
passphrase: undefined,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export async function genEcKeyPair(
|
||||
namedCurve:
|
||||
| "prime256v1"
|
||||
| "secp384r1"
|
||||
| "secp521r1"
|
||||
| "curve25519" = "prime256v1",
|
||||
) {
|
||||
return await generateKeyPair("ec", {
|
||||
namedCurve,
|
||||
publicKeyEncoding: {
|
||||
type: "spki",
|
||||
format: "pem",
|
||||
},
|
||||
privateKeyEncoding: {
|
||||
type: "pkcs8",
|
||||
format: "pem",
|
||||
cipher: undefined,
|
||||
passphrase: undefined,
|
||||
},
|
||||
});
|
||||
}
|
Loading…
Reference in a new issue