@bytescale/sdk 3.41.0 → 3.42.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.
- package/dist/browser/cjs/main.js +16 -2
- package/dist/browser/esm/main.mjs +16 -2
- package/dist/node/cjs/main.js +5 -0
- package/dist/node/esm/main.mjs +5 -0
- package/dist/types/private/model/AuthManagerInterface.d.ts +4 -0
- package/dist/types/public/browser/AuthManagerBrowser.d.ts +1 -0
- package/dist/types/public/node/AuthManagerNode.d.ts +1 -0
- package/dist/worker/cjs/main.js +5 -0
- package/dist/worker/esm/main.mjs +5 -0
- package/package.json +1 -1
package/dist/browser/cjs/main.js
CHANGED
|
@@ -3178,6 +3178,12 @@ var AuthManagerImpl = /*#__PURE__*/function () {
|
|
|
3178
3178
|
value: function isAuthSessionActive() {
|
|
3179
3179
|
return AuthSessionState.getSession() !== undefined;
|
|
3180
3180
|
}
|
|
3181
|
+
}, {
|
|
3182
|
+
key: "isAuthSessionReady",
|
|
3183
|
+
value: function isAuthSessionReady() {
|
|
3184
|
+
var _a;
|
|
3185
|
+
return ((_a = AuthSessionState.getSession()) === null || _a === void 0 ? void 0 : _a.accessToken) !== undefined;
|
|
3186
|
+
}
|
|
3181
3187
|
}, {
|
|
3182
3188
|
key: "beginAuthSession",
|
|
3183
3189
|
value: function beginAuthSession(params) {
|
|
@@ -3263,7 +3269,7 @@ var AuthManagerImpl = /*#__PURE__*/function () {
|
|
|
3263
3269
|
return AuthManagerBrowser_await(_this3.setAccessToken(session.params, jwt, setCookie), function (setTokenResult) {
|
|
3264
3270
|
return AuthManagerBrowser_invoke(function () {
|
|
3265
3271
|
if (session.authServiceWorker !== undefined) {
|
|
3266
|
-
return
|
|
3272
|
+
return AuthManagerBrowser_await(_this3.serviceWorkerUtils.sendMessage({
|
|
3267
3273
|
type: "SET_BYTESCALE_AUTH_CONFIG",
|
|
3268
3274
|
config: [{
|
|
3269
3275
|
headers: [{
|
|
@@ -3273,7 +3279,14 @@ var AuthManagerImpl = /*#__PURE__*/function () {
|
|
|
3273
3279
|
expires: Date.now() + setTokenResult.ttlSeconds * 1000,
|
|
3274
3280
|
urlPrefix: "".concat(_this3.getCdnUrl(session.params), "/").concat(session.params.accountId, "/")
|
|
3275
3281
|
}]
|
|
3276
|
-
}, session.authServiceWorker, _this3.serviceWorkerScriptFieldName))
|
|
3282
|
+
}, session.authServiceWorker, _this3.serviceWorkerScriptFieldName), function () {
|
|
3283
|
+
// Allow time for the service worker to receive and process the message. Since this is asynchronous and not
|
|
3284
|
+
// synchronized, we need to wait for a sufficient amount of time to ensure the service worker is ready to
|
|
3285
|
+
// authenticate requests, so that after 'beginAuthSession' completes, users can start making requests.
|
|
3286
|
+
return AuthManagerBrowser_awaitIgnored(new Promise(function (resolve) {
|
|
3287
|
+
return setTimeout(resolve, 100);
|
|
3288
|
+
}));
|
|
3289
|
+
});
|
|
3277
3290
|
}
|
|
3278
3291
|
}, function () {
|
|
3279
3292
|
var desiredTtl = setTokenResult.ttlSeconds - _this3.refreshBeforeExpirySeconds;
|
|
@@ -3282,6 +3295,7 @@ var AuthManagerImpl = /*#__PURE__*/function () {
|
|
|
3282
3295
|
ConsoleUtils.warn("JWT expiration is too short: waiting for ".concat(timeout, " seconds before refreshing."));
|
|
3283
3296
|
}
|
|
3284
3297
|
// There's no need to print a warning for this: it's OK to silently request the JWT before it expires. Also, this is 24 days in this case!
|
|
3298
|
+
// Set this at the end, as it's also used to signal 'isAuthSessionReady', so must be set after configuring the Service Worker, etc.
|
|
3285
3299
|
timeout = Math.min(timeout, _this3.maxJwtTtlSeconds);
|
|
3286
3300
|
session.accessToken = setTokenResult.accessToken;
|
|
3287
3301
|
});
|
|
@@ -3163,6 +3163,12 @@ var AuthManagerImpl = /*#__PURE__*/function () {
|
|
|
3163
3163
|
value: function isAuthSessionActive() {
|
|
3164
3164
|
return AuthSessionState.getSession() !== undefined;
|
|
3165
3165
|
}
|
|
3166
|
+
}, {
|
|
3167
|
+
key: "isAuthSessionReady",
|
|
3168
|
+
value: function isAuthSessionReady() {
|
|
3169
|
+
var _a;
|
|
3170
|
+
return ((_a = AuthSessionState.getSession()) === null || _a === void 0 ? void 0 : _a.accessToken) !== undefined;
|
|
3171
|
+
}
|
|
3166
3172
|
}, {
|
|
3167
3173
|
key: "beginAuthSession",
|
|
3168
3174
|
value: function beginAuthSession(params) {
|
|
@@ -3248,7 +3254,7 @@ var AuthManagerImpl = /*#__PURE__*/function () {
|
|
|
3248
3254
|
return AuthManagerBrowser_await(_this3.setAccessToken(session.params, jwt, setCookie), function (setTokenResult) {
|
|
3249
3255
|
return AuthManagerBrowser_invoke(function () {
|
|
3250
3256
|
if (session.authServiceWorker !== undefined) {
|
|
3251
|
-
return
|
|
3257
|
+
return AuthManagerBrowser_await(_this3.serviceWorkerUtils.sendMessage({
|
|
3252
3258
|
type: "SET_BYTESCALE_AUTH_CONFIG",
|
|
3253
3259
|
config: [{
|
|
3254
3260
|
headers: [{
|
|
@@ -3258,7 +3264,14 @@ var AuthManagerImpl = /*#__PURE__*/function () {
|
|
|
3258
3264
|
expires: Date.now() + setTokenResult.ttlSeconds * 1000,
|
|
3259
3265
|
urlPrefix: "".concat(_this3.getCdnUrl(session.params), "/").concat(session.params.accountId, "/")
|
|
3260
3266
|
}]
|
|
3261
|
-
}, session.authServiceWorker, _this3.serviceWorkerScriptFieldName))
|
|
3267
|
+
}, session.authServiceWorker, _this3.serviceWorkerScriptFieldName), function () {
|
|
3268
|
+
// Allow time for the service worker to receive and process the message. Since this is asynchronous and not
|
|
3269
|
+
// synchronized, we need to wait for a sufficient amount of time to ensure the service worker is ready to
|
|
3270
|
+
// authenticate requests, so that after 'beginAuthSession' completes, users can start making requests.
|
|
3271
|
+
return AuthManagerBrowser_awaitIgnored(new Promise(function (resolve) {
|
|
3272
|
+
return setTimeout(resolve, 100);
|
|
3273
|
+
}));
|
|
3274
|
+
});
|
|
3262
3275
|
}
|
|
3263
3276
|
}, function () {
|
|
3264
3277
|
var desiredTtl = setTokenResult.ttlSeconds - _this3.refreshBeforeExpirySeconds;
|
|
@@ -3267,6 +3280,7 @@ var AuthManagerImpl = /*#__PURE__*/function () {
|
|
|
3267
3280
|
ConsoleUtils.warn("JWT expiration is too short: waiting for ".concat(timeout, " seconds before refreshing."));
|
|
3268
3281
|
}
|
|
3269
3282
|
// There's no need to print a warning for this: it's OK to silently request the JWT before it expires. Also, this is 24 days in this case!
|
|
3283
|
+
// Set this at the end, as it's also used to signal 'isAuthSessionReady', so must be set after configuring the Service Worker, etc.
|
|
3270
3284
|
timeout = Math.min(timeout, _this3.maxJwtTtlSeconds);
|
|
3271
3285
|
session.accessToken = setTokenResult.accessToken;
|
|
3272
3286
|
});
|
package/dist/node/cjs/main.js
CHANGED
|
@@ -3092,6 +3092,11 @@ var AuthManagerImpl = /*#__PURE__*/function () {
|
|
|
3092
3092
|
value: function isAuthSessionActive() {
|
|
3093
3093
|
return false;
|
|
3094
3094
|
}
|
|
3095
|
+
}, {
|
|
3096
|
+
key: "isAuthSessionReady",
|
|
3097
|
+
value: function isAuthSessionReady() {
|
|
3098
|
+
return false;
|
|
3099
|
+
}
|
|
3095
3100
|
}]);
|
|
3096
3101
|
}();
|
|
3097
3102
|
/**
|
package/dist/node/esm/main.mjs
CHANGED
|
@@ -3087,6 +3087,11 @@ var AuthManagerImpl = /*#__PURE__*/function () {
|
|
|
3087
3087
|
value: function isAuthSessionActive() {
|
|
3088
3088
|
return false;
|
|
3089
3089
|
}
|
|
3090
|
+
}, {
|
|
3091
|
+
key: "isAuthSessionReady",
|
|
3092
|
+
value: function isAuthSessionReady() {
|
|
3093
|
+
return false;
|
|
3094
|
+
}
|
|
3090
3095
|
}]);
|
|
3091
3096
|
}();
|
|
3092
3097
|
/**
|
|
@@ -104,4 +104,8 @@ export interface AuthManagerInterface {
|
|
|
104
104
|
* Checks if an authenticated Bytescale API and Bytescale CDN session is active.
|
|
105
105
|
*/
|
|
106
106
|
isAuthSessionActive: () => boolean;
|
|
107
|
+
/**
|
|
108
|
+
* Checks if an authenticated Bytescale API and Bytescale CDN session is active and ready to authenticate HTTP requests.
|
|
109
|
+
*/
|
|
110
|
+
isAuthSessionReady: () => boolean;
|
|
107
111
|
}
|
|
@@ -14,6 +14,7 @@ declare class AuthManagerImpl implements AuthManagerInterface {
|
|
|
14
14
|
private readonly refreshBeforeExpirySeconds;
|
|
15
15
|
constructor(serviceWorkerUtils: ServiceWorkerUtils<AuthSwSetConfigDto>);
|
|
16
16
|
isAuthSessionActive(): boolean;
|
|
17
|
+
isAuthSessionReady(): boolean;
|
|
17
18
|
beginAuthSession(params: BeginAuthSessionParams): Promise<void>;
|
|
18
19
|
endAuthSession(): Promise<void>;
|
|
19
20
|
private refreshAccessToken;
|
|
@@ -3,6 +3,7 @@ declare class AuthManagerImpl implements AuthManagerInterface {
|
|
|
3
3
|
beginAuthSession(_params: BeginAuthSessionParams): Promise<void>;
|
|
4
4
|
endAuthSession(): Promise<void>;
|
|
5
5
|
isAuthSessionActive(): boolean;
|
|
6
|
+
isAuthSessionReady(): boolean;
|
|
6
7
|
}
|
|
7
8
|
/**
|
|
8
9
|
* Alternative way of implementing a static class (i.e. all methods static). We do this so we can use a interface on the class (interfaces can't define static methods).
|
package/dist/worker/cjs/main.js
CHANGED
|
@@ -2626,6 +2626,11 @@ var AuthManagerImpl = /*#__PURE__*/function () {
|
|
|
2626
2626
|
value: function isAuthSessionActive() {
|
|
2627
2627
|
return false;
|
|
2628
2628
|
}
|
|
2629
|
+
}, {
|
|
2630
|
+
key: "isAuthSessionReady",
|
|
2631
|
+
value: function isAuthSessionReady() {
|
|
2632
|
+
return false;
|
|
2633
|
+
}
|
|
2629
2634
|
}]);
|
|
2630
2635
|
}();
|
|
2631
2636
|
/**
|
package/dist/worker/esm/main.mjs
CHANGED
|
@@ -2611,6 +2611,11 @@ var AuthManagerImpl = /*#__PURE__*/function () {
|
|
|
2611
2611
|
value: function isAuthSessionActive() {
|
|
2612
2612
|
return false;
|
|
2613
2613
|
}
|
|
2614
|
+
}, {
|
|
2615
|
+
key: "isAuthSessionReady",
|
|
2616
|
+
value: function isAuthSessionReady() {
|
|
2617
|
+
return false;
|
|
2618
|
+
}
|
|
2614
2619
|
}]);
|
|
2615
2620
|
}();
|
|
2616
2621
|
/**
|