@bytescale/sdk 3.5.0 → 3.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -563,8 +563,8 @@ var BaseAPI = /*#__PURE__*/function () {
563
563
  }
564
564
  var configHeaders = _this4.config.headers;
565
565
  var _Object$assign3 = Object.assign({}, context.headers);
566
- return runtime_await(configHeaders === undefined ? {} : configHeaders(), function (_configHeaders) {
567
- var headers = Object.assign(_Object$assign3, _configHeaders);
566
+ return runtime_await(configHeaders === undefined ? {} : typeof configHeaders === "function" ? configHeaders() : configHeaders, function (_configHeaders) {
567
+ var headers = Object.assign(_Object$assign3, configHeaders === undefined ? _configHeaders : _configHeaders);
568
568
  Object.keys(headers).forEach(function (key) {
569
569
  return headers[key] === undefined ? delete headers[key] : {};
570
570
  });
@@ -590,7 +590,7 @@ var BaseAPI = /*#__PURE__*/function () {
590
590
  init: init
591
591
  };
592
592
  });
593
- }, configHeaders === undefined);
593
+ }, configHeaders === undefined || !(typeof configHeaders === "function"));
594
594
  } catch (e) {
595
595
  return Promise.reject(e);
596
596
  }
@@ -548,8 +548,8 @@ var BaseAPI = /*#__PURE__*/function () {
548
548
  }
549
549
  var configHeaders = _this4.config.headers;
550
550
  var _Object$assign3 = Object.assign({}, context.headers);
551
- return runtime_await(configHeaders === undefined ? {} : configHeaders(), function (_configHeaders) {
552
- var headers = Object.assign(_Object$assign3, _configHeaders);
551
+ return runtime_await(configHeaders === undefined ? {} : typeof configHeaders === "function" ? configHeaders() : configHeaders, function (_configHeaders) {
552
+ var headers = Object.assign(_Object$assign3, configHeaders === undefined ? _configHeaders : _configHeaders);
553
553
  Object.keys(headers).forEach(function (key) {
554
554
  return headers[key] === undefined ? delete headers[key] : {};
555
555
  });
@@ -575,7 +575,7 @@ var BaseAPI = /*#__PURE__*/function () {
575
575
  init: init
576
576
  };
577
577
  });
578
- }, configHeaders === undefined);
578
+ }, configHeaders === undefined || !(typeof configHeaders === "function"));
579
579
  } catch (e) {
580
580
  return Promise.reject(e);
581
581
  }
@@ -563,8 +563,8 @@ var BaseAPI = /*#__PURE__*/function () {
563
563
  }
564
564
  var configHeaders = _this4.config.headers;
565
565
  var _Object$assign3 = Object.assign({}, context.headers);
566
- return runtime_await(configHeaders === undefined ? {} : configHeaders(), function (_configHeaders) {
567
- var headers = Object.assign(_Object$assign3, _configHeaders);
566
+ return runtime_await(configHeaders === undefined ? {} : typeof configHeaders === "function" ? configHeaders() : configHeaders, function (_configHeaders) {
567
+ var headers = Object.assign(_Object$assign3, configHeaders === undefined ? _configHeaders : _configHeaders);
568
568
  Object.keys(headers).forEach(function (key) {
569
569
  return headers[key] === undefined ? delete headers[key] : {};
570
570
  });
@@ -590,7 +590,7 @@ var BaseAPI = /*#__PURE__*/function () {
590
590
  init: init
591
591
  };
592
592
  });
593
- }, configHeaders === undefined);
593
+ }, configHeaders === undefined || !(typeof configHeaders === "function"));
594
594
  } catch (e) {
595
595
  return Promise.reject(e);
596
596
  }
@@ -550,8 +550,8 @@ var BaseAPI = /*#__PURE__*/function () {
550
550
  }
551
551
  var configHeaders = _this4.config.headers;
552
552
  var _Object$assign3 = Object.assign({}, context.headers);
553
- return runtime_await(configHeaders === undefined ? {} : configHeaders(), function (_configHeaders) {
554
- var headers = Object.assign(_Object$assign3, _configHeaders);
553
+ return runtime_await(configHeaders === undefined ? {} : typeof configHeaders === "function" ? configHeaders() : configHeaders, function (_configHeaders) {
554
+ var headers = Object.assign(_Object$assign3, configHeaders === undefined ? _configHeaders : _configHeaders);
555
555
  Object.keys(headers).forEach(function (key) {
556
556
  return headers[key] === undefined ? delete headers[key] : {};
557
557
  });
@@ -577,7 +577,7 @@ var BaseAPI = /*#__PURE__*/function () {
577
577
  init: init
578
578
  };
579
579
  });
580
- }, configHeaders === undefined);
580
+ }, configHeaders === undefined || !(typeof configHeaders === "function"));
581
581
  } catch (e) {
582
582
  return Promise.reject(e);
583
583
  }
@@ -11,7 +11,7 @@ export interface BeginAuthSessionParams {
11
11
  */
12
12
  authHeaders: () => Promise<Record<string, string>>;
13
13
  /**
14
- * The fully-qualified URL for your backend API's auth endpoint.
14
+ * The fully-qualified URL for your backend API's auth endpoint (the endpoint that returns a JWT as plain text).
15
15
  */
16
16
  authUrl: string;
17
17
  /**
@@ -21,7 +21,9 @@ export interface BeginAuthSessionParams {
21
21
  }
22
22
  export interface AuthManagerInterface {
23
23
  /**
24
- * Begins an authenticated Bytescale API and Bytescale CDN session.
24
+ * Begins a JWT auth session with the Bytescale API and Bytescale CDN.
25
+ *
26
+ * 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).
25
27
  *
26
28
  * You can only call this method if 'isAuthSessionActive() === false', else an error will be returned.
27
29
  *
@@ -33,7 +35,7 @@ export interface AuthManagerInterface {
33
35
  *
34
36
  * 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.
35
37
  *
36
- * 2) You must await the promise before attempting to perform any downloads or API operations that require authentication.
38
+ * 2) You must await the returned promise before attempting to perform any downloads or API operations that require authentication.
37
39
  *
38
40
  * The auth process works as follows:
39
41
  *
@@ -36,7 +36,7 @@ export interface BytescaleApiClientConfig {
36
36
  *
37
37
  * These headers take precedence over any headers automatically added by the SDK (e.g. "Authorization", "Content-Type", etc.).
38
38
  */
39
- headers?: () => Promise<HTTPHeaders>;
39
+ headers?: HTTPHeaders | (() => Promise<HTTPHeaders> | HTTPHeaders);
40
40
  }
41
41
  export declare class BytescaleApiClientConfigUtils {
42
42
  static defaultApiUrl: string;
@@ -563,8 +563,8 @@ var BaseAPI = /*#__PURE__*/function () {
563
563
  }
564
564
  var configHeaders = _this4.config.headers;
565
565
  var _Object$assign3 = Object.assign({}, context.headers);
566
- return runtime_await(configHeaders === undefined ? {} : configHeaders(), function (_configHeaders) {
567
- var headers = Object.assign(_Object$assign3, _configHeaders);
566
+ return runtime_await(configHeaders === undefined ? {} : typeof configHeaders === "function" ? configHeaders() : configHeaders, function (_configHeaders) {
567
+ var headers = Object.assign(_Object$assign3, configHeaders === undefined ? _configHeaders : _configHeaders);
568
568
  Object.keys(headers).forEach(function (key) {
569
569
  return headers[key] === undefined ? delete headers[key] : {};
570
570
  });
@@ -590,7 +590,7 @@ var BaseAPI = /*#__PURE__*/function () {
590
590
  init: init
591
591
  };
592
592
  });
593
- }, configHeaders === undefined);
593
+ }, configHeaders === undefined || !(typeof configHeaders === "function"));
594
594
  } catch (e) {
595
595
  return Promise.reject(e);
596
596
  }
@@ -548,8 +548,8 @@ var BaseAPI = /*#__PURE__*/function () {
548
548
  }
549
549
  var configHeaders = _this4.config.headers;
550
550
  var _Object$assign3 = Object.assign({}, context.headers);
551
- return runtime_await(configHeaders === undefined ? {} : configHeaders(), function (_configHeaders) {
552
- var headers = Object.assign(_Object$assign3, _configHeaders);
551
+ return runtime_await(configHeaders === undefined ? {} : typeof configHeaders === "function" ? configHeaders() : configHeaders, function (_configHeaders) {
552
+ var headers = Object.assign(_Object$assign3, configHeaders === undefined ? _configHeaders : _configHeaders);
553
553
  Object.keys(headers).forEach(function (key) {
554
554
  return headers[key] === undefined ? delete headers[key] : {};
555
555
  });
@@ -575,7 +575,7 @@ var BaseAPI = /*#__PURE__*/function () {
575
575
  init: init
576
576
  };
577
577
  });
578
- }, configHeaders === undefined);
578
+ }, configHeaders === undefined || !(typeof configHeaders === "function"));
579
579
  } catch (e) {
580
580
  return Promise.reject(e);
581
581
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bytescale/sdk",
3
- "version": "3.5.0",
3
+ "version": "3.7.0",
4
4
  "description": "Bytescale JavaScript SDK",
5
5
  "author": "Bytescale <hello@bytescale.com> (https://www.bytescale.com)",
6
6
  "license": "MIT",
@@ -21,6 +21,7 @@
21
21
  "require": "./dist/browser/cjs/main.js",
22
22
  "import": "./dist/browser/esm/main.mjs"
23
23
  },
24
+ "types": "./dist/types/index.d.ts",
24
25
  "default": "./dist/browser/cjs/main.js"
25
26
  }
26
27
  },