From 5196c78f794aebdc26b9fba8dc6faee669d34252 Mon Sep 17 00:00:00 2001 From: Fabian Bormann Date: Wed, 30 Nov 2022 19:54:52 +0100 Subject: [PATCH 01/17] feat: add cip-0078 including a demo folder --- CIP-0078/README.md | 218 + CIP-0078/demo/README.md | 28 + CIP-0078/demo/dApp.html | 51 + CIP-0078/demo/ionic-app/.gitignore | 31 + CIP-0078/demo/ionic-app/capacitor.config.ts | 10 + CIP-0078/demo/ionic-app/config/env.js | 104 + .../demo/ionic-app/config/getHttpsConfig.js | 66 + .../ionic-app/config/jest/babelTransform.js | 29 + .../ionic-app/config/jest/cssTransform.js | 14 + .../ionic-app/config/jest/fileTransform.js | 40 + CIP-0078/demo/ionic-app/config/modules.js | 134 + CIP-0078/demo/ionic-app/config/paths.js | 77 + .../demo/ionic-app/config/webpack.config.js | 769 + .../persistentCache/createEnvironmentHash.js | 9 + .../config/webpackDevServer.config.js | 127 + CIP-0078/demo/ionic-app/ionic.config.json | 7 + CIP-0078/demo/ionic-app/package-lock.json | 31140 ++++++++++++++++ CIP-0078/demo/ionic-app/package.json | 183 + .../ionic-app/public/assets/icon/favicon.png | Bin 0 -> 930 bytes .../ionic-app/public/assets/icon/icon.png | Bin 0 -> 23794 bytes .../demo/ionic-app/public/assets/shapes.svg | 1 + CIP-0078/demo/ionic-app/public/index.html | 31 + CIP-0078/demo/ionic-app/public/manifest.json | 21 + CIP-0078/demo/ionic-app/scripts/build.js | 217 + CIP-0078/demo/ionic-app/scripts/start.js | 154 + CIP-0078/demo/ionic-app/scripts/test.js | 52 + CIP-0078/demo/ionic-app/src/App.test.tsx | 8 + CIP-0078/demo/ionic-app/src/App.tsx | 76 + CIP-0078/demo/ionic-app/src/bugout.d.ts | 53 + .../src/components/ExploreContainer.css | 24 + .../src/components/ExploreContainer.tsx | 16 + CIP-0078/demo/ionic-app/src/index.tsx | 50 + CIP-0078/demo/ionic-app/src/pages/Tab1.css | 0 CIP-0078/demo/ionic-app/src/pages/Tab1.tsx | 25 + CIP-0078/demo/ionic-app/src/pages/Tab2.css | 0 CIP-0078/demo/ionic-app/src/pages/Tab2.tsx | 25 + CIP-0078/demo/ionic-app/src/pages/Tab3.css | 0 CIP-0078/demo/ionic-app/src/pages/Tab3.tsx | 25 + .../demo/ionic-app/src/react-app-env.d.ts | 71 + .../demo/ionic-app/src/reportWebVitals.ts | 15 + CIP-0078/demo/ionic-app/src/service-worker.ts | 80 + .../src/serviceWorkerRegistration.ts | 142 + CIP-0078/demo/ionic-app/src/setupTests.ts | 14 + .../demo/ionic-app/src/theme/variables.css | 236 + CIP-0078/demo/ionic-app/tsconfig.json | 26 + 45 files changed, 34399 insertions(+) create mode 100644 CIP-0078/README.md create mode 100644 CIP-0078/demo/README.md create mode 100644 CIP-0078/demo/dApp.html create mode 100644 CIP-0078/demo/ionic-app/.gitignore create mode 100644 CIP-0078/demo/ionic-app/capacitor.config.ts create mode 100644 CIP-0078/demo/ionic-app/config/env.js create mode 100644 CIP-0078/demo/ionic-app/config/getHttpsConfig.js create mode 100644 CIP-0078/demo/ionic-app/config/jest/babelTransform.js create mode 100644 CIP-0078/demo/ionic-app/config/jest/cssTransform.js create mode 100644 CIP-0078/demo/ionic-app/config/jest/fileTransform.js create mode 100644 CIP-0078/demo/ionic-app/config/modules.js create mode 100644 CIP-0078/demo/ionic-app/config/paths.js create mode 100644 CIP-0078/demo/ionic-app/config/webpack.config.js create mode 100644 CIP-0078/demo/ionic-app/config/webpack/persistentCache/createEnvironmentHash.js create mode 100644 CIP-0078/demo/ionic-app/config/webpackDevServer.config.js create mode 100644 CIP-0078/demo/ionic-app/ionic.config.json create mode 100644 CIP-0078/demo/ionic-app/package-lock.json create mode 100644 CIP-0078/demo/ionic-app/package.json create mode 100644 CIP-0078/demo/ionic-app/public/assets/icon/favicon.png create mode 100644 CIP-0078/demo/ionic-app/public/assets/icon/icon.png create mode 100644 CIP-0078/demo/ionic-app/public/assets/shapes.svg create mode 100644 CIP-0078/demo/ionic-app/public/index.html create mode 100644 CIP-0078/demo/ionic-app/public/manifest.json create mode 100644 CIP-0078/demo/ionic-app/scripts/build.js create mode 100644 CIP-0078/demo/ionic-app/scripts/start.js create mode 100644 CIP-0078/demo/ionic-app/scripts/test.js create mode 100644 CIP-0078/demo/ionic-app/src/App.test.tsx create mode 100644 CIP-0078/demo/ionic-app/src/App.tsx create mode 100644 CIP-0078/demo/ionic-app/src/bugout.d.ts create mode 100644 CIP-0078/demo/ionic-app/src/components/ExploreContainer.css create mode 100644 CIP-0078/demo/ionic-app/src/components/ExploreContainer.tsx create mode 100644 CIP-0078/demo/ionic-app/src/index.tsx create mode 100644 CIP-0078/demo/ionic-app/src/pages/Tab1.css create mode 100644 CIP-0078/demo/ionic-app/src/pages/Tab1.tsx create mode 100644 CIP-0078/demo/ionic-app/src/pages/Tab2.css create mode 100644 CIP-0078/demo/ionic-app/src/pages/Tab2.tsx create mode 100644 CIP-0078/demo/ionic-app/src/pages/Tab3.css create mode 100644 CIP-0078/demo/ionic-app/src/pages/Tab3.tsx create mode 100644 CIP-0078/demo/ionic-app/src/react-app-env.d.ts create mode 100644 CIP-0078/demo/ionic-app/src/reportWebVitals.ts create mode 100644 CIP-0078/demo/ionic-app/src/service-worker.ts create mode 100644 CIP-0078/demo/ionic-app/src/serviceWorkerRegistration.ts create mode 100644 CIP-0078/demo/ionic-app/src/setupTests.ts create mode 100644 CIP-0078/demo/ionic-app/src/theme/variables.css create mode 100644 CIP-0078/demo/ionic-app/tsconfig.json diff --git a/CIP-0078/README.md b/CIP-0078/README.md new file mode 100644 index 0000000000..8c308495e1 --- /dev/null +++ b/CIP-0078/README.md @@ -0,0 +1,218 @@ +--- +CIP: 78 +Title: Decentralized WebRTC dApp/Wallet Communication Using WebTorrent Tracker for Peer Discovery +Authors: Fabian Bormann , Jaime Caso +Comments-Summary: No comments yet +Comments-URI: https://github.com/CardanoFoundation/CIPs/pulls/ +Status: Draft +Type: Standards +Created: 2022-11-29 +License: CC-BY-4.0 +--- + +# Abstract + +In a decentralized ecosystem a communication between wallet apps and dApps is still challanging. The inter-app communication on mobile devices does not directly allow remote procedure calls and is mostly resticed to Universal Links (iOS) or Deeplinks (Android). State-of-the-art solutions like WalletConnect tackle these problems using WebRTC communication which also works across devices, but requires a central signaling server (STUN or TURN server) to estalblish a WebRTC connection. In this CIP we want to introduce an architecture which uses WebTorrent trackers for peer discovery to remove the need of this central component. + +# Architecture + +## Establish a WebRTC Connection Using a STUN/TURN Server + +```mermaid +sequenceDiagram + dApp-->>+TURN/STUN: Who am I? + TURN/STUN-->>dApp: You are + Wallet-->>+TURN/STUN: Who am I? + TURN/STUN-->>Wallet: You are + dApp->>Wallet: messages + Wallet->>dApp: messages +``` + +The data will be send peer to peer via a WebRTC data channel once the ip discovery has been finished. E.g. WalletConnect expects/provides a relay server URL to initialize the connection. While this method allows dApps to communitcate peer-to-peer with wallets it also leads to a [possible SPOF](https://twitter.com/walletconnect/status/1407279853943001088?lang=en). + +## Establish a WebRTC Connection Using WebTorrent Tracker + +```mermaid +flowchart LR + subgraph dApp + subgraph .torrent server + end + end + + subgraph Wallet[Wallet App] + end + + dApp-->|.torrent| TrackerA[Tracker 1] + dApp-->|.torrent| TrackerB[Tracker 2] + dApp-->|.torrent| TrackerC[...] + dApp-->|.torrent| TrackerD[Tracker n] + + dApp-->|.torrent| TrackerA[Tracker 1] + dApp-->|.torrent| TrackerB[Tracker 2] + dApp-->|.torrent| TrackerC[...] + dApp-->|.torrent| TrackerD[Tracker n] + + dApp-->|Share public key| Wallet +``` + +Deeplinks, Universal Links or even a QR code could be used to share the public key. The wallet app would query a list of trackers using the public key to establish the WebRTC connection. Once this is done, the data is sent peer-to-peer via the WebRTC standard (e.g. to invoke RPC calls). + +```mermaid +flowchart LR + Wallet-->|queries| TrackerA[Tracker 1] + Wallet-->|queries| TrackerB[Tracker 2] + Wallet-->|queries| TrackerC[...] + Wallet-->|queries| TrackerD[Tracker n] + + Wallet-->|queries| TrackerA[Tracker 1] + Wallet-->|queries| TrackerB[Tracker 2] + Wallet-->|queries| TrackerC[...] + Wallet-->|queries| TrackerD[Tracker n] + + subgraph dApp + subgraph .torrent server + end + end + + Wallet<--Establish WebRTC data channel\n for peer to peer communication-->dApp +``` + +## Proof of Concept + +The idea of using WebTorrent trackers instead of STUN/TURN servers for peer discovery was already mentioned in [Aug 2018 by Chris McCormick](https://mccormick.cx/news/entries/on-self-hosting-and-decentralized-software): + "I've also been tinkering with WebTorrent. [...] +Working with this technology made me realise something the other day: it's now possible to host back-end services, or "servers" inside browser tabs. [...] So anyway, I've made this weird thing to enable developers to build "backend" services which run in browser tabs" + +McCormick's idea has been developed and open sourced as a library called [bugout](https://github.com/chr15m/bugout/) (MIT). + +For this proof of concept we wrote two small pieces of software: + +- A html page aka the dApp +- An ionic react app (to target mutliple devices) aka the wallet app + +### dApp + +The dApp consists of a standard HTML5 template including the following lines of code: + +```html + + +``` + +### Wallet App + +The wallet app is a standard ionic react app built by the ionic cli: + +```zsh +ionic start WalletApp blank --type=react +cd WalletApp +npm i bugout +``` + +The following lines of code were added to the index.tsx file: + +```js +const bugout = new Bugout( + "", { + announce: [ + 'udp://tracker.opentrackr.org:1337/announce', + 'udp://open.tracker.cl:1337/announce', + 'udp://opentracker.i2p.rocks:6969/announce', + 'https://opentracker.i2p.rocks:443/announce', + 'wss://tracker.files.fm:7073/announce', + 'wss://spacetradersapi-chatbox.herokuapp.com:443/announce', + 'ws://tracker.files.fm:7072/announce' + ] + }); + +bugout.on("server", function() { + console.log("[info]: connected to server") + bugout.rpc("", "api", {"api": { + version: "1.0.3", + name: 'boostwallet', + methods: ["getRewardAddresses"] + }}); +}); + +bugout.register("getRewardAddresses", (address:string, args:any, callback:Function) => { + callback(["e1820506cb0ce54ae755b2512b6cf31856d7265e8792cb86afc94e0872"]); +}); +``` + +This example has a few restrictions: + +1. bugout is currently not compatible with Webpack 5, so polyfills are not automatically included and a react-scripts eject is needed to add them to the webpack.config.js file + +2. bugout does not directly provide type declarations. There are some declarations within a [PR](https://github.com/chr15m/bugout/pull/45), but they need to be adjusted (a few parameters are not mandatory) and added to a bugout.d.ts file. + +# User Flow + +```mermaid +sequenceDiagram + dApp-->>Wallet: Share address using Deeplink /Universal Link / QR + Wallet-->>Tracker List: Accept connection and start quering using the address + Wallet-->>dApp: Once connected register RPC functions and share the API + dApp-->>dApp: Inject the API to window.cardano[walletName] + dApp-->>Wallet: Call RPC functions (e.g. getRewardAddresses) + Wallet-->>Wallet: If needed bring app to foregrund (e.g. request signing) + Wallet-->>dApp: Send response +``` + +# Security Aspects + +We decided to spwan the server within the dApp to force the user to manually scan a QR code (using a wallet app) or accept an "Open with " ui dialog (in case of Universal Links or Deeplinks). This prevents the user from connecting the wallet to an unwanted dApp. Additionally we need to add a few security checks to prevent a missusage of these method. + +- The wallet app needs to verifiy the origin (address) of the RPC call +- dApps should ask the user for the permission to injected the wallet names into the window.cardano object to prevent XSS attack (Maybe using a graphical representation of the wallet app address e.g. blockies) + +# Discussion/Open Points + +- Fork/Extend bugout to add webpack 5 and typescript support +- Maybe we should provide a general intermediate cardano-connect typescript library to provide + 1. A check for mobile/desktop environment + 2. Depending on the environment provide interfaces for CIP 30 / and / or CIP 78 + 3. Add an improved version of the server/client side code above to define a communication standard +- Identify potential security issues and attack vectors +- Check if the wallet app also reacts to rpc calls in background mode on iOS + +# Copyright + +This CIP is licensed under [CC-BY-4.0](https://creativecommons.org/licenses/by/4.0/legalcode) \ No newline at end of file diff --git a/CIP-0078/demo/README.md b/CIP-0078/demo/README.md new file mode 100644 index 0000000000..9f39679648 --- /dev/null +++ b/CIP-0078/demo/README.md @@ -0,0 +1,28 @@ +# Run the demo + +## Prerequirements + +* node>=16.x.x, npm>=8.x.x + +## Getting Started + +```zsh +cd ionic-app +npm i +``` + +## Run the server (aka dApp) + +Open the dApp.html file & your dev tools to see the console log outputs. + +## Run the client (aka Wallet App) + +```zsh +cd ionic-app +npm start +``` + +## Testing (PoC) + +Once you have the server and client running you should see something like `[info]: injected api of boostwallet into window.cardano` in your dApp logs. Now you can issue a `window.cardano.boostwallet.getRewardAddresses().then(result => console.log(result))` to execute the remote call and get the reward address from your Wallet App. + diff --git a/CIP-0078/demo/dApp.html b/CIP-0078/demo/dApp.html new file mode 100644 index 0000000000..343c3bdfc2 --- /dev/null +++ b/CIP-0078/demo/dApp.html @@ -0,0 +1,51 @@ + + + + + + + + + DApp + + +

Simple Example Dapp

+ + \ No newline at end of file diff --git a/CIP-0078/demo/ionic-app/.gitignore b/CIP-0078/demo/ionic-app/.gitignore new file mode 100644 index 0000000000..d258871014 --- /dev/null +++ b/CIP-0078/demo/ionic-app/.gitignore @@ -0,0 +1,31 @@ +# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. + +# dependencies +/node_modules +/.pnp +.pnp.js + +# testing +/coverage + +# production +/build + +# misc +.DS_Store +.env.local +.env.development.local +.env.test.local +.env.production.local +/.vscode/* +!/.vscode/extensions.json +.idea + +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# Optional eslint cache +.eslintcache + +.vscode/ \ No newline at end of file diff --git a/CIP-0078/demo/ionic-app/capacitor.config.ts b/CIP-0078/demo/ionic-app/capacitor.config.ts new file mode 100644 index 0000000000..341bcb2607 --- /dev/null +++ b/CIP-0078/demo/ionic-app/capacitor.config.ts @@ -0,0 +1,10 @@ +import { CapacitorConfig } from '@capacitor/cli'; + +const config: CapacitorConfig = { + appId: 'io.ionic.starter', + appName: 'WalletApp', + webDir: 'build', + bundledWebRuntime: false +}; + +export default config; diff --git a/CIP-0078/demo/ionic-app/config/env.js b/CIP-0078/demo/ionic-app/config/env.js new file mode 100644 index 0000000000..ffa7e496aa --- /dev/null +++ b/CIP-0078/demo/ionic-app/config/env.js @@ -0,0 +1,104 @@ +'use strict'; + +const fs = require('fs'); +const path = require('path'); +const paths = require('./paths'); + +// Make sure that including paths.js after env.js will read .env variables. +delete require.cache[require.resolve('./paths')]; + +const NODE_ENV = process.env.NODE_ENV; +if (!NODE_ENV) { + throw new Error( + 'The NODE_ENV environment variable is required but was not specified.' + ); +} + +// https://github.com/bkeepers/dotenv#what-other-env-files-can-i-use +const dotenvFiles = [ + `${paths.dotenv}.${NODE_ENV}.local`, + // Don't include `.env.local` for `test` environment + // since normally you expect tests to produce the same + // results for everyone + NODE_ENV !== 'test' && `${paths.dotenv}.local`, + `${paths.dotenv}.${NODE_ENV}`, + paths.dotenv, +].filter(Boolean); + +// Load environment variables from .env* files. Suppress warnings using silent +// if this file is missing. dotenv will never modify any environment variables +// that have already been set. Variable expansion is supported in .env files. +// https://github.com/motdotla/dotenv +// https://github.com/motdotla/dotenv-expand +dotenvFiles.forEach(dotenvFile => { + if (fs.existsSync(dotenvFile)) { + require('dotenv-expand')( + require('dotenv').config({ + path: dotenvFile, + }) + ); + } +}); + +// We support resolving modules according to `NODE_PATH`. +// This lets you use absolute paths in imports inside large monorepos: +// https://github.com/facebook/create-react-app/issues/253. +// It works similar to `NODE_PATH` in Node itself: +// https://nodejs.org/api/modules.html#modules_loading_from_the_global_folders +// Note that unlike in Node, only *relative* paths from `NODE_PATH` are honored. +// Otherwise, we risk importing Node.js core modules into an app instead of webpack shims. +// https://github.com/facebook/create-react-app/issues/1023#issuecomment-265344421 +// We also resolve them to make sure all tools using them work consistently. +const appDirectory = fs.realpathSync(process.cwd()); +process.env.NODE_PATH = (process.env.NODE_PATH || '') + .split(path.delimiter) + .filter(folder => folder && !path.isAbsolute(folder)) + .map(folder => path.resolve(appDirectory, folder)) + .join(path.delimiter); + +// Grab NODE_ENV and REACT_APP_* environment variables and prepare them to be +// injected into the application via DefinePlugin in webpack configuration. +const REACT_APP = /^REACT_APP_/i; + +function getClientEnvironment(publicUrl) { + const raw = Object.keys(process.env) + .filter(key => REACT_APP.test(key)) + .reduce( + (env, key) => { + env[key] = process.env[key]; + return env; + }, + { + // Useful for determining whether we’re running in production mode. + // Most importantly, it switches React into the correct mode. + NODE_ENV: process.env.NODE_ENV || 'development', + // Useful for resolving the correct path to static assets in `public`. + // For example, . + // This should only be used as an escape hatch. Normally you would put + // images into the `src` and `import` them in code to get their paths. + PUBLIC_URL: publicUrl, + // We support configuring the sockjs pathname during development. + // These settings let a developer run multiple simultaneous projects. + // They are used as the connection `hostname`, `pathname` and `port` + // in webpackHotDevClient. They are used as the `sockHost`, `sockPath` + // and `sockPort` options in webpack-dev-server. + WDS_SOCKET_HOST: process.env.WDS_SOCKET_HOST, + WDS_SOCKET_PATH: process.env.WDS_SOCKET_PATH, + WDS_SOCKET_PORT: process.env.WDS_SOCKET_PORT, + // Whether or not react-refresh is enabled. + // It is defined here so it is available in the webpackHotDevClient. + FAST_REFRESH: process.env.FAST_REFRESH !== 'false', + } + ); + // Stringify all values so we can feed into webpack DefinePlugin + const stringified = { + 'process.env': Object.keys(raw).reduce((env, key) => { + env[key] = JSON.stringify(raw[key]); + return env; + }, {}), + }; + + return { raw, stringified }; +} + +module.exports = getClientEnvironment; diff --git a/CIP-0078/demo/ionic-app/config/getHttpsConfig.js b/CIP-0078/demo/ionic-app/config/getHttpsConfig.js new file mode 100644 index 0000000000..013d493c1b --- /dev/null +++ b/CIP-0078/demo/ionic-app/config/getHttpsConfig.js @@ -0,0 +1,66 @@ +'use strict'; + +const fs = require('fs'); +const path = require('path'); +const crypto = require('crypto'); +const chalk = require('react-dev-utils/chalk'); +const paths = require('./paths'); + +// Ensure the certificate and key provided are valid and if not +// throw an easy to debug error +function validateKeyAndCerts({ cert, key, keyFile, crtFile }) { + let encrypted; + try { + // publicEncrypt will throw an error with an invalid cert + encrypted = crypto.publicEncrypt(cert, Buffer.from('test')); + } catch (err) { + throw new Error( + `The certificate "${chalk.yellow(crtFile)}" is invalid.\n${err.message}` + ); + } + + try { + // privateDecrypt will throw an error with an invalid key + crypto.privateDecrypt(key, encrypted); + } catch (err) { + throw new Error( + `The certificate key "${chalk.yellow(keyFile)}" is invalid.\n${ + err.message + }` + ); + } +} + +// Read file and throw an error if it doesn't exist +function readEnvFile(file, type) { + if (!fs.existsSync(file)) { + throw new Error( + `You specified ${chalk.cyan( + type + )} in your env, but the file "${chalk.yellow(file)}" can't be found.` + ); + } + return fs.readFileSync(file); +} + +// Get the https config +// Return cert files if provided in env, otherwise just true or false +function getHttpsConfig() { + const { SSL_CRT_FILE, SSL_KEY_FILE, HTTPS } = process.env; + const isHttps = HTTPS === 'true'; + + if (isHttps && SSL_CRT_FILE && SSL_KEY_FILE) { + const crtFile = path.resolve(paths.appPath, SSL_CRT_FILE); + const keyFile = path.resolve(paths.appPath, SSL_KEY_FILE); + const config = { + cert: readEnvFile(crtFile, 'SSL_CRT_FILE'), + key: readEnvFile(keyFile, 'SSL_KEY_FILE'), + }; + + validateKeyAndCerts({ ...config, keyFile, crtFile }); + return config; + } + return isHttps; +} + +module.exports = getHttpsConfig; diff --git a/CIP-0078/demo/ionic-app/config/jest/babelTransform.js b/CIP-0078/demo/ionic-app/config/jest/babelTransform.js new file mode 100644 index 0000000000..5b391e4055 --- /dev/null +++ b/CIP-0078/demo/ionic-app/config/jest/babelTransform.js @@ -0,0 +1,29 @@ +'use strict'; + +const babelJest = require('babel-jest').default; + +const hasJsxRuntime = (() => { + if (process.env.DISABLE_NEW_JSX_TRANSFORM === 'true') { + return false; + } + + try { + require.resolve('react/jsx-runtime'); + return true; + } catch (e) { + return false; + } +})(); + +module.exports = babelJest.createTransformer({ + presets: [ + [ + require.resolve('babel-preset-react-app'), + { + runtime: hasJsxRuntime ? 'automatic' : 'classic', + }, + ], + ], + babelrc: false, + configFile: false, +}); diff --git a/CIP-0078/demo/ionic-app/config/jest/cssTransform.js b/CIP-0078/demo/ionic-app/config/jest/cssTransform.js new file mode 100644 index 0000000000..8f65114812 --- /dev/null +++ b/CIP-0078/demo/ionic-app/config/jest/cssTransform.js @@ -0,0 +1,14 @@ +'use strict'; + +// This is a custom Jest transformer turning style imports into empty objects. +// http://facebook.github.io/jest/docs/en/webpack.html + +module.exports = { + process() { + return 'module.exports = {};'; + }, + getCacheKey() { + // The output is always the same. + return 'cssTransform'; + }, +}; diff --git a/CIP-0078/demo/ionic-app/config/jest/fileTransform.js b/CIP-0078/demo/ionic-app/config/jest/fileTransform.js new file mode 100644 index 0000000000..aab67618c3 --- /dev/null +++ b/CIP-0078/demo/ionic-app/config/jest/fileTransform.js @@ -0,0 +1,40 @@ +'use strict'; + +const path = require('path'); +const camelcase = require('camelcase'); + +// This is a custom Jest transformer turning file imports into filenames. +// http://facebook.github.io/jest/docs/en/webpack.html + +module.exports = { + process(src, filename) { + const assetFilename = JSON.stringify(path.basename(filename)); + + if (filename.match(/\.svg$/)) { + // Based on how SVGR generates a component name: + // https://github.com/smooth-code/svgr/blob/01b194cf967347d43d4cbe6b434404731b87cf27/packages/core/src/state.js#L6 + const pascalCaseFilename = camelcase(path.parse(filename).name, { + pascalCase: true, + }); + const componentName = `Svg${pascalCaseFilename}`; + return `const React = require('react'); + module.exports = { + __esModule: true, + default: ${assetFilename}, + ReactComponent: React.forwardRef(function ${componentName}(props, ref) { + return { + $$typeof: Symbol.for('react.element'), + type: 'svg', + ref: ref, + key: null, + props: Object.assign({}, props, { + children: ${assetFilename} + }) + }; + }), + };`; + } + + return `module.exports = ${assetFilename};`; + }, +}; diff --git a/CIP-0078/demo/ionic-app/config/modules.js b/CIP-0078/demo/ionic-app/config/modules.js new file mode 100644 index 0000000000..d63e41d78d --- /dev/null +++ b/CIP-0078/demo/ionic-app/config/modules.js @@ -0,0 +1,134 @@ +'use strict'; + +const fs = require('fs'); +const path = require('path'); +const paths = require('./paths'); +const chalk = require('react-dev-utils/chalk'); +const resolve = require('resolve'); + +/** + * Get additional module paths based on the baseUrl of a compilerOptions object. + * + * @param {Object} options + */ +function getAdditionalModulePaths(options = {}) { + const baseUrl = options.baseUrl; + + if (!baseUrl) { + return ''; + } + + const baseUrlResolved = path.resolve(paths.appPath, baseUrl); + + // We don't need to do anything if `baseUrl` is set to `node_modules`. This is + // the default behavior. + if (path.relative(paths.appNodeModules, baseUrlResolved) === '') { + return null; + } + + // Allow the user set the `baseUrl` to `appSrc`. + if (path.relative(paths.appSrc, baseUrlResolved) === '') { + return [paths.appSrc]; + } + + // If the path is equal to the root directory we ignore it here. + // We don't want to allow importing from the root directly as source files are + // not transpiled outside of `src`. We do allow importing them with the + // absolute path (e.g. `src/Components/Button.js`) but we set that up with + // an alias. + if (path.relative(paths.appPath, baseUrlResolved) === '') { + return null; + } + + // Otherwise, throw an error. + throw new Error( + chalk.red.bold( + "Your project's `baseUrl` can only be set to `src` or `node_modules`." + + ' Create React App does not support other values at this time.' + ) + ); +} + +/** + * Get webpack aliases based on the baseUrl of a compilerOptions object. + * + * @param {*} options + */ +function getWebpackAliases(options = {}) { + const baseUrl = options.baseUrl; + + if (!baseUrl) { + return {}; + } + + const baseUrlResolved = path.resolve(paths.appPath, baseUrl); + + if (path.relative(paths.appPath, baseUrlResolved) === '') { + return { + src: paths.appSrc, + }; + } +} + +/** + * Get jest aliases based on the baseUrl of a compilerOptions object. + * + * @param {*} options + */ +function getJestAliases(options = {}) { + const baseUrl = options.baseUrl; + + if (!baseUrl) { + return {}; + } + + const baseUrlResolved = path.resolve(paths.appPath, baseUrl); + + if (path.relative(paths.appPath, baseUrlResolved) === '') { + return { + '^src/(.*)$': '/src/$1', + }; + } +} + +function getModules() { + // Check if TypeScript is setup + const hasTsConfig = fs.existsSync(paths.appTsConfig); + const hasJsConfig = fs.existsSync(paths.appJsConfig); + + if (hasTsConfig && hasJsConfig) { + throw new Error( + 'You have both a tsconfig.json and a jsconfig.json. If you are using TypeScript please remove your jsconfig.json file.' + ); + } + + let config; + + // If there's a tsconfig.json we assume it's a + // TypeScript project and set up the config + // based on tsconfig.json + if (hasTsConfig) { + const ts = require(resolve.sync('typescript', { + basedir: paths.appNodeModules, + })); + config = ts.readConfigFile(paths.appTsConfig, ts.sys.readFile).config; + // Otherwise we'll check if there is jsconfig.json + // for non TS projects. + } else if (hasJsConfig) { + config = require(paths.appJsConfig); + } + + config = config || {}; + const options = config.compilerOptions || {}; + + const additionalModulePaths = getAdditionalModulePaths(options); + + return { + additionalModulePaths: additionalModulePaths, + webpackAliases: getWebpackAliases(options), + jestAliases: getJestAliases(options), + hasTsConfig, + }; +} + +module.exports = getModules(); diff --git a/CIP-0078/demo/ionic-app/config/paths.js b/CIP-0078/demo/ionic-app/config/paths.js new file mode 100644 index 0000000000..f0a6cd9c98 --- /dev/null +++ b/CIP-0078/demo/ionic-app/config/paths.js @@ -0,0 +1,77 @@ +'use strict'; + +const path = require('path'); +const fs = require('fs'); +const getPublicUrlOrPath = require('react-dev-utils/getPublicUrlOrPath'); + +// Make sure any symlinks in the project folder are resolved: +// https://github.com/facebook/create-react-app/issues/637 +const appDirectory = fs.realpathSync(process.cwd()); +const resolveApp = relativePath => path.resolve(appDirectory, relativePath); + +// We use `PUBLIC_URL` environment variable or "homepage" field to infer +// "public path" at which the app is served. +// webpack needs to know it to put the right ``` -### Wallet App +#### Wallet App The wallet app is a standard ionic react app built by the ionic cli: @@ -183,7 +193,7 @@ This example has a few restrictions: 2. bugout does not directly provide type declarations. There are some declarations within a [PR](https://github.com/chr15m/bugout/pull/45), but they need to be adjusted (a few parameters are not mandatory) and added to a bugout.d.ts file. -# User Flow +### User Flow ```mermaid sequenceDiagram @@ -196,23 +206,27 @@ sequenceDiagram Wallet-->>dApp: Send response ``` -# Security Aspects +### Security Aspects We decided to spwan the server within the dApp to force the user to manually scan a QR code (using a wallet app) or accept an "Open with " ui dialog (in case of Universal Links or Deeplinks). This prevents the user from connecting the wallet to an unwanted dApp. Additionally we need to add a few security checks to prevent a missusage of these method. - The wallet app needs to verifiy the origin (address) of the RPC call - dApps should ask the user for the permission to injected the wallet names into the window.cardano object to prevent XSS attack (Maybe using a graphical representation of the wallet app address e.g. blockies) -# Discussion/Open Points +## Rationale + +The purpose of this CIP mainly consists of two parts. It addresses the current lack of dApp mobile support, but at the same time provides an even more decentralized alternative to state-of-the-art communication methods. To archive this goal we have introduced a WebTorrent and WebRTC based architecture. To demonstrate a viable implementation, we have implemented a proof of concept which also shows how a rpc method injection like CIP-0030 might look like. + +## Implementation Plan -- Fork/Extend bugout to add webpack 5 and typescript support -- Maybe we should provide a general intermediate cardano-connect typescript library to provide +- [ ] Fork/Extend bugout to add webpack 5 and typescript support +- [ ] Povide a general intermediate cardano-connect typescript library to provide 1. A check for mobile/desktop environment 2. Depending on the environment provide interfaces for CIP 30 / and / or CIP 78 3. Add an improved version of the server/client side code above to define a communication standard -- Identify potential security issues and attack vectors -- Check if the wallet app also reacts to rpc calls in background mode on iOS +- [ ] Identify potential security issues and attack vectors +- [ ] Check if the wallet app also reacts to rpc calls in background mode on iOS -# Copyright +## Copyright This CIP is licensed under [CC-BY-4.0](https://creativecommons.org/licenses/by/4.0/legalcode) \ No newline at end of file diff --git a/CIP-0078/demo/README.md b/CIP-0078/demo/README.md index 9f39679648..a5357dd5f3 100644 --- a/CIP-0078/demo/README.md +++ b/CIP-0078/demo/README.md @@ -24,5 +24,17 @@ npm start ## Testing (PoC) -Once you have the server and client running you should see something like `[info]: injected api of boostwallet into window.cardano` in your dApp logs. Now you can issue a `window.cardano.boostwallet.getRewardAddresses().then(result => console.log(result))` to execute the remote call and get the reward address from your Wallet App. +Once you have the server and client running you should see something like + +```js +"[info]: injected api of boostwallet into window.cardano" +``` + +in your dApp logs. Now you can issue + +```js +window.cardano.boostwallet.getRewardAddresses().then(result => console.log(result)) +``` + +to execute the remote call and get the reward address from your Wallet App. From dfd00b92a6d14e4fcb0a89b147e8fbbea1dc3f45 Mon Sep 17 00:00:00 2001 From: Fabian Bormann Date: Thu, 1 Dec 2022 09:26:24 +0100 Subject: [PATCH 03/17] fix: structure and incorrectly formatted to-do list --- CIP-0078/README.md | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/CIP-0078/README.md b/CIP-0078/README.md index 313c8ac7ec..b0c9f636c1 100644 --- a/CIP-0078/README.md +++ b/CIP-0078/README.md @@ -1,9 +1,7 @@ --- CIP: 78 -Title: Decentralized WebRTC dApp/Wallet Communication Using WebTorrent Tracker for Peer Discovery -Authors: - - Fabian Bormann - - Jaime Caso +Title: Decentralized WebRTC dApp/Wallet Communication Using WebTorrent Trackers for Peer Discovery +Authors: Fabian Bormann , Jaime Caso Comments-Summary: No comments yet Comments-URI: https://github.com/CardanoFoundation/CIPs/pulls/ Status: Draft @@ -12,11 +10,11 @@ Created: 2022-11-29 License: CC-BY-4.0 --- -# CIP-0078: Decentralized WebRTC dApp/Wallet Communication Using WebTorrent Tracker for Peer Discovery +# CIP-0078: Decentralized WebRTC dApp/Wallet Communication Using WebTorrent Trackers for Peer Discovery ## Abstract -We want to introduce a decentralized communication method between dApps and wallets based on WebTorrent trackers and WebRTC. This CIP also contains a proof of concept implementation injecting the wallet rpc methods into the dApps global window object similar to [CIP-0030](https://github.com/cardano-foundation/CIPs/tree/master/CIP-0030). +We want to introduce a decentralized communication method between dApps and wallets based on WebTorrent trackers and WebRTC. This CIP also contains a proof of concept implementation injecting the wallet rpc methods into the dApps global window object similar to [CIP-0030](https://github.com/cardano-foundation/CIPs/tree/master/CIP-0030). The goal is not to replace existing solutions, but to discuss a more decentralized alternative. ## Motivation @@ -220,13 +218,13 @@ The purpose of this CIP mainly consists of two parts. It addresses the current l ## Implementation Plan - [ ] Fork/Extend bugout to add webpack 5 and typescript support +- [ ] Identify potential security issues and attack vectors +- [ ] Check if the wallet app also reacts to rpc calls in background mode on iOS - [ ] Povide a general intermediate cardano-connect typescript library to provide 1. A check for mobile/desktop environment 2. Depending on the environment provide interfaces for CIP 30 / and / or CIP 78 3. Add an improved version of the server/client side code above to define a communication standard -- [ ] Identify potential security issues and attack vectors -- [ ] Check if the wallet app also reacts to rpc calls in background mode on iOS ## Copyright -This CIP is licensed under [CC-BY-4.0](https://creativecommons.org/licenses/by/4.0/legalcode) \ No newline at end of file +This CIP is licensed under [CC-BY-4.0](https://creativecommons.org/licenses/by/4.0/legalcode) From 4ee0d27011704f9db6fb5ebd1883a34cf24f2a6b Mon Sep 17 00:00:00 2001 From: Fabian Bormann Date: Thu, 1 Dec 2022 14:47:17 +0100 Subject: [PATCH 04/17] fix: reformat the structure to match the cip-0001 specs --- {CIP-0078 => CIP-????}/README.md | 47 ++++++++++++------ {CIP-0078 => CIP-????}/demo/README.md | 0 {CIP-0078 => CIP-????}/demo/dApp.html | 0 .../demo/ionic-app/.gitignore | 0 .../demo/ionic-app/capacitor.config.ts | 0 .../demo/ionic-app/config/env.js | 0 .../demo/ionic-app/config/getHttpsConfig.js | 0 .../ionic-app/config/jest/babelTransform.js | 0 .../ionic-app/config/jest/cssTransform.js | 0 .../ionic-app/config/jest/fileTransform.js | 0 .../demo/ionic-app/config/modules.js | 0 .../demo/ionic-app/config/paths.js | 0 .../demo/ionic-app/config/webpack.config.js | 0 .../persistentCache/createEnvironmentHash.js | 0 .../config/webpackDevServer.config.js | 0 .../demo/ionic-app/ionic.config.json | 0 .../demo/ionic-app/package-lock.json | 0 .../demo/ionic-app/package.json | 0 .../ionic-app/public/assets/icon/favicon.png | Bin .../ionic-app/public/assets/icon/icon.png | Bin .../demo/ionic-app/public/assets/shapes.svg | 0 .../demo/ionic-app/public/index.html | 0 .../demo/ionic-app/public/manifest.json | 0 .../demo/ionic-app/scripts/build.js | 0 .../demo/ionic-app/scripts/start.js | 0 .../demo/ionic-app/scripts/test.js | 0 .../demo/ionic-app/src/App.test.tsx | 0 .../demo/ionic-app/src/App.tsx | 0 .../demo/ionic-app/src/bugout.d.ts | 0 .../src/components/ExploreContainer.css | 0 .../src/components/ExploreContainer.tsx | 0 .../demo/ionic-app/src/index.tsx | 0 .../demo/ionic-app/src/pages/Tab1.css | 0 .../demo/ionic-app/src/pages/Tab1.tsx | 0 .../demo/ionic-app/src/pages/Tab2.css | 0 .../demo/ionic-app/src/pages/Tab2.tsx | 0 .../demo/ionic-app/src/pages/Tab3.css | 0 .../demo/ionic-app/src/pages/Tab3.tsx | 0 .../demo/ionic-app/src/react-app-env.d.ts | 0 .../demo/ionic-app/src/reportWebVitals.ts | 0 .../demo/ionic-app/src/service-worker.ts | 0 .../src/serviceWorkerRegistration.ts | 0 .../demo/ionic-app/src/setupTests.ts | 0 .../demo/ionic-app/src/theme/variables.css | 0 .../demo/ionic-app/tsconfig.json | 0 45 files changed, 32 insertions(+), 15 deletions(-) rename {CIP-0078 => CIP-????}/README.md (84%) rename {CIP-0078 => CIP-????}/demo/README.md (100%) rename {CIP-0078 => CIP-????}/demo/dApp.html (100%) rename {CIP-0078 => CIP-????}/demo/ionic-app/.gitignore (100%) rename {CIP-0078 => CIP-????}/demo/ionic-app/capacitor.config.ts (100%) rename {CIP-0078 => CIP-????}/demo/ionic-app/config/env.js (100%) rename {CIP-0078 => CIP-????}/demo/ionic-app/config/getHttpsConfig.js (100%) rename {CIP-0078 => CIP-????}/demo/ionic-app/config/jest/babelTransform.js (100%) rename {CIP-0078 => CIP-????}/demo/ionic-app/config/jest/cssTransform.js (100%) rename {CIP-0078 => CIP-????}/demo/ionic-app/config/jest/fileTransform.js (100%) rename {CIP-0078 => CIP-????}/demo/ionic-app/config/modules.js (100%) rename {CIP-0078 => CIP-????}/demo/ionic-app/config/paths.js (100%) rename {CIP-0078 => CIP-????}/demo/ionic-app/config/webpack.config.js (100%) rename {CIP-0078 => CIP-????}/demo/ionic-app/config/webpack/persistentCache/createEnvironmentHash.js (100%) rename {CIP-0078 => CIP-????}/demo/ionic-app/config/webpackDevServer.config.js (100%) rename {CIP-0078 => CIP-????}/demo/ionic-app/ionic.config.json (100%) rename {CIP-0078 => CIP-????}/demo/ionic-app/package-lock.json (100%) rename {CIP-0078 => CIP-????}/demo/ionic-app/package.json (100%) rename {CIP-0078 => CIP-????}/demo/ionic-app/public/assets/icon/favicon.png (100%) rename {CIP-0078 => CIP-????}/demo/ionic-app/public/assets/icon/icon.png (100%) rename {CIP-0078 => CIP-????}/demo/ionic-app/public/assets/shapes.svg (100%) rename {CIP-0078 => CIP-????}/demo/ionic-app/public/index.html (100%) rename {CIP-0078 => CIP-????}/demo/ionic-app/public/manifest.json (100%) rename {CIP-0078 => CIP-????}/demo/ionic-app/scripts/build.js (100%) rename {CIP-0078 => CIP-????}/demo/ionic-app/scripts/start.js (100%) rename {CIP-0078 => CIP-????}/demo/ionic-app/scripts/test.js (100%) rename {CIP-0078 => CIP-????}/demo/ionic-app/src/App.test.tsx (100%) rename {CIP-0078 => CIP-????}/demo/ionic-app/src/App.tsx (100%) rename {CIP-0078 => CIP-????}/demo/ionic-app/src/bugout.d.ts (100%) rename {CIP-0078 => CIP-????}/demo/ionic-app/src/components/ExploreContainer.css (100%) rename {CIP-0078 => CIP-????}/demo/ionic-app/src/components/ExploreContainer.tsx (100%) rename {CIP-0078 => CIP-????}/demo/ionic-app/src/index.tsx (100%) rename {CIP-0078 => CIP-????}/demo/ionic-app/src/pages/Tab1.css (100%) rename {CIP-0078 => CIP-????}/demo/ionic-app/src/pages/Tab1.tsx (100%) rename {CIP-0078 => CIP-????}/demo/ionic-app/src/pages/Tab2.css (100%) rename {CIP-0078 => CIP-????}/demo/ionic-app/src/pages/Tab2.tsx (100%) rename {CIP-0078 => CIP-????}/demo/ionic-app/src/pages/Tab3.css (100%) rename {CIP-0078 => CIP-????}/demo/ionic-app/src/pages/Tab3.tsx (100%) rename {CIP-0078 => CIP-????}/demo/ionic-app/src/react-app-env.d.ts (100%) rename {CIP-0078 => CIP-????}/demo/ionic-app/src/reportWebVitals.ts (100%) rename {CIP-0078 => CIP-????}/demo/ionic-app/src/service-worker.ts (100%) rename {CIP-0078 => CIP-????}/demo/ionic-app/src/serviceWorkerRegistration.ts (100%) rename {CIP-0078 => CIP-????}/demo/ionic-app/src/setupTests.ts (100%) rename {CIP-0078 => CIP-????}/demo/ionic-app/src/theme/variables.css (100%) rename {CIP-0078 => CIP-????}/demo/ionic-app/tsconfig.json (100%) diff --git a/CIP-0078/README.md b/CIP-????/README.md similarity index 84% rename from CIP-0078/README.md rename to CIP-????/README.md index b0c9f636c1..714e492706 100644 --- a/CIP-0078/README.md +++ b/CIP-????/README.md @@ -1,20 +1,25 @@ --- -CIP: 78 -Title: Decentralized WebRTC dApp/Wallet Communication Using WebTorrent Trackers for Peer Discovery -Authors: Fabian Bormann , Jaime Caso -Comments-Summary: No comments yet -Comments-URI: https://github.com/CardanoFoundation/CIPs/pulls/ -Status: Draft -Type: Standards +CIP: ? +Title: Decentralized WebRTC dApp/Wallet Communication Using WebTorrent Tracker for Peer Discovery +Status: Proposed +Category: Wallets +Authors: + - Fabian Bormann + - Jaime Caso +Implementors: + - Fabian Bormann + - Jaime Caso +Discussions: + - https://github.com/cardano-foundation/CIPs/pull/395 Created: 2022-11-29 License: CC-BY-4.0 --- -# CIP-0078: Decentralized WebRTC dApp/Wallet Communication Using WebTorrent Trackers for Peer Discovery +# CIP-????: Decentralized WebRTC dApp/Wallet Communication Using WebTorrent Tracker for Peer Discovery ## Abstract -We want to introduce a decentralized communication method between dApps and wallets based on WebTorrent trackers and WebRTC. This CIP also contains a proof of concept implementation injecting the wallet rpc methods into the dApps global window object similar to [CIP-0030](https://github.com/cardano-foundation/CIPs/tree/master/CIP-0030). The goal is not to replace existing solutions, but to discuss a more decentralized alternative. +We want to introduce a decentralized communication method between dApps and wallets based on WebTorrent trackers and WebRTC. This CIP also contains a proof of concept implementation injecting the wallet rpc methods into the dApps global window object similar to [CIP-0030](https://github.com/cardano-foundation/CIPs/tree/master/CIP-0030). ## Motivation @@ -215,16 +220,28 @@ We decided to spwan the server within the dApp to force the user to manually sca The purpose of this CIP mainly consists of two parts. It addresses the current lack of dApp mobile support, but at the same time provides an even more decentralized alternative to state-of-the-art communication methods. To archive this goal we have introduced a WebTorrent and WebRTC based architecture. To demonstrate a viable implementation, we have implemented a proof of concept which also shows how a rpc method injection like CIP-0030 might look like. -## Implementation Plan +## Path to Active + +### Acceptance Criteria + +- [ ] A library should be build to make it easy from dAPP and wallet side to implement the proposed communication method +- [ ] The library target should be browser to avoid the need of manual polyfills +- [ ] Mobile testing on different devices and operating systems needs to be done with a special focus to the wallet app running in background mode +- [ ] Potential security issues and attack vectors need to be discussed in detail +- [ ] A full reference implementation is needed to test if the entire user flow and at the same time provide this as a how-to for developers + +### Implementation Plan - [ ] Fork/Extend bugout to add webpack 5 and typescript support -- [ ] Identify potential security issues and attack vectors -- [ ] Check if the wallet app also reacts to rpc calls in background mode on iOS - [ ] Povide a general intermediate cardano-connect typescript library to provide 1. A check for mobile/desktop environment - 2. Depending on the environment provide interfaces for CIP 30 / and / or CIP 78 - 3. Add an improved version of the server/client side code above to define a communication standard + 2. Depending on the environment provide interfaces for CIP-0030 / and / or CIP-? + 3. Add a full implementation of the server/client side code above to define a communication standard similar to CIP-0030 (getRewardAddresses, signData, signTx, ...) +- [ ] Start discussions about security gaps within the proposed method with various developers and also look for research papers +- [x] Check if the wallet app also reacts to rpc calls in background mode on Android +- [ ] Check if the wallet app also reacts to rpc calls in background mode on iOS +- [ ] Implement the library within an example dApp and [boost wallet](https://github.com/boost-pool/boost-wallet) ## Copyright -This CIP is licensed under [CC-BY-4.0](https://creativecommons.org/licenses/by/4.0/legalcode) +This CIP is licensed under [CC-BY-4.0](https://creativecommons.org/licenses/by/4.0/legalcode) \ No newline at end of file diff --git a/CIP-0078/demo/README.md b/CIP-????/demo/README.md similarity index 100% rename from CIP-0078/demo/README.md rename to CIP-????/demo/README.md diff --git a/CIP-0078/demo/dApp.html b/CIP-????/demo/dApp.html similarity index 100% rename from CIP-0078/demo/dApp.html rename to CIP-????/demo/dApp.html diff --git a/CIP-0078/demo/ionic-app/.gitignore b/CIP-????/demo/ionic-app/.gitignore similarity index 100% rename from CIP-0078/demo/ionic-app/.gitignore rename to CIP-????/demo/ionic-app/.gitignore diff --git a/CIP-0078/demo/ionic-app/capacitor.config.ts b/CIP-????/demo/ionic-app/capacitor.config.ts similarity index 100% rename from CIP-0078/demo/ionic-app/capacitor.config.ts rename to CIP-????/demo/ionic-app/capacitor.config.ts diff --git a/CIP-0078/demo/ionic-app/config/env.js b/CIP-????/demo/ionic-app/config/env.js similarity index 100% rename from CIP-0078/demo/ionic-app/config/env.js rename to CIP-????/demo/ionic-app/config/env.js diff --git a/CIP-0078/demo/ionic-app/config/getHttpsConfig.js b/CIP-????/demo/ionic-app/config/getHttpsConfig.js similarity index 100% rename from CIP-0078/demo/ionic-app/config/getHttpsConfig.js rename to CIP-????/demo/ionic-app/config/getHttpsConfig.js diff --git a/CIP-0078/demo/ionic-app/config/jest/babelTransform.js b/CIP-????/demo/ionic-app/config/jest/babelTransform.js similarity index 100% rename from CIP-0078/demo/ionic-app/config/jest/babelTransform.js rename to CIP-????/demo/ionic-app/config/jest/babelTransform.js diff --git a/CIP-0078/demo/ionic-app/config/jest/cssTransform.js b/CIP-????/demo/ionic-app/config/jest/cssTransform.js similarity index 100% rename from CIP-0078/demo/ionic-app/config/jest/cssTransform.js rename to CIP-????/demo/ionic-app/config/jest/cssTransform.js diff --git a/CIP-0078/demo/ionic-app/config/jest/fileTransform.js b/CIP-????/demo/ionic-app/config/jest/fileTransform.js similarity index 100% rename from CIP-0078/demo/ionic-app/config/jest/fileTransform.js rename to CIP-????/demo/ionic-app/config/jest/fileTransform.js diff --git a/CIP-0078/demo/ionic-app/config/modules.js b/CIP-????/demo/ionic-app/config/modules.js similarity index 100% rename from CIP-0078/demo/ionic-app/config/modules.js rename to CIP-????/demo/ionic-app/config/modules.js diff --git a/CIP-0078/demo/ionic-app/config/paths.js b/CIP-????/demo/ionic-app/config/paths.js similarity index 100% rename from CIP-0078/demo/ionic-app/config/paths.js rename to CIP-????/demo/ionic-app/config/paths.js diff --git a/CIP-0078/demo/ionic-app/config/webpack.config.js b/CIP-????/demo/ionic-app/config/webpack.config.js similarity index 100% rename from CIP-0078/demo/ionic-app/config/webpack.config.js rename to CIP-????/demo/ionic-app/config/webpack.config.js diff --git a/CIP-0078/demo/ionic-app/config/webpack/persistentCache/createEnvironmentHash.js b/CIP-????/demo/ionic-app/config/webpack/persistentCache/createEnvironmentHash.js similarity index 100% rename from CIP-0078/demo/ionic-app/config/webpack/persistentCache/createEnvironmentHash.js rename to CIP-????/demo/ionic-app/config/webpack/persistentCache/createEnvironmentHash.js diff --git a/CIP-0078/demo/ionic-app/config/webpackDevServer.config.js b/CIP-????/demo/ionic-app/config/webpackDevServer.config.js similarity index 100% rename from CIP-0078/demo/ionic-app/config/webpackDevServer.config.js rename to CIP-????/demo/ionic-app/config/webpackDevServer.config.js diff --git a/CIP-0078/demo/ionic-app/ionic.config.json b/CIP-????/demo/ionic-app/ionic.config.json similarity index 100% rename from CIP-0078/demo/ionic-app/ionic.config.json rename to CIP-????/demo/ionic-app/ionic.config.json diff --git a/CIP-0078/demo/ionic-app/package-lock.json b/CIP-????/demo/ionic-app/package-lock.json similarity index 100% rename from CIP-0078/demo/ionic-app/package-lock.json rename to CIP-????/demo/ionic-app/package-lock.json diff --git a/CIP-0078/demo/ionic-app/package.json b/CIP-????/demo/ionic-app/package.json similarity index 100% rename from CIP-0078/demo/ionic-app/package.json rename to CIP-????/demo/ionic-app/package.json diff --git a/CIP-0078/demo/ionic-app/public/assets/icon/favicon.png b/CIP-????/demo/ionic-app/public/assets/icon/favicon.png similarity index 100% rename from CIP-0078/demo/ionic-app/public/assets/icon/favicon.png rename to CIP-????/demo/ionic-app/public/assets/icon/favicon.png diff --git a/CIP-0078/demo/ionic-app/public/assets/icon/icon.png b/CIP-????/demo/ionic-app/public/assets/icon/icon.png similarity index 100% rename from CIP-0078/demo/ionic-app/public/assets/icon/icon.png rename to CIP-????/demo/ionic-app/public/assets/icon/icon.png diff --git a/CIP-0078/demo/ionic-app/public/assets/shapes.svg b/CIP-????/demo/ionic-app/public/assets/shapes.svg similarity index 100% rename from CIP-0078/demo/ionic-app/public/assets/shapes.svg rename to CIP-????/demo/ionic-app/public/assets/shapes.svg diff --git a/CIP-0078/demo/ionic-app/public/index.html b/CIP-????/demo/ionic-app/public/index.html similarity index 100% rename from CIP-0078/demo/ionic-app/public/index.html rename to CIP-????/demo/ionic-app/public/index.html diff --git a/CIP-0078/demo/ionic-app/public/manifest.json b/CIP-????/demo/ionic-app/public/manifest.json similarity index 100% rename from CIP-0078/demo/ionic-app/public/manifest.json rename to CIP-????/demo/ionic-app/public/manifest.json diff --git a/CIP-0078/demo/ionic-app/scripts/build.js b/CIP-????/demo/ionic-app/scripts/build.js similarity index 100% rename from CIP-0078/demo/ionic-app/scripts/build.js rename to CIP-????/demo/ionic-app/scripts/build.js diff --git a/CIP-0078/demo/ionic-app/scripts/start.js b/CIP-????/demo/ionic-app/scripts/start.js similarity index 100% rename from CIP-0078/demo/ionic-app/scripts/start.js rename to CIP-????/demo/ionic-app/scripts/start.js diff --git a/CIP-0078/demo/ionic-app/scripts/test.js b/CIP-????/demo/ionic-app/scripts/test.js similarity index 100% rename from CIP-0078/demo/ionic-app/scripts/test.js rename to CIP-????/demo/ionic-app/scripts/test.js diff --git a/CIP-0078/demo/ionic-app/src/App.test.tsx b/CIP-????/demo/ionic-app/src/App.test.tsx similarity index 100% rename from CIP-0078/demo/ionic-app/src/App.test.tsx rename to CIP-????/demo/ionic-app/src/App.test.tsx diff --git a/CIP-0078/demo/ionic-app/src/App.tsx b/CIP-????/demo/ionic-app/src/App.tsx similarity index 100% rename from CIP-0078/demo/ionic-app/src/App.tsx rename to CIP-????/demo/ionic-app/src/App.tsx diff --git a/CIP-0078/demo/ionic-app/src/bugout.d.ts b/CIP-????/demo/ionic-app/src/bugout.d.ts similarity index 100% rename from CIP-0078/demo/ionic-app/src/bugout.d.ts rename to CIP-????/demo/ionic-app/src/bugout.d.ts diff --git a/CIP-0078/demo/ionic-app/src/components/ExploreContainer.css b/CIP-????/demo/ionic-app/src/components/ExploreContainer.css similarity index 100% rename from CIP-0078/demo/ionic-app/src/components/ExploreContainer.css rename to CIP-????/demo/ionic-app/src/components/ExploreContainer.css diff --git a/CIP-0078/demo/ionic-app/src/components/ExploreContainer.tsx b/CIP-????/demo/ionic-app/src/components/ExploreContainer.tsx similarity index 100% rename from CIP-0078/demo/ionic-app/src/components/ExploreContainer.tsx rename to CIP-????/demo/ionic-app/src/components/ExploreContainer.tsx diff --git a/CIP-0078/demo/ionic-app/src/index.tsx b/CIP-????/demo/ionic-app/src/index.tsx similarity index 100% rename from CIP-0078/demo/ionic-app/src/index.tsx rename to CIP-????/demo/ionic-app/src/index.tsx diff --git a/CIP-0078/demo/ionic-app/src/pages/Tab1.css b/CIP-????/demo/ionic-app/src/pages/Tab1.css similarity index 100% rename from CIP-0078/demo/ionic-app/src/pages/Tab1.css rename to CIP-????/demo/ionic-app/src/pages/Tab1.css diff --git a/CIP-0078/demo/ionic-app/src/pages/Tab1.tsx b/CIP-????/demo/ionic-app/src/pages/Tab1.tsx similarity index 100% rename from CIP-0078/demo/ionic-app/src/pages/Tab1.tsx rename to CIP-????/demo/ionic-app/src/pages/Tab1.tsx diff --git a/CIP-0078/demo/ionic-app/src/pages/Tab2.css b/CIP-????/demo/ionic-app/src/pages/Tab2.css similarity index 100% rename from CIP-0078/demo/ionic-app/src/pages/Tab2.css rename to CIP-????/demo/ionic-app/src/pages/Tab2.css diff --git a/CIP-0078/demo/ionic-app/src/pages/Tab2.tsx b/CIP-????/demo/ionic-app/src/pages/Tab2.tsx similarity index 100% rename from CIP-0078/demo/ionic-app/src/pages/Tab2.tsx rename to CIP-????/demo/ionic-app/src/pages/Tab2.tsx diff --git a/CIP-0078/demo/ionic-app/src/pages/Tab3.css b/CIP-????/demo/ionic-app/src/pages/Tab3.css similarity index 100% rename from CIP-0078/demo/ionic-app/src/pages/Tab3.css rename to CIP-????/demo/ionic-app/src/pages/Tab3.css diff --git a/CIP-0078/demo/ionic-app/src/pages/Tab3.tsx b/CIP-????/demo/ionic-app/src/pages/Tab3.tsx similarity index 100% rename from CIP-0078/demo/ionic-app/src/pages/Tab3.tsx rename to CIP-????/demo/ionic-app/src/pages/Tab3.tsx diff --git a/CIP-0078/demo/ionic-app/src/react-app-env.d.ts b/CIP-????/demo/ionic-app/src/react-app-env.d.ts similarity index 100% rename from CIP-0078/demo/ionic-app/src/react-app-env.d.ts rename to CIP-????/demo/ionic-app/src/react-app-env.d.ts diff --git a/CIP-0078/demo/ionic-app/src/reportWebVitals.ts b/CIP-????/demo/ionic-app/src/reportWebVitals.ts similarity index 100% rename from CIP-0078/demo/ionic-app/src/reportWebVitals.ts rename to CIP-????/demo/ionic-app/src/reportWebVitals.ts diff --git a/CIP-0078/demo/ionic-app/src/service-worker.ts b/CIP-????/demo/ionic-app/src/service-worker.ts similarity index 100% rename from CIP-0078/demo/ionic-app/src/service-worker.ts rename to CIP-????/demo/ionic-app/src/service-worker.ts diff --git a/CIP-0078/demo/ionic-app/src/serviceWorkerRegistration.ts b/CIP-????/demo/ionic-app/src/serviceWorkerRegistration.ts similarity index 100% rename from CIP-0078/demo/ionic-app/src/serviceWorkerRegistration.ts rename to CIP-????/demo/ionic-app/src/serviceWorkerRegistration.ts diff --git a/CIP-0078/demo/ionic-app/src/setupTests.ts b/CIP-????/demo/ionic-app/src/setupTests.ts similarity index 100% rename from CIP-0078/demo/ionic-app/src/setupTests.ts rename to CIP-????/demo/ionic-app/src/setupTests.ts diff --git a/CIP-0078/demo/ionic-app/src/theme/variables.css b/CIP-????/demo/ionic-app/src/theme/variables.css similarity index 100% rename from CIP-0078/demo/ionic-app/src/theme/variables.css rename to CIP-????/demo/ionic-app/src/theme/variables.css diff --git a/CIP-0078/demo/ionic-app/tsconfig.json b/CIP-????/demo/ionic-app/tsconfig.json similarity index 100% rename from CIP-0078/demo/ionic-app/tsconfig.json rename to CIP-????/demo/ionic-app/tsconfig.json From 7c7b5b7afe9e0671d6d19dcd70030bbeda73cb09 Mon Sep 17 00:00:00 2001 From: Fabian Bormann Date: Thu, 1 Dec 2022 14:51:50 +0100 Subject: [PATCH 05/17] fix: wrong formatted todo list item --- CIP-????/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CIP-????/README.md b/CIP-????/README.md index 714e492706..b93b7037f3 100644 --- a/CIP-????/README.md +++ b/CIP-????/README.md @@ -227,7 +227,7 @@ The purpose of this CIP mainly consists of two parts. It addresses the current l - [ ] A library should be build to make it easy from dAPP and wallet side to implement the proposed communication method - [ ] The library target should be browser to avoid the need of manual polyfills - [ ] Mobile testing on different devices and operating systems needs to be done with a special focus to the wallet app running in background mode -- [ ] Potential security issues and attack vectors need to be discussed in detail +- [ ] Potential security issues and attack vectors need to be discussed in detail - [ ] A full reference implementation is needed to test if the entire user flow and at the same time provide this as a how-to for developers ### Implementation Plan @@ -244,4 +244,4 @@ The purpose of this CIP mainly consists of two parts. It addresses the current l ## Copyright -This CIP is licensed under [CC-BY-4.0](https://creativecommons.org/licenses/by/4.0/legalcode) \ No newline at end of file +This CIP is licensed under [CC-BY-4.0](https://creativecommons.org/licenses/by/4.0/legalcode) From f4e9739035f349e365e587d18db6e60e4eae0377 Mon Sep 17 00:00:00 2001 From: Fabian Bormann Date: Thu, 1 Dec 2022 15:00:21 +0100 Subject: [PATCH 06/17] fix: add the changes from Roberto manually due to the changed file structure --- CIP-????/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CIP-????/README.md b/CIP-????/README.md index b93b7037f3..cd24cb417f 100644 --- a/CIP-????/README.md +++ b/CIP-????/README.md @@ -23,7 +23,7 @@ We want to introduce a decentralized communication method between dApps and wall ## Motivation -In a decentralized ecosystem a communication between wallet apps and dApps is still challanging. The inter-app communication on mobile devices does not directly allow remote procedure calls and is mostly resticed to Universal Links (iOS) or Deeplinks (Android). State-of-the-art solutions like WalletConnect tackle these problems using WebRTC communication which also works across devices, but requires a central signaling server (STUN or TURN server) to estalblish a WebRTC connection. In this CIP we want to introduce an architecture which uses WebTorrent trackers for peer discovery to remove the need of this central component. +In a decentralized ecosystem a communication between wallet apps and dApps is still challanging. The inter-app communication on mobile devices does not directly allow remote procedure calls and is mostly restricted to Universal Links (iOS) or Deeplinks (Android). State-of-the-art solutions like WalletConnect tackle these problems using WebRTC communication which also works across devices, but requires a central signaling server (STUN or TURN server) to estalblish a WebRTC connection. In this CIP we want to introduce an architecture which uses WebTorrent trackers for peer discovery to remove the need of this central component. ## Specification @@ -211,10 +211,10 @@ sequenceDiagram ### Security Aspects -We decided to spwan the server within the dApp to force the user to manually scan a QR code (using a wallet app) or accept an "Open with " ui dialog (in case of Universal Links or Deeplinks). This prevents the user from connecting the wallet to an unwanted dApp. Additionally we need to add a few security checks to prevent a missusage of these method. +We decided to spwan the server within the dApp to force the user to manually scan a QR code (using a wallet app) or accept an "Open with ``" ui dialog (in case of Universal Links or Deeplinks). This prevents the user from connecting the wallet to an unwanted dApp. Additionally we need to add a few security checks to prevent a misusage of this method. - The wallet app needs to verifiy the origin (address) of the RPC call -- dApps should ask the user for the permission to injected the wallet names into the window.cardano object to prevent XSS attack (Maybe using a graphical representation of the wallet app address e.g. blockies) +- dApps should ask the user for permission to inject the wallet names into the window.cardano object to prevent XSS attack (Maybe using a graphical representation of the wallet app address e.g. blockies) ## Rationale From bfdb646d5be7e9e9c7d1b6b1aab15081041b7e8a Mon Sep 17 00:00:00 2001 From: Fabian Bormann Date: Thu, 1 Dec 2022 18:09:39 +0100 Subject: [PATCH 07/17] fix: relocate the demo implementation to a new repository --- CIP-????/README.md | 6 +- CIP-????/demo/README.md | 40 - CIP-????/demo/dApp.html | 51 - CIP-????/demo/ionic-app/.gitignore | 31 - CIP-????/demo/ionic-app/capacitor.config.ts | 10 - CIP-????/demo/ionic-app/config/env.js | 104 - .../demo/ionic-app/config/getHttpsConfig.js | 66 - .../ionic-app/config/jest/babelTransform.js | 29 - .../ionic-app/config/jest/cssTransform.js | 14 - .../ionic-app/config/jest/fileTransform.js | 40 - CIP-????/demo/ionic-app/config/modules.js | 134 - CIP-????/demo/ionic-app/config/paths.js | 77 - .../demo/ionic-app/config/webpack.config.js | 769 - .../persistentCache/createEnvironmentHash.js | 9 - .../config/webpackDevServer.config.js | 127 - CIP-????/demo/ionic-app/ionic.config.json | 7 - CIP-????/demo/ionic-app/package-lock.json | 31140 ---------------- CIP-????/demo/ionic-app/package.json | 183 - .../ionic-app/public/assets/icon/favicon.png | Bin 930 -> 0 bytes .../ionic-app/public/assets/icon/icon.png | Bin 23794 -> 0 bytes .../demo/ionic-app/public/assets/shapes.svg | 1 - CIP-????/demo/ionic-app/public/index.html | 31 - CIP-????/demo/ionic-app/public/manifest.json | 21 - CIP-????/demo/ionic-app/scripts/build.js | 217 - CIP-????/demo/ionic-app/scripts/start.js | 154 - CIP-????/demo/ionic-app/scripts/test.js | 52 - CIP-????/demo/ionic-app/src/App.test.tsx | 8 - CIP-????/demo/ionic-app/src/App.tsx | 76 - CIP-????/demo/ionic-app/src/bugout.d.ts | 53 - .../src/components/ExploreContainer.css | 24 - .../src/components/ExploreContainer.tsx | 16 - CIP-????/demo/ionic-app/src/index.tsx | 50 - CIP-????/demo/ionic-app/src/pages/Tab1.css | 0 CIP-????/demo/ionic-app/src/pages/Tab1.tsx | 25 - CIP-????/demo/ionic-app/src/pages/Tab2.css | 0 CIP-????/demo/ionic-app/src/pages/Tab2.tsx | 25 - CIP-????/demo/ionic-app/src/pages/Tab3.css | 0 CIP-????/demo/ionic-app/src/pages/Tab3.tsx | 25 - .../demo/ionic-app/src/react-app-env.d.ts | 71 - .../demo/ionic-app/src/reportWebVitals.ts | 15 - CIP-????/demo/ionic-app/src/service-worker.ts | 80 - .../src/serviceWorkerRegistration.ts | 142 - CIP-????/demo/ionic-app/src/setupTests.ts | 14 - .../demo/ionic-app/src/theme/variables.css | 236 - CIP-????/demo/ionic-app/tsconfig.json | 26 - 45 files changed, 3 insertions(+), 34196 deletions(-) delete mode 100644 CIP-????/demo/README.md delete mode 100644 CIP-????/demo/dApp.html delete mode 100644 CIP-????/demo/ionic-app/.gitignore delete mode 100644 CIP-????/demo/ionic-app/capacitor.config.ts delete mode 100644 CIP-????/demo/ionic-app/config/env.js delete mode 100644 CIP-????/demo/ionic-app/config/getHttpsConfig.js delete mode 100644 CIP-????/demo/ionic-app/config/jest/babelTransform.js delete mode 100644 CIP-????/demo/ionic-app/config/jest/cssTransform.js delete mode 100644 CIP-????/demo/ionic-app/config/jest/fileTransform.js delete mode 100644 CIP-????/demo/ionic-app/config/modules.js delete mode 100644 CIP-????/demo/ionic-app/config/paths.js delete mode 100644 CIP-????/demo/ionic-app/config/webpack.config.js delete mode 100644 CIP-????/demo/ionic-app/config/webpack/persistentCache/createEnvironmentHash.js delete mode 100644 CIP-????/demo/ionic-app/config/webpackDevServer.config.js delete mode 100644 CIP-????/demo/ionic-app/ionic.config.json delete mode 100644 CIP-????/demo/ionic-app/package-lock.json delete mode 100644 CIP-????/demo/ionic-app/package.json delete mode 100644 CIP-????/demo/ionic-app/public/assets/icon/favicon.png delete mode 100644 CIP-????/demo/ionic-app/public/assets/icon/icon.png delete mode 100644 CIP-????/demo/ionic-app/public/assets/shapes.svg delete mode 100644 CIP-????/demo/ionic-app/public/index.html delete mode 100644 CIP-????/demo/ionic-app/public/manifest.json delete mode 100644 CIP-????/demo/ionic-app/scripts/build.js delete mode 100644 CIP-????/demo/ionic-app/scripts/start.js delete mode 100644 CIP-????/demo/ionic-app/scripts/test.js delete mode 100644 CIP-????/demo/ionic-app/src/App.test.tsx delete mode 100644 CIP-????/demo/ionic-app/src/App.tsx delete mode 100644 CIP-????/demo/ionic-app/src/bugout.d.ts delete mode 100644 CIP-????/demo/ionic-app/src/components/ExploreContainer.css delete mode 100644 CIP-????/demo/ionic-app/src/components/ExploreContainer.tsx delete mode 100644 CIP-????/demo/ionic-app/src/index.tsx delete mode 100644 CIP-????/demo/ionic-app/src/pages/Tab1.css delete mode 100644 CIP-????/demo/ionic-app/src/pages/Tab1.tsx delete mode 100644 CIP-????/demo/ionic-app/src/pages/Tab2.css delete mode 100644 CIP-????/demo/ionic-app/src/pages/Tab2.tsx delete mode 100644 CIP-????/demo/ionic-app/src/pages/Tab3.css delete mode 100644 CIP-????/demo/ionic-app/src/pages/Tab3.tsx delete mode 100644 CIP-????/demo/ionic-app/src/react-app-env.d.ts delete mode 100644 CIP-????/demo/ionic-app/src/reportWebVitals.ts delete mode 100644 CIP-????/demo/ionic-app/src/service-worker.ts delete mode 100644 CIP-????/demo/ionic-app/src/serviceWorkerRegistration.ts delete mode 100644 CIP-????/demo/ionic-app/src/setupTests.ts delete mode 100644 CIP-????/demo/ionic-app/src/theme/variables.css delete mode 100644 CIP-????/demo/ionic-app/tsconfig.json diff --git a/CIP-????/README.md b/CIP-????/README.md index cd24cb417f..a1bd70e9b9 100644 --- a/CIP-????/README.md +++ b/CIP-????/README.md @@ -1,6 +1,6 @@ --- CIP: ? -Title: Decentralized WebRTC dApp/Wallet Communication Using WebTorrent Tracker for Peer Discovery +Title: Decentralized WebRTC dApp-Wallet Communication Status: Proposed Category: Wallets Authors: @@ -15,7 +15,7 @@ Created: 2022-11-29 License: CC-BY-4.0 --- -# CIP-????: Decentralized WebRTC dApp/Wallet Communication Using WebTorrent Tracker for Peer Discovery +# CIP-????: Decentralized WebRTC dApp-Wallet Communication ## Abstract @@ -101,7 +101,7 @@ For this proof of concept we wrote two small pieces of software: - A html page aka the dApp - An ionic react app (to target mutliple devices) aka the wallet app -The whole code is provided within this [demo folder](demo) that also contains a [step-by-step guide](demo/README.md). +The whole code is provided within this [demo implementation](https://github.com/fabianbormann/WebRTC-WebTorrent-tracker-communication-demo) that also contains a step-by-step guide. #### dApp diff --git a/CIP-????/demo/README.md b/CIP-????/demo/README.md deleted file mode 100644 index a5357dd5f3..0000000000 --- a/CIP-????/demo/README.md +++ /dev/null @@ -1,40 +0,0 @@ -# Run the demo - -## Prerequirements - -* node>=16.x.x, npm>=8.x.x - -## Getting Started - -```zsh -cd ionic-app -npm i -``` - -## Run the server (aka dApp) - -Open the dApp.html file & your dev tools to see the console log outputs. - -## Run the client (aka Wallet App) - -```zsh -cd ionic-app -npm start -``` - -## Testing (PoC) - -Once you have the server and client running you should see something like - -```js -"[info]: injected api of boostwallet into window.cardano" -``` - -in your dApp logs. Now you can issue - -```js -window.cardano.boostwallet.getRewardAddresses().then(result => console.log(result)) -``` - -to execute the remote call and get the reward address from your Wallet App. - diff --git a/CIP-????/demo/dApp.html b/CIP-????/demo/dApp.html deleted file mode 100644 index 343c3bdfc2..0000000000 --- a/CIP-????/demo/dApp.html +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - - - - DApp - - -

Simple Example Dapp

- - \ No newline at end of file diff --git a/CIP-????/demo/ionic-app/.gitignore b/CIP-????/demo/ionic-app/.gitignore deleted file mode 100644 index d258871014..0000000000 --- a/CIP-????/demo/ionic-app/.gitignore +++ /dev/null @@ -1,31 +0,0 @@ -# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. - -# dependencies -/node_modules -/.pnp -.pnp.js - -# testing -/coverage - -# production -/build - -# misc -.DS_Store -.env.local -.env.development.local -.env.test.local -.env.production.local -/.vscode/* -!/.vscode/extensions.json -.idea - -npm-debug.log* -yarn-debug.log* -yarn-error.log* - -# Optional eslint cache -.eslintcache - -.vscode/ \ No newline at end of file diff --git a/CIP-????/demo/ionic-app/capacitor.config.ts b/CIP-????/demo/ionic-app/capacitor.config.ts deleted file mode 100644 index 341bcb2607..0000000000 --- a/CIP-????/demo/ionic-app/capacitor.config.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { CapacitorConfig } from '@capacitor/cli'; - -const config: CapacitorConfig = { - appId: 'io.ionic.starter', - appName: 'WalletApp', - webDir: 'build', - bundledWebRuntime: false -}; - -export default config; diff --git a/CIP-????/demo/ionic-app/config/env.js b/CIP-????/demo/ionic-app/config/env.js deleted file mode 100644 index ffa7e496aa..0000000000 --- a/CIP-????/demo/ionic-app/config/env.js +++ /dev/null @@ -1,104 +0,0 @@ -'use strict'; - -const fs = require('fs'); -const path = require('path'); -const paths = require('./paths'); - -// Make sure that including paths.js after env.js will read .env variables. -delete require.cache[require.resolve('./paths')]; - -const NODE_ENV = process.env.NODE_ENV; -if (!NODE_ENV) { - throw new Error( - 'The NODE_ENV environment variable is required but was not specified.' - ); -} - -// https://github.com/bkeepers/dotenv#what-other-env-files-can-i-use -const dotenvFiles = [ - `${paths.dotenv}.${NODE_ENV}.local`, - // Don't include `.env.local` for `test` environment - // since normally you expect tests to produce the same - // results for everyone - NODE_ENV !== 'test' && `${paths.dotenv}.local`, - `${paths.dotenv}.${NODE_ENV}`, - paths.dotenv, -].filter(Boolean); - -// Load environment variables from .env* files. Suppress warnings using silent -// if this file is missing. dotenv will never modify any environment variables -// that have already been set. Variable expansion is supported in .env files. -// https://github.com/motdotla/dotenv -// https://github.com/motdotla/dotenv-expand -dotenvFiles.forEach(dotenvFile => { - if (fs.existsSync(dotenvFile)) { - require('dotenv-expand')( - require('dotenv').config({ - path: dotenvFile, - }) - ); - } -}); - -// We support resolving modules according to `NODE_PATH`. -// This lets you use absolute paths in imports inside large monorepos: -// https://github.com/facebook/create-react-app/issues/253. -// It works similar to `NODE_PATH` in Node itself: -// https://nodejs.org/api/modules.html#modules_loading_from_the_global_folders -// Note that unlike in Node, only *relative* paths from `NODE_PATH` are honored. -// Otherwise, we risk importing Node.js core modules into an app instead of webpack shims. -// https://github.com/facebook/create-react-app/issues/1023#issuecomment-265344421 -// We also resolve them to make sure all tools using them work consistently. -const appDirectory = fs.realpathSync(process.cwd()); -process.env.NODE_PATH = (process.env.NODE_PATH || '') - .split(path.delimiter) - .filter(folder => folder && !path.isAbsolute(folder)) - .map(folder => path.resolve(appDirectory, folder)) - .join(path.delimiter); - -// Grab NODE_ENV and REACT_APP_* environment variables and prepare them to be -// injected into the application via DefinePlugin in webpack configuration. -const REACT_APP = /^REACT_APP_/i; - -function getClientEnvironment(publicUrl) { - const raw = Object.keys(process.env) - .filter(key => REACT_APP.test(key)) - .reduce( - (env, key) => { - env[key] = process.env[key]; - return env; - }, - { - // Useful for determining whether we’re running in production mode. - // Most importantly, it switches React into the correct mode. - NODE_ENV: process.env.NODE_ENV || 'development', - // Useful for resolving the correct path to static assets in `public`. - // For example, . - // This should only be used as an escape hatch. Normally you would put - // images into the `src` and `import` them in code to get their paths. - PUBLIC_URL: publicUrl, - // We support configuring the sockjs pathname during development. - // These settings let a developer run multiple simultaneous projects. - // They are used as the connection `hostname`, `pathname` and `port` - // in webpackHotDevClient. They are used as the `sockHost`, `sockPath` - // and `sockPort` options in webpack-dev-server. - WDS_SOCKET_HOST: process.env.WDS_SOCKET_HOST, - WDS_SOCKET_PATH: process.env.WDS_SOCKET_PATH, - WDS_SOCKET_PORT: process.env.WDS_SOCKET_PORT, - // Whether or not react-refresh is enabled. - // It is defined here so it is available in the webpackHotDevClient. - FAST_REFRESH: process.env.FAST_REFRESH !== 'false', - } - ); - // Stringify all values so we can feed into webpack DefinePlugin - const stringified = { - 'process.env': Object.keys(raw).reduce((env, key) => { - env[key] = JSON.stringify(raw[key]); - return env; - }, {}), - }; - - return { raw, stringified }; -} - -module.exports = getClientEnvironment; diff --git a/CIP-????/demo/ionic-app/config/getHttpsConfig.js b/CIP-????/demo/ionic-app/config/getHttpsConfig.js deleted file mode 100644 index 013d493c1b..0000000000 --- a/CIP-????/demo/ionic-app/config/getHttpsConfig.js +++ /dev/null @@ -1,66 +0,0 @@ -'use strict'; - -const fs = require('fs'); -const path = require('path'); -const crypto = require('crypto'); -const chalk = require('react-dev-utils/chalk'); -const paths = require('./paths'); - -// Ensure the certificate and key provided are valid and if not -// throw an easy to debug error -function validateKeyAndCerts({ cert, key, keyFile, crtFile }) { - let encrypted; - try { - // publicEncrypt will throw an error with an invalid cert - encrypted = crypto.publicEncrypt(cert, Buffer.from('test')); - } catch (err) { - throw new Error( - `The certificate "${chalk.yellow(crtFile)}" is invalid.\n${err.message}` - ); - } - - try { - // privateDecrypt will throw an error with an invalid key - crypto.privateDecrypt(key, encrypted); - } catch (err) { - throw new Error( - `The certificate key "${chalk.yellow(keyFile)}" is invalid.\n${ - err.message - }` - ); - } -} - -// Read file and throw an error if it doesn't exist -function readEnvFile(file, type) { - if (!fs.existsSync(file)) { - throw new Error( - `You specified ${chalk.cyan( - type - )} in your env, but the file "${chalk.yellow(file)}" can't be found.` - ); - } - return fs.readFileSync(file); -} - -// Get the https config -// Return cert files if provided in env, otherwise just true or false -function getHttpsConfig() { - const { SSL_CRT_FILE, SSL_KEY_FILE, HTTPS } = process.env; - const isHttps = HTTPS === 'true'; - - if (isHttps && SSL_CRT_FILE && SSL_KEY_FILE) { - const crtFile = path.resolve(paths.appPath, SSL_CRT_FILE); - const keyFile = path.resolve(paths.appPath, SSL_KEY_FILE); - const config = { - cert: readEnvFile(crtFile, 'SSL_CRT_FILE'), - key: readEnvFile(keyFile, 'SSL_KEY_FILE'), - }; - - validateKeyAndCerts({ ...config, keyFile, crtFile }); - return config; - } - return isHttps; -} - -module.exports = getHttpsConfig; diff --git a/CIP-????/demo/ionic-app/config/jest/babelTransform.js b/CIP-????/demo/ionic-app/config/jest/babelTransform.js deleted file mode 100644 index 5b391e4055..0000000000 --- a/CIP-????/demo/ionic-app/config/jest/babelTransform.js +++ /dev/null @@ -1,29 +0,0 @@ -'use strict'; - -const babelJest = require('babel-jest').default; - -const hasJsxRuntime = (() => { - if (process.env.DISABLE_NEW_JSX_TRANSFORM === 'true') { - return false; - } - - try { - require.resolve('react/jsx-runtime'); - return true; - } catch (e) { - return false; - } -})(); - -module.exports = babelJest.createTransformer({ - presets: [ - [ - require.resolve('babel-preset-react-app'), - { - runtime: hasJsxRuntime ? 'automatic' : 'classic', - }, - ], - ], - babelrc: false, - configFile: false, -}); diff --git a/CIP-????/demo/ionic-app/config/jest/cssTransform.js b/CIP-????/demo/ionic-app/config/jest/cssTransform.js deleted file mode 100644 index 8f65114812..0000000000 --- a/CIP-????/demo/ionic-app/config/jest/cssTransform.js +++ /dev/null @@ -1,14 +0,0 @@ -'use strict'; - -// This is a custom Jest transformer turning style imports into empty objects. -// http://facebook.github.io/jest/docs/en/webpack.html - -module.exports = { - process() { - return 'module.exports = {};'; - }, - getCacheKey() { - // The output is always the same. - return 'cssTransform'; - }, -}; diff --git a/CIP-????/demo/ionic-app/config/jest/fileTransform.js b/CIP-????/demo/ionic-app/config/jest/fileTransform.js deleted file mode 100644 index aab67618c3..0000000000 --- a/CIP-????/demo/ionic-app/config/jest/fileTransform.js +++ /dev/null @@ -1,40 +0,0 @@ -'use strict'; - -const path = require('path'); -const camelcase = require('camelcase'); - -// This is a custom Jest transformer turning file imports into filenames. -// http://facebook.github.io/jest/docs/en/webpack.html - -module.exports = { - process(src, filename) { - const assetFilename = JSON.stringify(path.basename(filename)); - - if (filename.match(/\.svg$/)) { - // Based on how SVGR generates a component name: - // https://github.com/smooth-code/svgr/blob/01b194cf967347d43d4cbe6b434404731b87cf27/packages/core/src/state.js#L6 - const pascalCaseFilename = camelcase(path.parse(filename).name, { - pascalCase: true, - }); - const componentName = `Svg${pascalCaseFilename}`; - return `const React = require('react'); - module.exports = { - __esModule: true, - default: ${assetFilename}, - ReactComponent: React.forwardRef(function ${componentName}(props, ref) { - return { - $$typeof: Symbol.for('react.element'), - type: 'svg', - ref: ref, - key: null, - props: Object.assign({}, props, { - children: ${assetFilename} - }) - }; - }), - };`; - } - - return `module.exports = ${assetFilename};`; - }, -}; diff --git a/CIP-????/demo/ionic-app/config/modules.js b/CIP-????/demo/ionic-app/config/modules.js deleted file mode 100644 index d63e41d78d..0000000000 --- a/CIP-????/demo/ionic-app/config/modules.js +++ /dev/null @@ -1,134 +0,0 @@ -'use strict'; - -const fs = require('fs'); -const path = require('path'); -const paths = require('./paths'); -const chalk = require('react-dev-utils/chalk'); -const resolve = require('resolve'); - -/** - * Get additional module paths based on the baseUrl of a compilerOptions object. - * - * @param {Object} options - */ -function getAdditionalModulePaths(options = {}) { - const baseUrl = options.baseUrl; - - if (!baseUrl) { - return ''; - } - - const baseUrlResolved = path.resolve(paths.appPath, baseUrl); - - // We don't need to do anything if `baseUrl` is set to `node_modules`. This is - // the default behavior. - if (path.relative(paths.appNodeModules, baseUrlResolved) === '') { - return null; - } - - // Allow the user set the `baseUrl` to `appSrc`. - if (path.relative(paths.appSrc, baseUrlResolved) === '') { - return [paths.appSrc]; - } - - // If the path is equal to the root directory we ignore it here. - // We don't want to allow importing from the root directly as source files are - // not transpiled outside of `src`. We do allow importing them with the - // absolute path (e.g. `src/Components/Button.js`) but we set that up with - // an alias. - if (path.relative(paths.appPath, baseUrlResolved) === '') { - return null; - } - - // Otherwise, throw an error. - throw new Error( - chalk.red.bold( - "Your project's `baseUrl` can only be set to `src` or `node_modules`." + - ' Create React App does not support other values at this time.' - ) - ); -} - -/** - * Get webpack aliases based on the baseUrl of a compilerOptions object. - * - * @param {*} options - */ -function getWebpackAliases(options = {}) { - const baseUrl = options.baseUrl; - - if (!baseUrl) { - return {}; - } - - const baseUrlResolved = path.resolve(paths.appPath, baseUrl); - - if (path.relative(paths.appPath, baseUrlResolved) === '') { - return { - src: paths.appSrc, - }; - } -} - -/** - * Get jest aliases based on the baseUrl of a compilerOptions object. - * - * @param {*} options - */ -function getJestAliases(options = {}) { - const baseUrl = options.baseUrl; - - if (!baseUrl) { - return {}; - } - - const baseUrlResolved = path.resolve(paths.appPath, baseUrl); - - if (path.relative(paths.appPath, baseUrlResolved) === '') { - return { - '^src/(.*)$': '/src/$1', - }; - } -} - -function getModules() { - // Check if TypeScript is setup - const hasTsConfig = fs.existsSync(paths.appTsConfig); - const hasJsConfig = fs.existsSync(paths.appJsConfig); - - if (hasTsConfig && hasJsConfig) { - throw new Error( - 'You have both a tsconfig.json and a jsconfig.json. If you are using TypeScript please remove your jsconfig.json file.' - ); - } - - let config; - - // If there's a tsconfig.json we assume it's a - // TypeScript project and set up the config - // based on tsconfig.json - if (hasTsConfig) { - const ts = require(resolve.sync('typescript', { - basedir: paths.appNodeModules, - })); - config = ts.readConfigFile(paths.appTsConfig, ts.sys.readFile).config; - // Otherwise we'll check if there is jsconfig.json - // for non TS projects. - } else if (hasJsConfig) { - config = require(paths.appJsConfig); - } - - config = config || {}; - const options = config.compilerOptions || {}; - - const additionalModulePaths = getAdditionalModulePaths(options); - - return { - additionalModulePaths: additionalModulePaths, - webpackAliases: getWebpackAliases(options), - jestAliases: getJestAliases(options), - hasTsConfig, - }; -} - -module.exports = getModules(); diff --git a/CIP-????/demo/ionic-app/config/paths.js b/CIP-????/demo/ionic-app/config/paths.js deleted file mode 100644 index f0a6cd9c98..0000000000 --- a/CIP-????/demo/ionic-app/config/paths.js +++ /dev/null @@ -1,77 +0,0 @@ -'use strict'; - -const path = require('path'); -const fs = require('fs'); -const getPublicUrlOrPath = require('react-dev-utils/getPublicUrlOrPath'); - -// Make sure any symlinks in the project folder are resolved: -// https://github.com/facebook/create-react-app/issues/637 -const appDirectory = fs.realpathSync(process.cwd()); -const resolveApp = relativePath => path.resolve(appDirectory, relativePath); - -// We use `PUBLIC_URL` environment variable or "homepage" field to infer -// "public path" at which the app is served. -// webpack needs to know it to put the right