-
Notifications
You must be signed in to change notification settings - Fork 161
feat: Cache interactive login credentials #222
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great progress - Let me know if you need help wrapping this up.
const CONFIG_DIRECTORY = path.join(os.homedir(), ".azure"); | ||
const SLS_TOKEN_FILE = path.join(CONFIG_DIRECTORY, "slsTokenCache.json"); | ||
|
||
export class SimpleFileTokenCache { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there an actual interface type definition that we can reference here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good, have a few comments
this.load(); | ||
} | ||
|
||
public add(entries: any, cb?: any) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's cb
? a more descriptive name would be better
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
callback
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's a callback, I'll switch the name
} | ||
} | ||
|
||
public remove(entries: any, cb?: any) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
callback
} | ||
} | ||
|
||
public find(query: any, cb?: any) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
|
||
//-------- File toke cache specific methods | ||
|
||
public addSubs(entries: any) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does entries change? can we be more specific than just default to any
?
|
||
public addSubs(entries: any) { | ||
this.subscriptions.push(...entries); | ||
this.subscriptions = this.subscriptions.reduce((acc, current) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's acc
stand for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's the accumulator for the reducer, not a very exciting name haha
* Add simple file token cache * Address pr feedback * Added tests for existing and nonexisting cached login * Cleaned up cached login test for login service * Clean up simpleFileTokenCache, add tests * Add param to simpleFileTokenCache constructor for path * Updated simple file token cache tests * Restore fs mocks at end of each test * Fix getTokens in mock * Fixing broken tests * Address pr feedback * Pushing again * Address more pr feedback
feat: Cache interactive login credentials
Currently once a user logs in using the interactive login, there is no way to cache the credentials and the user must keep logging in through that method. This adds a simple file token cache that saves the credentials and subscription information and then uses those to login, reducing number of logins required.
AB#359