Support sovereign/custom clouds in microsoft authentication provider (#178725)

This commit is contained in:
Brandon Waterloo [MSFT]
2023-04-07 19:38:38 -04:00
committed by GitHub
parent d74f53ef2a
commit f9d14d68fb
7 changed files with 222 additions and 48 deletions

View File

@@ -81,11 +81,13 @@ export class BetterTokenStorage<T> {
return tokens.get(key);
}
async getAll(): Promise<T[]> {
async getAll(predicate?: (item: T) => boolean): Promise<T[]> {
const tokens = await this.getTokens();
const values = new Array<T>();
for (const [_, value] of tokens) {
values.push(value);
if (!predicate || predicate(value)) {
values.push(value);
}
}
return values;
}
@@ -141,11 +143,13 @@ export class BetterTokenStorage<T> {
this._operationInProgress = false;
}
async deleteAll(): Promise<void> {
async deleteAll(predicate?: (item: T) => boolean): Promise<void> {
const tokens = await this.getTokens();
const promises = [];
for (const [key] of tokens) {
promises.push(this.delete(key));
for (const [key, value] of tokens) {
if (!predicate || predicate(value)) {
promises.push(this.delete(key));
}
}
await Promise.all(promises);
}