Skip to content

Commit

Permalink
utils: Add createCredentialsForScopes to ISubscriptionContext (#1765
Browse files Browse the repository at this point in the history
)

* Bump package

* Add comment
  • Loading branch information
nturinski authored Aug 7, 2024
1 parent aa55ccc commit 50f299b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions utils/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ export interface AzExtServiceClientCredentialsT2 {
*/
export interface ISubscriptionContext {
credentials: AzExtServiceClientCredentials;
createCredentialsForScopes: (scopes: string[]) => Promise<AzExtServiceClientCredentials>;
subscriptionDisplayName: string;
subscriptionId: string;
subscriptionPath: string;
Expand Down
4 changes: 2 additions & 2 deletions utils/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion utils/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@microsoft/vscode-azext-utils",
"author": "Microsoft Corporation",
"version": "2.5.3",
"version": "2.5.4",
"description": "Common UI tools for developing Azure extensions for VS Code",
"tags": [
"azure",
Expand Down
7 changes: 6 additions & 1 deletion utils/src/utils/credentialUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ export function createSubscriptionContext(subscription: AzureSubscription): ISub
userId: '', // TODO
subscriptionPath: subscription.subscriptionId,
...subscription,
credentials: createCredential(subscription.authentication.getSession)
credentials: createCredential(subscription.authentication.getSession),
createCredentialsForScopes: async (scopes: string[]) => {
// Have to use bind here because we need to pass a `getSessions` function with a `scopes` parameter to `createCredential`
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
return createCredential(subscription.authentication.getSessionWithScopes.bind(subscription.authentication, scopes));
}
};
}

0 comments on commit 50f299b

Please sign in to comment.