Skip to content

Commit f0ed0f4

Browse files
committed
feat: update readme
1 parent 461828d commit f0ed0f4

File tree

1 file changed

+27
-9
lines changed

1 file changed

+27
-9
lines changed

README.md

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ Javascript SDK for [ImageKit](https://imagekit.io/) provides URL generation for
1414

1515
ImageKit is complete media storage, optimization, and transformation solution that comes with an [image and video CDN](https://imagekit.io/features/imagekit-infrastructure). It can be integrated with your existing infrastructure - storage like AWS S3, web servers, your CDN, and custom domain names, allowing you to deliver optimized images in minutes with minimal code changes.
1616

17+
## Changelog - SDK Version 2.0.0
18+
### Breaking changes
19+
**1. Authentication Process Update:**
20+
* Previously, when using client side file upload, the SDK required the `publicKey` and `authenticationEndpoint` parameters during SDK initialization to fetch security parameters (`signature`, `token`, and `expire`).
21+
* In version 2.0.0, we've updated the authentication process for the SDK. As a user of the SDK, you are now responsible for generating the security parameters (`signature`, `token`, and `expire`) yourself. This means you no longer need to provide the `authenticationEndpoint`. When using the SDK's upload method, make sure to pass these security parameters explicitly along with other [upload options](https://docs.imagekit.io/api-reference/upload-file-api/client-side-file-upload). For guidance on generating these security parameters, please refer to the documentation available [here](https://docs.imagekit.io/api-reference/upload-file-api/client-side-file-upload).
22+
1723
## Installation
1824

1925
### Using npm
@@ -59,12 +65,11 @@ var imagekit = new ImageKit({
5965
});
6066
```
6167

62-
`publicKey` and `authenticationEndpoint` parameters are required if you want to use the SDK for client-side file upload. You can get these parameters from the developer section in your ImageKit dashboard - https://imagekit.io/dashboard#developers
68+
`publicKey` parameter is required if you want to use the SDK for client-side file upload. You can get this parameter from the developer section in your ImageKit dashboard - https://imagekit.io/dashboard#developers
6369
```
6470
var imagekit = new ImageKit({
6571
publicKey: "your_public_api_key",
6672
urlEndpoint: "https://ik.imagekit.io/your_imagekit_id",
67-
authenticationEndpoint: "http://www.yourserver.com/auth",
6873
});
6974
```
7075

@@ -261,9 +266,7 @@ The SDK provides a simple interface using the `.upload()` method to upload files
261266

262267
The `upload()` method requires mandatory `file` and the `fileName` parameter. In addition, it accepts all the parameters supported by the [ImageKit Upload API](https://docs.imagekit.io/api-reference/upload-file-api/client-side-file-upload).
263268

264-
Also, ensure that you have specified `authenticationEndpoint` during SDK initialization. The SDK makes an HTTP GET request to this endpoint and expects a JSON response with three fields, i.e. `signature`, `token`, and `expire`. In addition, the SDK adds a query parameter `t` with a random value to ensure that the request URL is unique and the response is not cached in [Safari iOS](https://github.com/imagekit-developer/imagekit-javascript/issues/59). Your backend can ignore this query parameter.
265-
266-
[Learn how to implement authenticationEndpoint](https://docs.imagekit.io/api-reference/upload-file-api/client-side-file-upload#how-to-implement-authenticationendpoint-endpoint) on your server.
269+
Also before making an upload request, please ensure you have generated mandatory security parameters: `signature`, `token`, and `expire`. To generate these security parameters, refer to the [documentation here](https://docs.imagekit.io/api-reference/upload-file-api/client-side-file-upload). Obtain the parameters using a secure method and pass them, along with the mandatory `file` and `fileName` parameters, to the `upload()` method.
267270

268271
You can pass other parameters supported by the ImageKit upload API using the same parameter name as specified in the upload API documentation. For example, to specify tags for a file at the time of upload, use the `tags` parameter as specified in the [documentation here](https://docs.imagekit.io/api-reference/upload-file-api/client-side-file-upload).
269272

@@ -277,13 +280,12 @@ You can pass other parameters supported by the ImageKit upload API using the sam
277280
<script type="text/javascript" src="../dist/imagekit.js"></script>
278281

279282
<script>
280-
/* SDK initilization
281-
authenticationEndpoint should be implemented on your server. Learn more here - https://docs.imagekit.io/api-reference/upload-file-api/client-side-file-upload#how-to-implement-authenticationendpoint-endpoint
283+
/*
284+
SDK initilization
282285
*/
283286
var imagekit = new ImageKit({
284287
publicKey: "your_public_api_key",
285288
urlEndpoint: "https://ik.imagekit.io/your_imagekit_id",
286-
authenticationEndpoint: "http://www.yourserver.com/auth"
287289
});
288290
289291
// Upload function internally uses the ImageKit.io javascript SDK
@@ -295,6 +297,9 @@ You can pass other parameters supported by the ImageKit upload API using the sam
295297
file: file.files[0],
296298
fileName: "abc1.jpg",
297299
tags: ["tag1"],
300+
token: 'generated_token',
301+
signature: 'generated_signature',
302+
expire: 'generated_expire',
298303
extensions: [
299304
{
300305
name: "aws-auto-tagging",
@@ -311,6 +316,9 @@ You can pass other parameters supported by the ImageKit upload API using the sam
311316
file: file.files[0],
312317
fileName: "abc1.jpg",
313318
tags: ["tag1"],
319+
token: 'generated_token',
320+
signature: 'generated_signature',
321+
expire: 'generated_expire',
314322
extensions: [
315323
{
316324
name: "aws-auto-tagging",
@@ -352,6 +360,9 @@ imagekit.upload({
352360
file: file.files[0],
353361
fileName: "abc1.jpg",
354362
tags: ["tag1"],
363+
token: 'generated_token',
364+
signature: 'generated_signature',
365+
expire: 'generated_expire',
355366
extensions: [
356367
{
357368
name: "aws-auto-tagging",
@@ -375,6 +386,9 @@ var response = await imagekit.upload({
375386
file: file.files[0],
376387
fileName: "abc1.jpg",
377388
tags: ["tag1"],
389+
token: 'generated_token',
390+
signature: 'generated_signature',
391+
expire: 'generated_expire',
378392
extensions: [
379393
{
380394
name: "aws-auto-tagging",
@@ -394,6 +408,9 @@ try {
394408
file: file.files[0],
395409
fileName: "abc1.jpg",
396410
tags: ["tag1"],
411+
token: 'generated_token',
412+
signature: 'generated_signature',
413+
expire: 'generated_expire',
397414
extensions: [
398415
{
399416
name: "aws-auto-tagging",
@@ -407,4 +424,5 @@ try {
407424

408425
// {'content-type': 'application/json', 'x-request-id': 'ee560df4-d44f-455e-a48e-29dfda49aec5'}
409426
console.log(response.$ResponseMetadata.headers);
410-
}
427+
}
428+
```

0 commit comments

Comments
 (0)