remix-auth-afdian
Version:
爱发电 for Remix Auth
53 lines (52 loc) • 1.93 kB
TypeScript
import { type StrategyVerifyCallback } from 'remix-auth';
import { OAuth2Profile, OAuth2Strategy, OAuth2StrategyVerifyParams } from 'remix-auth-oauth2';
export interface AfdianStrategyOptions {
clientID: string;
clientSecret: string;
callbackURL: string;
scope?: AfdianScope[] | string;
userAgent?: string;
authorizationURL?: string;
tokenURL?: string;
}
export type AfdianScope = 'basic';
export type AfdianEmails = OAuth2Profile['emails'];
export type AfdianEmailsResponse = {
email: string;
verified: boolean;
primary: boolean;
visibility: string | null;
}[];
export interface AfdianProfile extends OAuth2Profile {
provider: string;
id: string;
displayName: string;
emails?: AfdianEmails;
photos: [{
value: string;
}];
_json: {
user_id?: string;
user_private_id?: string;
name?: string;
avatar?: string;
};
}
export interface AfdianExtraParams extends Record<string, string | number | null> {
}
export declare const AfdianStrategyDefaultName = "afdian";
export declare const AfdianStrategyDefaultScope: AfdianScope;
export declare const AfdianStrategyScopeSeperator = " ";
export declare class AfdianStrategy<User> extends OAuth2Strategy<User, AfdianProfile, AfdianExtraParams> {
name: string;
private scope;
private userAgent;
constructor({ clientID, clientSecret, callbackURL, userAgent, scope, authorizationURL, tokenURL }: AfdianStrategyOptions, verify: StrategyVerifyCallback<User, OAuth2StrategyVerifyParams<AfdianProfile, AfdianExtraParams>>);
private getScope;
/**
* Format the data to be sent in the request body to the token endpoint.
*/
protected fetchAccessToken(code: string): Promise<AfdianProfile>;
protected getAccessToken(profile: AfdianProfile): Promise<AfdianProfile>;
protected userProfile(profile: AfdianProfile): Promise<AfdianProfile>;
}