chore: configura o prettier para formatacao do codigo
This commit is contained in:
@@ -92,7 +92,10 @@ export function getAuthRuntimeConfig(event?: H3Event): AuthRuntimeConfig {
|
||||
kid,
|
||||
accessTtlSec: parsePositiveInt(String(runtimeConfig.jwtAccessTtlSec), 'JWT access TTL'),
|
||||
refreshTtlSec: parsePositiveInt(String(runtimeConfig.jwtRefreshTtlSec), 'JWT refresh TTL'),
|
||||
passwordResetTtlSec: parsePositiveInt(String(runtimeConfig.passwordResetTtlSec), 'Password reset TTL'),
|
||||
passwordResetTtlSec: parsePositiveInt(
|
||||
String(runtimeConfig.passwordResetTtlSec),
|
||||
'Password reset TTL'
|
||||
),
|
||||
privateKeyPem: normalizePem(String(runtimeConfig.jwtPrivateKeyPem ?? ''), 'JWT private key'),
|
||||
publicKeyPem: normalizePem(String(runtimeConfig.jwtPublicKeyPem ?? ''), 'JWT public key'),
|
||||
refreshTokenPepper,
|
||||
|
||||
@@ -37,6 +37,8 @@ export function getRouteRequirement(method: string, path: string): AuthRouteRequ
|
||||
const normalizedPath = normalizePath(path)
|
||||
|
||||
return (
|
||||
PROTECTED_ROUTES.find((route) => route.method === normalizedMethod && route.path === normalizedPath) ?? null
|
||||
PROTECTED_ROUTES.find(
|
||||
(route) => route.method === normalizedMethod && route.path === normalizedPath
|
||||
) ?? null
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
import { createError, type H3Event } from 'h3'
|
||||
import {
|
||||
SignJWT,
|
||||
importPKCS8,
|
||||
importSPKI,
|
||||
jwtVerify,
|
||||
type JWTPayload
|
||||
} from 'jose'
|
||||
import { SignJWT, importPKCS8, importSPKI, jwtVerify, type JWTPayload } from 'jose'
|
||||
|
||||
import type { AccessTokenClaims } from '../types/auth'
|
||||
import { getAuthRuntimeConfig } from './auth-config'
|
||||
@@ -74,7 +68,10 @@ async function loadSigningKeys(event: H3Event): Promise<LoadedSigningKeys> {
|
||||
* @param payload Dados mínimos do token (apenas `sub`).
|
||||
* @returns JWT assinado em formato string.
|
||||
*/
|
||||
export async function signAccessToken(event: H3Event, payload: Pick<AccessTokenClaims, 'sub'>): Promise<string> {
|
||||
export async function signAccessToken(
|
||||
event: H3Event,
|
||||
payload: Pick<AccessTokenClaims, 'sub'>
|
||||
): Promise<string> {
|
||||
const config = getAuthRuntimeConfig(event)
|
||||
const keys = await loadSigningKeys(event)
|
||||
|
||||
|
||||
@@ -39,7 +39,10 @@ function generateRawRefreshToken(): string {
|
||||
* @param userId ID do usuário dono do token.
|
||||
* @returns Metadados do refresh token emitido.
|
||||
*/
|
||||
export async function issueRefreshToken(event: H3Event, userId: string): Promise<IssuedRefreshToken> {
|
||||
export async function issueRefreshToken(
|
||||
event: H3Event,
|
||||
userId: string
|
||||
): Promise<IssuedRefreshToken> {
|
||||
const config = getAuthRuntimeConfig(event)
|
||||
const token = generateRawRefreshToken()
|
||||
const tokenHash = hashRefreshToken(token, config.refreshTokenPepper)
|
||||
|
||||
Reference in New Issue
Block a user