@@ -99,6 +99,15 @@ export interface ClientOptions {
9999 */
100100 password ?: string | null | undefined ;
101101
102+ /**
103+ * Your ImageKit webhook secret. This is used by the SDK to verify webhook signatures. It starts with a `whsec_` prefix.
104+ * You can view and manage your webhook secret in the [dashboard](https://imagekit.io/dashboard/developer/webhooks).
105+ * Treat the secret like a password, keep it private and do not expose it publicly.
106+ * Learn more about [webhook verification](https://imagekit.io/docs/webhooks#verify-webhook-signature).
107+ *
108+ */
109+ webhookSecret ?: string | null | undefined ;
110+
102111 /**
103112 * Override the default base URL for the API, e.g., "https://api.example.com/v2/"
104113 *
@@ -174,6 +183,7 @@ export interface ClientOptions {
174183export class ImageKit {
175184 privateAPIKey : string ;
176185 password : string | null ;
186+ webhookSecret : string | null ;
177187
178188 baseURL : string ;
179189 maxRetries : number ;
@@ -192,6 +202,7 @@ export class ImageKit {
192202 *
193203 * @param {string | undefined } [opts.privateAPIKey=process.env['IMAGEKIT_PRIVATE_API_KEY'] ?? undefined]
194204 * @param {string | null | undefined } [opts.password=process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'] ?? do_not_set]
205+ * @param {string | null | undefined } [opts.webhookSecret=process.env['IMAGEKIT_WEBHOOK_SECRET'] ?? null]
195206 * @param {string } [opts.baseURL=process.env['IMAGE_KIT_BASE_URL'] ?? https://api.imagekit.io] - Override the default base URL for the API.
196207 * @param {number } [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
197208 * @param {MergedRequestInit } [opts.fetchOptions] - Additional `RequestInit` options to be passed to `fetch` calls.
@@ -204,6 +215,7 @@ export class ImageKit {
204215 baseURL = readEnv ( 'IMAGE_KIT_BASE_URL' ) ,
205216 privateAPIKey = readEnv ( 'IMAGEKIT_PRIVATE_API_KEY' ) ,
206217 password = readEnv ( 'OPTIONAL_IMAGEKIT_IGNORES_THIS' ) ?? 'do_not_set' ,
218+ webhookSecret = readEnv ( 'IMAGEKIT_WEBHOOK_SECRET' ) ?? null ,
207219 ...opts
208220 } : ClientOptions = { } ) {
209221 if ( privateAPIKey === undefined ) {
@@ -215,6 +227,7 @@ export class ImageKit {
215227 const options : ClientOptions = {
216228 privateAPIKey,
217229 password,
230+ webhookSecret,
218231 ...opts ,
219232 baseURL : baseURL || `https://api.imagekit.io` ,
220233 } ;
@@ -238,6 +251,7 @@ export class ImageKit {
238251
239252 this . privateAPIKey = privateAPIKey ;
240253 this . password = password ;
254+ this . webhookSecret = webhookSecret ;
241255 }
242256
243257 /**
@@ -255,6 +269,7 @@ export class ImageKit {
255269 fetchOptions : this . fetchOptions ,
256270 privateAPIKey : this . privateAPIKey ,
257271 password : this . password ,
272+ webhookSecret : this . webhookSecret ,
258273 ...options ,
259274 } ) ;
260275 return client ;
0 commit comments