@bytescale/sdk 3.12.0 → 3.14.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) {
@@ -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) {
@@ -59,7 +59,7 @@ export interface BeginAuthSessionParams {
59
59
  * Service workers can only interact with events raised by pages at the same level or below them, hence why your
60
60
  * script must be hosted on your website's domain in the root directory.
61
61
  */
62
- serviceWorkerScript: string | undefined;
62
+ serviceWorkerScript?: string;
63
63
  }
64
64
  export interface AuthManagerInterface {
65
65
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bytescale/sdk",
3
- "version": "3.12.0",
3
+ "version": "3.14.0",
4
4
  "description": "Bytescale JavaScript SDK",
5
5
  "author": "Bytescale <hello@bytescale.com> (https://www.bytescale.com)",
6
6
  "license": "MIT",