@@ -3,9 +3,9 @@ import {applicationId} from './identity.js'
33import { ApplicationToken , IdentityToken , validateCachedIdentityTokenStructure } from './schema.js'
44import { validateIdentityToken } from './identity-token-validation.js'
55import { sessionConstants } from '../constants.js'
6- import { outputDebug } from '../../../public/node/output.js'
76import { firstPartyDev } from '../../../public/node/context/local.js'
87import { OAuthApplications } from '../session.js'
8+ import { outputDebug } from '@shopify/cli-kit/node/output'
99
1010type ValidationResult = 'needs_refresh' | 'needs_full_auth' | 'ok'
1111
@@ -35,7 +35,6 @@ export async function validateSession(
3535) : Promise < ValidationResult > {
3636 if ( ! session ) return 'needs_full_auth'
3737 const scopesAreValid = validateScopes ( scopes , session . identity )
38- const identityIsValid = await validateIdentityToken ( session . identity . accessToken )
3938 if ( ! scopesAreValid ) return 'needs_full_auth'
4039 let tokensAreExpired = isTokenExpired ( session . identity )
4140
@@ -64,18 +63,18 @@ export async function validateSession(
6463 tokensAreExpired = tokensAreExpired || isTokenExpired ( token )
6564 }
6665
67- outputDebug ( `
68- The validation of the token for application/identity completed with the following results:
69- - It's expired: ${ tokensAreExpired }
70- - It's invalid in identity: ${ ! identityIsValid }
71- ` )
66+ outputDebug ( `- Token validation -> It's expired: ${ tokensAreExpired } ` )
7267
7368 if ( ! validateCachedIdentityTokenStructure ( session . identity ) ) {
7469 return 'needs_full_auth'
7570 }
7671
7772 if ( tokensAreExpired ) return 'needs_refresh'
73+
74+ const identityIsValid = await validateIdentityToken ( session . identity . accessToken )
75+ outputDebug ( `- Token validation -> It's invalid in identity: ${ ! identityIsValid } ` )
7876 if ( ! identityIsValid ) return 'needs_full_auth'
77+
7978 return 'ok'
8079}
8180
0 commit comments