mirror of
https://github.com/waku-org/js-waku.git
synced 2025-02-21 08:38:17 +00:00
Merge branch 'master' of github.com:waku-org/js-waku into feat/nwaku-docker
This commit is contained in:
commit
1575d5a87e
9
.prettierignore
Normal file
9
.prettierignore
Normal file
@ -0,0 +1,9 @@
|
||||
.github
|
||||
.husky
|
||||
.vscode
|
||||
nwaku
|
||||
*/**/build
|
||||
*/**/bundle
|
||||
*/**/dist
|
||||
*/**/node_modules
|
||||
*/**/CHANGELOG.md
|
56
package-lock.json
generated
56
package-lock.json
generated
@ -23273,9 +23273,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/prettier": {
|
||||
"version": "2.8.4",
|
||||
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.4.tgz",
|
||||
"integrity": "sha512-vIS4Rlc2FNh0BySk3Wkd6xmwxB0FpOndW5fisM5H8hsZSxU2VWVB5CWIkIjWvrHjIhxk2g3bfMKM87zNTrZddw==",
|
||||
"version": "2.8.7",
|
||||
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.7.tgz",
|
||||
"integrity": "sha512-yPngTo3aXUUmyuTjeTUT75txrf+aMh9FiD7q9ZE/i6r0bPb22g4FsE6Y338PQX1bmfy08i9QQCB7/rcUAVntfw==",
|
||||
"dev": true,
|
||||
"bin": {
|
||||
"prettier": "bin-prettier.js"
|
||||
@ -29030,7 +29030,7 @@
|
||||
"version": "1.0.0",
|
||||
"license": "MIT OR Apache-2.0",
|
||||
"devDependencies": {
|
||||
"prettier": "^2.8.4"
|
||||
"prettier": "^2.8.7"
|
||||
}
|
||||
},
|
||||
"packages/core": {
|
||||
@ -29086,7 +29086,7 @@
|
||||
"karma-webpack": "^5.0.0",
|
||||
"mocha": "^10.2.0",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"prettier": "^2.8.4",
|
||||
"prettier": "^2.8.7",
|
||||
"process": "^0.11.10",
|
||||
"puppeteer": "^19.8.2",
|
||||
"rollup": "^3.15.0",
|
||||
@ -29175,7 +29175,7 @@
|
||||
"eslint-plugin-prettier": "^4.2.1",
|
||||
"interface-datastore": "^7.0.4",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"prettier": "^2.8.4",
|
||||
"prettier": "^2.8.7",
|
||||
"rollup": "^3.15.0",
|
||||
"typescript": "^4.9.5"
|
||||
},
|
||||
@ -29256,7 +29256,7 @@
|
||||
"karma-webpack": "^5.0.0",
|
||||
"mocha": "^10.2.0",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"prettier": "^2.8.4",
|
||||
"prettier": "^2.8.7",
|
||||
"rollup": "^3.15.0",
|
||||
"ts-loader": "^9.4.2",
|
||||
"typescript": "^4.9.5"
|
||||
@ -29324,7 +29324,7 @@
|
||||
"karma-webpack": "^5.0.0",
|
||||
"mocha": "^10.2.0",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"prettier": "^2.8.4",
|
||||
"prettier": "^2.8.7",
|
||||
"process": "^0.11.10",
|
||||
"puppeteer": "^19.8.2",
|
||||
"rollup": "^3.15.0",
|
||||
@ -29377,7 +29377,7 @@
|
||||
"eslint-plugin-import": "^2.27.5",
|
||||
"eslint-plugin-prettier": "^4.2.1",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"prettier": "^2.8.4",
|
||||
"prettier": "^2.8.7",
|
||||
"typescript": "^4.9.5"
|
||||
},
|
||||
"engines": {
|
||||
@ -29445,7 +29445,7 @@
|
||||
"karma-webpack": "^5.0.0",
|
||||
"mocha": "^10.2.0",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"prettier": "^2.8.4",
|
||||
"prettier": "^2.8.7",
|
||||
"process": "^0.11.10",
|
||||
"puppeteer": "^19.8.2",
|
||||
"rollup": "^3.15.0",
|
||||
@ -29494,7 +29494,7 @@
|
||||
"eslint-plugin-import": "^2.27.5",
|
||||
"eslint-plugin-prettier": "^4.2.1",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"prettier": "^2.8.4",
|
||||
"prettier": "^2.8.7",
|
||||
"rollup": "^3.15.0",
|
||||
"ts-loader": "^9.4.2",
|
||||
"typescript": "^4.9.5",
|
||||
@ -29526,7 +29526,7 @@
|
||||
"eslint-plugin-import": "^2.27.5",
|
||||
"eslint-plugin-prettier": "^4.2.1",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"prettier": "^2.8.4",
|
||||
"prettier": "^2.8.7",
|
||||
"protons": "^7.0.2",
|
||||
"rollup": "^3.15.0",
|
||||
"typescript": "^4.9.5",
|
||||
@ -29620,7 +29620,7 @@
|
||||
"eslint-plugin-prettier": "^4.2.1",
|
||||
"mocha": "^10.2.0",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"prettier": "^2.8.4",
|
||||
"prettier": "^2.8.7",
|
||||
"typescript": "^4.9.5"
|
||||
},
|
||||
"engines": {
|
||||
@ -29653,7 +29653,7 @@
|
||||
"eslint-plugin-import": "^2.27.5",
|
||||
"eslint-plugin-prettier": "^4.2.1",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"prettier": "^2.8.4",
|
||||
"prettier": "^2.8.7",
|
||||
"rollup": "^3.15.0",
|
||||
"typescript": "^4.9.5"
|
||||
},
|
||||
@ -34106,7 +34106,7 @@
|
||||
"@waku/build-utils": {
|
||||
"version": "file:packages/build-utils",
|
||||
"requires": {
|
||||
"prettier": "^2.8.4"
|
||||
"prettier": "^2.8.7"
|
||||
}
|
||||
},
|
||||
"@waku/core": {
|
||||
@ -34156,7 +34156,7 @@
|
||||
"mocha": "^10.2.0",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"p-event": "^5.0.1",
|
||||
"prettier": "^2.8.4",
|
||||
"prettier": "^2.8.7",
|
||||
"process": "^0.11.10",
|
||||
"puppeteer": "^19.8.2",
|
||||
"rollup": "^3.15.0",
|
||||
@ -34225,7 +34225,7 @@
|
||||
"interface-datastore": "^7.0.4",
|
||||
"libp2p": "^0.42.2",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"prettier": "^2.8.4",
|
||||
"prettier": "^2.8.7",
|
||||
"rollup": "^3.15.0",
|
||||
"typescript": "^4.9.5"
|
||||
},
|
||||
@ -34291,7 +34291,7 @@
|
||||
"karma-webpack": "^5.0.0",
|
||||
"mocha": "^10.2.0",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"prettier": "^2.8.4",
|
||||
"prettier": "^2.8.7",
|
||||
"rollup": "^3.15.0",
|
||||
"ts-loader": "^9.4.2",
|
||||
"typescript": "^4.9.5",
|
||||
@ -34351,7 +34351,7 @@
|
||||
"karma-webpack": "^5.0.0",
|
||||
"mocha": "^10.2.0",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"prettier": "^2.8.4",
|
||||
"prettier": "^2.8.7",
|
||||
"process": "^0.11.10",
|
||||
"puppeteer": "^19.8.2",
|
||||
"rollup": "^3.15.0",
|
||||
@ -34397,7 +34397,7 @@
|
||||
"eslint-plugin-import": "^2.27.5",
|
||||
"eslint-plugin-prettier": "^4.2.1",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"prettier": "^2.8.4",
|
||||
"prettier": "^2.8.7",
|
||||
"typescript": "^4.9.5"
|
||||
},
|
||||
"dependencies": {
|
||||
@ -34456,7 +34456,7 @@
|
||||
"karma-webpack": "^5.0.0",
|
||||
"mocha": "^10.2.0",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"prettier": "^2.8.4",
|
||||
"prettier": "^2.8.7",
|
||||
"process": "^0.11.10",
|
||||
"puppeteer": "^19.8.2",
|
||||
"rollup": "^3.15.0",
|
||||
@ -34498,7 +34498,7 @@
|
||||
"it-length-prefixed": "^8.0.4",
|
||||
"it-pipe": "^2.0.5",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"prettier": "^2.8.4",
|
||||
"prettier": "^2.8.7",
|
||||
"rollup": "^3.15.0",
|
||||
"ts-loader": "^9.4.2",
|
||||
"typescript": "^4.9.5",
|
||||
@ -34522,7 +34522,7 @@
|
||||
"eslint-plugin-import": "^2.27.5",
|
||||
"eslint-plugin-prettier": "^4.2.1",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"prettier": "^2.8.4",
|
||||
"prettier": "^2.8.7",
|
||||
"protons": "^7.0.2",
|
||||
"protons-runtime": "^5.0.0",
|
||||
"rollup": "^3.15.0",
|
||||
@ -34596,7 +34596,7 @@
|
||||
"npm-run-all": "^4.1.5",
|
||||
"p-timeout": "^6.1.0",
|
||||
"portfinder": "^1.0.32",
|
||||
"prettier": "^2.8.4",
|
||||
"prettier": "^2.8.7",
|
||||
"tail": "^2.2.6",
|
||||
"typescript": "^4.9.5"
|
||||
}
|
||||
@ -34622,7 +34622,7 @@
|
||||
"eslint-plugin-import": "^2.27.5",
|
||||
"eslint-plugin-prettier": "^4.2.1",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"prettier": "^2.8.4",
|
||||
"prettier": "^2.8.7",
|
||||
"rollup": "^3.15.0",
|
||||
"typescript": "^4.9.5",
|
||||
"uint8arrays": "^4.0.3"
|
||||
@ -47022,9 +47022,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"prettier": {
|
||||
"version": "2.8.4",
|
||||
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.4.tgz",
|
||||
"integrity": "sha512-vIS4Rlc2FNh0BySk3Wkd6xmwxB0FpOndW5fisM5H8hsZSxU2VWVB5CWIkIjWvrHjIhxk2g3bfMKM87zNTrZddw==",
|
||||
"version": "2.8.7",
|
||||
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.7.tgz",
|
||||
"integrity": "sha512-yPngTo3aXUUmyuTjeTUT75txrf+aMh9FiD7q9ZE/i6r0bPb22g4FsE6Y338PQX1bmfy08i9QQCB7/rcUAVntfw==",
|
||||
"dev": true
|
||||
},
|
||||
"prettier-linter-helpers": {
|
||||
|
@ -20,9 +20,12 @@
|
||||
"build": "npm run build --workspaces --if-present",
|
||||
"build:esm": "npm run build:esm --workspaces --if-present",
|
||||
"size": "npm run build && size-limit",
|
||||
"fix": "npm run fix --workspaces --if-present",
|
||||
"fix:lint": "npm run fix:lint --workspaces --if-present",
|
||||
"check": "npm run check --workspaces --if-present",
|
||||
"fix": "run-s fix:*",
|
||||
"fix:workspaces": "npm run fix --workspaces --if-present",
|
||||
"fix:prettier": "prettier ./packages --write",
|
||||
"check": "run-s check:*",
|
||||
"check:workspaces": "npm run check --workspaces --if-present",
|
||||
"check:prettier": "prettier ./packages --list-different",
|
||||
"check:ws": "[ $(ls -1 ./packages|wc -l) -eq $(cat package.json | jq '.workspaces | length') ] || exit 1 # check no packages left behind",
|
||||
"test": "npm run test --workspaces --if-present",
|
||||
"test:browser": "npm run test:browser --workspaces --if-present",
|
||||
|
@ -9,10 +9,8 @@
|
||||
"scripts": {
|
||||
"fix": "run-s fix:*",
|
||||
"fix:lint": "eslint . --fix",
|
||||
"fix:prettier": "prettier . --write",
|
||||
"check": "run-s check:*",
|
||||
"check:lint": "eslint .",
|
||||
"check:prettier": "prettier . --list-different"
|
||||
"check:lint": "eslint ."
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@ -25,6 +23,6 @@
|
||||
},
|
||||
"homepage": "https://github.com/waku-org/js-waku#readme",
|
||||
"devDependencies": {
|
||||
"prettier": "^2.8.4"
|
||||
"prettier": "^2.8.7"
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +0,0 @@
|
||||
build
|
||||
bundle
|
||||
dist
|
||||
node_modules
|
||||
CHANGELOG.md
|
@ -56,13 +56,11 @@
|
||||
"build:esm": "tsc",
|
||||
"build:bundle": "rollup --config rollup.config.js",
|
||||
"fix": "run-s fix:*",
|
||||
"fix:prettier": "prettier . --write",
|
||||
"fix:lint": "eslint src *.js --fix",
|
||||
"pretest": "run-s pretest:*",
|
||||
"check": "run-s check:*",
|
||||
"check:tsc": "tsc -p tsconfig.dev.json",
|
||||
"check:lint": "eslint src *.js",
|
||||
"check:prettier": "prettier . --list-different",
|
||||
"check:spelling": "cspell \"{README.md,src/**/*.ts}\"",
|
||||
"test": "run-s test:*",
|
||||
"test:node": "TS_NODE_PROJECT=./tsconfig.dev.json mocha",
|
||||
@ -124,7 +122,7 @@
|
||||
"karma-webpack": "^5.0.0",
|
||||
"mocha": "^10.2.0",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"prettier": "^2.8.4",
|
||||
"prettier": "^2.8.7",
|
||||
"process": "^0.11.10",
|
||||
"puppeteer": "^19.8.2",
|
||||
"rollup": "^3.15.0",
|
||||
|
@ -8,8 +8,8 @@ describe("Waku Message version 0", function () {
|
||||
it("Round trip binary serialization", async function () {
|
||||
await fc.assert(
|
||||
fc.asyncProperty(
|
||||
fc.string(),
|
||||
fc.string(),
|
||||
fc.string({ minLength: 1 }),
|
||||
fc.string({ minLength: 1 }),
|
||||
fc.uint8Array({ minLength: 1 }),
|
||||
async (contentTopic, pubSubTopic, payload) => {
|
||||
const encoder = createEncoder({
|
||||
@ -37,8 +37,8 @@ describe("Waku Message version 0", function () {
|
||||
it("Ephemeral field set to true", async function () {
|
||||
await fc.assert(
|
||||
fc.asyncProperty(
|
||||
fc.string(),
|
||||
fc.string(),
|
||||
fc.string({ minLength: 1 }),
|
||||
fc.string({ minLength: 1 }),
|
||||
fc.uint8Array({ minLength: 1 }),
|
||||
async (contentTopic, pubSubTopic, payload) => {
|
||||
const encoder = createEncoder({
|
||||
@ -62,8 +62,8 @@ describe("Waku Message version 0", function () {
|
||||
it("Meta field set when metaSetter is specified", async function () {
|
||||
await fc.assert(
|
||||
fc.asyncProperty(
|
||||
fc.string(),
|
||||
fc.string(),
|
||||
fc.string({ minLength: 1 }),
|
||||
fc.string({ minLength: 1 }),
|
||||
fc.uint8Array({ minLength: 1 }),
|
||||
async (contentTopic, pubSubTopic, payload) => {
|
||||
// Encode the length of the payload
|
||||
@ -106,3 +106,34 @@ describe("Waku Message version 0", function () {
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Ensures content topic is defined", () => {
|
||||
it("Encoder throws on undefined content topic", () => {
|
||||
const wrapper = function (): void {
|
||||
createEncoder({ contentTopic: undefined as unknown as string });
|
||||
};
|
||||
|
||||
expect(wrapper).to.throw("Content topic must be specified");
|
||||
});
|
||||
it("Encoder throws on empty string content topic", () => {
|
||||
const wrapper = function (): void {
|
||||
createEncoder({ contentTopic: "" });
|
||||
};
|
||||
|
||||
expect(wrapper).to.throw("Content topic must be specified");
|
||||
});
|
||||
it("Decoder throws on undefined content topic", () => {
|
||||
const wrapper = function (): void {
|
||||
createDecoder(undefined as unknown as string);
|
||||
};
|
||||
|
||||
expect(wrapper).to.throw("Content topic must be specified");
|
||||
});
|
||||
it("Decoder throws on empty string content topic", () => {
|
||||
const wrapper = function (): void {
|
||||
createDecoder("");
|
||||
};
|
||||
|
||||
expect(wrapper).to.throw("Content topic must be specified");
|
||||
});
|
||||
});
|
||||
|
@ -71,7 +71,11 @@ export class Encoder implements IEncoder {
|
||||
public contentTopic: string,
|
||||
public ephemeral: boolean = false,
|
||||
public metaSetter?: IMetaSetter
|
||||
) {}
|
||||
) {
|
||||
if (!contentTopic || contentTopic === "") {
|
||||
throw new Error("Content topic must be specified");
|
||||
}
|
||||
}
|
||||
|
||||
async toWire(message: IMessage): Promise<Uint8Array> {
|
||||
return proto.WakuMessage.encode(await this.toProtoObj(message));
|
||||
@ -117,7 +121,11 @@ export function createEncoder({
|
||||
}
|
||||
|
||||
export class Decoder implements IDecoder<DecodedMessage> {
|
||||
constructor(public contentTopic: string) {}
|
||||
constructor(public contentTopic: string) {
|
||||
if (!contentTopic || contentTopic === "") {
|
||||
throw new Error("Content topic must be specified");
|
||||
}
|
||||
}
|
||||
|
||||
fromWireToProtoObj(bytes: Uint8Array): Promise<IProtoMessage | undefined> {
|
||||
const protoMessage = proto.WakuMessage.decode(bytes);
|
||||
|
@ -1,5 +0,0 @@
|
||||
build
|
||||
bundle
|
||||
dist
|
||||
node_modules
|
||||
CHANGELOG.md
|
@ -36,11 +36,9 @@
|
||||
"build:esm": "tsc",
|
||||
"build:bundle": "rollup --config rollup.config.js",
|
||||
"fix": "run-s fix:*",
|
||||
"fix:prettier": "prettier . --write",
|
||||
"fix:lint": "eslint src *.js --fix",
|
||||
"check": "run-s check:*",
|
||||
"check:lint": "eslint src *.js",
|
||||
"check:prettier": "prettier . --list-different",
|
||||
"check:spelling": "cspell \"{README.md,src/**/*.ts}\"",
|
||||
"check:tsc": "tsc -p tsconfig.dev.json",
|
||||
"prepublish": "npm run build",
|
||||
@ -88,7 +86,7 @@
|
||||
"eslint-plugin-prettier": "^4.2.1",
|
||||
"interface-datastore": "^7.0.4",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"prettier": "^2.8.4",
|
||||
"prettier": "^2.8.7",
|
||||
"rollup": "^3.15.0",
|
||||
"typescript": "^4.9.5"
|
||||
},
|
||||
|
@ -1,5 +0,0 @@
|
||||
build
|
||||
bundle
|
||||
dist
|
||||
node_modules
|
||||
CHANGELOG.md
|
@ -43,11 +43,9 @@
|
||||
"build:esm": "tsc",
|
||||
"build:bundle": "rollup --config rollup.config.js",
|
||||
"fix": "run-s fix:*",
|
||||
"fix:prettier": "prettier . --write",
|
||||
"fix:lint": "eslint src *.js --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",
|
||||
"prepublish": "npm run build",
|
||||
@ -97,7 +95,7 @@
|
||||
"karma-webpack": "^5.0.0",
|
||||
"mocha": "^10.2.0",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"prettier": "^2.8.4",
|
||||
"prettier": "^2.8.7",
|
||||
"rollup": "^3.15.0",
|
||||
"ts-loader": "^9.4.2",
|
||||
"typescript": "^4.9.5"
|
||||
|
@ -1,5 +0,0 @@
|
||||
build
|
||||
bundle
|
||||
dist
|
||||
node_modules
|
||||
CHANGELOG.md
|
@ -36,11 +36,9 @@
|
||||
"build:esm": "tsc",
|
||||
"build:bundle": "rollup --config rollup.config.js",
|
||||
"fix": "run-s fix:*",
|
||||
"fix:prettier": "prettier . --write",
|
||||
"fix:lint": "eslint src *.js --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:*",
|
||||
@ -89,7 +87,7 @@
|
||||
"karma-webpack": "^5.0.0",
|
||||
"mocha": "^10.2.0",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"prettier": "^2.8.4",
|
||||
"prettier": "^2.8.7",
|
||||
"process": "^0.11.10",
|
||||
"puppeteer": "^19.8.2",
|
||||
"rollup": "^3.15.0",
|
||||
|
@ -1,5 +0,0 @@
|
||||
build
|
||||
bundle
|
||||
dist
|
||||
node_modules
|
||||
CHANGELOG.md
|
@ -35,11 +35,9 @@
|
||||
"build": "run-s build:**",
|
||||
"build:esm": "tsc",
|
||||
"fix": "run-s fix:*",
|
||||
"fix:prettier": "prettier . --write",
|
||||
"fix:lint": "eslint src --fix",
|
||||
"check": "run-s check:*",
|
||||
"check:lint": "eslint src",
|
||||
"check:prettier": "prettier . --list-different",
|
||||
"check:spelling": "cspell \"{README.md,src/**/*.ts}\"",
|
||||
"check:tsc": "tsc -p tsconfig.dev.json",
|
||||
"prepublish": "npm run build",
|
||||
@ -68,7 +66,7 @@
|
||||
"eslint-plugin-import": "^2.27.5",
|
||||
"eslint-plugin-prettier": "^4.2.1",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"prettier": "^2.8.4",
|
||||
"prettier": "^2.8.7",
|
||||
"typescript": "^4.9.5"
|
||||
},
|
||||
"typedoc": {
|
||||
|
@ -1,5 +0,0 @@
|
||||
build
|
||||
bundle
|
||||
dist
|
||||
node_modules
|
||||
CHANGELOG.md
|
@ -53,11 +53,9 @@
|
||||
"build:esm": "tsc",
|
||||
"build:bundle": "rollup --config rollup.config.js",
|
||||
"fix": "run-s fix:*",
|
||||
"fix:prettier": "prettier . --write",
|
||||
"fix:lint": "eslint src *.js --fix",
|
||||
"check": "run-s check:*",
|
||||
"check:lint": "eslint src *.js",
|
||||
"check:prettier": "prettier . --list-different",
|
||||
"check:spelling": "cspell \"{README.md,src/**/*.ts}\"",
|
||||
"check:tsc": "tsc -p tsconfig.dev.json",
|
||||
"test": "run-s test:*",
|
||||
@ -111,7 +109,7 @@
|
||||
"karma-webpack": "^5.0.0",
|
||||
"mocha": "^10.2.0",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"prettier": "^2.8.4",
|
||||
"prettier": "^2.8.7",
|
||||
"process": "^0.11.10",
|
||||
"puppeteer": "^19.8.2",
|
||||
"rollup": "^3.15.0",
|
||||
|
@ -9,8 +9,8 @@ describe("Ecies Encryption", function () {
|
||||
it("Round trip binary encryption [ecies, no signature]", async function () {
|
||||
await fc.assert(
|
||||
fc.asyncProperty(
|
||||
fc.string(),
|
||||
fc.string(),
|
||||
fc.string({ minLength: 1 }),
|
||||
fc.string({ minLength: 1 }),
|
||||
fc.uint8Array({ minLength: 1 }),
|
||||
fc.uint8Array({ min: 1, minLength: 32, maxLength: 32 }),
|
||||
async (pubSubTopic, contentTopic, payload, privateKey) => {
|
||||
@ -44,8 +44,8 @@ describe("Ecies Encryption", function () {
|
||||
|
||||
await fc.assert(
|
||||
fc.asyncProperty(
|
||||
fc.string(),
|
||||
fc.string(),
|
||||
fc.string({ minLength: 1 }),
|
||||
fc.string({ minLength: 1 }),
|
||||
fc.uint8Array({ minLength: 1 }),
|
||||
fc.uint8Array({ min: 1, minLength: 32, maxLength: 32 }),
|
||||
fc.uint8Array({ min: 1, minLength: 32, maxLength: 32 }),
|
||||
@ -86,8 +86,8 @@ describe("Ecies Encryption", function () {
|
||||
it("Check meta is set [ecies]", async function () {
|
||||
await fc.assert(
|
||||
fc.asyncProperty(
|
||||
fc.string(),
|
||||
fc.string(),
|
||||
fc.string({ minLength: 1 }),
|
||||
fc.string({ minLength: 1 }),
|
||||
fc.uint8Array({ minLength: 1 }),
|
||||
fc.uint8Array({ min: 1, minLength: 32, maxLength: 32 }),
|
||||
async (pubSubTopic, contentTopic, payload, privateKey) => {
|
||||
@ -130,3 +130,37 @@ describe("Ecies Encryption", function () {
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Ensures content topic is defined", () => {
|
||||
it("Encoder throws on undefined content topic", () => {
|
||||
const wrapper = function (): void {
|
||||
createEncoder({
|
||||
contentTopic: undefined as unknown as string,
|
||||
publicKey: new Uint8Array(),
|
||||
});
|
||||
};
|
||||
|
||||
expect(wrapper).to.throw("Content topic must be specified");
|
||||
});
|
||||
it("Encoder throws on empty string content topic", () => {
|
||||
const wrapper = function (): void {
|
||||
createEncoder({ contentTopic: "", publicKey: new Uint8Array() });
|
||||
};
|
||||
|
||||
expect(wrapper).to.throw("Content topic must be specified");
|
||||
});
|
||||
it("Decoder throws on undefined content topic", () => {
|
||||
const wrapper = function (): void {
|
||||
createDecoder(undefined as unknown as string, new Uint8Array());
|
||||
};
|
||||
|
||||
expect(wrapper).to.throw("Content topic must be specified");
|
||||
});
|
||||
it("Decoder throws on empty string content topic", () => {
|
||||
const wrapper = function (): void {
|
||||
createDecoder("", new Uint8Array());
|
||||
};
|
||||
|
||||
expect(wrapper).to.throw("Content topic must be specified");
|
||||
});
|
||||
});
|
||||
|
@ -37,7 +37,11 @@ class Encoder implements IEncoder {
|
||||
private sigPrivKey?: Uint8Array,
|
||||
public ephemeral: boolean = false,
|
||||
public metaSetter?: IMetaSetter
|
||||
) {}
|
||||
) {
|
||||
if (!contentTopic || contentTopic === "") {
|
||||
throw new Error("Content topic must be specified");
|
||||
}
|
||||
}
|
||||
|
||||
async toWire(message: IMessage): Promise<Uint8Array | undefined> {
|
||||
const protoMessage = await this.toProtoObj(message);
|
||||
|
@ -9,8 +9,8 @@ describe("Symmetric Encryption", function () {
|
||||
it("Round trip binary encryption [symmetric, no signature]", async function () {
|
||||
await fc.assert(
|
||||
fc.asyncProperty(
|
||||
fc.string(),
|
||||
fc.string(),
|
||||
fc.string({ minLength: 1 }),
|
||||
fc.string({ minLength: 1 }),
|
||||
fc.uint8Array({ minLength: 1 }),
|
||||
fc.uint8Array({ min: 1, minLength: 32, maxLength: 32 }),
|
||||
async (pubSubTopic, contentTopic, payload, symKey) => {
|
||||
@ -40,8 +40,8 @@ describe("Symmetric Encryption", function () {
|
||||
it("Round trip binary encryption [symmetric, signature]", async function () {
|
||||
await fc.assert(
|
||||
fc.asyncProperty(
|
||||
fc.string(),
|
||||
fc.string(),
|
||||
fc.string({ minLength: 1 }),
|
||||
fc.string({ minLength: 1 }),
|
||||
fc.uint8Array({ minLength: 1 }),
|
||||
fc.uint8Array({ min: 1, minLength: 32, maxLength: 32 }),
|
||||
fc.uint8Array({ min: 1, minLength: 32, maxLength: 32 }),
|
||||
@ -75,8 +75,8 @@ describe("Symmetric Encryption", function () {
|
||||
it("Check meta is set [symmetric]", async function () {
|
||||
await fc.assert(
|
||||
fc.asyncProperty(
|
||||
fc.string(),
|
||||
fc.string(),
|
||||
fc.string({ minLength: 1 }),
|
||||
fc.string({ minLength: 1 }),
|
||||
fc.uint8Array({ minLength: 1 }),
|
||||
fc.uint8Array({ min: 1, minLength: 32, maxLength: 32 }),
|
||||
async (pubSubTopic, contentTopic, payload, symKey) => {
|
||||
@ -118,3 +118,37 @@ describe("Symmetric Encryption", function () {
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Ensures content topic is defined", () => {
|
||||
it("Encoder throws on undefined content topic", () => {
|
||||
const wrapper = function (): void {
|
||||
createEncoder({
|
||||
contentTopic: undefined as unknown as string,
|
||||
symKey: new Uint8Array(),
|
||||
});
|
||||
};
|
||||
|
||||
expect(wrapper).to.throw("Content topic must be specified");
|
||||
});
|
||||
it("Encoder throws on empty string content topic", () => {
|
||||
const wrapper = function (): void {
|
||||
createEncoder({ contentTopic: "", symKey: new Uint8Array() });
|
||||
};
|
||||
|
||||
expect(wrapper).to.throw("Content topic must be specified");
|
||||
});
|
||||
it("Decoder throws on undefined content topic", () => {
|
||||
const wrapper = function (): void {
|
||||
createDecoder(undefined as unknown as string, new Uint8Array());
|
||||
};
|
||||
|
||||
expect(wrapper).to.throw("Content topic must be specified");
|
||||
});
|
||||
it("Decoder throws on empty string content topic", () => {
|
||||
const wrapper = function (): void {
|
||||
createDecoder("", new Uint8Array());
|
||||
};
|
||||
|
||||
expect(wrapper).to.throw("Content topic must be specified");
|
||||
});
|
||||
});
|
||||
|
@ -32,7 +32,11 @@ class Encoder implements IEncoder {
|
||||
private sigPrivKey?: Uint8Array,
|
||||
public ephemeral: boolean = false,
|
||||
public metaSetter?: IMetaSetter
|
||||
) {}
|
||||
) {
|
||||
if (!contentTopic || contentTopic === "") {
|
||||
throw new Error("Content topic must be specified");
|
||||
}
|
||||
}
|
||||
|
||||
async toWire(message: IMessage): Promise<Uint8Array | undefined> {
|
||||
const protoMessage = await this.toProtoObj(message);
|
||||
|
@ -1,5 +0,0 @@
|
||||
build
|
||||
bundle
|
||||
dist
|
||||
node_modules
|
||||
CHANGELOG.md
|
@ -36,11 +36,9 @@
|
||||
"build:esm": "tsc",
|
||||
"build:bundle": "rollup --config rollup.config.js",
|
||||
"fix": "run-s fix:*",
|
||||
"fix:prettier": "prettier . --write",
|
||||
"fix:lint": "eslint src *.js --fix",
|
||||
"check": "run-s check:*",
|
||||
"check:lint": "eslint src *.js",
|
||||
"check:prettier": "prettier . --list-different",
|
||||
"check:spelling": "cspell \"{README.md,src/**/*.ts}\"",
|
||||
"check:tsc": "tsc -p tsconfig.dev.json",
|
||||
"prepublish": "npm run build",
|
||||
@ -83,7 +81,7 @@
|
||||
"eslint-plugin-import": "^2.27.5",
|
||||
"eslint-plugin-prettier": "^4.2.1",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"prettier": "^2.8.4",
|
||||
"prettier": "^2.8.7",
|
||||
"rollup": "^3.15.0",
|
||||
"ts-loader": "^9.4.2",
|
||||
"typescript": "^4.9.5",
|
||||
|
@ -1,5 +0,0 @@
|
||||
build
|
||||
bundle
|
||||
dist
|
||||
node_modules
|
||||
CHANGELOG.md
|
@ -38,9 +38,7 @@
|
||||
"proto": "rimraf src/lib/*.ts; protons src/lib/*.proto",
|
||||
"check:tsc": "tsc -p tsconfig.dev.json",
|
||||
"prepublish": "npm run build",
|
||||
"reset-hard": "git clean -dfx -e .idea && git reset --hard && npm i && npm run build",
|
||||
"fix": "run-s fix:*",
|
||||
"fix:prettier": "prettier . --write"
|
||||
"reset-hard": "git clean -dfx -e .idea && git reset --hard && npm i && npm run build"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=16"
|
||||
@ -63,7 +61,7 @@
|
||||
"eslint-plugin-import": "^2.27.5",
|
||||
"eslint-plugin-prettier": "^4.2.1",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"prettier": "^2.8.4",
|
||||
"prettier": "^2.8.7",
|
||||
"protons": "^7.0.2",
|
||||
"rollup": "^3.15.0",
|
||||
"typescript": "^4.9.5",
|
||||
|
@ -1,4 +0,0 @@
|
||||
build
|
||||
bundle
|
||||
dist
|
||||
node_modules
|
@ -36,10 +36,8 @@
|
||||
"build": "run-s build:**",
|
||||
"build:esm": "tsc",
|
||||
"fix": "run-s fix:*",
|
||||
"fix:prettier": "prettier . --write",
|
||||
"fix:lint": "eslint src tests --fix",
|
||||
"check": "run-s check:*",
|
||||
"check:prettier": "prettier . --list-different",
|
||||
"check:lint": "eslint src tests",
|
||||
"check:spelling": "cspell \"{README.md,{tests,src}/**/*.ts}\"",
|
||||
"check:tsc": "tsc -p tsconfig.dev.json",
|
||||
@ -89,7 +87,7 @@
|
||||
"eslint-plugin-prettier": "^4.2.1",
|
||||
"mocha": "^10.2.0",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"prettier": "^2.8.4",
|
||||
"prettier": "^2.8.7",
|
||||
"typescript": "^4.9.5"
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +0,0 @@
|
||||
build
|
||||
bundle
|
||||
dist
|
||||
node_modules
|
||||
CHANGELOG.md
|
@ -53,11 +53,9 @@
|
||||
"build:esm": "tsc",
|
||||
"build:bundle": "rollup --config rollup.config.js",
|
||||
"fix": "run-s fix:*",
|
||||
"fix:prettier": "prettier . --write",
|
||||
"fix:lint": "eslint src *.js --fix",
|
||||
"check": "run-s check:*",
|
||||
"check:lint": "eslint src *.js",
|
||||
"check:prettier": "prettier . --list-different",
|
||||
"check:spelling": "cspell \"{README.md,src/**/*.ts}\"",
|
||||
"check:tsc": "tsc -p tsconfig.dev.json",
|
||||
"prepublish": "npm run build",
|
||||
@ -88,7 +86,7 @@
|
||||
"eslint-plugin-import": "^2.27.5",
|
||||
"eslint-plugin-prettier": "^4.2.1",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"prettier": "^2.8.4",
|
||||
"prettier": "^2.8.7",
|
||||
"rollup": "^3.15.0",
|
||||
"typescript": "^4.9.5"
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user