Skip to content
This repository has been archived by the owner on Jun 21, 2023. It is now read-only.

Commit

Permalink
Merge pull request #82 from PureStake/develop
Browse files Browse the repository at this point in the history
Candidate Release 1.0
  • Loading branch information
purestaketdb authored Aug 24, 2020
2 parents 5b80ec4 + 25f7c8e commit f07ac64
Show file tree
Hide file tree
Showing 79 changed files with 1,810 additions and 494 deletions.
9 changes: 4 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
name: Tests

on: [push]
on:
push:
branches-ignore:
- release

jobs:
end_to_end_tests:
Expand All @@ -12,10 +15,6 @@ jobs:
- uses: actions/setup-node@v2-beta
with:
node-version: '12.15'
# - name: Build project
# run: npm run prebuild && npm run build
# - name: Build ui
# run: npm run buildui
- name: Delete all dist
run: npm run clean
- name: Install testing dependencies
Expand Down
54 changes: 54 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Release build
on:
create:
tags:
- v0.9-*
- v1.*
- v2.*

jobs:
generate:
runs-on: ubuntu-latest
env:
CI: 'true'
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2-beta
with:
node-version: '12.15'
- name: Delete all dist
run: npm run clean
- name: Install testing dependencies
env:
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: 'true'
run: npm install
- name: Build
id: build_dist
run: npm run build
- name: Run tests including puppeteer
uses: djp3/puppeteer-headful@master
with:
args: npm test
- name: Zip up release
id: zip_up
run: zip -r AlgoSigner.zip ./dist/*
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./AlgoSigner.zip
asset_name: AlgoSigner.zip
asset_content_type: application/zip
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
**/@types
**/packages/dapp/lib
.DS_Store
test*.png
test*.png
**/coverage
13 changes: 7 additions & 6 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
*
* Copyright (C) PureStake, Inc - All Rights Reserved
* Unauthorized copying of any contents of this repository, via any medium is strictly prohibited
* Proprietary and confidential
* Written by PureStake Development <[email protected]>, 2020
*
Copyright 2020 PureStake LTD

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
61 changes: 48 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,37 @@
# Introduction
This project is designed to provide an Algorand Wallet and extension based access to sign Algorand transactions in common web browsers.
# ![AlgoSigner](media/algosigner-wallet-banner-3.png)

AlgoSigner is in a pre-launch beta status.
An open-source Algorand wallet browser extension that permits dApp communication for signing Algorand transactions - available for Chrome initially.

## Chrome Extension Store
The extension is available on the Chrome Extension Store at:

_This is the preferred solution for end-users, updates will be automatically installed after review by the extension store_

Developers working with dApps may also install directly from the release package, or by downloading the project and building it.

## Decentralized Applications
As a browser extension, AlgoSigner opens the door for developers to build DeFi applications on Algorand by providing a secure way to add transaction capabilities. This enables developers to initiate transactions and accept ALGOs seamlessly, without jeopardizing the security of their users’ secrets.

For end users, AlgoSigner also makes it easy to use Algorand-based applications on the web. Simply create or import your Algorand account, visit a compatible dApp, and approve or deny transactions — all from within your browser.

DApp users can trust AlgoSigner to:
- Securely store and encrypt account secrets
- Authorize transactions without giving dApps direct access to their keys
- Sign and approve transactions when using dApps

### Developing a dApp

- Read [dApp Integration Guide](docs/dApp-integration.md)
- Read [Sample dApp project](https://github.com/PureStake/algosigner-dapp-example)
- Try [Interactive dApp](https://purestake.github.io/algosigner-dapp-example/)

## Project Structure
There are multiple packages in the project that combine to build the overall extension. Each component package is designed so that it's functionality doesn't require the rebuild of other packages and will be combined to build the deployable extension.

*https://github.com/PureStake*
* algosigner-> // Base project folder
* dist-> // Folder containing the combined distribution components, used to install the extension, created on build
* packages-> // Folder for scripts compents that support the extension
* packages-> // Folder for scripts components that support the extension
* common-> // Contains core elements used in other packages
* crypto-> // Wrapper for encrypting and decrypting account information
* dapp-> // AlgoSigner library that gets injected in dApps
Expand All @@ -20,11 +42,13 @@ There are multiple packages in the project that combine to build the overall ext
* manifest.json // Extension definition file
* package.json // Algosigner package, required packages, and scripts to build the project
* readme.md // Project overview
* dApp-integration.md // Guide to integrating dApps with AlgoSigner
* LICENSE.md // License for this repository
* docs -> // Guides and how-to's
* dApp-integration.md // Guide to integrating dApps with AlgoSigner
* media -> // Supporting images for this repository
* LICENSE.txt // License for this repository

## Installation
The ./dist/ folder is the only required folder to install the extension and must be built.
## Build and Install
The ./dist/ folder is the only required folder to install the extension yourself from code and must be built.

- Clone the repository locally
- Run `npm install` in the root folder
Expand All @@ -34,13 +58,24 @@ The ./dist/ folder is the only required folder to install the extension and must
- Select `Load Unpacked` and choose the just created `dist` folder
- AlgoSigner is now installed and available

## Developing a dApp
## Install from zip
The latest built zip is available for download on the releases page -

- Read [dApp Integration Guide](docs/dApp-integration.md)
- Read [Sample dApp project](https://github.com/PureStake/algosigner-dapp-example)
- Try [Interactive dApp](https://purestake.github.io/algosigner-dapp-example/)
Note - this is not recommended for non-developers and never for production purposes, extreme caution should be taken with installing any wallet.

### Prerequisites
- Installation of the Chrome Browser
- File unzip program
- Local file system write permissions
- Access to set developer mode in Chrome and install unpacked extensions

### Process
- Unzip `AlgoSigner.zip` file to local file system
- Open Chrome Browser and go to `chrome://extensions/`
- Enable developer mode
- Select `Load Unpacked` and choose the unzipped `dist` folder
- AlgoSigner is now installed and available

## License
Until initial development is complete and the product is launched, this repository is private and the contents confidential.
This project is under the MIT License

9 changes: 7 additions & 2 deletions docs/dApp-integration.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# dApp integration through AlgoSigner

AlogSigner injects a JavaScript library for interacting with the extension into every web page the browser user visits. dApp’s may use the injected library to connect to the user’s wallet, discover account addresses, send transactions to the wallet user for signing approval, send signed transactions to the network and query the network.
AlgoSigner injects a JavaScript library for interacting with the extension into every web page the browser user visits. dApp’s may use the injected library to connect to the user’s wallet, discover account addresses, send transactions to the wallet user for signing approval, send signed transactions to the network and query the network.

The sample dApp at https://purestake.github.io/algosigner-dapp-example/ demonstrates these interactions. Instructions here - https://github.com/PureStake/algosigner-dapp-example.

Expand Down Expand Up @@ -124,7 +124,7 @@ let txn = {
"lastRound": txParams['last-round'] + 1000,
"genesisID": txParams['genesis-id'],
"genesisHash": txParams['genesis-hash'],
"note": new Uint8Array(0)
"note": "NOTE is a string"
};
AlgoSigner.sign(txn)
```
Expand All @@ -134,6 +134,9 @@ let txn = {
{"txID":"4F6GE5EBTBJ7DOTWKA3GK4JYARFDCVR5CYEXP6O27FUCE5SGFDYQ",
"blob":"gqNzaWfEQL6mW/7ss2HKAqsuHN/7ePx11wKSAvFocw5QEDvzSvrvJdzWYvT7ua8Lc0SS0zOmUDDaHQC/pGJ0PNqnu7W3qQKjdHhuiaNhbXQGo2ZlZc4AA7U4omZ2zgB+OrujZ2VurHRlc3RuZXQtdjEuMKJnaMQgSGO1GKSzyE7IEPItTxCByw9x8FmnrCDexi9/cOUJOiKibHbOAH4+o6NyY3bEIHhydylNDQQhpD9QdKWejLCMBgb5UYJTGCfDW3KgLsI+o3NuZMQgZM5ZNuFgR8pz2dHBgDlmHolfGgF96zX/X4x2bnAJ3aqkdHlwZaNwYXk="}
```

Interrogation of the blob if needed can be accomplished with a basic example shown for NodeJS and Python in the associated sub folders of the example dapp.

### AlgoSigner.send()
Send a base64 encoded signed transaction blob to AlgoSigner to transmit to the network.

Expand Down Expand Up @@ -162,3 +165,5 @@ The following errors may be returned by the dApp in case of users rejecting requ
UnsupportedLedger = '[RequestErrors.UnsupportedLedger] The provided ledger is not supported.',
Undefined = '[RequestErrors.Undefined] An undefined error occurred.',
```

Errors may be passed back to the dApp from the Algorand JS SDK if a transaction is valid, but has some other issue - for example insufficient funds in the sending account.
2 changes: 1 addition & 1 deletion docs/zip-installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ The zip file contains everything necessary to install and use the AlgoSigner ext
- Access to set developer mode in Chrome and install unpacked extensions

## Process
- Unzip provided `AlgoSigner.version.zip` file to local file system
- Unzip provided `AlgoSigner.zip` file to local file system
- Open Chrome Browser and go to `chrome://extensions/`
- Enable developer mode
- Select `Load Unpacked` and choose the unzipped `dist` folder
Expand Down
Binary file added media/algosigner-wallet-banner-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 4 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "algosigner",
"version": "0.0.1",
"version": "1.0.0",
"author": "https://developer.purestake.io",
"description": "Sign Algorand transactions in your browser with PureStake.",
"keywords": [
Expand All @@ -15,9 +15,8 @@
"postbuild": "npm run copy",
"postinstall": "(cd ./packages/common && npm install); (cd ./packages/crypto && npm install); (cd ./packages/storage && npm install); (cd ./packages/ui && npm install); (cd ./packages/extension && npm install); (cd ./packages/dapp && npm install); (cd ./packages/test-project && npm install);",
"prebuild": "rm -rf ./dist/*",
"test": "cd ./packages/test-project && npm run github-test"
"coveragetest": "cd ./packages/test-project && npm run coveragetest",
"test": "(cd ./packages/crypto && npm run test); (cd ./packages/extension && npm run test); (cd ./packages/ui && npm run test); (cd ./packages/dapp && npm run test); (cd ./packages/common && npm run test); (cd ./packages/test-project && npm run github-test);"
},
"devDependencies": {
"puppeteer": "^5.2.1"
}
"devDependencies": {}
}
15 changes: 15 additions & 0 deletions packages/common/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module.exports = {
"roots": [
"<rootDir>/src"
],
"testMatch": [
"**/__tests__/**/*.+(ts|tsx|js)",
"**/?(*.)+(spec|test).+(ts|tsx|js)"
],
"transform": {
"^.+\\.(ts|tsx)$": "ts-jest"
},
setupFiles: [
"jest-webextension-mock"
]
}
12 changes: 9 additions & 3 deletions packages/common/package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
{
"name": "@algosigner/common",
"version": "0.0.1",
"version": "1.0.0",
"author": "https://developer.purestake.io",
"description": "Common library functions for AlgoSigner.",
"devDependencies": {
"typescript": "^3.7.5"
"typescript": "^3.7.5",
"@types/jest": "^26.0.10",
"jest": "^26.4.1",
"jest-webextension-mock": "^3.6.1",
"ts-jest": "^26.2.0",
"ts-loader": "^8.0.2"
},
"dependencies": {},
"scripts": {
"build": "npm run clean && tsc",
"clean": "rm -rf ./dist/"
"clean": "rm -rf ./dist/",
"test": "jest"
}
}
40 changes: 40 additions & 0 deletions packages/common/src/common.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { extensionBrowser } from './chrome';
import { logging } from './logging';
import { isFromExtension } from './utils';
import { RequestErrors,Transaction,TAccount,Note,Amount } from './types';


test('Test chrome reference', () => {
//@ts-ignore
expect(extensionBrowser).toBe(chrome);
});

test('Logging test', () => {
expect(typeof logging.log).toBe("function");
});

test('Test extension parts', () => {
extensionBrowser.runtime.id = '12345';
expect(isFromExtension('chrome-extension://12345')).toBe(true);
});

test('Type - RequestErrors undefined test', () => {
expect(RequestErrors.Undefined).toBe('[RequestErrors.Undefined] An undefined error occurred.');
});

test('Type - Transaction', () => {
expect({amount: 1, from:"AAA", to:"BBB"} as Transaction).toBeInstanceOf(Object);
});

test('Type - TAccount', () => {
expect('string' as TAccount).toBe('string');
});

test('Type - Note', () => {
expect('string' as Note).toBe('string');
});

test('Type - Amount', () => {
expect(12345 as Amount).toBe(12345);
});

3 changes: 2 additions & 1 deletion packages/common/src/logging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
export class Logging
{
log(error: string): void {
// TODO: BC - How should we handle errors?
// TODO: BC - How should we handle errors?
// Should likely use a logging packackage here to send errors to the user or backend logging.
console.log(error);
}
}
Expand Down
4 changes: 0 additions & 4 deletions packages/common/src/messaging/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ export enum JsonRpcMethod {

}

export enum SupportedAlgod {
Status = "status"
}

export type JsonPayload = {[key: string]: string | number | JsonPayload | undefined};

export type JsonRpcBody = {
Expand Down
7 changes: 0 additions & 7 deletions packages/common/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import {SupportedAlgod} from './messaging/types';

export enum RequestErrors {
None,
NotAuthorized = '[RequestErrors.NotAuthorized] The extension user does not authorize the request.',
Expand All @@ -21,8 +19,3 @@ export type Transaction = {
readonly note?: Note;
readonly to: TAccount;
}

export type AlgodRequest = {
readonly method: SupportedAlgod;
readonly params: {[key: string]: string | number | undefined};
}
6 changes: 6 additions & 0 deletions packages/common/src/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { extensionBrowser } from './chrome';

export function isFromExtension(origin) {
const s = origin.split('://');
return s[0] === "chrome-extension" && s[1] === extensionBrowser.runtime.id;
}
12 changes: 12 additions & 0 deletions packages/crypto/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module.exports = {
"roots": [
"<rootDir>/src"
],
"testMatch": [
"**/__tests__/**/*.+(ts|tsx|js)",
"**/?(*.)+(spec|test).+(ts|tsx|js)"
],
"transform": {
"^.+\\.(ts|tsx)$": "ts-jest"
},
}
Loading

0 comments on commit f07ac64

Please sign in to comment.