From ad995b1934a51f8563c4dbd7f8a7fdb4e674a6ee Mon Sep 17 00:00:00 2001
From: Fouad
Date: Wed, 5 Jul 2023 16:14:21 +0100
Subject: [PATCH] Node Tester SDK examples (#3641)
* create parcel example
* update plain html example
* move chat examples into own dir
* add examples to workspace
* update tsconfig path
* move webpack base to parent dir
---
.../examples/{ => chat-app}/parcel/README.md | 0
.../{ => chat-app}/parcel/package.json | 0
.../{ => chat-app}/parcel/src/dom-utils.ts | 0
.../{ => chat-app}/parcel/src/index.html | 0
.../{ => chat-app}/parcel/src/index.ts | 0
.../examples/chat-app/parcel/tsconfig.json | 9 ++
.../{ => chat-app}/plain-html/.babelrc | 0
.../{ => chat-app}/plain-html/README.md | 0
.../{ => chat-app}/plain-html/jest.config.js | 0
.../{ => chat-app}/plain-html/package.json | 0
.../plain-html/src/dom-utils.ts | 0
.../{ => chat-app}/plain-html/src/index.html | 0
.../{ => chat-app}/plain-html/src/index.ts | 0
.../chat-app/plain-html/tsconfig.json | 9 ++
.../plain-html/tsconfig.prod.json | 0
.../plain-html/webpack.common.js | 2 +-
.../plain-html/webpack.config.js | 0
.../{ => chat-app}/plain-html/webpack.prod.js | 0
.../react-webpack-with-theme-example/.babelrc | 0
.../README.md | 0
.../jest.config.js | 0
.../package.json | 0
.../src/App.tsx | 0
.../src/ThemeToggle.tsx | 0
.../src/context/index.tsx | 0
.../src/context/mixnet.tsx | 0
.../src/index.html | 0
.../src/index.tsx | 0
.../src/tests/App.test.tsx | 0
.../src/theme/common.ts | 0
.../src/theme/index.tsx | 0
.../src/theme/mui-theme.d.ts | 0
.../src/theme/theme.ts | 0
.../src/typings/FC.d.ts | 0
.../src/typings/svg.d.ts | 0
.../tsconfig.json | 9 ++
.../tsconfig.prod.json | 0
.../webpack.common.js | 0
.../webpack.config.js | 0
.../webpack.prod.js | 0
.../examples/node-tester/parcel/README.md | 14 +++
.../examples/node-tester/parcel/package.json | 43 +++++++
.../node-tester/parcel/src/index.html | 29 +++++
.../examples/node-tester/parcel/src/index.ts | 118 ++++++++++++++++++
.../examples/node-tester/parcel/tsconfig.json | 8 ++
.../examples/node-tester/plain-html/README.md | 2 +-
.../node-tester/plain-html/package.json | 3 +
.../node-tester/plain-html/tsconfig.json | 1 -
sdk/typescript/examples/parcel/tsconfig.json | 16 ---
.../examples/plain-html/tsconfig.json | 16 ---
.../tsconfig.json | 16 ---
51 files changed, 244 insertions(+), 51 deletions(-)
rename sdk/typescript/examples/{ => chat-app}/parcel/README.md (100%)
rename sdk/typescript/examples/{ => chat-app}/parcel/package.json (100%)
rename sdk/typescript/examples/{ => chat-app}/parcel/src/dom-utils.ts (100%)
rename sdk/typescript/examples/{ => chat-app}/parcel/src/index.html (100%)
rename sdk/typescript/examples/{ => chat-app}/parcel/src/index.ts (100%)
create mode 100644 sdk/typescript/examples/chat-app/parcel/tsconfig.json
rename sdk/typescript/examples/{ => chat-app}/plain-html/.babelrc (100%)
rename sdk/typescript/examples/{ => chat-app}/plain-html/README.md (100%)
rename sdk/typescript/examples/{ => chat-app}/plain-html/jest.config.js (100%)
rename sdk/typescript/examples/{ => chat-app}/plain-html/package.json (100%)
rename sdk/typescript/examples/{ => chat-app}/plain-html/src/dom-utils.ts (100%)
rename sdk/typescript/examples/{ => chat-app}/plain-html/src/index.html (100%)
rename sdk/typescript/examples/{ => chat-app}/plain-html/src/index.ts (100%)
create mode 100644 sdk/typescript/examples/chat-app/plain-html/tsconfig.json
rename sdk/typescript/examples/{ => chat-app}/plain-html/tsconfig.prod.json (100%)
rename sdk/typescript/examples/{ => chat-app}/plain-html/webpack.common.js (89%)
rename sdk/typescript/examples/{ => chat-app}/plain-html/webpack.config.js (100%)
rename sdk/typescript/examples/{ => chat-app}/plain-html/webpack.prod.js (100%)
rename sdk/typescript/examples/{ => chat-app}/react-webpack-with-theme-example/.babelrc (100%)
rename sdk/typescript/examples/{ => chat-app}/react-webpack-with-theme-example/README.md (100%)
rename sdk/typescript/examples/{ => chat-app}/react-webpack-with-theme-example/jest.config.js (100%)
rename sdk/typescript/examples/{ => chat-app}/react-webpack-with-theme-example/package.json (100%)
rename sdk/typescript/examples/{ => chat-app}/react-webpack-with-theme-example/src/App.tsx (100%)
rename sdk/typescript/examples/{ => chat-app}/react-webpack-with-theme-example/src/ThemeToggle.tsx (100%)
rename sdk/typescript/examples/{ => chat-app}/react-webpack-with-theme-example/src/context/index.tsx (100%)
rename sdk/typescript/examples/{ => chat-app}/react-webpack-with-theme-example/src/context/mixnet.tsx (100%)
rename sdk/typescript/examples/{ => chat-app}/react-webpack-with-theme-example/src/index.html (100%)
rename sdk/typescript/examples/{ => chat-app}/react-webpack-with-theme-example/src/index.tsx (100%)
rename sdk/typescript/examples/{ => chat-app}/react-webpack-with-theme-example/src/tests/App.test.tsx (100%)
rename sdk/typescript/examples/{ => chat-app}/react-webpack-with-theme-example/src/theme/common.ts (100%)
rename sdk/typescript/examples/{ => chat-app}/react-webpack-with-theme-example/src/theme/index.tsx (100%)
rename sdk/typescript/examples/{ => chat-app}/react-webpack-with-theme-example/src/theme/mui-theme.d.ts (100%)
rename sdk/typescript/examples/{ => chat-app}/react-webpack-with-theme-example/src/theme/theme.ts (100%)
rename sdk/typescript/examples/{ => chat-app}/react-webpack-with-theme-example/src/typings/FC.d.ts (100%)
rename sdk/typescript/examples/{ => chat-app}/react-webpack-with-theme-example/src/typings/svg.d.ts (100%)
create mode 100644 sdk/typescript/examples/chat-app/react-webpack-with-theme-example/tsconfig.json
rename sdk/typescript/examples/{ => chat-app}/react-webpack-with-theme-example/tsconfig.prod.json (100%)
rename sdk/typescript/examples/{ => chat-app}/react-webpack-with-theme-example/webpack.common.js (100%)
rename sdk/typescript/examples/{ => chat-app}/react-webpack-with-theme-example/webpack.config.js (100%)
rename sdk/typescript/examples/{ => chat-app}/react-webpack-with-theme-example/webpack.prod.js (100%)
create mode 100644 sdk/typescript/examples/node-tester/parcel/README.md
create mode 100644 sdk/typescript/examples/node-tester/parcel/package.json
create mode 100644 sdk/typescript/examples/node-tester/parcel/src/index.html
create mode 100644 sdk/typescript/examples/node-tester/parcel/src/index.ts
create mode 100644 sdk/typescript/examples/node-tester/parcel/tsconfig.json
delete mode 100644 sdk/typescript/examples/parcel/tsconfig.json
delete mode 100644 sdk/typescript/examples/plain-html/tsconfig.json
delete mode 100644 sdk/typescript/examples/react-webpack-with-theme-example/tsconfig.json
diff --git a/sdk/typescript/examples/parcel/README.md b/sdk/typescript/examples/chat-app/parcel/README.md
similarity index 100%
rename from sdk/typescript/examples/parcel/README.md
rename to sdk/typescript/examples/chat-app/parcel/README.md
diff --git a/sdk/typescript/examples/parcel/package.json b/sdk/typescript/examples/chat-app/parcel/package.json
similarity index 100%
rename from sdk/typescript/examples/parcel/package.json
rename to sdk/typescript/examples/chat-app/parcel/package.json
diff --git a/sdk/typescript/examples/parcel/src/dom-utils.ts b/sdk/typescript/examples/chat-app/parcel/src/dom-utils.ts
similarity index 100%
rename from sdk/typescript/examples/parcel/src/dom-utils.ts
rename to sdk/typescript/examples/chat-app/parcel/src/dom-utils.ts
diff --git a/sdk/typescript/examples/parcel/src/index.html b/sdk/typescript/examples/chat-app/parcel/src/index.html
similarity index 100%
rename from sdk/typescript/examples/parcel/src/index.html
rename to sdk/typescript/examples/chat-app/parcel/src/index.html
diff --git a/sdk/typescript/examples/parcel/src/index.ts b/sdk/typescript/examples/chat-app/parcel/src/index.ts
similarity index 100%
rename from sdk/typescript/examples/parcel/src/index.ts
rename to sdk/typescript/examples/chat-app/parcel/src/index.ts
diff --git a/sdk/typescript/examples/chat-app/parcel/tsconfig.json b/sdk/typescript/examples/chat-app/parcel/tsconfig.json
new file mode 100644
index 0000000000..86902367db
--- /dev/null
+++ b/sdk/typescript/examples/chat-app/parcel/tsconfig.json
@@ -0,0 +1,9 @@
+{
+ "extends": "../../../tsconfig.json",
+ "compilerOptions": {
+ "jsx": "react-jsx",
+ "outDir": "./dist"
+ },
+ "include": ["src/**/*.ts", "src/**/*.tsx"],
+ "exclude": ["node_modules", "build", "dist"]
+}
diff --git a/sdk/typescript/examples/plain-html/.babelrc b/sdk/typescript/examples/chat-app/plain-html/.babelrc
similarity index 100%
rename from sdk/typescript/examples/plain-html/.babelrc
rename to sdk/typescript/examples/chat-app/plain-html/.babelrc
diff --git a/sdk/typescript/examples/plain-html/README.md b/sdk/typescript/examples/chat-app/plain-html/README.md
similarity index 100%
rename from sdk/typescript/examples/plain-html/README.md
rename to sdk/typescript/examples/chat-app/plain-html/README.md
diff --git a/sdk/typescript/examples/plain-html/jest.config.js b/sdk/typescript/examples/chat-app/plain-html/jest.config.js
similarity index 100%
rename from sdk/typescript/examples/plain-html/jest.config.js
rename to sdk/typescript/examples/chat-app/plain-html/jest.config.js
diff --git a/sdk/typescript/examples/plain-html/package.json b/sdk/typescript/examples/chat-app/plain-html/package.json
similarity index 100%
rename from sdk/typescript/examples/plain-html/package.json
rename to sdk/typescript/examples/chat-app/plain-html/package.json
diff --git a/sdk/typescript/examples/plain-html/src/dom-utils.ts b/sdk/typescript/examples/chat-app/plain-html/src/dom-utils.ts
similarity index 100%
rename from sdk/typescript/examples/plain-html/src/dom-utils.ts
rename to sdk/typescript/examples/chat-app/plain-html/src/dom-utils.ts
diff --git a/sdk/typescript/examples/plain-html/src/index.html b/sdk/typescript/examples/chat-app/plain-html/src/index.html
similarity index 100%
rename from sdk/typescript/examples/plain-html/src/index.html
rename to sdk/typescript/examples/chat-app/plain-html/src/index.html
diff --git a/sdk/typescript/examples/plain-html/src/index.ts b/sdk/typescript/examples/chat-app/plain-html/src/index.ts
similarity index 100%
rename from sdk/typescript/examples/plain-html/src/index.ts
rename to sdk/typescript/examples/chat-app/plain-html/src/index.ts
diff --git a/sdk/typescript/examples/chat-app/plain-html/tsconfig.json b/sdk/typescript/examples/chat-app/plain-html/tsconfig.json
new file mode 100644
index 0000000000..86902367db
--- /dev/null
+++ b/sdk/typescript/examples/chat-app/plain-html/tsconfig.json
@@ -0,0 +1,9 @@
+{
+ "extends": "../../../tsconfig.json",
+ "compilerOptions": {
+ "jsx": "react-jsx",
+ "outDir": "./dist"
+ },
+ "include": ["src/**/*.ts", "src/**/*.tsx"],
+ "exclude": ["node_modules", "build", "dist"]
+}
diff --git a/sdk/typescript/examples/plain-html/tsconfig.prod.json b/sdk/typescript/examples/chat-app/plain-html/tsconfig.prod.json
similarity index 100%
rename from sdk/typescript/examples/plain-html/tsconfig.prod.json
rename to sdk/typescript/examples/chat-app/plain-html/tsconfig.prod.json
diff --git a/sdk/typescript/examples/plain-html/webpack.common.js b/sdk/typescript/examples/chat-app/plain-html/webpack.common.js
similarity index 89%
rename from sdk/typescript/examples/plain-html/webpack.common.js
rename to sdk/typescript/examples/chat-app/plain-html/webpack.common.js
index 3d5f37c912..ae6ef6dc8e 100644
--- a/sdk/typescript/examples/plain-html/webpack.common.js
+++ b/sdk/typescript/examples/chat-app/plain-html/webpack.common.js
@@ -1,6 +1,6 @@
const path = require('path');
const { mergeWithRules } = require('webpack-merge');
-const { webpackCommon } = require('../.webpack/webpack.base');
+const { webpackCommon } = require('../../.webpack/webpack.base');
module.exports = mergeWithRules({
module: {
diff --git a/sdk/typescript/examples/plain-html/webpack.config.js b/sdk/typescript/examples/chat-app/plain-html/webpack.config.js
similarity index 100%
rename from sdk/typescript/examples/plain-html/webpack.config.js
rename to sdk/typescript/examples/chat-app/plain-html/webpack.config.js
diff --git a/sdk/typescript/examples/plain-html/webpack.prod.js b/sdk/typescript/examples/chat-app/plain-html/webpack.prod.js
similarity index 100%
rename from sdk/typescript/examples/plain-html/webpack.prod.js
rename to sdk/typescript/examples/chat-app/plain-html/webpack.prod.js
diff --git a/sdk/typescript/examples/react-webpack-with-theme-example/.babelrc b/sdk/typescript/examples/chat-app/react-webpack-with-theme-example/.babelrc
similarity index 100%
rename from sdk/typescript/examples/react-webpack-with-theme-example/.babelrc
rename to sdk/typescript/examples/chat-app/react-webpack-with-theme-example/.babelrc
diff --git a/sdk/typescript/examples/react-webpack-with-theme-example/README.md b/sdk/typescript/examples/chat-app/react-webpack-with-theme-example/README.md
similarity index 100%
rename from sdk/typescript/examples/react-webpack-with-theme-example/README.md
rename to sdk/typescript/examples/chat-app/react-webpack-with-theme-example/README.md
diff --git a/sdk/typescript/examples/react-webpack-with-theme-example/jest.config.js b/sdk/typescript/examples/chat-app/react-webpack-with-theme-example/jest.config.js
similarity index 100%
rename from sdk/typescript/examples/react-webpack-with-theme-example/jest.config.js
rename to sdk/typescript/examples/chat-app/react-webpack-with-theme-example/jest.config.js
diff --git a/sdk/typescript/examples/react-webpack-with-theme-example/package.json b/sdk/typescript/examples/chat-app/react-webpack-with-theme-example/package.json
similarity index 100%
rename from sdk/typescript/examples/react-webpack-with-theme-example/package.json
rename to sdk/typescript/examples/chat-app/react-webpack-with-theme-example/package.json
diff --git a/sdk/typescript/examples/react-webpack-with-theme-example/src/App.tsx b/sdk/typescript/examples/chat-app/react-webpack-with-theme-example/src/App.tsx
similarity index 100%
rename from sdk/typescript/examples/react-webpack-with-theme-example/src/App.tsx
rename to sdk/typescript/examples/chat-app/react-webpack-with-theme-example/src/App.tsx
diff --git a/sdk/typescript/examples/react-webpack-with-theme-example/src/ThemeToggle.tsx b/sdk/typescript/examples/chat-app/react-webpack-with-theme-example/src/ThemeToggle.tsx
similarity index 100%
rename from sdk/typescript/examples/react-webpack-with-theme-example/src/ThemeToggle.tsx
rename to sdk/typescript/examples/chat-app/react-webpack-with-theme-example/src/ThemeToggle.tsx
diff --git a/sdk/typescript/examples/react-webpack-with-theme-example/src/context/index.tsx b/sdk/typescript/examples/chat-app/react-webpack-with-theme-example/src/context/index.tsx
similarity index 100%
rename from sdk/typescript/examples/react-webpack-with-theme-example/src/context/index.tsx
rename to sdk/typescript/examples/chat-app/react-webpack-with-theme-example/src/context/index.tsx
diff --git a/sdk/typescript/examples/react-webpack-with-theme-example/src/context/mixnet.tsx b/sdk/typescript/examples/chat-app/react-webpack-with-theme-example/src/context/mixnet.tsx
similarity index 100%
rename from sdk/typescript/examples/react-webpack-with-theme-example/src/context/mixnet.tsx
rename to sdk/typescript/examples/chat-app/react-webpack-with-theme-example/src/context/mixnet.tsx
diff --git a/sdk/typescript/examples/react-webpack-with-theme-example/src/index.html b/sdk/typescript/examples/chat-app/react-webpack-with-theme-example/src/index.html
similarity index 100%
rename from sdk/typescript/examples/react-webpack-with-theme-example/src/index.html
rename to sdk/typescript/examples/chat-app/react-webpack-with-theme-example/src/index.html
diff --git a/sdk/typescript/examples/react-webpack-with-theme-example/src/index.tsx b/sdk/typescript/examples/chat-app/react-webpack-with-theme-example/src/index.tsx
similarity index 100%
rename from sdk/typescript/examples/react-webpack-with-theme-example/src/index.tsx
rename to sdk/typescript/examples/chat-app/react-webpack-with-theme-example/src/index.tsx
diff --git a/sdk/typescript/examples/react-webpack-with-theme-example/src/tests/App.test.tsx b/sdk/typescript/examples/chat-app/react-webpack-with-theme-example/src/tests/App.test.tsx
similarity index 100%
rename from sdk/typescript/examples/react-webpack-with-theme-example/src/tests/App.test.tsx
rename to sdk/typescript/examples/chat-app/react-webpack-with-theme-example/src/tests/App.test.tsx
diff --git a/sdk/typescript/examples/react-webpack-with-theme-example/src/theme/common.ts b/sdk/typescript/examples/chat-app/react-webpack-with-theme-example/src/theme/common.ts
similarity index 100%
rename from sdk/typescript/examples/react-webpack-with-theme-example/src/theme/common.ts
rename to sdk/typescript/examples/chat-app/react-webpack-with-theme-example/src/theme/common.ts
diff --git a/sdk/typescript/examples/react-webpack-with-theme-example/src/theme/index.tsx b/sdk/typescript/examples/chat-app/react-webpack-with-theme-example/src/theme/index.tsx
similarity index 100%
rename from sdk/typescript/examples/react-webpack-with-theme-example/src/theme/index.tsx
rename to sdk/typescript/examples/chat-app/react-webpack-with-theme-example/src/theme/index.tsx
diff --git a/sdk/typescript/examples/react-webpack-with-theme-example/src/theme/mui-theme.d.ts b/sdk/typescript/examples/chat-app/react-webpack-with-theme-example/src/theme/mui-theme.d.ts
similarity index 100%
rename from sdk/typescript/examples/react-webpack-with-theme-example/src/theme/mui-theme.d.ts
rename to sdk/typescript/examples/chat-app/react-webpack-with-theme-example/src/theme/mui-theme.d.ts
diff --git a/sdk/typescript/examples/react-webpack-with-theme-example/src/theme/theme.ts b/sdk/typescript/examples/chat-app/react-webpack-with-theme-example/src/theme/theme.ts
similarity index 100%
rename from sdk/typescript/examples/react-webpack-with-theme-example/src/theme/theme.ts
rename to sdk/typescript/examples/chat-app/react-webpack-with-theme-example/src/theme/theme.ts
diff --git a/sdk/typescript/examples/react-webpack-with-theme-example/src/typings/FC.d.ts b/sdk/typescript/examples/chat-app/react-webpack-with-theme-example/src/typings/FC.d.ts
similarity index 100%
rename from sdk/typescript/examples/react-webpack-with-theme-example/src/typings/FC.d.ts
rename to sdk/typescript/examples/chat-app/react-webpack-with-theme-example/src/typings/FC.d.ts
diff --git a/sdk/typescript/examples/react-webpack-with-theme-example/src/typings/svg.d.ts b/sdk/typescript/examples/chat-app/react-webpack-with-theme-example/src/typings/svg.d.ts
similarity index 100%
rename from sdk/typescript/examples/react-webpack-with-theme-example/src/typings/svg.d.ts
rename to sdk/typescript/examples/chat-app/react-webpack-with-theme-example/src/typings/svg.d.ts
diff --git a/sdk/typescript/examples/chat-app/react-webpack-with-theme-example/tsconfig.json b/sdk/typescript/examples/chat-app/react-webpack-with-theme-example/tsconfig.json
new file mode 100644
index 0000000000..86902367db
--- /dev/null
+++ b/sdk/typescript/examples/chat-app/react-webpack-with-theme-example/tsconfig.json
@@ -0,0 +1,9 @@
+{
+ "extends": "../../../tsconfig.json",
+ "compilerOptions": {
+ "jsx": "react-jsx",
+ "outDir": "./dist"
+ },
+ "include": ["src/**/*.ts", "src/**/*.tsx"],
+ "exclude": ["node_modules", "build", "dist"]
+}
diff --git a/sdk/typescript/examples/react-webpack-with-theme-example/tsconfig.prod.json b/sdk/typescript/examples/chat-app/react-webpack-with-theme-example/tsconfig.prod.json
similarity index 100%
rename from sdk/typescript/examples/react-webpack-with-theme-example/tsconfig.prod.json
rename to sdk/typescript/examples/chat-app/react-webpack-with-theme-example/tsconfig.prod.json
diff --git a/sdk/typescript/examples/react-webpack-with-theme-example/webpack.common.js b/sdk/typescript/examples/chat-app/react-webpack-with-theme-example/webpack.common.js
similarity index 100%
rename from sdk/typescript/examples/react-webpack-with-theme-example/webpack.common.js
rename to sdk/typescript/examples/chat-app/react-webpack-with-theme-example/webpack.common.js
diff --git a/sdk/typescript/examples/react-webpack-with-theme-example/webpack.config.js b/sdk/typescript/examples/chat-app/react-webpack-with-theme-example/webpack.config.js
similarity index 100%
rename from sdk/typescript/examples/react-webpack-with-theme-example/webpack.config.js
rename to sdk/typescript/examples/chat-app/react-webpack-with-theme-example/webpack.config.js
diff --git a/sdk/typescript/examples/react-webpack-with-theme-example/webpack.prod.js b/sdk/typescript/examples/chat-app/react-webpack-with-theme-example/webpack.prod.js
similarity index 100%
rename from sdk/typescript/examples/react-webpack-with-theme-example/webpack.prod.js
rename to sdk/typescript/examples/chat-app/react-webpack-with-theme-example/webpack.prod.js
diff --git a/sdk/typescript/examples/node-tester/parcel/README.md b/sdk/typescript/examples/node-tester/parcel/README.md
new file mode 100644
index 0000000000..6669b8f164
--- /dev/null
+++ b/sdk/typescript/examples/node-tester/parcel/README.md
@@ -0,0 +1,14 @@
+# Nym Node Tester - Parcel bundler
+
+This is an example of using the Nym Mixnet node tester.
+
+You can use this example as a seed for a new project.
+
+## Running the example
+
+Try out the node tester app by running:
+
+```
+npm install
+npm start
+```
diff --git a/sdk/typescript/examples/node-tester/parcel/package.json b/sdk/typescript/examples/node-tester/parcel/package.json
new file mode 100644
index 0000000000..27c563a40e
--- /dev/null
+++ b/sdk/typescript/examples/node-tester/parcel/package.json
@@ -0,0 +1,43 @@
+{
+ "name": "@nymproject/sdk-example-node-tester-plain-html-parcel",
+ "description": "An example project that uses WASM and plain HTML bundled with Parcel v2",
+ "version": "1.0.0",
+ "license": "Apache-2.0",
+ "source": "src/index.html",
+ "browserslist": "> 0.5%, last 2 versions, not dead",
+ "dependencies": {
+ "@nymproject/sdk": "1"
+ },
+ "devDependencies": {
+ "@types/jest": "^27.0.1",
+ "@types/node": "^16.7.13",
+ "@typescript-eslint/eslint-plugin": "^5.13.0",
+ "@typescript-eslint/parser": "^5.13.0",
+ "eslint": "^8.10.0",
+ "eslint-config-airbnb": "^19.0.4",
+ "eslint-config-airbnb-typescript": "^16.1.0",
+ "eslint-config-prettier": "^8.5.0",
+ "eslint-import-resolver-root-import": "^1.0.4",
+ "eslint-plugin-import": "^2.25.4",
+ "eslint-plugin-jest": "^26.1.1",
+ "eslint-plugin-jsx-a11y": "^6.5.1",
+ "eslint-plugin-prettier": "^4.0.0",
+ "jest": "^27.1.0",
+ "mini-css-extract-plugin": "^2.2.2",
+ "npm-run-all": "^4.1.5",
+ "prettier": "^2.8.7",
+ "ts-jest": "^27.0.5",
+ "typescript": "^4.6.2"
+ },
+ "scripts": {
+ "start": "npx parcel",
+ "build": "npx parcel build",
+ "build:serve": "npx serve dist",
+ "test": "jest",
+ "test:watch": "jest --watch",
+ "tsc": "tsc",
+ "tsc:watch": "tsc --watch",
+ "lint": "eslint src",
+ "lint:fix": "eslint src --fix"
+ }
+}
diff --git a/sdk/typescript/examples/node-tester/parcel/src/index.html b/sdk/typescript/examples/node-tester/parcel/src/index.html
new file mode 100644
index 0000000000..a7bd3057e7
--- /dev/null
+++ b/sdk/typescript/examples/node-tester/parcel/src/index.html
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+ Nym WebAssembly Demo
+
+
+
+
+
+
+
+
+
+
+
+
+
+Test a mixnode by entering the mixnode id above and click the Test button
+
+
+
+
+
+
+
+
diff --git a/sdk/typescript/examples/node-tester/parcel/src/index.ts b/sdk/typescript/examples/node-tester/parcel/src/index.ts
new file mode 100644
index 0000000000..350be6e469
--- /dev/null
+++ b/sdk/typescript/examples/node-tester/parcel/src/index.ts
@@ -0,0 +1,118 @@
+import { createNodeTesterClient, NodeTester } from '@nymproject/sdk';
+
+let nodeTester: NodeTester | null = null;
+
+/**
+ * Display messages that have been sent up the websocket. Colours them blue.
+ *
+ * @param {string} message
+ */
+function displayOutput(message: string, color?: string) {
+ const timestamp = new Date().toISOString().substr(11, 12);
+
+ const sendDiv = document.createElement('div');
+ const paragraph = document.createElement('p');
+ paragraph.setAttribute('style', `color: ${color || 'blue'}`);
+ const paragraphContent = document.createTextNode(`${timestamp} >>> ${message}`);
+ paragraph.appendChild(paragraphContent);
+
+ sendDiv.appendChild(paragraph);
+ document.getElementById('output')?.appendChild(sendDiv);
+}
+
+/**
+ * The main entry point
+ */
+async function main() {
+ nodeTester = await createNodeTesterClient();
+
+ // add node tester to the Window globally, so that it can be used from the dev tools console
+ (window as any).nodeTester = nodeTester;
+
+ if (!nodeTester) {
+ console.error('Oh no! Could not the node test');
+ return;
+ }
+
+ const nymApiUrl = 'https://validator.nymtech.net/api';
+ const nodeTesterId = new Date().toISOString(); // make a new tester id for each session
+ await nodeTester.tester.init(nymApiUrl, nodeTesterId);
+
+ const mixnodes = await (await fetch(`${nymApiUrl}/v1/mixnodes/active`)).json();
+
+ const exampleMixnodeIdentityKey = mixnodes[0].bond_information.mix_node.identity_key;
+
+ const testButton: HTMLButtonElement = document.querySelector('#test-button') as HTMLButtonElement;
+ const reconnectButton: HTMLButtonElement = document.querySelector('#reconnect-button') as HTMLButtonElement;
+ const disconnectButton: HTMLButtonElement = document.querySelector('#disconnect-button') as HTMLButtonElement;
+ const terminateButton: HTMLButtonElement = document.querySelector('#terminate-button') as HTMLButtonElement;
+
+ const mixnodeIdInput = document.getElementById('mixnodeId') as HTMLFormElement;
+
+ mixnodeIdInput.value = exampleMixnodeIdentityKey;
+
+ reconnectButton.onclick = async function () {
+ try {
+ await nodeTester?.tester.reconnectToGateway();
+ } catch (e: any) {
+ console.error('Error', e);
+ displayOutput(`ERROR: ${e.message}`, 'red');
+ }
+ };
+
+ disconnectButton.onclick = async function () {
+ try {
+ await nodeTester?.tester.disconnectFromGateway();
+ } catch (e: any) {
+ console.error('Error', e);
+ displayOutput(`ERROR: ${e.message}`, 'red');
+ }
+ };
+
+ terminateButton.onclick = async function () {
+ try {
+ await nodeTester?.terminate();
+ } catch (e: any) {
+ console.error('Error', e);
+ displayOutput(`ERROR: ${e.message}`, 'red');
+ }
+ };
+
+ if (testButton) {
+ testButton.onclick = async function () {
+ console.log('clicked');
+
+ const mixnodeId = mixnodeIdInput.value;
+ if (!nodeTester) {
+ displayOutput('ERROR: The node tester is not defined');
+ console.error('The node tester is not defined');
+ return;
+ }
+ if (!mixnodeId) {
+ displayOutput('ERROR: No mix id specified');
+ console.error('No mix id specified');
+ return;
+ }
+
+ if (nodeTester && mixnodeId) {
+ displayOutput('Starting test...');
+ try {
+ const response = await nodeTester.tester.startTest(mixnodeId);
+ displayOutput('Done!');
+ if (response) {
+ displayOutput(JSON.stringify(response, null, 2), 'green');
+ }
+ } catch (e: any) {
+ console.error('Error', e);
+ displayOutput(`ERROR: ${e.message}`, 'red');
+ }
+ }
+ };
+ }
+}
+
+// wait for the html to load
+window.addEventListener('DOMContentLoaded', () => {
+ // let's do this!
+ main();
+});
diff --git a/sdk/typescript/examples/node-tester/parcel/tsconfig.json b/sdk/typescript/examples/node-tester/parcel/tsconfig.json
new file mode 100644
index 0000000000..5403eafc03
--- /dev/null
+++ b/sdk/typescript/examples/node-tester/parcel/tsconfig.json
@@ -0,0 +1,8 @@
+{
+ "extends": "../../../tsconfig.json",
+ "compilerOptions": {
+ "outDir": "./dist"
+ },
+ "include": ["src/**/*.ts", "src/**/*.tsx"],
+ "exclude": ["node_modules", "build", "dist"]
+}
diff --git a/sdk/typescript/examples/node-tester/plain-html/README.md b/sdk/typescript/examples/node-tester/plain-html/README.md
index a255725316..7a613f68a2 100644
--- a/sdk/typescript/examples/node-tester/plain-html/README.md
+++ b/sdk/typescript/examples/node-tester/plain-html/README.md
@@ -1,4 +1,4 @@
-# HTML Nyn Node Test
+# Nym Node Tester - HTML
This is an example of using the Nym Mixnet node tester.
diff --git a/sdk/typescript/examples/node-tester/plain-html/package.json b/sdk/typescript/examples/node-tester/plain-html/package.json
index a3befe83ea..b80734f6d4 100644
--- a/sdk/typescript/examples/node-tester/plain-html/package.json
+++ b/sdk/typescript/examples/node-tester/plain-html/package.json
@@ -3,6 +3,9 @@
"description": "An example project that uses WASM node tester and plain HTML",
"version": "1.0.0",
"license": "Apache-2.0",
+ "dependencies": {
+ "@nymproject/sdk": "1"
+ },
"devDependencies": {
"@babel/core": "^7.15.0",
"@babel/plugin-transform-async-to-generator": "^7.14.5",
diff --git a/sdk/typescript/examples/node-tester/plain-html/tsconfig.json b/sdk/typescript/examples/node-tester/plain-html/tsconfig.json
index 86902367db..5403eafc03 100644
--- a/sdk/typescript/examples/node-tester/plain-html/tsconfig.json
+++ b/sdk/typescript/examples/node-tester/plain-html/tsconfig.json
@@ -1,7 +1,6 @@
{
"extends": "../../../tsconfig.json",
"compilerOptions": {
- "jsx": "react-jsx",
"outDir": "./dist"
},
"include": ["src/**/*.ts", "src/**/*.tsx"],
diff --git a/sdk/typescript/examples/parcel/tsconfig.json b/sdk/typescript/examples/parcel/tsconfig.json
deleted file mode 100644
index b8059e8698..0000000000
--- a/sdk/typescript/examples/parcel/tsconfig.json
+++ /dev/null
@@ -1,16 +0,0 @@
-{
- "extends": "../../tsconfig.json",
- "compilerOptions": {
- "jsx": "react-jsx",
- "outDir": "./dist"
- },
- "include": [
- "src/**/*.ts",
- "src/**/*.tsx"
- ],
- "exclude": [
- "node_modules",
- "build",
- "dist"
- ]
-}
diff --git a/sdk/typescript/examples/plain-html/tsconfig.json b/sdk/typescript/examples/plain-html/tsconfig.json
deleted file mode 100644
index b8059e8698..0000000000
--- a/sdk/typescript/examples/plain-html/tsconfig.json
+++ /dev/null
@@ -1,16 +0,0 @@
-{
- "extends": "../../tsconfig.json",
- "compilerOptions": {
- "jsx": "react-jsx",
- "outDir": "./dist"
- },
- "include": [
- "src/**/*.ts",
- "src/**/*.tsx"
- ],
- "exclude": [
- "node_modules",
- "build",
- "dist"
- ]
-}
diff --git a/sdk/typescript/examples/react-webpack-with-theme-example/tsconfig.json b/sdk/typescript/examples/react-webpack-with-theme-example/tsconfig.json
deleted file mode 100644
index b8059e8698..0000000000
--- a/sdk/typescript/examples/react-webpack-with-theme-example/tsconfig.json
+++ /dev/null
@@ -1,16 +0,0 @@
-{
- "extends": "../../tsconfig.json",
- "compilerOptions": {
- "jsx": "react-jsx",
- "outDir": "./dist"
- },
- "include": [
- "src/**/*.ts",
- "src/**/*.tsx"
- ],
- "exclude": [
- "node_modules",
- "build",
- "dist"
- ]
-}