├── .gitignore ├── README.md ├── examples ├── angular │ ├── .browserslistrc │ ├── .editorconfig │ ├── .gitignore │ ├── .vscode │ │ ├── extensions.json │ │ ├── launch.json │ │ └── tasks.json │ ├── README.md │ ├── angular.json │ ├── karma.conf.js │ ├── package-lock.json │ ├── package.json │ ├── src │ │ ├── app │ │ │ ├── app-routing.module.ts │ │ │ ├── app.component.css │ │ │ ├── app.component.html │ │ │ ├── app.component.spec.ts │ │ │ ├── app.component.ts │ │ │ ├── app.module.ts │ │ │ └── webSdk.ts │ │ ├── assets │ │ │ └── .gitkeep │ │ ├── environments │ │ │ ├── environment.prod.ts │ │ │ └── environment.ts │ │ ├── favicon.ico │ │ ├── index.html │ │ ├── main.ts │ │ ├── polyfills.ts │ │ ├── styles.css │ │ └── test.ts │ ├── tailwind.config.js │ ├── tsconfig.app.json │ ├── tsconfig.json │ └── tsconfig.spec.json ├── react │ ├── .gitignore │ ├── README.md │ ├── package-lock.json │ ├── package.json │ ├── postcss.config.js │ ├── public │ │ ├── favicon.ico │ │ ├── index.html │ │ ├── logo192.png │ │ ├── logo512.png │ │ ├── manifest.json │ │ └── robots.txt │ ├── src │ │ ├── App.tsx │ │ ├── assets │ │ │ └── logo.svg │ │ ├── atoms │ │ │ └── user.ts │ │ ├── components │ │ │ ├── Avatar.tsx │ │ │ ├── Header.tsx │ │ │ └── Transfer.tsx │ │ ├── index.css │ │ ├── index.tsx │ │ ├── types │ │ │ └── react-app-env.d.ts │ │ └── webSdk.ts │ └── tsconfig.json ├── svelte │ ├── .gitignore │ ├── .vscode │ │ └── extensions.json │ ├── README.md │ ├── package-lock.json │ ├── package.json │ ├── public │ │ ├── favicon.png │ │ └── index.html │ ├── sandbox.config.json │ ├── setupTypeScript.js │ ├── src │ │ ├── App.svelte │ │ ├── Avatar.svelte │ │ ├── Header.svelte │ │ ├── Transfer.svelte │ │ ├── main.ts │ │ ├── userState.ts │ │ └── webSdk.ts │ ├── tsconfig.json │ └── webpack.config.js ├── vanilla-html │ ├── README.md │ └── index.html └── vue │ ├── .browserslistrc │ ├── .eslintrc.js │ ├── .gitignore │ ├── README.md │ ├── babel.config.js │ ├── cypress.json │ ├── package-lock.json │ ├── package.json │ ├── postcss.config.js │ ├── public │ ├── favicon.ico │ └── index.html │ ├── src │ ├── App.vue │ ├── assets │ │ └── logo.svg │ ├── components │ │ ├── Avatar.vue │ │ ├── Header.vue │ │ └── Transfer.vue │ ├── index.css │ ├── main.ts │ ├── router │ │ └── index.ts │ ├── shims-vue.d.ts │ ├── store │ │ └── index.ts │ ├── views │ │ └── Home.vue │ └── webSdk.ts │ ├── tailwind.config.js │ ├── tests │ ├── e2e │ │ ├── .eslintrc.js │ │ ├── plugins │ │ │ └── index.js │ │ ├── specs │ │ │ └── test.js │ │ └── support │ │ │ ├── commands.js │ │ │ └── index.js │ └── unit │ │ └── example.spec.ts │ └── tsconfig.json ├── lerna.json ├── package.json ├── packages ├── proton-browser-transport │ ├── .editorconfig │ ├── .eslintrc │ ├── .gitignore │ ├── .prettierrc │ ├── LICENSE │ ├── Makefile │ ├── README.md │ ├── package-lock.json │ ├── package.json │ ├── rollup.config.js │ ├── src │ │ ├── global.d.ts │ │ ├── index.ts │ │ ├── qrcode │ │ │ ├── 8BitByte.ts │ │ │ ├── BitBuffer.ts │ │ │ ├── ErrorCorrectLevel.ts │ │ │ ├── LICENSE-qrcode │ │ │ ├── Polynomial.ts │ │ │ ├── QRCode.ts │ │ │ ├── RSBlock.ts │ │ │ ├── index.ts │ │ │ ├── math.ts │ │ │ ├── mode.ts │ │ │ └── util.ts │ │ ├── storage.ts │ │ ├── transport.ts │ │ ├── types.ts │ │ ├── utils.ts │ │ └── views │ │ │ ├── CountDown.svelte │ │ │ ├── Dialog.svelte │ │ │ └── QRCode.svelte │ └── tsconfig.json ├── proton-link │ ├── .editorconfig │ ├── .eslintrc │ ├── .gitignore │ ├── .prettierrc │ ├── LICENSE │ ├── Makefile │ ├── README.md │ ├── examples │ │ ├── README.md │ │ ├── login │ │ │ └── index.html │ │ └── transact │ │ │ └── index.html │ ├── package-lock.json │ ├── package.json │ ├── protocol.md │ ├── rollup.config.js │ ├── src │ │ ├── errors.ts │ │ ├── index-bundle.ts │ │ ├── index-module.ts │ │ ├── index.ts │ │ ├── link-callback.ts │ │ ├── link-options.ts │ │ ├── link-session.ts │ │ ├── link-storage.ts │ │ ├── link-transport.ts │ │ ├── link-types.ts │ │ ├── link.ts │ │ └── utils.ts │ ├── test │ │ ├── abis │ │ │ └── eosio.token.json │ │ ├── aes.ts │ │ ├── session.ts │ │ └── tsconfig.json │ ├── tsconfig.json │ └── tslint.json ├── proton-react-native-sdk │ ├── .gitignore │ ├── LICENSE │ ├── README.md │ ├── example │ │ ├── .buckconfig │ │ ├── .editorconfig │ │ ├── .eslintrc.js │ │ ├── .flowconfig │ │ ├── .gitattributes │ │ ├── .gitignore │ │ ├── .prettierrc.js │ │ ├── .watchmanconfig │ │ ├── App.js │ │ ├── __tests__ │ │ │ └── App-test.js │ │ ├── android │ │ │ ├── .project │ │ │ ├── .settings │ │ │ │ └── org.eclipse.buildship.core.prefs │ │ │ ├── app │ │ │ │ ├── .classpath │ │ │ │ ├── .project │ │ │ │ ├── .settings │ │ │ │ │ └── org.eclipse.buildship.core.prefs │ │ │ │ ├── _BUCK │ │ │ │ ├── build.gradle │ │ │ │ ├── build_defs.bzl │ │ │ │ ├── debug.keystore │ │ │ │ ├── proguard-rules.pro │ │ │ │ └── src │ │ │ │ │ ├── debug │ │ │ │ │ ├── AndroidManifest.xml │ │ │ │ │ └── java │ │ │ │ │ │ └── com │ │ │ │ │ │ └── example │ │ │ │ │ │ └── ReactNativeFlipper.java │ │ │ │ │ └── main │ │ │ │ │ ├── AndroidManifest.xml │ │ │ │ │ ├── java │ │ │ │ │ └── com │ │ │ │ │ │ └── example │ │ │ │ │ │ ├── MainActivity.java │ │ │ │ │ │ └── MainApplication.java │ │ │ │ │ └── res │ │ │ │ │ ├── mipmap-hdpi │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ └── ic_launcher_round.png │ │ │ │ │ ├── mipmap-mdpi │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ └── ic_launcher_round.png │ │ │ │ │ ├── mipmap-xhdpi │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ └── ic_launcher_round.png │ │ │ │ │ ├── mipmap-xxhdpi │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ └── ic_launcher_round.png │ │ │ │ │ ├── mipmap-xxxhdpi │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ └── ic_launcher_round.png │ │ │ │ │ └── values │ │ │ │ │ ├── strings.xml │ │ │ │ │ └── styles.xml │ │ │ ├── build.gradle │ │ │ ├── gradle.properties │ │ │ ├── gradle │ │ │ │ └── wrapper │ │ │ │ │ ├── gradle-wrapper.jar │ │ │ │ │ └── gradle-wrapper.properties │ │ │ ├── gradlew │ │ │ ├── gradlew.bat │ │ │ └── settings.gradle │ │ ├── app.json │ │ ├── babel.config.js │ │ ├── index.js │ │ ├── ios │ │ │ ├── File.swift │ │ │ ├── Gemfile │ │ │ ├── Gemfile.lock │ │ │ ├── Podfile │ │ │ ├── Podfile.lock │ │ │ ├── example-Bridging-Header.h │ │ │ ├── example.xcodeproj │ │ │ │ ├── project.pbxproj │ │ │ │ └── xcshareddata │ │ │ │ │ └── xcschemes │ │ │ │ │ └── example.xcscheme │ │ │ ├── example.xcworkspace │ │ │ │ ├── contents.xcworkspacedata │ │ │ │ └── xcshareddata │ │ │ │ │ └── IDEWorkspaceChecks.plist │ │ │ ├── example │ │ │ │ ├── AppDelegate.h │ │ │ │ ├── AppDelegate.m │ │ │ │ ├── Images.xcassets │ │ │ │ │ ├── AppIcon.appiconset │ │ │ │ │ │ └── Contents.json │ │ │ │ │ └── Contents.json │ │ │ │ ├── Info.plist │ │ │ │ ├── LaunchScreen.storyboard │ │ │ │ └── main.m │ │ │ └── exampleTests │ │ │ │ ├── Info.plist │ │ │ │ └── exampleTests.m │ │ ├── metro.config.js │ │ ├── package.json │ │ ├── registerGlobals.js │ │ ├── shim.js │ │ └── yarn.lock │ ├── package-lock.json │ ├── package.json │ ├── src │ │ ├── index.ts │ │ ├── registerGlobals.ts │ │ ├── storage.ts │ │ └── transport.ts │ └── tsconfig.json ├── proton-signing-request │ ├── .editorconfig │ ├── .eslintrc │ ├── .gitignore │ ├── .prettierrc │ ├── LICENSE │ ├── Makefile │ ├── README.md │ ├── package-lock.json │ ├── package.json │ ├── rollup.config.js │ ├── src │ │ ├── abi.ts │ │ ├── base64u.ts │ │ ├── chain-id.ts │ │ ├── identity-proof.ts │ │ ├── index.ts │ │ └── signing-request.ts │ ├── test │ │ ├── abis │ │ │ └── eosio.token.json │ │ ├── misc.ts │ │ ├── request.ts │ │ ├── tsconfig.json │ │ └── utils │ │ │ ├── mock-abi-provider.ts │ │ │ └── node-zlib-provider.ts │ └── tsconfig.json └── proton-web-sdk │ ├── .editorconfig │ ├── .eslintrc.js │ ├── .gitignore │ ├── LICENSE │ ├── Makefile │ ├── README.md │ ├── package-lock.json │ ├── package.json │ ├── rollup.config.js │ ├── src │ ├── connect.ts │ ├── constants.ts │ ├── global.d.ts │ ├── index.ts │ ├── links │ │ ├── cleos.ts │ │ └── protonWeb.ts │ ├── storage.ts │ ├── styles.ts │ ├── types.ts │ ├── views │ │ ├── Dialog.svelte │ │ ├── Footer.svelte │ │ ├── Header.svelte │ │ └── Wallet.svelte │ └── walletTypeSelector.ts │ └── tsconfig.json └── tsconfig.json /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules -------------------------------------------------------------------------------- /examples/angular/.browserslistrc: -------------------------------------------------------------------------------- 1 | # This file is used by the build system to adjust CSS and JS output to support the specified browsers below. 2 | # For additional information regarding the format and rule options, please see: 3 | # https://github.com/browserslist/browserslist#queries 4 | 5 | # For the full list of supported browsers by the Angular framework, please see: 6 | # https://angular.io/guide/browser-support 7 | 8 | # You can see what browsers were selected by your queries by running: 9 | # npx browserslist 10 | 11 | last 1 Chrome version 12 | last 1 Firefox version 13 | last 2 Edge major versions 14 | last 2 Safari major versions 15 | last 2 iOS major versions 16 | Firefox ESR 17 | -------------------------------------------------------------------------------- /examples/angular/.editorconfig: -------------------------------------------------------------------------------- 1 | # Editor configuration, see https://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | indent_style = space 7 | indent_size = 2 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [*.ts] 12 | quote_type = single 13 | 14 | [*.md] 15 | max_line_length = off 16 | trim_trailing_whitespace = false 17 | -------------------------------------------------------------------------------- /examples/angular/.gitignore: -------------------------------------------------------------------------------- 1 | # See http://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # compiled output 4 | /dist 5 | /tmp 6 | /out-tsc 7 | # Only exists if Bazel was run 8 | /bazel-out 9 | 10 | # dependencies 11 | /node_modules 12 | 13 | # profiling files 14 | chrome-profiler-events*.json 15 | 16 | # IDEs and editors 17 | /.idea 18 | .project 19 | .classpath 20 | .c9/ 21 | *.launch 22 | .settings/ 23 | *.sublime-workspace 24 | 25 | # IDE - VSCode 26 | .vscode/* 27 | !.vscode/settings.json 28 | !.vscode/tasks.json 29 | !.vscode/launch.json 30 | !.vscode/extensions.json 31 | .history/* 32 | 33 | # misc 34 | /.angular/cache 35 | /.sass-cache 36 | /connect.lock 37 | /coverage 38 | /libpeerconnection.log 39 | npm-debug.log 40 | yarn-error.log 41 | testem.log 42 | /typings 43 | 44 | # System Files 45 | .DS_Store 46 | Thumbs.db 47 | -------------------------------------------------------------------------------- /examples/angular/.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=827846 3 | "recommendations": ["angular.ng-template"] 4 | } 5 | -------------------------------------------------------------------------------- /examples/angular/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 3 | "version": "0.2.0", 4 | "configurations": [ 5 | { 6 | "name": "ng serve", 7 | "type": "pwa-chrome", 8 | "request": "launch", 9 | "preLaunchTask": "npm: start", 10 | "url": "http://localhost:4200/" 11 | }, 12 | { 13 | "name": "ng test", 14 | "type": "chrome", 15 | "request": "launch", 16 | "preLaunchTask": "npm: test", 17 | "url": "http://localhost:9876/debug.html" 18 | } 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /examples/angular/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | // For more information, visit: https://go.microsoft.com/fwlink/?LinkId=733558 3 | "version": "2.0.0", 4 | "tasks": [ 5 | { 6 | "type": "npm", 7 | "script": "start", 8 | "isBackground": true, 9 | "problemMatcher": { 10 | "owner": "typescript", 11 | "pattern": "$tsc", 12 | "background": { 13 | "activeOnStart": true, 14 | "beginsPattern": { 15 | "regexp": "(.*?)" 16 | }, 17 | "endsPattern": { 18 | "regexp": "bundle generation complete" 19 | } 20 | } 21 | } 22 | }, 23 | { 24 | "type": "npm", 25 | "script": "test", 26 | "isBackground": true, 27 | "problemMatcher": { 28 | "owner": "typescript", 29 | "pattern": "$tsc", 30 | "background": { 31 | "activeOnStart": true, 32 | "beginsPattern": { 33 | "regexp": "(.*?)" 34 | }, 35 | "endsPattern": { 36 | "regexp": "bundle generation complete" 37 | } 38 | } 39 | } 40 | } 41 | ] 42 | } 43 | -------------------------------------------------------------------------------- /examples/angular/README.md: -------------------------------------------------------------------------------- 1 | # Proton Web SDK - Angular Example 2 | 3 | Small boilerplate to get started with Proton on Angular 4 | 5 | [CodeSandbox Playground](https://codesandbox.io/s/proton-angular-demo-d5d9oy) 6 | 7 | ## Development server 8 | 9 | Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files. 10 | 11 | ## Code scaffolding 12 | 13 | Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`. 14 | 15 | ## Build 16 | 17 | Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. 18 | 19 | ## Running unit tests 20 | 21 | Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io). 22 | 23 | ## Running end-to-end tests 24 | 25 | Run `ng e2e` to execute the end-to-end tests via a platform of your choice. To use this command, you need to first add a package that implements end-to-end testing capabilities. 26 | 27 | ## Further help 28 | 29 | To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page. 30 | -------------------------------------------------------------------------------- /examples/angular/karma.conf.js: -------------------------------------------------------------------------------- 1 | // Karma configuration file, see link for more information 2 | // https://karma-runner.github.io/1.0/config/configuration-file.html 3 | 4 | module.exports = function (config) { 5 | config.set({ 6 | basePath: '', 7 | frameworks: ['jasmine', '@angular-devkit/build-angular'], 8 | plugins: [ 9 | require('karma-jasmine'), 10 | require('karma-chrome-launcher'), 11 | require('karma-jasmine-html-reporter'), 12 | require('karma-coverage'), 13 | require('@angular-devkit/build-angular/plugins/karma') 14 | ], 15 | client: { 16 | jasmine: { 17 | // you can add configuration options for Jasmine here 18 | // the possible options are listed at https://jasmine.github.io/api/edge/Configuration.html 19 | // for example, you can disable the random execution with `random: false` 20 | // or set a specific seed with `seed: 4321` 21 | }, 22 | clearContext: false // leave Jasmine Spec Runner output visible in browser 23 | }, 24 | jasmineHtmlReporter: { 25 | suppressAll: true // removes the duplicated traces 26 | }, 27 | coverageReporter: { 28 | dir: require('path').join(__dirname, './coverage/angular'), 29 | subdir: '.', 30 | reporters: [ 31 | { type: 'html' }, 32 | { type: 'text-summary' } 33 | ] 34 | }, 35 | reporters: ['progress', 'kjhtml'], 36 | port: 9876, 37 | colors: true, 38 | logLevel: config.LOG_INFO, 39 | autoWatch: true, 40 | browsers: ['Chrome'], 41 | singleRun: false, 42 | restartOnFileChange: true 43 | }); 44 | }; 45 | -------------------------------------------------------------------------------- /examples/angular/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "angular", 3 | "version": "4.2.19", 4 | "scripts": { 5 | "ng": "ng", 6 | "start": "ng serve", 7 | "build": "ng build", 8 | "test": "ng test" 9 | }, 10 | "private": true, 11 | "dependencies": { 12 | "@angular/animations": "~13.1.0", 13 | "@angular/common": "~13.1.0", 14 | "@angular/compiler": "~13.1.0", 15 | "@angular/core": "~13.1.0", 16 | "@angular/forms": "~13.1.0", 17 | "@angular/platform-browser": "~13.1.0", 18 | "@angular/platform-browser-dynamic": "~13.1.0", 19 | "@angular/router": "~13.1.0", 20 | "@proton/js": "^28.0.0", 21 | "@proton/web-sdk": "^4.2.19", 22 | "@tailwindcss/forms": "^0.4.0", 23 | "rxjs": "~7.4.0", 24 | "tslib": "^2.3.0", 25 | "zone.js": "~0.11.4" 26 | }, 27 | "devDependencies": { 28 | "@angular-devkit/build-angular": "~13.1.2", 29 | "@angular/cli": "~13.1.2", 30 | "@angular/compiler-cli": "~13.1.0", 31 | "@types/bn.js": "^5.1.0", 32 | "@types/elliptic": "^6.4.14", 33 | "@types/jasmine": "~3.10.0", 34 | "@types/node": "^12.11.1", 35 | "jasmine-core": "~3.10.0", 36 | "karma": "~6.3.0", 37 | "karma-chrome-launcher": "~3.1.0", 38 | "karma-coverage": "~2.1.0", 39 | "karma-jasmine": "~4.0.0", 40 | "karma-jasmine-html-reporter": "~1.7.0", 41 | "tailwindcss": "^3.0.7", 42 | "typescript": "~4.5.2" 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /examples/angular/src/app/app-routing.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { RouterModule, Routes } from '@angular/router'; 3 | 4 | const routes: Routes = []; 5 | 6 | @NgModule({ 7 | imports: [ 8 | RouterModule.forRoot(routes) 9 | ], 10 | exports: [RouterModule] 11 | }) 12 | export class AppRoutingModule { } 13 | -------------------------------------------------------------------------------- /examples/angular/src/app/app.component.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XPRNetwork/proton-web-sdk/8a4df507fd7eaeab9759515c092966acefd92c47/examples/angular/src/app/app.component.css -------------------------------------------------------------------------------- /examples/angular/src/app/app.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed } from '@angular/core/testing'; 2 | import { RouterTestingModule } from '@angular/router/testing'; 3 | import { AppComponent } from './app.component'; 4 | 5 | describe('AppComponent', () => { 6 | 7 | }); 8 | -------------------------------------------------------------------------------- /examples/angular/src/app/app.component.ts: -------------------------------------------------------------------------------- 1 | import { Component } from '@angular/core'; 2 | import { FormControl } from '@angular/forms'; 3 | import { RpcInterfaces } from '@proton/js' 4 | import * as SDK from './webSdk' 5 | 6 | @Component({ 7 | selector: 'app-root', 8 | templateUrl: './app.component.html', 9 | styleUrls: ['./app.component.css'] 10 | }) 11 | export class AppComponent { 12 | actor = ''; 13 | permission = ''; 14 | avatar = ''; 15 | accountData = undefined as RpcInterfaces.UserInfo | undefined; 16 | toControl = new FormControl(''); 17 | amountControl = new FormControl(''); 18 | 19 | ngAfterContentInit() { 20 | this.login(true) 21 | } 22 | 23 | clear () { 24 | this.actor = '' 25 | this.permission = '' 26 | this.accountData = undefined 27 | } 28 | 29 | async login (reconnect: boolean = false) { 30 | this.clear() 31 | 32 | if (reconnect) { 33 | await SDK.reconnect() 34 | } else { 35 | await SDK.login() 36 | } 37 | 38 | if (SDK.session && SDK.session.auth) { 39 | this.actor = SDK.session.auth.actor.toString() 40 | this.permission = SDK.session.auth.permission.toString() 41 | 42 | this.accountData = await SDK.getProtonAvatar(this.actor) 43 | this.avatar = this.getAvatar() 44 | } 45 | } 46 | 47 | async logout () { 48 | await SDK.logout() 49 | this.clear() 50 | } 51 | 52 | async transfer () { 53 | await SDK.transfer({ 54 | to: this.toControl.value, 55 | amount: this.amountControl.value, 56 | }) 57 | } 58 | 59 | getAvatar () { 60 | const avatar = this.accountData && this.accountData.avatar 61 | 62 | if (avatar) { 63 | if (avatar.indexOf('/9j/') !== -1) { 64 | return `data:image/jpeg;base64,${avatar}` 65 | } else if (avatar.indexOf('iVBORw0KGgo') !== -1) { 66 | return `data:image/png;base64,${avatar}` 67 | } 68 | } 69 | 70 | return 'https://bloks.io/img/proton_avatar.png' 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /examples/angular/src/app/app.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { BrowserModule } from '@angular/platform-browser'; 3 | import { FormsModule, ReactiveFormsModule } from '@angular/forms'; 4 | 5 | import { AppRoutingModule } from './app-routing.module'; 6 | import { AppComponent } from './app.component'; 7 | 8 | @NgModule({ 9 | declarations: [ 10 | AppComponent 11 | ], 12 | imports: [ 13 | BrowserModule, 14 | AppRoutingModule, 15 | FormsModule, 16 | ReactiveFormsModule, 17 | ], 18 | providers: [], 19 | bootstrap: [AppComponent] 20 | }) 21 | export class AppModule { } 22 | -------------------------------------------------------------------------------- /examples/angular/src/assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XPRNetwork/proton-web-sdk/8a4df507fd7eaeab9759515c092966acefd92c47/examples/angular/src/assets/.gitkeep -------------------------------------------------------------------------------- /examples/angular/src/environments/environment.prod.ts: -------------------------------------------------------------------------------- 1 | export const environment = { 2 | production: true 3 | }; 4 | -------------------------------------------------------------------------------- /examples/angular/src/environments/environment.ts: -------------------------------------------------------------------------------- 1 | // This file can be replaced during build by using the `fileReplacements` array. 2 | // `ng build` replaces `environment.ts` with `environment.prod.ts`. 3 | // The list of file replacements can be found in `angular.json`. 4 | 5 | export const environment = { 6 | production: false 7 | }; 8 | 9 | /* 10 | * For easier debugging in development mode, you can import the following file 11 | * to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`. 12 | * 13 | * This import should be commented out in production mode because it will have a negative impact 14 | * on performance if an error is thrown. 15 | */ 16 | // import 'zone.js/plugins/zone-error'; // Included with Angular CLI. 17 | -------------------------------------------------------------------------------- /examples/angular/src/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XPRNetwork/proton-web-sdk/8a4df507fd7eaeab9759515c092966acefd92c47/examples/angular/src/favicon.ico -------------------------------------------------------------------------------- /examples/angular/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 |
14 | */
15 | export default function generate(text: string, level: 'L' | 'M' | 'Q' | 'H' = 'L', version = -1) {
16 | const qr = new QRCode(version, ErrorCorrectLevel[level])
17 | const rects: Rect[] = []
18 |
19 | qr.addData(text)
20 | qr.make()
21 |
22 | const rows = qr.modules
23 | const size = rows.length
24 |
25 | for (const [y, row] of rows.entries()) {
26 | let rect: Rect | undefined
27 | for (const [x, on] of row.entries()) {
28 | if (on) {
29 | if (!rect) rect = {x, y, width: 0, height: 1}
30 | rect.width++
31 | } else {
32 | if (rect && rect.width > 0) {
33 | rects.push(rect)
34 | }
35 | rect = undefined
36 | }
37 | }
38 | if (rect && rect.width > 0) {
39 | rects.push(rect)
40 | }
41 | }
42 |
43 | const svg: string[] = [`')
48 |
49 |
50 | return "data:image/svg+xml;base64," + btoa(svg.join(''));
51 | }
52 |
--------------------------------------------------------------------------------
/packages/proton-browser-transport/src/qrcode/math.ts:
--------------------------------------------------------------------------------
1 | const QRMath = {
2 | glog: function (n) {
3 | if (n < 1) {
4 | throw new Error('glog(' + n + ')')
5 | }
6 |
7 | return QRMath.LOG_TABLE[n]
8 | },
9 |
10 | gexp: function (n) {
11 | while (n < 0) {
12 | n += 255
13 | }
14 |
15 | while (n >= 256) {
16 | n -= 255
17 | }
18 |
19 | return QRMath.EXP_TABLE[n]
20 | },
21 |
22 | EXP_TABLE: new Array(256),
23 |
24 | LOG_TABLE: new Array(256),
25 | }
26 |
27 | for (let i = 0; i < 8; i++) {
28 | QRMath.EXP_TABLE[i] = 1 << i
29 | }
30 | for (let i = 8; i < 256; i++) {
31 | QRMath.EXP_TABLE[i] =
32 | QRMath.EXP_TABLE[i - 4] ^
33 | QRMath.EXP_TABLE[i - 5] ^
34 | QRMath.EXP_TABLE[i - 6] ^
35 | QRMath.EXP_TABLE[i - 8]
36 | }
37 | for (let i = 0; i < 255; i++) {
38 | QRMath.LOG_TABLE[QRMath.EXP_TABLE[i]] = i
39 | }
40 |
41 | export default QRMath
42 |
--------------------------------------------------------------------------------
/packages/proton-browser-transport/src/qrcode/mode.ts:
--------------------------------------------------------------------------------
1 | export default {
2 | MODE_NUMBER: 1 << 0,
3 | MODE_ALPHA_NUM: 1 << 1,
4 | MODE_8BIT_BYTE: 1 << 2,
5 | MODE_KANJI: 1 << 3,
6 | }
7 |
--------------------------------------------------------------------------------
/packages/proton-browser-transport/src/storage.ts:
--------------------------------------------------------------------------------
1 | import type { LinkStorage } from "@proton/link"
2 |
3 | export class Storage implements LinkStorage {
4 | constructor(readonly keyPrefix: string) { }
5 | async write(key: string, data: string): Promise {
6 | localStorage.setItem(this.storageKey(key), data)
7 | }
8 | async read(key: string): Promise {
9 | return localStorage.getItem(this.storageKey(key))
10 | }
11 | async remove(key: string): Promise {
12 | localStorage.removeItem(this.storageKey(key))
13 | }
14 | storageKey(key: string) {
15 | return `${this.keyPrefix}-${key}`
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/packages/proton-browser-transport/src/types.ts:
--------------------------------------------------------------------------------
1 | export const SkipToManual = Symbol()
2 |
3 | export interface BrowserTransportOptions {
4 | /** CSS class prefix, defaults to `proton-link` */
5 | classPrefix?: string
6 | /** Whether to display request success and error messages, defaults to true */
7 | requestStatus?: boolean
8 | /** Requesting account of the dapp (optional) */
9 | requestAccount?: string
10 | /** Wallet name e.g. proton, anchor, etc */
11 | walletType?: string
12 | /** Local storage prefix, defaults to `proton-link`. */
13 | storagePrefix?: string
14 | }
15 |
16 | export interface footNoteDownloadLinks {
17 | [key: string]: string
18 | }
19 |
20 | export interface DialogArgs {
21 | title: string | HTMLElement
22 | manual?: HTMLElement
23 | subtitle?: string | HTMLElement
24 | type?: string
25 | content?: Record
26 | action?: { text: string; callback: () => void }
27 | showFootnote?: boolean,
28 | hideLogo?: boolean,
29 | hideBackButton?: boolean
30 | }
31 |
--------------------------------------------------------------------------------
/packages/proton-browser-transport/src/views/CountDown.svelte:
--------------------------------------------------------------------------------
1 |
4 |
5 | {countDown}
6 |
7 |
21 |
--------------------------------------------------------------------------------
/packages/proton-browser-transport/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.json",
3 | "compilerOptions": {
4 | "downlevelIteration": true,
5 | "esModuleInterop": true,
6 | "importHelpers": true,
7 | "lib": [
8 | "esnext",
9 | "dom"
10 | ],
11 | "module": "esnext",
12 | "moduleResolution": "node",
13 | "noImplicitAny": false,
14 | "strict": true,
15 | "target": "es2020",
16 | "declarationDir": "./dist/types",
17 | /**
18 | Svelte Preprocess cannot figure out whether you have a value or a type, so tell TypeScript
19 | to enforce using `import type` instead of `import` for Types.
20 | */
21 | "importsNotUsedAsValues": "error",
22 | /**
23 | TypeScript doesn't know about import usages in the template because it only sees the
24 | script of a Svelte file. Therefore preserve all value imports. Requires TS 4.5 or higher.
25 | */
26 | "preserveValueImports": true,
27 | "isolatedModules": true,
28 | /**
29 | To have warnings/errors of the Svelte compiler at the correct position,
30 | enable source maps by default.
31 | */
32 | "sourceMap": true,
33 | "skipLibCheck": true,
34 | "forceConsistentCasingInFileNames": true
35 | },
36 | "include": [
37 | "src/**/*"
38 | ]
39 | }
--------------------------------------------------------------------------------
/packages/proton-link/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | indent_style = space
5 | indent_size = 4
6 | end_of_line = lf
7 | charset = utf-8
8 | trim_trailing_whitespace = true
9 | insert_final_newline = true
10 |
11 | [*.md]
12 | trim_trailing_whitespace = false
13 |
--------------------------------------------------------------------------------
/packages/proton-link/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | "root": true,
3 | "parser": "@typescript-eslint/parser",
4 | "plugins": ["@typescript-eslint"],
5 | "ignorePatterns": ["lib/*", "node_modules/**"],
6 | "extends": [
7 | "eslint:recommended",
8 | "plugin:prettier/recommended",
9 | "plugin:@typescript-eslint/eslint-recommended",
10 | "plugin:@typescript-eslint/recommended"
11 | ],
12 | "rules": {
13 | "prettier/prettier": "warn",
14 | "no-console": "warn",
15 | "sort-imports": [
16 | "warn",
17 | {
18 | "ignoreCase": true,
19 | "ignoreDeclarationSort": true
20 | }
21 | ],
22 | "@typescript-eslint/explicit-module-boundary-types": "off",
23 | "@typescript-eslint/no-explicit-any": "off",
24 | "@typescript-eslint/no-namespace": "off",
25 | "@typescript-eslint/no-non-null-assertion": "off",
26 | "@typescript-eslint/no-empty-function": "warn",
27 | "no-inner-declarations": "off",
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/packages/proton-link/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules/
2 | lib/
3 | docs/
4 | .nyc_output
5 | coverage
6 |
--------------------------------------------------------------------------------
/packages/proton-link/.prettierrc:
--------------------------------------------------------------------------------
1 | arrowParens: "always"
2 | bracketSpacing: false
3 | endOfLine: "lf"
4 | printWidth: 100
5 | semi: false
6 | singleQuote: true
7 | tabWidth: 4
8 | trailingComma: "es5"
9 |
--------------------------------------------------------------------------------
/packages/proton-link/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2020 Greymass Inc. All Rights Reserved.
2 |
3 | Redistribution and use in source and binary forms, with or without modification,
4 | are permitted provided that the following conditions are met:
5 |
6 | 1. Redistribution of source code must retain the above copyright notice, this
7 | list of conditions and the following disclaimer.
8 |
9 | 2. Redistribution in binary form must reproduce the above copyright notice,
10 | this list of conditions and the following disclaimer in the documentation
11 | and/or other materials provided with the distribution.
12 |
13 | 3. Neither the name of the copyright holder nor the names of its contributors
14 | may be used to endorse or promote products derived from this software without
15 | specific prior written permission.
16 |
17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 | IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
21 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
22 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
24 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
25 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
26 | OF THE POSSIBILITY OF SUCH DAMAGE.
27 |
28 | YOU ACKNOWLEDGE THAT THIS SOFTWARE IS NOT DESIGNED, LICENSED OR INTENDED FOR USE
29 | IN THE DESIGN, CONSTRUCTION, OPERATION OR MAINTENANCE OF ANY MILITARY FACILITY.
30 |
--------------------------------------------------------------------------------
/packages/proton-link/Makefile:
--------------------------------------------------------------------------------
1 | SRC_FILES := $(shell find src -name '*.ts')
2 |
3 | lib: ${SRC_FILES} package.json tsconfig.json node_modules rollup.config.js
4 | @./node_modules/.bin/rollup -c && touch lib
5 |
6 | .PHONY: test
7 | test: node_modules
8 | @TS_NODE_PROJECT='./test/tsconfig.json' ./node_modules/.bin/mocha -u tdd -r ts-node/register --extension ts test/*.ts --grep '$(grep)'
9 |
10 | .PHONY: coverage
11 | coverage: node_modules
12 | @TS_NODE_PROJECT='./test/tsconfig.json' ./node_modules/.bin/nyc --reporter=html ./node_modules/.bin/mocha -u tdd -r ts-node/register --extension ts test/*.ts -R nyan && open coverage/index.html
13 |
14 | .PHONY: lint
15 | lint: node_modules
16 | @./node_modules/.bin/eslint src --ext .ts --fix
17 |
18 | .PHONY: ci-test
19 | ci-test: node_modules
20 | @TS_NODE_PROJECT='./test/tsconfig.json' ./node_modules/.bin/nyc --reporter=text ./node_modules/.bin/mocha -u tdd -r ts-node/register --extension ts test/*.ts -R list
21 |
22 | .PHONY: ci-lint
23 | ci-lint: node_modules
24 | @./node_modules/.bin/eslint src --ext .ts --max-warnings 0 --format unix && echo "Ok"
25 |
26 | docs: $(SRC_FILES) node_modules
27 | ./node_modules/.bin/typedoc \
28 | --excludeInternal \
29 | --excludePrivate --excludeProtected \
30 | --name "Proton Link" --includeVersion --readme none \
31 | --out docs \
32 | src/index-module.ts
33 |
34 | .PHONY: deploy-site
35 | deploy-site: docs
36 | cp -r ./examples ./docs/examples/
37 | ./node_modules/.bin/gh-pages -d docs
38 |
39 | node_modules:
40 | yarn install --non-interactive --frozen-lockfile --ignore-scripts
41 |
42 | .PHONY: publish
43 | publish: | distclean node_modules
44 | @git diff-index --quiet HEAD || (echo "Uncommitted changes, please commit first" && exit 1)
45 | @git fetch origin && git diff origin/master --quiet || (echo "Changes not pushed to origin, please push first" && exit 1)
46 | @yarn config set version-tag-prefix "" && yarn config set version-git-message "Version %s"
47 | @yarn publish && git push && git push --tags
48 |
49 | .PHONY: clean
50 | clean:
51 | rm -rf lib/ coverage/ docs/
52 |
53 | .PHONY: distclean
54 | distclean: clean
55 | rm -rf node_modules/
56 |
--------------------------------------------------------------------------------
/packages/proton-link/examples/README.md:
--------------------------------------------------------------------------------
1 | # Proton Link usage examples
2 |
3 | - Once-off transaction on custom chain - [Source](./transact) | [Live demo](https://greymass.github.io/proton-link/examples/transact/)
4 | - Login and transact with sessions - [Source](./login) | [Live demo](https://greymass.github.io/proton-link/examples/login/)
5 |
6 | Note that these examples uses the pre-built bundles from [unpkg](https://unpkg.com/proton-link/) for convenience and portability, we recommend that you use a bundler like [parcel](https://parceljs.org), [rollup](https://rollupjs.org) or [webpack](https://webpack.js.org) to include Proton Link in your project instead.
7 |
--------------------------------------------------------------------------------
/packages/proton-link/examples/transact/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Proton Link - Transact
7 |
8 |
9 |
42 |
43 |
44 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/packages/proton-link/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@proton/link",
3 | "version": "4.2.20",
4 | "description": "Library for authenticating and signing transactions using the Proton Link protocol",
5 | "license": "BSD-3-Clause",
6 | "main": "lib/proton-link.js",
7 | "module": "lib/proton-link.m.js",
8 | "types": "lib/proton-link.d.ts",
9 | "unpkg": "lib/proton-link.bundle.js",
10 | "scripts": {
11 | "watch": "rollup -c -w",
12 | "prepare": "make"
13 | },
14 | "directories": {
15 | "lib": "lib"
16 | },
17 | "repository": {
18 | "type": "git",
19 | "url": "git+https://github.com/protonprotocol/proton-link.git"
20 | },
21 | "authors": [
22 | "Johan Nordberg ",
23 | "Aaron Cox "
24 | ],
25 | "bugs": {
26 | "url": "https://github.com/protonprotocol/proton-link/issues"
27 | },
28 | "homepage": "https://github.com/protonprotocol/proton-link",
29 | "files": [
30 | "lib/*",
31 | "src/*"
32 | ],
33 | "browser": {
34 | "buffer": false,
35 | "crypto": false
36 | },
37 | "dependencies": {
38 | "@greymass/eosio": "^0.6.1",
39 | "@jafri/asmcrypto.js": "^2.3.2",
40 | "@proton/js": "^28.1.2",
41 | "@proton/signing-request": "^4.2.7",
42 | "bson": "^4.6.0",
43 | "fetch-ponyfill": "^7.1.0",
44 | "isomorphic-ws": "^4.0.1",
45 | "pako": "^2.0.3",
46 | "uuid": "^8.3.2",
47 | "ws": "^7.4.3"
48 | },
49 | "devDependencies": {
50 | "@babel/core": "^7.12.16",
51 | "@babel/preset-env": "^7.12.16",
52 | "@rollup/plugin-babel": "^5.2.3",
53 | "@rollup/plugin-commonjs": "^19.0.0",
54 | "@rollup/plugin-json": "^4.1.0",
55 | "@rollup/plugin-node-resolve": "^13.0.0",
56 | "@rollup/plugin-replace": "^2.3.4",
57 | "@rollup/plugin-typescript": "^8.1.1",
58 | "@types/bn.js": "^5.1.0",
59 | "@types/mocha": "^8.2.3",
60 | "@types/node": "^16.3.3",
61 | "@types/pako": "^1.0.1",
62 | "@types/uuid": "^8.0.0",
63 | "@types/ws": "^7.4.0",
64 | "@typescript-eslint/eslint-plugin": "^4.15.0",
65 | "@typescript-eslint/parser": "^4.15.0",
66 | "core-js": "^3.8.3",
67 | "eslint": "^7.18.0",
68 | "eslint-config-prettier": "^8.1.0",
69 | "eslint-plugin-prettier": "^3.3.1",
70 | "gh-pages": "^5.0.0",
71 | "mocha": "^9.0.2",
72 | "nyc": "^15.1.0",
73 | "prettier": "^2.2.1",
74 | "rollup": "^2.38.5",
75 | "rollup-plugin-dts": "^3.0.1",
76 | "rollup-plugin-terser": "^7.0.2",
77 | "ts-node": "^10.0.0",
78 | "tslib": "^2.4.0",
79 | "typedoc": "^0.21.4",
80 | "typescript": "^4.1.5"
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/packages/proton-link/src/errors.ts:
--------------------------------------------------------------------------------
1 | import type {LinkSession} from './link-session'
2 |
3 | /**
4 | * Error codes. Accessible using the `code` property on errors thrown by [[Link]] and [[LinkSession]].
5 | * - `E_DELIVERY`: Unable to route message to wallet.
6 | * - `E_TIMEOUT`: Request was delivered but user/wallet didn't respond in time.
7 | * - `E_CANCEL`: The [[LinkTransport]] canceled the request.
8 | * - `E_IDENTITY`: Identity proof failed to verify.
9 | */
10 | export type LinkErrorCode = 'E_DELIVERY' | 'E_TIMEOUT' | 'E_CANCEL' | 'E_IDENTITY'
11 |
12 | /**
13 | * Error that is thrown if a [[LinkTransport]] cancels a request.
14 | * @internal
15 | */
16 | export class CancelError extends Error {
17 | public code = 'E_CANCEL'
18 | constructor(reason?: string) {
19 | super(`Request cancelled ${reason ? '(' + reason + ')' : ''}`)
20 | }
21 | }
22 |
23 | /**
24 | * Error that is thrown if an identity request fails to verify.
25 | * @internal
26 | */
27 | export class IdentityError extends Error {
28 | public code = 'E_IDENTITY'
29 | constructor(reason?: string) {
30 | super(`Unable to verify identity ${reason ? '(' + reason + ')' : ''}`)
31 | }
32 | }
33 |
34 | /**
35 | * Error originating from a [[LinkSession]].
36 | * @internal
37 | */
38 | export class SessionError extends Error {
39 | public code: 'E_DELIVERY' | 'E_TIMEOUT'
40 | public session: LinkSession
41 | constructor(reason: string, code: 'E_DELIVERY' | 'E_TIMEOUT', session: LinkSession) {
42 | super(reason)
43 | this.code = code
44 | this.session = session
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/packages/proton-link/src/index-bundle.ts:
--------------------------------------------------------------------------------
1 | import * as pkg from './index'
2 | const ProtonLink = pkg.default
3 | for (const key of Object.keys(pkg)) {
4 | if (key === 'default') continue
5 | ProtonLink[key] = pkg[key]
6 | }
7 | export default ProtonLink
8 |
--------------------------------------------------------------------------------
/packages/proton-link/src/index-module.ts:
--------------------------------------------------------------------------------
1 | export * from './link'
2 | export * from './link-session'
3 | export * from './link-types'
4 |
5 | export type {LinkOptions, LinkChainConfig} from './link-options'
6 | export type {LinkTransport} from './link-transport'
7 | export type {LinkStorage} from './link-storage'
8 | export type {
9 | LinkCallback,
10 | LinkCallbackService,
11 | LinkCallbackRejection,
12 | LinkCallbackResponse,
13 | } from './link-callback'
14 | export * from './errors'
15 | export {
16 | IdentityProof,
17 | IdentityProofType,
18 | CallbackPayload,
19 | ChainId,
20 | ChainIdType,
21 | ChainName,
22 | } from '@proton/signing-request'
23 |
--------------------------------------------------------------------------------
/packages/proton-link/src/index.ts:
--------------------------------------------------------------------------------
1 | // export library
2 | export * from './index-module'
3 |
4 | // default export is Link class for convenience
5 | import { Link } from './index-module'
6 | export default Link
7 |
8 | // expose dependencies
9 | export * from '@proton/signing-request'
10 | export * from '@greymass/eosio'
11 |
--------------------------------------------------------------------------------
/packages/proton-link/src/link-storage.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Interface storage adapters should implement.
3 | *
4 | * Storage adapters are responsible for persisting [[LinkSession]]s and can optionally be
5 | * passed to the [[Link]] constructor to auto-persist sessions.
6 | */
7 | export interface LinkStorage {
8 | /** Write string to storage at key. Should overwrite existing values without error. */
9 | write(key: string, data: string): Promise
10 | /** Read key from storage. Should return `null` if key can not be found. */
11 | read(key: string): Promise
12 | /** Delete key from storage. Should not error if deleting non-existing key. */
13 | remove(key: string): Promise
14 | }
15 |
--------------------------------------------------------------------------------
/packages/proton-link/src/link-transport.ts:
--------------------------------------------------------------------------------
1 | import type {Bytes} from '@greymass/eosio'
2 | import type {SigningRequest} from '@proton/signing-request'
3 |
4 | import type {TransactResult} from './link'
5 | import type {LinkSession} from './link-session'
6 | import type {LinkStorage} from './link-storage'
7 |
8 | /**
9 | * Protocol link transports need to implement.
10 | *
11 | * A transport is responsible for getting the request to the
12 | * user, e.g. by opening request URIs or displaying QR codes.
13 | */
14 | export interface LinkTransport {
15 | /**
16 | * Present a signing request to the user.
17 | * @param request The signing request.
18 | * @param cancel Can be called to abort the request.
19 | */
20 | onRequest(request: SigningRequest, cancel: (reason: string | Error) => void): void
21 | /** Called if the request was successful. */
22 | onSuccess?(request: SigningRequest, result: TransactResult): void
23 | /** Called if the request failed. */
24 | onFailure?(request: SigningRequest, error: Error): void
25 | /**
26 | * Called when a session request is initiated.
27 | * @param session Session where the request originated.
28 | * @param request Signing request that will be sent over the session.
29 | */
30 | onSessionRequest?(
31 | session: LinkSession,
32 | request: SigningRequest,
33 | cancel: (reason: string | Error) => void
34 | ): void
35 | /** Can be implemented if transport provides a storage as well. */
36 | storage?: LinkStorage
37 | /** Can be implemented to modify request just after it has been created. */
38 | prepare?(request: SigningRequest, session?: LinkSession): Promise
39 | /** Called immediately when the transaction starts */
40 | showLoading?(): void
41 | /** User agent reported to the signer. */
42 | userAgent?(): string
43 | /** Send session request payload, optional. Can return false to indicate it has to be sent over the socket. */
44 | sendSessionPayload?(payload: Bytes, session: LinkSession): boolean
45 | /**
46 | * Can be implemented to recover from certain errors, if the function returns true the error will
47 | * not bubble up to the caller of .transact or .login and the link will continue waiting for the callback.
48 | */
49 | recoverError?(error: Error, request: SigningRequest): boolean
50 | }
51 |
--------------------------------------------------------------------------------
/packages/proton-link/src/link-types.ts:
--------------------------------------------------------------------------------
1 | import {Bytes, Name, PublicKey, Struct, TimePointSec, UInt32, UInt64} from '@greymass/eosio'
2 |
3 | @Struct.type('sealed_message')
4 | export class SealedMessage extends Struct {
5 | @Struct.field('public_key') from!: PublicKey;
6 | @Struct.field('uint64') nonce!: UInt64;
7 | @Struct.field('bytes') ciphertext!: Bytes;
8 | @Struct.field('uint32') checksum!: UInt32;
9 | }
10 |
11 | @Struct.type('link_create')
12 | export class LinkCreate extends Struct {
13 | @Struct.field('name') session_name!: Name;
14 | @Struct.field('public_key') request_key!: PublicKey;
15 | @Struct.field('string', {extension: true}) user_agent?: string
16 | }
17 |
18 | @Struct.type('link_info')
19 | export class LinkInfo extends Struct {
20 | @Struct.field('time_point_sec') expiration!: TimePointSec;
21 | }
22 |
--------------------------------------------------------------------------------
/packages/proton-link/src/utils.ts:
--------------------------------------------------------------------------------
1 | import makeFetch from 'fetch-ponyfill'
2 | import {AES_CBC} from '@jafri/asmcrypto.js'
3 | import {
4 | Bytes,
5 | Checksum256,
6 | Checksum512,
7 | PrivateKey,
8 | PublicKey,
9 | Serializer,
10 | UInt32,
11 | UInt64,
12 | } from '@greymass/eosio'
13 | import {CallbackPayload, SigningRequest} from '@proton/signing-request'
14 |
15 | import {SealedMessage} from './link-types'
16 |
17 | /** @internal */
18 | export const fetch = makeFetch().fetch
19 |
20 | /**
21 | * Encrypt a message using AES and shared secret derived from given keys.
22 | * @internal
23 | */
24 | export function sealMessage(
25 | message: string,
26 | privateKey: PrivateKey,
27 | publicKey: PublicKey,
28 | nonce?: UInt64
29 | ): SealedMessage {
30 | const secret = privateKey.sharedSecret(publicKey)
31 | if (!nonce) {
32 | nonce = UInt64.from(UInt32.random())
33 | }
34 | const key = Checksum512.hash(Serializer.encode({object: nonce}).appending(secret.array))
35 | const cbc = new AES_CBC(key.array.slice(0, 32), key.array.slice(32, 48))
36 | const ciphertext = Bytes.from(cbc.encrypt(Bytes.from(message, 'utf8').array))
37 | const checksumView = new DataView(Checksum256.hash(key.array).array.buffer)
38 | const checksum = checksumView.getUint32(0, true)
39 | return SealedMessage.from({
40 | from: privateKey.toPublic(),
41 | nonce,
42 | ciphertext,
43 | checksum,
44 | })
45 | }
46 |
47 | /**
48 | * Extract session metadata from a callback payload and request.
49 | * @internal
50 | */
51 | export function sessionMetadata(payload: CallbackPayload, request: SigningRequest) {
52 | const metadata: Record = {
53 | // backwards compat, can be removed next major release
54 | sameDevice: request.getRawInfo()['return_path'] !== undefined,
55 | }
56 | // append extra metadata from the signer
57 | if (payload.link_meta) {
58 | try {
59 | const parsed = JSON.parse(payload.link_meta)
60 | for (const key of Object.keys(parsed)) {
61 | // normalize key names to camelCase
62 | metadata[snakeToCamel(key)] = parsed[key]
63 | }
64 | } catch (error) {
65 | logWarn('Unable to parse link metadata', error, payload.link_meta)
66 | }
67 | }
68 | return metadata
69 | }
70 |
71 | /**
72 | * Return PascalCase version of snake_case string.
73 | * @internal
74 | */
75 | function snakeToPascal(name: string): string {
76 | return name
77 | .split('_')
78 | .map((v) => (v[0] ? v[0].toUpperCase() : '_') + v.slice(1))
79 | .join('')
80 | }
81 |
82 | /**
83 | * Return camelCase version of snake_case string.
84 | * @internal
85 | */
86 | function snakeToCamel(name: string): string {
87 | const pascal = snakeToPascal(name)
88 | return pascal[0].toLowerCase() + pascal.slice(1)
89 | }
90 |
91 | /**
92 | * Print a warning message to console.
93 | * @internal
94 | **/
95 | export function logWarn(...args: any[]) {
96 | // eslint-disable-next-line no-console
97 | console.warn('[anchor-link]', ...args)
98 | }
99 |
--------------------------------------------------------------------------------
/packages/proton-link/test/aes.ts:
--------------------------------------------------------------------------------
1 | import * as assert from 'assert'
2 | import 'mocha'
3 |
4 | import {sealMessage} from '../src/utils'
5 | import {PrivateKey, UInt64} from '@greymass/eosio'
6 |
7 | suite('aes', function () {
8 | test('seal message', function () {
9 | const k1 = PrivateKey.from('5KGNiwTYdDWVBc9RCC28hsi7tqHGUsikn9Gs8Yii93fXbkYzxGi')
10 | const k2 = PrivateKey.from('5Kik3tbLSn24ScHFsj6GwLkgd1H4Wecxkzt1VX7PBBRDQUCdGFa')
11 | const sealed = sealMessage(
12 | 'The hovercraft is full of eels',
13 | k1,
14 | k2.toPublic(),
15 | UInt64.from(42)
16 | )
17 | assert.equal(
18 | sealed.ciphertext.hexString,
19 | 'a26b34e0fe70e2d624da9fddf3ba574c5b827d729d0edc172641f44ea3739ab0'
20 | )
21 | assert.equal(sealed.checksum.toString(), '2660735416')
22 | })
23 | })
24 |
--------------------------------------------------------------------------------
/packages/proton-link/test/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "isolatedModules": false,
5 | "module": "commonjs",
6 | "target": "es2015"
7 | },
8 | "include": ["./**/*.ts"]
9 | }
10 |
--------------------------------------------------------------------------------
/packages/proton-link/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.json",
3 | "compilerOptions": {
4 | "downlevelIteration": true,
5 | "esModuleInterop": true,
6 | "experimentalDecorators": true,
7 | "importHelpers": true,
8 | "lib": ["esnext", "dom"],
9 | "module": "esnext",
10 | "moduleResolution": "node",
11 | "noImplicitAny": false,
12 | "sourceMap": true,
13 | "strict": true,
14 | "target": "es2020",
15 | "declarationDir": "./dist/types",
16 | },
17 | "include": ["src/*"]
18 | }
19 |
--------------------------------------------------------------------------------
/packages/proton-link/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": [
3 | "tslint-plugin-prettier",
4 | "tslint-config-prettier"
5 | ],
6 | "rules": {
7 | "prettier": true,
8 | "triple-equals": [
9 | true,
10 | "allow-null-check"
11 | ],
12 | "ordered-imports": true
13 | }
14 | }
--------------------------------------------------------------------------------
/packages/proton-react-native-sdk/.gitignore:
--------------------------------------------------------------------------------
1 | *.log
2 | .DS_Store
3 | node_modules
4 | dist
5 |
--------------------------------------------------------------------------------
/packages/proton-react-native-sdk/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020 philolo1
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/packages/proton-react-native-sdk/example/.buckconfig:
--------------------------------------------------------------------------------
1 |
2 | [android]
3 | target = Google Inc.:Google APIs:23
4 |
5 | [maven_repositories]
6 | central = https://repo1.maven.org/maven2
7 |
--------------------------------------------------------------------------------
/packages/proton-react-native-sdk/example/.editorconfig:
--------------------------------------------------------------------------------
1 | # Windows files
2 | [*.bat]
3 | end_of_line = crlf
4 |
--------------------------------------------------------------------------------
/packages/proton-react-native-sdk/example/.eslintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | root: true,
3 | extends: '@react-native-community',
4 | };
5 |
--------------------------------------------------------------------------------
/packages/proton-react-native-sdk/example/.flowconfig:
--------------------------------------------------------------------------------
1 | [ignore]
2 | ; We fork some components by platform
3 | .*/*[.]android.js
4 |
5 | ; Ignore "BUCK" generated dirs
6 | /\.buckd/
7 |
8 | ; Ignore polyfills
9 | node_modules/react-native/Libraries/polyfills/.*
10 |
11 | ; Flow doesn't support platforms
12 | .*/Libraries/Utilities/LoadingView.js
13 |
14 | [untyped]
15 | .*/node_modules/@react-native-community/cli/.*/.*
16 |
17 | [include]
18 |
19 | [libs]
20 | node_modules/react-native/interface.js
21 | node_modules/react-native/flow/
22 |
23 | [options]
24 | emoji=true
25 |
26 | esproposal.optional_chaining=enable
27 | esproposal.nullish_coalescing=enable
28 |
29 | exact_by_default=true
30 |
31 | module.file_ext=.js
32 | module.file_ext=.json
33 | module.file_ext=.ios.js
34 |
35 | munge_underscores=true
36 |
37 | module.name_mapper='^react-native/\(.*\)$' -> '/node_modules/react-native/\1'
38 | module.name_mapper='^@?[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> '/node_modules/react-native/Libraries/Image/RelativeImageStub'
39 |
40 | suppress_type=$FlowIssue
41 | suppress_type=$FlowFixMe
42 | suppress_type=$FlowFixMeProps
43 | suppress_type=$FlowFixMeState
44 |
45 | [lints]
46 | sketchy-null-number=warn
47 | sketchy-null-mixed=warn
48 | sketchy-number=warn
49 | untyped-type-import=warn
50 | nonstrict-import=warn
51 | deprecated-type=warn
52 | unsafe-getters-setters=warn
53 | unnecessary-invariant=warn
54 | signature-verification-failure=warn
55 |
56 | [strict]
57 | deprecated-type
58 | nonstrict-import
59 | sketchy-null
60 | unclear-type
61 | unsafe-getters-setters
62 | untyped-import
63 | untyped-type-import
64 |
65 | [version]
66 | ^0.137.0
67 |
--------------------------------------------------------------------------------
/packages/proton-react-native-sdk/example/.gitattributes:
--------------------------------------------------------------------------------
1 | # Windows files should use crlf line endings
2 | # https://help.github.com/articles/dealing-with-line-endings/
3 | *.bat text eol=crlf
4 |
--------------------------------------------------------------------------------
/packages/proton-react-native-sdk/example/.gitignore:
--------------------------------------------------------------------------------
1 | # OSX
2 | #
3 | .DS_Store
4 |
5 | # Xcode
6 | #
7 | build/
8 | *.pbxuser
9 | !default.pbxuser
10 | *.mode1v3
11 | !default.mode1v3
12 | *.mode2v3
13 | !default.mode2v3
14 | *.perspectivev3
15 | !default.perspectivev3
16 | xcuserdata
17 | *.xccheckout
18 | *.moved-aside
19 | DerivedData
20 | *.hmap
21 | *.ipa
22 | *.xcuserstate
23 |
24 | # Android/IntelliJ
25 | #
26 | build/
27 | .idea
28 | .gradle
29 | local.properties
30 | *.iml
31 |
32 | # node.js
33 | #
34 | node_modules/
35 | npm-debug.log
36 | yarn-error.log
37 |
38 | # BUCK
39 | buck-out/
40 | \.buckd/
41 | *.keystore
42 | !debug.keystore
43 |
44 | # fastlane
45 | #
46 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
47 | # screenshots whenever they are needed.
48 | # For more information about the recommended setup visit:
49 | # https://docs.fastlane.tools/best-practices/source-control/
50 |
51 | */fastlane/report.xml
52 | */fastlane/Preview.html
53 | */fastlane/screenshots
54 |
55 | # Bundle artifact
56 | *.jsbundle
57 |
58 | # CocoaPods
59 | /ios/Pods/
60 |
--------------------------------------------------------------------------------
/packages/proton-react-native-sdk/example/.prettierrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | bracketSpacing: false,
3 | jsxBracketSameLine: true,
4 | singleQuote: true,
5 | trailingComma: 'all',
6 | arrowParens: 'avoid',
7 | };
8 |
--------------------------------------------------------------------------------
/packages/proton-react-native-sdk/example/.watchmanconfig:
--------------------------------------------------------------------------------
1 | {}
--------------------------------------------------------------------------------
/packages/proton-react-native-sdk/example/__tests__/App-test.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @format
3 | */
4 |
5 | import 'react-native';
6 | import React from 'react';
7 | import App from '../App';
8 |
9 | // Note: test renderer must be required after react-native.
10 | import renderer from 'react-test-renderer';
11 |
12 | it('renders correctly', () => {
13 | renderer.create( );
14 | });
15 |
--------------------------------------------------------------------------------
/packages/proton-react-native-sdk/example/android/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | example
4 | Project android created by Buildship.
5 |
6 |
7 |
8 |
9 | org.eclipse.buildship.core.gradleprojectbuilder
10 |
11 |
12 |
13 |
14 |
15 | org.eclipse.buildship.core.gradleprojectnature
16 |
17 |
18 |
19 | 0
20 |
21 | 30
22 |
23 | org.eclipse.core.resources.regexFilterMatcher
24 | node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/packages/proton-react-native-sdk/example/android/.settings/org.eclipse.buildship.core.prefs:
--------------------------------------------------------------------------------
1 | arguments=
2 | auto.sync=false
3 | build.scans.enabled=false
4 | connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER)
5 | connection.project.dir=
6 | eclipse.preferences.version=1
7 | gradle.user.home=
8 | java.home=/Library/Java/JavaVirtualMachines/adoptopenjdk-15.jdk/Contents/Home
9 | jvm.arguments=
10 | offline.mode=false
11 | override.workspace.settings=true
12 | show.console.view=true
13 | show.executions.view=true
14 |
--------------------------------------------------------------------------------
/packages/proton-react-native-sdk/example/android/app/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/packages/proton-react-native-sdk/example/android/app/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | app
4 | Project app created by Buildship.
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 | org.eclipse.buildship.core.gradleprojectbuilder
15 |
16 |
17 |
18 |
19 |
20 | org.eclipse.jdt.core.javanature
21 | org.eclipse.buildship.core.gradleprojectnature
22 |
23 |
24 |
25 | 1626150921685
26 |
27 | 30
28 |
29 | org.eclipse.core.resources.regexFilterMatcher
30 | node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/packages/proton-react-native-sdk/example/android/app/.settings/org.eclipse.buildship.core.prefs:
--------------------------------------------------------------------------------
1 | connection.project.dir=..
2 | eclipse.preferences.version=1
3 |
--------------------------------------------------------------------------------
/packages/proton-react-native-sdk/example/android/app/_BUCK:
--------------------------------------------------------------------------------
1 | # To learn about Buck see [Docs](https://buckbuild.com/).
2 | # To run your application with Buck:
3 | # - install Buck
4 | # - `npm start` - to start the packager
5 | # - `cd android`
6 | # - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"`
7 | # - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck
8 | # - `buck install -r android/app` - compile, install and run application
9 | #
10 |
11 | load(":build_defs.bzl", "create_aar_targets", "create_jar_targets")
12 |
13 | lib_deps = []
14 |
15 | create_aar_targets(glob(["libs/*.aar"]))
16 |
17 | create_jar_targets(glob(["libs/*.jar"]))
18 |
19 | android_library(
20 | name = "all-libs",
21 | exported_deps = lib_deps,
22 | )
23 |
24 | android_library(
25 | name = "app-code",
26 | srcs = glob([
27 | "src/main/java/**/*.java",
28 | ]),
29 | deps = [
30 | ":all-libs",
31 | ":build_config",
32 | ":res",
33 | ],
34 | )
35 |
36 | android_build_config(
37 | name = "build_config",
38 | package = "com.example",
39 | )
40 |
41 | android_resource(
42 | name = "res",
43 | package = "com.example",
44 | res = "src/main/res",
45 | )
46 |
47 | android_binary(
48 | name = "app",
49 | keystore = "//android/keystores:debug",
50 | manifest = "src/main/AndroidManifest.xml",
51 | package_type = "debug",
52 | deps = [
53 | ":app-code",
54 | ],
55 | )
56 |
--------------------------------------------------------------------------------
/packages/proton-react-native-sdk/example/android/app/build_defs.bzl:
--------------------------------------------------------------------------------
1 | """Helper definitions to glob .aar and .jar targets"""
2 |
3 | def create_aar_targets(aarfiles):
4 | for aarfile in aarfiles:
5 | name = "aars__" + aarfile[aarfile.rindex("/") + 1:aarfile.rindex(".aar")]
6 | lib_deps.append(":" + name)
7 | android_prebuilt_aar(
8 | name = name,
9 | aar = aarfile,
10 | )
11 |
12 | def create_jar_targets(jarfiles):
13 | for jarfile in jarfiles:
14 | name = "jars__" + jarfile[jarfile.rindex("/") + 1:jarfile.rindex(".jar")]
15 | lib_deps.append(":" + name)
16 | prebuilt_jar(
17 | name = name,
18 | binary_jar = jarfile,
19 | )
20 |
--------------------------------------------------------------------------------
/packages/proton-react-native-sdk/example/android/app/debug.keystore:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/XPRNetwork/proton-web-sdk/8a4df507fd7eaeab9759515c092966acefd92c47/packages/proton-react-native-sdk/example/android/app/debug.keystore
--------------------------------------------------------------------------------
/packages/proton-react-native-sdk/example/android/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
--------------------------------------------------------------------------------
/packages/proton-react-native-sdk/example/android/app/src/debug/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/packages/proton-react-native-sdk/example/android/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
13 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/packages/proton-react-native-sdk/example/android/app/src/main/java/com/example/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.example;
2 |
3 | import com.facebook.react.ReactActivity;
4 |
5 | public class MainActivity extends ReactActivity {
6 |
7 | /**
8 | * Returns the name of the main component registered from JavaScript. This is used to schedule
9 | * rendering of the component.
10 | */
11 | @Override
12 | protected String getMainComponentName() {
13 | return "example";
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/packages/proton-react-native-sdk/example/android/app/src/main/java/com/example/MainApplication.java:
--------------------------------------------------------------------------------
1 | package com.example;
2 |
3 | import android.app.Application;
4 | import android.content.Context;
5 | import com.facebook.react.PackageList;
6 | import com.facebook.react.ReactApplication;
7 | import com.facebook.react.ReactInstanceManager;
8 | import com.facebook.react.ReactNativeHost;
9 | import com.facebook.react.ReactPackage;
10 | import com.facebook.soloader.SoLoader;
11 | import java.lang.reflect.InvocationTargetException;
12 | import java.util.List;
13 |
14 | public class MainApplication extends Application implements ReactApplication {
15 |
16 | private final ReactNativeHost mReactNativeHost =
17 | new ReactNativeHost(this) {
18 | @Override
19 | public boolean getUseDeveloperSupport() {
20 | return BuildConfig.DEBUG;
21 | }
22 |
23 | @Override
24 | protected List getPackages() {
25 | @SuppressWarnings("UnnecessaryLocalVariable")
26 | List packages = new PackageList(this).getPackages();
27 | // Packages that cannot be autolinked yet can be added manually here, for example:
28 | // packages.add(new MyReactNativePackage());
29 | return packages;
30 | }
31 |
32 | @Override
33 | protected String getJSMainModuleName() {
34 | return "index";
35 | }
36 | };
37 |
38 | @Override
39 | public ReactNativeHost getReactNativeHost() {
40 | return mReactNativeHost;
41 | }
42 |
43 | @Override
44 | public void onCreate() {
45 | super.onCreate();
46 | SoLoader.init(this, /* native exopackage */ false);
47 | initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
48 | }
49 |
50 | /**
51 | * Loads Flipper in React Native templates. Call this in the onCreate method with something like
52 | * initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
53 | *
54 | * @param context
55 | * @param reactInstanceManager
56 | */
57 | private static void initializeFlipper(
58 | Context context, ReactInstanceManager reactInstanceManager) {
59 | if (BuildConfig.DEBUG) {
60 | try {
61 | /*
62 | We use reflection here to pick up the class that initializes Flipper,
63 | since Flipper library is not available in release mode
64 | */
65 | Class> aClass = Class.forName("com.example.ReactNativeFlipper");
66 | aClass
67 | .getMethod("initializeFlipper", Context.class, ReactInstanceManager.class)
68 | .invoke(null, context, reactInstanceManager);
69 | } catch (ClassNotFoundException e) {
70 | e.printStackTrace();
71 | } catch (NoSuchMethodException e) {
72 | e.printStackTrace();
73 | } catch (IllegalAccessException e) {
74 | e.printStackTrace();
75 | } catch (InvocationTargetException e) {
76 | e.printStackTrace();
77 | }
78 | }
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/packages/proton-react-native-sdk/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/XPRNetwork/proton-web-sdk/8a4df507fd7eaeab9759515c092966acefd92c47/packages/proton-react-native-sdk/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/packages/proton-react-native-sdk/example/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/XPRNetwork/proton-web-sdk/8a4df507fd7eaeab9759515c092966acefd92c47/packages/proton-react-native-sdk/example/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/packages/proton-react-native-sdk/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/XPRNetwork/proton-web-sdk/8a4df507fd7eaeab9759515c092966acefd92c47/packages/proton-react-native-sdk/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/packages/proton-react-native-sdk/example/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/XPRNetwork/proton-web-sdk/8a4df507fd7eaeab9759515c092966acefd92c47/packages/proton-react-native-sdk/example/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/packages/proton-react-native-sdk/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/XPRNetwork/proton-web-sdk/8a4df507fd7eaeab9759515c092966acefd92c47/packages/proton-react-native-sdk/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/packages/proton-react-native-sdk/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/XPRNetwork/proton-web-sdk/8a4df507fd7eaeab9759515c092966acefd92c47/packages/proton-react-native-sdk/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/packages/proton-react-native-sdk/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/XPRNetwork/proton-web-sdk/8a4df507fd7eaeab9759515c092966acefd92c47/packages/proton-react-native-sdk/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/packages/proton-react-native-sdk/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/XPRNetwork/proton-web-sdk/8a4df507fd7eaeab9759515c092966acefd92c47/packages/proton-react-native-sdk/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/packages/proton-react-native-sdk/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/XPRNetwork/proton-web-sdk/8a4df507fd7eaeab9759515c092966acefd92c47/packages/proton-react-native-sdk/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/packages/proton-react-native-sdk/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/XPRNetwork/proton-web-sdk/8a4df507fd7eaeab9759515c092966acefd92c47/packages/proton-react-native-sdk/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/packages/proton-react-native-sdk/example/android/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | example
3 |
4 |
--------------------------------------------------------------------------------
/packages/proton-react-native-sdk/example/android/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/packages/proton-react-native-sdk/example/android/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | ext {
5 | buildToolsVersion = "29.0.3"
6 | minSdkVersion = 22
7 | compileSdkVersion = 30
8 | targetSdkVersion = 29
9 | ndkVersion = "20.1.5948944"
10 | }
11 | repositories {
12 | google()
13 | mavenCentral()
14 | }
15 | dependencies {
16 | classpath("com.android.tools.build:gradle:4.1.0")
17 | // NOTE: Do not place your application dependencies here; they belong
18 | // in the individual module build.gradle files
19 | }
20 | }
21 |
22 | allprojects {
23 | repositories {
24 | mavenLocal()
25 | maven {
26 | // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
27 | url("$rootDir/../node_modules/react-native/android")
28 | }
29 | maven {
30 | // Android JSC is installed from npm
31 | url("$rootDir/../node_modules/jsc-android/dist")
32 | }
33 |
34 | google()
35 | mavenCentral()
36 | maven { url 'https://www.jitpack.io' }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/packages/proton-react-native-sdk/example/android/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
19 |
20 | # AndroidX package structure to make it clearer which packages are bundled with the
21 | # Android operating system, and which are packaged with your app's APK
22 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
23 | android.useAndroidX=true
24 | # Automatically convert third-party libraries to use AndroidX
25 | android.enableJetifier=true
26 |
27 | # Version of flipper SDK to use with React Native
28 | FLIPPER_VERSION=0.75.1
29 |
--------------------------------------------------------------------------------
/packages/proton-react-native-sdk/example/android/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/XPRNetwork/proton-web-sdk/8a4df507fd7eaeab9759515c092966acefd92c47/packages/proton-react-native-sdk/example/android/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/packages/proton-react-native-sdk/example/android/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 |
--------------------------------------------------------------------------------
/packages/proton-react-native-sdk/example/android/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%" == "" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%" == "" set DIRNAME=.
29 | set APP_BASE_NAME=%~n0
30 | set APP_HOME=%DIRNAME%
31 |
32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
34 |
35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
37 |
38 | @rem Find java.exe
39 | if defined JAVA_HOME goto findJavaFromJavaHome
40 |
41 | set JAVA_EXE=java.exe
42 | %JAVA_EXE% -version >NUL 2>&1
43 | if "%ERRORLEVEL%" == "0" goto execute
44 |
45 | echo.
46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
47 | echo.
48 | echo Please set the JAVA_HOME variable in your environment to match the
49 | echo location of your Java installation.
50 |
51 | goto fail
52 |
53 | :findJavaFromJavaHome
54 | set JAVA_HOME=%JAVA_HOME:"=%
55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
56 |
57 | if exist "%JAVA_EXE%" goto execute
58 |
59 | echo.
60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
61 | echo.
62 | echo Please set the JAVA_HOME variable in your environment to match the
63 | echo location of your Java installation.
64 |
65 | goto fail
66 |
67 | :execute
68 | @rem Setup the command line
69 |
70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
71 |
72 |
73 | @rem Execute Gradle
74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
75 |
76 | :end
77 | @rem End local scope for the variables with windows NT shell
78 | if "%ERRORLEVEL%"=="0" goto mainEnd
79 |
80 | :fail
81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
82 | rem the _cmd.exe /c_ return code!
83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
84 | exit /b 1
85 |
86 | :mainEnd
87 | if "%OS%"=="Windows_NT" endlocal
88 |
89 | :omega
90 |
--------------------------------------------------------------------------------
/packages/proton-react-native-sdk/example/android/settings.gradle:
--------------------------------------------------------------------------------
1 | rootProject.name = 'example'
2 | apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
3 | include ':app'
4 |
--------------------------------------------------------------------------------
/packages/proton-react-native-sdk/example/app.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "example",
3 | "displayName": "example"
4 | }
--------------------------------------------------------------------------------
/packages/proton-react-native-sdk/example/babel.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | presets: ['module:metro-react-native-babel-preset'],
3 | };
4 |
--------------------------------------------------------------------------------
/packages/proton-react-native-sdk/example/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @format
3 | */
4 |
5 | import {AppRegistry} from 'react-native';
6 | import App from './App';
7 | import {name as appName} from './app.json';
8 | import './registerGlobals'
9 |
10 | AppRegistry.registerComponent(appName, () => App);
11 |
--------------------------------------------------------------------------------
/packages/proton-react-native-sdk/example/ios/File.swift:
--------------------------------------------------------------------------------
1 | //
2 | // File.swift
3 | // example
4 | //
5 | // Created by Syed Jafri on 2021-12-20.
6 | //
7 |
8 | import Foundation
9 |
--------------------------------------------------------------------------------
/packages/proton-react-native-sdk/example/ios/Gemfile:
--------------------------------------------------------------------------------
1 | source 'https://rubygems.org'
2 |
3 | gem 'cocoapods'
4 | gem 'cocoapods-user-defined-build-types'
5 |
--------------------------------------------------------------------------------
/packages/proton-react-native-sdk/example/ios/Gemfile.lock:
--------------------------------------------------------------------------------
1 | GEM
2 | remote: https://rubygems.org/
3 | specs:
4 | CFPropertyList (3.0.3)
5 | activesupport (5.2.6)
6 | concurrent-ruby (~> 1.0, >= 1.0.2)
7 | i18n (>= 0.7, < 2)
8 | minitest (~> 5.1)
9 | tzinfo (~> 1.1)
10 | addressable (2.8.0)
11 | public_suffix (>= 2.0.2, < 5.0)
12 | algoliasearch (1.27.5)
13 | httpclient (~> 2.8, >= 2.8.3)
14 | json (>= 1.5.1)
15 | atomos (0.1.3)
16 | claide (1.0.3)
17 | cocoapods (1.10.1)
18 | addressable (~> 2.6)
19 | claide (>= 1.0.2, < 2.0)
20 | cocoapods-core (= 1.10.1)
21 | cocoapods-deintegrate (>= 1.0.3, < 2.0)
22 | cocoapods-downloader (>= 1.4.0, < 2.0)
23 | cocoapods-plugins (>= 1.0.0, < 2.0)
24 | cocoapods-search (>= 1.0.0, < 2.0)
25 | cocoapods-trunk (>= 1.4.0, < 2.0)
26 | cocoapods-try (>= 1.1.0, < 2.0)
27 | colored2 (~> 3.1)
28 | escape (~> 0.0.4)
29 | fourflusher (>= 2.3.0, < 3.0)
30 | gh_inspector (~> 1.0)
31 | molinillo (~> 0.6.6)
32 | nap (~> 1.0)
33 | ruby-macho (~> 1.4)
34 | xcodeproj (>= 1.19.0, < 2.0)
35 | cocoapods-core (1.10.1)
36 | activesupport (> 5.0, < 6)
37 | addressable (~> 2.6)
38 | algoliasearch (~> 1.0)
39 | concurrent-ruby (~> 1.1)
40 | fuzzy_match (~> 2.0.4)
41 | nap (~> 1.0)
42 | netrc (~> 0.11)
43 | public_suffix
44 | typhoeus (~> 1.0)
45 | cocoapods-deintegrate (1.0.4)
46 | cocoapods-downloader (1.4.0)
47 | cocoapods-plugins (1.0.0)
48 | nap
49 | cocoapods-search (1.0.0)
50 | cocoapods-trunk (1.5.0)
51 | nap (>= 0.8, < 2.0)
52 | netrc (~> 0.11)
53 | cocoapods-try (1.2.0)
54 | cocoapods-user-defined-build-types (0.0.7)
55 | cocoapods (>= 1.5.0, < 2.0)
56 | colored2 (3.1.2)
57 | concurrent-ruby (1.1.9)
58 | escape (0.0.4)
59 | ethon (0.14.0)
60 | ffi (>= 1.15.0)
61 | ffi (1.15.3)
62 | fourflusher (2.3.1)
63 | fuzzy_match (2.0.4)
64 | gh_inspector (1.1.3)
65 | httpclient (2.8.3)
66 | i18n (1.8.10)
67 | concurrent-ruby (~> 1.0)
68 | json (2.5.1)
69 | minitest (5.14.4)
70 | molinillo (0.6.6)
71 | nanaimo (0.3.0)
72 | nap (1.1.0)
73 | netrc (0.11.0)
74 | public_suffix (4.0.6)
75 | rexml (3.2.5)
76 | ruby-macho (1.4.0)
77 | thread_safe (0.3.6)
78 | typhoeus (1.4.0)
79 | ethon (>= 0.9.0)
80 | tzinfo (1.2.9)
81 | thread_safe (~> 0.1)
82 | xcodeproj (1.20.0)
83 | CFPropertyList (>= 2.3.3, < 4.0)
84 | atomos (~> 0.1.3)
85 | claide (>= 1.0.2, < 2.0)
86 | colored2 (~> 3.1)
87 | nanaimo (~> 0.3.0)
88 | rexml (~> 3.2.4)
89 |
90 | PLATFORMS
91 | x86_64-darwin-19
92 |
93 | DEPENDENCIES
94 | cocoapods
95 | cocoapods-user-defined-build-types
96 |
97 | BUNDLED WITH
98 | 2.2.22
99 |
--------------------------------------------------------------------------------
/packages/proton-react-native-sdk/example/ios/Podfile:
--------------------------------------------------------------------------------
1 | require_relative '../node_modules/react-native/scripts/react_native_pods'
2 | require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
3 |
4 | platform :ios, '10.0'
5 |
6 | plugin 'cocoapods-user-defined-build-types'
7 | enable_user_defined_build_types!
8 |
9 | target 'example' do
10 | config = use_native_modules!
11 |
12 | use_react_native!(
13 | :path => config[:reactNativePath],
14 | # to enable hermes on iOS, change `false` to `true` and then install pods
15 | :hermes_enabled => false
16 | )
17 |
18 | target 'exampleTests' do
19 | inherit! :complete
20 | # Pods for testing
21 | end
22 |
23 | pod 'KeychainAccess', :build_type => :dynamic_framework
24 |
25 | # Enables Flipper.
26 | #
27 | # Note that if you have use_frameworks! enabled, Flipper will not work and
28 | # you should disable the next line.
29 | # use_flipper!()
30 |
31 | post_install do |installer|
32 | installer.pods_project.targets.each do |target|
33 | target.build_configurations.each do |config|
34 | config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '11.0'
35 | config.build_settings['EXCLUDED_ARCHS[sdk=iphonesimulator*]'] = 'arm64'
36 | end
37 | end
38 |
39 | # flipper_post_install(installer)
40 | react_native_post_install(installer)
41 | end
42 | end
--------------------------------------------------------------------------------
/packages/proton-react-native-sdk/example/ios/example-Bridging-Header.h:
--------------------------------------------------------------------------------
1 | //
2 | // Use this file to import your target's public headers that you would like to expose to Swift.
3 | //
4 |
5 |
--------------------------------------------------------------------------------
/packages/proton-react-native-sdk/example/ios/example.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/packages/proton-react-native-sdk/example/ios/example.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/packages/proton-react-native-sdk/example/ios/example/AppDelegate.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import
3 |
4 | @interface AppDelegate : UIResponder
5 |
6 | @property (nonatomic, strong) UIWindow *window;
7 |
8 | @end
9 |
--------------------------------------------------------------------------------
/packages/proton-react-native-sdk/example/ios/example/AppDelegate.m:
--------------------------------------------------------------------------------
1 | #import "AppDelegate.h"
2 |
3 | #import
4 | #import
5 | #import
6 |
7 | #ifdef FB_SONARKIT_ENABLED
8 | #import
9 | #import
10 | #import
11 | #import
12 | #import
13 | #import
14 |
15 | static void InitializeFlipper(UIApplication *application) {
16 | FlipperClient *client = [FlipperClient sharedClient];
17 | SKDescriptorMapper *layoutDescriptorMapper = [[SKDescriptorMapper alloc] initWithDefaults];
18 | [client addPlugin:[[FlipperKitLayoutPlugin alloc] initWithRootNode:application withDescriptorMapper:layoutDescriptorMapper]];
19 | [client addPlugin:[[FKUserDefaultsPlugin alloc] initWithSuiteName:nil]];
20 | [client addPlugin:[FlipperKitReactPlugin new]];
21 | [client addPlugin:[[FlipperKitNetworkPlugin alloc] initWithNetworkAdapter:[SKIOSNetworkAdapter new]]];
22 | [client start];
23 | }
24 | #endif
25 |
26 | @implementation AppDelegate
27 |
28 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
29 | {
30 | #ifdef FB_SONARKIT_ENABLED
31 | InitializeFlipper(application);
32 | #endif
33 |
34 | RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
35 | RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
36 | moduleName:@"example"
37 | initialProperties:nil];
38 |
39 | if (@available(iOS 13.0, *)) {
40 | rootView.backgroundColor = [UIColor systemBackgroundColor];
41 | } else {
42 | rootView.backgroundColor = [UIColor whiteColor];
43 | }
44 |
45 | self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
46 | UIViewController *rootViewController = [UIViewController new];
47 | rootViewController.view = rootView;
48 | self.window.rootViewController = rootViewController;
49 | [self.window makeKeyAndVisible];
50 | return YES;
51 | }
52 |
53 | - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
54 | {
55 | #if DEBUG
56 | return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
57 | #else
58 | return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
59 | #endif
60 | }
61 |
62 | @end
63 |
--------------------------------------------------------------------------------
/packages/proton-react-native-sdk/example/ios/example/Images.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "scale" : "2x",
6 | "size" : "20x20"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "scale" : "3x",
11 | "size" : "20x20"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "scale" : "2x",
16 | "size" : "29x29"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "scale" : "3x",
21 | "size" : "29x29"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "scale" : "2x",
26 | "size" : "40x40"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "scale" : "3x",
31 | "size" : "40x40"
32 | },
33 | {
34 | "idiom" : "iphone",
35 | "scale" : "2x",
36 | "size" : "60x60"
37 | },
38 | {
39 | "idiom" : "iphone",
40 | "scale" : "3x",
41 | "size" : "60x60"
42 | },
43 | {
44 | "idiom" : "ios-marketing",
45 | "scale" : "1x",
46 | "size" : "1024x1024"
47 | }
48 | ],
49 | "info" : {
50 | "author" : "xcode",
51 | "version" : 1
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/packages/proton-react-native-sdk/example/ios/example/Images.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/packages/proton-react-native-sdk/example/ios/example/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleDisplayName
8 | example
9 | CFBundleExecutable
10 | $(EXECUTABLE_NAME)
11 | CFBundleIdentifier
12 | $(PRODUCT_BUNDLE_IDENTIFIER)
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | $(PRODUCT_NAME)
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | 1.0
21 | CFBundleSignature
22 | ????
23 | CFBundleURLTypes
24 |
25 |
26 | CFBundleURLSchemes
27 |
28 | example
29 |
30 |
31 |
32 | CFBundleVersion
33 | 1
34 | LSRequiresIPhoneOS
35 |
36 | NSAppTransportSecurity
37 |
38 | NSExceptionDomains
39 |
40 | localhost
41 |
42 | NSExceptionAllowsInsecureHTTPLoads
43 |
44 |
45 |
46 |
47 | NSLocationWhenInUseUsageDescription
48 |
49 | UILaunchStoryboardName
50 | LaunchScreen
51 | UIRequiredDeviceCapabilities
52 |
53 | armv7
54 |
55 | UISupportedInterfaceOrientations
56 |
57 | UIInterfaceOrientationPortrait
58 | UIInterfaceOrientationLandscapeLeft
59 | UIInterfaceOrientationLandscapeRight
60 |
61 | UIViewControllerBasedStatusBarAppearance
62 |
63 |
64 |
65 |
--------------------------------------------------------------------------------
/packages/proton-react-native-sdk/example/ios/example/main.m:
--------------------------------------------------------------------------------
1 | #import
2 |
3 | #import "AppDelegate.h"
4 |
5 | int main(int argc, char * argv[]) {
6 | @autoreleasepool {
7 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/packages/proton-react-native-sdk/example/ios/exampleTests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 |
24 |
25 |
--------------------------------------------------------------------------------
/packages/proton-react-native-sdk/example/ios/exampleTests/exampleTests.m:
--------------------------------------------------------------------------------
1 | #import
2 | #import
3 |
4 | #import
5 | #import
6 |
7 | #define TIMEOUT_SECONDS 600
8 | #define TEXT_TO_LOOK_FOR @"Welcome to React"
9 |
10 | @interface exampleTests : XCTestCase
11 |
12 | @end
13 |
14 | @implementation exampleTests
15 |
16 | - (BOOL)findSubviewInView:(UIView *)view matching:(BOOL(^)(UIView *view))test
17 | {
18 | if (test(view)) {
19 | return YES;
20 | }
21 | for (UIView *subview in [view subviews]) {
22 | if ([self findSubviewInView:subview matching:test]) {
23 | return YES;
24 | }
25 | }
26 | return NO;
27 | }
28 |
29 | - (void)testRendersWelcomeScreen
30 | {
31 | UIViewController *vc = [[[RCTSharedApplication() delegate] window] rootViewController];
32 | NSDate *date = [NSDate dateWithTimeIntervalSinceNow:TIMEOUT_SECONDS];
33 | BOOL foundElement = NO;
34 |
35 | __block NSString *redboxError = nil;
36 | #ifdef DEBUG
37 | RCTSetLogFunction(^(RCTLogLevel level, RCTLogSource source, NSString *fileName, NSNumber *lineNumber, NSString *message) {
38 | if (level >= RCTLogLevelError) {
39 | redboxError = message;
40 | }
41 | });
42 | #endif
43 |
44 | while ([date timeIntervalSinceNow] > 0 && !foundElement && !redboxError) {
45 | [[NSRunLoop mainRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
46 | [[NSRunLoop mainRunLoop] runMode:NSRunLoopCommonModes beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
47 |
48 | foundElement = [self findSubviewInView:vc.view matching:^BOOL(UIView *view) {
49 | if ([view.accessibilityLabel isEqualToString:TEXT_TO_LOOK_FOR]) {
50 | return YES;
51 | }
52 | return NO;
53 | }];
54 | }
55 |
56 | #ifdef DEBUG
57 | RCTSetLogFunction(RCTDefaultLogFunction);
58 | #endif
59 |
60 | XCTAssertNil(redboxError, @"RedBox error: %@", redboxError);
61 | XCTAssertTrue(foundElement, @"Couldn't find element with text '%@' in %d seconds", TEXT_TO_LOOK_FOR, TIMEOUT_SECONDS);
62 | }
63 |
64 |
65 | @end
66 |
--------------------------------------------------------------------------------
/packages/proton-react-native-sdk/example/metro.config.js:
--------------------------------------------------------------------------------
1 | // metro.config.js
2 | //
3 | // with multiple workarounds for this issue with symlinks:
4 | // https://github.com/facebook/metro/issues/1
5 | //
6 | // with thanks to @johnryan ()
7 | // for the pointers to multiple workaround solutions here:
8 | // https://github.com/facebook/metro/issues/1#issuecomment-541642857
9 | //
10 | // see also this discussion:
11 | // https://github.com/brodybits/create-react-native-module/issues/232
12 |
13 | const path = require('path')
14 |
15 | module.exports = {
16 | // workaround for an issue with symlinks encountered starting with
17 | // metro@0.55 / React Native 0.61
18 | // (not needed with React Native 0.60 / metro@0.54)
19 | resolver: {
20 | extraNodeModules: new Proxy(
21 | {},
22 | { get: (_, name) => path.resolve('.', 'node_modules', name) }
23 | )
24 | },
25 |
26 | transformer: {
27 | getTransformOptions: async () => ({
28 | transform: {
29 | // this defeats the RCTDeviceEventEmitter is not a registered callable module
30 | inlineRequires: true,
31 | },
32 | }),
33 | },
34 |
35 | // quick workaround for another issue with symlinks
36 | watchFolders: [path.resolve('.'), path.resolve('..')]
37 | }
38 |
--------------------------------------------------------------------------------
/packages/proton-react-native-sdk/example/registerGlobals.js:
--------------------------------------------------------------------------------
1 | import { TextDecoder, TextEncoder } from 'text-encoding-shim'
2 |
3 | global.TextDecoder = TextDecoder;
4 | global.TextEncoder = TextEncoder
5 |
--------------------------------------------------------------------------------
/packages/proton-react-native-sdk/example/shim.js:
--------------------------------------------------------------------------------
1 | if (typeof __dirname === 'undefined') global.__dirname = '/'
2 | if (typeof __filename === 'undefined') global.__filename = ''
3 | if (typeof process === 'undefined') {
4 | global.process = require('process')
5 | } else {
6 | const bProcess = require('process')
7 | for (var p in bProcess) {
8 | if (!(p in process)) {
9 | process[p] = bProcess[p]
10 | }
11 | }
12 | }
13 |
14 | process.browser = false
15 | if (typeof Buffer === 'undefined') global.Buffer = require('buffer').Buffer
16 |
17 | // global.location = global.location || { port: 80 }
18 | const isDev = typeof __DEV__ === 'boolean' && __DEV__
19 | process.env['NODE_ENV'] = isDev ? 'development' : 'production'
20 | if (typeof localStorage !== 'undefined') {
21 | localStorage.debug = isDev ? '*' : ''
22 | }
23 |
24 | // If using the crypto shim, uncomment the following line to ensure
25 | // crypto is loaded first, so it can populate global.crypto
26 | // require('crypto')
27 |
--------------------------------------------------------------------------------
/packages/proton-react-native-sdk/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@proton/react-native-sdk",
3 | "author": "Metallicus",
4 | "module": "dist/index.js",
5 | "unpkg": "dist/bundle.js",
6 | "types": "dist/index.d.ts",
7 | "source": "src/index.ts",
8 | "version": "4.2.18",
9 | "license": "MIT",
10 | "main": "dist/index.js",
11 | "typings": "dist/index.d.ts",
12 | "files": [
13 | "dist",
14 | "src"
15 | ],
16 | "engines": {
17 | "node": ">=10"
18 | },
19 | "scripts": {
20 | "watch": "tsdx watch --verbose --noClean",
21 | "build": "tsdx build",
22 | "lint": "tsdx lint",
23 | "prepare": "tsdx build",
24 | "size": "size-limit",
25 | "analyze": "size-limit --why"
26 | },
27 | "dependencies": {
28 | "@proton/js": "^28.0.0",
29 | "@proton/link": "^4.2.18",
30 | "@proton/signing-request": "^2.2.2-9",
31 | "@react-native-async-storage/async-storage": "^1.17.3",
32 | "buffer": "^6.0.3",
33 | "react-native": "^0.63.4",
34 | "react-native-get-random-values": "^1.7.1",
35 | "text-encoding-shim": "^1.0.5"
36 | },
37 | "husky": {
38 | "hooks": {
39 | "pre-commit": "tsdx lint"
40 | }
41 | },
42 | "prettier": {
43 | "printWidth": 80,
44 | "semi": true,
45 | "singleQuote": true,
46 | "trailingComma": "es5"
47 | },
48 | "gitHead": "e15e7e40cc610b4a7ceeaee75909ff6389d8f1e5",
49 | "devDependencies": {
50 | "@types/react-native": "^0.63.43"
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/packages/proton-react-native-sdk/src/index.ts:
--------------------------------------------------------------------------------
1 | import './registerGlobals'
2 | import ReactNativeTransport, { ReactNativeTransportOptions } from './transport'
3 |
4 | import ProtonLink, {
5 | LinkStorage,
6 | LinkOptions,
7 | LinkSession,
8 | PermissionLevel,
9 | } from '@proton/link'
10 | import { JsonRpc } from '@proton/js'
11 |
12 | import Storage from './storage'
13 |
14 | type PartialBy = Omit & Partial>
15 |
16 | interface ConnectWalletArgs {
17 | linkOptions: PartialBy & {
18 | endpoints: string[]
19 | rpc?: JsonRpc
20 | storage?: LinkStorage
21 | storagePrefix?: string
22 | restoreSession?: boolean
23 | }
24 | transportOptions: ReactNativeTransportOptions
25 | }
26 |
27 | const ConnectWallet = async ({
28 | linkOptions,
29 | transportOptions,
30 | }: ConnectWalletArgs) => {
31 | // Add RPC
32 | linkOptions.client = linkOptions.rpc || new JsonRpc(linkOptions.endpoints)
33 |
34 | // Add chain ID if not present
35 | if (!linkOptions.chainId) {
36 | const info = await linkOptions.client!.get_info()
37 | linkOptions.chainId = info.chain_id
38 | }
39 |
40 | // Add storage if not present
41 | if (!linkOptions.storage) {
42 | linkOptions.storage = new Storage(
43 | linkOptions.storagePrefix || 'proton-storage'
44 | )
45 | }
46 |
47 | // Stop restore session if no saved data
48 | if (linkOptions.restoreSession) {
49 | const savedUserAuth = await linkOptions.storage.read('user-auth')
50 | if (!savedUserAuth) {
51 | // clean storage to remove unexpected side effects if session restore fails
52 | linkOptions.storage.remove('user-auth')
53 | return { link: null, session: null }
54 | }
55 | }
56 |
57 | let session, link, loginResult
58 |
59 | if (
60 | linkOptions.chainId ===
61 | '71ee83bcf52142d61019d95f9cc5427ba6a0d7ff8accd9e2088ae2abeaf3d3dd'
62 | ) {
63 | linkOptions.scheme = 'proton-dev'
64 | } else {
65 | linkOptions.scheme = 'proton'
66 | }
67 |
68 | const transport = new ReactNativeTransport({
69 | ...transportOptions,
70 | })
71 |
72 | // Create link
73 | const options = {
74 | ...linkOptions,
75 | transport,
76 | walletType: 'proton',
77 | chains: []
78 | }
79 |
80 | link = new ProtonLink(options)
81 |
82 | // Get session based on login or restore session
83 | if (!linkOptions.restoreSession) {
84 | loginResult = await link.login(transportOptions.requestAccount || '')
85 | session = loginResult.session
86 | linkOptions.storage.write('user-auth', JSON.stringify(loginResult.session.auth))
87 | } else {
88 | const stringifiedUserAuth = await linkOptions.storage.read('user-auth')
89 | const parsedUserAuth = stringifiedUserAuth
90 | ? JSON.parse(stringifiedUserAuth)
91 | : {}
92 | const savedUserAuth: PermissionLevel = Object.keys(parsedUserAuth).length > 0 ? parsedUserAuth : null
93 | if (savedUserAuth) {
94 | session = await link.restoreSession(
95 | transportOptions.requestAccount || '',
96 | savedUserAuth
97 | )
98 | }
99 | }
100 |
101 | return { link, session, loginResult }
102 | }
103 |
104 | export { ProtonLink, LinkSession }
105 | export default ConnectWallet
106 |
--------------------------------------------------------------------------------
/packages/proton-react-native-sdk/src/registerGlobals.ts:
--------------------------------------------------------------------------------
1 | import 'react-native-get-random-values'
2 | import { Buffer } from 'buffer'
3 | import { TextDecoder, TextEncoder } from 'text-encoding-shim'
4 |
5 | global.Buffer = Buffer
6 | global.TextDecoder = TextDecoder;
7 | (global as any).TextEncoder = TextEncoder
8 |
9 | if (typeof global.crypto !== 'object') {
10 | (global as any).crypto = {}
11 | }
--------------------------------------------------------------------------------
/packages/proton-react-native-sdk/src/storage.ts:
--------------------------------------------------------------------------------
1 | import AsyncStorage from '@react-native-async-storage/async-storage';
2 |
3 | import { LinkStorage } from '@proton/link';
4 |
5 | class Storage implements LinkStorage {
6 | constructor(readonly keyPrefix: string) {}
7 | async write(key: string, data: string): Promise {
8 | AsyncStorage.setItem(this.storageKey(key), data);
9 | }
10 |
11 | async read(key: string): Promise {
12 | return AsyncStorage.getItem(this.storageKey(key));
13 | }
14 |
15 | async remove(key: string): Promise {
16 | AsyncStorage.removeItem(this.storageKey(key));
17 | }
18 |
19 | storageKey(key: string) {
20 | return `${this.keyPrefix}-${key}`;
21 | }
22 | }
23 |
24 | export default Storage;
25 |
--------------------------------------------------------------------------------
/packages/proton-react-native-sdk/src/transport.ts:
--------------------------------------------------------------------------------
1 | import { LinkSession, LinkTransport } from '@proton/link';
2 | import { SigningRequest } from '@proton/signing-request';
3 | import { Linking } from 'react-native';
4 |
5 | export interface ReactNativeTransportOptions {
6 | /** Requesting account of the dapp */
7 | requestAccount: string;
8 |
9 | /** Return url to the original app */
10 | getReturnUrl(): string;
11 | }
12 |
13 | export default class ReactNativeTransport implements LinkTransport {
14 | private requestAccount: string;
15 | private getReturnUrl: () => string;
16 |
17 | constructor(public readonly options: ReactNativeTransportOptions) {
18 | this.requestAccount = options.requestAccount;
19 | this.getReturnUrl = options.getReturnUrl;
20 | }
21 |
22 | public onRequest(
23 | request: SigningRequest,
24 | _cancel: (reason: string | Error) => void
25 | ) {
26 | const deviceRequest = request.clone();
27 | deviceRequest.setInfoKey('same_device', true);
28 | deviceRequest.setInfoKey('return_path', this.getReturnUrl());
29 |
30 | if (this.requestAccount.length > 0) {
31 | request.setInfoKey('req_account', this.requestAccount);
32 | deviceRequest.setInfoKey('req_account', this.requestAccount);
33 | }
34 |
35 | const sameDeviceUri = deviceRequest.encode(true, false);
36 | Linking.openURL(sameDeviceUri);
37 | }
38 |
39 | public onSessionRequest(
40 | _session: LinkSession,
41 | request: SigningRequest,
42 | _cancel: (reason: string | Error) => void
43 | ) {
44 | request.setInfoKey('return_path', this.getReturnUrl());
45 |
46 | const scheme = request.getScheme();
47 | Linking.openURL(`${scheme}://link`);
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/packages/proton-react-native-sdk/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.json",
3 | // see https://www.typescriptlang.org/tsconfig to better understand tsconfigs
4 | "include": ["src", "types"],
5 | "compilerOptions": {
6 | "module": "esnext",
7 | "lib": ["dom", "esnext"],
8 | "importHelpers": true,
9 | // output .d.ts declaration files for consumers
10 | "declaration": true,
11 | // output .js.map sourcemap files for consumers
12 | "sourceMap": true,
13 | // match output dir to input dir. e.g. dist/index instead of dist/src/index
14 | "rootDir": "./src",
15 | "declarationDir": "./dist/types",
16 | // stricter type-checking for stronger correctness. Recommended by TS
17 | "strict": true,
18 | // linter checks for common issues
19 | "noImplicitReturns": true,
20 | "noFallthroughCasesInSwitch": true,
21 | // noUnused* overlap with @typescript-eslint/no-unused-vars, can disable if duplicative
22 | "noUnusedLocals": true,
23 | "noUnusedParameters": true,
24 | // use Node's module resolution algorithm, instead of the legacy TS one
25 | "moduleResolution": "node",
26 | // transpile JSX to React.createElement
27 | "jsx": "react",
28 | // interop between ESM and CJS modules. Recommended by TS
29 | "esModuleInterop": true,
30 | // significant perf increase by skipping checking .d.ts files, particularly those in node_modules. Recommended by TS
31 | "skipLibCheck": true,
32 | // error out if import and file system have a casing mismatch. Recommended by TS
33 | "forceConsistentCasingInFileNames": true,
34 | // `tsdx build` ignores this option, but it is commonly used when type-checking separately with `tsc`
35 | "noEmit": true,
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/packages/proton-signing-request/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | indent_style = space
5 | indent_size = 4
6 | end_of_line = lf
7 | charset = utf-8
8 | trim_trailing_whitespace = true
9 | insert_final_newline = true
10 |
11 | [*.md]
12 | trim_trailing_whitespace = false
13 |
--------------------------------------------------------------------------------
/packages/proton-signing-request/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | "root": true,
3 | "parser": "@typescript-eslint/parser",
4 | "plugins": ["@typescript-eslint"],
5 | "ignorePatterns": ["lib/*", "node_modules/**"],
6 | "extends": [
7 | "eslint:recommended",
8 | "plugin:prettier/recommended",
9 | "plugin:@typescript-eslint/eslint-recommended",
10 | "plugin:@typescript-eslint/recommended"
11 | ],
12 | "rules": {
13 | "prettier/prettier": "warn",
14 | "no-console": "warn",
15 | "sort-imports": [
16 | "warn",
17 | {
18 | "ignoreCase": true,
19 | "ignoreDeclarationSort": true
20 | }
21 | ],
22 | "@typescript-eslint/explicit-module-boundary-types": "off",
23 | "@typescript-eslint/no-explicit-any": "off",
24 | "@typescript-eslint/no-namespace": "off",
25 | "@typescript-eslint/no-non-null-assertion": "off",
26 | "@typescript-eslint/no-empty-function": "warn",
27 | "no-inner-declarations": "off",
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/packages/proton-signing-request/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules/
2 | lib/
3 | coverage/
4 | .nyc_output/
5 |
--------------------------------------------------------------------------------
/packages/proton-signing-request/.prettierrc:
--------------------------------------------------------------------------------
1 | arrowParens: "always"
2 | bracketSpacing: false
3 | endOfLine: "lf"
4 | printWidth: 100
5 | semi: false
6 | singleQuote: true
7 | tabWidth: 4
8 | trailingComma: "es5"
9 |
--------------------------------------------------------------------------------
/packages/proton-signing-request/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright © 2021 Greymass Inc.
2 |
3 | Permission is hereby granted, free of charge, to any person
4 | obtaining a copy of this software and associated documentation
5 | files (the “Software”), to deal in the Software without
6 | restriction, including without limitation the rights to use,
7 | copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | copies of the Software, and to permit persons to whom the
9 | Software is furnished to do so, subject to the following
10 | conditions:
11 |
12 | The above copyright notice and this permission notice shall be
13 | included in all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 | OTHER DEALINGS IN THE SOFTWARE.
23 |
24 | YOU ACKNOWLEDGE THAT THIS SOFTWARE IS NOT DESIGNED, LICENSED OR
25 | INTENDED FOR USE IN THE DESIGN, CONSTRUCTION, OPERATION OR
26 | MAINTENANCE OF ANY MILITARY FACILITY.
27 |
--------------------------------------------------------------------------------
/packages/proton-signing-request/Makefile:
--------------------------------------------------------------------------------
1 | SRC_FILES := $(shell find src -name '*.ts')
2 | BIN := ./node_modules/.bin
3 |
4 | lib: ${SRC_FILES} package.json tsconfig.json node_modules rollup.config.js
5 | @${BIN}/rollup -c && touch lib
6 |
7 | .PHONY: test
8 | test: node_modules
9 | @TS_NODE_PROJECT='./test/tsconfig.json' ${BIN}/mocha -r ts-node/register --extension ts test/*.ts --grep '$(grep)'
10 |
11 | .PHONY: coverage
12 | coverage: node_modules
13 | @TS_NODE_PROJECT='./test/tsconfig.json' ${BIN}/nyc --reporter=html ${BIN}/mocha -r ts-node/register --extension ts test/*.ts -R nyan && open coverage/index.html
14 |
15 | .PHONY: lint
16 | lint: node_modules
17 | @${BIN}/eslint src --ext .ts --fix
18 |
19 | .PHONY: ci-test
20 | ci-test: node_modules
21 | @TS_NODE_PROJECT='./test/tsconfig.json' ${BIN}/nyc --reporter=text ${BIN}/mocha -r ts-node/register --extension ts test/*.ts -R list
22 |
23 | .PHONY: ci-lint
24 | ci-lint: node_modules
25 | @${BIN}/eslint src --ext .ts --max-warnings 0 --format unix && echo "Ok"
26 |
27 | node_modules:
28 | yarn install --non-interactive --frozen-lockfile --ignore-scripts
29 |
30 | .PHONY: publish
31 | publish: | distclean node_modules
32 | @git diff-index --quiet HEAD || (echo "Uncommitted changes, please commit first" && exit 1)
33 | @git fetch origin && git diff origin/master --quiet || (echo "Changes not pushed to origin, please push first" && exit 1)
34 | @yarn config set version-tag-prefix "" && yarn config set version-git-message "Version %s"
35 | @yarn publish && git push && git push --tags
36 |
37 | .PHONY: clean
38 | clean:
39 | rm -rf lib/ coverage/
40 |
41 | .PHONY: distclean
42 | distclean: clean
43 | rm -rf node_modules/
44 |
--------------------------------------------------------------------------------
/packages/proton-signing-request/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@proton/signing-request",
3 | "version": "4.2.7",
4 | "description": "Proton Signing Request (ESR / EEP-7) encoder and decoder",
5 | "homepage": "https://github.com/ProtonProtocol/proton-signing-request",
6 | "license": "MIT",
7 | "main": "lib/esr.js",
8 | "module": "lib/esr.m.js",
9 | "unpkg": "lib/proton-signing-request.bundle.js",
10 | "types": "lib/esr.d.ts",
11 | "sideEffects": false,
12 | "files": [
13 | "src/*",
14 | "lib/*"
15 | ],
16 | "scripts": {
17 | "watch": "rollup -c -w",
18 | "prepare": "make"
19 | },
20 | "dependencies": {
21 | "@greymass/eosio": "^0.6.1"
22 | },
23 | "devDependencies": {
24 | "@babel/plugin-proposal-class-properties": "^7.18.6",
25 | "@babel/plugin-proposal-decorators": "^7.17.2",
26 | "@babel/preset-env": "^7.16.11",
27 | "@babel/preset-typescript": "^7.16.7",
28 | "@rollup/plugin-babel": "^5.3.0",
29 | "@rollup/plugin-commonjs": "^21.0.1",
30 | "@rollup/plugin-json": "^4.1.0",
31 | "@rollup/plugin-node-resolve": "^13.1.3",
32 | "@rollup/plugin-replace": "^3.0.1",
33 | "@rollup/plugin-typescript": "^8.1.1",
34 | "@types/bn.js": "^5.1.0",
35 | "@types/mocha": "^8.0.4",
36 | "@types/node": "^14.14.9",
37 | "@typescript-eslint/eslint-plugin": "^4.9.0",
38 | "@typescript-eslint/parser": "^4.9.0",
39 | "core-js": "^3.21.0",
40 | "eslint": "^7.15.0",
41 | "eslint-config-prettier": "^8.1.0",
42 | "eslint-plugin-prettier": "^3.2.0",
43 | "mocha": "^8.0.1",
44 | "node-fetch": "^2.6.0",
45 | "nyc": "^15.1.0",
46 | "prettier": "^2.2.1",
47 | "rollup": "^2.38.1",
48 | "rollup-plugin-dts": "^3.0.1",
49 | "rollup-plugin-polyfill-node": "^0.8.0",
50 | "rollup-plugin-terser": "^7.0.2",
51 | "ts-node": "^10.0.0",
52 | "tslib": "^2.4.0",
53 | "typescript": "^4.3.2"
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/packages/proton-signing-request/src/base64u.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Base64u - URL-Safe Base64 variant no padding.
3 | * Based on https://gist.github.com/jonleighton/958841
4 | */
5 |
6 | const baseCharset = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
7 | const lookup = new Uint8Array(256)
8 | for (let i = 0; i < 62; i++) {
9 | lookup[baseCharset.charCodeAt(i)] = i
10 | }
11 | // support both urlsafe and standard base64
12 | lookup[43] = lookup[45] = 62
13 | lookup[47] = lookup[95] = 63
14 |
15 | export function encode(data: Uint8Array, urlSafe = true): string {
16 | const byteLength = data.byteLength
17 | const byteRemainder = byteLength % 3
18 | const mainLength = byteLength - byteRemainder
19 | const charset = baseCharset + (urlSafe ? '-_' : '+/')
20 | const parts: string[] = []
21 |
22 | let a: number
23 | let b: number
24 | let c: number
25 | let d: number
26 | let chunk: number
27 |
28 | // Main loop deals with bytes in chunks of 3
29 | for (let i = 0; i < mainLength; i += 3) {
30 | // Combine the three bytes into a single integer
31 | chunk = (data[i] << 16) | (data[i + 1] << 8) | data[i + 2]
32 |
33 | // Use bitmasks to extract 6-bit segments from the triplet
34 | a = (chunk & 16515072) >> 18 // 16515072 = (2^6 - 1) << 18
35 | b = (chunk & 258048) >> 12 // 258048 = (2^6 - 1) << 12
36 | c = (chunk & 4032) >> 6 // 4032 = (2^6 - 1) << 6
37 | d = chunk & 63 // 63 = 2^6 - 1
38 |
39 | // Convert the raw binary segments to the appropriate ASCII encoding
40 | parts.push(charset[a] + charset[b] + charset[c] + charset[d])
41 | }
42 |
43 | // Deal with the remaining bytes
44 | if (byteRemainder === 1) {
45 | chunk = data[mainLength]
46 |
47 | a = (chunk & 252) >> 2 // 252 = (2^6 - 1) << 2
48 |
49 | // Set the 4 least significant bits to zero
50 | b = (chunk & 3) << 4 // 3 = 2^2 - 1
51 |
52 | parts.push(charset[a] + charset[b])
53 | } else if (byteRemainder === 2) {
54 | chunk = (data[mainLength] << 8) | data[mainLength + 1]
55 |
56 | a = (chunk & 64512) >> 10 // 64512 = (2^6 - 1) << 10
57 | b = (chunk & 1008) >> 4 // 1008 = (2^6 - 1) << 4
58 |
59 | // Set the 2 least significant bits to zero
60 | c = (chunk & 15) << 2 // 15 = 2^4 - 1
61 |
62 | parts.push(charset[a] + charset[b] + charset[c])
63 | }
64 |
65 | return parts.join('')
66 | }
67 |
68 | export function decode(input: string): Uint8Array {
69 | const byteLength = input.length * 0.75
70 | const data = new Uint8Array(byteLength)
71 |
72 | let a: number
73 | let b: number
74 | let c: number
75 | let d: number
76 | let p = 0
77 |
78 | for (let i = 0; i < input.length; i += 4) {
79 | a = lookup[input.charCodeAt(i)]
80 | b = lookup[input.charCodeAt(i + 1)]
81 | c = lookup[input.charCodeAt(i + 2)]
82 | d = lookup[input.charCodeAt(i + 3)]
83 |
84 | data[p++] = (a << 2) | (b >> 4)
85 | data[p++] = ((b & 15) << 4) | (c >> 2)
86 | data[p++] = ((c & 3) << 6) | (d & 63)
87 | }
88 |
89 | return data
90 | }
91 |
--------------------------------------------------------------------------------
/packages/proton-signing-request/src/index.ts:
--------------------------------------------------------------------------------
1 | export * from './signing-request'
2 | export * from './abi'
3 | export * from './chain-id'
4 | export * from './identity-proof'
5 | export * as Base64u from './base64u'
6 |
--------------------------------------------------------------------------------
/packages/proton-signing-request/test/misc.ts:
--------------------------------------------------------------------------------
1 | import {strict as assert} from 'assert'
2 | import 'mocha'
3 | import {ChainId, ChainIdVariant, ChainName, RequestFlags} from '../src'
4 |
5 | describe('misc', function () {
6 | it('should create chain id', function () {
7 | const id = ChainId.from(1)
8 | assert.equal(
9 | id.equals('aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906'),
10 | true
11 | )
12 | assert.equal(id.chainVariant.chainId.chainName, ChainName.EOS)
13 | const id2 = ChainId.from('beefbeef06b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906')
14 | assert.equal(id2.chainName, ChainName.UNKNOWN)
15 | assert.equal(id2.chainVariant.variantName, 'chain_id')
16 | assert.equal(id2.chainVariant.chainId.equals(id2), true)
17 | assert.throws(() => {
18 | ChainId.from(99)
19 | })
20 | assert.throws(() => {
21 | ChainIdVariant.from(['chain_alias', 0]).chainId
22 | })
23 | })
24 | it('should set request flags', function () {
25 | const flags = RequestFlags.from(0)
26 | assert.equal(flags.background, false)
27 | assert.equal(flags.broadcast, false)
28 | flags.background = true
29 | assert.equal(flags.background, true)
30 | assert.equal(flags.broadcast, false)
31 | assert.equal(Number(flags), 2)
32 | flags.broadcast = true
33 | assert.equal(flags.background, true)
34 | assert.equal(flags.broadcast, true)
35 | assert.equal(Number(flags), 3)
36 | flags.background = false
37 | assert.equal(flags.background, false)
38 | assert.equal(flags.broadcast, true)
39 | assert.equal(Number(flags), 1)
40 | flags.broadcast = false
41 | assert.equal(flags.background, false)
42 | assert.equal(flags.broadcast, false)
43 | assert.equal(Number(flags), 0)
44 | })
45 | })
46 |
--------------------------------------------------------------------------------
/packages/proton-signing-request/test/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "isolatedModules": false,
5 | "module": "commonjs",
6 | "target": "es2015"
7 | },
8 | "include": ["./**/*.ts"]
9 | }
10 |
--------------------------------------------------------------------------------
/packages/proton-signing-request/test/utils/mock-abi-provider.ts:
--------------------------------------------------------------------------------
1 | import {readdirSync as readdir, readFileSync as readfile} from 'fs'
2 | import {join as joinPath} from 'path'
3 | import {AbiProvider} from '../../src'
4 | import {Name} from '@greymass/eosio'
5 |
6 | // To add an ABI for testing run (in project root):
7 | // CONTRACT=eosio.token; cleos -u https://eos.greymass.com get abi $CONTRACT > test/abis/$CONTRACT.json
8 |
9 | export class MockAbiProvider implements AbiProvider {
10 | constructor(public readonly abis: Map) {}
11 |
12 | public async getAbi(account: Name) {
13 | const abi = this.abis.get(account.toString())
14 | if (!abi) {
15 | throw new Error(`No ABI for: ${account}`)
16 | }
17 | return abi
18 | }
19 | }
20 |
21 | function createTestProvider() {
22 | const dir = joinPath(__dirname, '../abis')
23 | const abis = new Map()
24 | readdir(dir).forEach((name) => {
25 | abis.set(name.slice(0, -5), JSON.parse(readfile(joinPath(dir, name)).toString('utf8')))
26 | })
27 | return new MockAbiProvider(abis)
28 | }
29 |
30 | export default createTestProvider()
31 |
--------------------------------------------------------------------------------
/packages/proton-signing-request/test/utils/node-zlib-provider.ts:
--------------------------------------------------------------------------------
1 | import {deflateRawSync, inflateRawSync} from 'zlib'
2 | import {ZlibProvider} from '../../src'
3 |
4 | export default {
5 | deflateRaw: (data) => {
6 | return new Uint8Array(deflateRawSync(Buffer.from(data)))
7 | },
8 | inflateRaw: (data) => {
9 | return new Uint8Array(inflateRawSync(Buffer.from(data)))
10 | },
11 | } as ZlibProvider
12 |
--------------------------------------------------------------------------------
/packages/proton-signing-request/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.json",
3 | "compilerOptions": {
4 | "downlevelIteration": true,
5 | "esModuleInterop": true,
6 | "experimentalDecorators": true,
7 | "importHelpers": true,
8 | "isolatedModules": true,
9 | "lib": ["dom", "es2020"],
10 | "module": "es2020",
11 | "moduleResolution": "node",
12 | "noImplicitAny": false,
13 | "useDefineForClassFields": false,
14 | "sourceMap": true,
15 | "strict": true,
16 | "target": "es2020",
17 | "declarationDir": "./dist/types"
18 | },
19 | "include": ["src/**/*"]
20 | }
21 |
--------------------------------------------------------------------------------
/packages/proton-web-sdk/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | indent_style = space
5 | indent_size = 2
6 | end_of_line = lf
7 | charset = utf-8
8 | trim_trailing_whitespace = true
9 | insert_final_newline = true
10 |
11 | [*.md]
12 | trim_trailing_whitespace = false
13 |
--------------------------------------------------------------------------------
/packages/proton-web-sdk/.eslintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | "env": {
3 | "browser": true,
4 | "es6": true
5 | },
6 | "extends": [
7 | "eslint:recommended",
8 | "plugin:@typescript-eslint/eslint-recommended"
9 | ],
10 | "globals": {
11 | "Atomics": "readonly",
12 | "SharedArrayBuffer": "readonly"
13 | },
14 | "parserOptions": {
15 | "ecmaVersion": 2018,
16 | "parser": "@typescript-eslint/parser",
17 | "sourceType": "module"
18 | },
19 | "plugins": [
20 | "@typescript-eslint"
21 | ],
22 | "rules": {
23 | "indent": [
24 | "error",
25 | 4
26 | ],
27 | "linebreak-style": [
28 | "error",
29 | "unix"
30 | ],
31 | "quotes": [
32 | "error",
33 | "double"
34 | ],
35 | "semi": [
36 | "error",
37 | "never"
38 | ]
39 | }
40 | }
--------------------------------------------------------------------------------
/packages/proton-web-sdk/.gitignore:
--------------------------------------------------------------------------------
1 | *.log
2 | .DS_Store
3 | node_modules
4 | dist
5 |
--------------------------------------------------------------------------------
/packages/proton-web-sdk/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020-2023 Metallicus
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
--------------------------------------------------------------------------------
/packages/proton-web-sdk/Makefile:
--------------------------------------------------------------------------------
1 | SRC_FILES := $(shell find src -name '*.ts')
2 |
3 | lib: ${SRC_FILES} package.json tsconfig.json node_modules rollup.config.js
4 | @./node_modules/.bin/rollup -c
5 |
6 | .PHONY: test
7 | test: node_modules
8 | @TS_NODE_PROJECT='./test/tsconfig.json' ./node_modules/.bin/mocha -u tdd -r ts-node/register --extension ts test/*.ts --grep '$(grep)'
9 |
10 | .PHONY: coverage
11 | coverage: node_modules
12 | @TS_NODE_PROJECT='./test/tsconfig.json' ./node_modules/.bin/nyc --reporter=html ./node_modules/.bin/mocha -u tdd -r ts-node/register --extension ts test/*.ts -R nyan && open coverage/index.html
13 |
14 | .PHONY: lint
15 | lint: node_modules
16 | @./node_modules/.bin/eslint src --ext .ts --fix
17 |
18 | .PHONY: ci-test
19 | ci-test: node_modules
20 | @TS_NODE_PROJECT='./test/tsconfig.json' ./node_modules/.bin/nyc --reporter=text ./node_modules/.bin/mocha -u tdd -r ts-node/register --extension ts test/*.ts -R list
21 |
22 | .PHONY: ci-lint
23 | ci-lint: node_modules
24 | @./node_modules/.bin/eslint src --ext .ts --max-warnings 0 --format unix && echo "Ok"
25 |
26 | docs: $(SRC_FILES) node_modules
27 | ./node_modules/.bin/typedoc \
28 | --excludeInternal \
29 | --excludePrivate --excludeProtected \
30 | --name "Proton Link" --includeVersion --readme none \
31 | --out docs \
32 | src/index-module.ts
33 |
34 | .PHONY: deploy-site
35 | deploy-site: docs
36 | cp -r ./examples ./docs/examples/
37 | ./node_modules/.bin/gh-pages -d docs
38 |
39 | node_modules:
40 | yarn install --non-interactive --frozen-lockfile --ignore-scripts
41 |
42 | .PHONY: publish
43 | publish: | distclean node_modules
44 | @git diff-index --quiet HEAD || (echo "Uncommitted changes, please commit first" && exit 1)
45 | @git fetch origin && git diff origin/master --quiet || (echo "Changes not pushed to origin, please push first" && exit 1)
46 | @yarn config set version-tag-prefix "" && yarn config set version-git-message "Version %s"
47 | @yarn publish && git push && git push --tags
48 |
49 | .PHONY: clean
50 | clean:
51 | rm -rf lib/ coverage/ docs/
52 |
53 | .PHONY: distclean
54 | distclean: clean
55 | rm -rf node_modules/
56 |
--------------------------------------------------------------------------------
/packages/proton-web-sdk/README.md:
--------------------------------------------------------------------------------
1 | # Proton Web SDK
2 |
3 | Installation
4 | ```
5 | npm i @proton/web-sdk
6 | yarn add @proton/web-sdk
7 | ```
8 |
9 | Usage
10 | ```javascript
11 | import ProtonWebSDK from '@proton/web-sdk'
12 |
13 | // Constants
14 | const appIdentifier = 'taskly'
15 |
16 | // Login
17 | const { link, session } = await ProtonWebSDK({
18 | linkOptions: {
19 | /* RPC endpoints */
20 | endpoints: ['https://proton.greymass.com'],
21 |
22 | /* Recommended: false if first time connecting, true if trying to reconnect */
23 | restoreSession: false
24 | },
25 | transportOptions: {
26 | /* Recommended: Your proton account */
27 | requestAccount: appIdentifier,
28 |
29 | /* Optional: Display request success and error messages, Default true */
30 | requestStatus: true,
31 | },
32 | selectorOptions: {
33 | /* Optional: Name to show in modal, Default 'app' */
34 | appName: 'Taskly',
35 |
36 | /* Optional: Logo to show in modal */
37 | appLogo: 'https://protondemos.com/static/media/taskly-logo.ad0bfb0f.svg',
38 |
39 | /* Optional: Custom style options for modal */
40 | customStyleOptions: {
41 | modalBackgroundColor: '#F4F7FA',
42 | logoBackgroundColor: 'white',
43 | isLogoRound: true,
44 | optionBackgroundColor: 'white',
45 | optionFontColor: 'black',
46 | primaryFontColor: 'black',
47 | secondaryFontColor: '#6B727F',
48 | linkColor: '#752EEB'
49 | }
50 | }
51 | })
52 |
53 | // Actor and permission
54 | console.log(session.auth.actor) // e.g. "metal"
55 | console.log(session.auth.permission) // e.g. "active"
56 |
57 | // Send Transaction
58 | const result = await session.transact({
59 | transaction: {
60 | actions: [{
61 | // Token contract for XUSDT
62 | account: 'xtokens',
63 |
64 | // Action name
65 | name: 'transfer',
66 |
67 | // Action parameters
68 | data: {
69 | from: session.auth.actor,
70 | to: 'token.burn',
71 | quantity: '0.000001 XUSDT',
72 | memo: 'Tip!'
73 | },
74 | authorization: [session.auth]
75 | }]
76 | },
77 | }, { broadcast: true })
78 | console.log('Transaction ID', result.processed.id)
79 |
80 | // Logout
81 | await link.removeSession(appIdentifier, session.auth)
82 | link = undefined
83 | session = undefined
84 | ```
85 |
--------------------------------------------------------------------------------
/packages/proton-web-sdk/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@proton/web-sdk",
3 | "author": "metallicus",
4 | "publishConfig": {
5 | "access": "public"
6 | },
7 | "type": "module",
8 | "module": "dist/index.js",
9 | "unpkg": "dist/bundle.js",
10 | "types": "dist/index.d.ts",
11 | "source": "src/index.ts",
12 | "version": "4.2.20",
13 | "license": "MIT",
14 | "main": "dist/index.js",
15 | "typings": "dist/index.d.ts",
16 | "files": [
17 | "dist",
18 | "cdn",
19 | "src"
20 | ],
21 | "engines": {
22 | "node": ">=10"
23 | },
24 | "scripts": {
25 | "watch": "rollup -c -w",
26 | "build": "make",
27 | "lint": "tsdx lint",
28 | "prepare": "make",
29 | "size": "size-limit",
30 | "analyze": "size-limit --why"
31 | },
32 | "dependencies": {
33 | "@greymass/eosio": "^0.6.1",
34 | "@proton/browser-transport": "^4.2.19",
35 | "@proton/js": "^28.1.2",
36 | "@proton/link": "^4.2.18"
37 | },
38 | "husky": {
39 | "hooks": {
40 | "pre-commit": "tsdx lint"
41 | }
42 | },
43 | "prettier": {
44 | "printWidth": 80,
45 | "semi": true,
46 | "singleQuote": true,
47 | "trailingComma": "es5"
48 | },
49 | "gitHead": "d81cd76c8aacc2538243e24d0801b3eae4b8dba2",
50 | "devDependencies": {
51 | "@rollup/plugin-commonjs": "^22.0.1",
52 | "@rollup/plugin-json": "^4.1.0",
53 | "@rollup/plugin-node-resolve": "^13.0.0",
54 | "@rollup/plugin-replace": "^4.0.0",
55 | "@rollup/plugin-typescript": "^8.3.3",
56 | "@tsconfig/svelte": "^3.0.0",
57 | "@types/node": "^16.4.0",
58 | "@typescript-eslint/eslint-plugin": "^5.30.0",
59 | "@typescript-eslint/parser": "^5.30.0",
60 | "core-js": "^3.21.0",
61 | "eslint": "^7.31.0",
62 | "postcss": "^8.4.14",
63 | "rollup": "^2.75.7",
64 | "rollup-plugin-dts": "^4.2.2",
65 | "rollup-plugin-svelte": "^7.1.0",
66 | "rollup-plugin-terser": "^7.0.2",
67 | "sass": "^1.53.0",
68 | "svelte": "^3.48.0",
69 | "svelte-check": "^2.8.0",
70 | "svelte-preprocess": "^4.10.7",
71 | "ts-node": "^10.0.0",
72 | "tslib": "^2.4.0",
73 | "typescript": "^4.7.4"
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/packages/proton-web-sdk/src/constants.ts:
--------------------------------------------------------------------------------
1 | export const WALLET_TYPES = [
2 | { key: 'proton', value: 'Mobile' },
3 | { key: 'webauth', value: 'Browser' },
4 | { key: 'anchor', value: 'Desktop' },
5 | ]
--------------------------------------------------------------------------------
/packages/proton-web-sdk/src/global.d.ts:
--------------------------------------------------------------------------------
1 | ///
--------------------------------------------------------------------------------
/packages/proton-web-sdk/src/index.ts:
--------------------------------------------------------------------------------
1 |
2 | import { ConnectWallet } from './connect'
3 |
4 | export type { ProtonWebLink } from './links/protonWeb'
5 | export type { Link, LinkSession, TransactResult } from '@proton/link'
6 |
7 | //Allowing Type Definitions to be used by other modules
8 | export * from "./types"
9 |
10 | export default ConnectWallet
11 |
--------------------------------------------------------------------------------
/packages/proton-web-sdk/src/storage.ts:
--------------------------------------------------------------------------------
1 | import type { LinkStorage } from "@proton/link"
2 |
3 | export class Storage implements LinkStorage {
4 | constructor(readonly keyPrefix: string) { }
5 |
6 | async write(key: string, data: string): Promise {
7 | localStorage.setItem(this.storageKey(key), data)
8 | }
9 |
10 | async read(key: string): Promise {
11 | return localStorage.getItem(this.storageKey(key))
12 | }
13 |
14 | async remove(key: string): Promise {
15 | localStorage.removeItem(this.storageKey(key))
16 | }
17 |
18 | storageKey(key: string) {
19 | return `${this.keyPrefix}-${key}`
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/packages/proton-web-sdk/src/styles.ts:
--------------------------------------------------------------------------------
1 | import type { CustomStyleOptions } from "./types";
2 |
3 | export const CustomStyleOptionsToVarsMap: Map = new Map([
4 | ['modalBackgroundColor', 'proton-wallet-modal-bgcolor'],
5 | ['logoBackgroundColor', 'proton-wallet-color-bglogo'],
6 | ['optionBackgroundColor', 'proton-wallet-option-bg'],
7 | ['optionFontColor', 'proton-wallet-option-font'],
8 | ['primaryFontColor', 'proton-wallet-color-font-primary'],
9 | ['secondaryFontColor', 'proton-wallet-color-font-secondary'],
10 | ['linkColor', 'proton-wallet-color-link'],
11 | ])
12 |
13 |
--------------------------------------------------------------------------------
/packages/proton-web-sdk/src/types.ts:
--------------------------------------------------------------------------------
1 | import type { LinkStorage, LinkOptions, LinkSession, Link, LoginResult } from "@proton/link"
2 | import type { BrowserTransportOptions } from "@proton/browser-transport"
3 | import type { ProtonWebLink } from './links/protonWeb';
4 |
5 | type PartialBy = Omit & Partial>
6 |
7 | export interface CustomStyleOptions {
8 | modalBackgroundColor?: string,
9 | logoBackgroundColor?: string,
10 | isLogoRound?: boolean,
11 | optionBackgroundColor?: string,
12 | optionFontColor?: string,
13 | primaryFontColor?: string,
14 | secondaryFontColor?: string,
15 | linkColor?: string,
16 | }
17 |
18 | export interface SelectorOptions {
19 | appName?: string,
20 | appLogo?: string,
21 | walletType?: string,
22 | enabledWalletTypes?: string[],
23 | dialogRootNode?: HTMLElement | string;
24 | customStyleOptions?: CustomStyleOptions
25 | }
26 |
27 | export type LocalLinkOptions = PartialBy & {
28 | endpoints: string[],
29 | storage?: LinkStorage,
30 | storagePrefix?: string,
31 | restoreSession?: boolean,
32 | testUrl?: string
33 | }
34 |
35 | export interface ConnectWalletArgs {
36 | linkOptions: LocalLinkOptions,
37 | transportOptions?: BrowserTransportOptions;
38 | selectorOptions?: SelectorOptions
39 | }
40 |
41 | export interface ConnectWalletRet {
42 | session?: LinkSession;
43 | link?: ProtonWebLink | Link;
44 | loginResult?: LoginResult;
45 | error?: any
46 | }
47 |
48 | export interface WalletItem {
49 | key: string;
50 | value: string;
51 | }
52 |
53 | export interface LoginOptions {
54 | selectorOptions: SelectorOptions;
55 | linkOptions: LocalLinkOptions;
56 | transportOptions: BrowserTransportOptions;
57 | repeat?: boolean
58 | }
59 |
--------------------------------------------------------------------------------
/packages/proton-web-sdk/src/views/Footer.svelte:
--------------------------------------------------------------------------------
1 |
25 |
26 |
46 |
--------------------------------------------------------------------------------
/packages/proton-web-sdk/src/views/Header.svelte:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 | {#if logo}
10 |
{/if}
16 | {#if title}{title}{/if}
17 | {#if subtitle}{subtitle}{/if}
18 |
19 |
20 |
66 |
--------------------------------------------------------------------------------
/packages/proton-web-sdk/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.json",
3 | "compilerOptions": {
4 | "module": "esnext",
5 | "lib": [
6 | "esnext",
7 | "dom"
8 | ],
9 | "target": "es2020",
10 | "importHelpers": true,
11 | "downlevelIteration": true,
12 | "esModuleInterop": true,
13 | "moduleResolution": "node",
14 | "noImplicitAny": false,
15 | "strict": true,
16 | "declarationDir": "./dist/types",
17 | /**
18 | Svelte Preprocess cannot figure out whether you have a value or a type, so tell TypeScript
19 | to enforce using `import type` instead of `import` for Types.
20 | */
21 | "importsNotUsedAsValues": "error",
22 | /**
23 | TypeScript doesn't know about import usages in the template because it only sees the
24 | script of a Svelte file. Therefore preserve all value imports. Requires TS 4.5 or higher.
25 | */
26 | "preserveValueImports": true,
27 | "isolatedModules": true,
28 | /**
29 | To have warnings/errors of the Svelte compiler at the correct position,
30 | enable source maps by default.
31 | */
32 | "sourceMap": true,
33 | "skipLibCheck": true,
34 | "forceConsistentCasingInFileNames": true
35 | },
36 | "include": [
37 | "src/**/*"
38 | ]
39 | }
40 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "baseUrl": "./packages",
4 | "paths": {
5 | "@proton/browser-transport": ["proton-browser-transport"],
6 | "@proton/link": ["proton-link"],
7 | "@proton/react-native-sdk": ["proton-react-native-sdk"],
8 | "@proton/signing-request": ["proton-signing-request"],
9 | "@proton/web-sdk": ["proton-web-sdk"],
10 | },
11 | "downlevelIteration": true,
12 | "declaration": true,
13 | "esModuleInterop": true,
14 | "experimentalDecorators": true,
15 | "allowJs": true
16 | }
17 | }
--------------------------------------------------------------------------------