@@ -40,7 +40,7 @@ import { IKCallback } from "./libs/interfaces/IKCallback";
4040import manage from "./libs/manage" ;
4141import signature from "./libs/signature" ;
4242import upload from "./libs/upload" ;
43- import { verify as verifyWebhookSignature } from "./utils/webhook-signature" ;
43+ import { verify as verifyWebhookEvent } from "./utils/webhook-signature" ;
4444import customMetadataField from "./libs/manage/custom-metadata-field" ;
4545/*
4646 Implementations
@@ -76,16 +76,7 @@ const promisify = function <T = void>(thisContext: ImageKit, fn: Function) {
7676 }
7777 } ;
7878} ;
79-
80- const Webhook = {
81- verify : verifyWebhookSignature ,
82- }
83-
84- class ImageKitStaticUtils {
85- static Webhook = Webhook ;
86- }
87-
88- class ImageKit extends ImageKitStaticUtils {
79+ class ImageKit {
8980 options : ImageKitOptions = {
9081 uploadEndpoint : "https://upload.imagekit.io/api/v1/files/upload" ,
9182 publicKey : "" ,
@@ -95,7 +86,6 @@ class ImageKit extends ImageKitStaticUtils {
9586 } ;
9687
9788 constructor ( opts : ImageKitOptions = { } as ImageKitOptions ) {
98- super ( )
9989 this . options = _ . extend ( this . options , opts ) ;
10090 if ( ! this . options . publicKey ) {
10191 throw new Error ( errorMessages . MANDATORY_PUBLIC_KEY_MISSING . message ) ;
@@ -677,6 +667,14 @@ class ImageKit extends ImageKitStaticUtils {
677667 pHashDistance ( firstPHash : string , secondPHash : string ) : number | Error {
678668 return pHashUtils . pHashDistance ( firstPHash , secondPHash ) ;
679669 }
670+
671+ /**
672+ * @param payload - Raw webhook request body (Encoded as UTF8 string or Buffer)
673+ * @param signature - Webhook signature as UTF8 encoded strings (Stored in `x-ik-signature` header of the request)
674+ * @param secret - Webhook secret as UTF8 encoded string [Copy from ImageKit dashboard](https://imagekit.io/dashboard/developer/webhooks)
675+ * @returns \{ `timstamp`: Verified UNIX epoch timestamp if signature, `event`: Parsed webhook event payload \}
676+ */
677+ verifyWebhookEvent = verifyWebhookEvent ;
680678}
681679
682- export = ImageKit ;
680+ export = ImageKit ;
0 commit comments