Skip to content

Commit 577ccd6

Browse files
authored
[office-js] add getAuthContext and AuthOptions APIs (DefinitelyTyped#73279)
1 parent f7a1192 commit 577ccd6

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

types/office-js/index.d.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3635,6 +3635,19 @@ declare namespace Office {
36353635
* @returns Promise to the access token.
36363636
*/
36373637
getAccessToken(options?: AuthOptions): Promise<string>;
3638+
/**
3639+
* Gets information about the signed-in user.
3640+
* The add-in can pass this information to the Microsoft authentication library (MSAL.js) to get an access token for the current session.
3641+
*
3642+
* @remarks
3643+
*
3644+
* **Hosts**: Excel, OneNote, Outlook, PowerPoint, Word
3645+
*
3646+
* **Requirement set**: NestedAppAuth 1.1
3647+
*
3648+
* @returns Promise to the AuthContext object.
3649+
*/
3650+
getAuthContext(): Promise<AuthContext>;
36383651
}
36393652
/**
36403653
* Provides options for the user experience when Office obtains an access token to the add-in from AAD v. 2.0 with the `getAccessToken` method.
@@ -3691,6 +3704,35 @@ declare namespace Office {
36913704
*/
36923705
forMSGraphAccess?: boolean;
36933706
}
3707+
/**
3708+
* Represents the user information which can be passed to the Microsoft Authentication Library for JavaScript (MSAL.js).
3709+
*/
3710+
interface AuthContext {
3711+
/**
3712+
* The unique ID of the account.
3713+
*/
3714+
userObjectId: string;
3715+
/**
3716+
* The full tenant or organizational ID that this account belongs to.
3717+
*/
3718+
tenantId: string;
3719+
/**
3720+
* The user's internet-style login name, based on the Internet standard RFC. Also known as UPN.
3721+
*/
3722+
userPrincipalName: string;
3723+
/**
3724+
* The identity type by its identity provider (IdP) for this account. "aad" represents an organization account and "msa" represents a {@link https://support.microsoft.com/account-billing/72f10e1e-cab8-4950-a8da-7c45339575b0 | Microsoft personal account}.
3725+
*/
3726+
authorityType: "aad" | "msa" | "other";
3727+
/**
3728+
* The URL that indicates a directory that MSAL can request tokens from.
3729+
*/
3730+
authorityBaseUrl: string;
3731+
/**
3732+
* An optional claim that provides a hint about the user account attempting to sign in.
3733+
*/
3734+
loginHint: string;
3735+
}
36943736
/**
36953737
* Represents a modal notification dialog that can appear when the user attempts to close a document. The document won't close until the user responds.
36963738
* The notification dialog will allow the user to confirm the request to close the document or cancel the request to close the document.

0 commit comments

Comments
 (0)