@@ -92,11 +92,10 @@ export interface ClientOptions {
9292 * You can view and manage API keys in the [dashboard](https://imagekit.io/dashboard/developer/api-keys).
9393 *
9494 */
95- privateAPIKey ?: string | undefined ;
95+ privateKey ?: string | undefined ;
9696
9797 /**
98- * ImageKit Basic Auth only uses the username field and ignores the password.
99- * This field is unused.
98+ * ImageKit Basic Auth only uses the `private_key` as username and ignores the password.
10099 *
101100 */
102101 password ?: string | null | undefined ;
@@ -183,7 +182,7 @@ export interface ClientOptions {
183182 * API Client for interfacing with the Image Kit API.
184183 */
185184export class ImageKit {
186- privateAPIKey : string ;
185+ privateKey : string ;
187186 password : string | null ;
188187 webhookSecret : string | null ;
189188
@@ -202,7 +201,7 @@ export class ImageKit {
202201 /**
203202 * API Client for interfacing with the Image Kit API.
204203 *
205- * @param {string | undefined } [opts.privateAPIKey =process.env['IMAGEKIT_PRIVATE_API_KEY'] ?? undefined]
204+ * @param {string | undefined } [opts.privateKey =process.env['IMAGEKIT_PRIVATE_API_KEY'] ?? undefined]
206205 * @param {string | null | undefined } [opts.password=process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'] ?? do_not_set]
207206 * @param {string | null | undefined } [opts.webhookSecret=process.env['IMAGEKIT_WEBHOOK_SECRET'] ?? null]
208207 * @param {string } [opts.baseURL=process.env['IMAGE_KIT_BASE_URL'] ?? https://api.imagekit.io] - Override the default base URL for the API.
@@ -215,19 +214,19 @@ export class ImageKit {
215214 */
216215 constructor ( {
217216 baseURL = readEnv ( 'IMAGE_KIT_BASE_URL' ) ,
218- privateAPIKey = readEnv ( 'IMAGEKIT_PRIVATE_API_KEY' ) ,
217+ privateKey = readEnv ( 'IMAGEKIT_PRIVATE_API_KEY' ) ,
219218 password = readEnv ( 'OPTIONAL_IMAGEKIT_IGNORES_THIS' ) ?? 'do_not_set' ,
220219 webhookSecret = readEnv ( 'IMAGEKIT_WEBHOOK_SECRET' ) ?? null ,
221220 ...opts
222221 } : ClientOptions = { } ) {
223- if ( privateAPIKey === undefined ) {
222+ if ( privateKey === undefined ) {
224223 throw new Errors . ImageKitError (
225- "The IMAGEKIT_PRIVATE_API_KEY environment variable is missing or empty; either provide it, or instantiate the ImageKit client with an privateAPIKey option, like new ImageKit({ privateAPIKey : 'My Private API Key' })." ,
224+ "The IMAGEKIT_PRIVATE_API_KEY environment variable is missing or empty; either provide it, or instantiate the ImageKit client with an privateKey option, like new ImageKit({ privateKey : 'My Private Key' })." ,
226225 ) ;
227226 }
228227
229228 const options : ClientOptions = {
230- privateAPIKey ,
229+ privateKey ,
231230 password,
232231 webhookSecret,
233232 ...opts ,
@@ -251,7 +250,7 @@ export class ImageKit {
251250
252251 this . _options = options ;
253252
254- this . privateAPIKey = privateAPIKey ;
253+ this . privateKey = privateKey ;
255254 this . password = password ;
256255 this . webhookSecret = webhookSecret ;
257256 }
@@ -269,7 +268,7 @@ export class ImageKit {
269268 logLevel : this . logLevel ,
270269 fetch : this . fetch ,
271270 fetchOptions : this . fetchOptions ,
272- privateAPIKey : this . privateAPIKey ,
271+ privateKey : this . privateKey ,
273272 password : this . password ,
274273 webhookSecret : this . webhookSecret ,
275274 ...options ,
@@ -289,28 +288,28 @@ export class ImageKit {
289288 }
290289
291290 protected validateHeaders ( { values, nulls } : NullableHeaders ) {
292- if ( this . privateAPIKey && this . password && values . get ( 'authorization' ) ) {
291+ if ( this . privateKey && this . password && values . get ( 'authorization' ) ) {
293292 return ;
294293 }
295294 if ( nulls . has ( 'authorization' ) ) {
296295 return ;
297296 }
298297
299298 throw new Error (
300- 'Could not resolve authentication method. Expected the privateAPIKey or password to be set. Or for the "Authorization" headers to be explicitly omitted' ,
299+ 'Could not resolve authentication method. Expected the privateKey or password to be set. Or for the "Authorization" headers to be explicitly omitted' ,
301300 ) ;
302301 }
303302
304303 protected async authHeaders ( opts : FinalRequestOptions ) : Promise < NullableHeaders | undefined > {
305- if ( ! this . privateAPIKey ) {
304+ if ( ! this . privateKey ) {
306305 return undefined ;
307306 }
308307
309308 if ( ! this . password ) {
310309 return undefined ;
311310 }
312311
313- const credentials = `${ this . privateAPIKey } :${ this . password } ` ;
312+ const credentials = `${ this . privateKey } :${ this . password } ` ;
314313 const Authorization = `Basic ${ toBase64 ( credentials ) } ` ;
315314 return buildHeaders ( [ { Authorization } ] ) ;
316315 }
0 commit comments