@bytescale/sdk 3.13.0 → 3.15.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.
@@ -2547,6 +2547,14 @@ var AuthManagerImpl = /*#__PURE__*/function () {
2547
2547
  if (serviceWorkerScript === undefined) {
2548
2548
  return undefined;
2549
2549
  }
2550
+ var field = "serviceWorkerScript";
2551
+ if (!serviceWorkerScript.startsWith("/")) {
2552
+ throw new Error("The '".concat(field, "' field must start with a '/' and reference a script at the root of your website."));
2553
+ }
2554
+ var forwardSlashCount = serviceWorkerScript.split("/").length - 1;
2555
+ if (forwardSlashCount > 1) {
2556
+ ConsoleUtils.warn("The '".concat(field, "' field should be a root script (e.g. '/bytescale-auth-sw.js'). The Bytescale SDK can only authorize requests originating from webpages that are at the same level as the script or below."));
2557
+ }
2550
2558
  return AuthManagerBrowser_catch(function () {
2551
2559
  if ("serviceWorker" in navigator) {
2552
2560
  return AuthManagerBrowser_await(navigator.serviceWorker.register(serviceWorkerScript), function (registration) {
@@ -2592,8 +2600,8 @@ var AuthManagerImpl = /*#__PURE__*/function () {
2592
2600
  return AuthManagerBrowser_await(_this6.setAccessToken(session.params, jwt), function (setTokenResult) {
2593
2601
  _this6.setServiceWorkerConfig(session, [{
2594
2602
  headers: [{
2595
- key: "Authorization-Token",
2596
- value: jwt
2603
+ key: "Authorization",
2604
+ value: "Bearer ".concat(jwt)
2597
2605
  }],
2598
2606
  expires: Date.now() + setTokenResult.ttlSeconds * 1000,
2599
2607
  urlPrefix: "".concat(_this6.getCdnUrl(session.params), "/").concat(session.params.accountId, "/")
@@ -2532,6 +2532,14 @@ var AuthManagerImpl = /*#__PURE__*/function () {
2532
2532
  if (serviceWorkerScript === undefined) {
2533
2533
  return undefined;
2534
2534
  }
2535
+ var field = "serviceWorkerScript";
2536
+ if (!serviceWorkerScript.startsWith("/")) {
2537
+ throw new Error("The '".concat(field, "' field must start with a '/' and reference a script at the root of your website."));
2538
+ }
2539
+ var forwardSlashCount = serviceWorkerScript.split("/").length - 1;
2540
+ if (forwardSlashCount > 1) {
2541
+ ConsoleUtils.warn("The '".concat(field, "' field should be a root script (e.g. '/bytescale-auth-sw.js'). The Bytescale SDK can only authorize requests originating from webpages that are at the same level as the script or below."));
2542
+ }
2535
2543
  return AuthManagerBrowser_catch(function () {
2536
2544
  if ("serviceWorker" in navigator) {
2537
2545
  return AuthManagerBrowser_await(navigator.serviceWorker.register(serviceWorkerScript), function (registration) {
@@ -2577,8 +2585,8 @@ var AuthManagerImpl = /*#__PURE__*/function () {
2577
2585
  return AuthManagerBrowser_await(_this6.setAccessToken(session.params, jwt), function (setTokenResult) {
2578
2586
  _this6.setServiceWorkerConfig(session, [{
2579
2587
  headers: [{
2580
- key: "Authorization-Token",
2581
- value: jwt
2588
+ key: "Authorization",
2589
+ value: "Bearer ".concat(jwt)
2582
2590
  }],
2583
2591
  expires: Date.now() + setTokenResult.ttlSeconds * 1000,
2584
2592
  urlPrefix: "".concat(_this6.getCdnUrl(session.params), "/").concat(session.params.accountId, "/")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bytescale/sdk",
3
- "version": "3.13.0",
3
+ "version": "3.15.0",
4
4
  "description": "Bytescale JavaScript SDK",
5
5
  "author": "Bytescale <hello@bytescale.com> (https://www.bytescale.com)",
6
6
  "license": "MIT",