@bytescale/sdk
Advanced tools
Comparing version 3.21.0 to 3.21.1
@@ -72,3 +72,3 @@ import { BytescaleApiClientConfig } from "../../public/shared"; | ||
* | ||
* Specifically, calling this method will cause the SDK to periodically acquire a JWT from your JWT endpoint. The SDK will then automatically include this JWT in all subsequent Bytescale API requests (via the 'authorization-token' request header) and also in all Bytescale CDN download requests (via a session cookie). | ||
* Specifically, calling this method will cause the SDK to periodically acquire a JWT from your JWT endpoint. The SDK will then automatically include this JWT in all subsequent Bytescale API requests (via the 'authorization-token' request header) and also in all Bytescale CDN download requests (via a session cookie, or an 'authorization' header if service workers are being used). | ||
* | ||
@@ -83,6 +83,4 @@ * You can only call this method if 'isAuthSessionActive() === false', else an error will be returned. | ||
* | ||
* 1) You must add '?auth=true' to the URL of any private file you're trying to access. This includes the URLs you use in 'src' elements in img/video elements, etc. | ||
* 1) You must await the returned promise before attempting to perform any downloads or API operations that require authentication. | ||
* | ||
* 2) You must await the returned promise before attempting to perform any downloads or API operations that require authentication. | ||
* | ||
* The auth process works as follows: | ||
@@ -92,5 +90,5 @@ * | ||
* | ||
* 2) The JWT will be saved to a cookie scoped to the Bytescale CDN. This allows the user to view private files via the URL in the browser, including <img> elements on the page that reference private images, etc. | ||
* 2) The JWT will be added as a request header via 'authorization-token' to all Bytescale API requests made via this SDK. This allows the user to upload private files and perform administrative operations permitted by the JWT, such as deleting files, etc. | ||
* | ||
* 3) The JWT will also be added as a request header via 'authorization-token' to all Bytescale API requests made via this SDK. This allows the user to upload private files and perform administrative operations permitted by the JWT, such as deleting files, etc. | ||
* 3) The JWT will be also saved to a cookie scoped to the Bytescale CDN if service workers are not being used (see the 'serviceWorkerScript' field). This allows the user to view private files via the URL in the browser, including <img> elements on the page that reference private images, etc. If service workers are being used, then the JWT will be submitted to the Bytescale CDN via the 'authorization' header instead. | ||
*/ | ||
@@ -97,0 +95,0 @@ beginAuthSession: (params: BeginAuthSessionParams) => Promise<void>; |
@@ -28,7 +28,3 @@ /** | ||
/** | ||
* Set to 'true' to download a private file. Requires an active auth session. See AuthManager.beginAuthSession. | ||
* | ||
* Set to 'false' or omit when downloading publicly-accessible files. | ||
* | ||
* Default: false | ||
* @deprecated This field has no effect: the 'auth' querystring parameter is no-longer required by the Bytescale CDN. You may remove this field from your code. | ||
*/ | ||
@@ -35,0 +31,0 @@ auth?: boolean; |
{ | ||
"name": "@bytescale/sdk", | ||
"version": "3.21.0", | ||
"version": "3.21.1", | ||
"description": "Bytescale JavaScript SDK", | ||
@@ -5,0 +5,0 @@ "author": "Bytescale <hello@bytescale.com> (https://www.bytescale.com)", |
@@ -409,9 +409,9 @@ <h1 align="center"> | ||
## Authorization | ||
## Authentication | ||
The Bytescale JavaScript SDK supports two types of authorization: | ||
The Bytescale JavaScript SDK supports two types of authentication: | ||
### API Keys | ||
The Bytescale JavaScript SDK automatically adds the `apiKey` from the constructor to the `Authorization` header for all requests made via the SDK. | ||
The Bytescale JavaScript SDK automatically adds the `apiKey` from the constructor to the `authorization` header for all requests made via the SDK. | ||
@@ -426,14 +426,12 @@ With API key auth, the requester has access to the resources available to the API key: | ||
### JWT Cookies | ||
### JWTs | ||
JWT cookies are optional. | ||
JWTs are optional. | ||
With JWT cookies, the user can download private files directly via the URL, as authorization is performed implicitly via a session cookie. This allows the browser to display private files in `<img>` and `<video>` elements. | ||
With JWTs, the user can download private files directly via the URL, as authentication is performed implicitly via a session cookie _or_ via an `authorization` header if service workers are used (see the `serviceWorkerScript` param on the `AuthManager.beginAuthSession` method). This allows the browser to display private files in `<img>` and `<video>` elements. | ||
With JWT cookies, the user can also perform API requests (e.g. file uploads) granted by the [JWT's payload](https://www.bytescale.com/docs/types/BytescaleJwt). This is because the Bytescale JavaScript SDK automatically injects the user's JWT into the `authorization-token` request header for all API requests, assuming the `AuthManager.beginAuthSession` method has been called. | ||
With JWTs, the user can also perform API requests, such as file uploads, as these can be granted by the [JWT's payload](https://www.bytescale.com/docs/types/BytescaleJwt). The Bytescale JavaScript SDK will automatically inject the user's JWT into the `authorization-token` request header for all API requests, assuming the `AuthManager.beginAuthSession` method has been called. | ||
_Note: when using JWT cookies to download files, the `?auth=true` query parameter must be added to the URL._ | ||
[Learn more about the `AuthManager` and JWTs »](https://www.bytescale.com/docs/auth) | ||
[Learn more about the `AuthManager` and JWT cookies »](https://www.bytescale.com/docs/authorization#jwt-cookie) | ||
## UrlBuilder | ||
@@ -440,0 +438,0 @@ |
@@ -12,3 +12,3 @@ import { UrlBuilder } from "../src/public/shared"; | ||
const actual = UrlBuilder.url({ accountId: "1234abc", filePath: "/example.jpg", options: { auth: true } }); | ||
const expected = "https://upcdn.io/1234abc/raw/example.jpg?auth=true"; | ||
const expected = "https://upcdn.io/1234abc/raw/example.jpg"; | ||
expect(actual).toEqual(expected); | ||
@@ -23,3 +23,3 @@ }); | ||
}); | ||
const expected = "https://upcdn.io/1234abc/raw/example.jpg?auth=true&cache=true&version=42"; | ||
const expected = "https://upcdn.io/1234abc/raw/example.jpg?cache=true&version=42"; | ||
expect(actual).toEqual(expected); | ||
@@ -34,3 +34,3 @@ }); | ||
}); | ||
const expected = "https://upcdn.io/1234abc/raw/example.jpg?auth=true&cache=true&cache_ttl=100"; | ||
const expected = "https://upcdn.io/1234abc/raw/example.jpg?cache=true&cache_ttl=100"; | ||
expect(actual).toEqual(expected); | ||
@@ -127,4 +127,3 @@ }); | ||
}); | ||
const expected = | ||
"https://upcdn.io/1234abc/image/example.jpg?w=42&h=50&auth=true&version=50&cache_perm=auto&artifact=%2Ffoo"; | ||
const expected = "https://upcdn.io/1234abc/image/example.jpg?w=42&h=50&version=50&cache_perm=auto&artifact=%2Ffoo"; | ||
expect(actual).toEqual(expected); | ||
@@ -147,3 +146,3 @@ }); | ||
}); | ||
const expected = "https://upcdn.io/1234abc/image/example.jpg?r=52&auth=true"; | ||
const expected = "https://upcdn.io/1234abc/image/example.jpg?r=52"; | ||
expect(actual).toEqual(expected); | ||
@@ -150,0 +149,0 @@ }); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1003780
20884
556