@bytescale/sdk 3.18.0 → 3.20.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.
@@ -2419,6 +2419,13 @@ function ServiceWorkerUtils_catch(body, recover) {
2419
2419
  }
2420
2420
  return result;
2421
2421
  }
2422
+ function ServiceWorkerUtils_invoke(body, then) {
2423
+ var result = body();
2424
+ if (result && result.then) {
2425
+ return result.then(then);
2426
+ }
2427
+ return then(result);
2428
+ }
2422
2429
  function ServiceWorkerUtils_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
2423
2430
  function ServiceWorkerUtils_defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, ServiceWorkerUtils_toPropertyKey(descriptor.key), descriptor); } }
2424
2431
  function ServiceWorkerUtils_createClass(Constructor, protoProps, staticProps) { if (protoProps) ServiceWorkerUtils_defineProperties(Constructor.prototype, protoProps); if (staticProps) ServiceWorkerUtils_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
@@ -2430,50 +2437,53 @@ var ServiceWorkerUtils = /*#__PURE__*/function () {
2430
2437
  ServiceWorkerUtils_classCallCheck(this, ServiceWorkerUtils);
2431
2438
  }
2432
2439
  ServiceWorkerUtils_createClass(ServiceWorkerUtils, [{
2433
- key: "registerServiceWorkerIfSupported",
2434
- value:
2435
- /**
2436
- * Idempotent.
2437
- *
2438
- * Only returns once the service worker has been activated.
2439
- *
2440
- * We don't need to unregister it: we just need to clear the config when auth ends.
2441
- */
2442
- function registerServiceWorkerIfSupported(serviceWorkerScript, configFieldName, fallbackMessage) {
2440
+ key: "canUseServiceWorkers",
2441
+ value: function canUseServiceWorkers() {
2442
+ return "serviceWorker" in navigator;
2443
+ }
2444
+ }, {
2445
+ key: "sendMessage",
2446
+ value: function sendMessage(message, config, serviceWorkerScriptFieldName) {
2443
2447
  try {
2444
2448
  var _this2 = this;
2445
- if (serviceWorkerScript === undefined) {
2446
- return undefined;
2447
- }
2448
- if (!("serviceWorker" in navigator)) {
2449
- ConsoleUtils.warn("Service workers not supported by browser. ".concat(fallbackMessage));
2450
- return undefined;
2451
- }
2449
+ return ServiceWorkerUtils_await(config.serviceWorkerScope !== undefined ? _this2.getActiveServiceWorkerElseRegister(config, message) : _this2.registerServiceWorkerValidated(config.serviceWorkerScript, message, serviceWorkerScriptFieldName), function (result) {
2450
+ if (!result.messageSent) {
2451
+ result.serviceWorker.postMessage(message);
2452
+ }
2453
+ return result.config;
2454
+ });
2455
+ } catch (e) {
2456
+ return Promise.reject(e);
2457
+ }
2458
+ }
2459
+ }, {
2460
+ key: "registerServiceWorkerValidated",
2461
+ value: function registerServiceWorkerValidated(serviceWorkerScript, init, serviceWorkerScriptFieldName) {
2462
+ try {
2463
+ var _this4 = this;
2452
2464
  if (!serviceWorkerScript.startsWith("/")) {
2453
- throw new Error("The '".concat(configFieldName, "' field must start with a '/' and reference a script at the root of your website."));
2465
+ throw new Error("The '".concat(serviceWorkerScriptFieldName, "' field must start with a '/' and reference a script at the root of your website."));
2454
2466
  }
2455
2467
  var forwardSlashCount = serviceWorkerScript.split("/").length - 1;
2456
2468
  if (forwardSlashCount > 1) {
2457
- ConsoleUtils.warn("The '".concat(configFieldName, "' field should be a root script (e.g. '/script.js'). The Bytescale SDK can only authorize requests originating from webpages that are at the same level as the script or below."));
2469
+ ConsoleUtils.warn("The '".concat(serviceWorkerScriptFieldName, "' field should be a root script (e.g. '/script.js'). The Bytescale SDK can only authorize requests originating from webpages that are at the same level as the script or below."));
2458
2470
  }
2459
- return ServiceWorkerUtils_await(_this2.registerAuthServiceWorker(serviceWorkerScript), function (_this$registerAuthSer) {
2460
- return _this$registerAuthSer.config;
2461
- });
2471
+ return ServiceWorkerUtils_await(_this4.registerServiceWorker(serviceWorkerScript, init));
2462
2472
  } catch (e) {
2463
2473
  return Promise.reject(e);
2464
2474
  }
2465
2475
  }
2466
2476
  }, {
2467
2477
  key: "getActiveServiceWorkerElseRegister",
2468
- value: function getActiveServiceWorkerElseRegister(_ref) {
2469
- var serviceWorkerScope = _ref.serviceWorkerScope,
2470
- serviceWorkerScript = _ref.serviceWorkerScript;
2478
+ value: function getActiveServiceWorkerElseRegister(config, init) {
2471
2479
  try {
2472
- var _this4 = this;
2473
- return ServiceWorkerUtils_await(_this4.getActiveServiceWorker(serviceWorkerScope), function (serviceWorker) {
2474
- return serviceWorker !== undefined ? serviceWorker : ServiceWorkerUtils_await(_this4.registerAuthServiceWorker(serviceWorkerScript), function (_this3$registerAuthSe) {
2475
- return _this3$registerAuthSe.serviceWorker;
2476
- });
2480
+ var _this6 = this;
2481
+ return ServiceWorkerUtils_await(_this6.getActiveServiceWorker(config.serviceWorkerScope), function (serviceWorker) {
2482
+ return serviceWorker !== undefined ? {
2483
+ serviceWorker: serviceWorker,
2484
+ messageSent: false,
2485
+ config: config
2486
+ } : ServiceWorkerUtils_await(_this6.registerServiceWorker(config.serviceWorkerScript, init));
2477
2487
  });
2478
2488
  } catch (e) {
2479
2489
  return Promise.reject(e);
@@ -2487,36 +2497,25 @@ var ServiceWorkerUtils = /*#__PURE__*/function () {
2487
2497
  * We don't need to unregister it: we just need to clear the config when auth ends.
2488
2498
  */
2489
2499
  }, {
2490
- key: "registerAuthServiceWorker",
2491
- value: function registerAuthServiceWorker(serviceWorkerScript) {
2500
+ key: "registerServiceWorker",
2501
+ value: function registerServiceWorker(serviceWorkerScript, init) {
2492
2502
  try {
2503
+ var _this8 = this;
2493
2504
  return ServiceWorkerUtils_catch(function () {
2494
2505
  return ServiceWorkerUtils_await(navigator.serviceWorker.register(serviceWorkerScript), function (registration) {
2495
- return registration.active !== null ? {
2496
- serviceWorker: registration.active,
2497
- config: {
2498
- serviceWorkerScript: serviceWorkerScript,
2499
- serviceWorkerScope: registration.scope
2500
- }
2501
- } : ServiceWorkerUtils_await(new Promise(function (resolve) {
2502
- registration.addEventListener("updatefound", function () {
2503
- var newWorker = registration.installing;
2504
- if (newWorker !== null) {
2505
- newWorker.addEventListener("statechange", function () {
2506
- if (newWorker.state === "activated") {
2507
- resolve({
2508
- config: {
2509
- serviceWorkerScript: serviceWorkerScript,
2510
- serviceWorkerScope: registration.scope
2511
- },
2512
- serviceWorker: newWorker
2513
- });
2514
- }
2515
- });
2506
+ return ServiceWorkerUtils_await(_this8.waitForActiveServiceWorker(registration, init), function (_ref) {
2507
+ var serviceWorker = _ref.serviceWorker,
2508
+ messageSent = _ref.messageSent;
2509
+ return {
2510
+ serviceWorker: serviceWorker,
2511
+ messageSent: messageSent,
2512
+ config: {
2513
+ serviceWorkerScript: serviceWorkerScript,
2514
+ serviceWorkerScope: registration.scope
2516
2515
  }
2517
- });
2518
- }));
2519
- }); // Occurs when: (service worker is already registered AND there's been no code changes) OR (service worker was not previously registered).
2516
+ };
2517
+ });
2518
+ });
2520
2519
  }, function (e) {
2521
2520
  throw new Error("Failed to install Bytescale Service Worker (SW). ".concat(e.name, ": ").concat(e.message));
2522
2521
  });
@@ -2524,6 +2523,52 @@ var ServiceWorkerUtils = /*#__PURE__*/function () {
2524
2523
  return Promise.reject(e);
2525
2524
  }
2526
2525
  }
2526
+ }, {
2527
+ key: "waitForActiveServiceWorker",
2528
+ value: function waitForActiveServiceWorker(registration, init) {
2529
+ try {
2530
+ var _exit2 = false;
2531
+ // We must check the 'installing' state before the 'active' state (see comment below).
2532
+ // The state will be 'installing' when the service worker is installed for the first time, or if there have been
2533
+ // code changes to the service worker, else the state will be 'active'.
2534
+ var installing = registration.installing;
2535
+ return ServiceWorkerUtils_invoke(function () {
2536
+ if (installing !== null) {
2537
+ installing.postMessage(init);
2538
+ _exit2 = true;
2539
+ return ServiceWorkerUtils_await(new Promise(function (resolve) {
2540
+ var stateChangeHandler = function stateChangeHandler(e) {
2541
+ var sw = e.target;
2542
+ if (sw.state === "activated") {
2543
+ installing.removeEventListener("statechange", stateChangeHandler);
2544
+ resolve({
2545
+ messageSent: true,
2546
+ serviceWorker: sw
2547
+ });
2548
+ }
2549
+ };
2550
+ installing.addEventListener("statechange", stateChangeHandler);
2551
+ }));
2552
+ }
2553
+ }, function (_result) {
2554
+ if (_exit2) return _result;
2555
+ // We must check the 'installing' state before the 'active' state, because if we've just installed a new service
2556
+ // worker, then the new service worker will be in the 'installing' slot whereas the old service worker will be in
2557
+ // the 'active' slot. So, if we checked this first, we would always return the old service worker, and therefore the
2558
+ // new service worker would never be initialized.
2559
+ if (registration.active !== null) {
2560
+ return {
2561
+ serviceWorker: registration.active,
2562
+ messageSent: false
2563
+ };
2564
+ }
2565
+ // We expect the service worker to use 'skipWaiting', so we don't expect 'waiting' service workers.
2566
+ throw new Error("Service worker was neither 'installing' or 'active'.");
2567
+ });
2568
+ } catch (e) {
2569
+ return Promise.reject(e);
2570
+ }
2571
+ }
2527
2572
  }, {
2528
2573
  key: "getActiveServiceWorker",
2529
2574
  value: function getActiveServiceWorker(serviceWorkerScope) {
@@ -2582,6 +2627,19 @@ function AuthManagerBrowser_async(f) {
2582
2627
  }
2583
2628
  };
2584
2629
  }
2630
+ function AuthManagerBrowser_invokeIgnored(body) {
2631
+ var result = body();
2632
+ if (result && result.then) {
2633
+ return result.then(AuthManagerBrowser_empty);
2634
+ }
2635
+ }
2636
+ function AuthManagerBrowser_invoke(body, then) {
2637
+ var result = body();
2638
+ if (result && result.then) {
2639
+ return result.then(then);
2640
+ }
2641
+ return then(result);
2642
+ }
2585
2643
  function AuthManagerBrowser_catch(body, recover) {
2586
2644
  try {
2587
2645
  var result = body();
@@ -2626,6 +2684,7 @@ var AuthManagerImpl = /*#__PURE__*/function () {
2626
2684
  function AuthManagerImpl(serviceWorkerUtils) {
2627
2685
  AuthManagerBrowser_classCallCheck(this, AuthManagerImpl);
2628
2686
  this.serviceWorkerUtils = serviceWorkerUtils;
2687
+ this.serviceWorkerScriptFieldName = "serviceWorkerScript";
2629
2688
  this.contentType = "content-type";
2630
2689
  this.contentTypeJson = "application/json";
2631
2690
  this.contentTypeText = "text/plain";
@@ -2650,18 +2709,18 @@ var AuthManagerImpl = /*#__PURE__*/function () {
2650
2709
  if (_this2.isAuthSessionActive()) {
2651
2710
  throw new Error("Auth session already active. Please call 'await endAuthSession()' and then call 'await beginAuthSession(...)' to start a new auth session.");
2652
2711
  }
2653
- var serviceWorkerScriptField = "serviceWorkerScript";
2654
- return AuthManagerBrowser_await(_this2.serviceWorkerUtils.registerServiceWorkerIfSupported(params.serviceWorkerScript, serviceWorkerScriptField, "Falling back to Bytescale CDN cookies for auth. These are third-party cookies, which some modern browsers block."), function (_this2$serviceWorkerU) {
2655
- var newSession = {
2656
- accessToken: undefined,
2657
- accessTokenRefreshHandle: undefined,
2658
- params: params,
2659
- isActive: true,
2660
- authServiceWorker: _this2$serviceWorkerU
2661
- };
2662
- AuthSessionState.setSession(newSession);
2663
- return newSession;
2664
- });
2712
+ var newSession = {
2713
+ accessToken: undefined,
2714
+ accessTokenRefreshHandle: undefined,
2715
+ params: params,
2716
+ isActive: true,
2717
+ authServiceWorker: params.serviceWorkerScript !== undefined && _this2.serviceWorkerUtils.canUseServiceWorkers() ? {
2718
+ serviceWorkerScript: params.serviceWorkerScript,
2719
+ serviceWorkerScope: undefined
2720
+ } : undefined
2721
+ };
2722
+ AuthSessionState.setSession(newSession);
2723
+ return newSession;
2665
2724
  })), function (session) {
2666
2725
  // IMPORTANT: must be called outside the above, else re-entrant deadlock will occur.
2667
2726
  return AuthManagerBrowser_awaitIgnored(_this2.refreshAccessToken(session));
@@ -2686,7 +2745,15 @@ var AuthManagerImpl = /*#__PURE__*/function () {
2686
2745
  clearTimeout(session.accessTokenRefreshHandle);
2687
2746
  }
2688
2747
  return AuthManagerBrowser_await(_this4.deleteAccessToken(session.params), function () {
2689
- return AuthManagerBrowser_awaitIgnored(_this4.setServiceWorkerConfig(session, [])); // Prevent service worker from authorizing subsequent requests.
2748
+ return AuthManagerBrowser_invokeIgnored(function () {
2749
+ if (session.authServiceWorker !== undefined) {
2750
+ // Prevent service worker from authorizing subsequent requests.
2751
+ return AuthManagerBrowser_awaitIgnored(_this4.serviceWorkerUtils.sendMessage({
2752
+ type: "SET_BYTESCALE_AUTH_CONFIG",
2753
+ config: []
2754
+ }, session.authServiceWorker, _this4.serviceWorkerScriptFieldName));
2755
+ }
2756
+ });
2690
2757
  });
2691
2758
  })));
2692
2759
  } catch (e) {
@@ -2713,16 +2780,23 @@ var AuthManagerImpl = /*#__PURE__*/function () {
2713
2780
  // confusion for us in the future (i.e. we may question "do we need to use both together? was there a reason?").
2714
2781
  // Also: if the user has omitted "allowedOrigins" from their JWT, then service worker-based auth is more secure
2715
2782
  // than cookie-based auth, which is another reason to prevent these cookies from being set unless required.
2716
- var setCookie = !_this6.isUsingServiceWorker(session);
2783
+ var setCookie = session.authServiceWorker === undefined;
2717
2784
  return AuthManagerBrowser_await(_this6.setAccessToken(session.params, jwt, setCookie), function (setTokenResult) {
2718
- return AuthManagerBrowser_await(_this6.setServiceWorkerConfig(session, [{
2719
- headers: [{
2720
- key: "Authorization",
2721
- value: "Bearer ".concat(jwt)
2722
- }],
2723
- expires: Date.now() + setTokenResult.ttlSeconds * 1000,
2724
- urlPrefix: "".concat(_this6.getCdnUrl(session.params), "/").concat(session.params.accountId, "/")
2725
- }]), function () {
2785
+ return AuthManagerBrowser_invoke(function () {
2786
+ if (session.authServiceWorker !== undefined) {
2787
+ return AuthManagerBrowser_awaitIgnored(_this6.serviceWorkerUtils.sendMessage({
2788
+ type: "SET_BYTESCALE_AUTH_CONFIG",
2789
+ config: [{
2790
+ headers: [{
2791
+ key: "Authorization",
2792
+ value: "Bearer ".concat(jwt)
2793
+ }],
2794
+ expires: Date.now() + setTokenResult.ttlSeconds * 1000,
2795
+ urlPrefix: "".concat(_this6.getCdnUrl(session.params), "/").concat(session.params.accountId, "/")
2796
+ }]
2797
+ }, session.authServiceWorker, _this6.serviceWorkerScriptFieldName));
2798
+ }
2799
+ }, function () {
2726
2800
  var desiredTtl = setTokenResult.ttlSeconds - _this6.refreshBeforeExpirySeconds;
2727
2801
  timeout = Math.max(desiredTtl, _this6.minJwtTtlSeconds);
2728
2802
  if (desiredTtl !== timeout) {
@@ -2754,32 +2828,6 @@ var AuthManagerImpl = /*#__PURE__*/function () {
2754
2828
  return Promise.reject(e);
2755
2829
  }
2756
2830
  }
2757
- }, {
2758
- key: "isUsingServiceWorker",
2759
- value: function isUsingServiceWorker(session) {
2760
- return session.authServiceWorker !== undefined;
2761
- }
2762
- }, {
2763
- key: "setServiceWorkerConfig",
2764
- value: function setServiceWorkerConfig(session, config) {
2765
- try {
2766
- var _this8 = this;
2767
- if (session.authServiceWorker === undefined) {
2768
- return undefined;
2769
- }
2770
- // We re-fetch the latest active worker, as another tab may have registered a new one, and then the tab may be closed,
2771
- // leaving us as the only open tab but with an old and ineffective service worker reference.
2772
- return AuthManagerBrowser_await(_this8.serviceWorkerUtils.getActiveServiceWorkerElseRegister(session.authServiceWorker), function (serviceWorker) {
2773
- var message = {
2774
- type: "SET_BYTESCALE_AUTH_CONFIG",
2775
- config: config
2776
- };
2777
- serviceWorker.postMessage(message);
2778
- });
2779
- } catch (e) {
2780
- return Promise.reject(e);
2781
- }
2782
- }
2783
2831
  }, {
2784
2832
  key: "getAccessTokenUrl",
2785
2833
  value: function getAccessTokenUrl(params, setCookie) {
@@ -2795,9 +2843,9 @@ var AuthManagerImpl = /*#__PURE__*/function () {
2795
2843
  key: "deleteAccessToken",
2796
2844
  value: function deleteAccessToken(params) {
2797
2845
  try {
2798
- var _this10 = this;
2846
+ var _this8 = this;
2799
2847
  var _a;
2800
- return AuthManagerBrowser_awaitIgnored(BaseAPI.fetch(_this10.getAccessTokenUrl(params, true), {
2848
+ return AuthManagerBrowser_awaitIgnored(BaseAPI.fetch(_this8.getAccessTokenUrl(params, true), {
2801
2849
  method: "DELETE",
2802
2850
  credentials: "include",
2803
2851
  headers: {}
@@ -2813,15 +2861,15 @@ var AuthManagerImpl = /*#__PURE__*/function () {
2813
2861
  key: "setAccessToken",
2814
2862
  value: function setAccessToken(params, jwt, setCookie) {
2815
2863
  try {
2816
- var _this12 = this;
2864
+ var _this10 = this;
2817
2865
  var _a;
2818
2866
  var request = {
2819
2867
  accessToken: jwt
2820
2868
  };
2821
- return AuthManagerBrowser_await(BaseAPI.fetch(_this12.getAccessTokenUrl(params, setCookie), {
2869
+ return AuthManagerBrowser_await(BaseAPI.fetch(_this10.getAccessTokenUrl(params, setCookie), {
2822
2870
  method: "PUT",
2823
2871
  credentials: "include",
2824
- headers: AuthManagerBrowser_defineProperty({}, _this12.contentType, _this12.contentTypeJson),
2872
+ headers: AuthManagerBrowser_defineProperty({}, _this10.contentType, _this10.contentTypeJson),
2825
2873
  body: JSON.stringify(request)
2826
2874
  }, {
2827
2875
  isBytescaleApi: true,
@@ -2837,10 +2885,10 @@ var AuthManagerImpl = /*#__PURE__*/function () {
2837
2885
  key: "getAccessToken",
2838
2886
  value: function getAccessToken(params, headers) {
2839
2887
  try {
2840
- var _this14 = this;
2888
+ var _this12 = this;
2841
2889
  var _a, _b;
2842
2890
  var endpointName = "Your auth API endpoint";
2843
- var requiredContentType = _this14.contentTypeText;
2891
+ var requiredContentType = _this12.contentTypeText;
2844
2892
  return AuthManagerBrowser_await(BaseAPI.fetch(params.authUrl, {
2845
2893
  method: "GET",
2846
2894
  headers: headers
@@ -2848,10 +2896,10 @@ var AuthManagerImpl = /*#__PURE__*/function () {
2848
2896
  isBytescaleApi: false,
2849
2897
  fetchApi: (_a = params.options) === null || _a === void 0 ? void 0 : _a.fetchApi
2850
2898
  }), function (result) {
2851
- var actualContentType = (_b = result.headers.get(_this14.contentType)) !== null && _b !== void 0 ? _b : "";
2899
+ var actualContentType = (_b = result.headers.get(_this12.contentType)) !== null && _b !== void 0 ? _b : "";
2852
2900
  // Support content types like "text/plain; charset=utf-8" and "text/plain"
2853
2901
  if (actualContentType.split(";")[0] !== requiredContentType) {
2854
- throw new Error("".concat(endpointName, " returned \"").concat(actualContentType, "\" for the ").concat(_this14.contentType, " response header, but the Bytescale SDK requires \"").concat(requiredContentType, "\"."));
2902
+ throw new Error("".concat(endpointName, " returned \"").concat(actualContentType, "\" for the ").concat(_this12.contentType, " response header, but the Bytescale SDK requires \"").concat(requiredContentType, "\"."));
2855
2903
  }
2856
2904
  return AuthManagerBrowser_await(result.text(), function (jwt) {
2857
2905
  if (jwt.length === 0) {
@@ -2404,6 +2404,13 @@ function ServiceWorkerUtils_catch(body, recover) {
2404
2404
  }
2405
2405
  return result;
2406
2406
  }
2407
+ function ServiceWorkerUtils_invoke(body, then) {
2408
+ var result = body();
2409
+ if (result && result.then) {
2410
+ return result.then(then);
2411
+ }
2412
+ return then(result);
2413
+ }
2407
2414
  function ServiceWorkerUtils_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
2408
2415
  function ServiceWorkerUtils_defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, ServiceWorkerUtils_toPropertyKey(descriptor.key), descriptor); } }
2409
2416
  function ServiceWorkerUtils_createClass(Constructor, protoProps, staticProps) { if (protoProps) ServiceWorkerUtils_defineProperties(Constructor.prototype, protoProps); if (staticProps) ServiceWorkerUtils_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
@@ -2415,50 +2422,53 @@ var ServiceWorkerUtils = /*#__PURE__*/function () {
2415
2422
  ServiceWorkerUtils_classCallCheck(this, ServiceWorkerUtils);
2416
2423
  }
2417
2424
  ServiceWorkerUtils_createClass(ServiceWorkerUtils, [{
2418
- key: "registerServiceWorkerIfSupported",
2419
- value:
2420
- /**
2421
- * Idempotent.
2422
- *
2423
- * Only returns once the service worker has been activated.
2424
- *
2425
- * We don't need to unregister it: we just need to clear the config when auth ends.
2426
- */
2427
- function registerServiceWorkerIfSupported(serviceWorkerScript, configFieldName, fallbackMessage) {
2425
+ key: "canUseServiceWorkers",
2426
+ value: function canUseServiceWorkers() {
2427
+ return "serviceWorker" in navigator;
2428
+ }
2429
+ }, {
2430
+ key: "sendMessage",
2431
+ value: function sendMessage(message, config, serviceWorkerScriptFieldName) {
2428
2432
  try {
2429
2433
  var _this2 = this;
2430
- if (serviceWorkerScript === undefined) {
2431
- return undefined;
2432
- }
2433
- if (!("serviceWorker" in navigator)) {
2434
- ConsoleUtils.warn("Service workers not supported by browser. ".concat(fallbackMessage));
2435
- return undefined;
2436
- }
2434
+ return ServiceWorkerUtils_await(config.serviceWorkerScope !== undefined ? _this2.getActiveServiceWorkerElseRegister(config, message) : _this2.registerServiceWorkerValidated(config.serviceWorkerScript, message, serviceWorkerScriptFieldName), function (result) {
2435
+ if (!result.messageSent) {
2436
+ result.serviceWorker.postMessage(message);
2437
+ }
2438
+ return result.config;
2439
+ });
2440
+ } catch (e) {
2441
+ return Promise.reject(e);
2442
+ }
2443
+ }
2444
+ }, {
2445
+ key: "registerServiceWorkerValidated",
2446
+ value: function registerServiceWorkerValidated(serviceWorkerScript, init, serviceWorkerScriptFieldName) {
2447
+ try {
2448
+ var _this4 = this;
2437
2449
  if (!serviceWorkerScript.startsWith("/")) {
2438
- throw new Error("The '".concat(configFieldName, "' field must start with a '/' and reference a script at the root of your website."));
2450
+ throw new Error("The '".concat(serviceWorkerScriptFieldName, "' field must start with a '/' and reference a script at the root of your website."));
2439
2451
  }
2440
2452
  var forwardSlashCount = serviceWorkerScript.split("/").length - 1;
2441
2453
  if (forwardSlashCount > 1) {
2442
- ConsoleUtils.warn("The '".concat(configFieldName, "' field should be a root script (e.g. '/script.js'). The Bytescale SDK can only authorize requests originating from webpages that are at the same level as the script or below."));
2454
+ ConsoleUtils.warn("The '".concat(serviceWorkerScriptFieldName, "' field should be a root script (e.g. '/script.js'). The Bytescale SDK can only authorize requests originating from webpages that are at the same level as the script or below."));
2443
2455
  }
2444
- return ServiceWorkerUtils_await(_this2.registerAuthServiceWorker(serviceWorkerScript), function (_this$registerAuthSer) {
2445
- return _this$registerAuthSer.config;
2446
- });
2456
+ return ServiceWorkerUtils_await(_this4.registerServiceWorker(serviceWorkerScript, init));
2447
2457
  } catch (e) {
2448
2458
  return Promise.reject(e);
2449
2459
  }
2450
2460
  }
2451
2461
  }, {
2452
2462
  key: "getActiveServiceWorkerElseRegister",
2453
- value: function getActiveServiceWorkerElseRegister(_ref) {
2454
- var serviceWorkerScope = _ref.serviceWorkerScope,
2455
- serviceWorkerScript = _ref.serviceWorkerScript;
2463
+ value: function getActiveServiceWorkerElseRegister(config, init) {
2456
2464
  try {
2457
- var _this4 = this;
2458
- return ServiceWorkerUtils_await(_this4.getActiveServiceWorker(serviceWorkerScope), function (serviceWorker) {
2459
- return serviceWorker !== undefined ? serviceWorker : ServiceWorkerUtils_await(_this4.registerAuthServiceWorker(serviceWorkerScript), function (_this3$registerAuthSe) {
2460
- return _this3$registerAuthSe.serviceWorker;
2461
- });
2465
+ var _this6 = this;
2466
+ return ServiceWorkerUtils_await(_this6.getActiveServiceWorker(config.serviceWorkerScope), function (serviceWorker) {
2467
+ return serviceWorker !== undefined ? {
2468
+ serviceWorker: serviceWorker,
2469
+ messageSent: false,
2470
+ config: config
2471
+ } : ServiceWorkerUtils_await(_this6.registerServiceWorker(config.serviceWorkerScript, init));
2462
2472
  });
2463
2473
  } catch (e) {
2464
2474
  return Promise.reject(e);
@@ -2472,36 +2482,25 @@ var ServiceWorkerUtils = /*#__PURE__*/function () {
2472
2482
  * We don't need to unregister it: we just need to clear the config when auth ends.
2473
2483
  */
2474
2484
  }, {
2475
- key: "registerAuthServiceWorker",
2476
- value: function registerAuthServiceWorker(serviceWorkerScript) {
2485
+ key: "registerServiceWorker",
2486
+ value: function registerServiceWorker(serviceWorkerScript, init) {
2477
2487
  try {
2488
+ var _this8 = this;
2478
2489
  return ServiceWorkerUtils_catch(function () {
2479
2490
  return ServiceWorkerUtils_await(navigator.serviceWorker.register(serviceWorkerScript), function (registration) {
2480
- return registration.active !== null ? {
2481
- serviceWorker: registration.active,
2482
- config: {
2483
- serviceWorkerScript: serviceWorkerScript,
2484
- serviceWorkerScope: registration.scope
2485
- }
2486
- } : ServiceWorkerUtils_await(new Promise(function (resolve) {
2487
- registration.addEventListener("updatefound", function () {
2488
- var newWorker = registration.installing;
2489
- if (newWorker !== null) {
2490
- newWorker.addEventListener("statechange", function () {
2491
- if (newWorker.state === "activated") {
2492
- resolve({
2493
- config: {
2494
- serviceWorkerScript: serviceWorkerScript,
2495
- serviceWorkerScope: registration.scope
2496
- },
2497
- serviceWorker: newWorker
2498
- });
2499
- }
2500
- });
2491
+ return ServiceWorkerUtils_await(_this8.waitForActiveServiceWorker(registration, init), function (_ref) {
2492
+ var serviceWorker = _ref.serviceWorker,
2493
+ messageSent = _ref.messageSent;
2494
+ return {
2495
+ serviceWorker: serviceWorker,
2496
+ messageSent: messageSent,
2497
+ config: {
2498
+ serviceWorkerScript: serviceWorkerScript,
2499
+ serviceWorkerScope: registration.scope
2501
2500
  }
2502
- });
2503
- }));
2504
- }); // Occurs when: (service worker is already registered AND there's been no code changes) OR (service worker was not previously registered).
2501
+ };
2502
+ });
2503
+ });
2505
2504
  }, function (e) {
2506
2505
  throw new Error("Failed to install Bytescale Service Worker (SW). ".concat(e.name, ": ").concat(e.message));
2507
2506
  });
@@ -2509,6 +2508,52 @@ var ServiceWorkerUtils = /*#__PURE__*/function () {
2509
2508
  return Promise.reject(e);
2510
2509
  }
2511
2510
  }
2511
+ }, {
2512
+ key: "waitForActiveServiceWorker",
2513
+ value: function waitForActiveServiceWorker(registration, init) {
2514
+ try {
2515
+ var _exit2 = false;
2516
+ // We must check the 'installing' state before the 'active' state (see comment below).
2517
+ // The state will be 'installing' when the service worker is installed for the first time, or if there have been
2518
+ // code changes to the service worker, else the state will be 'active'.
2519
+ var installing = registration.installing;
2520
+ return ServiceWorkerUtils_invoke(function () {
2521
+ if (installing !== null) {
2522
+ installing.postMessage(init);
2523
+ _exit2 = true;
2524
+ return ServiceWorkerUtils_await(new Promise(function (resolve) {
2525
+ var stateChangeHandler = function stateChangeHandler(e) {
2526
+ var sw = e.target;
2527
+ if (sw.state === "activated") {
2528
+ installing.removeEventListener("statechange", stateChangeHandler);
2529
+ resolve({
2530
+ messageSent: true,
2531
+ serviceWorker: sw
2532
+ });
2533
+ }
2534
+ };
2535
+ installing.addEventListener("statechange", stateChangeHandler);
2536
+ }));
2537
+ }
2538
+ }, function (_result) {
2539
+ if (_exit2) return _result;
2540
+ // We must check the 'installing' state before the 'active' state, because if we've just installed a new service
2541
+ // worker, then the new service worker will be in the 'installing' slot whereas the old service worker will be in
2542
+ // the 'active' slot. So, if we checked this first, we would always return the old service worker, and therefore the
2543
+ // new service worker would never be initialized.
2544
+ if (registration.active !== null) {
2545
+ return {
2546
+ serviceWorker: registration.active,
2547
+ messageSent: false
2548
+ };
2549
+ }
2550
+ // We expect the service worker to use 'skipWaiting', so we don't expect 'waiting' service workers.
2551
+ throw new Error("Service worker was neither 'installing' or 'active'.");
2552
+ });
2553
+ } catch (e) {
2554
+ return Promise.reject(e);
2555
+ }
2556
+ }
2512
2557
  }, {
2513
2558
  key: "getActiveServiceWorker",
2514
2559
  value: function getActiveServiceWorker(serviceWorkerScope) {
@@ -2567,6 +2612,19 @@ function AuthManagerBrowser_async(f) {
2567
2612
  }
2568
2613
  };
2569
2614
  }
2615
+ function AuthManagerBrowser_invokeIgnored(body) {
2616
+ var result = body();
2617
+ if (result && result.then) {
2618
+ return result.then(AuthManagerBrowser_empty);
2619
+ }
2620
+ }
2621
+ function AuthManagerBrowser_invoke(body, then) {
2622
+ var result = body();
2623
+ if (result && result.then) {
2624
+ return result.then(then);
2625
+ }
2626
+ return then(result);
2627
+ }
2570
2628
  function AuthManagerBrowser_catch(body, recover) {
2571
2629
  try {
2572
2630
  var result = body();
@@ -2611,6 +2669,7 @@ var AuthManagerImpl = /*#__PURE__*/function () {
2611
2669
  function AuthManagerImpl(serviceWorkerUtils) {
2612
2670
  AuthManagerBrowser_classCallCheck(this, AuthManagerImpl);
2613
2671
  this.serviceWorkerUtils = serviceWorkerUtils;
2672
+ this.serviceWorkerScriptFieldName = "serviceWorkerScript";
2614
2673
  this.contentType = "content-type";
2615
2674
  this.contentTypeJson = "application/json";
2616
2675
  this.contentTypeText = "text/plain";
@@ -2635,18 +2694,18 @@ var AuthManagerImpl = /*#__PURE__*/function () {
2635
2694
  if (_this2.isAuthSessionActive()) {
2636
2695
  throw new Error("Auth session already active. Please call 'await endAuthSession()' and then call 'await beginAuthSession(...)' to start a new auth session.");
2637
2696
  }
2638
- var serviceWorkerScriptField = "serviceWorkerScript";
2639
- return AuthManagerBrowser_await(_this2.serviceWorkerUtils.registerServiceWorkerIfSupported(params.serviceWorkerScript, serviceWorkerScriptField, "Falling back to Bytescale CDN cookies for auth. These are third-party cookies, which some modern browsers block."), function (_this2$serviceWorkerU) {
2640
- var newSession = {
2641
- accessToken: undefined,
2642
- accessTokenRefreshHandle: undefined,
2643
- params: params,
2644
- isActive: true,
2645
- authServiceWorker: _this2$serviceWorkerU
2646
- };
2647
- AuthSessionState.setSession(newSession);
2648
- return newSession;
2649
- });
2697
+ var newSession = {
2698
+ accessToken: undefined,
2699
+ accessTokenRefreshHandle: undefined,
2700
+ params: params,
2701
+ isActive: true,
2702
+ authServiceWorker: params.serviceWorkerScript !== undefined && _this2.serviceWorkerUtils.canUseServiceWorkers() ? {
2703
+ serviceWorkerScript: params.serviceWorkerScript,
2704
+ serviceWorkerScope: undefined
2705
+ } : undefined
2706
+ };
2707
+ AuthSessionState.setSession(newSession);
2708
+ return newSession;
2650
2709
  })), function (session) {
2651
2710
  // IMPORTANT: must be called outside the above, else re-entrant deadlock will occur.
2652
2711
  return AuthManagerBrowser_awaitIgnored(_this2.refreshAccessToken(session));
@@ -2671,7 +2730,15 @@ var AuthManagerImpl = /*#__PURE__*/function () {
2671
2730
  clearTimeout(session.accessTokenRefreshHandle);
2672
2731
  }
2673
2732
  return AuthManagerBrowser_await(_this4.deleteAccessToken(session.params), function () {
2674
- return AuthManagerBrowser_awaitIgnored(_this4.setServiceWorkerConfig(session, [])); // Prevent service worker from authorizing subsequent requests.
2733
+ return AuthManagerBrowser_invokeIgnored(function () {
2734
+ if (session.authServiceWorker !== undefined) {
2735
+ // Prevent service worker from authorizing subsequent requests.
2736
+ return AuthManagerBrowser_awaitIgnored(_this4.serviceWorkerUtils.sendMessage({
2737
+ type: "SET_BYTESCALE_AUTH_CONFIG",
2738
+ config: []
2739
+ }, session.authServiceWorker, _this4.serviceWorkerScriptFieldName));
2740
+ }
2741
+ });
2675
2742
  });
2676
2743
  })));
2677
2744
  } catch (e) {
@@ -2698,16 +2765,23 @@ var AuthManagerImpl = /*#__PURE__*/function () {
2698
2765
  // confusion for us in the future (i.e. we may question "do we need to use both together? was there a reason?").
2699
2766
  // Also: if the user has omitted "allowedOrigins" from their JWT, then service worker-based auth is more secure
2700
2767
  // than cookie-based auth, which is another reason to prevent these cookies from being set unless required.
2701
- var setCookie = !_this6.isUsingServiceWorker(session);
2768
+ var setCookie = session.authServiceWorker === undefined;
2702
2769
  return AuthManagerBrowser_await(_this6.setAccessToken(session.params, jwt, setCookie), function (setTokenResult) {
2703
- return AuthManagerBrowser_await(_this6.setServiceWorkerConfig(session, [{
2704
- headers: [{
2705
- key: "Authorization",
2706
- value: "Bearer ".concat(jwt)
2707
- }],
2708
- expires: Date.now() + setTokenResult.ttlSeconds * 1000,
2709
- urlPrefix: "".concat(_this6.getCdnUrl(session.params), "/").concat(session.params.accountId, "/")
2710
- }]), function () {
2770
+ return AuthManagerBrowser_invoke(function () {
2771
+ if (session.authServiceWorker !== undefined) {
2772
+ return AuthManagerBrowser_awaitIgnored(_this6.serviceWorkerUtils.sendMessage({
2773
+ type: "SET_BYTESCALE_AUTH_CONFIG",
2774
+ config: [{
2775
+ headers: [{
2776
+ key: "Authorization",
2777
+ value: "Bearer ".concat(jwt)
2778
+ }],
2779
+ expires: Date.now() + setTokenResult.ttlSeconds * 1000,
2780
+ urlPrefix: "".concat(_this6.getCdnUrl(session.params), "/").concat(session.params.accountId, "/")
2781
+ }]
2782
+ }, session.authServiceWorker, _this6.serviceWorkerScriptFieldName));
2783
+ }
2784
+ }, function () {
2711
2785
  var desiredTtl = setTokenResult.ttlSeconds - _this6.refreshBeforeExpirySeconds;
2712
2786
  timeout = Math.max(desiredTtl, _this6.minJwtTtlSeconds);
2713
2787
  if (desiredTtl !== timeout) {
@@ -2739,32 +2813,6 @@ var AuthManagerImpl = /*#__PURE__*/function () {
2739
2813
  return Promise.reject(e);
2740
2814
  }
2741
2815
  }
2742
- }, {
2743
- key: "isUsingServiceWorker",
2744
- value: function isUsingServiceWorker(session) {
2745
- return session.authServiceWorker !== undefined;
2746
- }
2747
- }, {
2748
- key: "setServiceWorkerConfig",
2749
- value: function setServiceWorkerConfig(session, config) {
2750
- try {
2751
- var _this8 = this;
2752
- if (session.authServiceWorker === undefined) {
2753
- return undefined;
2754
- }
2755
- // We re-fetch the latest active worker, as another tab may have registered a new one, and then the tab may be closed,
2756
- // leaving us as the only open tab but with an old and ineffective service worker reference.
2757
- return AuthManagerBrowser_await(_this8.serviceWorkerUtils.getActiveServiceWorkerElseRegister(session.authServiceWorker), function (serviceWorker) {
2758
- var message = {
2759
- type: "SET_BYTESCALE_AUTH_CONFIG",
2760
- config: config
2761
- };
2762
- serviceWorker.postMessage(message);
2763
- });
2764
- } catch (e) {
2765
- return Promise.reject(e);
2766
- }
2767
- }
2768
2816
  }, {
2769
2817
  key: "getAccessTokenUrl",
2770
2818
  value: function getAccessTokenUrl(params, setCookie) {
@@ -2780,9 +2828,9 @@ var AuthManagerImpl = /*#__PURE__*/function () {
2780
2828
  key: "deleteAccessToken",
2781
2829
  value: function deleteAccessToken(params) {
2782
2830
  try {
2783
- var _this10 = this;
2831
+ var _this8 = this;
2784
2832
  var _a;
2785
- return AuthManagerBrowser_awaitIgnored(BaseAPI.fetch(_this10.getAccessTokenUrl(params, true), {
2833
+ return AuthManagerBrowser_awaitIgnored(BaseAPI.fetch(_this8.getAccessTokenUrl(params, true), {
2786
2834
  method: "DELETE",
2787
2835
  credentials: "include",
2788
2836
  headers: {}
@@ -2798,15 +2846,15 @@ var AuthManagerImpl = /*#__PURE__*/function () {
2798
2846
  key: "setAccessToken",
2799
2847
  value: function setAccessToken(params, jwt, setCookie) {
2800
2848
  try {
2801
- var _this12 = this;
2849
+ var _this10 = this;
2802
2850
  var _a;
2803
2851
  var request = {
2804
2852
  accessToken: jwt
2805
2853
  };
2806
- return AuthManagerBrowser_await(BaseAPI.fetch(_this12.getAccessTokenUrl(params, setCookie), {
2854
+ return AuthManagerBrowser_await(BaseAPI.fetch(_this10.getAccessTokenUrl(params, setCookie), {
2807
2855
  method: "PUT",
2808
2856
  credentials: "include",
2809
- headers: AuthManagerBrowser_defineProperty({}, _this12.contentType, _this12.contentTypeJson),
2857
+ headers: AuthManagerBrowser_defineProperty({}, _this10.contentType, _this10.contentTypeJson),
2810
2858
  body: JSON.stringify(request)
2811
2859
  }, {
2812
2860
  isBytescaleApi: true,
@@ -2822,10 +2870,10 @@ var AuthManagerImpl = /*#__PURE__*/function () {
2822
2870
  key: "getAccessToken",
2823
2871
  value: function getAccessToken(params, headers) {
2824
2872
  try {
2825
- var _this14 = this;
2873
+ var _this12 = this;
2826
2874
  var _a, _b;
2827
2875
  var endpointName = "Your auth API endpoint";
2828
- var requiredContentType = _this14.contentTypeText;
2876
+ var requiredContentType = _this12.contentTypeText;
2829
2877
  return AuthManagerBrowser_await(BaseAPI.fetch(params.authUrl, {
2830
2878
  method: "GET",
2831
2879
  headers: headers
@@ -2833,10 +2881,10 @@ var AuthManagerImpl = /*#__PURE__*/function () {
2833
2881
  isBytescaleApi: false,
2834
2882
  fetchApi: (_a = params.options) === null || _a === void 0 ? void 0 : _a.fetchApi
2835
2883
  }), function (result) {
2836
- var actualContentType = (_b = result.headers.get(_this14.contentType)) !== null && _b !== void 0 ? _b : "";
2884
+ var actualContentType = (_b = result.headers.get(_this12.contentType)) !== null && _b !== void 0 ? _b : "";
2837
2885
  // Support content types like "text/plain; charset=utf-8" and "text/plain"
2838
2886
  if (actualContentType.split(";")[0] !== requiredContentType) {
2839
- throw new Error("".concat(endpointName, " returned \"").concat(actualContentType, "\" for the ").concat(_this14.contentType, " response header, but the Bytescale SDK requires \"").concat(requiredContentType, "\"."));
2887
+ throw new Error("".concat(endpointName, " returned \"").concat(actualContentType, "\" for the ").concat(_this12.contentType, " response header, but the Bytescale SDK requires \"").concat(requiredContentType, "\"."));
2840
2888
  }
2841
2889
  return AuthManagerBrowser_await(result.text(), function (jwt) {
2842
2890
  if (jwt.length === 0) {
@@ -1,5 +1,9 @@
1
- import { ServiceWorkerConfig } from "./model/ServiceWorkerConfig";
2
- export declare class ServiceWorkerUtils {
1
+ import { ServiceWorkerConfig, ServiceWorkerConfigInitialized } from "./model/ServiceWorkerConfig";
2
+ export declare class ServiceWorkerUtils<TMessage> {
3
+ canUseServiceWorkers(): boolean;
4
+ sendMessage(message: TMessage, config: ServiceWorkerConfig, serviceWorkerScriptFieldName: string): Promise<ServiceWorkerConfigInitialized>;
5
+ private registerServiceWorkerValidated;
6
+ private getActiveServiceWorkerElseRegister;
3
7
  /**
4
8
  * Idempotent.
5
9
  *
@@ -7,15 +11,7 @@ export declare class ServiceWorkerUtils {
7
11
  *
8
12
  * We don't need to unregister it: we just need to clear the config when auth ends.
9
13
  */
10
- registerServiceWorkerIfSupported(serviceWorkerScript: string | undefined, configFieldName: string, fallbackMessage: string): Promise<ServiceWorkerConfig | undefined>;
11
- getActiveServiceWorkerElseRegister({ serviceWorkerScope, serviceWorkerScript }: ServiceWorkerConfig): Promise<ServiceWorker>;
12
- /**
13
- * Idempotent.
14
- *
15
- * Only returns once the service worker has been activated.
16
- *
17
- * We don't need to unregister it: we just need to clear the config when auth ends.
18
- */
19
- private registerAuthServiceWorker;
14
+ private registerServiceWorker;
15
+ private waitForActiveServiceWorker;
20
16
  private getActiveServiceWorker;
21
17
  }
@@ -1,4 +1,9 @@
1
- export interface ServiceWorkerConfig {
1
+ export declare type ServiceWorkerConfig = ServiceWorkerConfigUninitialized | ServiceWorkerConfigInitialized;
2
+ export interface ServiceWorkerConfigUninitialized {
3
+ serviceWorkerScope: undefined;
4
+ serviceWorkerScript: string;
5
+ }
6
+ export interface ServiceWorkerConfigInitialized {
2
7
  serviceWorkerScope: string;
3
8
  serviceWorkerScript: string;
4
9
  }
@@ -0,0 +1,6 @@
1
+ import { ServiceWorkerConfigInitialized } from "./ServiceWorkerConfig";
2
+ export interface ServiceWorkerInitStatus {
3
+ config: ServiceWorkerConfigInitialized;
4
+ messageSent: boolean;
5
+ serviceWorker: ServiceWorker;
6
+ }
@@ -1,8 +1,10 @@
1
1
  import { AuthManagerInterface, BeginAuthSessionParams } from "../../private/model/AuthManagerInterface";
2
+ import { AuthSwSetConfigDto } from "../../private/dtos/AuthSwSetConfigDto";
2
3
  import { ServiceWorkerUtils } from "../../private/ServiceWorkerUtils";
3
4
  declare class AuthManagerImpl implements AuthManagerInterface {
4
5
  private readonly serviceWorkerUtils;
5
6
  private readonly authSessionMutex;
7
+ private readonly serviceWorkerScriptFieldName;
6
8
  private readonly contentType;
7
9
  private readonly contentTypeJson;
8
10
  private readonly contentTypeText;
@@ -10,13 +12,11 @@ declare class AuthManagerImpl implements AuthManagerInterface {
10
12
  private readonly maxJwtTtlSeconds;
11
13
  private readonly retryAuthAfterErrorSeconds;
12
14
  private readonly refreshBeforeExpirySeconds;
13
- constructor(serviceWorkerUtils: ServiceWorkerUtils);
15
+ constructor(serviceWorkerUtils: ServiceWorkerUtils<AuthSwSetConfigDto>);
14
16
  isAuthSessionActive(): boolean;
15
17
  beginAuthSession(params: BeginAuthSessionParams): Promise<void>;
16
18
  endAuthSession(): Promise<void>;
17
19
  private refreshAccessToken;
18
- private isUsingServiceWorker;
19
- private setServiceWorkerConfig;
20
20
  private getAccessTokenUrl;
21
21
  private getCdnUrl;
22
22
  private deleteAccessToken;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bytescale/sdk",
3
- "version": "3.18.0",
3
+ "version": "3.20.0",
4
4
  "description": "Bytescale JavaScript SDK",
5
5
  "author": "Bytescale <hello@bytescale.com> (https://www.bytescale.com)",
6
6
  "license": "MIT",