react-liff-v2
Version:
A react context provider for LIFF (LINE Front-end Framework)
103 lines (102 loc) • 3.74 kB
JavaScript
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.liffStub = void 0;
// login status
let loginState = false;
const permanentLink = {
createUrl: () => 'https://liff.line.me/liffId/path',
setExtraQueryParam: () => { },
};
exports.liffStub = {
init: () => __awaiter(void 0, void 0, void 0, function* () { }),
getOS: () => 'web',
getVersion: () => '2.1.3',
getLanguage: () => 'ja',
isInClient: () => true,
isLoggedIn: () => loginState,
login: () => {
loginState = true;
},
logout: () => {
loginState = false;
},
getAccessToken: () => 'DummyAccessToken',
getIDToken: () => 'DummyIDToken',
getDecodedIDToken: () => ({
amr: [],
aud: 'aud',
email: 'email@example.com',
exp: 0,
iat: 0,
iss: 'iss',
name: 'name',
picture: 'picture_url',
sub: 'sub',
}),
getContext: () => ({
type: 'none',
groupId: 'groupId',
userId: 'userId',
endpointUrl: 'endpointUrl',
viewType: 'full',
availability: {
multipleLiffTransition: {
permission: false,
minVer: '10.8.0',
},
shareTargetPicker: {
permission: false,
minVer: '10.8.0',
},
},
}),
openWindow: ({ url, external }) => {
external ? window.open(url) : (window.location.href = url);
},
closeWindow: () => {
window.close();
},
getFeatures: () => [],
getFriendship: () => __awaiter(void 0, void 0, void 0, function* () {
return { friendFlag: true };
}),
checkFeature: () => true,
getAId: () => undefined,
getProfilePlus: () => undefined,
getIsVideoAutoPlay: () => true,
getLineVersion: () => '10.8.0',
isApiAvailable: () => true,
getProfile: () => __awaiter(void 0, void 0, void 0, function* () {
return ({
displayName: 'displayName',
pictureUrl: 'https://example.com/test.jpg',
statusMessage: '',
userId: 'userId',
});
}),
sendMessages: () => __awaiter(void 0, void 0, void 0, function* () { }),
userPicker: () => __awaiter(void 0, void 0, void 0, function* () { return null; }),
shareTargetPicker: () => __awaiter(void 0, void 0, void 0, function* () { }),
permanentLink,
ready: new Promise(() => { }),
id: 'liffId',
_dispatchEvent: () => { },
_call: () => __awaiter(void 0, void 0, void 0, function* () { }),
_addListener: () => { },
_removeListener: () => { },
_postMessage: () => { },
// Extras
addToHomeScreen: () => __awaiter(void 0, void 0, void 0, function* () { return 0; }),
scanCode: () => __awaiter(void 0, void 0, void 0, function* () { return ({ value: 'DummyCode' }); }),
getAdvertisingId: () => __awaiter(void 0, void 0, void 0, function* () { return null; }),
initPlugins: () => __awaiter(void 0, void 0, void 0, function* () { return []; }),
};
;