Skip to content

Commit 8438438

Browse files
@W-20893800: Adding support for stateful auth [sfcc-ci compatibility]
1 parent 82c253f commit 8438438

3 files changed

Lines changed: 9 additions & 1 deletion

File tree

packages/b2c-cli/src/commands/auth/client/index.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,13 @@ export default class AuthClient extends BaseCommand<typeof AuthClient> {
172172

173173
this.logger.trace({method, url, body: data}, `[StatefulAuth RESP BODY] ${method} ${url}`);
174174

175+
try {
176+
const decoded = decodeJWT(data.access_token);
177+
this.logger.trace({jwt: decoded.payload}, '[StatefulAuth] JWT payload');
178+
} catch {
179+
// not a JWT; ignore
180+
}
181+
175182
setStoredSession({
176183
clientId,
177184
accessToken: data.access_token,

packages/b2c-cli/src/commands/auth/client/token.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ export default class AuthClientToken extends BaseCommand<typeof AuthClientToken>
6666
const scope = decoded.payload.scope as string | string[] | undefined;
6767
scopes = scope === null || scope === undefined ? [] : Array.isArray(scope) ? scope : scope.split(' ');
6868
this.logger.debug({expires, scopes}, '[StatefulAuth] Decoded JWT claims');
69+
this.logger.trace({jwt: decoded.payload}, '[StatefulAuth] JWT payload');
6970
} catch {
7071
this.logger.debug('[StatefulAuth] Token is not a valid JWT; returning raw token');
7172
}

packages/b2c-tooling-sdk/src/cli/oauth-command.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ export abstract class OAuthCommand<T extends typeof Command> extends BaseCommand
149149

150150
// Use stateful auth only when the session is valid and no explicit auth flags override it
151151
if (validSession && explicitAuthFlags.length === 0) {
152-
this.logger.debug('[Auth] Using stateful session (sfcc-ci compatible store)');
152+
this.logger.debug('[Auth] Using stateful session');
153153
return new StatefulOAuthStrategy(statefulSession, {
154154
accountManagerHost,
155155
scopes: requiredScopes,

0 commit comments

Comments
 (0)