import { SaleorSchemaVersion, AppManifest, Permission, AsyncWebhookEventType, SyncWebhookEventType, WebhookManifest } from './types.js'; import { AuthData, APL } from './APL/index.js'; import { ASTNode } from 'graphql'; import { v as verifySignatureWithJwks } from './verify-signature-mKf0fpOE.js'; import { c as WebhookError, F as FormatWebhookErrorResult, P as PlatformAdapterInterface, d as WebhookContext } from './saleor-webhook-De0XK_dM.js'; type CreateManifestHandlerOptions = { manifestFactory(context: { appBaseUrl: string; request: T; /** * Schema version is optional. During installation, Saleor will send it, * so manifest can be generated according to the version. But it may * be also requested from plain GET from the browser, so it may not be available */ schemaVersion?: SaleorSchemaVersion; }): AppManifest | Promise; }; type TokenUserPayload = { email: string; userPermissions: Permission[]; }; type ProtectedHandlerContext = { baseUrl: string; authData: AuthData; user: TokenUserPayload; }; interface GenericWebhookConfig { name?: string; webhookPath: string; event: Event; isActive?: boolean; apl: APL; onError?(error: WebhookError | Error, request: RequestType): void; formatErrorResponse?(error: WebhookError | Error, request: RequestType): Promise; query: string | ASTNode; /** * Allows to overwrite the default signature verification function. * * This is useful for testing purposes, when you want to fabricate a payload, or to opt-out from the default behavior from the library */ verifySignatureFn?: typeof verifySignatureWithJwks; } declare abstract class GenericSaleorWebhook { protected abstract eventType: "async" | "sync"; name: string; webhookPath: string; query: string | ASTNode; event: AsyncWebhookEventType | SyncWebhookEventType; isActive?: boolean; apl: APL; onError: GenericWebhookConfig["onError"]; formatErrorResponse: GenericWebhookConfig["formatErrorResponse"]; verifySignatureFn: typeof verifySignatureWithJwks; private webhookValidator; protected constructor(configuration: GenericWebhookConfig); /** Gets webhook absolute URL based on baseUrl of app * baseUrl is passed usually from manifest * baseUrl can include it's own pathname (e.g. http://aws-lambda.com/prod -> has /prod pathname) * that should be included in full webhook URL, e.g. http://my-webhook.com/prod/api/webhook/order-created */ private getTargetUrl; /** * Returns synchronous event manifest for this webhook. * * @param baseUrl Base URL used by your application * @returns WebhookManifest */ getWebhookManifest(baseUrl: string): WebhookManifest; protected prepareRequest>(adapter: Adapter): Promise<{ result: "callHandler"; context: WebhookContext; } | { result: "sendResponse"; response: ReturnType; }>; abstract createHandler(handlerFn: unknown): unknown; } export { type CreateManifestHandlerOptions as C, GenericSaleorWebhook as G, type ProtectedHandlerContext as P, type GenericWebhookConfig as a };