├── .nvmrc ├── examples ├── react-native │ ├── .node-version │ ├── .watchmanconfig │ ├── .ruby-version │ ├── app.json │ ├── babel.config.js │ ├── android │ │ ├── app │ │ │ ├── src │ │ │ │ ├── main │ │ │ │ │ ├── res │ │ │ │ │ │ ├── values │ │ │ │ │ │ │ ├── strings.xml │ │ │ │ │ │ │ └── styles.xml │ │ │ │ │ │ ├── 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 │ │ │ │ │ │ └── drawable │ │ │ │ │ │ │ └── rn_edit_text_material.xml │ │ │ │ │ ├── jni │ │ │ │ │ │ ├── CMakeLists.txt │ │ │ │ │ │ ├── MainApplicationModuleProvider.h │ │ │ │ │ │ ├── OnLoad.cpp │ │ │ │ │ │ ├── MainComponentsRegistry.h │ │ │ │ │ │ ├── MainApplicationModuleProvider.cpp │ │ │ │ │ │ ├── MainApplicationTurboModuleManagerDelegate.h │ │ │ │ │ │ ├── MainApplicationTurboModuleManagerDelegate.cpp │ │ │ │ │ │ └── MainComponentsRegistry.cpp │ │ │ │ │ ├── java │ │ │ │ │ │ └── com │ │ │ │ │ │ │ └── example │ │ │ │ │ │ │ ├── newarchitecture │ │ │ │ │ │ │ ├── components │ │ │ │ │ │ │ │ └── MainComponentsRegistry.java │ │ │ │ │ │ │ └── modules │ │ │ │ │ │ │ │ └── MainApplicationTurboModuleManagerDelegate.java │ │ │ │ │ │ │ └── MainActivity.java │ │ │ │ │ └── AndroidManifest.xml │ │ │ │ └── debug │ │ │ │ │ └── AndroidManifest.xml │ │ │ ├── debug.keystore │ │ │ ├── proguard-rules.pro │ │ │ ├── build_defs.bzl │ │ │ └── _BUCK │ │ ├── gradle │ │ │ └── wrapper │ │ │ │ ├── gradle-wrapper.jar │ │ │ │ └── gradle-wrapper.properties │ │ ├── settings.gradle │ │ ├── build.gradle │ │ └── gradle.properties │ ├── ios │ │ ├── example │ │ │ ├── Images.xcassets │ │ │ │ ├── Contents.json │ │ │ │ └── AppIcon.appiconset │ │ │ │ │ └── Contents.json │ │ │ ├── AppDelegate.h │ │ │ ├── main.m │ │ │ └── Info.plist │ │ ├── .xcode.env │ │ ├── exampleTests │ │ │ ├── Info.plist │ │ │ └── exampleTests.m │ │ └── Podfile │ ├── .buckconfig │ ├── registerGlobals.js │ ├── .prettierrc.js │ ├── Gemfile │ ├── index.js │ ├── metro.config.js │ ├── tsconfig.json │ ├── .eslintrc.js │ ├── .gitignore │ ├── package.json │ ├── webSdk.ts │ └── App.tsx ├── svelte │ ├── .npmrc │ ├── src │ │ ├── lib │ │ │ ├── index.ts │ │ │ ├── userState.ts │ │ │ └── components │ │ │ │ ├── Avatar.svelte │ │ │ │ └── Transfer.svelte │ │ ├── app.css │ │ ├── app.d.ts │ │ ├── routes │ │ │ └── +page.svelte │ │ └── app.html │ ├── static │ │ └── favicon.png │ ├── .prettierignore │ ├── vite.config.ts │ ├── .prettierrc │ ├── .gitignore │ ├── tsconfig.json │ ├── README.md │ ├── svelte.config.js │ ├── eslint.config.js │ └── package.json ├── vue │ ├── .gitattributes │ ├── env.d.ts │ ├── public │ │ └── favicon.ico │ ├── .prettierrc.json │ ├── .vscode │ │ └── extensions.json │ ├── tsconfig.json │ ├── src │ │ ├── assets │ │ │ └── main.css │ │ ├── main.ts │ │ ├── App.vue │ │ ├── stores │ │ │ ├── counter.ts │ │ │ └── user.ts │ │ └── components │ │ │ ├── Header.vue │ │ │ ├── Transfer.vue │ │ │ └── Avatar.vue │ ├── .editorconfig │ ├── tsconfig.app.json │ ├── index.html │ ├── .gitignore │ ├── tsconfig.node.json │ ├── vite.config.ts │ ├── eslint.config.ts │ ├── README.md │ └── package.json ├── angular │ ├── src │ │ ├── app │ │ │ ├── app.component.html │ │ │ ├── app.config.ts │ │ │ ├── components │ │ │ │ ├── header │ │ │ │ │ ├── header.component.ts │ │ │ │ │ └── header.component.html │ │ │ │ ├── avatar │ │ │ │ │ ├── avatar.component.ts │ │ │ │ │ └── avatar.component.html │ │ │ │ └── transfer │ │ │ │ │ ├── transfer.component.ts │ │ │ │ │ └── transfer.component.html │ │ │ ├── app.component.ts │ │ │ └── services │ │ │ │ └── user │ │ │ │ └── user.service.ts │ │ ├── styles.css │ │ ├── main.ts │ │ └── index.html │ ├── .postcssrc.json │ ├── public │ │ └── favicon.ico │ ├── .vscode │ │ ├── extensions.json │ │ ├── launch.json │ │ └── tasks.json │ ├── .editorconfig │ ├── tsconfig.app.json │ ├── tsconfig.spec.json │ ├── tsconfig.json │ ├── package.json │ └── README.md ├── react │ ├── src │ │ ├── vite-env.d.ts │ │ ├── index.css │ │ ├── App.tsx │ │ ├── main.tsx │ │ ├── hooks │ │ │ └── store.ts │ │ ├── store │ │ │ ├── store.ts │ │ │ └── slices │ │ │ │ └── user.slice.ts │ │ └── components │ │ │ └── Header.tsx │ ├── tsconfig.json │ ├── vite.config.ts │ ├── .gitignore │ ├── index.html │ ├── README.md │ ├── tsconfig.node.json │ ├── tsconfig.app.json │ ├── eslint.config.js │ ├── package.json │ └── public │ │ └── vite.svg └── vanilla-html │ └── README.md ├── packages ├── proton-web-sdk │ ├── src │ │ ├── global.d.ts │ │ ├── constants.ts │ │ ├── index.ts │ │ ├── state.svelte.ts │ │ ├── styles.ts │ │ ├── storage.ts │ │ ├── views │ │ │ ├── Footer.svelte │ │ │ └── Header.svelte │ │ └── types.ts │ ├── .gitignore │ ├── .editorconfig │ ├── .prettierrc │ ├── tsconfig.json │ ├── LICENSE │ ├── Makefile │ ├── package.json │ ├── eslint.config.ts │ └── README.md ├── proton-browser-transport │ ├── src │ │ ├── global.d.ts │ │ ├── qrcode │ │ │ ├── ErrorCorrectLevel.ts │ │ │ ├── mode.ts │ │ │ ├── 8BitByte.ts │ │ │ ├── BitBuffer.ts │ │ │ ├── math.ts │ │ │ ├── LICENSE-qrcode │ │ │ ├── index.ts │ │ │ └── Polynomial.ts │ │ ├── index.ts │ │ ├── storage.ts │ │ ├── views │ │ │ └── CountDown.svelte │ │ ├── state.svelte.ts │ │ └── types.ts │ ├── .gitignore │ ├── .editorconfig │ ├── .prettierrc │ ├── Makefile │ ├── tsconfig.json │ ├── LICENSE │ ├── README.md │ ├── package.json │ └── eslint.config.ts ├── proton-react-native-sdk │ ├── .gitignore │ ├── .prettierrc │ ├── .editorconfig │ ├── src │ │ ├── registerGlobals.ts │ │ ├── storage.ts │ │ └── transport.ts │ ├── LICENSE │ ├── Makefile │ ├── eslint.config.ts │ ├── tsconfig.json │ ├── package.json │ └── rollup.config.js ├── proton-link │ ├── .gitignore │ ├── .prettierrc │ ├── src │ │ ├── index-bundle.ts │ │ ├── index.ts │ │ ├── index-module.ts │ │ ├── link-storage.ts │ │ ├── link-types.ts │ │ ├── errors.ts │ │ └── link-transport.ts │ ├── test │ │ ├── tsconfig.json │ │ └── aes.ts │ ├── .editorconfig │ ├── tslint.json │ ├── examples │ │ ├── README.md │ │ └── transact │ │ │ └── index.html │ ├── tsconfig.json │ ├── LICENSE │ ├── eslint.config.ts │ └── Makefile └── proton-signing-request │ ├── .gitignore │ ├── src │ └── index.ts │ ├── test │ ├── tsconfig.json │ ├── utils │ │ ├── node-zlib-provider.ts │ │ └── mock-abi-provider.ts │ └── misc.ts │ ├── .prettierrc │ ├── .editorconfig │ ├── tsconfig.json │ ├── LICENSE │ ├── eslint.config.ts │ ├── Makefile │ └── package.json ├── .gitignore ├── .vscode └── settings.json ├── pnpm-workspace.yaml ├── .changeset ├── config.json └── README.md ├── turbo.json ├── package.json └── tsconfig.json /.nvmrc: -------------------------------------------------------------------------------- 1 | v18.19.1 -------------------------------------------------------------------------------- /examples/react-native/.node-version: -------------------------------------------------------------------------------- 1 | 18 2 | -------------------------------------------------------------------------------- /examples/react-native/.watchmanconfig: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /examples/react-native/.ruby-version: -------------------------------------------------------------------------------- 1 | 2.7.5 2 | -------------------------------------------------------------------------------- /examples/svelte/.npmrc: -------------------------------------------------------------------------------- 1 | engine-strict=true 2 | -------------------------------------------------------------------------------- /examples/vue/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto eol=lf 2 | -------------------------------------------------------------------------------- /examples/vue/env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /examples/angular/src/app/app.component.html: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/react/src/vite-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /packages/proton-web-sdk/src/global.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /packages/proton-browser-transport/src/global.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /packages/proton-web-sdk/.gitignore: -------------------------------------------------------------------------------- 1 | *.log 2 | .DS_Store 3 | node_modules 4 | dist 5 | -------------------------------------------------------------------------------- /examples/react-native/app.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "example", 3 | "displayName": "example" 4 | } -------------------------------------------------------------------------------- /packages/proton-react-native-sdk/.gitignore: -------------------------------------------------------------------------------- 1 | *.log 2 | .DS_Store 3 | node_modules 4 | dist 5 | -------------------------------------------------------------------------------- /packages/proton-link/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | lib/ 3 | docs/ 4 | .nyc_output 5 | coverage 6 | -------------------------------------------------------------------------------- /packages/proton-signing-request/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | lib/ 3 | coverage/ 4 | .nyc_output/ 5 | -------------------------------------------------------------------------------- /examples/svelte/src/lib/index.ts: -------------------------------------------------------------------------------- 1 | // place files you want to import through the `$lib` alias in this folder. 2 | -------------------------------------------------------------------------------- /examples/angular/.postcssrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "plugins": { 3 | "@tailwindcss/postcss": {} 4 | } 5 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .angular 3 | .turbo 4 | dist 5 | lib 6 | 7 | packages/proton-react-native-sdk/example/*.lock -------------------------------------------------------------------------------- /examples/vue/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XPRNetwork/proton-web-sdk/HEAD/examples/vue/public/favicon.ico -------------------------------------------------------------------------------- /examples/react-native/babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: ['module:metro-react-native-babel-preset'], 3 | }; 4 | -------------------------------------------------------------------------------- /packages/proton-browser-transport/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | lib 3 | lib/ 4 | lib/* 5 | docs/ 6 | .nyc_output 7 | coverage 8 | -------------------------------------------------------------------------------- /examples/angular/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XPRNetwork/proton-web-sdk/HEAD/examples/angular/public/favicon.ico -------------------------------------------------------------------------------- /examples/svelte/static/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XPRNetwork/proton-web-sdk/HEAD/examples/svelte/static/favicon.png -------------------------------------------------------------------------------- /examples/svelte/.prettierignore: -------------------------------------------------------------------------------- 1 | # Package Managers 2 | package-lock.json 3 | pnpm-lock.yaml 4 | yarn.lock 5 | bun.lock 6 | bun.lockb 7 | -------------------------------------------------------------------------------- /packages/proton-browser-transport/src/qrcode/ErrorCorrectLevel.ts: -------------------------------------------------------------------------------- 1 | export default { 2 | L: 1, 3 | M: 0, 4 | Q: 3, 5 | H: 2, 6 | } 7 | -------------------------------------------------------------------------------- /examples/react-native/android/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | example 3 | 4 | -------------------------------------------------------------------------------- /examples/react-native/ios/example/Images.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /examples/react-native/android/app/debug.keystore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XPRNetwork/proton-web-sdk/HEAD/examples/react-native/android/app/debug.keystore -------------------------------------------------------------------------------- /examples/react-native/.buckconfig: -------------------------------------------------------------------------------- 1 | 2 | [android] 3 | target = Google Inc.:Google APIs:23 4 | 5 | [maven_repositories] 6 | central = https://repo1.maven.org/maven2 7 | -------------------------------------------------------------------------------- /examples/vue/.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json.schemastore.org/prettierrc", 3 | "semi": false, 4 | "singleQuote": true, 5 | "printWidth": 100 6 | } 7 | -------------------------------------------------------------------------------- /examples/react/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "files": [], 3 | "references": [ 4 | { "path": "./tsconfig.app.json" }, 5 | { "path": "./tsconfig.node.json" } 6 | ] 7 | } 8 | -------------------------------------------------------------------------------- /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/react-native/android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XPRNetwork/proton-web-sdk/HEAD/examples/react-native/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /examples/react-native/registerGlobals.js: -------------------------------------------------------------------------------- 1 | import {TextDecoder, TextEncoder} from 'text-encoding-shim'; 2 | 3 | global.TextDecoder = TextDecoder; 4 | global.TextEncoder = TextEncoder; 5 | -------------------------------------------------------------------------------- /packages/proton-browser-transport/src/index.ts: -------------------------------------------------------------------------------- 1 | export type {BrowserTransportOptions} from './types' 2 | import {BrowserTransport} from './transport' 3 | export default BrowserTransport 4 | -------------------------------------------------------------------------------- /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-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-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 | ] 6 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "svelte.plugin.svelte.compilerWarnings": { 3 | "a11y-click-events-have-key-events": "ignore", 4 | "a11y-interactive-supports-focus": "ignore" 5 | } 6 | } -------------------------------------------------------------------------------- /examples/react-native/.prettierrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | arrowParens: 'avoid', 3 | bracketSameLine: true, 4 | bracketSpacing: false, 5 | singleQuote: true, 6 | trailingComma: 'all', 7 | }; 8 | -------------------------------------------------------------------------------- /examples/vue/.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "Vue.volar", 4 | "dbaeumer.vscode-eslint", 5 | "EditorConfig.EditorConfig", 6 | "esbenp.prettier-vscode" 7 | ] 8 | } 9 | -------------------------------------------------------------------------------- /examples/react-native/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XPRNetwork/proton-web-sdk/HEAD/examples/react-native/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /examples/react-native/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XPRNetwork/proton-web-sdk/HEAD/examples/react-native/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /examples/react-native/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XPRNetwork/proton-web-sdk/HEAD/examples/react-native/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /examples/react-native/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XPRNetwork/proton-web-sdk/HEAD/examples/react-native/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /examples/react-native/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XPRNetwork/proton-web-sdk/HEAD/examples/react-native/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /examples/react-native/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | # You may use http://rbenv.org/ or https://rvm.io/ to install and use this version 4 | ruby '2.7.5' 5 | 6 | gem 'cocoapods', '~> 1.11', '>= 1.11.3' 7 | -------------------------------------------------------------------------------- /examples/react-native/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XPRNetwork/proton-web-sdk/HEAD/examples/react-native/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /examples/react-native/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XPRNetwork/proton-web-sdk/HEAD/examples/react-native/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /examples/react-native/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XPRNetwork/proton-web-sdk/HEAD/examples/react-native/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /examples/vanilla-html/README.md: -------------------------------------------------------------------------------- 1 | # Proton Web SDK - HTML Example 2 | 3 | Small boilerplate to get started with Proton on vanilla HTML 4 | 5 | [CodeSandbox Playground](https://codesandbox.io/s/proton-html-example-13zsh) 6 | -------------------------------------------------------------------------------- /examples/vue/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "files": [], 3 | "references": [ 4 | { 5 | "path": "./tsconfig.node.json" 6 | }, 7 | { 8 | "path": "./tsconfig.app.json" 9 | } 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /examples/react-native/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XPRNetwork/proton-web-sdk/HEAD/examples/react-native/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /examples/react-native/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XPRNetwork/proton-web-sdk/HEAD/examples/react-native/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /examples/angular/src/app/app.config.ts: -------------------------------------------------------------------------------- 1 | import { ApplicationConfig, provideZoneChangeDetection } from '@angular/core'; 2 | 3 | export const appConfig: ApplicationConfig = { 4 | providers: [provideZoneChangeDetection({ eventCoalescing: true }),] 5 | }; 6 | -------------------------------------------------------------------------------- /examples/react/src/index.css: -------------------------------------------------------------------------------- 1 | @import "tailwindcss"; 2 | 3 | body { 4 | font-family: Avenir, Helvetica, Arial, sans-serif; 5 | -webkit-font-smoothing: antialiased; 6 | -moz-osx-font-smoothing: grayscale; 7 | text-align: center; 8 | color: #2c3e50; 9 | } -------------------------------------------------------------------------------- /examples/svelte/vite.config.ts: -------------------------------------------------------------------------------- 1 | import { sveltekit } from '@sveltejs/kit/vite'; 2 | import tailwindcss from '@tailwindcss/vite'; 3 | import { defineConfig } from 'vite'; 4 | 5 | export default defineConfig({ 6 | plugins: [tailwindcss(), sveltekit()] 7 | }); 8 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /examples/angular/src/styles.css: -------------------------------------------------------------------------------- 1 | @import "tailwindcss"; 2 | 3 | body { 4 | font-family: Avenir, Helvetica, Arial, sans-serif; 5 | -webkit-font-smoothing: antialiased; 6 | -moz-osx-font-smoothing: grayscale; 7 | text-align: center; 8 | color: #2c3e50; 9 | } -------------------------------------------------------------------------------- /examples/vue/src/assets/main.css: -------------------------------------------------------------------------------- 1 | @import "tailwindcss"; 2 | 3 | #app { 4 | font-family: Avenir, Helvetica, Arial, sans-serif; 5 | -webkit-font-smoothing: antialiased; 6 | -moz-osx-font-smoothing: grayscale; 7 | text-align: center; 8 | color: #2c3e50; 9 | } -------------------------------------------------------------------------------- /examples/svelte/src/app.css: -------------------------------------------------------------------------------- 1 | @import 'tailwindcss'; 2 | 3 | body { 4 | font-family: Avenir, Helvetica, Arial, sans-serif; 5 | -webkit-font-smoothing: antialiased; 6 | -moz-osx-font-smoothing: grayscale; 7 | text-align: center; 8 | color: #2c3e50; 9 | } 10 | -------------------------------------------------------------------------------- /examples/react-native/ios/example/AppDelegate.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @interface AppDelegate : UIResponder 5 | 6 | @property (nonatomic, strong) UIWindow *window; 7 | 8 | @end 9 | -------------------------------------------------------------------------------- /examples/vue/src/main.ts: -------------------------------------------------------------------------------- 1 | import './assets/main.css' 2 | 3 | import { createApp } from 'vue' 4 | import { createPinia } from 'pinia' 5 | import App from './App.vue' 6 | 7 | const app = createApp(App) 8 | 9 | app.use(createPinia()) 10 | 11 | app.mount('#app') 12 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /pnpm-workspace.yaml: -------------------------------------------------------------------------------- 1 | packages: 2 | - examples/* 3 | - packages/* 4 | 5 | ignoredBuiltDependencies: 6 | - '@parcel/watcher' 7 | - core-js 8 | - lmdb 9 | - msgpackr-extract 10 | 11 | onlyBuiltDependencies: 12 | - esbuild 13 | - svelte-preprocess 14 | -------------------------------------------------------------------------------- /examples/react/vite.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'vite' 2 | import react from '@vitejs/plugin-react' 3 | import tailwindcss from '@tailwindcss/vite' 4 | 5 | // https://vite.dev/config/ 6 | export default defineConfig({ 7 | plugins: [tailwindcss(), react()], 8 | }) 9 | -------------------------------------------------------------------------------- /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-react-native-sdk/.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "arrowParens": "always", 3 | "bracketSpacing": false, 4 | "endOfLine": "lf", 5 | "printWidth": 100, 6 | "semi": false, 7 | "singleQuote": true, 8 | "tabWidth": 2, 9 | "trailingComma": "es5" 10 | } -------------------------------------------------------------------------------- /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-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 | -------------------------------------------------------------------------------- /examples/react-native/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-all.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /examples/react-native/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 | -------------------------------------------------------------------------------- /examples/react-native/ios/example/main.m: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | #import "AppDelegate.h" 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | @autoreleasepool { 8 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /examples/react/src/App.tsx: -------------------------------------------------------------------------------- 1 | import { Header } from './components/Header' 2 | import { Transfer } from './components/Transfer' 3 | 4 | function App() { 5 | return ( 6 | <> 7 |
8 | 9 | 10 | ) 11 | } 12 | 13 | export default App 14 | -------------------------------------------------------------------------------- /examples/vue/.editorconfig: -------------------------------------------------------------------------------- 1 | [*.{js,jsx,mjs,cjs,ts,tsx,mts,cts,vue,css,scss,sass,less,styl}] 2 | charset = utf-8 3 | indent_size = 2 4 | indent_style = space 5 | insert_final_newline = true 6 | trim_trailing_whitespace = true 7 | 8 | end_of_line = lf 9 | max_line_length = 100 10 | -------------------------------------------------------------------------------- /packages/proton-signing-request/.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "arrowParens": "always", 3 | "bracketSpacing": false, 4 | "endOfLine": "lf", 5 | "printWidth": 100, 6 | "semi": false, 7 | "singleQuote": true, 8 | "tabWidth": 4, 9 | "trailingComma": "es5" 10 | } 11 | -------------------------------------------------------------------------------- /examples/vue/src/App.vue: -------------------------------------------------------------------------------- 1 | 5 | 6 | 10 | 11 | 14 | -------------------------------------------------------------------------------- /packages/proton-browser-transport/.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-react-native-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-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 | -------------------------------------------------------------------------------- /examples/angular/src/main.ts: -------------------------------------------------------------------------------- 1 | import { bootstrapApplication } from '@angular/platform-browser'; 2 | import { appConfig } from './app/app.config'; 3 | import { AppComponent } from './app/app.component'; 4 | 5 | bootstrapApplication(AppComponent, appConfig) 6 | .catch((err) => console.error(err)); 7 | -------------------------------------------------------------------------------- /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 | } -------------------------------------------------------------------------------- /examples/svelte/.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "useTabs": true, 3 | "singleQuote": true, 4 | "trailingComma": "none", 5 | "printWidth": 100, 6 | "plugins": ["prettier-plugin-svelte"], 7 | "overrides": [ 8 | { 9 | "files": "*.svelte", 10 | "options": { 11 | "parser": "svelte" 12 | } 13 | } 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /examples/svelte/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | 3 | # Output 4 | .output 5 | .vercel 6 | .netlify 7 | .wrangler 8 | /.svelte-kit 9 | /build 10 | 11 | # OS 12 | .DS_Store 13 | Thumbs.db 14 | 15 | # Env 16 | .env 17 | .env.* 18 | !.env.example 19 | !.env.test 20 | 21 | # Vite 22 | vite.config.js.timestamp-* 23 | vite.config.ts.timestamp-* 24 | -------------------------------------------------------------------------------- /.changeset/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://unpkg.com/@changesets/config@3.1.1/schema.json", 3 | "changelog": "@changesets/cli/changelog", 4 | "commit": false, 5 | "fixed": [], 6 | "linked": [], 7 | "access": "restricted", 8 | "baseBranch": "master", 9 | "updateInternalDependencies": "patch", 10 | "ignore": [] 11 | } 12 | -------------------------------------------------------------------------------- /packages/proton-web-sdk/src/index.ts: -------------------------------------------------------------------------------- 1 | import {ConnectWallet} from './connect' 2 | 3 | export type {ProtonWebLink} from './links/protonWeb' 4 | export type {Link, LinkSession, TransactResult} from '@proton/link' 5 | 6 | //Allowing Type Definitions to be used by other modules 7 | export * from './types' 8 | 9 | export default ConnectWallet 10 | -------------------------------------------------------------------------------- /examples/react-native/android/app/src/main/jni/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.13) 2 | 3 | # Define the library name here. 4 | project(example_appmodules) 5 | 6 | # This file includes all the necessary to let you build your application with the New Architecture. 7 | include(${REACT_ANDROID_DIR}/cmake-utils/ReactNative-application.cmake) 8 | -------------------------------------------------------------------------------- /examples/react/src/main.tsx: -------------------------------------------------------------------------------- 1 | import { createRoot } from 'react-dom/client' 2 | import './index.css' 3 | import App from './App.tsx' 4 | import { Provider } from 'react-redux' 5 | import {store} from './store/store' 6 | 7 | createRoot(document.getElementById('root')!).render( 8 | 9 | 10 | 11 | ) 12 | -------------------------------------------------------------------------------- /examples/svelte/src/app.d.ts: -------------------------------------------------------------------------------- 1 | // See https://svelte.dev/docs/kit/types#app.d.ts 2 | // for information about these interfaces 3 | declare global { 4 | namespace App { 5 | // interface Error {} 6 | // interface Locals {} 7 | // interface PageData {} 8 | // interface PageState {} 9 | // interface Platform {} 10 | } 11 | } 12 | 13 | export {}; 14 | -------------------------------------------------------------------------------- /examples/vue/tsconfig.app.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@vue/tsconfig/tsconfig.dom.json", 3 | "include": ["env.d.ts", "src/**/*", "src/**/*.vue"], 4 | "exclude": ["src/**/__tests__/*"], 5 | "compilerOptions": { 6 | "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo", 7 | 8 | "paths": { 9 | "@/*": ["./src/*"] 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /examples/react-native/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /turbo.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://turborepo.org/schema.json", 3 | "tasks": { 4 | "build": { 5 | "dependsOn": ["^build"], 6 | "outputs": ["dist/**", "lib/**"] 7 | }, 8 | "lint": { 9 | "outputs": [] 10 | }, 11 | "dev": { 12 | "cache": false 13 | }, 14 | "deployprod": { 15 | "dependsOn": ["build"] 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /examples/react/.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | pnpm-debug.log* 8 | lerna-debug.log* 9 | 10 | node_modules 11 | dist 12 | dist-ssr 13 | *.local 14 | 15 | # Editor directories and files 16 | .vscode/* 17 | !.vscode/extensions.json 18 | .idea 19 | .DS_Store 20 | *.suo 21 | *.ntvs* 22 | *.njsproj 23 | *.sln 24 | *.sw? 25 | -------------------------------------------------------------------------------- /examples/svelte/src/routes/+page.svelte: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | Home 9 | 10 | 11 |
12 |
13 | 14 |
15 | 16 | 18 | -------------------------------------------------------------------------------- /examples/vue/src/stores/counter.ts: -------------------------------------------------------------------------------- 1 | import { ref, computed } from 'vue' 2 | import { defineStore } from 'pinia' 3 | 4 | export const useCounterStore = defineStore('counter', () => { 5 | const count = ref(0) 6 | const doubleCount = computed(() => count.value * 2) 7 | function increment() { 8 | count.value++ 9 | } 10 | 11 | return { count, doubleCount, increment } 12 | }) 13 | -------------------------------------------------------------------------------- /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 | } 12 | -------------------------------------------------------------------------------- /examples/react-native/metro.config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Metro configuration for React Native 3 | * https://github.com/facebook/react-native 4 | * 5 | * @format 6 | */ 7 | 8 | module.exports = { 9 | transformer: { 10 | getTransformOptions: async () => ({ 11 | transform: { 12 | experimentalImportSupport: false, 13 | inlineRequires: true, 14 | }, 15 | }), 16 | }, 17 | }; 18 | -------------------------------------------------------------------------------- /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 | ij_typescript_use_double_quotes = false 14 | 15 | [*.md] 16 | max_line_length = off 17 | trim_trailing_whitespace = false 18 | -------------------------------------------------------------------------------- /examples/react-native/tsconfig.json: -------------------------------------------------------------------------------- 1 | // prettier-ignore 2 | { 3 | "extends": "@tsconfig/react-native/tsconfig.json", /* Recommended React Native TSConfig base */ 4 | "compilerOptions": { 5 | /* Visit https://aka.ms/tsconfig.json to read more about this file */ 6 | 7 | /* Completeness */ 8 | "skipLibCheck": true /* Skip type checking all .d.ts files. */ 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /examples/svelte/src/app.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | %sveltekit.head% 8 | 9 | 10 |
%sveltekit.body%
11 | 12 | 13 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /examples/angular/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Proton Angular App 7 | 8 | 10 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /examples/react-native/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | extends: '@react-native-community', 4 | parser: '@typescript-eslint/parser', 5 | plugins: ['@typescript-eslint'], 6 | overrides: [ 7 | { 8 | files: ['*.ts', '*.tsx'], 9 | rules: { 10 | '@typescript-eslint/no-shadow': ['error'], 11 | 'no-shadow': 'off', 12 | 'no-undef': 'off', 13 | }, 14 | }, 15 | ], 16 | }; 17 | -------------------------------------------------------------------------------- /examples/vue/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 8 | 10 | Proton Vue App 11 | 12 | 13 | 14 |
15 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /examples/angular/src/app/components/header/header.component.ts: -------------------------------------------------------------------------------- 1 | import { Component } from '@angular/core'; 2 | import { AvatarComponent } from '../avatar/avatar.component'; 3 | 4 | @Component({ 5 | selector: 'app-header', 6 | imports: [AvatarComponent], 7 | templateUrl: './header.component.html', 8 | standalone: true, 9 | host: { 10 | 'class': 'relative bg-white' 11 | } 12 | }) 13 | export class HeaderComponent { 14 | 15 | } 16 | -------------------------------------------------------------------------------- /examples/react/src/hooks/store.ts: -------------------------------------------------------------------------------- 1 | import { useDispatch, useSelector, useStore } from 'react-redux' 2 | import type { AppDispatch, AppStore, RootState } from '../store/store' 3 | 4 | // Use throughout your app instead of plain `useDispatch` and `useSelector` 5 | export const useAppDispatch = useDispatch.withTypes() 6 | export const useAppSelector = useSelector.withTypes() 7 | export const useAppStore = useStore.withTypes() -------------------------------------------------------------------------------- /packages/proton-web-sdk/.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "arrowParens": "always", 3 | "bracketSpacing": false, 4 | "endOfLine": "lf", 5 | "printWidth": 100, 6 | "semi": false, 7 | "singleQuote": true, 8 | "tabWidth": 2, 9 | "trailingComma": "es5", 10 | "plugins": ["prettier-plugin-svelte"], 11 | "overrides": [ 12 | { 13 | "files": "*.svelte", 14 | "options": { 15 | "parser": "svelte" 16 | } 17 | } 18 | ] 19 | } -------------------------------------------------------------------------------- /packages/proton-browser-transport/.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "arrowParens": "always", 3 | "bracketSpacing": false, 4 | "endOfLine": "lf", 5 | "printWidth": 100, 6 | "semi": false, 7 | "singleQuote": true, 8 | "tabWidth": 2, 9 | "trailingComma": "es5", 10 | "plugins": ["prettier-plugin-svelte"], 11 | "overrides": [ 12 | { 13 | "files": "*.svelte", 14 | "options": { 15 | "parser": "svelte" 16 | } 17 | } 18 | ] 19 | } -------------------------------------------------------------------------------- /examples/react-native/android/app/src/main/jni/MainApplicationModuleProvider.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | 8 | namespace facebook { 9 | namespace react { 10 | 11 | std::shared_ptr MainApplicationModuleProvider( 12 | const std::string &moduleName, 13 | const JavaTurboModule::InitParams ¶ms); 14 | 15 | } // namespace react 16 | } // namespace facebook 17 | -------------------------------------------------------------------------------- /examples/vue/.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | pnpm-debug.log* 8 | lerna-debug.log* 9 | 10 | node_modules 11 | .DS_Store 12 | dist 13 | dist-ssr 14 | coverage 15 | *.local 16 | 17 | /cypress/videos/ 18 | /cypress/screenshots/ 19 | 20 | # Editor directories and files 21 | .vscode/* 22 | !.vscode/extensions.json 23 | .idea 24 | *.suo 25 | *.ntvs* 26 | *.njsproj 27 | *.sln 28 | *.sw? 29 | 30 | *.tsbuildinfo 31 | -------------------------------------------------------------------------------- /examples/react-native/android/app/src/main/jni/OnLoad.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "MainApplicationTurboModuleManagerDelegate.h" 3 | #include "MainComponentsRegistry.h" 4 | 5 | JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *) { 6 | return facebook::jni::initialize(vm, [] { 7 | facebook::react::MainApplicationTurboModuleManagerDelegate:: 8 | registerNatives(); 9 | facebook::react::MainComponentsRegistry::registerNatives(); 10 | }); 11 | } 12 | -------------------------------------------------------------------------------- /examples/react/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 9 | 11 | Proton React App 12 | 13 | 14 | 15 |
16 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /examples/angular/src/app/app.component.ts: -------------------------------------------------------------------------------- 1 | import { Component } from '@angular/core'; 2 | import {HeaderComponent } from './components/header/header.component' 3 | import { TransferComponent } from './components/transfer/transfer.component'; 4 | 5 | @Component({ 6 | selector: 'app-root', 7 | imports: [HeaderComponent, TransferComponent], 8 | templateUrl: './app.component.html', 9 | standalone: true, 10 | }) 11 | export class AppComponent { 12 | title = 'Proton Angular App'; 13 | } 14 | -------------------------------------------------------------------------------- /examples/angular/tsconfig.app.json: -------------------------------------------------------------------------------- 1 | /* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */ 2 | /* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */ 3 | { 4 | "extends": "./tsconfig.json", 5 | "compilerOptions": { 6 | "outDir": "./out-tsc/app", 7 | "types": [] 8 | }, 9 | "files": [ 10 | "src/main.ts" 11 | ], 12 | "include": [ 13 | "src/**/*.d.ts" 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /examples/react-native/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 | -------------------------------------------------------------------------------- /examples/vue/tsconfig.node.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@tsconfig/node22/tsconfig.json", 3 | "include": [ 4 | "vite.config.*", 5 | "vitest.config.*", 6 | "cypress.config.*", 7 | "nightwatch.conf.*", 8 | "playwright.config.*", 9 | "eslint.config.*" 10 | ], 11 | "compilerOptions": { 12 | "noEmit": true, 13 | "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo", 14 | 15 | "module": "ESNext", 16 | "moduleResolution": "Bundler", 17 | "types": ["node"] 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /examples/angular/tsconfig.spec.json: -------------------------------------------------------------------------------- 1 | /* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */ 2 | /* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */ 3 | { 4 | "extends": "./tsconfig.json", 5 | "compilerOptions": { 6 | "outDir": "./out-tsc/spec", 7 | "types": [ 8 | "jasmine" 9 | ] 10 | }, 11 | "include": [ 12 | "src/**/*.spec.ts", 13 | "src/**/*.d.ts" 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /packages/proton-browser-transport/src/qrcode/8BitByte.ts: -------------------------------------------------------------------------------- 1 | import mode from './mode' 2 | 3 | export default class QR8bitByte { 4 | data 5 | mode 6 | constructor(data: any) { 7 | this.mode = mode.MODE_8BIT_BYTE 8 | this.data = data 9 | } 10 | getLength() { 11 | return this.data.length 12 | } 13 | 14 | write(buffer: {put: (_arg0: any, _arg1: number) => void}) { 15 | for (let i = 0; i < this.data.length; i++) { 16 | // not JIS ... 17 | buffer.put(this.data.charCodeAt(i), 8) 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /.changeset/README.md: -------------------------------------------------------------------------------- 1 | # Changesets 2 | 3 | Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works 4 | with multi-package repos, or single-package repos to help you version and publish your code. You can 5 | find the full documentation for it [in our repository](https://github.com/changesets/changesets) 6 | 7 | We have a quick list of common questions to get you started engaging with this project in 8 | [our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md) 9 | -------------------------------------------------------------------------------- /examples/react/README.md: -------------------------------------------------------------------------------- 1 | # Proton Web SDK - React Example 2 | 3 | Small boilerplate to get started with Proton on React 4 | 5 | ## Developing 6 | 7 | Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server: 8 | 9 | ```bash 10 | npm run dev 11 | 12 | # or start the server and open the app in a new browser tab 13 | npm run dev -- --open 14 | ``` 15 | 16 | ## Building 17 | 18 | To create a production version of your app: 19 | 20 | ```bash 21 | npm run build 22 | ``` 23 | -------------------------------------------------------------------------------- /examples/vue/vite.config.ts: -------------------------------------------------------------------------------- 1 | import { fileURLToPath, URL } from 'node:url' 2 | 3 | import { defineConfig } from 'vite' 4 | import vue from '@vitejs/plugin-vue' 5 | import vueDevTools from 'vite-plugin-vue-devtools' 6 | import tailwindcss from '@tailwindcss/vite' 7 | 8 | // https://vite.dev/config/ 9 | export default defineConfig({ 10 | plugins: [ 11 | tailwindcss(), 12 | vue(), 13 | vueDevTools(), 14 | ], 15 | resolve: { 16 | alias: { 17 | '@': fileURLToPath(new URL('./src', import.meta.url)) 18 | }, 19 | }, 20 | }) 21 | -------------------------------------------------------------------------------- /examples/react-native/ios/.xcode.env: -------------------------------------------------------------------------------- 1 | # This `.xcode.env` file is versioned and is used to source the environment 2 | # used when running script phases inside Xcode. 3 | # To customize your local environment, you can create an `.xcode.env.local` 4 | # file that is not versioned. 5 | 6 | # NODE_BINARY variable contains the PATH to the node executable. 7 | # 8 | # Customize the NODE_BINARY variable here. 9 | # For example, to use nvm with brew, add the following line 10 | # . "$(brew --prefix nvm)/nvm.sh" --no-use 11 | export NODE_BINARY=$(command -v node) 12 | -------------------------------------------------------------------------------- /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": "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/react/src/store/store.ts: -------------------------------------------------------------------------------- 1 | import { configureStore } from '@reduxjs/toolkit' 2 | import userReducer from './slices/user.slice' 3 | 4 | export const store = configureStore({ 5 | reducer: { 6 | user: userReducer, 7 | } 8 | }) 9 | 10 | // Get the type of our store variable 11 | export type AppStore = typeof store 12 | // Infer the `RootState` and `AppDispatch` types from the store itself 13 | export type RootState = ReturnType 14 | // Inferred type: {posts: PostsState, comments: CommentsState, users: UsersState} 15 | export type AppDispatch = AppStore['dispatch'] -------------------------------------------------------------------------------- /packages/proton-web-sdk/src/state.svelte.ts: -------------------------------------------------------------------------------- 1 | import type {WalletItem} from './types' 2 | 3 | export interface DialogProps { 4 | title?: string 5 | subtitle?: string 6 | show?: boolean 7 | appLogo?: string | null 8 | hasRoundedLogo?: boolean 9 | wallets?: WalletItem[] 10 | close: () => void 11 | select_wallet: (walletName: string) => void 12 | } 13 | 14 | export const DIALOG_STATE = $state({ 15 | title: '', 16 | subtitle: '', 17 | show: false, 18 | appLogo: '', 19 | hasRoundedLogo: false, 20 | wallets: [], 21 | close: () => {}, 22 | select_wallet: (_) => {}, 23 | }) 24 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "root", 3 | "private": true, 4 | "workspaces": [ 5 | "packages/*", 6 | "examples/*" 7 | ], 8 | "scripts": { 9 | "publish-packages": "turbo run build lint --filter=./packages/* && changeset version && changeset publish && pnpm i", 10 | "lint": "turbo run build lint", 11 | "build": "turbo run build", 12 | "dev": "turbo run watch --parallel" 13 | }, 14 | "devDependencies": { 15 | "@changesets/cli": "^2.25.0", 16 | "turbo": "^2.5.6" 17 | }, 18 | "engines": { 19 | "node": ">=18.0.0" 20 | }, 21 | "packageManager": "pnpm@10.21.0" 22 | } 23 | -------------------------------------------------------------------------------- /examples/react-native/android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /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-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 | -------------------------------------------------------------------------------- /examples/angular/src/app/components/avatar/avatar.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, inject } from '@angular/core'; 2 | import { UserService } from '../../services/user/user.service'; 3 | import { AsyncPipe } from '@angular/common'; 4 | 5 | @Component({ 6 | selector: 'app-avatar', 7 | imports: [AsyncPipe], 8 | templateUrl: './avatar.component.html', 9 | standalone: true, 10 | }) 11 | export class AvatarComponent { 12 | 13 | protected user = inject(UserService); 14 | protected actor$ = this.user.actor$; 15 | protected avatar$ = this.user.avatar$; 16 | 17 | login () { 18 | this.user.login() 19 | } 20 | 21 | logout () { 22 | this.user.logout() 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /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/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "downlevelIteration": true, 5 | "esModuleInterop": true, 6 | "experimentalDecorators": true, 7 | "importHelpers": true, 8 | "lib": [ 9 | "esnext", 10 | "dom" 11 | ], 12 | "module": "esnext", 13 | "moduleResolution": "node", 14 | "noImplicitAny": false, 15 | "sourceMap": true, 16 | "strict": true, 17 | "target": "es2020", 18 | "declarationDir": "./lib/types", 19 | "outDir": "./lib" 20 | }, 21 | "include": [ 22 | "src/*" 23 | ] 24 | } -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "baseUrl": "./", 4 | "paths": { 5 | "@proton/browser-transport": [ 6 | "proton-browser-transport" 7 | ], 8 | "@proton/link": [ 9 | "proton-link" 10 | ], 11 | "@proton/react-native-sdk": [ 12 | "proton-react-native-sdk" 13 | ], 14 | "@proton/signing-request": [ 15 | "proton-signing-request" 16 | ], 17 | "@proton/web-sdk": [ 18 | "proton-web-sdk" 19 | ], 20 | }, 21 | "downlevelIteration": true, 22 | "declaration": true, 23 | "esModuleInterop": true, 24 | "experimentalDecorators": true, 25 | "allowJs": true 26 | } 27 | } -------------------------------------------------------------------------------- /packages/proton-browser-transport/src/storage.ts: -------------------------------------------------------------------------------- 1 | import type {LinkStorage} from '@proton/link' 2 | 3 | export class Storage implements LinkStorage { 4 | // eslint-disable-next-line no-unused-vars 5 | constructor(readonly keyPrefix: string) {} 6 | async write(key: string, data: string): Promise { 7 | localStorage.setItem(this.storageKey(key), data) 8 | } 9 | async read(key: string): Promise { 10 | return localStorage.getItem(this.storageKey(key)) 11 | } 12 | async remove(key: string): Promise { 13 | localStorage.removeItem(this.storageKey(key)) 14 | } 15 | storageKey(key: string) { 16 | return `${this.keyPrefix}-${key}` 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /examples/react-native/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 | includeBuild('../node_modules/react-native-gradle-plugin') 5 | 6 | if (settings.hasProperty("newArchEnabled") && settings.newArchEnabled == "true") { 7 | include(":ReactAndroid") 8 | project(":ReactAndroid").projectDir = file('../node_modules/react-native/ReactAndroid') 9 | include(":ReactAndroid:hermes-engine") 10 | project(":ReactAndroid:hermes-engine").projectDir = file('../node_modules/react-native/ReactAndroid/hermes-engine') 11 | } 12 | -------------------------------------------------------------------------------- /examples/react-native/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-browser-transport/src/views/CountDown.svelte: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | 7 | 24 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /examples/svelte/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./.svelte-kit/tsconfig.json", 3 | "compilerOptions": { 4 | "allowJs": true, 5 | "checkJs": true, 6 | "esModuleInterop": true, 7 | "forceConsistentCasingInFileNames": true, 8 | "resolveJsonModule": true, 9 | "skipLibCheck": true, 10 | "sourceMap": true, 11 | "strict": true, 12 | "moduleResolution": "bundler" 13 | } 14 | // Path aliases are handled by https://svelte.dev/docs/kit/configuration#alias 15 | // except $lib which is handled by https://svelte.dev/docs/kit/configuration#files 16 | // 17 | // If you want to overwrite includes/excludes, make sure to copy over the relevant includes/excludes 18 | // from the referenced tsconfig.json - TypeScript does not merge them in 19 | } 20 | -------------------------------------------------------------------------------- /examples/svelte/README.md: -------------------------------------------------------------------------------- 1 | # Proton Web SDK - Svelte Example 2 | 3 | Small boilerplate to get started with Proton on Svelte 4 | 5 | ## Developing 6 | 7 | Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server: 8 | 9 | ```bash 10 | npm run dev 11 | 12 | # or start the server and open the app in a new browser tab 13 | npm run dev -- --open 14 | ``` 15 | 16 | ## Building 17 | 18 | To create a production version of your app: 19 | 20 | ```bash 21 | npm run build 22 | ``` 23 | 24 | You can preview the production build with `npm run preview`. 25 | 26 | > To deploy your app, you may need to install an [adapter](https://svelte.dev/docs/kit/adapters) for your target environment. 27 | -------------------------------------------------------------------------------- /examples/svelte/svelte.config.js: -------------------------------------------------------------------------------- 1 | import adapter from '@sveltejs/adapter-auto'; 2 | import { vitePreprocess } from '@sveltejs/vite-plugin-svelte'; 3 | 4 | /** @type {import('@sveltejs/kit').Config} */ 5 | const config = { 6 | // Consult https://svelte.dev/docs/kit/integrations 7 | // for more information about preprocessors 8 | preprocess: vitePreprocess(), 9 | 10 | kit: { 11 | // adapter-auto only supports some environments, see https://svelte.dev/docs/kit/adapter-auto for a list. 12 | // If your environment is not supported, or you settled on a specific environment, switch out the adapter. 13 | // See https://svelte.dev/docs/kit/adapters for more information about adapters. 14 | adapter: adapter() 15 | } 16 | }; 17 | 18 | export default config; 19 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /examples/react/tsconfig.node.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo", 4 | "target": "ES2022", 5 | "lib": ["ES2023"], 6 | "module": "ESNext", 7 | "skipLibCheck": true, 8 | 9 | /* Bundler mode */ 10 | "moduleResolution": "bundler", 11 | "allowImportingTsExtensions": true, 12 | "verbatimModuleSyntax": true, 13 | "moduleDetection": "force", 14 | "noEmit": true, 15 | 16 | /* Linting */ 17 | "strict": true, 18 | "noUnusedLocals": true, 19 | "noUnusedParameters": true, 20 | "erasableSyntaxOnly": true, 21 | "noFallthroughCasesInSwitch": true, 22 | "noUncheckedSideEffectImports": true 23 | }, 24 | "include": ["vite.config.ts"] 25 | } 26 | -------------------------------------------------------------------------------- /examples/angular/src/app/components/header/header.component.html: -------------------------------------------------------------------------------- 1 |
2 |
3 | 9 | 10 | 13 | 14 |
15 | 16 |
17 |
18 |
-------------------------------------------------------------------------------- /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": [ 10 | "dom", 11 | "es2020" 12 | ], 13 | "module": "es2020", 14 | "moduleResolution": "node", 15 | "noImplicitAny": false, 16 | "useDefineForClassFields": false, 17 | "sourceMap": true, 18 | "strict": true, 19 | "target": "es2020", 20 | "declarationDir": "./lib/types", 21 | "outDir": "./lib" 22 | }, 23 | "include": [ 24 | "src/**/*" 25 | ] 26 | } -------------------------------------------------------------------------------- /packages/proton-browser-transport/src/state.svelte.ts: -------------------------------------------------------------------------------- 1 | export interface DialogProps { 2 | show?: boolean 3 | showBackButton?: boolean 4 | walletType?: string 5 | title?: HTMLElement | string 6 | subtitle?: HTMLElement | string | null 7 | showFootnote?: boolean 8 | countDown?: string | null 9 | qrData?: {code: string; link: string} | null 10 | action?: {text: string; callback: () => void} | null 11 | back?: () => void 12 | close?: () => void 13 | } 14 | 15 | export const DIALOG_STATE = $state({ 16 | show: false, 17 | showBackButton: false, 18 | walletType: 'proton', 19 | title: '', 20 | subtitle: null, 21 | showFootnote: false, 22 | countDown: null, 23 | qrData: null, 24 | action: null, 25 | close: () => {}, 26 | back: () => {}, 27 | }) 28 | -------------------------------------------------------------------------------- /examples/react/tsconfig.app.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo", 4 | "target": "ES2020", 5 | "useDefineForClassFields": true, 6 | "lib": ["ES2020", "DOM", "DOM.Iterable"], 7 | "module": "ESNext", 8 | "skipLibCheck": true, 9 | 10 | /* Bundler mode */ 11 | "moduleResolution": "bundler", 12 | "allowImportingTsExtensions": true, 13 | "verbatimModuleSyntax": true, 14 | "moduleDetection": "force", 15 | "noEmit": true, 16 | "jsx": "react-jsx", 17 | 18 | /* Linting */ 19 | "strict": true, 20 | "noUnusedLocals": true, 21 | "noUnusedParameters": true, 22 | "erasableSyntaxOnly": true, 23 | "noFallthroughCasesInSwitch": true, 24 | "noUncheckedSideEffectImports": true 25 | }, 26 | "include": ["src"] 27 | } 28 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /examples/react-native/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 | -------------------------------------------------------------------------------- /examples/react/eslint.config.js: -------------------------------------------------------------------------------- 1 | import js from '@eslint/js' 2 | import globals from 'globals' 3 | import reactHooks from 'eslint-plugin-react-hooks' 4 | import reactRefresh from 'eslint-plugin-react-refresh' 5 | import tseslint from 'typescript-eslint' 6 | 7 | export default tseslint.config( 8 | { ignores: ['dist'] }, 9 | { 10 | extends: [js.configs.recommended, ...tseslint.configs.recommended], 11 | files: ['**/*.{ts,tsx}'], 12 | languageOptions: { 13 | ecmaVersion: 2020, 14 | globals: globals.browser, 15 | }, 16 | plugins: { 17 | 'react-hooks': reactHooks, 18 | 'react-refresh': reactRefresh, 19 | }, 20 | rules: { 21 | ...reactHooks.configs.recommended.rules, 22 | 'react-refresh/only-export-components': [ 23 | 'warn', 24 | { allowConstantExport: true }, 25 | ], 26 | }, 27 | }, 28 | ) 29 | -------------------------------------------------------------------------------- /packages/proton-browser-transport/src/qrcode/BitBuffer.ts: -------------------------------------------------------------------------------- 1 | export default class QRBitBuffer { 2 | buffer: number[] 3 | length: number 4 | constructor() { 5 | this.buffer = [] 6 | this.length = 0 7 | } 8 | get(index) { 9 | const bufIndex = Math.floor(index / 8) 10 | return ((this.buffer[bufIndex] >>> (7 - (index % 8))) & 1) == 1 11 | } 12 | 13 | put(num, length) { 14 | for (let i = 0; i < length; i++) { 15 | this.putBit(((num >>> (length - i - 1)) & 1) == 1) 16 | } 17 | } 18 | 19 | getLengthInBits() { 20 | return this.length 21 | } 22 | 23 | putBit(bit) { 24 | const bufIndex = Math.floor(this.length / 8) 25 | if (this.buffer.length <= bufIndex) { 26 | this.buffer.push(0) 27 | } 28 | 29 | if (bit) { 30 | this.buffer[bufIndex] |= 0x80 >>> this.length % 8 31 | } 32 | 33 | this.length++ 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /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-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 | -------------------------------------------------------------------------------- /examples/vue/eslint.config.ts: -------------------------------------------------------------------------------- 1 | import { globalIgnores } from 'eslint/config' 2 | import { defineConfigWithVueTs, vueTsConfigs } from '@vue/eslint-config-typescript' 3 | import pluginVue from 'eslint-plugin-vue' 4 | import skipFormatting from '@vue/eslint-config-prettier/skip-formatting' 5 | 6 | // To allow more languages other than `ts` in `.vue` files, uncomment the following lines: 7 | // import { configureVueProject } from '@vue/eslint-config-typescript' 8 | // configureVueProject({ scriptLangs: ['ts', 'tsx'] }) 9 | // More info at https://github.com/vuejs/eslint-config-typescript/#advanced-setup 10 | 11 | export default defineConfigWithVueTs( 12 | { 13 | name: 'app/files-to-lint', 14 | files: ['**/*.{ts,mts,tsx,vue}'], 15 | }, 16 | 17 | globalIgnores(['**/dist/**', '**/dist-ssr/**', '**/coverage/**']), 18 | 19 | pluginVue.configs['flat/essential'], 20 | vueTsConfigs.recommended, 21 | skipFormatting, 22 | ) 23 | -------------------------------------------------------------------------------- /packages/proton-browser-transport/src/types.ts: -------------------------------------------------------------------------------- 1 | export const SkipToManual = Symbol() 2 | 3 | export interface BrowserTransportOptions { 4 | /** Whether to display request success and error messages, defaults to true */ 5 | requestStatus?: boolean 6 | /** Requesting account of the dapp (optional) */ 7 | requestAccount?: string 8 | /** Wallet name e.g. proton, anchor, etc */ 9 | walletType?: string 10 | /** Local storage prefix, defaults to `proton-link`. */ 11 | storagePrefix?: string 12 | } 13 | 14 | export interface footNoteDownloadLinks { 15 | [key: string]: string 16 | } 17 | 18 | export interface DialogArgs { 19 | title: string | HTMLElement 20 | manual?: HTMLElement 21 | subtitle?: string | HTMLElement 22 | type?: string 23 | content?: Record 24 | action?: {text: string; callback: () => void} 25 | showFootnote?: boolean 26 | hideLogo?: boolean 27 | hideBackButton?: boolean 28 | } 29 | -------------------------------------------------------------------------------- /examples/react/src/components/Header.tsx: -------------------------------------------------------------------------------- 1 | import { Avatar } from "./Avatar"; 2 | import logo from '../assets/logo.svg' 3 | 4 | export const Header = () => ( 5 |
6 |
7 |
8 |
9 | Proton 10 | 15 |
16 | 17 | 20 | 21 |
22 | 23 |
24 |
25 |
26 |
27 | ) -------------------------------------------------------------------------------- /packages/proton-browser-transport/Makefile: -------------------------------------------------------------------------------- 1 | SRC_FILES := $(shell find src -name '*.ts' -or -name '*.svelte') 2 | BIN := ./node_modules/.bin 3 | 4 | all: lib 5 | 6 | lib: ${SRC_FILES} package.json tsconfig.json node_modules rollup.config.js 7 | @${BIN}/rollup -c && touch lib 8 | 9 | .PHONY: lint 10 | lint: node_modules 11 | @${BIN}/eslint src --ext .ts --fix 12 | 13 | .PHONY: publish 14 | publish: | distclean node_modules 15 | @git diff-index --quiet HEAD || (echo "Uncommitted changes, please commit first" && exit 1) 16 | @git fetch origin && git diff origin/master --quiet || (echo "Changes not pushed to origin, please push first" && exit 1) 17 | @yarn config set version-tag-prefix "" && yarn config set version-git-message "Version %s" 18 | @yarn publish && git push && git push --tags 19 | 20 | node_modules: 21 | yarn install --non-interactive --frozen-lockfile --ignore-scripts 22 | 23 | .PHONY: clean 24 | clean: 25 | rm -rf lib/ 26 | 27 | .PHONY: distclean 28 | distclean: clean 29 | rm -rf node_modules/ 30 | -------------------------------------------------------------------------------- /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 | "declaration": true, 17 | "declarationDir": "./lib/types", 18 | "verbatimModuleSyntax": true, 19 | "isolatedModules": true, 20 | /** 21 | To have warnings/errors of the Svelte compiler at the correct position, 22 | enable source maps by default. 23 | */ 24 | "sourceMap": true, 25 | "skipLibCheck": true, 26 | "forceConsistentCasingInFileNames": true, 27 | "outDir": "./lib" 28 | }, 29 | "include": [ 30 | "src/**/*" 31 | ] 32 | } -------------------------------------------------------------------------------- /packages/proton-browser-transport/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 | "declaration": true, 17 | "declarationDir": "./lib/types", 18 | "verbatimModuleSyntax": true, 19 | "isolatedModules": true, 20 | "outDir": "./lib", 21 | /** 22 | To have warnings/errors of the Svelte compiler at the correct position, 23 | enable source maps by default. 24 | */ 25 | "sourceMap": true, 26 | "skipLibCheck": true, 27 | "forceConsistentCasingInFileNames": true 28 | }, 29 | "include": [ 30 | "src/**/*" 31 | ] 32 | } -------------------------------------------------------------------------------- /examples/angular/src/app/components/transfer/transfer.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, inject } from '@angular/core'; 2 | import { FormControl, ReactiveFormsModule} from '@angular/forms'; 3 | import { UserService } from '../../services/user/user.service'; 4 | import { AsyncPipe } from '@angular/common'; 5 | 6 | @Component({ 7 | selector: 'app-transfer', 8 | imports: [ReactiveFormsModule, AsyncPipe], 9 | templateUrl: './transfer.component.html', 10 | standalone: true, 11 | host: { 12 | 'class': 'p-8 flex items-center justify-center bg-white' 13 | } 14 | }) 15 | export class TransferComponent { 16 | 17 | protected user = inject(UserService); 18 | protected actor$ = this.user.actor$; 19 | 20 | readonly toControl = new FormControl('', { nonNullable: true }); 21 | readonly amountControl = new FormControl('', { nonNullable: true }); 22 | 23 | async transfer () { 24 | await this.user.transfer( 25 | this.toControl.value, 26 | this.amountControl.value, 27 | ) 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /examples/angular/tsconfig.json: -------------------------------------------------------------------------------- 1 | /* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */ 2 | /* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */ 3 | { 4 | "compileOnSave": false, 5 | "compilerOptions": { 6 | "outDir": "./dist/out-tsc", 7 | "strict": true, 8 | "noImplicitOverride": true, 9 | "noPropertyAccessFromIndexSignature": true, 10 | "noImplicitReturns": true, 11 | "noFallthroughCasesInSwitch": true, 12 | "skipLibCheck": true, 13 | "isolatedModules": true, 14 | "esModuleInterop": true, 15 | "experimentalDecorators": true, 16 | "moduleResolution": "bundler", 17 | "importHelpers": true, 18 | "target": "ES2022", 19 | "module": "ES2022" 20 | }, 21 | "angularCompilerOptions": { 22 | "enableI18nLegacyMessageIdFormat": false, 23 | "strictInjectionParameters": true, 24 | "strictInputAccessModifiers": true, 25 | "strictTemplates": true 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /examples/vue/src/components/Header.vue: -------------------------------------------------------------------------------- 1 | 25 | 26 | -------------------------------------------------------------------------------- /examples/react/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "test-app-react", 3 | "private": true, 4 | "version": "4.3.0", 5 | "type": "module", 6 | "scripts": { 7 | "dev": "vite", 8 | "build": "tsc -b && vite build", 9 | "lint": "eslint .", 10 | "preview": "vite preview" 11 | }, 12 | "dependencies": { 13 | "@proton/js": "^28.0.0", 14 | "@proton/web-sdk": "workspace:^", 15 | "@reduxjs/toolkit": "^2.8.2", 16 | "@tailwindcss/vite": "^4.1.8", 17 | "react": "^19.1.0", 18 | "react-dom": "^19.1.0", 19 | "react-redux": "^9.2.0", 20 | "tailwindcss": "^4.1.8" 21 | }, 22 | "devDependencies": { 23 | "@eslint/js": "^9.25.0", 24 | "@types/react": "^19.1.2", 25 | "@types/react-dom": "^19.1.2", 26 | "@types/react-redux": "^7.1.34", 27 | "@vitejs/plugin-react": "^4.4.1", 28 | "eslint": "^9.25.0", 29 | "eslint-plugin-react-hooks": "^5.2.0", 30 | "eslint-plugin-react-refresh": "^0.4.19", 31 | "globals": "^16.0.0", 32 | "typescript": "~5.8.3", 33 | "typescript-eslint": "^8.30.1", 34 | "vite": "^6.3.5" 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /examples/react-native/android/app/src/main/jni/MainComponentsRegistry.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | namespace facebook { 9 | namespace react { 10 | 11 | class MainComponentsRegistry 12 | : public facebook::jni::HybridClass { 13 | public: 14 | // Adapt it to the package you used for your Java class. 15 | constexpr static auto kJavaDescriptor = 16 | "Lcom/example/newarchitecture/components/MainComponentsRegistry;"; 17 | 18 | static void registerNatives(); 19 | 20 | MainComponentsRegistry(ComponentFactory *delegate); 21 | 22 | private: 23 | static std::shared_ptr 24 | sharedProviderRegistry(); 25 | 26 | static jni::local_ref initHybrid( 27 | jni::alias_ref, 28 | ComponentFactory *delegate); 29 | }; 30 | 31 | } // namespace react 32 | } // namespace facebook 33 | -------------------------------------------------------------------------------- /examples/vue/README.md: -------------------------------------------------------------------------------- 1 | # vue 2 | 3 | This template should help get you started developing with Vue 3 in Vite. 4 | 5 | ## Recommended IDE Setup 6 | 7 | [VSCode](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur). 8 | 9 | ## Type Support for `.vue` Imports in TS 10 | 11 | TypeScript cannot handle type information for `.vue` imports by default, so we replace the `tsc` CLI with `vue-tsc` for type checking. In editors, we need [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) to make the TypeScript language service aware of `.vue` types. 12 | 13 | ## Customize configuration 14 | 15 | See [Vite Configuration Reference](https://vite.dev/config/). 16 | 17 | ## Project Setup 18 | 19 | ```sh 20 | npm install 21 | ``` 22 | 23 | ### Compile and Hot-Reload for Development 24 | 25 | ```sh 26 | npm run dev 27 | ``` 28 | 29 | ### Type-Check, Compile and Minify for Production 30 | 31 | ```sh 32 | npm run build 33 | ``` 34 | 35 | ### Lint with [ESLint](https://eslint.org/) 36 | 37 | ```sh 38 | npm run lint 39 | ``` 40 | -------------------------------------------------------------------------------- /packages/proton-browser-transport/src/qrcode/LICENSE-qrcode: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 Kazuhiko Arase 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | -------------------------------------------------------------------------------- /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/react-native/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 | -------------------------------------------------------------------------------- /examples/react-native/android/app/src/main/jni/MainApplicationModuleProvider.cpp: -------------------------------------------------------------------------------- 1 | #include "MainApplicationModuleProvider.h" 2 | 3 | #include 4 | #include 5 | 6 | namespace facebook { 7 | namespace react { 8 | 9 | std::shared_ptr MainApplicationModuleProvider( 10 | const std::string &moduleName, 11 | const JavaTurboModule::InitParams ¶ms) { 12 | // Here you can provide your own module provider for TurboModules coming from 13 | // either your application or from external libraries. The approach to follow 14 | // is similar to the following (for a library called `samplelibrary`: 15 | // 16 | // auto module = samplelibrary_ModuleProvider(moduleName, params); 17 | // if (module != nullptr) { 18 | // return module; 19 | // } 20 | // return rncore_ModuleProvider(moduleName, params); 21 | 22 | // Module providers autolinked by RN CLI 23 | auto rncli_module = rncli_ModuleProvider(moduleName, params); 24 | if (rncli_module != nullptr) { 25 | return rncli_module; 26 | } 27 | 28 | return rncore_ModuleProvider(moduleName, params); 29 | } 30 | 31 | } // namespace react 32 | } // namespace facebook 33 | -------------------------------------------------------------------------------- /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. -------------------------------------------------------------------------------- /examples/svelte/eslint.config.js: -------------------------------------------------------------------------------- 1 | import prettier from 'eslint-config-prettier'; 2 | import js from '@eslint/js'; 3 | import { includeIgnoreFile } from '@eslint/compat'; 4 | import svelte from 'eslint-plugin-svelte'; 5 | import globals from 'globals'; 6 | import { fileURLToPath } from 'node:url'; 7 | import ts from 'typescript-eslint'; 8 | import svelteConfig from './svelte.config.js'; 9 | 10 | const gitignorePath = fileURLToPath(new URL('./.gitignore', import.meta.url)); 11 | 12 | export default ts.config( 13 | includeIgnoreFile(gitignorePath), 14 | js.configs.recommended, 15 | ...ts.configs.recommended, 16 | ...svelte.configs.recommended, 17 | prettier, 18 | ...svelte.configs.prettier, 19 | { 20 | languageOptions: { 21 | globals: { ...globals.browser, ...globals.node } 22 | }, 23 | rules: { 'no-undef': 'off', 'svelte/valid-compile': ['error', { ignoreWarnings: true }] } 24 | }, 25 | { 26 | files: ['**/*.svelte', '**/*.svelte.ts', '**/*.svelte.js'], 27 | languageOptions: { 28 | parserOptions: { 29 | projectService: true, 30 | extraFileExtensions: ['.svelte'], 31 | parser: ts.parser, 32 | svelteConfig 33 | } 34 | } 35 | } 36 | ); 37 | -------------------------------------------------------------------------------- /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-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 | -------------------------------------------------------------------------------- /examples/react-native/.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 | ios/.xcode.env.local 24 | 25 | # Android/IntelliJ 26 | # 27 | build/ 28 | .idea 29 | .gradle 30 | local.properties 31 | *.iml 32 | *.hprof 33 | .cxx/ 34 | 35 | # node.js 36 | # 37 | node_modules/ 38 | npm-debug.log 39 | yarn-error.log 40 | 41 | # BUCK 42 | buck-out/ 43 | \.buckd/ 44 | *.keystore 45 | !debug.keystore 46 | 47 | # fastlane 48 | # 49 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 50 | # screenshots whenever they are needed. 51 | # For more information about the recommended setup visit: 52 | # https://docs.fastlane.tools/best-practices/source-control/ 53 | 54 | **/fastlane/report.xml 55 | **/fastlane/Preview.html 56 | **/fastlane/screenshots 57 | **/fastlane/test_output 58 | 59 | # Bundle artifact 60 | *.jsbundle 61 | 62 | # Ruby / CocoaPods 63 | /ios/Pods/ 64 | /vendor/bundle/ 65 | -------------------------------------------------------------------------------- /examples/vue/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "test-app-vue", 3 | "version": "4.3.0", 4 | "private": true, 5 | "type": "module", 6 | "scripts": { 7 | "dev": "vite", 8 | "build": "run-p type-check \"build-only {@}\" --", 9 | "preview": "vite preview", 10 | "build-only": "vite build", 11 | "type-check": "vue-tsc --build", 12 | "lint": "eslint . --fix", 13 | "format": "prettier --write src/" 14 | }, 15 | "dependencies": { 16 | "@proton/js": "^28.0.0", 17 | "@proton/web-sdk": "workspace:^", 18 | "@tailwindcss/vite": "^4.1.8", 19 | "pinia": "^3.0.1", 20 | "tailwindcss": "^4.1.8", 21 | "vue": "^3.5.13" 22 | }, 23 | "devDependencies": { 24 | "@tsconfig/node22": "^22.0.1", 25 | "@types/node": "^22.14.0", 26 | "@vitejs/plugin-vue": "^5.2.3", 27 | "@vue/eslint-config-prettier": "^10.2.0", 28 | "@vue/eslint-config-typescript": "^14.5.0", 29 | "@vue/tsconfig": "^0.7.0", 30 | "eslint": "^9.22.0", 31 | "eslint-plugin-vue": "~10.0.0", 32 | "jiti": "^2.4.2", 33 | "npm-run-all2": "^7.0.2", 34 | "prettier": "3.5.3", 35 | "typescript": "~5.8.0", 36 | "vite": "^6.2.4", 37 | "vite-plugin-vue-devtools": "^7.7.2", 38 | "vue-tsc": "^2.2.8" 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /packages/proton-react-native-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 && 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 | .PHONY: clean 27 | clean: 28 | rm -rf lib/ coverage/ docs/ 29 | 30 | .PHONY: distclean 31 | distclean: clean 32 | rm -rf node_modules/ 33 | -------------------------------------------------------------------------------- /packages/proton-web-sdk/src/views/Footer.svelte: -------------------------------------------------------------------------------- 1 | 25 | 26 | 46 | -------------------------------------------------------------------------------- /examples/svelte/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "svelte-demo-app", 3 | "private": true, 4 | "version": "4.3.0", 5 | "type": "module", 6 | "scripts": { 7 | "dev": "vite dev", 8 | "build": "vite build", 9 | "preview": "vite preview", 10 | "prepare": "svelte-kit sync || echo ''", 11 | "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json", 12 | "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch", 13 | "format": "prettier --write .", 14 | "lint": "prettier --check . && eslint ." 15 | }, 16 | "dependencies": { 17 | "@proton/js": "^28.0.0", 18 | "@proton/web-sdk": "workspace:^", 19 | "@tailwindcss/vite": "^4.1.8", 20 | "tailwindcss": "^4.1.8" 21 | }, 22 | "devDependencies": { 23 | "@eslint/compat": "^1.2.5", 24 | "@eslint/js": "^9.18.0", 25 | "@sveltejs/adapter-auto": "^6.0.0", 26 | "@sveltejs/kit": "^2.16.0", 27 | "@sveltejs/vite-plugin-svelte": "^5.0.0", 28 | "eslint": "^9.18.0", 29 | "eslint-config-prettier": "^10.0.1", 30 | "eslint-plugin-svelte": "^3.0.0", 31 | "globals": "^16.0.0", 32 | "prettier": "^3.4.2", 33 | "prettier-plugin-svelte": "^3.3.3", 34 | "svelte": "^5.0.0", 35 | "svelte-check": "^4.0.0", 36 | "typescript": "^5.0.0", 37 | "typescript-eslint": "^8.20.0", 38 | "vite": "^6.2.6" 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /examples/angular/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "test-angular-app", 3 | "version": "4.3.0", 4 | "scripts": { 5 | "ng": "ng", 6 | "start": "ng serve", 7 | "build": "ng build", 8 | "watch": "ng build --watch --configuration development", 9 | "test": "ng test" 10 | }, 11 | "private": true, 12 | "dependencies": { 13 | "@angular/common": "^19.2.0", 14 | "@angular/compiler": "^19.2.0", 15 | "@angular/core": "^19.2.0", 16 | "@angular/forms": "^19.2.0", 17 | "@angular/platform-browser": "^19.2.0", 18 | "@angular/platform-browser-dynamic": "^19.2.0", 19 | "@angular/router": "^19.2.0", 20 | "@proton/js": "^28.1.2", 21 | "@proton/web-sdk": "workspace:^", 22 | "@tailwindcss/postcss": "^4.1.8", 23 | "postcss": "^8.5.4", 24 | "rxjs": "~7.8.0", 25 | "tailwindcss": "^4.1.8", 26 | "tslib": "^2.3.0", 27 | "zone.js": "~0.15.0" 28 | }, 29 | "devDependencies": { 30 | "@angular-devkit/build-angular": "^19.2.14", 31 | "@angular/cli": "^19.2.14", 32 | "@angular/compiler-cli": "^19.2.0", 33 | "@types/jasmine": "~5.1.0", 34 | "jasmine-core": "~5.6.0", 35 | "karma": "~6.4.0", 36 | "karma-chrome-launcher": "~3.2.0", 37 | "karma-coverage": "~2.2.0", 38 | "karma-jasmine": "~5.1.0", 39 | "karma-jasmine-html-reporter": "~2.1.0", 40 | "typescript": "~5.7.2" 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /examples/react-native/android/app/src/main/jni/MainApplicationTurboModuleManagerDelegate.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | #include 6 | 7 | namespace facebook { 8 | namespace react { 9 | 10 | class MainApplicationTurboModuleManagerDelegate 11 | : public jni::HybridClass< 12 | MainApplicationTurboModuleManagerDelegate, 13 | TurboModuleManagerDelegate> { 14 | public: 15 | // Adapt it to the package you used for your Java class. 16 | static constexpr auto kJavaDescriptor = 17 | "Lcom/example/newarchitecture/modules/MainApplicationTurboModuleManagerDelegate;"; 18 | 19 | static jni::local_ref initHybrid(jni::alias_ref); 20 | 21 | static void registerNatives(); 22 | 23 | std::shared_ptr getTurboModule( 24 | const std::string &name, 25 | const std::shared_ptr &jsInvoker) override; 26 | std::shared_ptr getTurboModule( 27 | const std::string &name, 28 | const JavaTurboModule::InitParams ¶ms) override; 29 | 30 | /** 31 | * Test-only method. Allows user to verify whether a TurboModule can be 32 | * created by instances of this class. 33 | */ 34 | bool canCreateTurboModule(const std::string &name); 35 | }; 36 | 37 | } // namespace react 38 | } // namespace facebook 39 | -------------------------------------------------------------------------------- /examples/react-native/android/app/src/main/java/com/example/newarchitecture/components/MainComponentsRegistry.java: -------------------------------------------------------------------------------- 1 | package com.example.newarchitecture.components; 2 | 3 | import com.facebook.jni.HybridData; 4 | import com.facebook.proguard.annotations.DoNotStrip; 5 | import com.facebook.react.fabric.ComponentFactory; 6 | import com.facebook.soloader.SoLoader; 7 | 8 | /** 9 | * Class responsible to load the custom Fabric Components. This class has native methods and needs a 10 | * corresponding C++ implementation/header file to work correctly (already placed inside the jni/ 11 | * folder for you). 12 | * 13 | *

Please note that this class is used ONLY if you opt-in for the New Architecture (see the 14 | * `newArchEnabled` property). Is ignored otherwise. 15 | */ 16 | @DoNotStrip 17 | public class MainComponentsRegistry { 18 | static { 19 | SoLoader.loadLibrary("fabricjni"); 20 | } 21 | 22 | @DoNotStrip private final HybridData mHybridData; 23 | 24 | @DoNotStrip 25 | private native HybridData initHybrid(ComponentFactory componentFactory); 26 | 27 | @DoNotStrip 28 | private MainComponentsRegistry(ComponentFactory componentFactory) { 29 | mHybridData = initHybrid(componentFactory); 30 | } 31 | 32 | @DoNotStrip 33 | public static MainComponentsRegistry register(ComponentFactory componentFactory) { 34 | return new MainComponentsRegistry(componentFactory); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /examples/vue/src/stores/user.ts: -------------------------------------------------------------------------------- 1 | import { defineStore } from 'pinia' 2 | import type { RpcInterfaces } from '@proton/js' 3 | import * as SDK from '@/webSdk' 4 | 5 | export const useUserStore = defineStore('user', { 6 | state: () => ({ 7 | actor: '', 8 | permission: '', 9 | accountData: undefined as RpcInterfaces.UserInfo | undefined 10 | }), 11 | actions: { 12 | async login () { 13 | this.clear() 14 | await SDK.login() 15 | 16 | if (SDK.session) { 17 | if (SDK.session.auth) { 18 | this.actor = SDK.session.auth.actor.toString() 19 | this.permission = SDK.session.auth.permission.toString() 20 | this.accountData = await SDK.getProtonAvatar(this.actor) 21 | } 22 | } 23 | }, 24 | 25 | async reconnect () { 26 | this.clear() 27 | 28 | await SDK.reconnect() 29 | 30 | if (SDK.session && SDK.session.auth) { 31 | this.actor = SDK.session.auth.actor.toString() 32 | this.permission = SDK.session.auth.permission.toString() 33 | } 34 | }, 35 | 36 | async logout () { 37 | await SDK.logout() 38 | this.clear() 39 | }, 40 | 41 | async transfer ({ to, amount }: { to: string; amount: string; }) { 42 | await SDK.transfer({ to, amount }) 43 | }, 44 | 45 | clear() { 46 | this.actor = '' 47 | this.permission = '' 48 | } 49 | }, 50 | }) 51 | -------------------------------------------------------------------------------- /examples/react/public/vite.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/proton-browser-transport/src/qrcode/index.ts: -------------------------------------------------------------------------------- 1 | import ErrorCorrectLevel from './ErrorCorrectLevel' 2 | import QRCode from './QRCode' 3 | 4 | interface Rect { 5 | x: number 6 | y: number 7 | width: number 8 | height: number 9 | } 10 | 11 | /** 12 | * Generate QR SVG 13 | * @author Johan Nordberg 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[] = [``] 44 | for (const {x, y, width, height} of rects) { 45 | svg.push(``) 46 | } 47 | svg.push('') 48 | 49 | return 'data:image/svg+xml;base64,' + btoa(svg.join('')) 50 | } 51 | -------------------------------------------------------------------------------- /examples/react-native/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 13 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /examples/react-native/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "example", 3 | "version": "0.0.1", 4 | "private": true, 5 | "scripts": { 6 | "android": "react-native run-android", 7 | "ios": "react-native run-ios", 8 | "start": "react-native start", 9 | "test": "jest", 10 | "lint": "eslint . --ext .js,.jsx,.ts,.tsx" 11 | }, 12 | "dependencies": { 13 | "@proton/react-native-sdk": "workspace:^", 14 | "@react-native-async-storage/async-storage": "^2.2.0", 15 | "react": "18.1.0", 16 | "react-native": "0.70.10", 17 | "react-native-get-random-values": "^1.11.0" 18 | }, 19 | "devDependencies": { 20 | "@babel/core": "^7.12.9", 21 | "@babel/runtime": "^7.12.5", 22 | "@react-native-community/eslint-config": "^2.0.0", 23 | "@tsconfig/react-native": "^2.0.2", 24 | "@types/jest": "^26.0.23", 25 | "@types/react": "^18.0.21", 26 | "@types/react-native": "^0.70.6", 27 | "@types/react-test-renderer": "^18.0.0", 28 | "@typescript-eslint/eslint-plugin": "^5.37.0", 29 | "@typescript-eslint/parser": "^5.37.0", 30 | "babel-jest": "^26.6.3", 31 | "eslint": "^7.32.0", 32 | "jest": "^26.6.3", 33 | "metro-react-native-babel-preset": "0.72.3", 34 | "react-test-renderer": "18.1.0", 35 | "typescript": "^4.8.3" 36 | }, 37 | "jest": { 38 | "preset": "react-native", 39 | "moduleFileExtensions": [ 40 | "ts", 41 | "tsx", 42 | "js", 43 | "jsx", 44 | "json", 45 | "node" 46 | ] 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /examples/react-native/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 | -------------------------------------------------------------------------------- /examples/svelte/src/lib/userState.ts: -------------------------------------------------------------------------------- 1 | import { writable, get } from 'svelte/store'; 2 | import * as SDK from './webSdk'; 3 | import type { RpcInterfaces } from '@proton/js'; 4 | 5 | export const actor = writable(''); 6 | export const permission = writable(''); 7 | export const avatar = writable(''); 8 | 9 | const clear = () => { 10 | actor.set(''); 11 | permission.set(''); 12 | avatar.set(''); 13 | }; 14 | 15 | const getAvatar = (accountData: RpcInterfaces.UserInfo | undefined) => { 16 | const avatar = accountData && accountData.avatar; 17 | 18 | if (avatar) { 19 | if (avatar.indexOf('/9j/') !== -1) { 20 | return `data:image/jpeg;base64,${avatar}`; 21 | } else if (avatar.indexOf('iVBORw0KGgo') !== -1) { 22 | return `data:image/png;base64,${avatar}`; 23 | } 24 | } 25 | 26 | return 'https://explorer.xprnetwork.org/img/proton_avatar.png'; 27 | }; 28 | 29 | export const login = async (reconnect: boolean = false) => { 30 | 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 | actor.set(SDK.session!.auth.actor.toString()); 40 | permission.set(SDK.session!.auth.permission.toString()); 41 | 42 | const userInfo = await SDK.getProtonAvatar(get(actor)); 43 | avatar.set(getAvatar(userInfo)); 44 | } 45 | }; 46 | 47 | export const logout = async () => { 48 | await SDK.logout(); 49 | clear(); 50 | }; 51 | 52 | export const transfer = async ({ to, amount }: { to: string; amount: string }) => { 53 | await SDK.transfer({ 54 | to, 55 | amount 56 | }); 57 | }; 58 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /examples/react-native/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, '12.4' 5 | install! 'cocoapods', :deterministic_uuids => false 6 | 7 | target 'example' do 8 | config = use_native_modules! 9 | 10 | # Flags change depending on the env values. 11 | flags = get_default_flags() 12 | 13 | use_react_native!( 14 | :path => config[:reactNativePath], 15 | # Hermes is now enabled by default. Disable by setting this flag to false. 16 | # Upcoming versions of React Native may rely on get_default_flags(), but 17 | # we make it explicit here to aid in the React Native upgrade process. 18 | :hermes_enabled => true, 19 | :fabric_enabled => flags[:fabric_enabled], 20 | # Enables Flipper. 21 | # 22 | # Note that if you have use_frameworks! enabled, Flipper will not work and 23 | # you should disable the next line. 24 | :flipper_configuration => FlipperConfiguration.enabled, 25 | # An absolute path to your application root. 26 | :app_path => "#{Pod::Config.instance.installation_root}/.." 27 | ) 28 | 29 | target 'exampleTests' do 30 | inherit! :complete 31 | # Pods for testing 32 | end 33 | 34 | post_install do |installer| 35 | react_native_post_install( 36 | installer, 37 | # Set `mac_catalyst_enabled` to `true` in order to apply patches 38 | # necessary for Mac Catalyst builds 39 | :mac_catalyst_enabled => false 40 | ) 41 | __apply_Xcode_12_5_M1_post_install_workaround(installer) 42 | end 43 | end 44 | -------------------------------------------------------------------------------- /packages/proton-signing-request/eslint.config.ts: -------------------------------------------------------------------------------- 1 | import js from '@eslint/js' 2 | import globals from 'globals' 3 | import tseslint from 'typescript-eslint' 4 | import {defineConfig, globalIgnores} from 'eslint/config' 5 | import prettier from 'eslint-plugin-prettier/recommended' 6 | 7 | export default defineConfig([ 8 | globalIgnores(['lib/*', 'node_modules/**/*']), 9 | { 10 | files: ['**/*.{js,mjs,cjs,ts,mts,cts}'], 11 | plugins: {js}, 12 | extends: ['js/recommended'], 13 | languageOptions: { 14 | globals: {...globals.browser, ...globals.node, NodeJS: true}, 15 | parserOptions: { 16 | tsconfigRootDir: __dirname, 17 | }, 18 | }, 19 | }, 20 | tseslint.configs.recommended, 21 | prettier, 22 | { 23 | rules: { 24 | 'prettier/prettier': 'warn', 25 | 'no-console': 'warn', 26 | 27 | 'sort-imports': [ 28 | 'warn', 29 | { 30 | ignoreCase: true, 31 | ignoreDeclarationSort: true, 32 | }, 33 | ], 34 | '@typescript-eslint/explicit-module-boundary-types': 'off', 35 | '@typescript-eslint/no-explicit-any': 'off', 36 | '@typescript-eslint/no-namespace': 'off', 37 | '@typescript-eslint/no-non-null-assertion': 'off', 38 | '@typescript-eslint/no-empty-function': 'off', 39 | 'no-inner-declarations': 'off', 40 | 'no-unused-vars': [ 41 | 'warn', 42 | { 43 | argsIgnorePattern: '^_', 44 | }, 45 | ], 46 | '@typescript-eslint/no-unused-vars': [ 47 | 'warn', 48 | { 49 | argsIgnorePattern: '^_', 50 | }, 51 | ], 52 | }, 53 | } 54 | ]) 55 | -------------------------------------------------------------------------------- /packages/proton-react-native-sdk/eslint.config.ts: -------------------------------------------------------------------------------- 1 | import js from '@eslint/js' 2 | import globals from 'globals' 3 | import tseslint from 'typescript-eslint' 4 | import {defineConfig, globalIgnores} from 'eslint/config' 5 | import prettier from 'eslint-plugin-prettier/recommended' 6 | 7 | export default defineConfig([ 8 | globalIgnores(['lib/*', 'node_modules/**/*']), 9 | { 10 | files: ['**/*.{js,mjs,cjs,ts,mts,cts}'], 11 | plugins: {js}, 12 | extends: ['js/recommended'], 13 | languageOptions: { 14 | globals: {...globals.browser, ...globals.node, NodeJS: true}, 15 | parserOptions: { 16 | tsconfigRootDir: __dirname, 17 | }, 18 | }, 19 | }, 20 | tseslint.configs.recommended, 21 | prettier, 22 | { 23 | rules: { 24 | 'prettier/prettier': 'warn', 25 | 'no-console': 'warn', 26 | 27 | 'sort-imports': [ 28 | 'warn', 29 | { 30 | ignoreCase: true, 31 | ignoreDeclarationSort: true, 32 | }, 33 | ], 34 | '@typescript-eslint/explicit-module-boundary-types': 'off', 35 | '@typescript-eslint/no-explicit-any': 'off', 36 | '@typescript-eslint/no-namespace': 'off', 37 | '@typescript-eslint/no-non-null-assertion': 'off', 38 | '@typescript-eslint/no-empty-function': 'off', 39 | 'no-inner-declarations': 'off', 40 | 'no-unused-vars': [ 41 | 'warn', 42 | { 43 | argsIgnorePattern: '^_', 44 | }, 45 | ], 46 | '@typescript-eslint/no-unused-vars': [ 47 | 'warn', 48 | { 49 | argsIgnorePattern: '^_', 50 | }, 51 | ], 52 | }, 53 | } 54 | ]) 55 | -------------------------------------------------------------------------------- /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(request: SigningRequest, _cancel: (reason: string | Error) => void) { 23 | const deviceRequest = request.clone() 24 | deviceRequest.setInfoKey('same_device', true) 25 | deviceRequest.setInfoKey('return_path', this.getReturnUrl()) 26 | 27 | if (this.requestAccount.length > 0) { 28 | request.setInfoKey('req_account', this.requestAccount) 29 | deviceRequest.setInfoKey('req_account', this.requestAccount) 30 | } 31 | 32 | const sameDeviceUri = deviceRequest.encode(true, false) 33 | Linking.openURL(sameDeviceUri) 34 | } 35 | 36 | public onSessionRequest( 37 | _session: LinkSession, 38 | request: SigningRequest, 39 | _cancel: (reason: string | Error) => void 40 | ) { 41 | request.setInfoKey('return_path', this.getReturnUrl()) 42 | 43 | const scheme = request.getScheme() 44 | Linking.openURL(`${scheme}://link`) 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /examples/react-native/android/app/src/main/jni/MainApplicationTurboModuleManagerDelegate.cpp: -------------------------------------------------------------------------------- 1 | #include "MainApplicationTurboModuleManagerDelegate.h" 2 | #include "MainApplicationModuleProvider.h" 3 | 4 | namespace facebook { 5 | namespace react { 6 | 7 | jni::local_ref 8 | MainApplicationTurboModuleManagerDelegate::initHybrid( 9 | jni::alias_ref) { 10 | return makeCxxInstance(); 11 | } 12 | 13 | void MainApplicationTurboModuleManagerDelegate::registerNatives() { 14 | registerHybrid({ 15 | makeNativeMethod( 16 | "initHybrid", MainApplicationTurboModuleManagerDelegate::initHybrid), 17 | makeNativeMethod( 18 | "canCreateTurboModule", 19 | MainApplicationTurboModuleManagerDelegate::canCreateTurboModule), 20 | }); 21 | } 22 | 23 | std::shared_ptr 24 | MainApplicationTurboModuleManagerDelegate::getTurboModule( 25 | const std::string &name, 26 | const std::shared_ptr &jsInvoker) { 27 | // Not implemented yet: provide pure-C++ NativeModules here. 28 | return nullptr; 29 | } 30 | 31 | std::shared_ptr 32 | MainApplicationTurboModuleManagerDelegate::getTurboModule( 33 | const std::string &name, 34 | const JavaTurboModule::InitParams ¶ms) { 35 | return MainApplicationModuleProvider(name, params); 36 | } 37 | 38 | bool MainApplicationTurboModuleManagerDelegate::canCreateTurboModule( 39 | const std::string &name) { 40 | return getTurboModule(name, nullptr) != nullptr || 41 | getTurboModule(name, {.moduleName = name}) != nullptr; 42 | } 43 | 44 | } // namespace react 45 | } // namespace facebook 46 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /examples/angular/README.md: -------------------------------------------------------------------------------- 1 | # Proton Web SDK - Angular Example 2 | 3 | Small boilerplate to get started with Proton on Angular 4 | 5 | ## Development server 6 | 7 | To start a local development server, run: 8 | 9 | ```bash 10 | ng serve 11 | ``` 12 | 13 | Once the server is running, open your browser and navigate to `http://localhost:4200/`. The application will automatically reload whenever you modify any of the source files. 14 | 15 | ## Code scaffolding 16 | 17 | Angular CLI includes powerful code scaffolding tools. To generate a new component, run: 18 | 19 | ```bash 20 | ng generate component component-name 21 | ``` 22 | 23 | For a complete list of available schematics (such as `components`, `directives`, or `pipes`), run: 24 | 25 | ```bash 26 | ng generate --help 27 | ``` 28 | 29 | ## Building 30 | 31 | To build the project run: 32 | 33 | ```bash 34 | ng build 35 | ``` 36 | 37 | This will compile your project and store the build artifacts in the `dist/` directory. By default, the production build optimizes your application for performance and speed. 38 | 39 | ## Running unit tests 40 | 41 | To execute unit tests with the [Karma](https://karma-runner.github.io) test runner, use the following command: 42 | 43 | ```bash 44 | ng test 45 | ``` 46 | 47 | ## Running end-to-end tests 48 | 49 | For end-to-end (e2e) testing, run: 50 | 51 | ```bash 52 | ng e2e 53 | ``` 54 | 55 | Angular CLI does not come with an end-to-end testing framework by default. You can choose one that suits your needs. 56 | 57 | ## Additional Resources 58 | 59 | For more information on using the Angular CLI, including detailed command references, visit the [Angular CLI Overview and Command Reference](https://angular.dev/tools/cli) page. 60 | -------------------------------------------------------------------------------- /packages/proton-browser-transport/src/qrcode/Polynomial.ts: -------------------------------------------------------------------------------- 1 | import math from './math' 2 | 3 | export default class QRPolynomial { 4 | num: number[] 5 | constructor(num, shift) { 6 | if (num.length == undefined) { 7 | throw new Error(num.length + '/' + shift) 8 | } 9 | 10 | let offset = 0 11 | 12 | while (offset < num.length && num[offset] == 0) { 13 | offset++ 14 | } 15 | 16 | this.num = new Array(num.length - offset + shift) 17 | for (let i = 0; i < num.length - offset; i++) { 18 | this.num[i] = num[i + offset] 19 | } 20 | } 21 | 22 | get(index: string | number) { 23 | return this.num[index] 24 | } 25 | 26 | getLength() { 27 | return this.num.length 28 | } 29 | 30 | multiply(e: {getLength: () => number; get: (_: number) => any}) { 31 | const num = new Array(this.getLength() + e.getLength() - 1) 32 | 33 | for (let i = 0; i < this.getLength(); i++) { 34 | for (let j = 0; j < e.getLength(); j++) { 35 | num[i + j] ^= math.gexp(math.glog(this.get(i)) + math.glog(e.get(j))) 36 | } 37 | } 38 | 39 | return new QRPolynomial(num, 0) 40 | } 41 | 42 | mod(e: {getLength: () => number; get: (_: number) => any}) { 43 | if (this.getLength() - e.getLength() < 0) { 44 | return this 45 | } 46 | 47 | const ratio = math.glog(this.get(0)) - math.glog(e.get(0)) 48 | 49 | const num = new Array(this.getLength()) 50 | 51 | for (let i = 0; i < this.getLength(); i++) { 52 | num[i] = this.get(i) 53 | } 54 | 55 | for (let i = 0; i < e.getLength(); i++) { 56 | num[i] ^= math.gexp(math.glog(e.get(i)) + ratio) 57 | } 58 | 59 | // recursive call 60 | return new QRPolynomial(num, 0).mod(e) 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /packages/proton-web-sdk/src/types.ts: -------------------------------------------------------------------------------- 1 | import type {Link, LinkOptions, LinkSession, LinkStorage, 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 | } 58 | -------------------------------------------------------------------------------- /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-browser-transport/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-react-native-sdk/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | // see https://www.typescriptlang.org/tsconfig to better understand tsconfigs 4 | "include": [ 5 | "src", 6 | "types" 7 | ], 8 | "compilerOptions": { 9 | "module": "esnext", 10 | "lib": [ 11 | "dom", 12 | "esnext" 13 | ], 14 | "importHelpers": true, 15 | // output .d.ts declaration files for consumers 16 | "declaration": true, 17 | // output .js.map sourcemap files for consumers 18 | "sourceMap": true, 19 | // match output dir to input dir. e.g. dist/index instead of dist/src/index 20 | "rootDir": "./src", 21 | "declarationDir": "./lib/types", 22 | // stricter type-checking for stronger correctness. Recommended by TS 23 | "strict": true, 24 | // linter checks for common issues 25 | "noImplicitReturns": true, 26 | "noFallthroughCasesInSwitch": true, 27 | // noUnused* overlap with @typescript-eslint/no-unused-vars, can disable if duplicative 28 | "noUnusedLocals": true, 29 | "noUnusedParameters": true, 30 | // use Node's module resolution algorithm, instead of the legacy TS one 31 | "moduleResolution": "node", 32 | // transpile JSX to React.createElement 33 | "jsx": "react", 34 | // interop between ESM and CJS modules. Recommended by TS 35 | "esModuleInterop": true, 36 | // significant perf increase by skipping checking .d.ts files, particularly those in node_modules. Recommended by TS 37 | "skipLibCheck": true, 38 | // error out if import and file system have a casing mismatch. Recommended by TS 39 | "forceConsistentCasingInFileNames": true, 40 | // `tsdx build` ignores this option, but it is commonly used when type-checking separately with `tsc` 41 | "noEmit": true, 42 | "outDir": "./lib" 43 | } 44 | } -------------------------------------------------------------------------------- /packages/proton-web-sdk/src/views/Header.svelte: -------------------------------------------------------------------------------- 1 | 10 | 11 |

12 | {#if logo} 13 | {/if} 19 | {#if title}{title}{/if} 20 | {#if subtitle}{subtitle}{/if} 21 |
22 | 23 | 63 | -------------------------------------------------------------------------------- /examples/react-native/android/app/src/main/java/com/example/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.example; 2 | 3 | import com.facebook.react.ReactActivity; 4 | import com.facebook.react.ReactActivityDelegate; 5 | import com.facebook.react.ReactRootView; 6 | 7 | public class MainActivity extends ReactActivity { 8 | 9 | /** 10 | * Returns the name of the main component registered from JavaScript. This is used to schedule 11 | * rendering of the component. 12 | */ 13 | @Override 14 | protected String getMainComponentName() { 15 | return "example"; 16 | } 17 | 18 | /** 19 | * Returns the instance of the {@link ReactActivityDelegate}. There the RootView is created and 20 | * you can specify the renderer you wish to use - the new renderer (Fabric) or the old renderer 21 | * (Paper). 22 | */ 23 | @Override 24 | protected ReactActivityDelegate createReactActivityDelegate() { 25 | return new MainActivityDelegate(this, getMainComponentName()); 26 | } 27 | 28 | public static class MainActivityDelegate extends ReactActivityDelegate { 29 | public MainActivityDelegate(ReactActivity activity, String mainComponentName) { 30 | super(activity, mainComponentName); 31 | } 32 | 33 | @Override 34 | protected ReactRootView createRootView() { 35 | ReactRootView reactRootView = new ReactRootView(getContext()); 36 | // If you opted-in for the New Architecture, we enable the Fabric Renderer. 37 | reactRootView.setIsFabric(BuildConfig.IS_NEW_ARCHITECTURE_ENABLED); 38 | return reactRootView; 39 | } 40 | 41 | @Override 42 | protected boolean isConcurrentRootEnabled() { 43 | // If you opted-in for the New Architecture, we enable Concurrent Root (i.e. React 18). 44 | // More on this on https://reactjs.org/blog/2022/03/29/react-v18.html 45 | return BuildConfig.IS_NEW_ARCHITECTURE_ENABLED; 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /packages/proton-link/eslint.config.ts: -------------------------------------------------------------------------------- 1 | import js from '@eslint/js' 2 | import globals from 'globals' 3 | import tseslint from 'typescript-eslint' 4 | import {defineConfig, globalIgnores} from 'eslint/config' 5 | import prettier from 'eslint-plugin-prettier/recommended' 6 | 7 | export default defineConfig([ 8 | globalIgnores(['lib/*', 'node_modules/**/*']), 9 | { 10 | files: ['**/*.{js,mjs,cjs,ts,mts,cts}'], 11 | plugins: {js}, 12 | extends: ['js/recommended'], 13 | languageOptions: { 14 | globals: {...globals.browser, ...globals.node, NodeJS: true}, 15 | parserOptions: { 16 | tsconfigRootDir: __dirname, 17 | }, 18 | }, 19 | }, 20 | tseslint.configs.recommended, 21 | prettier, 22 | { 23 | rules: { 24 | 'prettier/prettier': 'warn', 25 | 'no-console': 'warn', 26 | 27 | 'sort-imports': [ 28 | 'warn', 29 | { 30 | ignoreCase: true, 31 | ignoreDeclarationSort: true, 32 | }, 33 | ], 34 | '@typescript-eslint/explicit-module-boundary-types': 'off', 35 | '@typescript-eslint/no-explicit-any': 'off', 36 | '@typescript-eslint/no-namespace': 'off', 37 | '@typescript-eslint/no-non-null-assertion': 'off', 38 | '@typescript-eslint/no-empty-function': 'off', 39 | 'no-inner-declarations': 'off', 40 | 'no-unused-vars': [ 41 | 'warn', 42 | { 43 | argsIgnorePattern: '^_', 44 | }, 45 | ], 46 | '@typescript-eslint/no-unused-vars': [ 47 | 'warn', 48 | { 49 | argsIgnorePattern: '^_', 50 | }, 51 | ], 52 | }, 53 | }, 54 | ]) 55 | -------------------------------------------------------------------------------- /examples/react-native/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 = "31.0.0" 6 | minSdkVersion = 21 7 | compileSdkVersion = 31 8 | targetSdkVersion = 31 9 | 10 | if (System.properties['os.arch'] == "aarch64") { 11 | // For M1 Users we need to use the NDK 24 which added support for aarch64 12 | ndkVersion = "24.0.8215888" 13 | } else { 14 | // Otherwise we default to the side-by-side NDK version from AGP. 15 | ndkVersion = "21.4.7075529" 16 | } 17 | } 18 | repositories { 19 | google() 20 | mavenCentral() 21 | } 22 | dependencies { 23 | classpath("com.android.tools.build:gradle:7.2.1") 24 | classpath("com.facebook.react:react-native-gradle-plugin") 25 | classpath("de.undercouch:gradle-download-task:5.0.1") 26 | // NOTE: Do not place your application dependencies here; they belong 27 | // in the individual module build.gradle files 28 | } 29 | } 30 | 31 | allprojects { 32 | repositories { 33 | maven { 34 | // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm 35 | url("$rootDir/../node_modules/react-native/android") 36 | } 37 | maven { 38 | // Android JSC is installed from npm 39 | url("$rootDir/../node_modules/jsc-android/dist") 40 | } 41 | mavenCentral { 42 | // We don't want to fetch react-native from Maven Central as there are 43 | // older versions over there. 44 | content { 45 | excludeGroup "com.facebook.react" 46 | } 47 | } 48 | google() 49 | maven { url 'https://www.jitpack.io' } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /examples/react/src/store/slices/user.slice.ts: -------------------------------------------------------------------------------- 1 | import type { RpcInterfaces } from '@proton/js'; 2 | import { createSlice, type PayloadAction } from '@reduxjs/toolkit' 3 | import type { RootState } from '../store'; 4 | 5 | // Define a type for the slice state 6 | interface UserState { 7 | actor: string; 8 | permission: string; 9 | accountData?: RpcInterfaces.UserInfo; 10 | } 11 | 12 | // Define the initial state using that type 13 | const initialState: UserState = { 14 | actor: '', 15 | permission: '', 16 | } 17 | 18 | export const userSlice = createSlice({ 19 | name: 'user', 20 | // `createSlice` will infer the state type from the `initialState` argument 21 | initialState, 22 | reducers: { 23 | setUser: (state, action: PayloadAction) => { 24 | 25 | state.actor = action.payload.actor; 26 | state.permission = action.payload.permission; 27 | state.accountData = action.payload.accountData ?? undefined 28 | console.log('setUser', state); 29 | }, 30 | clearUser: (state) => { 31 | userSlice.caseReducers.setUser(state, { type: 'setUser', payload: { actor: '', permission: '' }}) 32 | } 33 | } 34 | }) 35 | 36 | export const { setUser, clearUser } = userSlice.actions 37 | 38 | export const selectUser = (state: RootState) => state.user 39 | 40 | // Other code such as selectors can use the imported `RootState` type 41 | export const selectUserAvatar = ({ user }: RootState) => { 42 | 43 | const avatar = user.accountData && user.accountData.avatar 44 | 45 | if (avatar) { 46 | if (avatar.indexOf('/9j/') !== -1) { 47 | return `data:image/jpeg;base64,${avatar}` 48 | } else if (avatar.indexOf('iVBORw0KGgo') !== -1) { 49 | return `data:image/png;base64,${avatar}` 50 | } 51 | } 52 | 53 | return 'https://explorer.xprnetwork.org/img/proton_avatar.png' 54 | } 55 | 56 | export default userSlice.reducer -------------------------------------------------------------------------------- /examples/react-native/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: -Xmx512m -XX:MaxMetaspaceSize=256m 13 | org.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=512m 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.125.0 29 | 30 | # Use this property to specify which architecture you want to build. 31 | # You can also override it from the CLI using 32 | # ./gradlew -PreactNativeArchitectures=x86_64 33 | reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64 34 | 35 | # Use this property to enable support to the new architecture. 36 | # This will allow you to use TurboModules and the Fabric render in 37 | # your application. You should enable this flag either if you want 38 | # to write custom TurboModules/Fabric components OR use libraries that 39 | # are providing them. 40 | newArchEnabled=false 41 | -------------------------------------------------------------------------------- /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-link/examples/transact/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Proton Link - Transact 7 | 8 | 9 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /examples/react-native/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 | -------------------------------------------------------------------------------- /examples/svelte/src/lib/components/Avatar.svelte: -------------------------------------------------------------------------------- 1 | 9 | 10 |
11 | {#if $actor === ''} 12 |
login(false)} 14 | class="cursor-pointer whitespace-nowrap bg-purple-100 border border-transparent rounded-md py-2 px-4 inline-flex items-center justify-center text-base font-medium text-purple-600 hover:bg-purple-200" 15 | > 16 | Login 17 |
18 | {:else} 19 |
20 |
25 | 26 | 27 | 28 | {$actor} 29 | 30 | 31 | 48 |
49 |
50 | {/if} 51 |
52 | -------------------------------------------------------------------------------- /examples/react-native/android/app/src/main/java/com/example/newarchitecture/modules/MainApplicationTurboModuleManagerDelegate.java: -------------------------------------------------------------------------------- 1 | package com.example.newarchitecture.modules; 2 | 3 | import com.facebook.jni.HybridData; 4 | import com.facebook.react.ReactPackage; 5 | import com.facebook.react.ReactPackageTurboModuleManagerDelegate; 6 | import com.facebook.react.bridge.ReactApplicationContext; 7 | import com.facebook.soloader.SoLoader; 8 | import java.util.List; 9 | 10 | /** 11 | * Class responsible to load the TurboModules. This class has native methods and needs a 12 | * corresponding C++ implementation/header file to work correctly (already placed inside the jni/ 13 | * folder for you). 14 | * 15 | *

Please note that this class is used ONLY if you opt-in for the New Architecture (see the 16 | * `newArchEnabled` property). Is ignored otherwise. 17 | */ 18 | public class MainApplicationTurboModuleManagerDelegate 19 | extends ReactPackageTurboModuleManagerDelegate { 20 | 21 | private static volatile boolean sIsSoLibraryLoaded; 22 | 23 | protected MainApplicationTurboModuleManagerDelegate( 24 | ReactApplicationContext reactApplicationContext, List packages) { 25 | super(reactApplicationContext, packages); 26 | } 27 | 28 | protected native HybridData initHybrid(); 29 | 30 | native boolean canCreateTurboModule(String moduleName); 31 | 32 | public static class Builder extends ReactPackageTurboModuleManagerDelegate.Builder { 33 | protected MainApplicationTurboModuleManagerDelegate build( 34 | ReactApplicationContext context, List packages) { 35 | return new MainApplicationTurboModuleManagerDelegate(context, packages); 36 | } 37 | } 38 | 39 | @Override 40 | protected synchronized void maybeLoadOtherSoLibraries() { 41 | if (!sIsSoLibraryLoaded) { 42 | // If you change the name of your application .so file in the Android.mk file, 43 | // make sure you update the name here as well. 44 | SoLoader.loadLibrary("example_appmodules"); 45 | sIsSoLibraryLoaded = true; 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /examples/react-native/android/app/src/main/res/drawable/rn_edit_text_material.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 21 | 22 | 23 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /examples/svelte/src/lib/components/Transfer.svelte: -------------------------------------------------------------------------------- 1 | 7 | 8 |

9 |
10 |
11 | 12 |
13 | 22 |
23 |
24 | 25 |
26 | 27 |
28 | 36 |
37 |
38 |
39 | 40 |
41 | 49 |
50 |
51 | 52 |
53 |
transfer({ to, amount })} 56 | > 57 | Transfer 58 |
59 |
60 |
61 |
62 | -------------------------------------------------------------------------------- /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-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 | -------------------------------------------------------------------------------- /examples/react-native/webSdk.ts: -------------------------------------------------------------------------------- 1 | import ProtonRNSDK, {ProtonLink} from '@proton/react-native-sdk'; 2 | import type {LinkSession} from '@proton/react-native-sdk'; 3 | 4 | class ProtonSDK { 5 | chainId; 6 | endpoints; 7 | requestAccount; 8 | session: LinkSession | null | undefined; 9 | link: ProtonLink | null; 10 | 11 | constructor() { 12 | this.chainId = 13 | '71ee83bcf52142d61019d95f9cc5427ba6a0d7ff8accd9e2088ae2abeaf3d3dd'; 14 | this.endpoints = ['https://testnet.protonchain.com']; // Multiple for fault tolerance 15 | this.requestAccount = 'taskly'; // optional 16 | this.session = null; 17 | this.link = null; 18 | } 19 | 20 | login = async () => { 21 | const {session, link} = await ProtonRNSDK({ 22 | linkOptions: { 23 | chainId: this.chainId, 24 | endpoints: this.endpoints, 25 | }, 26 | transportOptions: { 27 | requestAccount: this.requestAccount, 28 | getReturnUrl: () => 'example://main', 29 | }, 30 | }); 31 | 32 | this.link = link; 33 | this.session = session; 34 | 35 | console.log('Auth: ', this.session?.auth); 36 | }; 37 | 38 | transfer = async () => { 39 | if (!this.session) { 40 | return; 41 | } 42 | 43 | return this.session.transact( 44 | { 45 | transaction: { 46 | actions: [ 47 | { 48 | account: 'eosio.token', 49 | name: 'transfer', 50 | authorization: [this.session.auth], 51 | data: { 52 | from: this.session.auth.actor, 53 | to: 'token.burn', 54 | quantity: '0.0001 XPR', 55 | memo: '', 56 | }, 57 | }, 58 | ], 59 | } as never, 60 | }, 61 | { 62 | broadcast: true, 63 | }, 64 | ); 65 | }; 66 | 67 | logout = async () => { 68 | if (this.link && this.session) { 69 | await this.link.removeSession(this.requestAccount, this.session.auth); 70 | 71 | this.link = null; 72 | this.session = undefined; 73 | } 74 | 75 | }; 76 | } 77 | 78 | export const sdk = new ProtonSDK(); 79 | -------------------------------------------------------------------------------- /examples/angular/src/app/components/avatar/avatar.component.html: -------------------------------------------------------------------------------- 1 | @if(actor$ | async; as actor) { 2 |
4 |
5 |
7 | 11 | 12 | 14 | {{ actor }} 15 | 16 | 17 | 32 |
33 |
34 |
35 | } @else { 36 |
39 | Login 40 |
41 | 42 | } -------------------------------------------------------------------------------- /packages/proton-react-native-sdk/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@proton/react-native-sdk", 3 | "author": "Metallicus", 4 | "module": "lib/react-native-sdk.m.js", 5 | "unpkg": "lib/react-native-sdk.bundle.js", 6 | "types": "lib/types/index.d.ts", 7 | "source": "src/index.ts", 8 | "version": "4.4.1", 9 | "license": "MIT", 10 | "main": "lib/react-native-sdk.js", 11 | "typings": "lib/types/index.d.ts", 12 | "type": "module", 13 | "files": [ 14 | "lib", 15 | "src" 16 | ], 17 | "engines": { 18 | "node": ">=10" 19 | }, 20 | "publishConfig": { 21 | "access": "public" 22 | }, 23 | "scripts": { 24 | "watch": "rollup -c -w", 25 | "prepare": "make", 26 | "build": "make", 27 | "lint": "make lint" 28 | }, 29 | "dependencies": { 30 | "@proton/js": "^28.1.2", 31 | "@proton/link": "workspace:^", 32 | "@proton/signing-request": "workspace:^", 33 | "@react-native-async-storage/async-storage": "^1.24.0", 34 | "buffer": "^6.0.3", 35 | "react-native": "^0.70.0", 36 | "react-native-get-random-values": "^1.11.0", 37 | "text-encoding-shim": "^1.0.5" 38 | }, 39 | "peerDependencies": { 40 | "react": "^18.0.0", 41 | "@react-native-async-storage/async-storage": "^1.24.0", 42 | "react-native-get-random-values": "^1.11.0" 43 | }, 44 | "gitHead": "e15e7e40cc610b4a7ceeaee75909ff6389d8f1e5", 45 | "devDependencies": { 46 | 47 | "@eslint/js": "^9.39.1", 48 | "@rollup/plugin-commonjs": "^28.0.3", 49 | "@rollup/plugin-json": "^6.1.0", 50 | "@rollup/plugin-node-resolve": "^16.0.1", 51 | "@rollup/plugin-replace": "^6.0.2", 52 | "@rollup/plugin-terser": "^0.4.4", 53 | "@rollup/plugin-typescript": "^12.1.2", 54 | "@types/node": "^16.4.0", 55 | "@types/react-native": "^0.70.0", 56 | "eslint": "^9.39.1", 57 | "eslint-config-prettier": "^10.1.8", 58 | "eslint-plugin-prettier": "^5.5.4", 59 | "globals": "^16.5.0", 60 | "jiti": "^2.6.1", 61 | "prettier": "^3.5.3", 62 | "rollup": "^4.40.0", 63 | "rollup-plugin-dts": "^6.2.1", 64 | "ts-node": "^10.0.0", 65 | "tslib": "^2.4.0", 66 | "typescript": "~5.4.0", 67 | "typescript-eslint": "^8.46.4" 68 | } 69 | } -------------------------------------------------------------------------------- /packages/proton-browser-transport/README.md: -------------------------------------------------------------------------------- 1 | # Proton Link - Browser Transport [![Package Version](https://img.shields.io/npm/v/@proton/browser-transport.svg?style=flat-square)](https://www.npmjs.com/package/@proton/browser-transport) ![License](https://img.shields.io/npm/l/@proton/browser-transport.svg?style=flat-square) 2 | 3 | A transport library for usage of [Proton Link](https://github.com/protonprotocol/proton-link) within a web browser environment. 4 | 5 | ## Basic usage 6 | 7 | A transport is required for Proton Link to communicate with clients. In most examples we use the browser transport with no configuration, like so: 8 | 9 | ```ts 10 | const transport = new ProtonBrowserTransport() 11 | const link = new ProtonLink({transport}) 12 | ``` 13 | 14 | Parameters can be passed to the transport during construction as an object, allowing for the following optional changes: 15 | 16 | ```ts 17 | const transport = new ProtonBrowserTransport({ 18 | /** Whether to display request success and error messages, defaults to true */ 19 | requestStatus: true, 20 | /** Local storage prefix, defaults to `proton-link`. */ 21 | storagePrefix: 'my-localstorage-prefix', 22 | /** 23 | * Whether to use Greymass Fuel for low resource accounts, defaults to false. 24 | * Note that this service is not available on all networks, and will automatically 25 | * determine based on chain id if it should be enabled or not. 26 | */ 27 | disableGreymassFuel: false, 28 | /** Referral account to use for Greymass Fuel. */ 29 | fuelReferrer: 'teamgreymass', 30 | }) 31 | const link = new ProtonLink({transport}) 32 | ``` 33 | 34 | ## Developing 35 | 36 | You need [Make](https://www.gnu.org/software/make/), [node.js](https://nodejs.org/en/) and [yarn](https://classic.yarnpkg.com/en/docs/install) installed. 37 | 38 | Clone the repository and run `make` to checkout all dependencies and build the project. See the [Makefile](./Makefile) for other useful targets. Before submitting a pull request make sure to run `make lint`. 39 | 40 | ## License 41 | 42 | [MIT](./LICENSE.md) 43 | 44 | --- 45 | 46 | Made with ☕️ & ❤️ by [Greymass](https://greymass.com), if you find this useful please consider [supporting us](https://greymass.com/support-us). 47 | -------------------------------------------------------------------------------- /examples/react-native/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( 38 | ^(RCTLogLevel level, RCTLogSource source, NSString *fileName, NSNumber *lineNumber, NSString *message) { 39 | if (level >= RCTLogLevelError) { 40 | redboxError = message; 41 | } 42 | }); 43 | #endif 44 | 45 | while ([date timeIntervalSinceNow] > 0 && !foundElement && !redboxError) { 46 | [[NSRunLoop mainRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; 47 | [[NSRunLoop mainRunLoop] runMode:NSRunLoopCommonModes beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; 48 | 49 | foundElement = [self findSubviewInView:vc.view 50 | matching:^BOOL(UIView *view) { 51 | if ([view.accessibilityLabel isEqualToString:TEXT_TO_LOOK_FOR]) { 52 | return YES; 53 | } 54 | return NO; 55 | }]; 56 | } 57 | 58 | #ifdef DEBUG 59 | RCTSetLogFunction(RCTDefaultLogFunction); 60 | #endif 61 | 62 | XCTAssertNil(redboxError, @"RedBox error: %@", redboxError); 63 | XCTAssertTrue(foundElement, @"Couldn't find element with text '%@' in %d seconds", TEXT_TO_LOOK_FOR, TIMEOUT_SECONDS); 64 | } 65 | 66 | @end 67 | -------------------------------------------------------------------------------- /packages/proton-web-sdk/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@proton/web-sdk", 3 | "version": "4.4.1", 4 | "license": "MIT", 5 | "author": "metallicus", 6 | "publishConfig": { 7 | "access": "public" 8 | }, 9 | "type": "module", 10 | "main": "lib/proton-web-sdk.js", 11 | "module": "lib/proton-web-sdk.m.js", 12 | "unpkg": "lib/proton-web-sdk.bundle.js", 13 | "types": "lib/types/proton-web-sdk.d.ts", 14 | "typings": "lib/types/index.d.ts", 15 | "source": "src/index.ts", 16 | "files": [ 17 | "lib", 18 | "src" 19 | ], 20 | "engines": { 21 | "node": ">=10" 22 | }, 23 | "scripts": { 24 | "watch": "rollup -c -w", 25 | "build": "make", 26 | "lint": "make lint", 27 | "prepare": "make", 28 | "size": "size-limit", 29 | "analyze": "size-limit --why" 30 | }, 31 | "dependencies": { 32 | "@greymass/eosio": "^0.6.1", 33 | "@proton/browser-transport": "workspace:^", 34 | "@proton/js": "^28.1.2", 35 | "@proton/link": "workspace:^" 36 | }, 37 | "gitHead": "d81cd76c8aacc2538243e24d0801b3eae4b8dba2", 38 | "devDependencies": { 39 | "@eslint/css": "^0.14.1", 40 | "@eslint/js": "^9.39.1", 41 | "@eslint/json": "^0.14.0", 42 | "@rollup/plugin-commonjs": "^28.0.3", 43 | "@rollup/plugin-json": "^6.1.0", 44 | "@rollup/plugin-node-resolve": "^16.0.1", 45 | "@rollup/plugin-replace": "^6.0.2", 46 | "@rollup/plugin-terser": "^0.4.4", 47 | "@rollup/plugin-typescript": "^12.1.2", 48 | "@tsconfig/svelte": "^5.0.4", 49 | "@types/node": "^16.4.0", 50 | "core-js": "^3.42.0", 51 | "eslint": "^9.39.1", 52 | "eslint-config-prettier": "^10.1.8", 53 | "eslint-plugin-prettier": "^5.5.4", 54 | "eslint-plugin-svelte": "^3.13.0", 55 | "globals": "^16.5.0", 56 | "jiti": "^2.6.1", 57 | "postcss": "^8.5.3", 58 | "prettier": "^3.5.3", 59 | "prettier-plugin-svelte": "^3.4.0", 60 | "rollup": "^4.40.0", 61 | "rollup-plugin-dts": "^6.2.1", 62 | "rollup-plugin-svelte": "^7.2.0", 63 | "sass": "^1.89.0", 64 | "svelte": "^5.41.0", 65 | "svelte-check": "^4.3.3", 66 | "svelte-eslint-parser": "^1.4.0", 67 | "svelte-preprocess": "^6.0.3", 68 | "ts-node": "^10.0.0", 69 | "tslib": "^2.4.0", 70 | "typescript": "~5.4.0", 71 | "typescript-eslint": "^8.46.4" 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /packages/proton-browser-transport/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@proton/browser-transport", 3 | "version": "4.4.1", 4 | "description": "Vanilla JS browser transport for Proton Link", 5 | "homepage": "https://github.com/protonprotocol/proton-browser-transport", 6 | "license": "BSD-3-Clause", 7 | "type": "module", 8 | "main": "lib/proton-browser-transport.js", 9 | "module": "lib/proton-browser-transport.m.js", 10 | "unpkg": "lib/proton-browser-transport.bundle.js", 11 | "types": "lib/types/proton-browser-transport.d.ts", 12 | "typings": "lib/types/index.d.ts", 13 | "publishConfig": { 14 | "access": "public" 15 | }, 16 | "scripts": { 17 | "watch": "rollup -c -w", 18 | "prepare": "make", 19 | "build": "make", 20 | "lint": "make lint" 21 | }, 22 | "files": [ 23 | "lib", 24 | "src" 25 | ], 26 | "dependencies": { 27 | "@proton/link": "workspace:^" 28 | }, 29 | "peerDependencies": { 30 | "@proton/link": "workspace:^" 31 | }, 32 | "devDependencies": { 33 | "@eslint/css": "^0.14.1", 34 | "@eslint/js": "^9.39.1", 35 | "@eslint/json": "^0.14.0", 36 | "@rollup/plugin-commonjs": "^28.0.3", 37 | "@rollup/plugin-json": "^6.1.0", 38 | "@rollup/plugin-node-resolve": "^16.0.1", 39 | "@rollup/plugin-replace": "^6.0.2", 40 | "@rollup/plugin-terser": "^0.4.4", 41 | "@rollup/plugin-typescript": "^12.1.2", 42 | "@tsconfig/svelte": "^5.0.4", 43 | "@types/node": "^16.4.0", 44 | "@types/ws": "^7.2.2", 45 | "core-js": "^3.42.0", 46 | "eslint": "^9.39.1", 47 | "eslint-config-prettier": "^10.1.8", 48 | "eslint-plugin-prettier": "^5.5.4", 49 | "eslint-plugin-svelte": "^3.13.0", 50 | "globals": "^16.5.0", 51 | "jiti": "^2.6.1", 52 | "postcss": "^8.5.3", 53 | "prettier": "^3.5.3", 54 | "prettier-plugin-svelte": "^3.4.0", 55 | "rollup": "^4.40.0", 56 | "rollup-plugin-dts": "^6.2.1", 57 | "rollup-plugin-svelte": "^7.2.0", 58 | "sass": "^1.89.0", 59 | "svelte": "^5.41.0", 60 | "svelte-check": "^4.3.3", 61 | "svelte-eslint-parser": "^1.4.0", 62 | "svelte-preprocess": "^6.0.3", 63 | "ts-node": "^10.0.0", 64 | "tslib": "^2.4.0", 65 | "typescript": "~5.4.0", 66 | "typescript-eslint": "^8.46.4" 67 | }, 68 | "gitHead": "d81cd76c8aacc2538243e24d0801b3eae4b8dba2" 69 | } 70 | -------------------------------------------------------------------------------- /packages/proton-web-sdk/eslint.config.ts: -------------------------------------------------------------------------------- 1 | import js from '@eslint/js' 2 | import globals from 'globals' 3 | import tseslint from 'typescript-eslint' 4 | import css from '@eslint/css' 5 | import {defineConfig, globalIgnores} from 'eslint/config' 6 | import svelte from 'eslint-plugin-svelte' 7 | import svelteparser from 'svelte-eslint-parser' 8 | import prettier from 'eslint-plugin-prettier/recommended' 9 | 10 | export default defineConfig([ 11 | globalIgnores(['lib/*', 'node_modules/**/*']), 12 | { 13 | files: ['**/*.{js,mjs,cjs,ts,mts,cts}'], 14 | plugins: {js}, 15 | extends: ['js/recommended'], 16 | languageOptions: { 17 | globals: {...globals.browser, ...globals.node, NodeJS: true}, 18 | parserOptions: { 19 | extraFileExtensions: ['.svelte'], 20 | tsconfigRootDir: __dirname, 21 | }, 22 | }, 23 | }, 24 | tseslint.configs.recommended, 25 | svelte.configs.recommended, 26 | prettier, 27 | svelte.configs.prettier, 28 | { 29 | files: ['**/*.svelte', '**/*.svelte.ts'], 30 | languageOptions: { 31 | parser: svelteparser, 32 | parserOptions: { 33 | parser: tseslint.parser, 34 | extraFileExtensions: ['.svelte'], 35 | }, 36 | }, 37 | }, 38 | { 39 | rules: { 40 | 'prettier/prettier': 'warn', 41 | 'no-console': 'warn', 42 | 43 | 'sort-imports': [ 44 | 'warn', 45 | { 46 | ignoreCase: true, 47 | ignoreDeclarationSort: true, 48 | }, 49 | ], 50 | '@typescript-eslint/explicit-module-boundary-types': 'off', 51 | '@typescript-eslint/no-explicit-any': 'off', 52 | '@typescript-eslint/no-namespace': 'off', 53 | '@typescript-eslint/no-non-null-assertion': 'off', 54 | '@typescript-eslint/no-empty-function': 'off', 55 | 'no-inner-declarations': 'off', 56 | 'no-unused-vars': [ 57 | 'warn', 58 | { 59 | argsIgnorePattern: '^_', 60 | }, 61 | ], 62 | '@typescript-eslint/no-unused-vars': [ 63 | 'warn', 64 | { 65 | argsIgnorePattern: '^_', 66 | }, 67 | ], 68 | }, 69 | }, 70 | {files: ['**/*.css'], plugins: {css}, language: 'css/css', extends: ['css/recommended']}, 71 | 72 | // {files: ['**/*.json'], plugins: {json}, language: 'json/json', extends: ['json/recommended']}, 73 | ]) 74 | -------------------------------------------------------------------------------- /packages/proton-browser-transport/eslint.config.ts: -------------------------------------------------------------------------------- 1 | import js from '@eslint/js' 2 | import globals from 'globals' 3 | import tseslint from 'typescript-eslint' 4 | import css from '@eslint/css' 5 | import {defineConfig, globalIgnores} from 'eslint/config' 6 | import svelte from 'eslint-plugin-svelte' 7 | import svelteparser from 'svelte-eslint-parser' 8 | import prettier from 'eslint-plugin-prettier/recommended' 9 | 10 | export default defineConfig([ 11 | globalIgnores(['lib/*', 'node_modules/**/*']), 12 | { 13 | files: ['**/*.{js,mjs,cjs,ts,mts,cts}'], 14 | plugins: {js}, 15 | extends: ['js/recommended'], 16 | languageOptions: { 17 | globals: {...globals.browser, ...globals.node, NodeJS: true}, 18 | parserOptions: { 19 | extraFileExtensions: ['.svelte'], 20 | tsconfigRootDir: __dirname, 21 | }, 22 | }, 23 | }, 24 | tseslint.configs.recommended, 25 | svelte.configs.recommended, 26 | prettier, 27 | svelte.configs.prettier, 28 | { 29 | files: ['**/*.svelte', '**/*.svelte.ts'], 30 | languageOptions: { 31 | parser: svelteparser, 32 | parserOptions: { 33 | parser: tseslint.parser, 34 | extraFileExtensions: ['.svelte'], 35 | }, 36 | }, 37 | }, 38 | { 39 | rules: { 40 | 'prettier/prettier': 'warn', 41 | 'no-console': 'warn', 42 | 43 | 'sort-imports': [ 44 | 'warn', 45 | { 46 | ignoreCase: true, 47 | ignoreDeclarationSort: true, 48 | }, 49 | ], 50 | '@typescript-eslint/explicit-module-boundary-types': 'off', 51 | '@typescript-eslint/no-explicit-any': 'off', 52 | '@typescript-eslint/no-namespace': 'off', 53 | '@typescript-eslint/no-non-null-assertion': 'off', 54 | '@typescript-eslint/no-empty-function': 'off', 55 | 'no-inner-declarations': 'off', 56 | 'no-unused-vars': [ 57 | 'warn', 58 | { 59 | argsIgnorePattern: '^_', 60 | }, 61 | ], 62 | '@typescript-eslint/no-unused-vars': [ 63 | 'warn', 64 | { 65 | argsIgnorePattern: '^_', 66 | }, 67 | ], 68 | }, 69 | }, 70 | {files: ['**/*.css'], plugins: {css}, language: 'css/css', extends: ['css/recommended']}, 71 | 72 | // {files: ['**/*.json'], plugins: {json}, language: 'json/json', extends: ['json/recommended']}, 73 | ]) 74 | -------------------------------------------------------------------------------- /examples/angular/src/app/services/user/user.service.ts: -------------------------------------------------------------------------------- 1 | import { inject, Injectable } from '@angular/core'; 2 | import { RpcInterfaces } from '@proton/js'; 3 | 4 | import { WebSdkService } from '../web-sdk/web-sdk.service'; 5 | import { from, map, of, ReplaySubject, shareReplay, switchMap } from 'rxjs'; 6 | 7 | @Injectable({ 8 | providedIn: 'root', 9 | }) 10 | export class UserService { 11 | readonly actor$ = new ReplaySubject(1); 12 | readonly permission$ = new ReplaySubject(1); 13 | 14 | readonly accountData$ = this.actor$.pipe( 15 | switchMap((actor) => { 16 | if (actor) { 17 | return from(this.sdk.getProtonAvatar(actor)); 18 | } 19 | return of(undefined); 20 | }), 21 | shareReplay({ 22 | bufferSize: 1, 23 | refCount: false, 24 | }) 25 | ); 26 | 27 | readonly avatar$ = this.accountData$.pipe( 28 | map((data) => this.getAvatar(data)), 29 | shareReplay({ 30 | bufferSize: 1, 31 | refCount: false, 32 | }) 33 | ); 34 | 35 | private sdk = inject(WebSdkService); 36 | 37 | constructor() { 38 | this.login(true); 39 | 40 | } 41 | 42 | async login(reconnect: boolean = false) { 43 | this.clear(); 44 | 45 | if (reconnect) { 46 | await this.sdk.reconnect(); 47 | } else { 48 | await this.sdk.login(); 49 | } 50 | 51 | if (this.sdk.session?.auth) { 52 | this.actor$.next(this.sdk.session.auth.actor.toString()); 53 | this.permission$.next(this.sdk.session.auth.permission.toString()); 54 | } 55 | } 56 | 57 | async logout() { 58 | await this.sdk.logout(); 59 | this.clear(); 60 | } 61 | 62 | async transfer(to: string, amount: string) { 63 | await this.sdk.transfer({ 64 | to: to, 65 | amount: amount, 66 | }); 67 | } 68 | 69 | private getAvatar(data?: RpcInterfaces.UserInfo): string { 70 | const avatar = data?.avatar; 71 | 72 | if (avatar) { 73 | if (avatar.indexOf('/9j/') !== -1) { 74 | return `data:image/jpeg;base64,${avatar}`; 75 | } else if (avatar.indexOf('iVBORw0KGgo') !== -1) { 76 | return `data:image/png;base64,${avatar}`; 77 | } 78 | } 79 | 80 | return 'https://explorer.xprnetwork.org/img/proton_avatar.png'; 81 | } 82 | 83 | private clear() { 84 | this.actor$.next(''); 85 | this.permission$.next(''); 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /examples/angular/src/app/components/transfer/transfer.component.html: -------------------------------------------------------------------------------- 1 |
2 | @let actor = actor$ | async; 3 | 4 |
5 | 7 |
8 | 16 |
17 |
18 | 19 |
20 | 22 |
23 | 29 |
30 |
31 |
32 | 34 |
35 | 41 |
42 |
43 | 44 |
45 | 51 |
52 |
-------------------------------------------------------------------------------- /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-react-native-sdk/rollup.config.js: -------------------------------------------------------------------------------- 1 | import {createRequire} from 'module' 2 | import fs from 'fs' 3 | import dts from 'rollup-plugin-dts' 4 | import typescript from '@rollup/plugin-typescript' 5 | import replace from '@rollup/plugin-replace' 6 | 7 | const pkg = createRequire(import.meta.url)('./package.json') 8 | const production = !process.env.ROLLUP_WATCH 9 | 10 | const license = fs.readFileSync('LICENSE').toString('utf-8').trim() 11 | const banner = ` 12 | /** 13 | * Proton React Native SDK v${pkg.version} 14 | * ${pkg.homepage} 15 | * 16 | * @license 17 | * ${license.replace(/\n/g, '\n * ')} 18 | */ 19 | `.trim() 20 | 21 | const replaceVersion = replace({ 22 | preventAssignment: true, 23 | __ver: pkg.version, 24 | }) 25 | 26 | export default [ 27 | { 28 | input: 'src/index.ts', 29 | output: { 30 | banner, 31 | file: pkg.main, 32 | format: 'cjs', 33 | sourcemap: !production, 34 | exports: 'named', 35 | }, 36 | plugins: [ 37 | replaceVersion, 38 | typescript({ 39 | sourceMap: !production, 40 | target: 'es6', 41 | }), 42 | ], 43 | external: Object.keys({...pkg.dependencies, ...pkg.peerDependencies}), 44 | onwarn, 45 | }, 46 | 47 | { 48 | input: 'src/index.ts', 49 | output: { 50 | banner, 51 | file: pkg.module, 52 | format: 'esm', 53 | sourcemap: !production, 54 | }, 55 | plugins: [ 56 | replaceVersion, 57 | typescript({ 58 | sourceMap: !production, 59 | target: 'es6', 60 | }), 61 | ], 62 | external: Object.keys({...pkg.dependencies, ...pkg.peerDependencies}), 63 | onwarn, 64 | }, 65 | 66 | { 67 | input: 'src/index.ts', 68 | output: {banner, file: pkg.types, format: 'esm'}, 69 | onwarn, 70 | plugins: [dts()], 71 | }, 72 | ] 73 | 74 | function onwarn(warning, rollupWarn) { 75 | if (warning.code === 'CIRCULAR_DEPENDENCY') { 76 | // unnecessary warning 77 | return 78 | } 79 | if ( 80 | warning.code === 'UNUSED_EXTERNAL_IMPORT' && 81 | warning.source === 'tslib' && 82 | warning.names[0] === '__read' 83 | ) { 84 | // when using ts with importHelpers: true rollup complains about this 85 | // seems safe to ignore since __read is not actually imported or used anywhere in the resulting bundles 86 | return 87 | } 88 | rollupWarn(warning) 89 | } 90 | -------------------------------------------------------------------------------- /packages/proton-signing-request/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@proton/signing-request", 3 | "version": "4.4.1", 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/proton-signing-request.js", 8 | "module": "lib/proton-signing-request.m.js", 9 | "unpkg": "lib/proton-signing-request.bundle.js", 10 | "types": "lib/types/proton-signing-request.d.ts", 11 | "sideEffects": false, 12 | "type": "module", 13 | "files": [ 14 | "lib", 15 | "src" 16 | ], 17 | "publishConfig": { 18 | "access": "public" 19 | }, 20 | "scripts": { 21 | "watch": "rollup -c -w", 22 | "prepare": "make", 23 | "build": "make", 24 | "lint": "make lint" 25 | }, 26 | "dependencies": { 27 | "@greymass/eosio": "^0.6.1" 28 | }, 29 | "devDependencies": { 30 | "@eslint/js": "^9.39.1", 31 | "@babel/plugin-transform-class-properties": "^7.27.1", 32 | "@babel/plugin-proposal-decorators": "^7.28.0", 33 | "@babel/preset-env": "^7.28.5", 34 | "@babel/preset-typescript": "^7.28.5", 35 | "@rollup/plugin-babel": "^6.1.0", 36 | "@rollup/plugin-commonjs": "^28.0.3", 37 | "@rollup/plugin-json": "^6.1.0", 38 | "@rollup/plugin-node-resolve": "^16.0.1", 39 | "@rollup/plugin-replace": "^6.0.2", 40 | "@rollup/plugin-terser": "^0.4.4", 41 | "@rollup/plugin-typescript": "^12.1.2", 42 | "@types/bn.js": "^5.1.0", 43 | "@types/mocha": "^9.1.1", 44 | "@types/node": "^16.4.0", 45 | "@typescript-eslint/eslint-plugin": "^8.33.0", 46 | "@typescript-eslint/parser": "^8.33.0", 47 | "core-js": "^3.42.0", 48 | "eslint": "^9.39.1", 49 | "eslint-config-prettier": "^10.1.8", 50 | "eslint-plugin-prettier": "^5.5.4", 51 | "globals": "^16.5.0", 52 | "jiti": "^2.6.1", 53 | "mocha": "^9.2.2", 54 | "node-fetch": "^2.6.0", 55 | "nyc": "^15.1.0", 56 | "prettier": "^3.5.3", 57 | "rollup": "^4.40.0", 58 | "rollup-plugin-dts": "^6.2.1", 59 | "rollup-plugin-polyfill-node": "^0.13.0", 60 | "ts-node": "^10.0.0", 61 | "tslib": "^2.4.0", 62 | "typescript": "~5.4.0", 63 | "typescript-eslint": "^8.46.4" 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /examples/react-native/android/app/src/main/jni/MainComponentsRegistry.cpp: -------------------------------------------------------------------------------- 1 | #include "MainComponentsRegistry.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | namespace facebook { 10 | namespace react { 11 | 12 | MainComponentsRegistry::MainComponentsRegistry(ComponentFactory *delegate) {} 13 | 14 | std::shared_ptr 15 | MainComponentsRegistry::sharedProviderRegistry() { 16 | auto providerRegistry = CoreComponentsRegistry::sharedProviderRegistry(); 17 | 18 | // Autolinked providers registered by RN CLI 19 | rncli_registerProviders(providerRegistry); 20 | 21 | // Custom Fabric Components go here. You can register custom 22 | // components coming from your App or from 3rd party libraries here. 23 | // 24 | // providerRegistry->add(concreteComponentDescriptorProvider< 25 | // AocViewerComponentDescriptor>()); 26 | return providerRegistry; 27 | } 28 | 29 | jni::local_ref 30 | MainComponentsRegistry::initHybrid( 31 | jni::alias_ref, 32 | ComponentFactory *delegate) { 33 | auto instance = makeCxxInstance(delegate); 34 | 35 | auto buildRegistryFunction = 36 | [](EventDispatcher::Weak const &eventDispatcher, 37 | ContextContainer::Shared const &contextContainer) 38 | -> ComponentDescriptorRegistry::Shared { 39 | auto registry = MainComponentsRegistry::sharedProviderRegistry() 40 | ->createComponentDescriptorRegistry( 41 | {eventDispatcher, contextContainer}); 42 | 43 | auto mutableRegistry = 44 | std::const_pointer_cast(registry); 45 | 46 | mutableRegistry->setFallbackComponentDescriptor( 47 | std::make_shared( 48 | ComponentDescriptorParameters{ 49 | eventDispatcher, contextContainer, nullptr})); 50 | 51 | return registry; 52 | }; 53 | 54 | delegate->buildRegistryFunction = buildRegistryFunction; 55 | return instance; 56 | } 57 | 58 | void MainComponentsRegistry::registerNatives() { 59 | registerHybrid({ 60 | makeNativeMethod("initHybrid", MainComponentsRegistry::initHybrid), 61 | }); 62 | } 63 | 64 | } // namespace react 65 | } // namespace facebook 66 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /examples/vue/src/components/Transfer.vue: -------------------------------------------------------------------------------- 1 | 52 | 53 | -------------------------------------------------------------------------------- /examples/react-native/App.tsx: -------------------------------------------------------------------------------- 1 | /** 2 | * Sample React Native App 3 | * https://github.com/facebook/react-native 4 | * 5 | * Generated with the TypeScript template 6 | * https://github.com/react-native-community/react-native-template-typescript 7 | * 8 | * @format 9 | */ 10 | 11 | import React, {useState} from 'react'; 12 | import { 13 | Button, 14 | SafeAreaView, 15 | ScrollView, 16 | StatusBar, 17 | StyleSheet, 18 | Text, 19 | useColorScheme, 20 | View, 21 | } from 'react-native'; 22 | 23 | import {Colors, Header} from 'react-native/Libraries/NewAppScreen'; 24 | import {sdk} from './webSdk'; 25 | 26 | const App = () => { 27 | const [auth, setAuth] = useState({}); 28 | 29 | const isDarkMode = useColorScheme() === 'dark'; 30 | 31 | const backgroundStyle = { 32 | backgroundColor: isDarkMode ? Colors.darker : Colors.lighter, 33 | }; 34 | 35 | return ( 36 | 37 | 41 | 44 |
45 | 49 | Proton SDK example 50 | Auth: {JSON.stringify(auth)} 51 | 52 | {Object.keys(auth).length > 0 ? ( 53 | <> 54 |