This commit is contained in:
darenhsu
2022-07-17 13:16:16 +08:00
parent 84759556ff
commit befd344ab0
28070 changed files with 4008428 additions and 1 deletions
+11
View File
@@ -0,0 +1,11 @@
interface Friendship {
friendFlag: boolean;
}
/**
* Gets the friendship status of the LINE Official Account that's linked to the LINE Login channel to which the LIFF app is added.
* Learn more on how to {@link https://developers.line.biz/en/docs/line-login/link-a-bot/|link a LINE Official Account to a LINE Login channel.}
* @export
* @returns {Promise<Friendship>}
*/
export default function getFriendship(): Promise<Friendship>;
export {};
+13
View File
@@ -0,0 +1,13 @@
interface Profile {
userId: string;
displayName: string;
pictureUrl?: string;
statusMessage?: string;
}
/**
* Gets the current user's profile.
* @export
* @returns {Promise<Profile>}
*/
export default function getProfile(): Promise<Profile>;
export {};
+27
View File
@@ -0,0 +1,27 @@
import { Message, ImageMapMessage } from '@line/bot-sdk/lib/types';
/**
* the options to choose the way to send message in sendMessages method
* none: send a message to context
* ott: send messages to users bound to One-Time-Token (can send up to 10 ppl/group)
*/
export declare enum SendMessagesOptionsType {
none = "none",
ott = "ott"
}
declare type LiffMessage = Exclude<Message, ImageMapMessage>;
export declare type SendMessagesParams = LiffMessage[];
export interface SendMessagesOptions {
type: SendMessagesOptionsType;
token: string;
}
/**
* Sends messages on behalf of the user to the chat screen where the LIFF app is opened.
* If the LIFF app is opened on a screen other than the chat screen, messages cannot be sent.
* @export
* @param {Array<{type: string, text: string, }>} messages
* @returns {Promise<void>}
*/
export default function sendMessages(messages: SendMessagesParams,
/** DEPRECATED. options to support old specs. */
options?: SendMessagesOptions): Promise<void>;
export {};
@@ -0,0 +1,95 @@
import { InitParams, ShareTargetPickerResult } from './def';
/**
* ShareTargetPicker
* (Singleton Class)
*/
export default class ShareTargetPicker {
private static instance;
private liffId;
private allowPostMessageOrigin;
private payloadToShareTargetPicker;
private ott;
private popupWindow;
private timeoutIDForHealthCheck;
private abortController;
private internalError;
private doesWaitForSubwindowResult;
private constructor();
/**
* return Singleton instance
*/
static getInstance(): ShareTargetPicker;
/**
* initialize
* @param params
*/
init(params: InitParams): Promise<ShareTargetPickerResult | void>;
private resetAllVariables;
/**
* reset instance
*/
private reset;
/**
* called whenever the process is finished
*/
private finalize;
/**
* create payload data in accordance with the relevant format
* So far, the format of `PayloadToShareTargetPicker` is same as `InitParams`
* @param params
*/
private buildPayloadToShareTargetPicker;
/**
* return string like "https://example.com" (not includes last `/`)
* @param url
*/
private initAllowPostMessageOrigin;
private initOtt;
/**
* get a reference to the new window
*/
private prepareAnotherWindow;
/**
* emit corresponding events
*/
private openAnotherWindow;
/**
* start to listen corresponding events
*/
private initListener;
/**
* this function will be called every second
*/
private healthCheck;
/**
* called after receiving the event named "receivedHealthCheck" . this function is called except on LIFF
*/
private onReceivedHealthcheck;
/**
* post share result (only for external browser)
*/
private onCanceled;
/**
* Fetch Get Share Result
*/
private getShareResult;
/**
* check if elapsed max duration of polling
*
* @static
* @param {number} startTime
* @param {number} endTime
* @returns {boolean}
* @memberof ShareTargetPicker
*/
static isPollingTimeOut(startTime: number, endTime: number): boolean;
/**
* Polling server side API to get result from shareTargetPicker screen,
* which has an access to access.line.me, via server API.
*
* @private
* @returns {(Promise<ShareTargetPickerResult|void>)}
* @memberof ShareTargetPicker
*/
private pollingShareResult;
}
+10
View File
@@ -0,0 +1,10 @@
import { PayloadToShareTargetPicker } from './def';
/**
* open another window for shareTargetPicker
* @param liffId
*/
export declare function openAnotherWindow(popupWindow: Window, liffId: string, ott: string): void;
export declare function initListener(cb: Function, allowPostMessageOrigin: string): void;
export declare function healthCheck(popupWindow: Window, allowPostMessageOrigin: string): void;
export declare function finalize(timeoutIDForHealthCheck: number | null, popupWindow: Window | null): void;
export declare function onReceivedHealthcheck(popupWindow: Window, payloadToShareTargetPicker: PayloadToShareTargetPicker, allowPostMessageOrigin: string): void;
+8
View File
@@ -0,0 +1,8 @@
import { PayloadToShareTargetPicker } from './def';
/**
* call LINE Scheme to let client receive infos to open another window for shareTargetPicker
* @param liffId
* @param ott
* @param message
*/
export declare function openAnotherWindow(liffId: string, ott: string, data: PayloadToShareTargetPicker): void;
+58
View File
@@ -0,0 +1,58 @@
import { SendMessagesParams } from './../sendMessages';
import { TellEvent } from '../../util/dom';
export declare const CLOSE_SHARETARGETPICKER_FAIL = 0;
export declare const CLOSE_SHARETARGETPICKER_SUCCEED = 1;
/**
* the format to send data to another window
*/
export interface PayloadToShareTargetPicker {
messages: SendMessagesParams;
referrer: {
liffId: string;
url: string;
};
}
/**
* the format in common with each closed event called when lfw/sub window closed
*/
export interface ClosedBody {
status?: number;
res?: {
message?: string;
};
callbackId: string;
}
/**
* the event called when lfw is closed
*/
export interface ClosedWebview extends CustomEvent {
detail: ClosedBody;
}
/**
* the event called when popup window is closed
*/
export interface ClosedPopupWindow extends TellEvent {
data: {
name: string;
body: ClosedBody;
};
}
/**
* the format of parameters for init is same as the format of payload to send to another screen so far.
* but the way to use is different. So I defined 2 types
*/
export interface InitParams extends PayloadToShareTargetPicker {
options?: {
waitForSubwindowResult: boolean;
};
}
export interface RetrievedOtt {
ott: string;
}
export interface RetrievedShareResult {
result?: 'SUCCESS' | 'FAILURE' | 'CANCEL';
resultDescription: string;
}
export interface ShareTargetPickerResult {
status: 'success';
}
+10
View File
@@ -0,0 +1,10 @@
import { SendMessagesParams } from '../sendMessages';
import { ShareTargetPickerResult } from './def';
/**
* Displays the target picker and sends the message created by the developer to the selected target.
* This message appears to your group or friends as if you had sent it
* @export
* @param {string} routerMode
* @returns {Promise<string|null>}
*/
export default function shareTargetPicker(messages: SendMessagesParams): Promise<ShareTargetPickerResult | void>;
+10
View File
@@ -0,0 +1,10 @@
import { ROUTER_MODE } from '../util/consts';
/**
* open a user picker screen in new window or iframe
* @export
* @param {string} routerMode
* @returns {Promise<string|null>}
*/
export default function userPicker(options?: {
routerMode: ROUTER_MODE;
}): Promise<string | null>;
+1
View File
@@ -0,0 +1 @@
export default function checkExpired(): boolean;
+7
View File
@@ -0,0 +1,7 @@
/**
* createCodeChallenge for PKCE Login
* @export
* @param {string} code_verifier
* @return {string}
*/
export default function createCodeChallenge(code_verifier: string): string;
+6
View File
@@ -0,0 +1,6 @@
/**
* createCodeVerifier for PKCE login
* @export
* @return {string}
*/
export default function createCodeVerifier(): string;
+1
View File
@@ -0,0 +1 @@
export default function cryptoVerify(pub: any, encodedBuf: any, signatureBuf: any): Promise<boolean>;
+6
View File
@@ -0,0 +1,6 @@
/**
* Checks whether the user is logged in.
* @export
* @returns {boolean}
*/
export default function isLoggedIn(): boolean;
@@ -0,0 +1,6 @@
/**
* Detect whether user is logged in by accessToken in sessionStorage
* @export
* @returns {boolean}
*/
export default function isRedirectedFromLoginServer(code: string): boolean;
+7
View File
@@ -0,0 +1,7 @@
/**
* Performs the LINE Login process (web login) for the Web app.
* @export
*/
export default function login(loginConfig?: {
redirectUri?: string;
}): void;
+5
View File
@@ -0,0 +1,5 @@
/**
* Logs out.
* @export
*/
export default function logout(): void;
+21
View File
@@ -0,0 +1,21 @@
/**
* Give developer ability to add extra params to permanent link.
* Can be used for tracking parameters for example
* @param {string} paramsToAdd - Extra params to add to permanent link
*/
declare const setExtraQueryParam: (paramsToAdd: string) => void;
/**
* Create Permanent Link function.
* @returns {string} - Generated permanent link
*/
declare const createUrl: () => string;
/**
* Decode liff.state
* If valid, return decoded state (with any double slashes removed)
* Else LiffError is thrown
* @param {string} state - liff.state's value
* @throws {LiffError}
* @returns {string} - Decoded liff.state with any double slashes removed
*/
declare const decodeState: (state: string) => string;
export { decodeState, createUrl, setExtraQueryParam };
+16
View File
@@ -0,0 +1,16 @@
interface AccessToken {
access_token: string;
token_type: string;
refresh_token: string;
expires_in: number;
scope: string;
id_token?: string;
}
/**
* Request OAuth server to issue access_token
* API Reference https://developers.line.biz/en/reference/social-api/
* @export
* @returns {Promise<any>}
*/
export default function requestAccessToken(): Promise<AccessToken>;
export {};
+9
View File
@@ -0,0 +1,9 @@
interface CertKey {
kid: string;
alg?: string;
}
interface Certs {
keys: CertKey[];
}
declare function requestCerts(): Promise<Certs>;
export default requestCerts;
+14
View File
@@ -0,0 +1,14 @@
export declare const INVALID_ALG = "Invalid \"alg\" value in ID_TOKEN";
export declare const FAILED_CRYPTO = "Failed to use Crypto API to verify ID_TOKEN";
export declare const INVALID_KID = "Invalid \"kid\" value in ID_TOKEN";
export declare const INVALID_ISS = "Invalid \"iss\" value in ID_TOKEN";
export declare const INVALID_AUD = "Invalid \"aud\" value in ID_TOKEN";
export declare const INVALID_EXP = "Invalid \"exp\" value in ID_TOKEN";
export declare const INVALID_SIG = "Invalid signature in ID_TOKEN";
/**
* verify ID Token in JWT format
* @export
* @param {string} idToken - string
* @returns {Promise<Object>}
*/
export default function verifyIDToken(idToken: string, liffClientId: string): Promise<unknown>;
+3
View File
@@ -0,0 +1,3 @@
import { AddToHomeScreen } from './common';
import { LiffCore } from '../../liff';
export default function createAddToHomeScreen(liff: LiffCore): AddToHomeScreen;
+18
View File
@@ -0,0 +1,18 @@
import { LiffCore } from '../../liff';
export interface AddToHomeScreenParams {
name: string;
iconUrl: string;
state: string;
}
export declare type AddToHomeScreen = (params: AddToHomeScreenParams) => Promise<number>;
export declare const SCHEME_HEADER = "app/";
export declare const ADD_TO_HOME_SCREEN_RESULT: {
UNKNOWN: number;
};
/**
* verification()
* @export
* @param {AddToHomeScreenParams} params
* @returns {boolean}
*/
export declare function verification(params: AddToHomeScreenParams, liff: LiffCore): boolean;
+3
View File
@@ -0,0 +1,3 @@
import { AddToHomeScreen } from './common';
import { LiffCore } from '../../liff';
export default function createAddToHomeScreen(liff: LiffCore): AddToHomeScreen;
+9
View File
@@ -0,0 +1,9 @@
import { ClientCallback } from './types';
export declare const callbacks: {};
/**
* Add callback to LIFFEvent listener.
* @export
* @param {string} type
* @param {ClientCallback} callback
*/
export default function addListener(type: string, callback: ClientCallback): void;
+19
View File
@@ -0,0 +1,19 @@
/**
* call()
* Let js pass event and data to client
* and wait for callback
* @export
* @param {string} type - name of event
* @param {*} [params={}] - data object to pass to client
* @param {{ - options
* callbackId?: string - use randomly string by default, use `''` if client needs
* once?: boolean - will remove listener once callback is fired if is true
* }} [options={
* once: true,
* }]
* @returns {Promise<any>}
*/
export default function call(type: string, params?: any, options?: {
callbackId?: string;
once?: boolean;
}): Promise<any>;
+2
View File
@@ -0,0 +1,2 @@
import './customEventPolyFill';
export default function createEvent<T>(detail: T): CustomEvent;
@@ -0,0 +1,3 @@
/**
* https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/CustomEvent#Polyfill
*/
+6
View File
@@ -0,0 +1,6 @@
/**
* Wrap window.dispatchEvent
* Expose `window.liff._dispatchEvent()` for client to interact with js
* @param {string} json
*/
export default function dispatch(json: string): void;
+6
View File
@@ -0,0 +1,6 @@
export { default as createEvent } from './createEvent';
export { default as addListener } from './addListener';
export { default as removeListener } from './removeListener';
export { default as dispatch } from './dispatch';
export { default as postMessage } from './postMessage';
export { default as call } from './call';
+8
View File
@@ -0,0 +1,8 @@
/**
* Wrapper of window._liff.postMessage
* @export
* @param {string} type - name of message to client
* @param {{}} [params={}] - object data sent to client
* @param {string} [callbackId=''] - callbackId to identify client callback
*/
export default function postMessage(type: string, params?: {}, callbackId?: string): void;
+7
View File
@@ -0,0 +1,7 @@
import { ClientCallback } from './types';
/**
* Remove callback from LIFFEvent listener.
* @param {string} type [description]
* @param {Function} callback [description]
*/
export default function removeListener(type: string, callback: ClientCallback): void;
+1
View File
@@ -0,0 +1 @@
export declare type ClientCallback = (e: CustomEvent) => void;
+7
View File
@@ -0,0 +1,7 @@
/**
* checkFeature()
* Check whether the permission of the feature is approved
* @param {string} feature [name of feature]
* @return {boolean}
*/
export default function checkFeature(feature: string): boolean;
+1
View File
@@ -0,0 +1 @@
export {};
+4
View File
@@ -0,0 +1,4 @@
/**
* Closes the LIFF app.
*/
export default function closeWindow(): void;
+2
View File
@@ -0,0 +1,2 @@
import { AIdInterface } from '../store';
export default function getAId(): AIdInterface | undefined;
+5
View File
@@ -0,0 +1,5 @@
import { LiffCore } from '../liff';
declare type GetAdvertisingIdResult = null | string;
export declare type GetAdvertisingId = () => Promise<GetAdvertisingIdResult>;
export default function createGetAdvertisingId(liff: LiffCore): GetAdvertisingId;
export {};
+1
View File
@@ -0,0 +1 @@
export default function getIsVideoAutoPlay(): boolean;
+11
View File
@@ -0,0 +1,11 @@
/**
* Gets the user's LINE version.
* @export
* @returns {string|null} LINE Version, if inside LINE client. Null, otherwise
* @example
* const lineVersion = liff.getLineVersion()
* if (!lineVersion || lineVersion === '9.1.0') {
* // do something
* }
*/
export default function getLineVersion(): string | null;
+2
View File
@@ -0,0 +1,2 @@
import { ProfilePlusInterface } from '../store';
export default function getProfilePlus(): ProfilePlusInterface | undefined;
+11
View File
@@ -0,0 +1,11 @@
export interface OpenWindowParams {
url: string;
external?: boolean;
}
/**
* Opens the specified URL in the in-app browser of LINE or external browser.
* @export
* @param {OpenWindowParams} params
* @returns {void}
*/
export default function openWindow(params: OpenWindowParams): void;
+2
View File
@@ -0,0 +1,2 @@
import { Context } from '../store';
export default function parseContext(contextStr: string): Context | null;
+7
View File
@@ -0,0 +1,7 @@
/**
* listen to `ready` event from client
* set client features in client callback
* @export
* @returns {Promise<any>}
*/
export default function ready(): Promise<void>;
+9
View File
@@ -0,0 +1,9 @@
import { LiffCore } from '../liff';
/**
* open scan qr code appview
*/
export interface ScanCodeResult {
value: string | null;
}
export declare type ScanCode = () => Promise<ScanCodeResult>;
export default function createScanCode(liff: LiffCore): ScanCode;
+5
View File
@@ -0,0 +1,5 @@
/**
* Gets the language settings of the environment in which the LIFF app is running.
* @export
*/
export default function getLanguage(): string;
+12
View File
@@ -0,0 +1,12 @@
declare type OS = 'ios' | 'android' | 'web' | undefined;
/**
* Gets the environment in which the user is running the LIFF app.
* @export
*/
export default function getOS(): OS;
/**
* Cleanup cached OS, testing use
* @export
*/
export declare function _cleanupCachedOS(): void;
export {};
+5
View File
@@ -0,0 +1,5 @@
/**
* Get LIFF SDK Version
* @return {string}
*/
export default function getVersion(): string;
+11
View File
@@ -0,0 +1,11 @@
/**
* Determines whether the LIFF app is running in LINE's in-app browser.
* @export
* @returns {boolean}
*/
export default function isInClient(): boolean;
/**
* Cleanup cached OS, testing use
* @export
*/
export declare function _cleanupCachedIsInClient(): void;
+5
View File
@@ -0,0 +1,5 @@
import 'whatwg-fetch';
import 'promise-polyfill/src/polyfill';
import liff from './liff';
export { liff };
export default liff;
+2
View File
File diff suppressed because one or more lines are too long
+18
View File
@@ -0,0 +1,18 @@
import { ScanCode } from '../../client/scanCode';
import { GetAdvertisingId } from '../../client/getAdvertisingId';
import { AddToHomeScreen } from '../../client/addToHomeScreen/common';
import { InitPlugins } from '../../plugin/initPlugins';
import { LiffCore } from '../../liff';
interface LiffExtendableAll {
addToHomeScreen: AddToHomeScreen;
scanCode: ScanCode;
getAdvertisingId: GetAdvertisingId;
initPlugins: InitPlugins;
}
export declare type ExtendableKeys = keyof LiffExtendableAll;
export declare type LiffExtendableFunctions = Partial<LiffExtendableAll>;
export interface LiffExtension {
install: (liff: LiffCore) => void;
}
export declare type ExtendedFunctionCreator = (liff: LiffCore) => Function;
export {};
@@ -0,0 +1,3 @@
import { LiffExtension, ExtendedFunctionCreator, ExtendableKeys } from './LiffExtension';
export declare type CreatorDefPair = [ExtendableKeys, ExtendedFunctionCreator];
export default function createExtension(creatorDefPairs: CreatorDefPair[]): LiffExtension;
+3
View File
@@ -0,0 +1,3 @@
import { LiffExtension } from './LiffExtension';
declare const ios9_18Extension: LiffExtension;
export default ios9_18Extension;
+3
View File
@@ -0,0 +1,3 @@
import { LiffExtension } from './LiffExtension';
declare const ios9_19Extension: LiffExtension;
export default ios9_19Extension;
+3
View File
@@ -0,0 +1,3 @@
import { LiffExtension } from './LiffExtension';
declare const othersExtension: LiffExtension;
export default othersExtension;
+1
View File
@@ -0,0 +1 @@
export default function fetchAndSetContext(): Promise<void>;
+1
View File
@@ -0,0 +1 @@
export default function handleLiffState(state: string): void;
@@ -0,0 +1,3 @@
export default function handleLoginAndInitFeatures(config: {
liffId: string;
}): Promise<void>;
@@ -0,0 +1 @@
export default function handleLoginExternalBrowser(): Promise<void>;
+2
View File
@@ -0,0 +1,2 @@
import LiffError from '../util/LiffError';
export default function handleOAuthError(errorType: string, errorDescription: string): LiffError;
@@ -0,0 +1 @@
export default function handleRedirectedFromLoginServer(liffClientId: string): Promise<void>;
+10
View File
@@ -0,0 +1,10 @@
import { LiffCore } from '../liff';
/**
* Initializes a LIFF app.
* You can only call other LIFF SDK methods after calling liff.init().
* The LIFF SDK gets access tokens and ID tokens from the LINE platform
* when you initialize the LIFF app.
*/
export default function init(this: LiffCore, config: {
liffId: string;
}, successCallback?: () => void, errorCallback?: (error: Error) => void): Promise<void>;
+9
View File
@@ -0,0 +1,9 @@
export declare let initDone: () => void;
/**
* A property holding the Promise object that resolves when you run liff.init() for the first time after starting the LIFF app.
*
* If you use liff.ready, you can execute any process after the completion of liff.init().
*
* liff.ready can be used before liff.init() finishes initializing the LIFF app.
*/
export declare const ready: Promise<void>;
+6
View File
@@ -0,0 +1,6 @@
export interface Config {
liffId: string;
redirectUri?: string;
}
export declare type SubsequentInit = (config: Config) => Promise<void>;
export default function subsequentInit(config: Config): Promise<void>;
+1
View File
@@ -0,0 +1 @@
export default function validateFeatureToken(liffId: any, featureToken: any): boolean;
@@ -0,0 +1 @@
(window.webpackJsonpliff=window.webpackJsonpliff||[]).push([[0],{120:function(n,f){},122:function(n,f){},154:function(n,f){},155:function(n,f){}}]);
+70
View File
@@ -0,0 +1,70 @@
import init from './init';
import getOS from './common/getOS';
import getVersion from './common/getVersion';
import getLanguage from './common/getLanguage';
import isInClient from './common/isInClient';
import isLoggedIn from './auth/isLoggedIn';
import login from './auth/login';
import logout from './auth/logout';
import { getAccessToken, getFeatures, getContext, getIDToken, getDecodedIDToken } from './store';
import { dispatch, call, postMessage, addListener, removeListener } from './client/bridge';
import checkFeature from './client/checkFeature';
import openWindow from './client/openWindow';
import closeWindow from './client/closeWindow';
import getAId from './client/getAId';
import getProfilePlus from './client/getProfilePlus';
import getIsVideoAutoPlay from './client/getIsVideoAutoPlay';
import getLineVersion from './client/getLineVersion';
import getProfile from './api/getProfile';
import sendMessages from './api/sendMessages';
import userPicker from './api/userPicker';
import shareTargetPicker from './api/shareTargetPicker';
import getFriendship from './api/getFriendship';
import { LiffExtendableFunctions } from './init/definition/LiffExtension';
declare const liffCore: {
init: typeof init;
getOS: typeof getOS;
getVersion: typeof getVersion;
getLanguage: typeof getLanguage;
isInClient: typeof isInClient;
isLoggedIn: typeof isLoggedIn;
login: typeof login;
logout: typeof logout;
getAccessToken: typeof getAccessToken;
getIDToken: typeof getIDToken;
getDecodedIDToken: typeof getDecodedIDToken;
getContext: typeof getContext;
openWindow: typeof openWindow;
closeWindow: typeof closeWindow;
getFeatures: typeof getFeatures;
getFriendship: typeof getFriendship;
checkFeature: typeof checkFeature;
getAId: typeof getAId;
getProfilePlus: typeof getProfilePlus;
getIsVideoAutoPlay: typeof getIsVideoAutoPlay;
getLineVersion: typeof getLineVersion;
isApiAvailable: (apiName: "shareTargetPicker") => boolean;
getProfile: typeof getProfile;
sendMessages: typeof sendMessages;
userPicker: typeof userPicker;
shareTargetPicker: typeof shareTargetPicker;
permanentLink: {
createUrl: () => string;
setExtraQueryParam: (paramsToAdd: string) => void;
};
ready: Promise<void>;
/**
* The property that holds the LIFF app ID (String type) passed to liff.init().
* The value of liff.id is null until you run liff.init().
*/
readonly id: string | null;
_dispatchEvent: typeof dispatch;
_call: typeof call;
_addListener: typeof addListener;
_removeListener: typeof removeListener;
_postMessage: typeof postMessage;
};
export declare type LiffCore = typeof liffCore;
declare type Liff = LiffCore & LiffExtendableFunctions;
declare const liff: Liff;
export default liff;
+11
View File
@@ -0,0 +1,11 @@
/**
* logToTorimochi()
* A method for sending logs in liff-sdk.
* For example: collecting potential abuser events.
* Here we only pick out the function of sending data in torimochi instead of using complete torimochi.js.
* So we can avoid conflict with torimochi that is already on the LIFF App side.
* @export
* @param {string} msg
* @returns {void}
*/
export default function logToTorimochi(msg: string, hitCallback?: Function): void;
+18
View File
@@ -0,0 +1,18 @@
import { LiffCore } from '../../liff';
declare type PluginName = 'bluetooth' | 'advertisement';
interface PluginModule {
default: (liff: LiffCore) => {} | Promise<{}>;
}
export interface Plugin {
checkSupport: (liff: LiffCore) => boolean;
load: () => Promise<PluginModule> | PluginModule;
errorMessage: string;
}
export declare type InitPlugins = (plugins: PluginName[]) => Promise<void[]>;
/**
* Verify and load and initialize plugins.
* @param {PluginNames} plugins - string array of plugin names
* @returns {Promise<any>}
*/
export default function createInitPlugins(liff: LiffCore, verification: any): InitPlugins;
export {};
@@ -0,0 +1,3 @@
import { Plugin } from '..';
declare const advertisement: Plugin;
export default advertisement;
@@ -0,0 +1,3 @@
import { Plugin } from '..';
declare const bluetooth: Plugin;
export default bluetooth;
+14
View File
@@ -0,0 +1,14 @@
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
+4
View File
@@ -0,0 +1,4 @@
/**
* remove all stored data
*/
export default function clean(): void;
+1
View File
@@ -0,0 +1 @@
export declare function getFeatureToken(liffId: string): string | null;
+9
View File
@@ -0,0 +1,9 @@
export declare function getByLiffId(key: string, liffId: string | undefined): any;
/**
* isInClient === true: sessionStorage setter
* isInClient === false: localStroage setter
* @export
* @param {string} key
* @return {*}
*/
export default function get(key: string): any;
+125
View File
@@ -0,0 +1,125 @@
import get from './get';
import set from './set';
import clean from './clean';
import remove from './remove';
declare const _default: {
get: typeof get;
set: typeof set;
remove: typeof remove;
clean: typeof clean;
};
export default _default;
interface Config {
liffId?: string;
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;
}
export declare function getConfig(): Config;
export declare function setConfig(value: Config): void;
export declare function getFeatures(): string[];
export declare function setFeatures(value: string[]): void;
interface LoginTmp {
codeVerifier: string;
}
/**
* temporary values for LINE Login getter / setter
*/
export declare function getLoginTmp(): LoginTmp;
export declare function setLoginTmp(value: LoginTmp): void;
export declare function removeLoginTmp(): void;
/**
* Gets the current user's access token.
* You can use the access token obtained with this API to send user information from the LIFF app to the server.
* @see {@link https://developers.line.biz/en/docs/liff/using-user-profile/|Using user information in LIFF apps and servers}
*/
export declare function getAccessToken(): string | null;
export declare function setAccessToken(value: string): void;
/**
* context token & client id will be set
* from token_hash to sessionToken from LINE 10.8.0
*/
export declare const getRawContext: () => string | null;
export declare const getClientId: () => string | null;
/**
* Get the raw ID token of the current user obtained by the LIFF SDK.
* An ID token is a JSON Web Token (JWT) that contains user information.
*
* You can use the ID token obtained with this API when sending the user information from the LIFF app to the server.
* @see {@link https://developers.line.biz/en/docs/liff/using-user-profile/|Using user information in LIFF apps and servers}
*/
export declare function getIDToken(): string | null;
export declare function setIDToken(value: string): void;
/**
* Gets the payload of the ID token that's acquired by the LIFF SDK.
* The payload includes the user display name, profile image URL, and email address.
*
* Use this API when you want to use the display name of the user in the LIFF app.
*/
export declare function getDecodedIDToken(): JWTPayload | null;
export declare function setDecodedIDToken(value: unknown): void;
/**
* featureToken getter / setter
*/
export declare function getFeatureToken(): string | null;
export declare function setFeatureToken(value: string): void;
export interface ProfilePlusInterface {
regionCode: string;
}
export interface AIdInterface {
id: string;
t: boolean;
}
/**
* context getter / setter
*/
export interface Context {
type: 'utou' | 'room' | 'group' | 'none';
utouId?: string;
roomId?: string;
groupId: string;
userId?: string;
endpointUrl: string;
viewType?: string;
accessTokenHash?: string;
permanentLinkPattern?: 'replace' | 'concat';
/**
* profile+ related settings
*/
profilePlus?: ProfilePlusInterface;
/**
* device-related settings
*/
d?: {
autoplay: boolean;
aId: AIdInterface;
};
/**
* whether user can use each methods
*/
availability: {
shareTargetPicker: {
permission: boolean;
minVer: string;
};
};
}
export declare function getContext(): Context | null;
export declare function setContext(value: Context | null): void;
/**
* special handle expire time in cookie
*/
export declare function setExpireTime(expires: Date): void;
export declare function getExpireTime(): string | null;
export declare function removeExpireTime(): void;
+6
View File
@@ -0,0 +1,6 @@
/**
* Checks whether the specified API is available in the environment where you started the LIFF app.
* Specifically, it verifies whether the current LINE version supports the API and whether the terms and conditions for the API have been accepted.
*/
declare const isApiAvailable: (apiName: "shareTargetPicker") => boolean;
export default isApiAvailable;
+8
View File
@@ -0,0 +1,8 @@
/**
* isInClient === true: sessionStorage
* isInClient === false: localStorage
* @export
* @param {string} key
* @param {*} value
*/
export default function remove(key: string): void;
+8
View File
@@ -0,0 +1,8 @@
/**
* isInClient === true: sessionStorage setter
* isInClient === false: localStorage setter
* @export
* @param {string} key
* @param {*} value
*/
export default function set(key: string, value: unknown): void;
+18
View File
@@ -0,0 +1,18 @@
import { UNAUTHORIZED, INVALID_ARGUMENT, INIT_FAILED, FORBIDDEN, INVALID_CONFIG, INVALID_ID_TOKEN, CREATE_SUBWINDOW_FAILED, EXCEPTION_IN_SUBWINDOW } from './consts';
declare const HTTPStatusCodeArray: string[];
export declare const HTTPStatusCodes: Set<string>;
declare type PublicErrorCode = typeof HTTPStatusCodeArray[number] | typeof FORBIDDEN | typeof INVALID_CONFIG | typeof INVALID_ID_TOKEN | typeof UNAUTHORIZED | typeof INVALID_ARGUMENT | typeof INIT_FAILED | 'THINGS_NO_LINKED_DEVICES' | 'BLUETOOTH_SETTING_OFF' | 'THINGS_TERMS_NOT_AGREED' | 'BLUETOOTH_NO_LOCATION_PERMISSION' | 'BLUETOOTH_LOCATION_DISABLED' | 'BLUETOOTH_LE_API_UNAVAILABLE' | 'BLUETOOTH_CONNECT_FAILED' | 'BLUETOOTH_ALREADY_CONNECTED' | 'BLUETOOTH_CONNECTION_LOST' | 'BLUETOOTH_UNSUPPORTED_OPERATION' | 'BLUETOOTH_SERVICE_NOT_FOUND' | 'BLUETOOTH_CHARACTERISTIC_NOT_FOUND' | 'UNKNOWN';
declare type InternalErrorCode = typeof CREATE_SUBWINDOW_FAILED | typeof EXCEPTION_IN_SUBWINDOW;
declare type AdErrorValue = 'ADS_APP_ID_NOT_SET' | 'ADS_FREQUENT_LOAD' | 'ADS_ALREADY_LOADED' | 'ADS_NO_FILL' | 'ADS_NOT_LOADED' | 'ADS_ADNETWORK_NOT_SUPPORTED' | 'CLIENT_UNSUPPORTED_OPERATION' | 'NETWORK_FAILURE' | 'INVALID_MESSAGE' | 'INVALID_ARGUMENTS' | 'INTERNAL_ERROR';
declare type UnpublishedErrorCode = 'LIFF.STATE_INVALID' | AdErrorValue;
export declare type ErrorCode = PublicErrorCode | InternalErrorCode | UnpublishedErrorCode;
/**
* Custom Liff Error with code & message
* @param {string} code
* @param {string} message
*/
export default class LiffError extends Error {
code: string | number;
constructor(code: ErrorCode, message: string);
}
export {};
+19
View File
@@ -0,0 +1,19 @@
/**
* decode Base64URL
* @export
* @param {string} str - string
* @returns {string}
*/
export declare function decode(str: string): string;
/**
* encode Base64URL
* @export
* @param {string} str - string
* @returns {string}
*/
export declare function encode(str: string): string;
declare const _default: {
decode: typeof decode;
encode: typeof encode;
};
export default _default;
+8
View File
@@ -0,0 +1,8 @@
/**
* compare two versions
* @export
* @param {string} version - string
* @param {string} comparedVersion - string
* @returns {-1|0|1} If version is higher, returns 1. same : 0, lower : -1.
*/
export default function compareVersion(version: string, comparedVersion: string): number;
+40
View File
@@ -0,0 +1,40 @@
import { ElementType } from './typeHelpers';
export declare const UNKNOWN = "UNKNOWN";
export declare const UNAUTHORIZED = "UNAUTHORIZED";
export declare const INVALID_ARGUMENT = "INVALID_ARGUMENT";
export declare const INIT_FAILED = "INIT_FAILED";
export declare const FORBIDDEN = "FORBIDDEN";
export declare const INVALID_CONFIG = "INVALID_CONFIG";
export declare const INVALID_ID_TOKEN = "INVALID_ID_TOKEN";
export declare const CREATE_SUBWINDOW_FAILED = "CREATE_SUBWINDOW_FAILED";
export declare const EXCEPTION_IN_SUBWINDOW = "EXCEPTION_IN_SUBWINDOW";
export declare const LIFF_EVENT = "liffEvent";
export declare const STORE_KEY = "LIFF_STORE";
export declare const PERMANENT_LINK_ORIGIN: string;
export declare const TORIMOCHI_URL = "https://torimochi.line-apps.com/1/req";
export declare const STORE_OBJECT: {
readonly ACCESS_TOKEN: "accessToken";
readonly ID_TOKEN: "IDToken";
readonly DECODED_ID_TOKEN: "decodedIDToken";
readonly FEATURE_TOKEN: "featureToken";
readonly FEATURES: "features";
readonly LOGIN_TMP: "loginTmp";
readonly CONFIG: "config";
readonly CONTEXT: "context";
readonly EXPIRES: "expires";
readonly RAW_CONTEXT: "rawContext";
readonly CLIENT_ID: "clientId";
};
export declare const STORE_SUBKEY_IS_IN_CLIENT = "isInClient";
export declare const LIFF_ATTR_DOM = "data-l-{0}";
export declare enum ROUTER_MODE {
NONE = "none",
HASH = "hash",
HISTORY = "history"
}
export declare const CREDENTIAL_KEYS: readonly ["context_token", "feature_token", "access_token", "id_token", "client_id"];
export declare type CREDENTIAL_OBJECTS = {
[key in ElementType<typeof CREDENTIAL_KEYS>]: string | null;
};
export declare const MAX_NUM_OF_SEND_MESSAGES = 5;
export declare const IFRAME_OPEN_ANIMATION_DURATION = 400;
+8
View File
@@ -0,0 +1,8 @@
/**
* string to ArrayBuffer
* https://developers.google.com/web/updates/2012/06/How-to-convert-ArrayBuffer-to-and-from-String
* @export
* @param {string} str - string
* @returns {ArrayBuffer}
*/
export declare function strToArrayBuffer(str: string): ArrayBuffer;
+7
View File
@@ -0,0 +1,7 @@
/**
* https://developer.mozilla.org/en-US/docs/Web/API/Document/cookie
* get cookie value by key
* @param {string} key
* @return {string}
*/
export default function get(key: string): string;
+9
View File
@@ -0,0 +1,9 @@
import set from './set';
import get from './get';
import remove from './remove';
declare const _default: {
set: typeof set;
get: typeof get;
remove: typeof remove;
};
export default _default;
+6
View File
@@ -0,0 +1,6 @@
/**
* https://developer.mozilla.org/en-US/docs/Web/API/Document/cookie
* @param {string} key
* @param {any} [options]
*/
export default function remove(key: string, options?: Record<string, unknown>): void;
+7
View File
@@ -0,0 +1,7 @@
/**
* https://developer.mozilla.org/en-US/docs/Web/API/Document/cookie
* @param {string} key
* @param {string | number} value
* @param {any} [options]
*/
export default function set(key: string, value: string | number, options?: Record<string, unknown>): void;
+8
View File
@@ -0,0 +1,8 @@
import LiffError, { ErrorCode } from './LiffError';
/**
* create custom liff error
* @param {string} code [description]
* @param {string} message [description]
* @return {LiffError} [description]
*/
export default function createError(code: ErrorCode, message?: string): LiffError;
+29
View File
@@ -0,0 +1,29 @@
import { AbstractIframe } from './abstract/AbstractIframe';
import { IframeEvent } from './windowPostMessage';
import { ROUTER_MODE } from '../consts';
export declare class ShareTargetPickerIFrame extends AbstractIframe {
protected routerMode: ROUTER_MODE;
protected submittedData: boolean | {};
private wrapperIn;
private originalBodyStyle;
private orgDocumentStyle;
private originalBodyPos;
private allowPostMessageOrigin;
constructor(url: string, accessToken: string, namespace?: Window);
init(routerMode?: ROUTER_MODE): Promise<void>;
protected prepareDom(): HTMLElement;
protected prepareStyle(): HTMLStyleElement;
cancel(): Promise<void>;
submit(): Promise<void>;
destroy(): Promise<void>;
protected changeBodyStyle(): void;
protected revertBodyStyle(): void;
private filter;
postMessageCallback(e: IframeEvent): Promise<void>;
/**
* TODO こいつらの処遇は後で決める
*/
protected historyAdd(): Promise<void>;
protected startWatchingHistoryChange(): void;
protected historyRemove(): void;
}
+13
View File
@@ -0,0 +1,13 @@
import { AbstractPopup } from './abstract/AbstractPopup';
import { IframeEvent } from './windowPostMessage';
export declare class ShareTargetPickerPopup extends AbstractPopup {
protected routerMode: any;
protected submittedData: boolean | {};
private allowPostMessageOrigin;
constructor(url: string, accessToken: string, namespace?: Window);
init(): Promise<void>;
cancel(): Promise<void>;
submit(): Promise<void>;
destroy(): Promise<void>;
postMessageCallback(e: IframeEvent): Promise<void>;
}
+12
View File
@@ -0,0 +1,12 @@
import { AbstractSubwindow } from './AbstractSubwindow';
export declare abstract class AbstractIframe extends AbstractSubwindow {
protected iframe: HTMLIFrameElement;
protected get postmessageDestination(): Window;
init(): Promise<void>;
protected prepareWindow(): Promise<void>;
protected breakWindow(): Promise<void>;
protected prepareDom(): HTMLElement;
protected prepareStyle(): HTMLStyleElement;
protected abstract changeBodyStyle(): void;
protected abstract revertBodyStyle(): void;
}
@@ -0,0 +1,8 @@
import { AbstractSubwindow } from './AbstractSubwindow';
export declare abstract class AbstractPopup extends AbstractSubwindow {
protected windowProxy: Window | null;
protected get postmessageDestination(): Window;
init(): Promise<void>;
prepareWindow(): Promise<void>;
breakWindow(): Promise<void>;
}
@@ -0,0 +1,22 @@
import { WindowPostMessage, IframeEvent } from '../windowPostMessage';
export declare abstract class AbstractSubwindow {
protected url: string;
protected uniqAttr: string;
protected namespace: Window;
protected accessToken: string;
protected windowPostMessage: WindowPostMessage;
protected contentElm: HTMLElement;
protected styleElm: HTMLStyleElement;
protected resolve: Function;
protected reject: Function;
protected pingHandler: any;
protected healthcheckHandler: any;
protected abstract postmessageDestination: Window;
constructor(url: string, accessToken: string, namespace?: Window);
init(): Promise<void>;
start(): Promise<null>;
destroy(): Promise<void>;
protected abstract prepareWindow(): Promise<void>;
protected abstract breakWindow(): Promise<void>;
postMessageCallback(e: IframeEvent): Promise<void>;
}
+2
View File
@@ -0,0 +1,2 @@
declare const _default: (uniq: string) => {};
export default _default;
+4
View File
@@ -0,0 +1,4 @@
export { default as listen } from './listen';
export { default as removeListen } from './removeListen';
export { default as messageTell, TellEvent } from './messageTell';
export { default as messageReceive, ReceiveEvent } from './messageReceive';
+21
View File
@@ -0,0 +1,21 @@
interface EventHandlers {
[k: string]: Function | null;
}
/**
* to retrieved cached values
*/
export declare function getEventHandlers(): EventHandlers;
/**
* Cleanup cached the variables, testing use
*/
export declare function _cleanupCache(): void;
/**
* main function to addEventListener with Promise which is resolve by being called at first time
* you can remove eventListener you added with this function by using `removeListen.ts`
* @param target Target Elements or Window
* @param key One or more space-separated event types and optional namespaces, such as "click" or "keydown.myPlugin".
* @param callback A function to execute when the event is triggered.
* @param options same as AddEventListenerOptions. see MDN if you find out more
*/
export default function listen(target: HTMLElement | HTMLDocument | Window, key: string, callback?: (e: Event) => void, options?: AddEventListenerOptions): Promise<Event>;
export {};
+5
View File
@@ -0,0 +1,5 @@
/**
* make a new unique attribute for HTMLElement to distinguish the elements created by LIFF SDK
* @param namespace
*/
export default function makeUniqAttr(namespace?: Window): string;
+23
View File
@@ -0,0 +1,23 @@
export interface ReceiveEvent extends MessageEvent {
data: {
name: string;
body: {} | {}[];
};
}
/**
* callback function called at first when receive a message event. (strictly speaking, listen.ts is called at very first)
* before calling callback you designated, this verifies if the name and origin are same as you expected
* @param name
* @param callback
* @param targetOrigin
*/
export declare function verifyCallback(name: string, callback: Function, targetOrigin: string): (event: ReceiveEvent) => void;
/**
* receive Event from another window calling postMessage.
* This is used for receiving data from another window like iframe, popup window, etc.
* @param target
* @param name
* @param callback
* @param targetOrigin
*/
export default function receive(target: Window, name: string, callback: Function, targetOrigin: string): void;

Some files were not shown because too many files have changed in this diff Show More