diff --git a/README.md b/README.md index 9df98ad..7ed3ef0 100644 --- a/README.md +++ b/README.md @@ -135,6 +135,10 @@ Run `ng build` to build the project. The build artifacts will be stored in the ` Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io). +## Security Review Status: pre-audit + +The code in this repository has not been audited. + ## License [![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fmailchain%2Fmailchain-web.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fmailchain%2Fmailchain-web?ref=badge_large) diff --git a/package-lock.json b/package-lock.json index c220414..0f3bf6c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -381,28 +381,46 @@ } }, "@angular-devkit/schematics": { - "version": "8.3.25", - "resolved": "https://registry.npmjs.org/@angular-devkit/schematics/-/schematics-8.3.25.tgz", - "integrity": "sha512-/p1MkfursfLy+JRGXlJGPEmX55lrFCsR/2khWAVXZcMaFR3QlR/b6/zvB8I2pHFfr0/XWnYTT/BsF7rJjO3RmA==", + "version": "8.3.29", + "resolved": "https://registry.npmjs.org/@angular-devkit/schematics/-/schematics-8.3.29.tgz", + "integrity": "sha512-AFJ9EK0XbcNlO5Dm9vr0OlBo1Nw6AaFXPR+DmHGBdcDDHxqEmYYLWfT+JU/8U2YFIdgrtlwvdtf6UQ3V2jdz1g==", "dev": true, "requires": { - "@angular-devkit/core": "8.3.25", + "@angular-devkit/core": "8.3.29", "rxjs": "6.4.0" }, "dependencies": { "@angular-devkit/core": { - "version": "8.3.25", - "resolved": "https://registry.npmjs.org/@angular-devkit/core/-/core-8.3.25.tgz", - "integrity": "sha512-l7Gqy1tMrTpRmPVlovcFX8UA3mtXRlgO8kcSsbJ9MKRKNTCcxlfsWEYY5igyDBUVh6ADkgSIu0nuk31ZGTe0lw==", + "version": "8.3.29", + "resolved": "https://registry.npmjs.org/@angular-devkit/core/-/core-8.3.29.tgz", + "integrity": "sha512-4jdja9QPwR6XG14ZSunyyOWT3nE2WtZC5IMDIBZADxujXvhzOU0n4oWpy6/JVHLUAxYNNgzLz+/LQORRWndcPg==", "dev": true, "requires": { - "ajv": "6.10.2", + "ajv": "6.12.3", "fast-json-stable-stringify": "2.0.0", "magic-string": "0.25.3", "rxjs": "6.4.0", "source-map": "0.7.3" } }, + "ajv": { + "version": "6.12.3", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.3.tgz", + "integrity": "sha512-4K0cK3L1hsqk9xIb2z9vs/XU+PGJZ9PNpJRDS9YLzmNdX6jmVPfamLvTJr0aDAusnHyCHO6MjzlkAsgtqp9teA==", + "dev": true, + "requires": { + "fast-deep-equal": "^3.1.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + } + }, + "fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", + "dev": true + }, "rxjs": { "version": "6.4.0", "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.4.0.tgz", @@ -429,16 +447,16 @@ } }, "@angular/cli": { - "version": "8.3.25", - "resolved": "https://registry.npmjs.org/@angular/cli/-/cli-8.3.25.tgz", - "integrity": "sha512-CPJI5nnbBvvyBUFwOHfRXy/KVwsiYlcbDAeIk1klcjQjbVFYZbnY0iAhNupy9j7rPQhb7jle5oslU3TLfbqOTQ==", + "version": "8.3.29", + "resolved": "https://registry.npmjs.org/@angular/cli/-/cli-8.3.29.tgz", + "integrity": "sha512-pW+iU0eKHIae+A1b9W5g8DKefMQcehZ+drGKs4Hryh8G+XGFS00BIWkmh6c1mydWTEhdsFlhdjD/rXCem7MAQQ==", "dev": true, "requires": { - "@angular-devkit/architect": "0.803.25", - "@angular-devkit/core": "8.3.25", - "@angular-devkit/schematics": "8.3.25", - "@schematics/angular": "8.3.25", - "@schematics/update": "0.803.25", + "@angular-devkit/architect": "0.803.29", + "@angular-devkit/core": "8.3.29", + "@angular-devkit/schematics": "8.3.29", + "@schematics/angular": "8.3.29", + "@schematics/update": "0.803.29", "@yarnpkg/lockfile": "1.1.0", "ansi-colors": "4.1.1", "debug": "^4.1.1", @@ -457,28 +475,40 @@ }, "dependencies": { "@angular-devkit/architect": { - "version": "0.803.25", - "resolved": "https://registry.npmjs.org/@angular-devkit/architect/-/architect-0.803.25.tgz", - "integrity": "sha512-usV/zEncKCKQuF6AD3pRU6N5i5fbaAux/qZb+nbOz9/2G5jrXwe5sH+y3vxbgqB83e3LqusEQCTu7/tfg6LwZg==", + "version": "0.803.29", + "resolved": "https://registry.npmjs.org/@angular-devkit/architect/-/architect-0.803.29.tgz", + "integrity": "sha512-yHBud/fZHTelX24yjQg5lefZrfIebruoFTGeOwF0JdX8+KiHcTIxS4LOnUTYriasfHarcHRFXBAV/bRm+wv5ow==", "dev": true, "requires": { - "@angular-devkit/core": "8.3.25", + "@angular-devkit/core": "8.3.29", "rxjs": "6.4.0" } }, "@angular-devkit/core": { - "version": "8.3.25", - "resolved": "https://registry.npmjs.org/@angular-devkit/core/-/core-8.3.25.tgz", - "integrity": "sha512-l7Gqy1tMrTpRmPVlovcFX8UA3mtXRlgO8kcSsbJ9MKRKNTCcxlfsWEYY5igyDBUVh6ADkgSIu0nuk31ZGTe0lw==", + "version": "8.3.29", + "resolved": "https://registry.npmjs.org/@angular-devkit/core/-/core-8.3.29.tgz", + "integrity": "sha512-4jdja9QPwR6XG14ZSunyyOWT3nE2WtZC5IMDIBZADxujXvhzOU0n4oWpy6/JVHLUAxYNNgzLz+/LQORRWndcPg==", "dev": true, "requires": { - "ajv": "6.10.2", + "ajv": "6.12.3", "fast-json-stable-stringify": "2.0.0", "magic-string": "0.25.3", "rxjs": "6.4.0", "source-map": "0.7.3" } }, + "ajv": { + "version": "6.12.3", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.3.tgz", + "integrity": "sha512-4K0cK3L1hsqk9xIb2z9vs/XU+PGJZ9PNpJRDS9YLzmNdX6jmVPfamLvTJr0aDAusnHyCHO6MjzlkAsgtqp9teA==", + "dev": true, + "requires": { + "fast-deep-equal": "^3.1.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + } + }, "ansi-colors": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz", @@ -486,14 +516,20 @@ "dev": true }, "debug": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", - "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.2.0.tgz", + "integrity": "sha512-IX2ncY78vDTjZMFUdmsvIRFY2Cf4FnD0wRs+nQwJU8Lu99/tPFdb0VybiiMTPe3I6rQmwsqQqRBvxU+bZ/I8sg==", "dev": true, "requires": { - "ms": "^2.1.1" + "ms": "2.1.2" } }, + "fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", + "dev": true + }, "ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", @@ -2884,28 +2920,46 @@ } }, "@schematics/angular": { - "version": "8.3.25", - "resolved": "https://registry.npmjs.org/@schematics/angular/-/angular-8.3.25.tgz", - "integrity": "sha512-/vEPtE+fvgsWPml/MVqzmlGPBujadPPNwaTuuj5Uz1aVcKeEYzLkbN8YQOpml4vxZHCF8RDwNdGiU4SZg63Jfg==", + "version": "8.3.29", + "resolved": "https://registry.npmjs.org/@schematics/angular/-/angular-8.3.29.tgz", + "integrity": "sha512-If+UhCsQzCgnQymiiF8dQRoic34+RgJ6rV0n4k7Tm4N2xNYJOG7ajjzKM7PIeafsF50FKnFP8dqaNGxCMyq5Ew==", "dev": true, "requires": { - "@angular-devkit/core": "8.3.25", - "@angular-devkit/schematics": "8.3.25" + "@angular-devkit/core": "8.3.29", + "@angular-devkit/schematics": "8.3.29" }, "dependencies": { "@angular-devkit/core": { - "version": "8.3.25", - "resolved": "https://registry.npmjs.org/@angular-devkit/core/-/core-8.3.25.tgz", - "integrity": "sha512-l7Gqy1tMrTpRmPVlovcFX8UA3mtXRlgO8kcSsbJ9MKRKNTCcxlfsWEYY5igyDBUVh6ADkgSIu0nuk31ZGTe0lw==", + "version": "8.3.29", + "resolved": "https://registry.npmjs.org/@angular-devkit/core/-/core-8.3.29.tgz", + "integrity": "sha512-4jdja9QPwR6XG14ZSunyyOWT3nE2WtZC5IMDIBZADxujXvhzOU0n4oWpy6/JVHLUAxYNNgzLz+/LQORRWndcPg==", "dev": true, "requires": { - "ajv": "6.10.2", + "ajv": "6.12.3", "fast-json-stable-stringify": "2.0.0", "magic-string": "0.25.3", "rxjs": "6.4.0", "source-map": "0.7.3" } }, + "ajv": { + "version": "6.12.3", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.3.tgz", + "integrity": "sha512-4K0cK3L1hsqk9xIb2z9vs/XU+PGJZ9PNpJRDS9YLzmNdX6jmVPfamLvTJr0aDAusnHyCHO6MjzlkAsgtqp9teA==", + "dev": true, + "requires": { + "fast-deep-equal": "^3.1.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + } + }, + "fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", + "dev": true + }, "rxjs": { "version": "6.4.0", "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.4.0.tgz", @@ -2924,13 +2978,13 @@ } }, "@schematics/update": { - "version": "0.803.25", - "resolved": "https://registry.npmjs.org/@schematics/update/-/update-0.803.25.tgz", - "integrity": "sha512-VIlqhJsCStA3aO4llxZ7lAOvQUqppyZdrEO7f/ApIJmuofPQTkO5Hx21tnv0dyExwoqPCSIHzEu4Tmc0/TWM1A==", + "version": "0.803.29", + "resolved": "https://registry.npmjs.org/@schematics/update/-/update-0.803.29.tgz", + "integrity": "sha512-Syf6h6DYeu1WU9aLihMwIgVASpcHCxUYqhZyHfQABiK8NkdlZ+KAp4cOxihsZyDqIJNLWON+0/FLPAQF3BXh5Q==", "dev": true, "requires": { - "@angular-devkit/core": "8.3.25", - "@angular-devkit/schematics": "8.3.25", + "@angular-devkit/core": "8.3.29", + "@angular-devkit/schematics": "8.3.29", "@yarnpkg/lockfile": "1.1.0", "ini": "1.3.5", "pacote": "9.5.5", @@ -2940,18 +2994,36 @@ }, "dependencies": { "@angular-devkit/core": { - "version": "8.3.25", - "resolved": "https://registry.npmjs.org/@angular-devkit/core/-/core-8.3.25.tgz", - "integrity": "sha512-l7Gqy1tMrTpRmPVlovcFX8UA3mtXRlgO8kcSsbJ9MKRKNTCcxlfsWEYY5igyDBUVh6ADkgSIu0nuk31ZGTe0lw==", + "version": "8.3.29", + "resolved": "https://registry.npmjs.org/@angular-devkit/core/-/core-8.3.29.tgz", + "integrity": "sha512-4jdja9QPwR6XG14ZSunyyOWT3nE2WtZC5IMDIBZADxujXvhzOU0n4oWpy6/JVHLUAxYNNgzLz+/LQORRWndcPg==", "dev": true, "requires": { - "ajv": "6.10.2", + "ajv": "6.12.3", "fast-json-stable-stringify": "2.0.0", "magic-string": "0.25.3", "rxjs": "6.4.0", "source-map": "0.7.3" } }, + "ajv": { + "version": "6.12.3", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.3.tgz", + "integrity": "sha512-4K0cK3L1hsqk9xIb2z9vs/XU+PGJZ9PNpJRDS9YLzmNdX6jmVPfamLvTJr0aDAusnHyCHO6MjzlkAsgtqp9teA==", + "dev": true, + "requires": { + "fast-deep-equal": "^3.1.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + } + }, + "fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", + "dev": true + }, "rxjs": { "version": "6.4.0", "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.4.0.tgz", @@ -3337,12 +3409,12 @@ "dev": true }, "ansi-escapes": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-4.3.0.tgz", - "integrity": "sha512-EiYhwo0v255HUL6eDyuLrXEkTi7WwVCLAw+SeOQ7M7qdun1z1pum4DEm/nuqIVbPvi9RPPc9k9LbyBv6H0DwVg==", + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-4.3.1.tgz", + "integrity": "sha512-JWF7ocqNrp8u9oqpgV+wH5ftbt+cfvv+PTjOvKLT3AdYly/LmORARfEVT1iyjwN+4MqE5UmVKoAdIBqeoCHgLA==", "dev": true, "requires": { - "type-fest": "^0.8.1" + "type-fest": "^0.11.0" } }, "ansi-html": { @@ -4317,9 +4389,9 @@ } }, "cli-width": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-2.2.0.tgz", - "integrity": "sha1-/xnt6Kml5XkyQUewwR8PvLq+1jk=", + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-2.2.1.tgz", + "integrity": "sha512-GRMWDxpOB6Dgk2E5Uo+3eEBvtOOlimMmpbFiKuLFnQzYDavtLFY3K5ona41jgN/WdRZtG7utuVSVTL4HbZHGkw==", "dev": true }, "cliui": { @@ -5235,9 +5307,9 @@ "dev": true }, "elliptic": { - "version": "6.5.2", - "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.2.tgz", - "integrity": "sha512-f4x70okzZbIQl/NSRLkI/+tteV/9WqL98zx+SQ69KbXxmVrmjwsNUPn/gYJJ0sHvEak24cZgHIPegRePAtA/xw==", + "version": "6.5.3", + "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.3.tgz", + "integrity": "sha512-IMqzv5wNQf+E6aHeIqATs0tOLeOTwj1QKbRcS3jBbYkl5oLAserA8yJTT7/VyHUYG91PRmPyeQDObKLPpeS4dw==", "requires": { "bn.js": "^4.4.0", "brorand": "^1.0.1", @@ -5266,12 +5338,23 @@ "dev": true }, "encoding": { - "version": "0.1.12", - "resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.12.tgz", - "integrity": "sha1-U4tm8+5izRq1HsMjgp0flIDHS+s=", + "version": "0.1.13", + "resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.13.tgz", + "integrity": "sha512-ETBauow1T35Y/WZMkio9jiM0Z5xjHHmJ4XmjZOq1l/dXz3lr2sRn87nJy20RupqSh1F2m3HHPSp8ShIPQJrJ3A==", "dev": true, "requires": { - "iconv-lite": "~0.4.13" + "iconv-lite": "^0.6.2" + }, + "dependencies": { + "iconv-lite": { + "version": "0.6.2", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.2.tgz", + "integrity": "sha512-2y91h5OpQlolefMPmUlivelittSWy0rP+oYVpn6A7GwVHNE8AWzoYOBNmlwks3LobaJxgHCYZAnyNo2GgpNRNQ==", + "dev": true, + "requires": { + "safer-buffer": ">= 2.1.2 < 3.0.0" + } + } } }, "end-of-stream": { @@ -5388,6 +5471,7 @@ "version": "4.1.1", "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-4.1.1.tgz", "integrity": "sha512-98p2zE+rL7/g/DzMHMTF4zZlCgeVdJ7yr6xzEpJRYwFYrGi9ANdn5DnJURg6RpBkyk60XYDnWIv51VfIhfNGuA==", + "dev": true, "requires": { "graceful-fs": "^4.1.2", "memory-fs": "^0.5.0", @@ -5398,6 +5482,7 @@ "version": "0.5.0", "resolved": "https://registry.npmjs.org/memory-fs/-/memory-fs-0.5.0.tgz", "integrity": "sha512-jA0rdU5KoQMC0e6ppoNRtpp6vjFq6+NY7r8hywnC7V+1Xj/MtHwGIbB1QaK/dunyjWteJzmkpd7ooeWg10T7GA==", + "dev": true, "requires": { "errno": "^0.1.3", "readable-stream": "^2.0.1" @@ -6973,9 +7058,9 @@ "dev": true }, "http-proxy": { - "version": "1.18.0", - "resolved": "https://registry.npmjs.org/http-proxy/-/http-proxy-1.18.0.tgz", - "integrity": "sha512-84I2iJM/n1d4Hdgc6y2+qY5mDaz2PUVjlg9znE9byl+q0uC3DeByqBGReQu5tpLK0TAqTIXScRUV+dg7+bUPpQ==", + "version": "1.18.1", + "resolved": "https://registry.npmjs.org/http-proxy/-/http-proxy-1.18.1.tgz", + "integrity": "sha512-7mz/721AbnJwIVbnaSv1Cz3Am0ZLT/UBwkC92VlxhXv/k/BBQfM2fXElQNC27BVGr0uwUpplYPQM9LnaBMR5NQ==", "dev": true, "requires": { "eventemitter3": "^4.0.0", @@ -7528,12 +7613,6 @@ "isobject": "^3.0.1" } }, - "is-promise": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.1.0.tgz", - "integrity": "sha1-eaKp7OfwlugPNtKy87wWwf9L8/o=", - "dev": true - }, "is-regex": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.0.4.tgz", @@ -7901,6 +7980,12 @@ "resolved": "https://registry.npmjs.org/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz", "integrity": "sha512-mrqyZKfX5EhL7hvqcV6WG1yYjnjeuYDzDhhcAAUrq8Po85NBQBJP+ZDUT75qZQ98IkUoBqdkExkukOU7Ts2wrw==" }, + "json-parse-even-better-errors": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz", + "integrity": "sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==", + "dev": true + }, "json-schema": { "version": "0.2.3", "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz", @@ -8378,9 +8463,9 @@ } }, "lodash": { - "version": "4.17.15", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", - "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==", + "version": "4.17.19", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.19.tgz", + "integrity": "sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ==", "dev": true }, "lodash-es": { @@ -8883,9 +8968,9 @@ "dev": true }, "node-fetch-npm": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/node-fetch-npm/-/node-fetch-npm-2.0.2.tgz", - "integrity": "sha512-nJIxm1QmAj4v3nfCvEeCrYSoVwXyxLnaPBK5W1W5DGEJwjlKuC2VEUycGw5oxk+4zZahRrB84PUJJgEmhFTDFw==", + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/node-fetch-npm/-/node-fetch-npm-2.0.4.tgz", + "integrity": "sha512-iOuIQDWDyjhv9qSDrj9aq/klt6F9z1p2otB3AV7v3zBDcL/x+OfGsvGQZZCcMZbUf4Ujw1xGNQkjvGnVT22cKg==", "dev": true, "requires": { "encoding": "^0.1.11", @@ -9186,9 +9271,9 @@ } }, "npm-registry-fetch": { - "version": "4.0.5", - "resolved": "https://registry.npmjs.org/npm-registry-fetch/-/npm-registry-fetch-4.0.5.tgz", - "integrity": "sha512-yQ0/U4fYpCCqmueB2g8sc+89ckQ3eXpmU4+Yi2j5o/r0WkKvE2+Y0tK3DEILAtn2UaQTkjTHxIXe2/CSdit+/Q==", + "version": "4.0.7", + "resolved": "https://registry.npmjs.org/npm-registry-fetch/-/npm-registry-fetch-4.0.7.tgz", + "integrity": "sha512-cny9v0+Mq6Tjz+e0erFAB+RYJ/AVGzkjnISiobqP8OWj9c9FLoZZu8/SPSKJWE17F1tk4018wfjV+ZbIbqC7fQ==", "dev": true, "requires": { "JSONStream": "^1.3.4", @@ -9372,9 +9457,9 @@ } }, "onetime": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.0.tgz", - "integrity": "sha512-5NcSkPHhwTVFIQN+TUqXoS5+dlElHXdpAWu9I0HP20YOtIi+aZ0Ct82jdlILDxjLEAWwvm+qj1m6aEtsDVmm6Q==", + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.2.tgz", + "integrity": "sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==", "dev": true, "requires": { "mimic-fn": "^2.1.0" @@ -9736,8 +9821,7 @@ "picomatch": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.1.1.tgz", - "integrity": "sha512-OYMyqkKzK7blWO/+XZYP6w8hH0LDvkBvdvKukti+7kqYFCiEAk+gI3DWnryapc0Dau05ugGTy0foQ6mqn4AHYA==", - "dev": true + "integrity": "sha512-OYMyqkKzK7blWO/+XZYP6w8hH0LDvkBvdvKukti+7kqYFCiEAk+gI3DWnryapc0Dau05ugGTy0foQ6mqn4AHYA==" }, "pify": { "version": "4.0.1", @@ -10322,14 +10406,13 @@ } }, "read-package-json": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/read-package-json/-/read-package-json-2.1.1.tgz", - "integrity": "sha512-dAiqGtVc/q5doFz6096CcnXhpYk0ZN8dEKVkGLU0CsASt8SrgF6SF7OTKAYubfvFhWaqofl+Y8HK19GR8jwW+A==", + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/read-package-json/-/read-package-json-2.1.2.tgz", + "integrity": "sha512-D1KmuLQr6ZSJS0tW8hf3WGpRlwszJOXZ3E8Yd/DNRaM5d+1wVRZdHlpGBLAuovjr28LbWvjpWkBHMxpRGGjzNA==", "dev": true, "requires": { "glob": "^7.1.1", - "graceful-fs": "^4.1.2", - "json-parse-better-errors": "^1.0.1", + "json-parse-even-better-errors": "^2.3.0", "normalize-package-data": "^2.0.0", "npm-normalize-package-bin": "^1.0.0" } @@ -10798,13 +10881,10 @@ } }, "run-async": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/run-async/-/run-async-2.3.0.tgz", - "integrity": "sha1-A3GrSuC91yDUFm19/aZP96RFpsA=", - "dev": true, - "requires": { - "is-promise": "^2.1.0" - } + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/run-async/-/run-async-2.4.1.tgz", + "integrity": "sha512-tvVnVv01b8c1RrA6Ep7JkStj85Guv/YrMcwqYQnwjsAS2cTmmPGBBjAjpCW7RrSodNSoE2/qg9O4bceNvUuDgQ==", + "dev": true }, "run-queue": { "version": "1.0.3", @@ -10815,9 +10895,9 @@ } }, "rxjs": { - "version": "6.5.5", - "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.5.5.tgz", - "integrity": "sha512-WfQI+1gohdf0Dai/Bbmk5L5ItH5tYqm3ki2c5GdWhKjalzjg93N3avFjVStyZZz+A2Em+ZxKH5bNghw9UeylGQ==", + "version": "6.6.0", + "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.6.0.tgz", + "integrity": "sha512-3HMA8z/Oz61DUHe+SdOiQyzIf4tOx5oQHmMir7IZEu6TMqCLHT4LRcmNaUS0NwOz8VLvmmBduMsoaUvMaIiqzg==", "requires": { "tslib": "^1.9.0" } @@ -12388,9 +12468,9 @@ "dev": true }, "type-fest": { - "version": "0.8.1", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.8.1.tgz", - "integrity": "sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==", + "version": "0.11.0", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.11.0.tgz", + "integrity": "sha512-OdjXJxnCN1AvyLSzeKIgXTXxV+99ZuXl3Hpo9XpJAv9MBcHrrJOQ5kV7ypXOuQie+AmWG25hLbiKdwYTifzcfQ==", "dev": true }, "type-is": { @@ -12512,23 +12592,23 @@ } }, "universal-analytics": { - "version": "0.4.20", - "resolved": "https://registry.npmjs.org/universal-analytics/-/universal-analytics-0.4.20.tgz", - "integrity": "sha512-gE91dtMvNkjO+kWsPstHRtSwHXz0l2axqptGYp5ceg4MsuurloM0PU3pdOfpb5zBXUvyjT4PwhWK2m39uczZuw==", + "version": "0.4.23", + "resolved": "https://registry.npmjs.org/universal-analytics/-/universal-analytics-0.4.23.tgz", + "integrity": "sha512-lgMIH7XBI6OgYn1woDEmxhGdj8yDefMKg7GkWdeATAlQZFrMrNyxSkpDzY57iY0/6fdlzTbBV03OawvvzG+q7A==", "dev": true, "requires": { - "debug": "^3.0.0", - "request": "^2.88.0", + "debug": "^4.1.1", + "request": "^2.88.2", "uuid": "^3.0.0" }, "dependencies": { "debug": { - "version": "3.2.6", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz", - "integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==", + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.2.0.tgz", + "integrity": "sha512-IX2ncY78vDTjZMFUdmsvIRFY2Cf4FnD0wRs+nQwJU8Lu99/tPFdb0VybiiMTPe3I6rQmwsqQqRBvxU+bZ/I8sg==", "dev": true, "requires": { - "ms": "^2.1.1" + "ms": "2.1.2" } }, "ms": { @@ -12536,6 +12616,44 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", "dev": true + }, + "request": { + "version": "2.88.2", + "resolved": "https://registry.npmjs.org/request/-/request-2.88.2.tgz", + "integrity": "sha512-MsvtOrfG9ZcrOwAW+Qi+F6HbD0CWXEh9ou77uOb7FM2WPhwT7smM833PzanhJLsgXjN89Ir6V2PczXNnMpwKhw==", + "dev": true, + "requires": { + "aws-sign2": "~0.7.0", + "aws4": "^1.8.0", + "caseless": "~0.12.0", + "combined-stream": "~1.0.6", + "extend": "~3.0.2", + "forever-agent": "~0.6.1", + "form-data": "~2.3.2", + "har-validator": "~5.1.3", + "http-signature": "~1.2.0", + "is-typedarray": "~1.0.0", + "isstream": "~0.1.2", + "json-stringify-safe": "~5.0.1", + "mime-types": "~2.1.19", + "oauth-sign": "~0.9.0", + "performance-now": "^2.1.0", + "qs": "~6.5.2", + "safe-buffer": "^5.1.2", + "tough-cookie": "~2.5.0", + "tunnel-agent": "^0.6.0", + "uuid": "^3.3.2" + } + }, + "tough-cookie": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.5.0.tgz", + "integrity": "sha512-nlLsUzgm1kfLXSXfRZMc1KLAugd4hqJHDTvc2hDIwS3mZAfMEuMbc03SujMF+GEcpaX/qboeycw6iO8JwVv2+g==", + "dev": true, + "requires": { + "psl": "^1.1.28", + "punycode": "^2.1.1" + } } } }, @@ -12844,6 +12962,15 @@ "neo-async": "^2.5.0" } }, + "watchpack-chokidar2": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/watchpack-chokidar2/-/watchpack-chokidar2-2.0.0.tgz", + "integrity": "sha512-9TyfOyN/zLUbA288wZ8IsMZ+6cbzvsNyEzSBp6e/zkifi6xxbl8SmQ/CxQq32k8NNqrdVEVUVSEf56L4rQ/ZxA==", + "optional": true, + "requires": { + "chokidar": "^2.1.8" + } + }, "wbuf": { "version": "1.7.3", "resolved": "https://registry.npmjs.org/wbuf/-/wbuf-1.7.3.tgz", @@ -12864,9 +12991,9 @@ } }, "webpack": { - "version": "4.43.0", - "resolved": "https://registry.npmjs.org/webpack/-/webpack-4.43.0.tgz", - "integrity": "sha512-GW1LjnPipFW2Y78OOab8NJlCflB7EFskMih2AHdvjbpKMeDJqEgSx24cXXXiPS65+WSwVyxtDsJH6jGX2czy+g==", + "version": "4.44.0", + "resolved": "https://registry.npmjs.org/webpack/-/webpack-4.44.0.tgz", + "integrity": "sha512-wAuJxK123sqAw31SpkPiPW3iKHgFUiKvO7E7UZjtdExcsRe3fgav4mvoMM7vvpjLHVoJ6a0Mtp2fzkoA13e0Zw==", "requires": { "@webassemblyjs/ast": "1.9.0", "@webassemblyjs/helper-module-context": "1.9.0", @@ -12876,7 +13003,7 @@ "ajv": "^6.10.2", "ajv-keywords": "^3.4.1", "chrome-trace-event": "^1.0.2", - "enhanced-resolve": "^4.1.0", + "enhanced-resolve": "^4.3.0", "eslint-scope": "^4.0.3", "json-parse-better-errors": "^1.0.2", "loader-runner": "^2.4.0", @@ -12889,7 +13016,7 @@ "schema-utils": "^1.0.0", "tapable": "^1.1.3", "terser-webpack-plugin": "^1.4.3", - "watchpack": "^1.6.1", + "watchpack": "^1.7.4", "webpack-sources": "^1.4.1" }, "dependencies": { @@ -13050,6 +13177,107 @@ "@xtuc/long": "4.2.2" } }, + "anymatch": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.1.tgz", + "integrity": "sha512-mM8522psRCqzV+6LhomX5wgp25YVibjh8Wj23I5RPkPppSVSjyKD2A2mBJmWGa+KN7f2D6LNh9jkBCeyLktzjg==", + "optional": true, + "requires": { + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" + } + }, + "binary-extensions": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.1.0.tgz", + "integrity": "sha512-1Yj8h9Q+QDF5FzhMs/c9+6UntbD5MkRfRwac8DoEm9ZfUBZ7tZ55YcGVAzEe4bXsdQHEk+s9S5wsOKVdZrw0tQ==", + "optional": true + }, + "braces": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", + "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "optional": true, + "requires": { + "fill-range": "^7.0.1" + } + }, + "chokidar": { + "version": "3.4.2", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.4.2.tgz", + "integrity": "sha512-IZHaDeBeI+sZJRX7lGcXsdzgvZqKv6sECqsbErJA4mHWfpRrD8B97kSFN4cQz6nGBGiuFia1MKR4d6c1o8Cv7A==", + "optional": true, + "requires": { + "anymatch": "~3.1.1", + "braces": "~3.0.2", + "fsevents": "~2.1.2", + "glob-parent": "~5.1.0", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.4.0" + } + }, + "enhanced-resolve": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-4.3.0.tgz", + "integrity": "sha512-3e87LvavsdxyoCfGusJnrZ5G8SLPOFeHSNpZI/ATL9a5leXo2k0w6MKnbqhdBad9qTobSfB20Ld7UmgoNbAZkQ==", + "requires": { + "graceful-fs": "^4.1.2", + "memory-fs": "^0.5.0", + "tapable": "^1.0.0" + }, + "dependencies": { + "memory-fs": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/memory-fs/-/memory-fs-0.5.0.tgz", + "integrity": "sha512-jA0rdU5KoQMC0e6ppoNRtpp6vjFq6+NY7r8hywnC7V+1Xj/MtHwGIbB1QaK/dunyjWteJzmkpd7ooeWg10T7GA==", + "requires": { + "errno": "^0.1.3", + "readable-stream": "^2.0.1" + } + } + } + }, + "fill-range": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", + "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "optional": true, + "requires": { + "to-regex-range": "^5.0.1" + } + }, + "fsevents": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.1.3.tgz", + "integrity": "sha512-Auw9a4AxqWpa9GUfj370BMPzzyncfBABW8Mab7BGWBYDj4Isgq+cDKtx0i6u9jcX9pQDnswsaaOTgTmA5pEjuQ==", + "optional": true + }, + "glob-parent": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.1.tgz", + "integrity": "sha512-FnI+VGOpnlGHWZxthPGR+QhR78fuiK0sNLkHQv+bL9fQi57lNNdquIbna/WrfROrolq8GK5Ek6BiMwqL/voRYQ==", + "optional": true, + "requires": { + "is-glob": "^4.0.1" + } + }, + "is-binary-path": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", + "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "optional": true, + "requires": { + "binary-extensions": "^2.0.0" + } + }, + "is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "optional": true + }, "minimist": { "version": "1.2.5", "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", @@ -13063,14 +13291,41 @@ "minimist": "^1.2.5" } }, + "readdirp": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.4.0.tgz", + "integrity": "sha512-0xe001vZBnJEK+uKcj8qOhyAKPzIT+gStxWr3LCB0DwcXR5NZJ3IaC+yGnHCYzB/S7ov3m3EEbZI2zeNvX+hGQ==", + "optional": true, + "requires": { + "picomatch": "^2.2.1" + }, + "dependencies": { + "picomatch": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.2.2.tgz", + "integrity": "sha512-q0M/9eZHzmr0AulXyPwNfZjtwZ/RBZlbN3K3CErVrk50T2ASYI7Bye0EvekFY3IP1Nt2DHu0re+V2ZHIpMkuWg==", + "optional": true + } + } + }, + "to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "optional": true, + "requires": { + "is-number": "^7.0.0" + } + }, "watchpack": { - "version": "1.6.1", - "resolved": "https://registry.npmjs.org/watchpack/-/watchpack-1.6.1.tgz", - "integrity": "sha512-+IF9hfUFOrYOOaKyfaI7h7dquUIOgyEMoQMLA7OP5FxegKA2+XdXThAZ9TU2kucfhDH7rfMHs1oPYziVGWRnZA==", + "version": "1.7.4", + "resolved": "https://registry.npmjs.org/watchpack/-/watchpack-1.7.4.tgz", + "integrity": "sha512-aWAgTW4MoSJzZPAicljkO1hsi1oKj/RRq/OJQh2PKI2UKL04c2Bs+MBOB+BBABHTXJpf9mCwHN7ANCvYsvY2sg==", "requires": { - "chokidar": "^2.1.8", + "chokidar": "^3.4.1", "graceful-fs": "^4.1.2", - "neo-async": "^2.5.0" + "neo-async": "^2.5.0", + "watchpack-chokidar2": "^2.0.0" } } } @@ -13439,9 +13694,19 @@ "dev": true }, "zone.js": { - "version": "0.10.3", - "resolved": "https://registry.npmjs.org/zone.js/-/zone.js-0.10.3.tgz", - "integrity": "sha512-LXVLVEq0NNOqK/fLJo3d0kfzd4sxwn2/h67/02pjCjfKDxgx1i9QqpvtHD8CrBnSSwMw5+dy11O7FRX5mkO7Cg==" + "version": "0.11.3", + "resolved": "https://registry.npmjs.org/zone.js/-/zone.js-0.11.3.tgz", + "integrity": "sha512-Y4hTHoh4VcxU5BDGAqEoOnOiyT254w6CiHtpQxAJUSMZPyVgdbKf+5R7Mwz6xsPhMIeBXk5rTopRZDpjssTCUg==", + "requires": { + "tslib": "^2.0.0" + }, + "dependencies": { + "tslib": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.1.0.tgz", + "integrity": "sha512-hcVC3wYEziELGGmEEXue7D75zbwIIVUMWAVbHItGPx0ziyXxrOMQx4rQEVEV45Ut/1IotuEvwqPopzIOkDMf0A==" + } + } } } } diff --git a/package.json b/package.json index 69b9946..f27f1b0 100644 --- a/package.json +++ b/package.json @@ -29,15 +29,15 @@ "jquery": "^3.5.1", "ngx-bootstrap": "^3.2.0", "popper.js": "^1.16.1", - "rxjs": "~6.5.5", + "rxjs": "~6.6.0", "semver": "^6.3.0", - "webpack": "^4.43.0", "tslib": "^1.13.0", - "zone.js": "~0.10.3" + "webpack": "^4.44.0", + "zone.js": "^0.11.3" }, "devDependencies": { "@angular-devkit/build-angular": "^0.803.25", - "@angular/cli": "^8.3.22", + "@angular/cli": "^8.3.29", "@angular/compiler-cli": "~8.2.14", "@angular/language-service": "~8.2.14", "@babel/compat-data": "~7.8.0", @@ -45,7 +45,7 @@ "@types/jasminewd2": "~2.0.3", "@types/node": "^8.10.54", "codelyzer": "^5.0.1", - "elliptic": "^6.5.2", + "elliptic": "^6.5.3", "jasmine-core": "^3.5.0", "jasmine-spec-reporter": "^5.0.2", "karma": "^4.4.1", diff --git a/src/app/inbox/inbox-message/inbox-message.component.spec.ts b/src/app/inbox/inbox-message/inbox-message.component.spec.ts index 3e95625..bc827e7 100644 --- a/src/app/inbox/inbox-message/inbox-message.component.spec.ts +++ b/src/app/inbox/inbox-message/inbox-message.component.spec.ts @@ -10,6 +10,10 @@ import { of } from 'rxjs'; import { NameserviceService } from 'src/app/services/mailchain/nameservice/nameservice.service'; import { HttpClientModule } from '@angular/common/http'; import { NameserviceServiceStub } from 'src/app/services/mailchain/nameservice/nameservice.service.stub'; +import { LocalStorageServerServiceStub } from 'src/app/services/helpers/local-storage-server/local-storage-server.service.stub'; +import { LocalStorageServerService } from 'src/app/services/helpers/local-storage-server/local-storage-server.service'; +import { ProtocolsService } from 'src/app/services/mailchain/protocols/protocols.service'; +import { ProtocolsServiceStub } from 'src/app/services/mailchain/protocols/protocols.service.stub'; describe('InboxMessageComponent', () => { @@ -17,6 +21,8 @@ describe('InboxMessageComponent', () => { let fixture: ComponentFixture; let mailchainService: MailchainService; let nameserviceService: NameserviceService; + let localStorageServerService: LocalStorageServerService; + let protocolsService: ProtocolsService; let mailchainTestService: MailchainTestService @@ -33,7 +39,9 @@ describe('InboxMessageComponent', () => { providers: [ HttpHelpersService, MailchainService, + { provide: ProtocolsService, useClass: ProtocolsServiceStub }, { provide: NameserviceService, useClass: NameserviceServiceStub }, + { provide: LocalStorageServerService, useClass: LocalStorageServerServiceStub }, ], imports: [ ModalModule.forRoot(), @@ -44,12 +52,15 @@ describe('InboxMessageComponent', () => { }) .compileComponents(); mailchainTestService = TestBed.get(MailchainTestService); + protocolsService = TestBed.get(ProtocolsService); + localStorageServerService = TestBed.get(LocalStorageServerService); nameserviceService = TestBed.get(NameserviceService); mailchainService = TestBed.get(MailchainService); })); beforeEach(() => { + fixture = TestBed.createComponent(InboxMessageComponent); component = fixture.componentInstance; @@ -83,103 +94,103 @@ describe('InboxMessageComponent', () => { describe('ngOnInit', () => { describe('resolveNamesFromMessage', () => { - it('should resolve the To field when there is a resolvable name', () => { + it('should resolve the To field when there is a resolvable name', async () => { component.currentMessage["headers"]["to"] = mcAddress1 - component.ngOnInit() + await component.ngOnInit() expect(component.messageNameRecords[address1]).toEqual('myaddress.eth') }) - it('should NOT resolve the To field when there is NOT a resolvable name', () => { + it('should NOT resolve the To field when there is NOT a resolvable name', async () => { component.currentMessage["headers"]["to"] = mcAddress2 - component.ngOnInit() + await component.ngOnInit() expect(component.messageNameRecords[address2]).toEqual(undefined) }) - it('should resolve the From field when there is a resolvable name', () => { + it('should resolve the From field when there is a resolvable name', async () => { component.currentMessage["headers"]["from"] = mcAddress1 - component.ngOnInit() + await component.ngOnInit() expect(component.messageNameRecords[address1]).toEqual('myaddress.eth') }) - it('should NOT resolve the From field when there is NOT a resolvable name', () => { + it('should NOT resolve the From field when there is NOT a resolvable name', async () => { component.currentMessage["headers"]["from"] = mcAddress2 - component.ngOnInit() + await component.ngOnInit() expect(component.messageNameRecords[address2]).toEqual(undefined) }) }); }); describe('getViewForContentType', () => { - it('should call getViewForContentType when the content-type is plaintext ', () => { + it('should call getViewForContentType when the content-type is plaintext ', async () => { spyOn(component, 'getViewForContentType') component.currentMessage["headers"]["content-type"] = 'text/plain; charset="UTF-8"' - component.ngOnInit() + await component.ngOnInit() expect(component.getViewForContentType).toHaveBeenCalled() }) - it('should call getViewForContentType when the content-type is text/plain; charset="UTF-8"', () => { + it('should call getViewForContentType when the content-type is text/plain; charset="UTF-8"', async () => { spyOn(component, 'getViewForContentType') component.currentMessage["headers"]["content-type"] = 'text/plain; charset="UTF-8"' - component.ngOnInit() + await component.ngOnInit() expect(component.getViewForContentType).toHaveBeenCalled() }) - it('should call getViewForContentType when the content-type is unknown', () => { + it('should call getViewForContentType when the content-type is unknown', async () => { spyOn(component, 'getViewForContentType') component.currentMessage["headers"]["content-type"] = 'unknown' - component.ngOnInit() + await component.ngOnInit() expect(component.getViewForContentType).toHaveBeenCalled() }) }) describe('addMessageText', () => { - it('should call addMessageText when the content-type is plaintext ', () => { + it('should call addMessageText when the content-type is plaintext ', async () => { spyOn(component, 'addMessageText') component.currentMessage["headers"]["content-type"] = 'text/plain; charset="UTF-8"' - component.ngOnInit() + await component.ngOnInit() expect(component.addMessageText).toHaveBeenCalled() }) - it('should NOT call addMessageText when the content-type is text/html; charset="UTF-8" ', () => { + it('should NOT call addMessageText when the content-type is text/html; charset="UTF-8" ', async () => { spyOn(component, 'addMessageText') component.currentMessage["headers"]["content-type"] = 'text/html; charset="UTF-8"' - component.ngOnInit() + await component.ngOnInit() expect(component.addMessageText).not.toHaveBeenCalled() }) - it('should call addMessageText when the content-type is unknown ', () => { + it('should call addMessageText when the content-type is unknown ', async () => { spyOn(component, 'addMessageText') component.currentMessage["headers"]["content-type"] = 'unknown' - component.ngOnInit() + await component.ngOnInit() expect(component.addMessageText).toHaveBeenCalled() }) }) describe('addMessageIframe', () => { - it('should NOT call addMessageIframe when the content-type is plaintext ', () => { + it('should NOT call addMessageIframe when the content-type is plaintext ', async () => { spyOn(component, 'addMessageIframe') component.currentMessage["headers"]["content-type"] = 'text/plain; charset="UTF-8"' - component.ngOnInit() + await component.ngOnInit() expect(component.addMessageIframe).not.toHaveBeenCalled() }) - it('should call addMessageIframe when the content-type is text/html; charset="UTF-8" ', () => { + it('should call addMessageIframe when the content-type is text/html; charset="UTF-8" ', async () => { spyOn(component, 'addMessageIframe') component.currentMessage["headers"]["content-type"] = 'text/html; charset="UTF-8"' - component.ngOnInit() + await component.ngOnInit() expect(component.addMessageIframe).toHaveBeenCalled() }) - it('should NOT call addMessageIframe when the content-type is unknown ', () => { + it('should NOT call addMessageIframe when the content-type is unknown ', async () => { spyOn(component, 'addMessageIframe') component.currentMessage["headers"]["content-type"] = 'unknown' - component.ngOnInit() + await component.ngOnInit() expect(component.addMessageIframe).not.toHaveBeenCalled() }) diff --git a/src/app/inbox/inbox-message/inbox-message.component.ts b/src/app/inbox/inbox-message/inbox-message.component.ts index 3a9c636..d4a9da0 100644 --- a/src/app/inbox/inbox-message/inbox-message.component.ts +++ b/src/app/inbox/inbox-message/inbox-message.component.ts @@ -2,6 +2,7 @@ import { Component, Input, Output, EventEmitter, OnInit, ViewEncapsulation } fro import { InboundMail } from 'src/app/models/inbound-mail'; import { NameserviceService } from 'src/app/services/mailchain/nameservice/nameservice.service'; import { MailchainService } from 'src/app/services/mailchain/mailchain.service'; +import { LocalStorageNameserviceService } from 'src/app/services/helpers/local-storage-nameservice/local-storage-nameservice.service'; @Component({ selector: '[inbox-message]', @@ -22,6 +23,7 @@ export class InboxMessageComponent implements OnInit { constructor( private nameserviceService: NameserviceService, private mailchainService: MailchainService, + private localStorageNameserviceService: LocalStorageNameserviceService, ) { } /** * Go back to the inbox-messages view @@ -30,8 +32,8 @@ export class InboxMessageComponent implements OnInit { this.goToInboxMessages.emit(''); } - ngOnInit() { - this.resolveNamesFromMessage() + async ngOnInit() { + await this.resolveNamesFromMessage() this.getViewForContentType() } @@ -47,12 +49,13 @@ export class InboxMessageComponent implements OnInit { * Sets the name corresponding to messageNameRecords * @param addr address in format 0x1234...1234 */ - private resolveMessageNameRecords(addr) { - this.nameserviceService.resolveAddress( + private async resolveMessageNameRecords(addr) { + let obs = await this.nameserviceService.resolveAddress( this.currentProtocol, this.currentNetwork, addr - ).subscribe(res => { + ) + obs.subscribe(res => { if (res['ok']) { this.messageNameRecords[addr] = res['body']['name'] } @@ -63,15 +66,17 @@ export class InboxMessageComponent implements OnInit { * resolveNamesFromMessages looks up the 'to' and 'from' name * records according to the currentNetwork and currentProtocol */ - private resolveNamesFromMessage() { - [ - this.currentMessage["headers"]["to"], - this.currentMessage["headers"]["from"] - ].forEach(element => { - let parsedAddr = this.parseAddressFromMailchain(element) - this.resolveMessageNameRecords(parsedAddr) - }); - + private async resolveNamesFromMessage() { + if (await this.localStorageNameserviceService.getCurrentNameserviceAddressEnabled() == "true") { + + [ + this.currentMessage["headers"]["to"], + this.currentMessage["headers"]["from"] + ].forEach(async element => { + let parsedAddr = this.parseAddressFromMailchain(element) + await this.resolveMessageNameRecords(parsedAddr) + }); + }; } /** diff --git a/src/app/inbox/inbox-messages/inbox-messages.component.spec.ts b/src/app/inbox/inbox-messages/inbox-messages.component.spec.ts index 67cf60d..af5f566 100644 --- a/src/app/inbox/inbox-messages/inbox-messages.component.spec.ts +++ b/src/app/inbox/inbox-messages/inbox-messages.component.spec.ts @@ -10,17 +10,24 @@ import { of } from 'rxjs'; import { NameserviceService } from 'src/app/services/mailchain/nameservice/nameservice.service'; import { ReadServiceStub } from 'src/app/services/mailchain/messages/read.service.stub'; import { NameserviceServiceStub } from 'src/app/services/mailchain/nameservice/nameservice.service.stub'; +import { ProtocolsService } from 'src/app/services/mailchain/protocols/protocols.service'; +import { ProtocolsServiceStub } from 'src/app/services/mailchain/protocols/protocols.service.stub'; +import { MailchainTestService } from 'src/app/test/test-helpers/mailchain-test.service'; describe('InboxMessagesComponent', () => { let component: InboxMessagesComponent; let fixture: ComponentFixture; let mailchainService: MailchainService let readService: ReadService; - let nameserviceService: NameserviceService + let nameserviceService: NameserviceService; + let protocolsService: ProtocolsService; + let mailchainTestService: MailchainTestService + const address1 = "0x0123456789012345678901234567890123456789" - const address2 = "0x0000000000000000000000000000000000000002" - const addresses = [address1, address2] + const address2 = "0xbbb0000000000000000000000000000000000000" + const address3 = "0xabc000000000000000000000000000000000000a" + const addresses = [address1, address2, address3] // id 00: unread & status ok; @@ -41,10 +48,23 @@ describe('InboxMessagesComponent', () => { // id 05: read & status error; // from: address 1 // to: address 2 + // id 06: addresses uppercase; + // from: address 2 + // to: address 3 + // id 07: addresses lowercase; + // from: address 2 + // to: address 3 + // id 08: addresses lowercase (SUBSTRATE); + // from: substrate address 1 + // to: substrate address 2 + // id 09: TO address uppercase (SUBSTRATE); + // from: substrate address 1 + // to: substrate address 2 + const messages = [ { "headers": { - "from": "<0x0000000000000000000000000000000000000002@ropsten.ethereum>", + "from": "<0xbbb0000000000000000000000000000000000000@ropsten.ethereum>", "to": "<0x0123456789012345678901234567890123456789@ropsten.ethereum>", "message-id": "00" }, @@ -54,7 +74,7 @@ describe('InboxMessagesComponent', () => { }, { "headers": { - "from": "<0x0000000000000000000000000000000000000002@ropsten.ethereum>", + "from": "<0xbbb0000000000000000000000000000000000000@ropsten.ethereum>", "to": "<0x0123456789012345678901234567890123456789@ropsten.ethereum>", "message-id": "01" }, @@ -64,7 +84,7 @@ describe('InboxMessagesComponent', () => { }, { "headers": { - "from": "<0x0000000000000000000000000000000000000002@ropsten.ethereum>", + "from": "<0xbbb0000000000000000000000000000000000000@ropsten.ethereum>", "to": "<0x0123456789012345678901234567890123456789@ropsten.ethereum>", "message-id": "02" }, @@ -75,7 +95,7 @@ describe('InboxMessagesComponent', () => { { "headers": { "from": "<0x0123456789012345678901234567890123456789@ropsten.ethereum>", - "to": "<0x0000000000000000000000000000000000000002@ropsten.ethereum>", + "to": "<0xbbb0000000000000000000000000000000000000@ropsten.ethereum>", "message-id": "03" }, "read": false, @@ -85,7 +105,7 @@ describe('InboxMessagesComponent', () => { { "headers": { "from": "<0x0123456789012345678901234567890123456789@ropsten.ethereum>", - "to": "<0x0000000000000000000000000000000000000002@ropsten.ethereum>", + "to": "<0xbbb0000000000000000000000000000000000000@ropsten.ethereum>", "message-id": "04" }, "read": true, @@ -95,13 +115,53 @@ describe('InboxMessagesComponent', () => { { "headers": { "from": "<0x0123456789012345678901234567890123456789@ropsten.ethereum>", - "to": "<0x0000000000000000000000000000000000000002@ropsten.ethereum>", + "to": "<0xbbb0000000000000000000000000000000000000@ropsten.ethereum>", "message-id": "05" }, "read": true, "status": "error", "subject": "Message 05" - } + }, + { + "headers": { + "from": "<0xbbb0000000000000000000000000000000000000@ropsten.ethereum>", + "to": "<0xABC000000000000000000000000000000000000A@ropsten.ethereum>", + "message-id": "06" + }, + "read": false, + "status": "ok", + "subject": "Message 06" + }, + { + "headers": { + "from": "<0xbbb0000000000000000000000000000000000000@ropsten.ethereum>", + "to": "<0xabc000000000000000000000000000000000000a@ropsten.ethereum>", + "message-id": "07" + }, + "read": false, + "status": "ok", + "subject": "Message 07" + }, + { + "headers": { + "from": "<5F4HMyes8GNWzpSDjTPSh61Aw6RTaWmZKwKvszocwqbsdn4h@edgeware-mainnet.substrate>", + "to": "<5CaLgJUDdDRxw6KQXJY2f5hFkMEEGHvtUPQYDWdSbku42Dv2@edgeware-mainnet.substrate>", + "message-id": "08" + }, + "read": false, + "status": "ok", + "subject": "Message 08" + }, + { + "headers": { + "from": "<5F4HMyes8GNWzpSDjTPSh61Aw6RTaWmZKwKvszocwqbsdn4h@edgeware-mainnet.substrate>", + "to": "<5CALGJUDDDRXW6KQXJY2F5HFKMEEGHVTUPQYDWDSBKU42DV2@edgeware-mainnet.substrate>", + "message-id": "09" + }, + "read": false, + "status": "ok", + "subject": "Message 09" + }, ] @@ -113,6 +173,7 @@ describe('InboxMessagesComponent', () => { providers: [ HttpHelpersService, MailchainService, + { provide: ProtocolsService, useClass: ProtocolsServiceStub }, { provide: ReadService, useClass: ReadServiceStub }, { provide: NameserviceService, useClass: NameserviceServiceStub }, @@ -124,8 +185,10 @@ describe('InboxMessagesComponent', () => { }) .compileComponents(); mailchainService = TestBed.get(MailchainService); + protocolsService = TestBed.get(ProtocolsService); readService = TestBed.get(ReadService); nameserviceService = TestBed.get(NameserviceService); + mailchainTestService = TestBed.get(MailchainTestService); })); @@ -166,12 +229,12 @@ describe('InboxMessagesComponent', () => { }); describe('resolveSendersFromMessages', () => { - it('should include resolved names in messagesNameRecords', () => { - component.resolveSendersFromMessages(messages) + it('should include resolved names in messagesNameRecords', async () => { + await component.resolveSendersFromMessages(messages) expect(component.messagesNameRecords[address1]).toEqual("myaddress.eth") }) - it('should not include unresolved names in messagesNameRecords', () => { - component.resolveSendersFromMessages(messages) + it('should not include unresolved names in messagesNameRecords', async () => { + await component.resolveSendersFromMessages(messages) expect(component.messagesNameRecords[address2]).toEqual(undefined) }) }) @@ -182,15 +245,22 @@ describe('InboxMessagesComponent', () => { let protocol = 'ethereum' let addrIcon1 = mailchainService.generateIdenticon(protocol, address1); let addrIcon2 = mailchainService.generateIdenticon(protocol, address2); - messages.forEach(msg => { component.addMailToInboxMessages(msg) }) component.inboxMessages.forEach((val, index) => { - expect(val['senderIdenticon']).toEqual( - index <= 2 ? addrIcon2 : addrIcon1 - ) + let icon + + if ( [0,1,2, 6,7,].includes(index) ){ + icon = addrIcon2 + } else if ([3,4,5].includes(index)) { + icon = addrIcon1 + } else if ([8,9].includes(index)) { + icon = '' // SUBSTRATE not supported + }; + + expect(val['senderIdenticon']).toEqual(icon); }); }); @@ -224,7 +294,7 @@ describe('InboxMessagesComponent', () => { let message = { "headers": { "from": "<0x0123456789012345678901234567890123456789@ropsten.ethereum>", - "to": "<0x0000000000000000000000000000000000000002@ropsten.ethereum>", + "to": "<0xbbb0000000000000000000000000000000000000@ropsten.ethereum>", "message-id": "05" }, "read": true, @@ -546,9 +616,9 @@ describe('InboxMessagesComponent', () => { component.addMailToInboxMessages(msg) }) }) - it('should set currentAccountInboxMessages to the currently selected account', () => { + it('should set currentAccountInboxMessages to the currently selected account', async () => { component.currentAccount = address2 - component.getCurrentAccountInboxMessages() + await component.getCurrentAccountInboxMessages() expect(component.currentAccountInboxMessages).toEqual([ component.inboxMessages[3], @@ -556,19 +626,19 @@ describe('InboxMessagesComponent', () => { component.inboxMessages[5] ]) }) - it('should filter currentAccountInboxMessages based on search text', () => { + it('should filter currentAccountInboxMessages based on search text', async () => { component.currentAccount = address2 component.searchText = "Message 04" - component.getCurrentAccountInboxMessages() + await component.getCurrentAccountInboxMessages() expect(component.currentAccountInboxMessages).toEqual([ component.inboxMessages[4] ]) }) - it('should dedupe currentAccountInboxMessages', () => { + it('should dedupe currentAccountInboxMessages', async () => { component.currentAccount = address2 component.inboxMessages.push(component.inboxMessages[4]) - component.getCurrentAccountInboxMessages() + await component.getCurrentAccountInboxMessages() expect(component.currentAccountInboxMessages).toEqual([ component.inboxMessages[3], @@ -576,6 +646,32 @@ describe('InboxMessagesComponent', () => { component.inboxMessages[5] ]) }) + + describe('and case sensitivity', () => { + describe('for ethereum', () => { + it('should be case insensitive', async () => { + component.currentAccount = address3 + await component.getCurrentAccountInboxMessages() + + expect(component.currentAccountInboxMessages).toEqual([ + component.inboxMessages[6], + component.inboxMessages[7] + ]) + + }); + }); + describe('for substrate', () => { + it('should be case sensitive', async () => { + component.currentAccount = "5CaLgJUDdDRxw6KQXJY2f5hFkMEEGHvtUPQYDWdSbku42Dv2" + component.currentProtocol = "substrate" + await component.getCurrentAccountInboxMessages() + + expect(component.currentAccountInboxMessages).toEqual([ + component.inboxMessages[8] + ]) + }); + }); + }); }); describe('ngOnChanges', () => { xit('should selectNone if "event" contains "currentAccount"', () => { diff --git a/src/app/inbox/inbox-messages/inbox-messages.component.ts b/src/app/inbox/inbox-messages/inbox-messages.component.ts index d2cdf65..afe5457 100644 --- a/src/app/inbox/inbox-messages/inbox-messages.component.ts +++ b/src/app/inbox/inbox-messages/inbox-messages.component.ts @@ -67,8 +67,8 @@ export class InboxMessagesComponent implements OnInit, OnChanges { * resolveSendersFromMessages of messages by name according to the currentNetwork and currentProtocol * @param messagesArray the array of messages */ - resolveSendersFromMessages(messagesArray) { - this.messagesNameRecords = this.mailchainService.resolveSendersFromMessages( + async resolveSendersFromMessages(messagesArray) { + this.messagesNameRecords = await this.mailchainService.resolveSendersFromMessages( this.currentProtocol, this.currentNetwork, messagesArray @@ -193,14 +193,14 @@ export class InboxMessagesComponent implements OnInit, OnChanges { async ngOnInit(): Promise { - this.getCurrentAccountInboxMessages() + await this.getCurrentAccountInboxMessages() } /** * Get the inbox messages, filtered by 'currently selected account' > 'searchtext'. * Dedupe message array - workaround for dupe messages @TODO: waiting on dupe bugfix in mailchain */ - getCurrentAccountInboxMessages() { + async getCurrentAccountInboxMessages() { if (this.currentProtocol && this.currentAccount) { var inboxMessagesFilteredByAddress = this.addressPipe.transform( this.inboxMessages, { @@ -217,7 +217,7 @@ export class InboxMessagesComponent implements OnInit, OnChanges { this.currentAccountInboxMessages = this.mailchainService.dedupeMessagesByIds(inboxMessagesFilteredByAddressSearch) // fetch names for senders - this.resolveSendersFromMessages(this.currentAccountInboxMessages) + await this.resolveSendersFromMessages(this.currentAccountInboxMessages) } } @@ -226,7 +226,7 @@ export class InboxMessagesComponent implements OnInit, OnChanges { if ('currentAccount' in event) { this.selectNone() } - this.getCurrentAccountInboxMessages() + await this.getCurrentAccountInboxMessages() } } diff --git a/src/app/inbox/inbox.component.spec.ts b/src/app/inbox/inbox.component.spec.ts index 9e6a0ef..e97b489 100644 --- a/src/app/inbox/inbox.component.spec.ts +++ b/src/app/inbox/inbox.component.spec.ts @@ -27,6 +27,7 @@ import { MessagesServiceStub } from '../services/mailchain/messages/messages.ser import { ProtocolsServiceStub } from '../services/mailchain/protocols/protocols.service.stub'; import { NameserviceServiceStub } from '../services/mailchain/nameservice/nameservice.service.stub'; import { LocalStorageAccountServiceStub } from '../services/helpers/local-storage-account/local-storage-account.service.stub'; +import { LocalStorageNameserviceService } from '../services/helpers/local-storage-nameservice/local-storage-nameservice.service'; describe('InboxComponent', () => { let component: InboxComponent; @@ -35,6 +36,7 @@ describe('InboxComponent', () => { let protocolsService: ProtocolsService let localStorageAccountService: LocalStorageAccountService let localStorageServerService: LocalStorageServerService + let localStorageNameserviceService: LocalStorageNameserviceService let mailchainService: MailchainService let nameserviceService: NameserviceService let addressesService: AddressesService @@ -86,6 +88,7 @@ describe('InboxComponent', () => { protocolsService = TestBed.get(ProtocolsService); localStorageAccountService = TestBed.get(LocalStorageAccountService); localStorageServerService = TestBed.get(LocalStorageServerService); + localStorageNameserviceService = TestBed.get(LocalStorageNameserviceService); mailchainService = TestBed.get(MailchainService); nameserviceService = TestBed.get(NameserviceService); addressesService = TestBed.get(AddressesService); @@ -100,6 +103,7 @@ describe('InboxComponent', () => { }); afterEach(() => { + localStorageServerService.removeCurrentNetwork(); fixture.destroy(); }) @@ -212,7 +216,7 @@ describe('InboxComponent', () => { }); describe('getServerSettings', () => { - it('should set the currentWebProtocol to the value foundin localStorage"', () => { + it('should set the currentWebProtocol to the value found in localStorage"', () => { let val = 'webProtocolVal' localStorageServerService.setCurrentWebProtocol(val) @@ -222,7 +226,7 @@ describe('InboxComponent', () => { expect(component.currentWebProtocol).toEqual(val) }); - it('should set the currentHost to the value foundin localStorage"', () => { + it('should set the currentHost to the value found in localStorage"', () => { let val = 'hostVal' localStorageServerService.setCurrentWebProtocol(val) @@ -231,7 +235,7 @@ describe('InboxComponent', () => { component.getServerSettings() expect(component.currentWebProtocol).toEqual(val) }); - it('should set the currentPort to the value foundin localStorage"', () => { + it('should set the currentPort to the value found in localStorage"', () => { let val = 'portVal' localStorageServerService.setCurrentWebProtocol(val) @@ -242,6 +246,29 @@ describe('InboxComponent', () => { }); }); + describe('getNameserviceSettings', () => { + it('should clear the existing nameservice address enabled status', async () => { + spyOn(localStorageNameserviceService,'removeCurrentNameserviceAddressEnabled').and.callThrough(); + await component.updateNameserviceSettings(); + expect(localStorageNameserviceService.removeCurrentNameserviceAddressEnabled).toHaveBeenCalled(); + }); + it('should lookup the nameservice address enabled status', async () => { + spyOn(localStorageNameserviceService,'setCurrentNameserviceAddressEnabled').and.callThrough(); + await component.updateNameserviceSettings(); + expect(localStorageNameserviceService.setCurrentNameserviceAddressEnabled).toHaveBeenCalled(); + }); + it('should clear the existing nameservice domain enabled status', async () => { + spyOn(localStorageNameserviceService,'removeCurrentNameserviceDomainEnabled').and.callThrough(); + await component.updateNameserviceSettings(); + expect(localStorageNameserviceService.removeCurrentNameserviceDomainEnabled).toHaveBeenCalled(); + }); + it('should lookup the nameservice domain enabled status', async () => { + spyOn(localStorageNameserviceService,'setCurrentNameserviceDomainEnabled').and.callThrough(); + await component.updateNameserviceSettings(); + expect(localStorageNameserviceService.setCurrentNameserviceDomainEnabled).toHaveBeenCalled(); + }); + }); + describe('addressIsActive', () => { it('should return true if the address is equal to the currentAccount', () => { component.currentAccount = currentAccount @@ -301,14 +328,15 @@ describe('InboxComponent', () => { }); describe('setAccountNameRecords', () => { - it('should lookup a name each fromAddress', () => { + it('should lookup a name each fromAddress', async () => { + localStorageServerService.setCurrentNetwork("mainnet") + + await component.updateNameserviceSettings() component.fromAddressesKeys = [currentAccount, currentAccount2] - component.setAccountNameRecords() - + await component.setAccountNameRecords() + expect(component.accountNameRecord[currentAccount]).toEqual(currentAccountNameLookup) - expect(component.accountNameRecord[currentAccount2]).toEqual(currentAccount2NameLookup) - }); }); diff --git a/src/app/inbox/inbox.component.ts b/src/app/inbox/inbox.component.ts index dc41247..dbcb503 100644 --- a/src/app/inbox/inbox.component.ts +++ b/src/app/inbox/inbox.component.ts @@ -7,6 +7,7 @@ import { LocalStorageServerService } from '../services/helpers/local-storage-ser import { LocalStorageProtocolService } from '../services/helpers/local-storage-protocol/local-storage-protocol.service'; import { AddressesService } from '../services/mailchain/addresses/addresses.service'; import { NameserviceService } from '../services/mailchain/nameservice/nameservice.service'; +import { LocalStorageNameserviceService } from '../services/helpers/local-storage-nameservice/local-storage-nameservice.service'; @Component({ selector: 'app-inbox', @@ -42,7 +43,8 @@ export class InboxComponent implements OnInit { constructor( private localStorageAccountService: LocalStorageAccountService, private localStorageServerService: LocalStorageServerService, - private LocalStorageProtocolService: LocalStorageProtocolService, + private localStorageProtocolService: LocalStorageProtocolService, + private localStorageNameserviceService: LocalStorageNameserviceService, private addressesService: AddressesService, private mailchainService: MailchainService, private messagesService: MessagesService, @@ -155,14 +157,17 @@ export class InboxComponent implements OnInit { /** * Lookup name records for addresses */ - setAccountNameRecords() { - this.fromAddressesKeys.forEach(address => { - this.nameserviceService.resolveAddress(this.currentProtocol, this.currentNetwork, address).subscribe(res => { - if (res['ok']) { - this.accountNameRecord[address] = res['body']['name'] - } - }) - }); + async setAccountNameRecords() { + if (await this.localStorageNameserviceService.getCurrentNameserviceAddressEnabled() == "true") { + await this.fromAddressesKeys.forEach(async address => { + let obs = await this.nameserviceService.resolveAddress(this.currentProtocol, this.currentNetwork, address) + obs.subscribe(res => { + if (res['ok']) { + this.accountNameRecord[address] = res['body']['name'] + } + }) + }); + }; } async ngOnInit(): Promise { @@ -171,7 +176,8 @@ export class InboxComponent implements OnInit { try { this.currentAccount = await this.localStorageAccountService.getCurrentAccount() this.currentNetwork = this.localStorageServerService.getCurrentNetwork() - this.currentProtocol = await this.LocalStorageProtocolService.getCurrentProtocol() + this.currentProtocol = await this.localStorageProtocolService.getCurrentProtocol() + await this.updateNameserviceSettings() this.getServerSettings() } catch (error) { this.getServerSettings() @@ -245,6 +251,13 @@ export class InboxComponent implements OnInit { validMessages.forEach(msg => this.addMailToInboxMessages(msg)); } + /** clear and (re)sets the nameservice settings for the protocol */ + public async updateNameserviceSettings(){ + await this.localStorageNameserviceService.removeCurrentNameserviceAddressEnabled() + await this.localStorageNameserviceService.removeCurrentNameserviceDomainEnabled() + await this.localStorageNameserviceService.getCurrentNameserviceAddressEnabled() + await this.localStorageNameserviceService.getCurrentNameserviceDomainEnabled() + } /** * setFetchingMessagesState diff --git a/src/app/pipes/address-pipe/address-pipe.pipe.ts b/src/app/pipes/address-pipe/address-pipe.pipe.ts index 730bcd8..23a3d53 100644 --- a/src/app/pipes/address-pipe/address-pipe.pipe.ts +++ b/src/app/pipes/address-pipe/address-pipe.pipe.ts @@ -30,8 +30,8 @@ export class AddressPipe implements PipeTransform { if (value) { return value.filter(conversation => { let toAddress = this.mailchainService.parseAddressFromMailchain(protocol, conversation["headers"]["to"]) - - return fromAddress == this.addressesService.handleAddressFormatting(toAddress, protocol); + + return fromAddress == this.addressesService.handleAddressFormattingByProtocol(toAddress, protocol); }); } } diff --git a/src/app/services/helpers/error-messages/error-messages.ts b/src/app/services/helpers/error-messages/error-messages.ts index 2ad934f..f850757 100644 --- a/src/app/services/helpers/error-messages/error-messages.ts +++ b/src/app/services/helpers/error-messages/error-messages.ts @@ -15,7 +15,7 @@ export const errorMessages = { "connectionErrorTitle": "Connection Error", // unknown error - "unknownErrorMessage": "

An unkown error occured.

Please raise an issue on Github to get some help.

", + "unknownErrorMessage": "

An unknown error occurred.

Please raise an issue on Github to get some help.

", "unknownErrorTitle": "Unknown Error", // update available diff --git a/src/app/services/helpers/local-storage-nameservice/local-storage-nameservice.service.spec.ts b/src/app/services/helpers/local-storage-nameservice/local-storage-nameservice.service.spec.ts new file mode 100644 index 0000000..e09c026 --- /dev/null +++ b/src/app/services/helpers/local-storage-nameservice/local-storage-nameservice.service.spec.ts @@ -0,0 +1,126 @@ +import { TestBed } from '@angular/core/testing'; +import { MailchainTestService } from 'src/app/test/test-helpers/mailchain-test.service'; +import { ProtocolsService } from '../../mailchain/protocols/protocols.service'; +import { ProtocolsServiceStub } from '../../mailchain/protocols/protocols.service.stub'; + +import { LocalStorageNameserviceService } from './local-storage-nameservice.service'; + +describe('LocalStorageNameserviceService', () => { + let localStorageNameserviceService: LocalStorageNameserviceService; + let mailchainTestService: MailchainTestService; + let protocolsService: ProtocolsService; + +MailchainTestService + beforeEach(() => { + TestBed.configureTestingModule({ + providers: [ + LocalStorageNameserviceService, + { provide: ProtocolsService, useClass: ProtocolsServiceStub }, + ] + }); + + mailchainTestService = TestBed.get(MailchainTestService); + localStorageNameserviceService = TestBed.get(LocalStorageNameserviceService); + protocolsService = TestBed.get(ProtocolsService) + + }); + + afterEach(() => { + sessionStorage.clear(); + }) + it('should be created', () => { + const service: LocalStorageNameserviceService = TestBed.get(LocalStorageNameserviceService); + expect(service).toBeTruthy(); + }); + + describe('getCurrentNameserviceAddressEnabled', () => { + it('should get the current nameservice address enabled status when "true"', async () => { + sessionStorage.setItem('currentNameserviceAddressEnabled', "true"); + expect(await localStorageNameserviceService.getCurrentNameserviceAddressEnabled()).toEqual("true"); + }); + it('should get the current nameservice address enabled status when "false"', async () => { + sessionStorage.setItem('currentNameserviceAddressEnabled', "false"); + expect(await localStorageNameserviceService.getCurrentNameserviceAddressEnabled()).toEqual("false"); + }); + it('should look up the current nameservice address enabled status from protocols endpoint if not defined, expecting `true` (ethereum)', async () => { + sessionStorage.removeItem('currentNameserviceAddressEnabled'); + sessionStorage.setItem('currentProtocol', 'ethereum') + sessionStorage.setItem('currentNetwork', 'mainnet') + spyOn(protocolsService, 'getProtocols').and.returnValue(mailchainTestService.protocolsServerResponse()) + + expect(await localStorageNameserviceService.getCurrentNameserviceAddressEnabled()).toEqual("true"); + }); + it('should look up the current nameservice address enabled status from protocols endpoint if not defined, expecting `false` (substrate)', async () => { + sessionStorage.removeItem('currentNameserviceAddressEnabled'); + sessionStorage.setItem('currentProtocol', 'substrate') + sessionStorage.setItem('currentNetwork', 'edgeware-mainnet') + spyOn(protocolsService, 'getProtocols').and.returnValue(mailchainTestService.protocolsServerResponse()) + + expect(await localStorageNameserviceService.getCurrentNameserviceAddressEnabled()).toEqual("false"); + }); + + }); + describe('setCurrentNameserviceAddressEnabled', () => { + it('should set the current nameservice address enabled status to "true" when `"true"`', async () => { + localStorageNameserviceService.setCurrentNameserviceAddressEnabled("true") + expect(await localStorageNameserviceService.getCurrentNameserviceAddressEnabled()).toEqual("true"); + }); + it('should set the current nameservice address enabled status to "false" if not "true"', async () => { + localStorageNameserviceService.setCurrentNameserviceAddressEnabled("false") + expect(await localStorageNameserviceService.getCurrentNameserviceAddressEnabled()).toEqual("false"); + }); + }); + describe('removeCurrentNameserviceAddressEnabled', () => { + it('should remove the current nameservice address enabled status', async () => { + sessionStorage.setItem('currentNameserviceAddressEnabled', "true") + localStorageNameserviceService.removeCurrentNameserviceAddressEnabled() + expect(sessionStorage.getItem('currentNameserviceAddressEnabled')).toEqual(null); + }); + }); + + describe('getCurrentNameserviceDomainEnabled', () => { + it('should get the current nameservice domain enabled status when "true"', async () => { + sessionStorage.setItem('currentNameserviceDomainEnabled', "true"); + expect(await localStorageNameserviceService.getCurrentNameserviceDomainEnabled()).toEqual("true"); + }); + it('should get the current nameservice domain enabled status when "false"', async () => { + sessionStorage.setItem('currentNameserviceDomainEnabled', "false"); + expect(await localStorageNameserviceService.getCurrentNameserviceDomainEnabled()).toEqual("false"); + }); + it('should look up the current nameservice domain enabled status from protocols endpoint if not defined, expecting `true` (ethereum)', async () => { + sessionStorage.removeItem('currentNameserviceDomainEnabled'); + sessionStorage.setItem('currentProtocol', 'ethereum') + sessionStorage.setItem('currentNetwork', 'mainnet') + spyOn(protocolsService, 'getProtocols').and.returnValue(mailchainTestService.protocolsServerResponse()) + + expect(await localStorageNameserviceService.getCurrentNameserviceDomainEnabled()).toEqual("true"); + }); + it('should look up the current nameservice domain enabled status from protocols endpoint if not defined, expecting `false` (substrate)', async () => { + sessionStorage.removeItem('currentNameserviceDomainEnabled'); + sessionStorage.setItem('currentProtocol', 'substrate') + sessionStorage.setItem('currentNetwork', 'edgeware-mainnet') + spyOn(protocolsService, 'getProtocols').and.returnValue(mailchainTestService.protocolsServerResponse()) + + expect(await localStorageNameserviceService.getCurrentNameserviceDomainEnabled()).toEqual("false"); + }); + + }); + describe('setCurrentNameserviceDomainEnabled', () => { + it('should set the current nameservice domain enabled status to "true" when `"true"`', async () => { + localStorageNameserviceService.setCurrentNameserviceDomainEnabled("true") + expect(await localStorageNameserviceService.getCurrentNameserviceDomainEnabled()).toEqual("true"); + }); + it('should set the current nameservice domain enabled status to "false" if not "true"', async () => { + localStorageNameserviceService.setCurrentNameserviceDomainEnabled("false") + expect(await localStorageNameserviceService.getCurrentNameserviceDomainEnabled()).toEqual("false"); + }); + }); + describe('removeCurrentNameserviceDomainEnabled', () => { + it('should remove the current nameservice domain enabled status', async () => { + sessionStorage.setItem('currentNameserviceDomainEnabled', "true") + localStorageNameserviceService.removeCurrentNameserviceDomainEnabled() + expect(sessionStorage.getItem('currentNameserviceDomainEnabled')).toEqual(null); + }); + }); + +}); diff --git a/src/app/services/helpers/local-storage-nameservice/local-storage-nameservice.service.ts b/src/app/services/helpers/local-storage-nameservice/local-storage-nameservice.service.ts new file mode 100644 index 0000000..6e5061c --- /dev/null +++ b/src/app/services/helpers/local-storage-nameservice/local-storage-nameservice.service.ts @@ -0,0 +1,93 @@ +import { Injectable } from '@angular/core'; +import { ProtocolsService } from '../../mailchain/protocols/protocols.service'; +import { LocalStorageProtocolService } from '../local-storage-protocol/local-storage-protocol.service'; +import { LocalStorageServerService } from '../local-storage-server/local-storage-server.service'; + +@Injectable({ + providedIn: 'root' +}) +export class LocalStorageNameserviceService { + + constructor( + private protocolsService: ProtocolsService, + private localStorageProtocolService: LocalStorageProtocolService, + private localStorageServerService: LocalStorageServerService, + ) { } + + /** + * Gets the current nameservice address lookup enabled status. + * If no value exists, it attempts to look it up via the protocolsService. + */ + async getCurrentNameserviceAddressEnabled(){ + if (sessionStorage['currentNameserviceAddressEnabled'] && sessionStorage['currentNameserviceAddressEnabled'] != "undefined") { + return sessionStorage.getItem('currentNameserviceAddressEnabled') + } else { + let currentNetwork = this.localStorageServerService.getCurrentNetwork(); + let currentProtocol = await this.localStorageProtocolService.getCurrentProtocol(); + if (![currentProtocol,currentNetwork].includes(undefined)) { + let status = await this.protocolsService.getProtocolNetworkAttributes(currentProtocol,currentNetwork) + return this.setCurrentNameserviceAddressEnabled(status["nameservice-address-enabled"].toString()) + } else { + return this.setCurrentNameserviceAddressEnabled("false") + } + } + } + + /** + * Sets the current nameservice address lookup enabled status. + * @param status string: `true` | `false` + */ + setCurrentNameserviceAddressEnabled(status: string) { + let val = status.toString() == "true" ? "true" : "false" + sessionStorage.setItem('currentNameserviceAddressEnabled', val); + return val + } + + /** + * Removes the nameservice address lookup enabled value + */ + removeCurrentNameserviceAddressEnabled(){ + sessionStorage.removeItem('currentNameserviceAddressEnabled') + } + + + /** + * Gets the current nameservice domain lookup enabled status. + * If no value exists, it attempts to look it up via the protocolsService. + */ + async getCurrentNameserviceDomainEnabled(){ + if (sessionStorage['currentNameserviceDomainEnabled'] && sessionStorage['currentNameserviceDomainEnabled'] != "undefined") { + return sessionStorage.getItem('currentNameserviceDomainEnabled') + } else { + let currentNetwork = this.localStorageServerService.getCurrentNetwork(); + let currentProtocol = await this.localStorageProtocolService.getCurrentProtocol(); + + if (![currentProtocol,currentNetwork].includes(undefined)) { + let status = await this.protocolsService.getProtocolNetworkAttributes(currentProtocol,currentNetwork) + return this.setCurrentNameserviceDomainEnabled(status["nameservice-domain-enabled"].toString()) + } else { + return this.setCurrentNameserviceDomainEnabled("false") + } + } + } + + /** + * Sets the current nameservice domain lookup enabled status. + * @param status string: `true` | `false` + */ + setCurrentNameserviceDomainEnabled(status: string) { + let val = status.toString() == "true" ? "true" : "false" + sessionStorage.setItem('currentNameserviceDomainEnabled', val); + return val + } + + /** + * Removes the nameservice domain lookup enabled value + */ + removeCurrentNameserviceDomainEnabled(){ + sessionStorage.removeItem('currentNameserviceDomainEnabled') + } + +} + + diff --git a/src/app/services/helpers/local-storage-server/local-storage-server.service.stub.ts b/src/app/services/helpers/local-storage-server/local-storage-server.service.stub.ts index 7752207..46ce4ec 100644 --- a/src/app/services/helpers/local-storage-server/local-storage-server.service.stub.ts +++ b/src/app/services/helpers/local-storage-server/local-storage-server.service.stub.ts @@ -1,4 +1,5 @@ import { Injectable } from '@angular/core'; +import { applicationApiConfig } from 'src/environments/environment'; @Injectable({ providedIn: 'root' @@ -17,7 +18,14 @@ export class LocalStorageServerServiceStub { ) { } getCurrentNetwork() { - return this.localStorageCurrentNetwork + if (sessionStorage['currentNetwork'] && sessionStorage['currentNetwork'] != "undefined") { + return sessionStorage.getItem('currentNetwork') + } else { + var networks = applicationApiConfig.networks + var network = networks.length ? networks[0] : "" + this.setCurrentNetwork(network) + return network + } } setCurrentNetwork(network: string) { diff --git a/src/app/services/mailchain/mailchain.service.spec.ts b/src/app/services/mailchain/mailchain.service.spec.ts index 12e3039..7933fcd 100644 --- a/src/app/services/mailchain/mailchain.service.spec.ts +++ b/src/app/services/mailchain/mailchain.service.spec.ts @@ -7,10 +7,13 @@ import { Mail } from 'src/app/models/mail'; import { HttpClientModule } from '@angular/common/http'; import { NameserviceService } from './nameservice/nameservice.service'; import * as IdenticonImages from 'src/test/images.json' +import { ProtocolsService } from './protocols/protocols.service'; +import { ProtocolsServiceStub } from './protocols/protocols.service.stub'; describe('MailchainService', () => { let mailchainService: MailchainService; let nameserviceService: NameserviceService + let protocolsService: ProtocolsService; const address1 = "0x0000000000000000000000000000000000000001" const address2 = "0x0000000000000000000000000000000000000002" @@ -40,10 +43,12 @@ describe('MailchainService', () => { providers: [ MailchainService, { provide: NameserviceService, useClass: NameserviceServiceStub }, + { provide: ProtocolsService, useClass: ProtocolsServiceStub }, ] }); mailchainService = TestBed.get(MailchainService); + protocolsService = TestBed.get(ProtocolsService); }); it('should be created', () => { @@ -210,8 +215,8 @@ describe('MailchainService', () => { { "headers": { "from": address2 }, "status": "ok" }, ] - it('should handle multiple messages', () => { - let res = mailchainService.resolveSendersFromMessages("ethereum", "testnet", messages) + it('should handle multiple messages', async () => { + let res = await mailchainService.resolveSendersFromMessages("ethereum", "testnet", messages) expect(res["0x0000000000000000000000000000000000000001"]).toEqual('myname.eth') expect(res["0x0000000000000000000000000000000000000002"]).toEqual(undefined) diff --git a/src/app/services/mailchain/mailchain.service.ts b/src/app/services/mailchain/mailchain.service.ts index 6b06a28..f6875b2 100644 --- a/src/app/services/mailchain/mailchain.service.ts +++ b/src/app/services/mailchain/mailchain.service.ts @@ -5,6 +5,7 @@ import { applicationApiConfig } from 'src/environments/environment'; import { NameserviceService } from './nameservice/nameservice.service'; import { stringify } from '@angular/compiler/src/util'; import { Mail } from 'src/app/models/mail'; +import { LocalStorageNameserviceService } from '../helpers/local-storage-nameservice/local-storage-nameservice.service'; @Injectable({ providedIn: 'root' @@ -12,7 +13,8 @@ import { Mail } from 'src/app/models/mail'; export class MailchainService { constructor( - private nameserviceService: NameserviceService + private nameserviceService: NameserviceService, + private localStorageNameserviceService: LocalStorageNameserviceService ) { } /** @@ -176,7 +178,7 @@ export class MailchainService { * @param network e.g. mainnet * @param messagesArray the message array */ - resolveSendersFromMessages(protocol: string, network: string, messagesArray: { headers: { from: string; }; status: string; }[]) { + async resolveSendersFromMessages(protocol: string, network: string, messagesArray: { headers: { from: string; }; status: string; }[]) { let uniqSenders: any[] let validMsgs: any[] let output = {} @@ -189,16 +191,18 @@ export class MailchainService { } ) - uniqSenders = this.dedupeMessagesBySender(protocol, validMsgs); - - uniqSenders.forEach((address: string | number) => { - this.nameserviceService.resolveAddress(protocol, network, address).subscribe(res => { - if (res['ok']) { - output[address] = res['body']['name'] - } - }) - }); - + if (await this.localStorageNameserviceService.getCurrentNameserviceAddressEnabled() == "true") { + uniqSenders = this.dedupeMessagesBySender(protocol, validMsgs); + + await uniqSenders.forEach(async (address: string | number) => { + let obs = await this.nameserviceService.resolveAddress(protocol, network, address) + obs.subscribe(res => { + if (res['ok']) { + output[address] = res['body']['name'] + } + }) + }); + } return output } diff --git a/src/app/services/mailchain/nameservice/nameservice.service.spec.ts b/src/app/services/mailchain/nameservice/nameservice.service.spec.ts index fbb6228..351d85c 100644 --- a/src/app/services/mailchain/nameservice/nameservice.service.spec.ts +++ b/src/app/services/mailchain/nameservice/nameservice.service.spec.ts @@ -6,12 +6,16 @@ import { NameserviceService } from './nameservice.service'; import { HttpHelpersService } from '../../helpers/http-helpers/http-helpers.service'; import { MailchainTestService } from '../../../test/test-helpers/mailchain-test.service'; +import { ProtocolsService } from '../protocols/protocols.service'; +import { ProtocolsServiceStub } from '../protocols/protocols.service.stub'; describe('NameserviceService', () => { let nameserviceService: NameserviceService; let httpTestingController: HttpTestingController; - let mailchainTestService: MailchainTestService + let mailchainTestService: MailchainTestService; + let protocolsService: ProtocolsService; + let address: String = "0x0000000000000000000000000000000000000022" let protocol: String = "ethereum" @@ -27,6 +31,7 @@ describe('NameserviceService', () => { NameserviceService, HttpHelpersService, MailchainTestService, + { provide: ProtocolsService, useClass: ProtocolsServiceStub }, ], imports: [HttpClientTestingModule] }); @@ -34,6 +39,8 @@ describe('NameserviceService', () => { nameserviceService = TestBed.get(NameserviceService); httpTestingController = TestBed.get(HttpTestingController); mailchainTestService = TestBed.get(MailchainTestService); + protocolsService = TestBed.get(ProtocolsService); + }); @@ -52,28 +59,27 @@ describe('NameserviceService', () => { }); describe('resolveName', () => { - it('should add the right params to the request', () => { - + it('should add the right params to the request', async () => { let resResponse = mailchainTestService.resolveNameResponse() - let response = nameserviceService.resolveName(protocol, network, name) - + let response = await nameserviceService.resolveName(protocol, network, name) + response.subscribe() // handle open connections const req = httpTestingController.expectOne(expectedResolveNameUrlWithParams); expect(req.request.method).toBe("GET"); - + expect(req.request.params.get('protocol')).toEqual(protocol); expect(req.request.params.get('network')).toEqual(network); req.flush(resResponse); }); - it('should resolve a public address from a name', () => { + it('should resolve a public address from a name', async () => { let resResponse = mailchainTestService.resolveNameResponse() - let response = nameserviceService.resolveName(protocol, network, name) + let response = await nameserviceService.resolveName(protocol, network, name) response.subscribe(res => { expect(res['url']).toEqual(expectedResolveNameUrlWithParams) @@ -90,10 +96,10 @@ describe('NameserviceService', () => { }); describe('resolveAddress', () => { - it('should add the right params to the request', () => { + it('should add the right params to the request', async () => { let resResponse = mailchainTestService.resolveAddressResponse() - let response = nameserviceService.resolveAddress(protocol, network, address) + let response = await nameserviceService.resolveAddress(protocol, network, address) response.subscribe() @@ -108,10 +114,10 @@ describe('NameserviceService', () => { req.flush(resResponse); }); - it('should resolve a name from a public address', () => { + it('should resolve a name from a public address', async () => { let resResponse = mailchainTestService.resolveAddressResponse() - let response = nameserviceService.resolveAddress(protocol, network, address) + let response = await nameserviceService.resolveAddress(protocol, network, address) response.subscribe(res => { expect(res['url']).toEqual(expectedResolveAddressUrlWithParams) diff --git a/src/app/services/mailchain/nameservice/nameservice.service.ts b/src/app/services/mailchain/nameservice/nameservice.service.ts index f82ad0e..ab1cfb0 100644 --- a/src/app/services/mailchain/nameservice/nameservice.service.ts +++ b/src/app/services/mailchain/nameservice/nameservice.service.ts @@ -3,7 +3,8 @@ import { HttpClient } from '@angular/common/http'; import { HttpHelpersService } from '../../helpers/http-helpers/http-helpers.service'; import { LocalStorageServerService } from '../../helpers/local-storage-server/local-storage-server.service'; -import { LocalStorageProtocolService } from '../../helpers/local-storage-protocol/local-storage-protocol.service'; +import { LocalStorageNameserviceService } from '../../helpers/local-storage-nameservice/local-storage-nameservice.service'; +import { observable, Observable } from 'rxjs'; @Injectable({ providedIn: 'root' @@ -16,7 +17,7 @@ export class NameserviceService { private http: HttpClient, private httpHelpersService: HttpHelpersService, private localStorageServerService: LocalStorageServerService, - private localStorageProtocolService: LocalStorageProtocolService, + private localStorageNameserviceService: LocalStorageNameserviceService, ) { this.initUrl() } @@ -32,35 +33,44 @@ export class NameserviceService { * Get address (e.g. 0x...) from name (e.g. alice.eth). * @param name the name to lookup */ - public resolveName(protocol, network, name) { - var httpOptions = this.httpHelpersService.getHttpOptions([ - ['protocol', protocol], - ['network', network], - ]) - - return this.http.get( - this.url + `/nameservice/name/${name}/resolve`, - httpOptions - // TODO: handle failure - ); + public async resolveName(protocol, network, name) { + if (await this.localStorageNameserviceService.getCurrentNameserviceDomainEnabled() == "true") { + var httpOptions = this.httpHelpersService.getHttpOptions([ + ['protocol', protocol], + ['network', network], + ]) + + return this.http.get( + this.url + `/nameservice/name/${name}/resolve`, + httpOptions + // TODO: handle failure + ); + } else { + console.warn("resolveName", protocol, network, name); + return new Observable + }; }; /** * Get name (e.g. alice.eth) from address (e.g. 0x...). * @param address the public address */ - public resolveAddress(protocol, network, address) { - var httpOptions = this.httpHelpersService.getHttpOptions([ - ['protocol', protocol], - ['network', network], - ]) - - return this.http.get( - this.url + `/nameservice/address/${address}/resolve`, - httpOptions - // TODO: handle failure - ); + public async resolveAddress(protocol, network, address) { + if (await this.localStorageNameserviceService.getCurrentNameserviceAddressEnabled() == "true") { + var httpOptions = this.httpHelpersService.getHttpOptions([ + ['protocol', protocol], + ['network', network], + ]) + return this.http.get( + this.url + `/nameservice/address/${address}/resolve`, + httpOptions + // TODO: handle failure + ); + } else { + console.warn("resolveAddress", protocol, network, address); + return new Observable + }; } } diff --git a/src/app/services/mailchain/protocols/protocols.service.spec.ts b/src/app/services/mailchain/protocols/protocols.service.spec.ts index 7d09f2f..a41bae4 100644 --- a/src/app/services/mailchain/protocols/protocols.service.spec.ts +++ b/src/app/services/mailchain/protocols/protocols.service.spec.ts @@ -5,6 +5,7 @@ import { MailchainTestService } from 'src/app/test/test-helpers/mailchain-test.s import { ProtocolsService } from './protocols.service'; import { HttpHelpersService } from '../../helpers/http-helpers/http-helpers.service'; +import { of } from 'rxjs'; describe('ProtocolsService', () => { @@ -48,15 +49,47 @@ describe('ProtocolsService', () => { }); }); - it('should get an array of protocols and networks', () => { - protocolsService.getProtocols().subscribe(res => { - expect(res).toEqual(serverResponse) + + describe('getProtocols', () => { + it('should get an array of protocols and networks', () => { + protocolsService.getProtocols().subscribe(res => { + expect(res).toEqual(serverResponse) + }); + + // handle open connections + const req = httpTestingController.expectOne(desiredUrl); + expect(req.request.method).toBe("GET"); + req.flush(serverResponse); }); + }); - // handle open connections - const req = httpTestingController.expectOne(desiredUrl); - expect(req.request.method).toBe("GET"); - req.flush(serverResponse); + describe('getProtocolsByName', () => { + it('should get the protocols by name', async () => { + spyOn(protocolsService,'getProtocols').and.returnValue(of(mailchainTestService.protocolsServerResponse())) + expect(await protocolsService.getProtocolsByName()).toEqual(["ethereum","substrate"]) + }); + }); + + describe('getProtocolNetworkAttributes', () => { + it('should return the attributes for a protocol network', async () => { + spyOn(protocolsService,'getProtocols').and.returnValue(of(mailchainTestService.protocolsServerResponse())) + expect(await protocolsService.getProtocolNetworkAttributes("ethereum","mainnet")).toEqual( + { + "name": "mainnet", + "id": "", + "nameservice-domain-enabled": true, + "nameservice-address-enabled": true + } + ) + expect(await protocolsService.getProtocolNetworkAttributes("substrate","edgeware-mainnet")).toEqual( + { + "name": "edgeware-mainnet", + "id": "7", + "nameservice-domain-enabled": false, + "nameservice-address-enabled": false + } + ) + }); }); }); diff --git a/src/app/services/mailchain/protocols/protocols.service.stub.ts b/src/app/services/mailchain/protocols/protocols.service.stub.ts index 97556ca..236f7f2 100644 --- a/src/app/services/mailchain/protocols/protocols.service.stub.ts +++ b/src/app/services/mailchain/protocols/protocols.service.stub.ts @@ -23,6 +23,14 @@ export class ProtocolsServiceStub { return ["ethereum", "substrate"] } + async getProtocolNetworkAttributes(protocol: string, network: string) { + let res = this.mailchainTestService.protocolsServerResponse() + let attributes = {} + let p = res["protocols"].find(el => el["name"] == protocol) + attributes = p["networks"].find(nw => nw["name"] == network) + return attributes + } + public getProtocolsResponse() { return of(this.mailchainTestService.protocolsObserveResponse()) } diff --git a/src/app/services/mailchain/protocols/protocols.service.ts b/src/app/services/mailchain/protocols/protocols.service.ts index 9c5bde5..f9b8ee3 100644 --- a/src/app/services/mailchain/protocols/protocols.service.ts +++ b/src/app/services/mailchain/protocols/protocols.service.ts @@ -43,6 +43,18 @@ export class ProtocolsService { return protocols } + /** + * Helper function to get and return the protocol & network attributes + */ + async getProtocolNetworkAttributes(protocol: string, network: string) { + let attributes = {} + await this.getProtocols().toPromise().then(res => { + let p = res["protocols"].find(el => el["name"] == protocol) + attributes = p["networks"].find(nw => nw["name"] == network) + }) + return attributes + } + /** * Returns the protocols response with status codes */ diff --git a/src/app/settings/settings/settings.component.spec.ts b/src/app/settings/settings/settings.component.spec.ts index 994ae23..08ff746 100644 --- a/src/app/settings/settings/settings.component.spec.ts +++ b/src/app/settings/settings/settings.component.spec.ts @@ -167,7 +167,8 @@ describe('SettingsComponent', () => { component.networks = [] await component.setCurrentNetwork() - expect(component.currentNetwork).toBe(undefined) + // expect(component.currentNetwork).toBe(undefined) // this is not undefined while applicationApiConfig is in use by localstorage (see https://github.com/mailchain/mailchain-web/issues/217) + expect(component.currentNetwork).toBe('mainnet') }); }); @@ -275,7 +276,8 @@ describe('SettingsComponent', () => { component.currentProtocol = 'substrate' await component.setNetworkList() expect(component.networks).toEqual([ - { label: "edgeware-berlin", value: "edgeware-berlin" }, + { label: "edgeware-beresheet", value: "edgeware-beresheet" }, + { label: "edgeware-local", value: "edgeware-local" }, { label: "edgeware-mainnet", value: "edgeware-mainnet" }, ]) diff --git a/src/app/test/test-helpers/mailchain-test.service.ts b/src/app/test/test-helpers/mailchain-test.service.ts index 65870c8..cc85840 100644 --- a/src/app/test/test-helpers/mailchain-test.service.ts +++ b/src/app/test/test-helpers/mailchain-test.service.ts @@ -313,7 +313,7 @@ export class MailchainTestService { } public protocolsServerResponse(): any { - return { "protocols": [{ "name": "ethereum", "networks": [{ "name": "goerli", "id": "" }, { "name": "kovan", "id": "" }, { "name": "mainnet", "id": "" }, { "name": "rinkeby", "id": "" }, { "name": "ropsten", "id": "" }] }, { "name": "substrate", "networks": [{ "name": "edgeware-berlin", "id": "7" }, { "name": "edgeware-mainnet", "id": "7" }] }] } + return {"protocols":[{"name":"ethereum","networks":[{"name":"goerli","id":"","nameservice-domain-enabled":true,"nameservice-address-enabled":true},{"name":"kovan","id":"","nameservice-domain-enabled":true,"nameservice-address-enabled":true},{"name":"mainnet","id":"","nameservice-domain-enabled":true,"nameservice-address-enabled":true},{"name":"rinkeby","id":"","nameservice-domain-enabled":true,"nameservice-address-enabled":true},{"name":"ropsten","id":"","nameservice-domain-enabled":true,"nameservice-address-enabled":true}]},{"name":"substrate","networks":[{"name":"edgeware-beresheet","id":"7","nameservice-domain-enabled":false,"nameservice-address-enabled":false},{"name":"edgeware-local","id":"7","nameservice-domain-enabled":false,"nameservice-address-enabled":false},{"name":"edgeware-mainnet","id":"7","nameservice-domain-enabled":false,"nameservice-address-enabled":false}]}]} } diff --git a/src/test.ts b/src/test.ts index 1631789..1900f62 100644 --- a/src/test.ts +++ b/src/test.ts @@ -18,3 +18,7 @@ getTestBed().initTestEnvironment( const context = require.context('./', true, /\.spec\.ts$/); // And load the modules. context.keys().map(context); + +beforeEach(function() { + sessionStorage.clear(); +}); \ No newline at end of file