code from master

Signed-off-by: Gasan Guseinov <gasan.guseinov@ing.com>
This commit is contained in:
Gasan Guseinov
2024-08-30 16:33:19 +02:00
committed by Gasan.Guseinov
parent 2a951d6fe5
commit 2f56fd30e8
2 changed files with 11 additions and 26 deletions
@@ -64,21 +64,6 @@ export class RefreshingAuthSessionManager<T> implements SessionManager<T> {
}
async getSession(options: GetSessionOptions): Promise<T | undefined> {
// eslint-disable-next-line consistent-this
const that = this;
const createSession = async () => {
// We can call authRequester multiple times, the returned session will contain all requested scopes.
that.currentSession = await that.connector.createSession({
...options,
scopes: that.helper.getExtendedScope(
that.currentSession,
options.scopes,
),
});
that.stateTracker.setIsSignedIn(true);
return that.currentSession;
};
if (
this.helper.sessionExistsAndHasScope(this.currentSession, options.scopes)
) {
@@ -98,17 +83,10 @@ export class RefreshingAuthSessionManager<T> implements SessionManager<T> {
}
return refreshedSession;
} catch (error) {
try {
return createSession();
} catch (err) {
if (options.optional) {
return undefined;
}
throw new Error(
`Cannot create a new session after failing to refresh the session. Session refresh error: ${error}`,
{ cause: err },
);
if (options.optional) {
return undefined;
}
throw error;
}
}
@@ -135,7 +113,13 @@ export class RefreshingAuthSessionManager<T> implements SessionManager<T> {
return undefined;
}
return createSession();
// We can call authRequester multiple times, the returned session will contain all requested scopes.
this.currentSession = await this.connector.createSession({
...options,
scopes: this.helper.getExtendedScope(this.currentSession, options.scopes),
});
this.stateTracker.setIsSignedIn(true);
return this.currentSession;
}
async removeSession() {
@@ -348,6 +348,7 @@ export class GoogleGCSPublish implements PublisherBase {
* can be used to verify if there are any pre-generated docs available to serve.
*/
async hasDocsBeenGenerated(entity: Entity): Promise<boolean> {
Promise.resolve();
return new Promise(resolve => {
const entityTriplet = `${entity.metadata.namespace}/${entity.kind}/${entity.metadata.name}`;
const entityDir = this.legacyPathCasing