From fd4ee2123dc72b4d8755504d57bced608c1ab928 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karol=20S=C3=B3jko?= Date: Wed, 6 Jul 2022 12:02:32 +0200 Subject: [PATCH] feat: add common package --- .pnp.cjs | 52 ++-- ...ommon-npm-1.23.1-ed73dbb679-f498f4c469.zip | Bin 24774 -> 0 bytes packages/auth/package.json | 2 +- packages/common/.eslintignore | 1 + packages/common/.eslintrc | 6 + packages/common/CHANGELOG.md | 258 ++++++++++++++++++ packages/common/jest.config.js | 19 ++ packages/common/linter.tsconfig.json | 4 + packages/common/package.json | 39 +++ .../src/Domain/Content/ContentDecoder.spec.ts | 37 +++ .../src/Domain/Content/ContentDecoder.ts | 23 ++ .../Domain/Content/ContentDecoderInterface.ts | 4 + .../common/src/Domain/Content/ContentType.ts | 44 +++ .../common/src/Domain/DataType/AnyRecord.ts | 2 + .../Domain/DataType/ApplicationIdentifier.ts | 1 + .../Domain/DataType/MicrosecondsTimestamp.ts | 1 + packages/common/src/Domain/DataType/Uuid.ts | 1 + .../Domain/Email/EmailMessageIdentifier.ts | 18 ++ packages/common/src/Domain/Error/ErrorTag.ts | 12 + .../Domain/KeyParams/AnyKeyParamsContent.ts | 6 + .../src/Domain/KeyParams/BaseKeyParams.ts | 10 + .../Domain/KeyParams/KeyParamsContent001.ts | 8 + .../Domain/KeyParams/KeyParamsContent002.ts | 8 + .../Domain/KeyParams/KeyParamsContent003.ts | 6 + .../Domain/KeyParams/KeyParamsContent004.ts | 6 + .../Domain/KeyParams/KeyParamsOrigination.ts | 8 + .../src/Domain/Protocol/ProtocolVersion.ts | 56 ++++ packages/common/src/Domain/Role/PaidRoles.ts | 4 + packages/common/src/Domain/Role/RoleName.ts | 7 + .../Domain/Subscription/SubscriptionName.ts | 5 + packages/common/src/Domain/index.ts | 20 ++ packages/common/src/index.ts | 1 + packages/common/tsconfig.json | 11 + packages/domain-events/package.json | 2 +- packages/files/package.json | 2 +- packages/predicates/package.json | 2 +- packages/scheduler/package.json | 2 +- packages/security/package.json | 2 +- packages/syncing-server/package.json | 2 +- tsconfig.json | 3 + yarn.lock | 33 ++- 41 files changed, 688 insertions(+), 40 deletions(-) delete mode 100644 .yarn/cache/@standardnotes-common-npm-1.23.1-ed73dbb679-f498f4c469.zip create mode 100644 packages/common/.eslintignore create mode 100644 packages/common/.eslintrc create mode 100644 packages/common/CHANGELOG.md create mode 100644 packages/common/jest.config.js create mode 100644 packages/common/linter.tsconfig.json create mode 100644 packages/common/package.json create mode 100644 packages/common/src/Domain/Content/ContentDecoder.spec.ts create mode 100644 packages/common/src/Domain/Content/ContentDecoder.ts create mode 100644 packages/common/src/Domain/Content/ContentDecoderInterface.ts create mode 100644 packages/common/src/Domain/Content/ContentType.ts create mode 100644 packages/common/src/Domain/DataType/AnyRecord.ts create mode 100644 packages/common/src/Domain/DataType/ApplicationIdentifier.ts create mode 100644 packages/common/src/Domain/DataType/MicrosecondsTimestamp.ts create mode 100644 packages/common/src/Domain/DataType/Uuid.ts create mode 100644 packages/common/src/Domain/Email/EmailMessageIdentifier.ts create mode 100644 packages/common/src/Domain/Error/ErrorTag.ts create mode 100644 packages/common/src/Domain/KeyParams/AnyKeyParamsContent.ts create mode 100644 packages/common/src/Domain/KeyParams/BaseKeyParams.ts create mode 100644 packages/common/src/Domain/KeyParams/KeyParamsContent001.ts create mode 100644 packages/common/src/Domain/KeyParams/KeyParamsContent002.ts create mode 100644 packages/common/src/Domain/KeyParams/KeyParamsContent003.ts create mode 100644 packages/common/src/Domain/KeyParams/KeyParamsContent004.ts create mode 100644 packages/common/src/Domain/KeyParams/KeyParamsOrigination.ts create mode 100644 packages/common/src/Domain/Protocol/ProtocolVersion.ts create mode 100644 packages/common/src/Domain/Role/PaidRoles.ts create mode 100644 packages/common/src/Domain/Role/RoleName.ts create mode 100644 packages/common/src/Domain/Subscription/SubscriptionName.ts create mode 100644 packages/common/src/Domain/index.ts create mode 100644 packages/common/src/index.ts create mode 100644 packages/common/tsconfig.json diff --git a/.pnp.cjs b/.pnp.cjs index faa7910ef..22cb1cb30 100755 --- a/.pnp.cjs +++ b/.pnp.cjs @@ -32,6 +32,10 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { "name": "@standardnotes/auth-server",\ "reference": "workspace:packages/auth"\ },\ + {\ + "name": "@standardnotes/common",\ + "reference": "workspace:packages/common"\ + },\ {\ "name": "@standardnotes/domain-events",\ "reference": "workspace:packages/domain-events"\ @@ -71,6 +75,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["@standardnotes/analytics", ["workspace:packages/analytics"]],\ ["@standardnotes/api-gateway", ["workspace:packages/api-gateway"]],\ ["@standardnotes/auth-server", ["workspace:packages/auth"]],\ + ["@standardnotes/common", ["workspace:packages/common"]],\ ["@standardnotes/domain-events", ["workspace:packages/domain-events"]],\ ["@standardnotes/domain-events-infra", ["workspace:packages/domain-events-infra"]],\ ["@standardnotes/files-server", ["workspace:packages/files"]],\ @@ -2667,7 +2672,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { "packageDependencies": [\ ["@standardnotes/api", "npm:1.1.19"],\ ["@standardnotes/auth", "npm:3.19.4"],\ - ["@standardnotes/common", "npm:1.23.1"],\ + ["@standardnotes/common", "workspace:packages/common"],\ ["@standardnotes/encryption", "npm:1.12.0"],\ ["@standardnotes/responses", "npm:1.6.39"],\ ["@standardnotes/services", "npm:1.15.0"],\ @@ -2725,7 +2730,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { "packageLocation": "./.yarn/cache/@standardnotes-auth-npm-3.19.4-29b35c1352-84ac9e669e.zip/node_modules/@standardnotes/auth/",\ "packageDependencies": [\ ["@standardnotes/auth", "npm:3.19.4"],\ - ["@standardnotes/common", "npm:1.23.1"],\ + ["@standardnotes/common", "workspace:packages/common"],\ ["jsonwebtoken", "npm:8.5.1"]\ ],\ "linkType": "HARD"\ @@ -2740,7 +2745,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["@sentry/node", "npm:7.5.0"],\ ["@standardnotes/analytics", "workspace:packages/analytics"],\ ["@standardnotes/api", "npm:1.1.19"],\ - ["@standardnotes/common", "npm:1.23.1"],\ + ["@standardnotes/common", "workspace:packages/common"],\ ["@standardnotes/domain-events", "workspace:packages/domain-events"],\ ["@standardnotes/domain-events-infra", "workspace:packages/domain-events-infra"],\ ["@standardnotes/features", "npm:1.50.0"],\ @@ -2793,12 +2798,19 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { }]\ ]],\ ["@standardnotes/common", [\ - ["npm:1.23.1", {\ - "packageLocation": "./.yarn/cache/@standardnotes-common-npm-1.23.1-ed73dbb679-f498f4c469.zip/node_modules/@standardnotes/common/",\ + ["workspace:packages/common", {\ + "packageLocation": "./packages/common/",\ "packageDependencies": [\ - ["@standardnotes/common", "npm:1.23.1"]\ + ["@standardnotes/common", "workspace:packages/common"],\ + ["@types/jest", "npm:27.5.2"],\ + ["@types/node", "npm:18.0.3"],\ + ["@typescript-eslint/eslint-plugin", "virtual:c66bf20e88479ada0172094776519a9f51acc4731d22079b60a295bcec7ea42d5545cbce58a77a50d932bf953298799135e99707486e343da6d99ba1d167bdbd#npm:5.30.5"],\ + ["eslint-plugin-prettier", "virtual:c66bf20e88479ada0172094776519a9f51acc4731d22079b60a295bcec7ea42d5545cbce58a77a50d932bf953298799135e99707486e343da6d99ba1d167bdbd#npm:4.2.1"],\ + ["jest", "virtual:c66bf20e88479ada0172094776519a9f51acc4731d22079b60a295bcec7ea42d5545cbce58a77a50d932bf953298799135e99707486e343da6d99ba1d167bdbd#npm:27.5.1"],\ + ["reflect-metadata", "npm:0.1.13"],\ + ["ts-jest", "virtual:c66bf20e88479ada0172094776519a9f51acc4731d22079b60a295bcec7ea42d5545cbce58a77a50d932bf953298799135e99707486e343da6d99ba1d167bdbd#npm:27.1.5"]\ ],\ - "linkType": "HARD"\ + "linkType": "SOFT"\ }]\ ]],\ ["@standardnotes/config", [\ @@ -2820,7 +2832,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { "packageLocation": "./packages/domain-events/",\ "packageDependencies": [\ ["@standardnotes/domain-events", "workspace:packages/domain-events"],\ - ["@standardnotes/common", "npm:1.23.1"],\ + ["@standardnotes/common", "workspace:packages/common"],\ ["@standardnotes/features", "npm:1.50.0"],\ ["@standardnotes/predicates", "workspace:packages/predicates"],\ ["@standardnotes/security", "workspace:packages/security"],\ @@ -2862,7 +2874,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { "packageLocation": "./.yarn/cache/@standardnotes-encryption-npm-1.12.0-eb2342c675-1a28653b1e.zip/node_modules/@standardnotes/encryption/",\ "packageDependencies": [\ ["@standardnotes/encryption", "npm:1.12.0"],\ - ["@standardnotes/common", "npm:1.23.1"],\ + ["@standardnotes/common", "workspace:packages/common"],\ ["@standardnotes/models", "npm:1.14.0"],\ ["@standardnotes/responses", "npm:1.6.39"],\ ["@standardnotes/services", "npm:1.15.0"],\ @@ -2879,7 +2891,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { "packageDependencies": [\ ["@standardnotes/features", "npm:1.50.0"],\ ["@standardnotes/auth", "npm:3.19.4"],\ - ["@standardnotes/common", "npm:1.23.1"],\ + ["@standardnotes/common", "workspace:packages/common"],\ ["reflect-metadata", "npm:0.1.13"]\ ],\ "linkType": "HARD"\ @@ -2891,7 +2903,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { "packageDependencies": [\ ["@standardnotes/files-server", "workspace:packages/files"],\ ["@sentry/node", "npm:7.5.0"],\ - ["@standardnotes/common", "npm:1.23.1"],\ + ["@standardnotes/common", "workspace:packages/common"],\ ["@standardnotes/config", "npm:2.4.3"],\ ["@standardnotes/domain-events", "workspace:packages/domain-events"],\ ["@standardnotes/domain-events-infra", "workspace:packages/domain-events-infra"],\ @@ -2942,7 +2954,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { "packageLocation": "./.yarn/cache/@standardnotes-models-npm-1.14.0-6f064d99e7-bfb9d517b6.zip/node_modules/@standardnotes/models/",\ "packageDependencies": [\ ["@standardnotes/models", "npm:1.14.0"],\ - ["@standardnotes/common", "npm:1.23.1"],\ + ["@standardnotes/common", "workspace:packages/common"],\ ["@standardnotes/features", "npm:1.50.0"],\ ["@standardnotes/responses", "npm:1.6.39"],\ ["@standardnotes/utils", "npm:1.6.12"],\ @@ -2957,7 +2969,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { "packageLocation": "./.yarn/cache/@standardnotes-payloads-npm-1.5.1-45dffe2f5c-65c28421e7.zip/node_modules/@standardnotes/payloads/",\ "packageDependencies": [\ ["@standardnotes/payloads", "npm:1.5.1"],\ - ["@standardnotes/common", "npm:1.23.1"],\ + ["@standardnotes/common", "workspace:packages/common"],\ ["@standardnotes/features", "npm:1.50.0"],\ ["@standardnotes/utils", "npm:1.6.12"]\ ],\ @@ -2969,7 +2981,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { "packageLocation": "./packages/predicates/",\ "packageDependencies": [\ ["@standardnotes/predicates", "workspace:packages/predicates"],\ - ["@standardnotes/common", "npm:1.23.1"],\ + ["@standardnotes/common", "workspace:packages/common"],\ ["@types/jest", "npm:27.5.2"],\ ["@typescript-eslint/eslint-plugin", "virtual:c66bf20e88479ada0172094776519a9f51acc4731d22079b60a295bcec7ea42d5545cbce58a77a50d932bf953298799135e99707486e343da6d99ba1d167bdbd#npm:5.30.5"],\ ["eslint-plugin-prettier", "virtual:c66bf20e88479ada0172094776519a9f51acc4731d22079b60a295bcec7ea42d5545cbce58a77a50d932bf953298799135e99707486e343da6d99ba1d167bdbd#npm:4.2.1"],\ @@ -2986,7 +2998,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { "packageDependencies": [\ ["@standardnotes/responses", "npm:1.6.39"],\ ["@standardnotes/auth", "npm:3.19.4"],\ - ["@standardnotes/common", "npm:1.23.1"],\ + ["@standardnotes/common", "workspace:packages/common"],\ ["@standardnotes/features", "npm:1.50.0"]\ ],\ "linkType": "HARD"\ @@ -2999,7 +3011,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["@standardnotes/scheduler-server", "workspace:packages/scheduler"],\ ["@newrelic/winston-enricher", "virtual:04783e12400851b8a3d76e71495851cc94959db6e62f04cb0a31190080629440b182d8c8eb4d7f2b04e281912f2783a5fd4d2c3c6ab68d38b7097246c93f4c19#npm:2.1.2"],\ ["@sentry/node", "npm:7.5.0"],\ - ["@standardnotes/common", "npm:1.23.1"],\ + ["@standardnotes/common", "workspace:packages/common"],\ ["@standardnotes/domain-events", "workspace:packages/domain-events"],\ ["@standardnotes/domain-events-infra", "workspace:packages/domain-events-infra"],\ ["@standardnotes/predicates", "workspace:packages/predicates"],\ @@ -3032,7 +3044,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { "packageLocation": "./packages/security/",\ "packageDependencies": [\ ["@standardnotes/security", "workspace:packages/security"],\ - ["@standardnotes/common", "npm:1.23.1"],\ + ["@standardnotes/common", "workspace:packages/common"],\ ["@types/jest", "npm:27.5.2"],\ ["@types/jsonwebtoken", "npm:8.5.8"],\ ["@typescript-eslint/eslint-plugin", "virtual:c66bf20e88479ada0172094776519a9f51acc4731d22079b60a295bcec7ea42d5545cbce58a77a50d932bf953298799135e99707486e343da6d99ba1d167bdbd#npm:5.30.5"],\ @@ -3078,7 +3090,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { "packageDependencies": [\ ["@standardnotes/services", "npm:1.15.0"],\ ["@standardnotes/auth", "npm:3.19.4"],\ - ["@standardnotes/common", "npm:1.23.1"],\ + ["@standardnotes/common", "workspace:packages/common"],\ ["@standardnotes/models", "npm:1.14.0"],\ ["@standardnotes/responses", "npm:1.6.39"],\ ["@standardnotes/utils", "npm:1.6.12"],\ @@ -3123,7 +3135,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["@newrelic/winston-enricher", "virtual:04783e12400851b8a3d76e71495851cc94959db6e62f04cb0a31190080629440b182d8c8eb4d7f2b04e281912f2783a5fd4d2c3c6ab68d38b7097246c93f4c19#npm:2.1.2"],\ ["@sentry/node", "npm:7.5.0"],\ ["@standardnotes/analytics", "workspace:packages/analytics"],\ - ["@standardnotes/common", "npm:1.23.1"],\ + ["@standardnotes/common", "workspace:packages/common"],\ ["@standardnotes/domain-events", "workspace:packages/domain-events"],\ ["@standardnotes/domain-events-infra", "workspace:packages/domain-events-infra"],\ ["@standardnotes/payloads", "npm:1.5.1"],\ @@ -3194,7 +3206,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { "packageLocation": "./.yarn/cache/@standardnotes-utils-npm-1.6.12-8fa8d7d09b-e177b1fa51.zip/node_modules/@standardnotes/utils/",\ "packageDependencies": [\ ["@standardnotes/utils", "npm:1.6.12"],\ - ["@standardnotes/common", "npm:1.23.1"],\ + ["@standardnotes/common", "workspace:packages/common"],\ ["dompurify", "npm:2.3.8"],\ ["lodash", "npm:4.17.21"]\ ],\ diff --git a/.yarn/cache/@standardnotes-common-npm-1.23.1-ed73dbb679-f498f4c469.zip b/.yarn/cache/@standardnotes-common-npm-1.23.1-ed73dbb679-f498f4c469.zip deleted file mode 100644 index 507ef2442d5348286e80222847a9f36af6fa8f70..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 24774 zcmdUX1yq$;8!lbaQW6rQMyYIq`OO`TN;r@1Oe%gP#W$*#WSAY znL9W$cdh%)`rzQee%{*g)>f2(hQWfkcm#_^5x#!-{sjg2-P*o^9bKpa4{dGi z9UbUN$nM_Asxvb-1K9t+BVFq1r2jBB zCSiRCz>lB)3z~nudU0Nz=I`_3`!WFqf$()n{Fp(3rvwQBVG9ibA^H1*eji*EXmv(k zbr%yUr_job?7wx2tMmh;n zB|s6jbPP*eL7dI}vA7u)=DX(p1*EJ}s-QM)ybQFP!>RJTq<0y8q1f(`OMi4d4Rq~G z#CITKZ|~HbeBj)f^N2x2v~^4VWbmqS#9xK4L@ck4SPG(NsxyU4Gg(B*$e+xe&=-N58c7hJ!RH4Q(}A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nF)BDeKc6Fof%)PqqJg3mU_62M)q!}5|0gK_ z(`5&4so;G|Al#;#SLW_#U;VE|$#;na{JtRsNpfYdKf2Js4xgWQDexYjORx+toqve* zN7(NjKYum7KR_6{@|qiN{Zk~ZxH<9zYG5@1rBaB;E8Au z`~v^K%Kf*rG&nqXq8J3<3M>Nt7lr>VZ43?%p1uXa7XVK${~Z30&I(BRAlnAdpMvo7 z1+R?%V^jRKy8^-o**yPK|U#HK$!Gr7yJmUp|R{~yzdqwykcJ(9wr6>an VjL!mVSAqXc1O3jo7x(Kz{2x^aXGs76 diff --git a/packages/auth/package.json b/packages/auth/package.json index 9388a2238..9c7de6346 100644 --- a/packages/auth/package.json +++ b/packages/auth/package.json @@ -35,7 +35,7 @@ "@sentry/node": "^7.3.0", "@standardnotes/analytics": "workspace:*", "@standardnotes/api": "^1.1.19", - "@standardnotes/common": "^1.23.1", + "@standardnotes/common": "workspace:*", "@standardnotes/domain-events": "workspace:*", "@standardnotes/domain-events-infra": "workspace:*", "@standardnotes/features": "^1.47.0", diff --git a/packages/common/.eslintignore b/packages/common/.eslintignore new file mode 100644 index 000000000..1521c8b76 --- /dev/null +++ b/packages/common/.eslintignore @@ -0,0 +1 @@ +dist diff --git a/packages/common/.eslintrc b/packages/common/.eslintrc new file mode 100644 index 000000000..cb7136174 --- /dev/null +++ b/packages/common/.eslintrc @@ -0,0 +1,6 @@ +{ + "extends": "../../.eslintrc", + "parserOptions": { + "project": "./linter.tsconfig.json" + } +} diff --git a/packages/common/CHANGELOG.md b/packages/common/CHANGELOG.md new file mode 100644 index 000000000..96006c25f --- /dev/null +++ b/packages/common/CHANGELOG.md @@ -0,0 +1,258 @@ +# Change Log + +All notable changes to this project will be documented in this file. +See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. + +## [1.23.2](https://github.com/standardnotes/snjs/compare/@standardnotes/common@1.23.1...@standardnotes/common@1.23.2) (2022-07-04) + +### Bug Fixes + +* add missing reflect-metadata package ([70aa494](https://github.com/standardnotes/snjs/commit/70aa4943a3fde70d4360055db22cb5388fc3f76e)) + +## [1.23.1](https://github.com/standardnotes/snjs/compare/@standardnotes/common@1.23.0...@standardnotes/common@1.23.1) (2022-06-27) + +### Bug Fixes + +* add email message identifier for files email campaign ([affa300](https://github.com/standardnotes/snjs/commit/affa3005b6933165e262227282198310f0a65cb3)) + +# [1.23.0](https://github.com/standardnotes/snjs/compare/@standardnotes/common@1.22.0...@standardnotes/common@1.23.0) (2022-06-15) + +### Features + +* add email requested events ([4d501fa](https://github.com/standardnotes/snjs/commit/4d501faedad44ff23782db1704956a6c19365fb6)) + +# [1.22.0](https://github.com/standardnotes/snjs/compare/@standardnotes/common@1.21.0...@standardnotes/common@1.22.0) (2022-05-22) + +### Features + +* optional files navigation ([#745](https://github.com/standardnotes/snjs/issues/745)) ([8512166](https://github.com/standardnotes/snjs/commit/851216615478b57b11a570173f94ee598bec31c0)) + +# [1.21.0](https://github.com/standardnotes/snjs/compare/@standardnotes/common@1.20.1...@standardnotes/common@1.21.0) (2022-05-17) + +### Features + +* remove basic user role and core subscription plan ([#741](https://github.com/standardnotes/snjs/issues/741)) ([7800ecd](https://github.com/standardnotes/snjs/commit/7800ecd119e7bbb5872d48bd7806b5d0f5522c0e)) + +## [1.20.1](https://github.com/standardnotes/snjs/compare/@standardnotes/common@1.20.0...@standardnotes/common@1.20.1) (2022-05-16) + +**Note:** Version bump only for package @standardnotes/common + +# [1.20.0](https://github.com/standardnotes/snjs/compare/@standardnotes/common@1.19.8...@standardnotes/common@1.20.0) (2022-05-16) + +### Features + +* remove basic user role and core subscription plan names ([304e232](https://github.com/standardnotes/snjs/commit/304e232e738456a93374de869117b5579e8a8f57)) + +## [1.19.8](https://github.com/standardnotes/snjs/compare/@standardnotes/common@1.19.6...@standardnotes/common@1.19.8) (2022-05-04) + +**Note:** Version bump only for package @standardnotes/common + +## [1.19.7](https://github.com/standardnotes/snjs/compare/@standardnotes/common@1.19.6...@standardnotes/common@1.19.7) (2022-05-04) + +**Note:** Version bump only for package @standardnotes/common + +## [1.19.6](https://github.com/standardnotes/snjs/compare/@standardnotes/common@1.19.5...@standardnotes/common@1.19.6) (2022-04-22) + +**Note:** Version bump only for package @standardnotes/common + +## [1.19.5](https://github.com/standardnotes/snjs/compare/@standardnotes/common@1.19.4...@standardnotes/common@1.19.5) (2022-04-21) + +### Bug Fixes + +* abort key recovery after aborted challenge ([#703](https://github.com/standardnotes/snjs/issues/703)) ([a67fb7e](https://github.com/standardnotes/snjs/commit/a67fb7e8cde41a5c9fadf545933e35d525faeaf0)) + +## [1.19.4](https://github.com/standardnotes/snjs/compare/@standardnotes/common@1.19.3...@standardnotes/common@1.19.4) (2022-04-15) + +**Note:** Version bump only for package @standardnotes/common + +## [1.19.3](https://github.com/standardnotes/snjs/compare/@standardnotes/common@1.19.2...@standardnotes/common@1.19.3) (2022-04-11) + +**Note:** Version bump only for package @standardnotes/common + +## [1.19.2](https://github.com/standardnotes/snjs/compare/@standardnotes/common@1.19.1...@standardnotes/common@1.19.2) (2022-04-01) + +**Note:** Version bump only for package @standardnotes/common + +## [1.19.1](https://github.com/standardnotes/snjs/compare/@standardnotes/common@1.19.0...@standardnotes/common@1.19.1) (2022-03-31) + +**Note:** Version bump only for package @standardnotes/common + +# [1.19.0](https://github.com/standardnotes/snjs/compare/@standardnotes/common@1.18.0...@standardnotes/common@1.19.0) (2022-03-31) + +### Features + +* encryption and models packages ([#679](https://github.com/standardnotes/snjs/issues/679)) ([5e03d48](https://github.com/standardnotes/snjs/commit/5e03d48aba7e3dd266117201139ab869b1f70cc9)) + +# [1.18.0](https://github.com/standardnotes/snjs/compare/@standardnotes/common@1.17.0...@standardnotes/common@1.18.0) (2022-03-30) + +### Features + +* files-beta role ([#678](https://github.com/standardnotes/snjs/issues/678)) ([f1ae62f](https://github.com/standardnotes/snjs/commit/f1ae62ff05e361dc551f1a0d047feabd129d0f76)) + +# [1.17.0](https://github.com/standardnotes/snjs/compare/@standardnotes/common@1.16.2...@standardnotes/common@1.17.0) (2022-03-22) + +### Features + +* add read only access error tag ([c3c7b4c](https://github.com/standardnotes/snjs/commit/c3c7b4c12f9b23dfc8e4bf1d4af43f6307f64190)) + +## [1.16.2](https://github.com/standardnotes/snjs/compare/@standardnotes/common@1.16.1...@standardnotes/common@1.16.2) (2022-03-21) + +**Note:** Version bump only for package @standardnotes/common + +## [1.16.1](https://github.com/standardnotes/snjs/compare/@standardnotes/common@1.16.0...@standardnotes/common@1.16.1) (2022-03-18) + +### Bug Fixes + +* add demo user role ([aa7ebc8](https://github.com/standardnotes/snjs/commit/aa7ebc84ef1160688d2767b86a32719ce68a257b)) + +# [1.16.0](https://github.com/standardnotes/snjs/compare/@standardnotes/common@1.15.3...@standardnotes/common@1.16.0) (2022-03-16) + +### Features + +* delete file functionality ([#657](https://github.com/standardnotes/snjs/issues/657)) ([edec4f7](https://github.com/standardnotes/snjs/commit/edec4f7a65ef557ed5f47be4dddcf2b659ee28b4)) + +## [1.15.4](https://github.com/standardnotes/snjs/compare/@standardnotes/common@1.15.3...@standardnotes/common@1.15.4) (2022-03-16) + +**Note:** Version bump only for package @standardnotes/common + +## [1.15.3](https://github.com/standardnotes/snjs/compare/@standardnotes/common@1.15.1...@standardnotes/common@1.15.3) (2022-02-28) + +### Bug Fixes + +* add pseudo change to get lerna to trigger ([41e6817](https://github.com/standardnotes/snjs/commit/41e6817bbf726b0932cdf16f58622328b9e42803)) + +## [1.15.2](https://github.com/standardnotes/snjs/compare/@standardnotes/common@1.15.1...@standardnotes/common@1.15.2) (2022-02-28) + +### Bug Fixes + +* add pseudo change to get lerna to trigger ([41e6817](https://github.com/standardnotes/snjs/commit/41e6817bbf726b0932cdf16f58622328b9e42803)) + +## [1.15.1](https://github.com/standardnotes/snjs/compare/@standardnotes/common@1.15.0...@standardnotes/common@1.15.1) (2022-02-27) + +**Note:** Version bump only for package @standardnotes/common + +# [1.15.0](https://github.com/standardnotes/snjs/compare/@standardnotes/common@1.14.1...@standardnotes/common@1.15.0) (2022-02-25) + +### Features + +* extract core functionalities to separate packages ([#610](https://github.com/standardnotes/snjs/issues/610)) ([801547a](https://github.com/standardnotes/snjs/commit/801547a71614ad51a92fb249eaa184ed46a44aac)) + +## [1.14.1](https://github.com/standardnotes/snjs/compare/@standardnotes/common@1.14.0...@standardnotes/common@1.14.1) (2022-02-24) + +**Note:** Version bump only for package @standardnotes/common + +# [1.14.0](https://github.com/standardnotes/snjs/compare/@standardnotes/common@1.13.0...@standardnotes/common@1.14.0) (2022-02-22) + +### Features + +* extract services package ([#605](https://github.com/standardnotes/snjs/issues/605)) ([3966b10](https://github.com/standardnotes/snjs/commit/3966b10745c10ef5bb92871abb13ceb4ea631362)) + +# [1.13.0](https://github.com/standardnotes/snjs/compare/@standardnotes/common@1.12.0...@standardnotes/common@1.13.0) (2022-02-22) + +### Features + +* extract SNJS utils as a separate package ([#604](https://github.com/standardnotes/snjs/issues/604)) ([b28195c](https://github.com/standardnotes/snjs/commit/b28195c20be788eec8dabc44c5aff518f074cdd9)) + +# [1.12.0](https://github.com/standardnotes/snjs/compare/@standardnotes/common@1.11.0...@standardnotes/common@1.12.0) (2022-02-18) + +### Features + +* add item integrity hash model ([975474a](https://github.com/standardnotes/snjs/commit/975474a04c4b11edea381235fe38273db59fa770)) + +# [1.11.0](https://github.com/standardnotes/snjs/compare/@standardnotes/common@1.10.0...@standardnotes/common@1.11.0) (2022-02-16) + +### Features + +* add paid roles definition ([3432608](https://github.com/standardnotes/snjs/commit/34326086c16000397d994054e807dd3589b536db)) + +# [1.10.0](https://github.com/standardnotes/snjs/compare/@standardnotes/common@1.9.0...@standardnotes/common@1.10.0) (2022-02-10) + +### Features + +* move role names and suscription names from auth to common package ([5358c03](https://github.com/standardnotes/snjs/commit/5358c03ef113597bcdcf7b0f3e730c8014885a0f)) + +# [1.9.0](https://github.com/standardnotes/snjs/compare/@standardnotes/common@1.8.0...@standardnotes/common@1.9.0) (2022-02-07) + +### Features + +* dynamic features based on runtime env ([#590](https://github.com/standardnotes/snjs/issues/590)) ([060861a](https://github.com/standardnotes/snjs/commit/060861a6c5bc179e3e1987c2b63490888e153bbb)) + +# [1.8.0](https://github.com/standardnotes/snjs/compare/@standardnotes/common@1.7.0...@standardnotes/common@1.8.0) (2022-01-15) + +### Bug Fixes + +* correct gitignore paths ([cefc0cf](https://github.com/standardnotes/snjs/commit/cefc0cfcf98e3e5378e055b8c46931b53b23195e)) +* include dist in static components ([d17ce0f](https://github.com/standardnotes/snjs/commit/d17ce0f67045c6e4c97bf4577709aa58794e72e6)) + +### Features + +* remove server extension type ([#552](https://github.com/standardnotes/snjs/issues/552)) ([aa542f3](https://github.com/standardnotes/snjs/commit/aa542f3124c60fa81a0b271030b3c35415c54a62)) + +# 1.7.0 (2021-12-23) + +### Features + +* rename email backup setting to email backup frequency ([25e7b46](https://github.com/standardnotes/snjs/commit/25e7b4620834711ac7f513ae893898c5eab1af53)) + +## 1.6.3 (2021-12-23) + +### Bug Fixes + +* lock package versions ([8aa2ce6](https://github.com/standardnotes/snjs/commit/8aa2ce676b57598ab72840adf851869d8e769022)) + +## 1.6.2 (2021-12-23) + +### Bug Fixes + +* add publishing from package version by lerna ([80433d0](https://github.com/standardnotes/snjs/commit/80433d044f258095753482b8322d73aba3d9a9e4)) + +## 1.6.1 (2021-12-23) + +### Bug Fixes + +* remove the ammend commit from lerna versioning ([f0400d9](https://github.com/standardnotes/snjs/commit/f0400d9a2f5a04eaece2e4c16da71166a2ddb251)) + +# 1.6.0 (2021-12-23) + +### Features + +* add one drive backup frequency setting ([#522](https://github.com/standardnotes/snjs/issues/522)) ([c27827f](https://github.com/standardnotes/snjs/commit/c27827f8c7969dd32511c9c75122ece372132c83)) + +## 1.5.4 (2021-12-23) + +### Bug Fixes + +* remove running tests upon deployment - ensured on PR status checks ([#523](https://github.com/standardnotes/snjs/issues/523)) ([5c795d1](https://github.com/standardnotes/snjs/commit/5c795d17b583d02955773576384e622c3ef7f418)) + +## 1.5.3 (2021-12-23) + +### Bug Fixes + +* pr template ([#518](https://github.com/standardnotes/snjs/issues/518)) ([b445bb6](https://github.com/standardnotes/snjs/commit/b445bb64841217ae27c2514887629235be95d2a3)) + +## 1.5.2 (2021-12-23) + +### Bug Fixes + +* checkout with personal access token ([773c1ef](https://github.com/standardnotes/snjs/commit/773c1ef91c4452ad411e928342060dcb59428e3c)) + +## 1.5.1 (2021-12-22) + +### Bug Fixes + +* gpg signing with CI StandardNotes user ([d72f61c](https://github.com/standardnotes/snjs/commit/d72f61c23cd15b31d37340cc756d16526634b9ee)) + +# 1.5.0 (2021-12-22) + +### Bug Fixes + +* versioning and package dependencies ([#509](https://github.com/standardnotes/snjs/issues/509)) ([fe1df94](https://github.com/standardnotes/snjs/commit/fe1df94eff3e90bcf9ba0cf45bdc44ac49204c71)) + +### Features + +* add content decoder to common package ([504cf10](https://github.com/standardnotes/snjs/commit/504cf10d83c9cba6e8ee79ce138847a293a2f9e0)) +* add ContentType to common package ([#401](https://github.com/standardnotes/snjs/issues/401)) ([1152c02](https://github.com/standardnotes/snjs/commit/1152c020e30e60996b4830b66e07ec4183bbac24)) +* add SN|Privileges to content types ([#444](https://github.com/standardnotes/snjs/issues/444)) ([0eee358](https://github.com/standardnotes/snjs/commit/0eee3581e5f9f41f227c824adc92a0e15b8fa4b4)) +* extract settings and common package ([#372](https://github.com/standardnotes/snjs/issues/372)) ([4f89688](https://github.com/standardnotes/snjs/commit/4f89688054cdae88c001287c9fb3431debd0136c)) +* remove legacy mfa ([#495](https://github.com/standardnotes/snjs/issues/495)) ([b0498f4](https://github.com/standardnotes/snjs/commit/b0498f4fad85367e1b57c6deacb5d313331bf8db)) +* upgrade node engine versions to latest active LTS ([#462](https://github.com/standardnotes/snjs/issues/462)) ([686fc15](https://github.com/standardnotes/snjs/commit/686fc15030d302b474ebb7ef1cd4dcc48ec42359)) diff --git a/packages/common/jest.config.js b/packages/common/jest.config.js new file mode 100644 index 000000000..ac920d85b --- /dev/null +++ b/packages/common/jest.config.js @@ -0,0 +1,19 @@ +// eslint-disable-next-line @typescript-eslint/no-var-requires +const base = require('../../jest.config'); + +module.exports = { + ...base, + globals: { + 'ts-jest': { + tsconfig: 'tsconfig.json', + }, + }, + coverageThreshold: { + global: { + branches: 14, + functions: 13, + lines: 14, + statements: 14 + } + } +}; diff --git a/packages/common/linter.tsconfig.json b/packages/common/linter.tsconfig.json new file mode 100644 index 000000000..c1a7d22c5 --- /dev/null +++ b/packages/common/linter.tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "./tsconfig.json", + "exclude": ["dist"] +} diff --git a/packages/common/package.json b/packages/common/package.json new file mode 100644 index 000000000..68bbd0b9d --- /dev/null +++ b/packages/common/package.json @@ -0,0 +1,39 @@ +{ + "name": "@standardnotes/common", + "version": "1.24.0", + "engines": { + "node": ">=16.0.0 <17.0.0" + }, + "description": "Common types and utilities for Standard Notes projects", + "main": "dist/src/index.js", + "author": "Standard Notes", + "types": "dist/src/index.d.ts", + "files": [ + "dist/src/**/*.js", + "dist/src/**/*.d.ts" + ], + "publishConfig": { + "access": "public" + }, + "license": "AGPL-3.0-or-later", + "scripts": { + "clean": "rm -fr dist", + "prestart": "yarn clean", + "start": "tsc -p tsconfig.json --watch", + "prebuild": "yarn clean", + "build": "tsc -p tsconfig.json", + "lint": "eslint . --ext .ts", + "test:unit": "jest spec --coverage" + }, + "devDependencies": { + "@types/jest": "^27.4.1", + "@types/node": "^18.0.0", + "@typescript-eslint/eslint-plugin": "^5.30.0", + "eslint-plugin-prettier": "^4.2.1", + "jest": "^27.5.1", + "ts-jest": "^27.1.3" + }, + "dependencies": { + "reflect-metadata": "^0.1.13" + } +} diff --git a/packages/common/src/Domain/Content/ContentDecoder.spec.ts b/packages/common/src/Domain/Content/ContentDecoder.spec.ts new file mode 100644 index 000000000..cdf738256 --- /dev/null +++ b/packages/common/src/Domain/Content/ContentDecoder.spec.ts @@ -0,0 +1,37 @@ +import 'reflect-metadata' + +import { ContentDecoder } from './ContentDecoder' + +describe('ContentDecoder', () => { + const createDecoder = () => new ContentDecoder() + + it('should decode content', () => { + const content = '000eyJmb28iOiJiYXIifQ==' + + expect(createDecoder().decode(content)).toEqual({ + foo: 'bar', + }) + }) + + it('should decode content without padding', () => { + const content = 'eyJmb28iOiJiYXIifQ==' + + expect(createDecoder().decode(content, 0)).toEqual({ + foo: 'bar', + }) + }) + + it('should encode content', () => { + expect( + createDecoder().encode({ + foo: 'bar', + }), + ).toEqual('000eyJmb28iOiJiYXIifQ==') + }) + + it('should return empty object on decoding failure', () => { + const content = '032400eyJmb28iOiJiYXIifQ==' + + expect(createDecoder().decode(content)).toEqual({}) + }) +}) diff --git a/packages/common/src/Domain/Content/ContentDecoder.ts b/packages/common/src/Domain/Content/ContentDecoder.ts new file mode 100644 index 000000000..ef0488a91 --- /dev/null +++ b/packages/common/src/Domain/Content/ContentDecoder.ts @@ -0,0 +1,23 @@ +import { ContentDecoderInterface } from './ContentDecoderInterface' + +export class ContentDecoder implements ContentDecoderInterface { + decode(content: string, leftPaddingLength = 3): Record { + try { + const contentToDecode = leftPaddingLength > 0 ? content.substring(leftPaddingLength) : content + const contentBuffer = Buffer.from(contentToDecode, 'base64') + const decodedContent = contentBuffer.toString() + + return JSON.parse(decodedContent) + } catch (error) { + return {} + } + } + + encode(content: Record, leftPaddingLength = 3): string | undefined { + const stringifiedContent = JSON.stringify(content) + + const encodedContent = Buffer.from(stringifiedContent).toString('base64') + + return encodedContent.padStart(encodedContent.length + leftPaddingLength, '0') + } +} diff --git a/packages/common/src/Domain/Content/ContentDecoderInterface.ts b/packages/common/src/Domain/Content/ContentDecoderInterface.ts new file mode 100644 index 000000000..61cdb3068 --- /dev/null +++ b/packages/common/src/Domain/Content/ContentDecoderInterface.ts @@ -0,0 +1,4 @@ +export interface ContentDecoderInterface { + decode(content: string, leftPaddingLength?: number): Record + encode(content: Record, leftPaddingLength?: number): string | undefined +} diff --git a/packages/common/src/Domain/Content/ContentType.ts b/packages/common/src/Domain/Content/ContentType.ts new file mode 100644 index 000000000..36d7a5a3d --- /dev/null +++ b/packages/common/src/Domain/Content/ContentType.ts @@ -0,0 +1,44 @@ +/* istanbul ignore file */ +export enum ContentType { + Any = '*', + Item = 'SF|Item', + RootKey = 'SN|RootKey|NoSync', + ItemsKey = 'SN|ItemsKey', + EncryptedStorage = 'SN|EncryptedStorage', + Privileges = 'SN|Privileges', + Note = 'Note', + Tag = 'Tag', + SmartView = 'SN|SmartTag', + Component = 'SN|Component', + Editor = 'SN|Editor', + ActionsExtension = 'Extension', + UserPrefs = 'SN|UserPreferences', + HistorySession = 'SN|HistorySession', + Theme = 'SN|Theme', + File = 'SN|File', + FilesafeCredentials = 'SN|FileSafe|Credentials', + FilesafeFileMetadata = 'SN|FileSafe|FileMetadata', + FilesafeIntegration = 'SN|FileSafe|Integration', + ExtensionRepo = 'SN|ExtensionRepo', + Unknown = 'Unknown', +} + +export function DisplayStringForContentType(contentType: ContentType): string | undefined { + const map: Partial> = { + [ContentType.ActionsExtension]: 'action-based extension', + [ContentType.Component]: 'component', + [ContentType.Editor]: 'editor', + [ContentType.File]: 'file', + [ContentType.FilesafeCredentials]: 'FileSafe credential', + [ContentType.FilesafeFileMetadata]: 'FileSafe file', + [ContentType.FilesafeIntegration]: 'FileSafe integration', + [ContentType.ItemsKey]: 'encryption key', + [ContentType.Note]: 'note', + [ContentType.SmartView]: 'smart view', + [ContentType.Tag]: 'tag', + [ContentType.Theme]: 'theme', + [ContentType.UserPrefs]: 'user preferences', + } + + return map[contentType] +} diff --git a/packages/common/src/Domain/DataType/AnyRecord.ts b/packages/common/src/Domain/DataType/AnyRecord.ts new file mode 100644 index 000000000..6a33aff0f --- /dev/null +++ b/packages/common/src/Domain/DataType/AnyRecord.ts @@ -0,0 +1,2 @@ +// eslint-disable-next-line @typescript-eslint/no-explicit-any +export type AnyRecord = Partial> diff --git a/packages/common/src/Domain/DataType/ApplicationIdentifier.ts b/packages/common/src/Domain/DataType/ApplicationIdentifier.ts new file mode 100644 index 000000000..20c51e9e3 --- /dev/null +++ b/packages/common/src/Domain/DataType/ApplicationIdentifier.ts @@ -0,0 +1 @@ +export type ApplicationIdentifier = string diff --git a/packages/common/src/Domain/DataType/MicrosecondsTimestamp.ts b/packages/common/src/Domain/DataType/MicrosecondsTimestamp.ts new file mode 100644 index 000000000..8723eab62 --- /dev/null +++ b/packages/common/src/Domain/DataType/MicrosecondsTimestamp.ts @@ -0,0 +1 @@ +export type MicrosecondsTimestamp = number diff --git a/packages/common/src/Domain/DataType/Uuid.ts b/packages/common/src/Domain/DataType/Uuid.ts new file mode 100644 index 000000000..3bf240f9d --- /dev/null +++ b/packages/common/src/Domain/DataType/Uuid.ts @@ -0,0 +1 @@ +export type Uuid = string diff --git a/packages/common/src/Domain/Email/EmailMessageIdentifier.ts b/packages/common/src/Domain/Email/EmailMessageIdentifier.ts new file mode 100644 index 000000000..d2e0cab9e --- /dev/null +++ b/packages/common/src/Domain/Email/EmailMessageIdentifier.ts @@ -0,0 +1,18 @@ +export enum EmailMessageIdentifier { + WELCOME_EMAIL = 'WELCOME_EMAIL', + ACCOUNT_CLAIM = 'ACCOUNT_CLAIM', + ACTIVATION_CODE = 'ACTIVATION_CODE', + VERSION_ADOPTION_REPORT = 'VERSION_ADOPTION_REPORT', + FAILED_DROPBOX_BACKUP = 'FAILED_DROPBOX_BACKUP', + FAILED_GOOGLE_DRIVE_BACKUP = 'FAILED_GOOGLE_DRIVE_BACKUP', + FAILED_ONE_DRIVE_BACKUP = 'FAILED_ONE_DRIVE_BACKUP', + DATA_BACKUP = 'DATA_BACKUP', + FAILED_BACKUP_ATTACHMENT_TOO_BIG = 'FAILED_BACKUP_ATTACHMENT_TOO_BIG', + OFFLINE_SUBSCRIPTION_ACCESS = 'OFFLINE_SUBSCRIPTION_ACCESS', + SIGN_IN = 'SIGN_IN', + SHARED_SUBSCRIPTION_INVITATION = 'SHARED_SUBSCRIPTION_INVITATION', + ENCOURAGE_EMAIL_BACKUPS = 'ENCOURAGE_EMAIL_BACKUPS', + ENCOURAGE_SUBSCRIPTION_PURCHASING = 'ENCOURAGE_SUBSCRIPTION_PURCHASING', + EXIT_INTERVIEW = 'EXIT_INTERVIEW', + MARKETING_CAMPAIGN_FILES = 'MARKETING_CAMPAIGN_FILES', +} diff --git a/packages/common/src/Domain/Error/ErrorTag.ts b/packages/common/src/Domain/Error/ErrorTag.ts new file mode 100644 index 000000000..f912e4c0c --- /dev/null +++ b/packages/common/src/Domain/Error/ErrorTag.ts @@ -0,0 +1,12 @@ +/* istanbul ignore file */ +export enum ErrorTag { + MfaInvalid = 'mfa-invalid', + MfaRequired = 'mfa-required', + RefreshTokenInvalid = 'invalid-refresh-token', + RefreshTokenExpired = 'expired-refresh-token', + AccessTokenExpired = 'expired-access-token', + ParametersInvalid = 'invalid-parameters', + RevokedSession = 'revoked-session', + AuthInvalid = 'invalid-auth', + ReadOnlyAccess = 'read-only-access', +} diff --git a/packages/common/src/Domain/KeyParams/AnyKeyParamsContent.ts b/packages/common/src/Domain/KeyParams/AnyKeyParamsContent.ts new file mode 100644 index 000000000..bf955eabd --- /dev/null +++ b/packages/common/src/Domain/KeyParams/AnyKeyParamsContent.ts @@ -0,0 +1,6 @@ +import { KeyParamsContent001 } from './KeyParamsContent001' +import { KeyParamsContent002 } from './KeyParamsContent002' +import { KeyParamsContent003 } from './KeyParamsContent003' +import { KeyParamsContent004 } from './KeyParamsContent004' + +export type AnyKeyParamsContent = KeyParamsContent001 | KeyParamsContent002 | KeyParamsContent003 | KeyParamsContent004 diff --git a/packages/common/src/Domain/KeyParams/BaseKeyParams.ts b/packages/common/src/Domain/KeyParams/BaseKeyParams.ts new file mode 100644 index 000000000..ac52936ce --- /dev/null +++ b/packages/common/src/Domain/KeyParams/BaseKeyParams.ts @@ -0,0 +1,10 @@ +import { ProtocolVersion } from '../Protocol/ProtocolVersion' +import { KeyParamsOrigination } from './KeyParamsOrigination' + +export type BaseKeyParams = { + /** Seconds since creation date */ + created?: string + /** The event that lead to the creation of these params */ + origination?: KeyParamsOrigination + version: ProtocolVersion +} diff --git a/packages/common/src/Domain/KeyParams/KeyParamsContent001.ts b/packages/common/src/Domain/KeyParams/KeyParamsContent001.ts new file mode 100644 index 000000000..f348a5b2e --- /dev/null +++ b/packages/common/src/Domain/KeyParams/KeyParamsContent001.ts @@ -0,0 +1,8 @@ +import { BaseKeyParams } from './BaseKeyParams' + +export type KeyParamsContent001 = BaseKeyParams & { + email: string + pw_cost: number + pw_salt: string + pw_nonce: string +} diff --git a/packages/common/src/Domain/KeyParams/KeyParamsContent002.ts b/packages/common/src/Domain/KeyParams/KeyParamsContent002.ts new file mode 100644 index 000000000..accc57aaa --- /dev/null +++ b/packages/common/src/Domain/KeyParams/KeyParamsContent002.ts @@ -0,0 +1,8 @@ +import { BaseKeyParams } from './BaseKeyParams' + +export type KeyParamsContent002 = BaseKeyParams & { + email: string + pw_cost: number + pw_salt: string + pw_nonce: string +} diff --git a/packages/common/src/Domain/KeyParams/KeyParamsContent003.ts b/packages/common/src/Domain/KeyParams/KeyParamsContent003.ts new file mode 100644 index 000000000..2dc2491e4 --- /dev/null +++ b/packages/common/src/Domain/KeyParams/KeyParamsContent003.ts @@ -0,0 +1,6 @@ +import { BaseKeyParams } from './BaseKeyParams' + +export type KeyParamsContent003 = BaseKeyParams & { + identifier: string + pw_nonce: string +} diff --git a/packages/common/src/Domain/KeyParams/KeyParamsContent004.ts b/packages/common/src/Domain/KeyParams/KeyParamsContent004.ts new file mode 100644 index 000000000..347300228 --- /dev/null +++ b/packages/common/src/Domain/KeyParams/KeyParamsContent004.ts @@ -0,0 +1,6 @@ +import { BaseKeyParams } from './BaseKeyParams' + +export type KeyParamsContent004 = Required & { + identifier: string + pw_nonce: string +} diff --git a/packages/common/src/Domain/KeyParams/KeyParamsOrigination.ts b/packages/common/src/Domain/KeyParams/KeyParamsOrigination.ts new file mode 100644 index 000000000..2700f204c --- /dev/null +++ b/packages/common/src/Domain/KeyParams/KeyParamsOrigination.ts @@ -0,0 +1,8 @@ +export enum KeyParamsOrigination { + Registration = 'registration', + EmailChange = 'email-change', + PasswordChange = 'password-change', + ProtocolUpgrade = 'protocol-upgrade', + PasscodeCreate = 'passcode-create', + PasscodeChange = 'passcode-change', +} diff --git a/packages/common/src/Domain/Protocol/ProtocolVersion.ts b/packages/common/src/Domain/Protocol/ProtocolVersion.ts new file mode 100644 index 000000000..9b3f7068c --- /dev/null +++ b/packages/common/src/Domain/Protocol/ProtocolVersion.ts @@ -0,0 +1,56 @@ +export enum ProtocolVersion { + V001 = '001', + V002 = '002', + V003 = '003', + V004 = '004', +} + +export const ProtocolVersionLatest = ProtocolVersion.V004 + +/** The last protocol version to not use root-key based items keys */ +export const ProtocolVersionLastNonrootItemsKey = ProtocolVersion.V003 + +export const ProtocolExpirationDates: Partial> = Object.freeze({ + [ProtocolVersion.V001]: Date.parse('2018-01-01'), + [ProtocolVersion.V002]: Date.parse('2020-01-01'), +}) + +export function isProtocolVersionExpired(version: ProtocolVersion) { + const expireDate = ProtocolExpirationDates[version] + if (!expireDate) { + return false + } + + const expired = new Date().getTime() > expireDate + return expired +} + +export const ProtocolVersionLength = 3 + +export function protocolVersionFromEncryptedString(string: string): ProtocolVersion { + const version = string.substring(0, ProtocolVersionLength) as ProtocolVersion + if (Object.values(ProtocolVersion).includes(version)) { + return version + } + + throw Error(`Unrecognized protocol version ${version}`) +} + +/** + * -1 if a < b + * 0 if a == b + * 1 if a > b + */ +export function compareVersions(a: ProtocolVersion, b: ProtocolVersion): number { + const aNum = Number(a) + const bNum = Number(b) + return aNum - bNum +} + +export function leftVersionGreaterThanOrEqualToRight(a: ProtocolVersion, b: ProtocolVersion): boolean { + return compareVersions(a, b) >= 0 +} + +export function isVersionLessThanOrEqualTo(input: ProtocolVersion, compareTo: ProtocolVersion): boolean { + return compareVersions(input, compareTo) <= 0 +} diff --git a/packages/common/src/Domain/Role/PaidRoles.ts b/packages/common/src/Domain/Role/PaidRoles.ts new file mode 100644 index 000000000..64e5da94d --- /dev/null +++ b/packages/common/src/Domain/Role/PaidRoles.ts @@ -0,0 +1,4 @@ +/* istanbul ignore file */ +import { RoleName } from './RoleName' + +export const PaidRoles = [RoleName.CoreUser, RoleName.PlusUser, RoleName.ProUser] diff --git a/packages/common/src/Domain/Role/RoleName.ts b/packages/common/src/Domain/Role/RoleName.ts new file mode 100644 index 000000000..c2f98c1d4 --- /dev/null +++ b/packages/common/src/Domain/Role/RoleName.ts @@ -0,0 +1,7 @@ +/* istanbul ignore file */ +export enum RoleName { + CoreUser = 'CORE_USER', + PlusUser = 'PLUS_USER', + ProUser = 'PRO_USER', + FilesBetaUser = 'FILES_BETA_USER', +} diff --git a/packages/common/src/Domain/Subscription/SubscriptionName.ts b/packages/common/src/Domain/Subscription/SubscriptionName.ts new file mode 100644 index 000000000..4015de964 --- /dev/null +++ b/packages/common/src/Domain/Subscription/SubscriptionName.ts @@ -0,0 +1,5 @@ +/* istanbul ignore file */ +export enum SubscriptionName { + PlusPlan = 'PLUS_PLAN', + ProPlan = 'PRO_PLAN', +} diff --git a/packages/common/src/Domain/index.ts b/packages/common/src/Domain/index.ts new file mode 100644 index 000000000..05af127a3 --- /dev/null +++ b/packages/common/src/Domain/index.ts @@ -0,0 +1,20 @@ +export * from './Content/ContentType' +export * from './Content/ContentDecoder' +export * from './Content/ContentDecoderInterface' +export * from './DataType/AnyRecord' +export * from './DataType/MicrosecondsTimestamp' +export * from './DataType/Uuid' +export * from './DataType/ApplicationIdentifier' +export * from './Email/EmailMessageIdentifier' +export * from './Error/ErrorTag' +export * from './KeyParams/AnyKeyParamsContent' +export * from './KeyParams/BaseKeyParams' +export * from './KeyParams/KeyParamsContent001' +export * from './KeyParams/KeyParamsContent002' +export * from './KeyParams/KeyParamsContent003' +export * from './KeyParams/KeyParamsContent004' +export * from './KeyParams/KeyParamsOrigination' +export * from './Protocol/ProtocolVersion' +export * from './Role/PaidRoles' +export * from './Role/RoleName' +export * from './Subscription/SubscriptionName' diff --git a/packages/common/src/index.ts b/packages/common/src/index.ts new file mode 100644 index 000000000..920deacdb --- /dev/null +++ b/packages/common/src/index.ts @@ -0,0 +1 @@ +export * from './Domain' diff --git a/packages/common/tsconfig.json b/packages/common/tsconfig.json new file mode 100644 index 000000000..8d2588d39 --- /dev/null +++ b/packages/common/tsconfig.json @@ -0,0 +1,11 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "composite": true, + "outDir": "./dist", + }, + "include": [ + "src/**/*" + ], + "references": [] +} diff --git a/packages/domain-events/package.json b/packages/domain-events/package.json index e417fd246..76dd8349c 100644 --- a/packages/domain-events/package.json +++ b/packages/domain-events/package.json @@ -24,7 +24,7 @@ "test:unit": "jest spec --coverage --passWithNoTests" }, "dependencies": { - "@standardnotes/common": "^1.23.1", + "@standardnotes/common": "workspace:*", "@standardnotes/features": "^1.47.0", "@standardnotes/predicates": "workspace:*", "@standardnotes/security": "workspace:*", diff --git a/packages/files/package.json b/packages/files/package.json index 371cdabe4..f671b53b4 100644 --- a/packages/files/package.json +++ b/packages/files/package.json @@ -27,7 +27,7 @@ }, "dependencies": { "@sentry/node": "^7.3.0", - "@standardnotes/common": "^1.23.1", + "@standardnotes/common": "workspace:*", "@standardnotes/domain-events": "workspace:*", "@standardnotes/domain-events-infra": "workspace:*", "@standardnotes/security": "workspace:*", diff --git a/packages/predicates/package.json b/packages/predicates/package.json index f98230268..b9e88ff5f 100644 --- a/packages/predicates/package.json +++ b/packages/predicates/package.json @@ -33,7 +33,7 @@ "ts-jest": "^27.1.3" }, "dependencies": { - "@standardnotes/common": "^1.23.1", + "@standardnotes/common": "workspace:*", "reflect-metadata": "^0.1.13" } } diff --git a/packages/scheduler/package.json b/packages/scheduler/package.json index f71db3110..395d757fa 100644 --- a/packages/scheduler/package.json +++ b/packages/scheduler/package.json @@ -26,7 +26,7 @@ "dependencies": { "@newrelic/winston-enricher": "^2.1.0", "@sentry/node": "^7.3.0", - "@standardnotes/common": "^1.23.1", + "@standardnotes/common": "workspace:*", "@standardnotes/domain-events": "workspace:*", "@standardnotes/domain-events-infra": "workspace:*", "@standardnotes/predicates": "workspace:*", diff --git a/packages/security/package.json b/packages/security/package.json index dc43dbfe9..b6b291db8 100644 --- a/packages/security/package.json +++ b/packages/security/package.json @@ -26,7 +26,7 @@ "test:unit": "jest spec --coverage" }, "dependencies": { - "@standardnotes/common": "^1.23.1", + "@standardnotes/common": "workspace:*", "jsonwebtoken": "^8.5.1", "reflect-metadata": "^0.1.13" }, diff --git a/packages/syncing-server/package.json b/packages/syncing-server/package.json index 66c27fa2b..3d8602be8 100644 --- a/packages/syncing-server/package.json +++ b/packages/syncing-server/package.json @@ -27,7 +27,7 @@ "@newrelic/winston-enricher": "^2.1.0", "@sentry/node": "^7.3.0", "@standardnotes/analytics": "workspace:*", - "@standardnotes/common": "^1.23.1", + "@standardnotes/common": "workspace:*", "@standardnotes/domain-events": "workspace:*", "@standardnotes/domain-events-infra": "workspace:*", "@standardnotes/payloads": "^1.5.1", diff --git a/tsconfig.json b/tsconfig.json index 3f2452d83..f2fe7c858 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -31,6 +31,9 @@ { "path": "./packages/auth" }, + { + "path": "./packages/common" + }, { "path": "./packages/domain-events" }, diff --git a/yarn.lock b/yarn.lock index bab691acf..ef7e89498 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2018,7 +2018,7 @@ __metadata: "@sentry/node": ^7.3.0 "@standardnotes/analytics": "workspace:*" "@standardnotes/api": ^1.1.19 - "@standardnotes/common": ^1.23.1 + "@standardnotes/common": "workspace:*" "@standardnotes/domain-events": "workspace:*" "@standardnotes/domain-events-infra": "workspace:*" "@standardnotes/features": ^1.47.0 @@ -2079,12 +2079,19 @@ __metadata: languageName: node linkType: hard -"@standardnotes/common@npm:^1.19.1, @standardnotes/common@npm:^1.23.1": - version: 1.23.1 - resolution: "@standardnotes/common@npm:1.23.1" - checksum: f498f4c469f7b9cdfc08b7648077832a2a214d844f012d02d73c2c418fab221af3302570cc6b1957b5ed481b55237f95bc24fc5c231162bfcdf8730333d38405 - languageName: node - linkType: hard +"@standardnotes/common@^1.19.1, @standardnotes/common@^1.23.1, @standardnotes/common@workspace:*, @standardnotes/common@workspace:packages/common": + version: 0.0.0-use.local + resolution: "@standardnotes/common@workspace:packages/common" + dependencies: + "@types/jest": ^27.4.1 + "@types/node": ^18.0.0 + "@typescript-eslint/eslint-plugin": ^5.30.0 + eslint-plugin-prettier: ^4.2.1 + jest: ^27.5.1 + reflect-metadata: ^0.1.13 + ts-jest: ^27.1.3 + languageName: unknown + linkType: soft "@standardnotes/config@npm:2.4.3": version: 2.4.3 @@ -2124,7 +2131,7 @@ __metadata: version: 0.0.0-use.local resolution: "@standardnotes/domain-events@workspace:packages/domain-events" dependencies: - "@standardnotes/common": ^1.23.1 + "@standardnotes/common": "workspace:*" "@standardnotes/features": ^1.47.0 "@standardnotes/predicates": "workspace:*" "@standardnotes/security": "workspace:*" @@ -2168,7 +2175,7 @@ __metadata: resolution: "@standardnotes/files-server@workspace:packages/files" dependencies: "@sentry/node": ^7.3.0 - "@standardnotes/common": ^1.23.1 + "@standardnotes/common": "workspace:*" "@standardnotes/config": 2.4.3 "@standardnotes/domain-events": "workspace:*" "@standardnotes/domain-events-infra": "workspace:*" @@ -2242,7 +2249,7 @@ __metadata: version: 0.0.0-use.local resolution: "@standardnotes/predicates@workspace:packages/predicates" dependencies: - "@standardnotes/common": ^1.23.1 + "@standardnotes/common": "workspace:*" "@types/jest": ^27.4.1 "@typescript-eslint/eslint-plugin": ^5.30.0 eslint-plugin-prettier: ^4.2.1 @@ -2269,7 +2276,7 @@ __metadata: dependencies: "@newrelic/winston-enricher": ^2.1.0 "@sentry/node": ^7.3.0 - "@standardnotes/common": ^1.23.1 + "@standardnotes/common": "workspace:*" "@standardnotes/domain-events": "workspace:*" "@standardnotes/domain-events-infra": "workspace:*" "@standardnotes/predicates": "workspace:*" @@ -2300,7 +2307,7 @@ __metadata: version: 0.0.0-use.local resolution: "@standardnotes/security@workspace:packages/security" dependencies: - "@standardnotes/common": ^1.23.1 + "@standardnotes/common": "workspace:*" "@types/jest": ^27.4.1 "@types/jsonwebtoken": ^8.5.8 "@typescript-eslint/eslint-plugin": ^5.30.0 @@ -2381,7 +2388,7 @@ __metadata: "@newrelic/winston-enricher": ^2.1.0 "@sentry/node": ^7.3.0 "@standardnotes/analytics": "workspace:*" - "@standardnotes/common": ^1.23.1 + "@standardnotes/common": "workspace:*" "@standardnotes/domain-events": "workspace:*" "@standardnotes/domain-events-infra": "workspace:*" "@standardnotes/payloads": ^1.5.1