UNPKG

@scayle/storefront-nuxt

Version:

Nuxt integration for the SCAYLE Commerce Engine and Storefront API

28 lines (27 loc) 1.33 kB
import type { EventHandler } from 'h3'; /** * Wraps an event handler with basic authentication. * * This function enhances a given event handler with basic authentication functionality. * It checks for an Authorization header in the request and compares the decoded * credentials with the provided authentication string. If the credentials match, * the original handler is executed. * * @param handler The event handler to be wrapped. * @param auth The authentication string in the format 'username:password'. * * @returns The wrapped and awaited event handler, else an authentication failure response is returned. */ export declare const eventHandlerWithBasicAuth: (handler: EventHandler, auth: string) => EventHandler<import("h3").EventHandlerRequest, Promise<any>>; /** * Wraps an event handler with cache authentication. * * It takes an event handler and returns a new handler that is protected by * basic authentication if cache authentication is configured in the runtime config (`cache.auth`). * If cache authentication is not configured, the original handler is returned. * * @param handler The event handler to wrap. * * @returns The wrapped event handler. */ export declare const eventHandlerWithCacheAuth: (handler: EventHandler) => EventHandler<import("h3").EventHandlerRequest, Promise<any>>;