GithubHelp home page GithubHelp logo

line / liff-inspector Goto Github PK

View Code? Open in Web Editor NEW
49.0 8.0 4.0 93 KB

The universal DevTools for LIFF (WebView) browser

Home Page: https://www.npmjs.com/package/@line/liff-inspector

License: Apache License 2.0

JavaScript 4.23% TypeScript 95.77%
devtools liff liff-plugin line chrome-devtools chrome-devtools-protocol

liff-inspector's Introduction

Check code health

LIFF Inspector ๐Ÿ”ฌ

The universal DevTools for LIFF (WebView) browser

LIFF Inspector is the official DevTools for LIFF(LNE Frontend Framework) that is integrated with the latest ChromeDevTools and built on top of the ChromeDevTools Protocol.

LIFF browser ChromeDevTools
image image



ๆ—ฅๆœฌ่ชž็‰ˆ

TOC

Features

๐Ÿ“ฑ Enable debugging LIFF Browser and WebView with debugging options disabled

๐ŸŒ Remote debug

๐Ÿ”ฌ Support Elements, Console and NetWork tabs of ChromeDevTools

Getting Started

LIFF Inspector consists of two components:

  • LIFF Inspector Server
  • LIFF Inspector Plugin

LIFF Inspector Server is a server program that mediates communication between LIFF app and ChromeDevTools. LIFF Inspector Plugin is a LIFF Plugin. LIFF Plugin is available in LIFF SDK v2.19.0 or later.

1. Start LIFF Inspector Server

$ npx @line/liff-inspector
Debugger listening on ws://{IP Address}:9222

2. Install LIFF Inspector Plugin to your LIFF App

$ npm install @line/liff-inspector
import liff from '@line/liff';
import LIFFInspectorPlugin from '@line/liff-inspector';

liff.use(new LIFFInspectorPlugin());

3. Connect LIFF App and LIFF Inspector Server

Before the actual liff.init process, LIFF Inspector Plugin will try to connect LIFF Inspector Server. Debugging with LIFF Inspector is available immediately after liff.init call.

liff.init({ liffId: 'liff-xxxx' }).then(() => {
  // LIFF Inspector has been enabled
});

4. Open ChromeDevTools

After liff.init, LIFF Inspector Server shows the devtools URL for your LIFF App in console.

$ npx @line/liff-inspector
Debugger listening on ws://{IP Address}:9222

+ connection from client, id: xxx
+ DevTools URL: devtools://devtools/bundled/inspector.html?wss=8a6f-113-35-87-12.ngrok.io/?hi_id=xxx

Open the URL starts with devtools://devtools/ and enjoy debugging!

Important: LIFF Inspector Server need to be served over SSL/TLS

By default, LIFF Inspector Server starts a local server on ws://localhost:9222, and your LIFF App is served over HTTPS (https://liff.line.me/xxx-yyy). LIFF Inspector Plugin will try to connect to ws://localhost:9222 from https://liff.line.me/xxx-yyy but this will fail due to mixed content.

To eliminate mixed content, you need to serve LIFF Inspector Server over HTTPS (wss://). We have two recommended ways:

Serve local server over HTTPS via 1 or 2

  1. Using ngrok to make LIFF Inspector Server public
    1. Run ngrok
      $ ngrok http 9222
    2. Copy the published URL
      $ node -e "const res=$(curl -s -sS http://127.0.0.1:4040/api/tunnels); const url=new URL(res.tunnels[0].public_url); console.log('wss://'+url.host);"
      wss://xxxx-xxx-xxx.ngrok   # Copy this url

Or

  1. Running LIFF Inspector Server with HTTPS using mkcert

Set HTTPS URL to LIFF Inspector Plugin via 1 or 2

Once LIFF Inspector Server runs over HTTPS, you need to specify its origin to LIFF Inspector Plugin.

  1. Use URL Search Parameter: ?li.origin=

    Add ?li.origin= query to the Endpoint URL of your LIFF App in LINE Developers Console.

    image

Or

  1. Use origin config of LIFF Inspector Plugin

    // Default origin: ws://localhost:9222
    liff.use(new LIFFInspectorPlugin({ origin: 'wss://xxx-xx-xx-xx.ngrok.io' }));

Priority

LIFF Inspector Plugin attempts to connect to given origin in the order li.origin (1), origin config (2).

(Pseudo code)

const originFromURL = new URLSearchParams(search).get('li.origin');
const originFromConfig = config.origin;
const defaultOrigin = 'ws://localhost:9222';
connect(originFromURL ?? originFromConfig ?? defaultOrigin);

Example

See https://github.com/cola119/liff-inspector-example

Roadmap

Contributions Welcome!

Elements Tab

  • To display Elements
  • To display overlays
  • To remove/add/edit Elements
  • To display styles

Console Tab

  • To display console logs
    • console.log
    • console.warn
    • console.error
    • console.info
    • others
  • To execute local scripts

Network Tab

  • To display simple network logs
    • Fetch/XHR
      • fetch()
      • XMLHttpRequest
      • sendBeacon()
      • others
    • Others(JS/CSS/Img/Media/Font...)
      • Technically difficult to intercept them...

Application Tab

  • LocalStorage
  • SessionStorage
  • Cookies
  • others

Contribution

See CONTRIBUTING.md

liff-inspector's People

Contributors

cola119 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

jonsoku-dev

liff-inspector's Issues

Critical Vulnerability in Webpack

I discovered vulnerability in npm packages used in this project.
I attempted to fix this, but it was not easily resolved. I am reporting this as a matter of urgency.

liff-inspector % npm install

changed 1 package, and audited 644 packages in 2s

65 packages are looking for funding
  run `npm fund` for details

10 vulnerabilities (4 moderate, 4 high, 2 critical)

To address issues that do not require attention, run:
  npm audit fix

To address all issues, run:
  npm audit fix --force

Run `npm audit` for details.
# npm audit report

webpack  5.0.0 - 5.75.0
Severity: critical
Cross-realm object access in Webpack 5 - https://github.com/advisories/GHSA-hc6q-2mpp-qw7j
fix available via `npm audit fix --force`
Will install [email protected], which is outside the stated dependency range
node_modules/webpack

1 critical severity vulnerability

To address all issues, run:
  npm audit fix --force

support "TrustProxies" option

When running inspector server behind a proxy like a load balancer, both app client and inspector client access to inspector server with SSL, but the proxy access to inspector server without SSL.

inspector server shows:
DevTools URL: devtools://devtools/bundled/inspector.html?ws=****

correct url is:
DevTools URL: devtools://devtools/bundled/inspector.html?wss=****

Switching display url option is needed like Laravel TrustProxies middleware.

โ˜”๏ธ Support Console API

Currently liff-inspector supports four console APIs: console.(log|warn|error|info) but there are still a lot methods in Console instance.
We welcome PRs that implements APIs not yet supported.

Remaining APIs

  • console.log
  • console.warn
  • console.error
  • console.info
  • console.assert
  • console.clear
  • console.count
  • console.countReset
  • console.debug
  • console.dir
  • console.dirxml
  • console.exception
  • console.group
  • console.groupCollapsed
  • console.groupEnd
  • console.profile
  • console.profileEnd
  • console.table
  • console.time
  • console.timeEnd
  • console.timeLog
  • console.timeStamp
  • console.trace

https://developer.mozilla.org/en-US/docs/Web/API/console#methods

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.