Skip to content

Commit 93a453e

Browse files
committed
expose verifySignatureFn to be injected
1 parent 965089a commit 93a453e

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

.changeset/fuzzy-rocks-kiss.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@saleor/app-sdk": patch
3+
---
4+
5+
Allow to override signature verification method in SaleorWebhook class (likely for testing)

src/handlers/shared/generic-saleor-webhook.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { ASTNode } from "graphql";
22

33
import { APL } from "@/APL";
4+
import { verifySignatureWithJwks } from "@/auth";
45
import { createDebug } from "@/debug";
56
import { gqlAstToString } from "@/gql-ast-to-string";
67
import {
@@ -32,6 +33,7 @@ export interface GenericWebhookConfig<
3233
request: RequestType,
3334
): Promise<FormatWebhookErrorResult>;
3435
query: string | ASTNode;
36+
verifySignatureFn?: typeof verifySignatureWithJwks;
3537
}
3638

3739
export abstract class GenericSaleorWebhook<TRequestType, TPayload = unknown> {
@@ -55,6 +57,8 @@ export abstract class GenericSaleorWebhook<TRequestType, TPayload = unknown> {
5557

5658
formatErrorResponse: GenericWebhookConfig<TRequestType>["formatErrorResponse"];
5759

60+
verifySignatureFn: typeof verifySignatureWithJwks;
61+
5862
protected constructor(configuration: GenericWebhookConfig<TRequestType>) {
5963
const { name, webhookPath, event, query, apl, isActive = true } = configuration;
6064

@@ -66,6 +70,7 @@ export abstract class GenericSaleorWebhook<TRequestType, TPayload = unknown> {
6670
this.apl = apl;
6771
this.onError = configuration.onError;
6872
this.formatErrorResponse = configuration.formatErrorResponse;
73+
this.verifySignatureFn = configuration.verifySignatureFn ?? verifySignatureWithJwks;
6974
}
7075

7176
/** Gets webhook absolute URL based on baseUrl of app

0 commit comments

Comments
 (0)