@equinor/fusion
Advanced tools
Comparing version 0.1.57 to 0.1.58
@@ -60,2 +60,3 @@ import AuthApp from "./AuthApp"; | ||
getCachedUser(): AuthUser | null; | ||
private updateTokenForAppAsync; | ||
protected cacheUserAsync(user: AuthUser): Promise<void>; | ||
@@ -62,0 +63,0 @@ protected static getResourceOrigin(resource: string): string; |
@@ -36,6 +36,3 @@ import AuthApp from "./AuthApp"; | ||
this.apps.push(app); | ||
await this.cache.storeTokenAsync(app, parsedToken); | ||
const cachedUser = (await this.getCachedUserAsync()) || AuthUser.createFromToken(parsedToken); | ||
cachedUser.mergeWithToken(parsedToken); | ||
await this.cacheUserAsync(cachedUser); | ||
await this.updateTokenForAppAsync(app, token); | ||
window.location.hash = ""; | ||
@@ -57,3 +54,8 @@ } | ||
} | ||
return await this.refreshTokenAsync(resource); | ||
const refreshedToken = await this.refreshTokenAsync(resource); | ||
if (!refreshedToken) { | ||
return null; | ||
} | ||
await this.updateTokenForAppAsync(app, refreshedToken); | ||
return refreshedToken; | ||
} | ||
@@ -111,2 +113,9 @@ async refreshTokenAsync(resource) { | ||
} | ||
async updateTokenForAppAsync(app, token) { | ||
const parsedToken = AuthToken.parse(token); | ||
await this.cache.storeTokenAsync(app, parsedToken); | ||
const cachedUser = (await this.getCachedUserAsync()) || AuthUser.createFromToken(parsedToken); | ||
cachedUser.mergeWithToken(parsedToken); | ||
await this.cacheUserAsync(cachedUser); | ||
} | ||
async cacheUserAsync(user) { | ||
@@ -113,0 +122,0 @@ this.cachedUser = user; |
{ | ||
"name": "@equinor/fusion", | ||
"version": "0.1.57", | ||
"version": "0.1.58", | ||
"description": "Everything a Fusion app needs to communicate with the core", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
128462
2995