react-facebook
Version:
Facebook components like a Login button, Like, Share, Comments, Embedded Post/Video, Messenger Chat, and Facebook Pixel tracking
93 lines (92 loc) • 3.03 kB
TypeScript
import LoginStatus from '../constants/LoginStatus';
export type AuthResponse = {
userID: string;
accessToken: string;
};
export type LoginResponse = {
status: LoginStatus.CONNECTED;
authResponse: AuthResponse;
} | {
status: Exclude<LoginStatus, LoginStatus.CONNECTED>;
};
export type LoginOptions = {
scope?: string;
returnScopes?: boolean;
authType?: string[];
rerequest?: boolean;
reauthorize?: boolean;
};
declare global {
interface Window {
fbAsyncInit: () => void;
FB: any;
}
}
export declare enum Method {
GET = "get",
POST = "post",
DELETE = "delete"
}
export declare enum Namespace {
UI = "ui",
API = "api",
LOGIN = "login",
LOGOUT = "logout",
GET_LOGIN_STATUS = "getLoginStatus",
GET_AUTH_RESPONSE = "getAuthResponse"
}
export type FacebookOptions = {
domain?: string;
version?: string;
cookie?: boolean;
status?: boolean;
xfbml?: boolean;
language?: string;
frictionlessRequests?: boolean;
debug?: boolean;
chatSupport?: boolean;
appId: string;
autoLogAppEvents?: boolean;
lazy?: boolean;
};
export default class Facebook {
options: FacebookOptions;
loadingPromise: Promise<any> | undefined;
constructor(options: FacebookOptions);
getAppId(): string;
getFB(): any;
init(): Promise<Facebook>;
process<Response>(namespace: Namespace, before?: any[], after?: any[]): Promise<Response>;
ui(options: any): Promise<unknown>;
api<T>(path: string, method?: Method, params?: {}): Promise<T>;
login(options: LoginOptions): Promise<LoginResponse>;
logout(): Promise<unknown>;
getLoginStatus(): Promise<LoginResponse>;
getAuthResponse(): Promise<unknown>;
getTokenDetail(loginResponse?: LoginResponse): Promise<AuthResponse>;
getProfile(params: any): Promise<unknown>;
getTokenDetailWithProfile(params: any, response: any): Promise<{
profile: unknown;
tokenDetail: AuthResponse;
}>;
getToken(): Promise<string>;
getUserId(): Promise<string>;
sendInvite(to: string, options: any): Promise<unknown>;
postAction(ogNamespace: string, ogAction: string, ogObject: string, ogObjectUrl: string, noFeedStory?: boolean): Promise<unknown>;
getPermissions(): Promise<{
permission: string;
status: "granted";
}[]>;
hasPermissions(permissions: string[]): Promise<boolean>;
subscribe<T>(eventName: string, callback: (value: T) => void): Promise<() => Promise<void>>;
unsubscribe<T>(eventName: string, callback: (value: T) => void): Promise<void>;
parse(parentNode: HTMLElement): Promise<void>;
getRequests(): Promise<unknown>;
removeRequest(requestId: string): Promise<unknown>;
setAutoGrow(): Promise<void>;
paySimple(product: string, quantity?: number): Promise<unknown>;
pay(product: string, options: any): Promise<unknown>;
getLocale(): string;
changeLocale(newLocale: string): Promise<void>;
parseAll(): Promise<void>;
}