mirror of
https://github.com/movie-web/backend.git
synced 2025-09-13 18:13:26 +00:00
Tidy namespaced imports
This commit is contained in:
@@ -7,6 +7,11 @@ import { StatusError } from '@/services/error';
|
|||||||
import { EntityManager } from '@mikro-orm/core';
|
import { EntityManager } from '@mikro-orm/core';
|
||||||
import forge from 'node-forge';
|
import forge from 'node-forge';
|
||||||
|
|
||||||
|
const {
|
||||||
|
pki: { ed25519 },
|
||||||
|
util: { ByteStringBuffer },
|
||||||
|
} = forge;
|
||||||
|
|
||||||
export async function assertChallengeCode(
|
export async function assertChallengeCode(
|
||||||
em: EntityManager,
|
em: EntityManager,
|
||||||
code: string,
|
code: string,
|
||||||
@@ -33,14 +38,10 @@ export async function assertChallengeCode(
|
|||||||
throw new StatusError('Challenge Code Expired', 401);
|
throw new StatusError('Challenge Code Expired', 401);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const verifiedChallenge = forge.pki.ed25519.verify({
|
const verifiedChallenge = ed25519.verify({
|
||||||
publicKey: new forge.util.ByteStringBuffer(
|
publicKey: new ByteStringBuffer(Buffer.from(publicKey, 'base64url')),
|
||||||
Buffer.from(publicKey, 'base64url'),
|
|
||||||
),
|
|
||||||
encoding: 'utf8',
|
encoding: 'utf8',
|
||||||
signature: new forge.util.ByteStringBuffer(
|
signature: new ByteStringBuffer(Buffer.from(signature, 'base64url')),
|
||||||
Buffer.from(signature, 'base64url'),
|
|
||||||
),
|
|
||||||
message: code,
|
message: code,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user