Git Product home page Git Product logo

signer's Introduction

Signer

Browser plugin used to sign transactions for CasperLabs.

Architecture

There are four roles in the browser extension.

1. Popup

The directory src/popup contains the UI part of WebExtension, which is written in React. Since all states lose when the user closes the WebExtension, we need to use the background script as a server.

State Synchronization

Popup call RPC method to background script to modify state, then background scripts push its updated state to popup.

2. Background script

Background work as a backend server, it provides RPC methods for injecting page and popup. The related source code is in src/background.

3. Content Script

A content script is a part of your extension that runs in the context of a particular web page. You can specify which webpage can run the content script by specifying rule in manifest.json/content_scripts.

The code is in src/content/contentscript.ts. When Clarity is visited, the WebExtension creates a new ContentScript in Clarity's page context. This script represents a per-page setup process, which injects inject.ts into the DOM before anything loads. And then content script sets up a Proxy, it receives requests from the injected script and forwards it to background script.

4. Inject Script

Inject script run inside the context of Clarity, which is injected by content script. It just creates a global instance of CasperLabsPluginHelper, so that Clarity code could use it by window.casperlabsHelper.

Develop locally

To build the client and the server you'll need npm.

Here we provide some useful npm command for developing.

npm install

It will install all dependencies for you.

npm run watch

It will build Popup and output bundle files to build directory, and it will also rebuild every time when you modified the code of Popup, however, you still need to reopen or refresh the Popup.

npm run scripts_watch

It will build background, content, and inject scrips in watch mode. However, you have to reload the extension in Chrome's Extension Manage Page.

Build & Publish

Run npm run complete, and then you can find a built browser extension in artifacts directory.

signer's People

Contributors

george-cl avatar hoffmannjan avatar abnerzheng avatar bors[bot] avatar tomvasile avatar sacherjj avatar piotr-dziubecki avatar killianh avatar

Watchers

James Cloos avatar

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.