@@ -10,7 +10,7 @@ import { getLogger } from '../../shared/logger/logger'
1010import fs from '../../shared/fs/fs'
1111import { createDiskCache , KeyedCache , mapCache } from '../../shared/utilities/cacheUtils'
1212import { stripUndefined } from '../../shared/utilities/collectionUtils'
13- import { getMissingProps , hasProps , selectFrom } from '../../shared/utilities/tsUtils'
13+ import { hasProps , selectFrom } from '../../shared/utilities/tsUtils'
1414import { SsoToken , ClientRegistration } from './model'
1515import { DevSettings } from '../../shared/settings'
1616import { onceChanged } from '../../shared/utilities/functionUtils'
@@ -79,6 +79,11 @@ export function getTokenCache(directory = getCacheDir()): KeyedCache<SsoAccess>
7979 }
8080
8181 function read ( data : StoredToken ) : SsoAccess {
82+ // Validate data is not missing. Since the input data is passed directly from whatever is on disk.
83+ if ( ! hasProps ( data , 'accessToken' ) ) {
84+ throw new ToolkitError ( `SSO cache data looks malformed` )
85+ }
86+
8287 const registration = hasProps ( data , 'clientId' , 'clientSecret' , 'registrationExpiresAt' )
8388 ? {
8489 ...selectFrom ( data , 'clientId' , 'clientSecret' , 'scopes' , 'startUrl' ) ,
@@ -93,12 +98,6 @@ export function getTokenCache(directory = getCacheDir()): KeyedCache<SsoAccess>
9398
9499 stripUndefined ( token )
95100
96- // Validate data is not missing.
97- const missingProps = getMissingProps ( token , 'accessToken' , 'refreshToken' )
98- if ( missingProps . length > 0 ) {
99- throw new ToolkitError ( `SSO cache data unexpectedly missing props: ${ JSON . stringify ( missingProps ) } ` )
100- }
101-
102101 return {
103102 token,
104103 registration,
0 commit comments