Skip to content

Instantly share code, notes, and snippets.

@nukotsuka
Created July 23, 2020 08:49
Show Gist options
  • Save nukotsuka/fed3843bef616747e06bcbb2fe1ce6b7 to your computer and use it in GitHub Desktop.
Save nukotsuka/fed3843bef616747e06bcbb2fe1ce6b7 to your computer and use it in GitHub Desktop.
declare const liff: Liff;
export default liff;
interface Liff {
init(this: Liff, config: InitConfig, successCallback?: () => void, errorCallback?: (error: Error) => void): Promise<void>;
getOS(): 'ios' | 'android' | 'web';
getVersion(): string;
getLanguage(): string;
isInClient(): boolean;
isLoggedIn(): boolean;
login(loginConfig?: LoginConfig): void;
logout(): void;
getAccessToken(): string | null;
getIDToken(): string | null;
getDecodedIDToken(): JWTPayload | null;
getContext(): Context | null;
openWindow(params: OpenWindowParams): void;
closeWindow(): void;
getFeatures(): string[];
getFriendship(): Promise<Friendship>;
checkFeature(feature: string): boolean;
getAId(): AIdInterface;
getProfilePlus(): ProfilePlusInterface;
getIsVideoAutoPlay(): boolean;
getLineVersion(): string | null;
isApiAvailable(apiName: "shareTargetPicker"): boolean;
getProfile(): Promise<Profile>;
sendMessages(messages: any[]): Promise<void>;
userPicker(options?: UserPickerOptions): Promise<string | null>;
shareTargetPicker(messages: any[]): Promise<ShareTargetPickerResult | void>;
permanentLink: PermanentLink;
ready: Promise<void>;
readonly id: string | null;
_dispatchEvent(json: string): void;
_call(type: string, params?: any, options?: CallOptions): Promise<any>;
_addListener(type: string, callback: ClientCallback): void;
_removeListener(type: string, callback: ClientCallback): void;
_postMessage(type: string, params?: {}, callbackId?: string): void;
/* LiffExtendableAll */
addToHomeScreen(params: AddToHomeScreenParams): Promise<number>;
scanCode(): Promise<ScanCodeResult>;
getAdvertisingId(): Promise<null | string>;
initPlugins(plugins: ('bluetooth' | 'advertisement')[]): Promise<void[]>;
}
interface Error {
name: string;
message: string;
stack?: string;
}
declare type ClientCallback = (e: CustomEvent) => void;
interface InitConfig {
liffId: string;
}
interface LoginConfig {
redirectUri?: string;
}
interface JWTPayload {
iss?: string;
sub?: string;
aud?: string;
exp?: number;
iat?: number;
auth_time?: number;
nonce?: string;
amr?: string[];
name?: string;
picture?: string;
email?: string;
}
interface Friendship {
friendFlag: boolean;
}
interface Context {
type: 'utou' | 'room' | 'group' | 'none';
utouId?: string;
roomId?: string;
groupId: string;
userId?: string;
endpointUrl: string;
viewType?: string;
accessTokenHash?: string;
permanentLinkPattern?: 'replace' | 'concat';
profilePlus?: ProfilePlusInterface;
d?: DeviceRelatedSettings;
availability: Availability;
}
interface AIdInterface {
id: string;
t: boolean;
}
interface ProfilePlusInterface {
regionCode: string;
}
interface Profile {
userId: string;
displayName: string;
pictureUrl?: string;
statusMessage?: string;
}
interface UserPickerOptions {
routerMode: "none" | "hash" | "history";
}
interface OpenWindowParams {
url: string;
external?: boolean;
}
interface ShareTargetPickerResult {
status: 'success';
}
interface AddToHomeScreenParams {
name: string;
iconUrl: string;
state: string;
}
interface ScanCodeResult {
value: string | null;
}
interface CustomEvent<T = any> {
readonly detail: T;
initCustomEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, detailArg: T): void;
}
interface PermanentLink {
createUrl: () => string;
setExtraQueryParam: (paramsToAdd: string) => void;
}
interface CallOptions {
callbackId?: string;
once?: boolean;
}
interface DeviceRelatedSettings {
autoplay: boolean;
aId: AIdInterface;
}
interface ShareTargetPicker {
permission: boolean;
minVer: string;
}
interface Availability {
shareTargetPicker: ShareTargetPicker;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment