@lvce-editor/auth-worker 3.13.2 → 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.
- package/dist/authWorkerMain.js +25 -17
- package/package.json +1 -1
package/dist/authWorkerMain.js
CHANGED
|
@@ -1134,21 +1134,6 @@ const initializeOpenerWorker = async () => {
|
|
|
1134
1134
|
set(rpc);
|
|
1135
1135
|
};
|
|
1136
1136
|
|
|
1137
|
-
const millisecondsPerSecond = 1000;
|
|
1138
|
-
const getAccessTokenExpiresAt = (expiresIn, now = Date.now()) => {
|
|
1139
|
-
if (typeof expiresIn !== 'number' || !Number.isFinite(expiresIn) || expiresIn <= 0) {
|
|
1140
|
-
return undefined;
|
|
1141
|
-
}
|
|
1142
|
-
return now + expiresIn * millisecondsPerSecond;
|
|
1143
|
-
};
|
|
1144
|
-
const isAccessTokenValid = (accessToken, expiresAt, now = Date.now()) => {
|
|
1145
|
-
if (!accessToken || !expiresAt) {
|
|
1146
|
-
return false;
|
|
1147
|
-
}
|
|
1148
|
-
const expiresAtNumber = Number(expiresAt);
|
|
1149
|
-
return Number.isFinite(expiresAtNumber) && expiresAtNumber > now;
|
|
1150
|
-
};
|
|
1151
|
-
|
|
1152
1137
|
const state$3 = {
|
|
1153
1138
|
backendUrl: ''
|
|
1154
1139
|
};
|
|
@@ -1169,6 +1154,26 @@ const setAuthPlatform = value => {
|
|
|
1169
1154
|
state$2.platform = value;
|
|
1170
1155
|
};
|
|
1171
1156
|
|
|
1157
|
+
const configure = options => {
|
|
1158
|
+
setAuthBackendUrl(options.backendUrl);
|
|
1159
|
+
setAuthPlatform(options.platform);
|
|
1160
|
+
};
|
|
1161
|
+
|
|
1162
|
+
const millisecondsPerSecond = 1000;
|
|
1163
|
+
const getAccessTokenExpiresAt = (expiresIn, now = Date.now()) => {
|
|
1164
|
+
if (typeof expiresIn !== 'number' || !Number.isFinite(expiresIn) || expiresIn <= 0) {
|
|
1165
|
+
return undefined;
|
|
1166
|
+
}
|
|
1167
|
+
return now + expiresIn * millisecondsPerSecond;
|
|
1168
|
+
};
|
|
1169
|
+
const isAccessTokenValid = (accessToken, expiresAt, now = Date.now()) => {
|
|
1170
|
+
if (!accessToken || !expiresAt) {
|
|
1171
|
+
return false;
|
|
1172
|
+
}
|
|
1173
|
+
const expiresAtNumber = Number(expiresAt);
|
|
1174
|
+
return Number.isFinite(expiresAtNumber) && expiresAtNumber > now;
|
|
1175
|
+
};
|
|
1176
|
+
|
|
1172
1177
|
const authStorageId = 'lvce-editor.auth';
|
|
1173
1178
|
const deleteSecret = async key => {
|
|
1174
1179
|
await deleteSecret$1(authStorageId, key);
|
|
@@ -2477,8 +2482,10 @@ const getPlatform = options => {
|
|
|
2477
2482
|
};
|
|
2478
2483
|
const initialize = async options => {
|
|
2479
2484
|
const backendUrl = getBackendUrl(options);
|
|
2480
|
-
|
|
2481
|
-
|
|
2485
|
+
configure({
|
|
2486
|
+
backendUrl,
|
|
2487
|
+
platform: getPlatform(options)
|
|
2488
|
+
});
|
|
2482
2489
|
try {
|
|
2483
2490
|
if (backendUrl) {
|
|
2484
2491
|
const completedBrowserLogin = await completeBrowserOidcLogin(backendUrl);
|
|
@@ -3178,6 +3185,7 @@ const logout = async state => {
|
|
|
3178
3185
|
|
|
3179
3186
|
const commandMap = {
|
|
3180
3187
|
'Auth.clearMocks': clear,
|
|
3188
|
+
'Auth.configure': configure,
|
|
3181
3189
|
'Auth.consumeNextLoginResponse': consumeNextLoginResponse,
|
|
3182
3190
|
'Auth.consumeNextRefreshResponse': consumeNextRefreshResponse,
|
|
3183
3191
|
'Auth.getAccessToken': getAccessToken,
|