({
request,
rawBody,
requestId,
providerConfig,
}: AuthContext)
| 59 | |
| 60 | export const loopsHandler: WebhookProviderHandler = { |
| 61 | async verifyAuth({ |
| 62 | request, |
| 63 | rawBody, |
| 64 | requestId, |
| 65 | providerConfig, |
| 66 | }: AuthContext): Promise<NextResponse | null> { |
| 67 | const signingSecret = providerConfig.signingSecret as string | undefined |
| 68 | if (!signingSecret?.trim()) { |
| 69 | logger.warn(`[${requestId}] Loops webhook missing signing secret in provider configuration`) |
| 70 | return new NextResponse('Unauthorized - Loops signing secret is required', { status: 401 }) |
| 71 | } |
| 72 | |
| 73 | const webhookId = request.headers.get('webhook-id') |
| 74 | const timestamp = request.headers.get('webhook-timestamp') |
| 75 | const signature = request.headers.get('webhook-signature') |
| 76 | |
| 77 | if (!webhookId || !timestamp || !signature) { |
| 78 | logger.warn(`[${requestId}] Loops webhook missing signature headers`) |
| 79 | return new NextResponse('Unauthorized - Missing Loops signature headers', { status: 401 }) |
| 80 | } |
| 81 | |
| 82 | if (!verifyLoopsSignature(signingSecret, webhookId, timestamp, signature, rawBody)) { |
| 83 | logger.warn(`[${requestId}] Loops signature verification failed`) |
| 84 | return new NextResponse('Unauthorized - Invalid Loops signature', { status: 401 }) |
| 85 | } |
| 86 | |
| 87 | return null |
| 88 | }, |
| 89 | |
| 90 | async matchEvent({ body, requestId, providerConfig }: EventMatchContext): Promise<boolean> { |
| 91 | const triggerId = providerConfig.triggerId as string | undefined |
nothing calls this directly
no test coverage detected