remix-auth-microsoft
Version:
The Microsoft strategy is used to authenticate users against an account on [Microsoft Active Directory](https://docs.microsoft.com/en-us/azure/active-directory/develop/) using [Remix Auth](https://github.com/sergiodxa/remix-auth). This can be a work/schoo
52 lines (51 loc) • 1.84 kB
TypeScript
import { StrategyVerifyCallback } from "remix-auth";
import { OAuth2Profile, OAuth2Strategy, OAuth2StrategyVerifyParams } from "remix-auth-oauth2";
/**
* @see https://learn.microsoft.com/en-us/azure/active-directory/develop/scopes-oidc#openid-connect-scopes
*/
export type MicrosoftScope = "openid" | "email" | "profile" | "offline_access";
export interface MicrosoftStrategyOptions {
clientId: string;
clientSecret: string;
redirectUri: string;
scope?: MicrosoftScope[] | string;
tenantId?: string;
prompt?: string;
}
export interface MicrosoftProfile extends OAuth2Profile {
id: string;
displayName: string;
name: {
familyName: string;
givenName: string;
};
emails: [{
value: string;
}];
_json: {
sub: string;
name: string;
family_name: string;
given_name: string;
email: string;
};
}
export interface MicrosoftExtraParams extends Record<string, string | number> {
expires_in: 3599;
token_type: "Bearer";
scope: string;
id_token: string;
}
export declare const MicrosoftStrategyDefaultScopes: MicrosoftScope[];
export declare const MicrosoftStrategyDefaultName = "microsoft";
export declare const MicrosoftStrategyScopeSeperator = " ";
export declare class MicrosoftStrategy<User> extends OAuth2Strategy<User, MicrosoftProfile, MicrosoftExtraParams> {
name: string;
scope: string;
private prompt;
private userInfoURL;
constructor({ clientId, clientSecret, redirectUri, scope, prompt, tenantId, }: MicrosoftStrategyOptions, verify: StrategyVerifyCallback<User, OAuth2StrategyVerifyParams<MicrosoftProfile, MicrosoftExtraParams>>);
private getScope;
protected authorizationParams(): URLSearchParams;
protected userProfile(accessToken: string): Promise<MicrosoftProfile>;
}