@lvce-editor/auth-worker 3.8.0 → 3.8.1
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 +3 -1
- package/package.json +1 -1
package/dist/authWorkerMain.js
CHANGED
|
@@ -3035,13 +3035,14 @@ const hasAuthorizationCode = value => {
|
|
|
3035
3035
|
const getElectronAuthorizationCode = async uid => {
|
|
3036
3036
|
return invoke$3('OAuthServer.getCode', String(uid));
|
|
3037
3037
|
};
|
|
3038
|
-
const waitForElectronBackendLogin = async (backendUrl, uid, redirectUri, codeVerifier, timeoutMs = 30_000, pollIntervalMs = 1000, getAuthorizationCode = getElectronAuthorizationCode, exchangeAuthorizationCode = exchangeElectronAuthorizationCode) => {
|
|
3038
|
+
const waitForElectronBackendLogin = async (backendUrl, uid, redirectUri, codeVerifier, timeoutMs = 30_000, pollIntervalMs = 1000, getAuthorizationCode = getElectronAuthorizationCode, exchangeAuthorizationCode = exchangeElectronAuthorizationCode, getUserName = getOidcUserName) => {
|
|
3039
3039
|
const deadline = Date.now() + timeoutMs;
|
|
3040
3040
|
while (Date.now() < deadline) {
|
|
3041
3041
|
const authorizationCode = await getAuthorizationCode(uid);
|
|
3042
3042
|
if (hasAuthorizationCode(authorizationCode)) {
|
|
3043
3043
|
const tokenResponse = await exchangeAuthorizationCode(backendUrl, authorizationCode, redirectUri, codeVerifier);
|
|
3044
3044
|
const authAccessTokenExpiresAt = getAccessTokenExpiresAt(tokenResponse.expiresIn);
|
|
3045
|
+
const userName = await getUserName(backendUrl, tokenResponse.accessToken);
|
|
3045
3046
|
return {
|
|
3046
3047
|
authAccessToken: tokenResponse.accessToken,
|
|
3047
3048
|
...(authAccessTokenExpiresAt && {
|
|
@@ -3049,6 +3050,7 @@ const waitForElectronBackendLogin = async (backendUrl, uid, redirectUri, codeVer
|
|
|
3049
3050
|
}),
|
|
3050
3051
|
authErrorMessage: '',
|
|
3051
3052
|
authRefreshToken: tokenResponse.refreshToken,
|
|
3053
|
+
userName,
|
|
3052
3054
|
userState: tokenResponse.accessToken ? 'loggedIn' : 'loggedOut'
|
|
3053
3055
|
};
|
|
3054
3056
|
}
|