From a20b7809d61ff9a9732aba82b99bbe99f229b935 Mon Sep 17 00:00:00 2001 From: "fryorcraken.eth" Date: Fri, 4 Nov 2022 11:13:12 +1100 Subject: [PATCH] chore: init message-encryption package --- packages/message-encryption/.eslintrc.cjs | 6 ++ packages/message-encryption/.mocharc.json | 11 +++ packages/message-encryption/.prettierignore | 4 + packages/message-encryption/karma.conf.cjs | 45 ++++++++++ packages/message-encryption/package.json | 90 +++++++++++++++++++ packages/message-encryption/rollup.config.js | 21 +++++ packages/message-encryption/tsconfig.dev.json | 8 ++ packages/message-encryption/tsconfig.json | 54 +++++++++++ typedoc.json | 3 +- 9 files changed, 241 insertions(+), 1 deletion(-) create mode 100644 packages/message-encryption/.eslintrc.cjs create mode 100644 packages/message-encryption/.mocharc.json create mode 100644 packages/message-encryption/.prettierignore create mode 100644 packages/message-encryption/karma.conf.cjs create mode 100644 packages/message-encryption/package.json create mode 100644 packages/message-encryption/rollup.config.js create mode 100644 packages/message-encryption/tsconfig.dev.json create mode 100644 packages/message-encryption/tsconfig.json diff --git a/packages/message-encryption/.eslintrc.cjs b/packages/message-encryption/.eslintrc.cjs new file mode 100644 index 0000000000..324f1f526d --- /dev/null +++ b/packages/message-encryption/.eslintrc.cjs @@ -0,0 +1,6 @@ +module.exports = { + parserOptions: { + tsconfigRootDir: __dirname, + project: "./tsconfig.dev.json", + }, +}; diff --git a/packages/message-encryption/.mocharc.json b/packages/message-encryption/.mocharc.json new file mode 100644 index 0000000000..db9dd73531 --- /dev/null +++ b/packages/message-encryption/.mocharc.json @@ -0,0 +1,11 @@ +{ + "extension": ["ts"], + "spec": "src/**/*.spec.ts", + "require": ["ts-node/register", "isomorphic-fetch", "jsdom-global/register"], + "loader": "ts-node/esm", + "node-option": [ + "experimental-specifier-resolution=node", + "loader=ts-node/esm" + ], + "exit": true +} diff --git a/packages/message-encryption/.prettierignore b/packages/message-encryption/.prettierignore new file mode 100644 index 0000000000..fecb37a393 --- /dev/null +++ b/packages/message-encryption/.prettierignore @@ -0,0 +1,4 @@ +build +bundle +dist +node_modules diff --git a/packages/message-encryption/karma.conf.cjs b/packages/message-encryption/karma.conf.cjs new file mode 100644 index 0000000000..8ee5033706 --- /dev/null +++ b/packages/message-encryption/karma.conf.cjs @@ -0,0 +1,45 @@ +process.env.CHROME_BIN = require("puppeteer").executablePath(); +const webpack = require("webpack"); + +module.exports = function (config) { + config.set({ + frameworks: ["webpack", "mocha"], + files: ["src/**/*.ts"], + preprocessors: { + "src/**/*.ts": ["webpack"], + }, + envPreprocessor: ["CI"], + reporters: ["progress"], + browsers: ["ChromeHeadless"], + singleRun: true, + client: { + mocha: { + timeout: 6000, // Default is 2s + }, + }, + webpack: { + mode: "development", + module: { + rules: [{ test: /\.([cm]?ts|tsx)$/, loader: "ts-loader" }], + }, + plugins: [ + new webpack.DefinePlugin({ + "process.env.CI": process.env.CI || false, + }), + new webpack.ProvidePlugin({ + process: "process/browser.js", + }), + ], + resolve: { + extensions: [".ts", ".tsx", ".js"], + extensionAlias: { + ".js": [".js", ".ts"], + ".cjs": [".cjs", ".cts"], + ".mjs": [".mjs", ".mts"], + }, + }, + stats: { warnings: false }, + devtool: "inline-source-map", + }, + }); +}; diff --git a/packages/message-encryption/package.json b/packages/message-encryption/package.json new file mode 100644 index 0000000000..0f1c288318 --- /dev/null +++ b/packages/message-encryption/package.json @@ -0,0 +1,90 @@ +{ + "name": "@waku/message-encryption", + "version": "0.0.1", + "description": "Waku Message Payload Encryption", + "types": "./dist/index.d.ts", + "module": "./dist/index.js", + "exports": { + ".": { + "types": "./dist/index.d.ts", + "import": "./dist/index.js" + } + }, + "type": "module", + "author": "Waku Team", + "homepage": "https://github.com/waku-org/js-waku/tree/master/packages/message-encryption#readme", + "repository": { + "type": "git", + "url": "https://github.com/waku-org/js-waku.git" + }, + "bugs": { + "url": "https://github.com/waku-org/js-waku/issues" + }, + "license": "MIT OR Apache-2.0", + "keywords": [ + "waku", + "decentralized", + "secure", + "communication", + "web3", + "ethereum", + "dapps", + "privacy" + ], + "scripts": { + "build": "run-s build:**", + "build:esm": "tsc", + "build:bundle": "rollup --config rollup.config.js", + "fix": "run-s fix:*", + "fix:prettier": "prettier . --write", + "fix:lint": "eslint src --ext .ts --ext .cjs --fix", + "check": "run-s check:*", + "check:lint": "eslint src --ext .ts", + "check:prettier": "prettier . --list-different", + "check:spelling": "cspell \"{README.md,src/**/*.ts}\"", + "check:tsc": "tsc -p tsconfig.dev.json", + "test": "run-s test:*", + "test:node": "TS_NODE_PROJECT=./tsconfig.dev.json mocha", + "test:browser": "karma start karma.conf.cjs", + "prepublish": "npm run build", + "reset-hard": "git clean -dfx -e .idea && git reset --hard && npm i && npm run build", + "release": "semantic-release" + }, + "engines": { + "node": ">=16" + }, + "dependencies": {}, + "devDependencies": { + "@rollup/plugin-commonjs": "^22.0.0", + "@rollup/plugin-json": "^4.1.0", + "@rollup/plugin-node-resolve": "^13.3.0", + "@typescript-eslint/eslint-plugin": "^5.8.1", + "@typescript-eslint/parser": "^5.8.1", + "chai": "^4.3.6", + "cspell": "^5.14.0", + "eslint": "^8.6.0", + "eslint-config-prettier": "^8.3.0", + "eslint-plugin-eslint-comments": "^3.2.0", + "eslint-plugin-functional": "^4.0.2", + "eslint-plugin-import": "^2.25.3", + "eslint-plugin-prettier": "^4.0.0", + "npm-run-all": "^4.1.5", + "prettier": "^2.1.1", + "rollup": "^2.75.0", + "ts-loader": "^9.4.1", + "typescript": "^4.6.3" + }, + "typedoc": { + "entryPoint": "./src/index.ts" + }, + "files": [ + "dist", + "bundle", + "src/**/*.ts", + "!**/*.spec.*", + "!**/*.json", + "CHANGELOG.md", + "LICENSE", + "README.md" + ] +} diff --git a/packages/message-encryption/rollup.config.js b/packages/message-encryption/rollup.config.js new file mode 100644 index 0000000000..d22d3d231e --- /dev/null +++ b/packages/message-encryption/rollup.config.js @@ -0,0 +1,21 @@ +import commonjs from "@rollup/plugin-commonjs"; +import json from "@rollup/plugin-json"; +import { nodeResolve } from "@rollup/plugin-node-resolve"; + +export default { + input: { + index: "dist/index.js", + }, + output: { + dir: "bundle", + format: "esm", + }, + plugins: [ + commonjs(), + json(), + nodeResolve({ + browser: true, + preferBuiltins: false, + }), + ], +}; diff --git a/packages/message-encryption/tsconfig.dev.json b/packages/message-encryption/tsconfig.dev.json new file mode 100644 index 0000000000..ffc27ef6ba --- /dev/null +++ b/packages/message-encryption/tsconfig.dev.json @@ -0,0 +1,8 @@ +{ + "extends": "./tsconfig", + "compilerOptions": { + "module": "esnext", + "noEmit": true + }, + "exclude": [] +} diff --git a/packages/message-encryption/tsconfig.json b/packages/message-encryption/tsconfig.json new file mode 100644 index 0000000000..7b01b30897 --- /dev/null +++ b/packages/message-encryption/tsconfig.json @@ -0,0 +1,54 @@ +{ + "compilerOptions": { + "incremental": true, + "target": "es2020", + "outDir": "dist/", + "rootDir": "src", + "moduleResolution": "node", + "module": "es2020", + "declaration": true, + "sourceMap": true, + "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */, + "resolveJsonModule": true /* Include modules imported with .json extension. */, + "tsBuildInfoFile": "dist/.tsbuildinfo", + "strict": true /* Enable all strict type-checking options. */, + + /* Strict Type-Checking Options */ + "noImplicitAny": true /* Raise error on expressions and declarations with an implied 'any' type. */, + "strictNullChecks": true /* Enable strict null checks. */, + "strictFunctionTypes": true /* Enable strict checking of function types. */, + "strictPropertyInitialization": true /* Enable strict checking of property initialization in classes. */, + "noImplicitThis": true /* Raise error on 'this' expressions with an implied 'any' type. */, + "alwaysStrict": true /* Parse in strict mode and emit "use strict" for each source file. */, + + /* Additional Checks */ + "noUnusedLocals": true /* Report errors on unused locals. */, + "noUnusedParameters": true /* Report errors on unused parameters. */, + "noImplicitReturns": true /* Report error when not all code paths in function return a value. */, + "noFallthroughCasesInSwitch": true /* Report errors for fallthrough cases in switch statement. */, + "forceConsistentCasingInFileNames": true, + + /* Debugging Options */ + "traceResolution": false /* Report module resolution log messages. */, + "listEmittedFiles": false /* Print names of generated files part of the compilation. */, + "listFiles": false /* Print names of files part of the compilation. */, + "pretty": true /* Stylize errors and messages using color and context. */, + + // Due to broken types in indirect dependencies + "skipLibCheck": true, + + /* Experimental Options */ + // "experimentalDecorators": true /* Enables experimental support for ES7 decorators. */, + // "emitDecoratorMetadata": true /* Enables experimental support for emitting type metadata for decorators. */, + + "lib": ["es2020", "dom"], + "types": ["node", "mocha"], + "typeRoots": ["node_modules/@types", "src/types"] + }, + "include": ["src"], + "exclude": ["src/**/*.spec.ts", "src/test_utils"], + "compileOnSave": false, + "ts-node": { + "files": true + } +} diff --git a/typedoc.json b/typedoc.json index 55192a4c00..4c614c573f 100644 --- a/typedoc.json +++ b/typedoc.json @@ -6,7 +6,8 @@ "packages/create", "packages/dns-discovery", "packages/enr", - "packages/interfaces" + "packages/interfaces", + "packages/message-encryption" ], "out": "docs", "exclude": ["**/*.spec.ts"],